diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt
index 5cb353d847429b22e148a80393e0c95e6f20c87c..8e91801b935a251cd8ef36978c3d26e672fb4df1 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt
@@ -52,4 +52,7 @@ atlas_add_component( TrigEgammaAnalysisTools
 atlas_install_headers( TrigEgammaAnalysisTools )
 atlas_install_python_modules( python/TrigEgamma*.py )
 atlas_install_joboptions( share/test*.py )
+atlas_install_generic( macros/trigEgammaDQ.py macros/get_trigEgammaDQ.sh 
+                        DESTINATION share/bin
+                        EXECUTABLE )
 
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx
index 84111ca63e99d33047a4145f0328c764baa0ddb7..91bcb7180cd6d29ce1dd6c04214a8c8fd25ae429 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx
@@ -458,6 +458,36 @@ bool TrigEgammaAnalysisBaseTool::isIsolated(const xAOD::Electron *eg, const std:
   return false;
 }
 
+// Check for Prescale at L1 and HLT
+// Check for Rerun decision
+bool TrigEgammaAnalysisBaseTool::isPrescaled(const std::string trigger){
+
+    bool efprescale=false;
+    bool l1prescale=false;
+    bool prescale=false;
+    bool rerun=true; //assume rerun for l1
+    std::string l1item="";
+
+    if(boost::starts_with(trigger, "L1" ))
+        l1item=trigger;
+    if(boost::starts_with(trigger,"HLT")){
+        l1item = getL1Item(trigger);
+        const unsigned int bit=tdt()->isPassedBits(trigger);
+        efprescale=bit & TrigDefs::EF_prescaled;
+        rerun=bit&TrigDefs::EF_resurrected; //Rerun, only check for HLT
+    }
+
+    const unsigned int l1bit=tdt()->isPassedBits(l1item);
+    bool l1_afterpre=l1bit&TrigDefs::L1_isPassedAfterPrescale;
+    bool l1_beforepre=l1bit&TrigDefs::L1_isPassedBeforePrescale;
+    l1prescale=l1_beforepre && !l1_afterpre;
+
+    prescale=efprescale || l1prescale;
+    if(rerun) return false; // Rerun use the event
+    if(prescale) return true; // Prescaled, reject event
+    return false; // Not prescaled, use event
+}
+
 float TrigEgammaAnalysisBaseTool::dR(const float eta1, const float phi1, const float eta2, const float phi2){
     float deta = fabs(eta1 - eta2);
     float dphi = fabs(phi1 - phi2) < TMath::Pi() ? fabs(phi1 - phi2) : 2*TMath:: \
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx
index f86fd147dfd5defe150caf7719507fd939abddf1..b3483ef25ec3eda962180f51e6aa1c9d1bf0e304 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx
@@ -91,27 +91,28 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i
         ATH_MSG_DEBUG("Distributions:: Retrieve features for chain " << info.trigName << " type " << info.trigType << l1trig);
         const auto fcl1 = (tdt()->features(l1trig, TrigDefs::alsoDeactivateTEs));
         const auto fc = (tdt()->features(info.trigName, TrigDefs::alsoDeactivateTEs));
-        if(m_detailedHists){
-            const auto initRois = fcl1.get<TrigRoiDescriptor>();
-            ATH_MSG_DEBUG("Size of initialRoI" << initRois.size());
-            for(const auto feat : initRois){
-                if(feat.te()==NULL) {
-                    ATH_MSG_DEBUG("initial RoI feature NULL");
-                    continue;
-                }
-                const TrigRoiDescriptor *roi = feat.cptr();
+        const auto initRois = fcl1.get<TrigRoiDescriptor>();
+        ATH_MSG_DEBUG("Size of initialRoI" << initRois.size());
+        for(const auto feat : initRois){
+            if(feat.te()==NULL) {
+                ATH_MSG_DEBUG("initial RoI feature NULL");
+                continue;
+            }
+            const TrigRoiDescriptor *roi = feat.cptr();
+            cd(dir+"HLT");
+            hist1("rejection")->Fill("L1Calo",1);
+            if(m_detailedHists){               
                 cd(dir+"RoI");
                 hist1("roi_eta")->Fill(roi->eta());
                 hist1("roi_phi")->Fill(roi->phi());
                 auto itEmTau = tdt()->ancestor<xAOD::EmTauRoI>(feat);
                 const xAOD::EmTauRoI *l1 = itEmTau.cptr();
                 if(l1==NULL) continue;
-                cd(dir+"HLT");
-                hist1("rejection")->Fill("L1Calo",1);
                 fillL1Calo(dir+"L1Calo",l1);
             }
         }
 
+        // Only fill distributions for TP triggers 
         if(m_tp){
             if(info.trigType=="electron"){
                 const auto vec_el = fc.get<xAOD::ElectronContainer>("egamma_Electrons",TrigDefs::alsoDeactivateTEs);
@@ -136,29 +137,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i
                     }
                 }
             }
-            else if(info.trigType=="photon"){
-                const auto vec_ph = fc.get<xAOD::PhotonContainer>("egamma_Photons",TrigDefs::alsoDeactivateTEs);
-                for (const auto feat : vec_ph){
-                    if(feat.te()==NULL) continue;
-                    const auto* cont = getFeature<xAOD::PhotonContainer>(feat.te());
-                    const auto *bits = getFeature<TrigPassBits>(feat.te());
-                    if(cont==NULL) continue;
-                    cd(dir+"HLT");
-                    if(ancestorPassed<xAOD::PhotonContainer>(feat.te()))
-                        hist1("rejection")->Fill("HLT",1);
-                    for(const auto& obj : *cont){
-                        // Only consider passing objects
-                        if(!obj) continue;
-                        if(bits==NULL){
-                            fillShowerShapes(dir+"HLT",obj); // Fill HLT shower shapes
-                        }
-                        // Only consider passing objects if bits available
-                        else if(!HLT::isPassing(bits,obj,cont)) continue;
-                        fillShowerShapes(dir+"HLT",obj); // Fill HLT shower shapes
-                    }
-                }
-            }
-            else ATH_MSG_WARNING("Chain type not specified");
+            else ATH_MSG_WARNING("Chain type not Electron for TP Trigger");
         }
         else {
             const auto vec_l2em = fc.get<xAOD::TrigEMCluster>("",TrigDefs::alsoDeactivateTEs);
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx
index 2ffcee1dd73bd03d67f1da571bcae1fc5b570902..372088822a0161e3db11b2114bbc407aad99444e 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx
@@ -75,8 +75,8 @@ StatusCode TrigEgammaNavAnalysisTool::childExecute(){
 
     cd(m_dir+"/Expert/Event");
     if( !TrigEgammaNavBaseTool::EventWiseSelection() ) {
-        ATH_MSG_DEBUG("Unable to retrieve offline containers");
-        return StatusCode::FAILURE;
+        ATH_MSG_DEBUG("Fails EventWise selection");
+        return StatusCode::SUCCESS; //return nicely
     }
 
     TrigEgammaAnalysisBaseTool::calculatePileupPrimaryVertex();
@@ -86,6 +86,7 @@ StatusCode TrigEgammaNavAnalysisTool::childExecute(){
         ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger 
                 << " " << getTrigInfo(trigger).trigName); 
 
+        if(isPrescaled(trigger)) continue; //Account for L1 and HLT prescale discard event
         // Trigger counts
         cd(m_dir+"/Expert/Event");
         if(tdt()->isPassed(trigger)) hist1(m_anatype+"_trigger_counts")->AddBinContent(ilist+1);
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx
index 405a1b0617ef691ac12ec995290447acd7c92bb5..12ebf094755c7b3a9016f59cb53cf16fd14d3cd0 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx
@@ -101,6 +101,12 @@ bool TrigEgammaNavBaseTool::EventWiseSelection( ){
     m_eventInfo=0;
     m_truthContainer = 0;
 
+    // Check HLTResult
+    if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){
+        ATH_MSG_WARNING("HLTResult truncated, skip event");
+        return false;
+    }
+    
     if ( (m_storeGate->retrieve(m_eventInfo, "EventInfo")).isFailure() ){
         ATH_MSG_WARNING("Failed to retrieve eventInfo ");
         return false;
@@ -123,7 +129,8 @@ bool TrigEgammaNavBaseTool::EventWiseSelection( ){
         ATH_MSG_WARNING("Failed to retrieve offline Photons ");
         return false; 
     }
-    
+
+
     for(const auto& eg : *m_offElectrons ){
         ATH_MSG_DEBUG("ApplyElectronPid...");
         if(ApplyElectronPid(eg,"Loose")) hist1(m_anatype+"_electrons")->AddBinContent(1);
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx
index a578124061eb9aeb418e01233de998794434c8c5..01506c6bf1605396557adc2766232513e220a7c8 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx
@@ -144,6 +144,7 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute()
 
     for(unsigned int ilist = 0; ilist != m_trigList.size(); ilist++) {
         std::string probeTrigger = m_trigList.at(ilist);
+        if(isPrescaled(probeTrigger)) continue; //Account for L1 and HLT prescale, discard event
         const char * cprobeTrigger = m_trigList.at(ilist).c_str();
         ATH_MSG_DEBUG("Start Chain Analysis ============================= " << probeTrigger);
         cd(m_dir+"/Expert/Event");
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx
index 8546220fd8844f73c2fc162ef7da96546fa5884e..337a192db7ec75641e22521f7e78e0a53d7cd370 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx
@@ -114,16 +114,17 @@ bool TrigEgammaNavTPBaseTool::EventWiseSelection(){
     m_jets = 0;
     m_truthContainer=0;
 
-    if ( (m_storeGate->retrieve(m_eventInfo, "EventInfo")).isFailure() ){
-        ATH_MSG_WARNING("Failed to retrieve eventInfo ");
+    // Check HLTResult
+    if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){
+        ATH_MSG_WARNING("HLTResult truncated, skip event");
         return false;
     }
-
-    if (m_eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error) {
-        ATH_MSG_DEBUG("Event not passing LAr");
+    
+    if ( (m_storeGate->retrieve(m_eventInfo, "EventInfo")).isFailure() ){
+        ATH_MSG_WARNING("Failed to retrieve eventInfo ");
         return false;
     }
-
+    
     if(m_storeGate->contains<xAOD::TruthParticleContainer>("egammaTruthParticles")){
       if(m_storeGate->retrieve(m_truthContainer,"egammaTruthParticles").isFailure()){
         ATH_MSG_WARNING("Could not retrieve xAOD::TruthParticleContainer 'egammaTruthParticles'");
@@ -131,6 +132,11 @@ bool TrigEgammaNavTPBaseTool::EventWiseSelection(){
       }
     }// protection
 
+    if (m_eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error) {
+        ATH_MSG_DEBUG("Event not passing LAr");
+        return false;
+    }
+    
     hist1(m_anatype+"_CutCounter")->Fill("LAr",1);
     
     if ( (m_storeGate->retrieve(m_offElectrons,m_offElContKey)).isFailure() ){
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h
index fd0933a22a9d92d915833d99254023ad5b010060..ea600877c84ef52406354b5c9c5430aa008d991f 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h
@@ -101,6 +101,7 @@ protected:
 
   /*! Check if electron fulfils isolation criteria */
   bool isIsolated(const xAOD::Electron*, const std::string);
+  bool isPrescaled(const std::string); 
 
   std::string getProbePid(const std::string);// {return m_offProbeTightness;}
   /*! book common histograms for analysis */
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements
index 9719baba1aabba502d9edaaa92fd58d1fa625431..9d61d53dd43122880344bd1d35862ff1ef766701 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements
@@ -44,6 +44,6 @@ end_private
 
 apply_pattern declare_joboptions files="test*.py"
 apply_pattern declare_python_modules files="TrigEgamma*.py"
-
+apply_pattern generic_declare_for_link kind=binaries files="-s=../macros trigEgammaDQ.py get_trigEgammaDQ.sh" prefix=share/bin
 library TrigEgammaAnalysisTools *.cxx ../Root/*.cxx -s=components *.cxx
 apply_pattern component_library
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/AtlasStyle.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/AtlasStyle.py
index 87d793441dd2076ecbb45d3f1febabc8d86679b8..a254e605e4ebf400404a268770eadd4162c2f142 100644
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/AtlasStyle.py
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/AtlasStyle.py
@@ -24,8 +24,8 @@ def AtlasStyle():
   atlasStyle.SetPaperSize(20,26)
 
   # set margin sizes
-  atlasStyle.SetPadTopMargin(0.05)
-  atlasStyle.SetPadRightMargin(0.05)
+  atlasStyle.SetPadTopMargin(0.07)
+  atlasStyle.SetPadRightMargin(0.09)
   atlasStyle.SetPadBottomMargin(0.16)
   atlasStyle.SetPadLeftMargin(0.16)
 
@@ -75,6 +75,7 @@ def AtlasStyle():
   # put tick marks on top and RHS of plots
   atlasStyle.SetPadTickX(1)
   atlasStyle.SetPadTickY(1)
+  atlasStyle.SetPalette(1)
   return atlasStyle
 
 from ROOT import TLatex, gPad
@@ -92,4 +93,24 @@ def ATLASLabel(x,y,text="Internal",color=1):
     p.SetTextFont(42);
     p.SetTextColor(color);
     p.DrawLatex(x+delx,y,text);
-    #    p.DrawLatex(x,y,"#sqrt{s}=900GeV");
\ No newline at end of file
+    #p.DrawLatex(x,y,"#sqrt{s}=900GeV");
+
+def ATLASRunNumberLabel(x,y,runnumber,color=1):
+    l = TLatex()
+    l.SetNDC();
+    l.SetTextFont(42);
+    l.SetTextSize(0.045);
+    l.SetTextColor(color);
+    dely = 0.115*472*gPad.GetWh()/(506*gPad.GetWw());
+    label="Run " + runnumber
+    l.DrawLatex(x,y-dely,label);
+
+def ATLASLumiLabel(x,y,lumi="78",color=1):   
+    l = TLatex()
+    l.SetNDC();
+    l.SetTextFont(42);
+    l.SetTextSize(0.045);
+    l.SetTextColor(color);
+    dely = 0.115*472*gPad.GetWh()/(506*gPad.GetWw());
+    label="Data 2016, #sqrt{s}=13 TeV, "+lumi+" pb^{-1}"
+    l.DrawLatex(x,y-dely,label);
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/getHistograms.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/getHistograms.py
deleted file mode 100644
index e558a69730f7867a51ea4d0a1d0813a0322b1b21..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/getHistograms.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-
-from ROOT import TFile, TH1F
-
-#########################################################################################
-def getTH1FsfromFile(ifile,triggerName,antype="Analysis",level="HLT"):
-        inputfile=ifile
-        histEffEt  = TH1F()
-        histEffEta = TH1F()
-        histEffPhi = TH1F()
-        histEffMu  = TH1F()
-        temp1 = TH1F()
-        temp2 = TH1F()
-        print "HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/match_et"
-        # et eff compututation
-        if False:
-            temp1 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/match_highet")
-            temp2 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/highet")
-        else:
-            temp1 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/match_et")
-            temp2 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/et")
-        histEffEt = temp1
-        histEffEt.Divide(temp1,temp2,1,1,"b")
-        # phi eff computation
-        temp1 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/match_eta")
-        temp2 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/eta")
-        histEffEta = temp1
-        histEffEta.Divide(temp1,temp2,1,1,"b")
-        # eta eff computation
-        temp1 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/match_phi")
-        temp2 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/phi")
-        histEffPhi = temp1
-        histEffPhi.Divide(temp1,temp2,1,1,"b")
-        # mu eff computation
-        temp1 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/match_mu")
-        temp2 = inputfile.Get("HLT/Egamma/"+antype+"/"+triggerName+"/Efficiency/"+level+"/mu")
-        histEffMu = temp1
-        histEffMu.Divide(temp1,temp2,1,1,"b")
-        # set axis labels
-        histEffEt.GetYaxis().SetTitle("#epsilon")
-        histEffEta.GetYaxis().SetTitle("#epsilon")
-        histEffEta.GetXaxis().SetTitle("#eta")
-        histEffPhi.GetYaxis().SetTitle("#epsilon")
-        histEffPhi.GetXaxis().SetTitle("#phi")
-        histEffMu.GetYaxis().SetTitle("#epsilon")
-        histEffMu.GetXaxis().SetTitle("#mu")
-        return histEffEt, histEffEta, histEffPhi, histEffMu
-
-# for Distributions (also Eff if changed)
-def getSingleTH1F(ifile,triggerName,histoname,folder0="Analysis",folder1="Distributions",folder2="Offline"):
-    inputfile=ifile
-    print "HLT/Egamma/"+folder0+"/"+triggerName+"/"+folder1+"/"+folder2+"/"+histoname
-    histogram=inputfile.Get("HLT/Egamma/"+folder0+"/"+triggerName+"/"+folder1+"/"+folder2+"/"+histoname)
-    return histogram
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/get_trigEgammaDQ.sh b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/get_trigEgammaDQ.sh
new file mode 100644
index 0000000000000000000000000000000000000000..3050435e4ef69a46f3506730a9d1ada2d15aa5e6
--- /dev/null
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/get_trigEgammaDQ.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+display_usage() { 
+    echo -e "\nUsage:\n$0 [runNumber] [dataCampaign] [stream] \n" 
+} 
+if [  $# -le 0 ] 
+then 
+    display_usage
+    exit 1
+fi 
+if [ -z "$1" ]
+then
+    echo "No Run Number supplied"
+    exit 1
+fi
+
+run=${1}
+data="data16_13TeV"
+stream="physics_Main"
+if [ -z "$2" ]
+then
+    echo "No data campaign, using data16_13TeV"
+else
+    data=${2}
+fi
+if [ -z "$2" ]
+then
+    echo "No stream, using physics_Main"
+else
+    stream=${3}
+fi
+
+echo $run $data $stream
+source /afs/cern.ch/project/eos/installation/atlas/etc/setup.sh
+
+# BASE=/eos/atlas/atlastier0/rucio/data15_cos/express_express/00259416
+# DIR1=`eos ls ${BASE} | grep HIST.x`
+# FILETOCOPY=`eos ls ${BASE}/${DIR1} | grep HIST`
+# echo "TEST ${BASE}/${DIR1}/${FILETOCOPY}"
+# eos cp ${BASE}/${DIR1}/${FILETOCOPY} .
+
+# for file in `echo ${LIST}`
+# do
+BASE=/eos/atlas/atlastier0/rucio/${data}/${stream}/00${run}
+echo $BASE    
+DIR1=`eos ls ${BASE} | grep HIST.x`
+DIR2=`eos ls ${BASE} | grep HIST.f`
+echo $DIR1 $DIR2
+if [ -n "$DIR1" ]; then
+    FILETOCOPY=`eos ls ${BASE}/${DIR1} | grep HIST`
+    echo "TEST ${BASE}/${DIR1}/${FILETOCOPY}"
+    eos cp ${BASE}/${DIR1}/${FILETOCOPY} .
+else
+    FILETOCOPY=`eos ls ${BASE}/${DIR2} | grep HIST`
+    echo "TEST ${BASE}/${DIR2}/${FILETOCOPY}"
+    eos cp ${BASE}/${DIR2}/${FILETOCOPY} .
+fi    
+inputfile=`ls | grep HIST`
+hcg.exe ${inputfile} -d HLT/Egamma -r Egamma TREG --tag "reference = stream=physics_Main:CentrallyManagedReferences_Main;CentrallyManagedReferences" -ds "https://twiki.cern.ch/twiki/bin/view/Atlas/TrigEgammaDataQualityAndMonitoring" --deleteref > ${data}.${stream}.$run.config
+python trigEgammaDQ.py --file ${inputfile} --run ${run} --t0 True
+rm *.bak
+#tar -czf TrigEgammaDQArchive_Run_${run}.tar.gz ${data}.* *.C *.eps --remove-files
+
+
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotDistributions.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotDistributions.py
deleted file mode 100644
index 154d91cf3b50f055077fbb75ae6aef388be005c6..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotDistributions.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-# 
-# python plotDistributions.py -b -i histo.root -t e24_lhtight_iloose
-#
-
-from sys import argv, exit
-
-from ROOT import TFile, TH1F
-from ROOT import TCanvas, TLegend
-from ROOT import SetOwnership
-
-from AtlasStyle import *
-from getHistograms import *
-
-#########################################################################################
-### Main program
-#########################################################################################
-
-if(len(argv)<4):
-	print "usage: plotEfficiencies.py -b <root file> <trigger name> <folder> <file format>"
-	exit(2)
-elif(len(argv)==6):
-  filename = argv[2]
-  triggerName = argv[3]
-  folder = argv[4]
-  fileformat = argv[5]
-  if (folder!="TPAnalysis") or (folder!="Analysis"):
-    print "Last argument is wrong"
-  print "ROOT File : ", filename
-  print "Trigger name :", triggerName
-  inputfile = TFile(filename)
-else:
-    print "usage: plotEfficiencies.py -b <root file> <trigger name> <folder> <file format>"
-    exit(2)
-
-
-#SetAtlasStyle()
-Level1=[
-"pt","et",
-"eta","phi","e011",
-"e132","e237","e277",
-]
-Level2=["ethad","ethad1","weta1",
-"weta2","f1","f3",
-"e2tsts1","Reta","Rphi",
-]
-Level3=["Rhad","Rhad1","deta1",
-"deta2","dphi2","dphiresc",
-"d0","d0sig","eratio",
-]
-Level4=["eprobht","nscthits","npixhits",
-]
-
-EFCaloLevels=["energyBE0","energyBE1","energyBE2",
-"energyBE3","energy","eta",
-"phi","eta_calo","phi_calo",
-]
-
-L1CaloIdd=[
-"energy",
-"roi_et",
-"emIso",
-"hadCore",
-"eta",
-"phi",
-]
-
-L2ElectronIdd = ["trkClusDeta","trkClusDphi"]
-
-ListAll = [Level1,Level2,Level3,Level4,EFCaloLevels,L2ElectronIdd,L1CaloIdd]
-NameList = ['HLT','HLT','HLT','HLT','EFCalo','L2Electron','L1Calo']
-def makeCanvas(idd,idx,idy,level,type):
-	c=TCanvas()
-	c.Divide(idx,idy)
-	i=1
-	for histoname in idd:
-		h = getSingleTH1F(inputfile,triggerName,histoname,folder,type,level)
-		c.cd(i)
-		h.Draw()
-		i=i+1
-	return c
-
-# I want titles
-atlasStyle = AtlasStyle()
-atlasStyle.SetOptTitle(1)
-gROOT.SetStyle("ATLAS")
-gROOT.ForceStyle()
-
-name=triggerName+"_Distributions"+".ps"
-iname=0
-c1=TCanvas()
-c1.Print(name+"[")
-for ilist in ListAll:
-    c1 = makeCanvas(ilist,3,3,NameList[iname],"Distributions")
-    c1.Print(name)
-    if "HLT" in NameList[iname]:
-        c1 = makeCanvas(ilist,3,3,NameList[iname],"Resolutions")
-    c1.Print(name)
-    iname += 1
-
-c1.Print(name+"]"); 
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficiencies.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficiencies.py
deleted file mode 100644
index a7ed4668a5978f9efc76a2d225413032d3117996..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficiencies.py
+++ /dev/null
@@ -1,245 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-# 
-# python plotEfficiencies.py -b -i histo.root -t e24_lhtight_iloose
-#
-
-from sys import argv, exit
-import argparse
-
-parser = argparse.ArgumentParser()
-parser.add_argument('--file', type=str,help='input file')
-parser.add_argument('--folder', type=str,help='folder')
-parser.add_argument('--fileformat', type=str,help='filetype')
-parser.add_argument('--trigger', type=str,help='trigger')
-parser.add_argument('--trigger2', type=str,help='trigger to compare')
-args = parser.parse_args()
-
-import ROOT
-from ROOT import TFile, TH1F
-from ROOT import TCanvas, TLegend
-from ROOT import SetOwnership
-ROOT.gROOT.SetBatch(True)
-
-from AtlasStyle import *
-from getHistograms import *
-
-inputfile=TFile(args.file)
-triggerName=args.trigger
-triggerName2=args.trigger2
-folder=args.folder
-fileformat=args.fileformat
-
-#########################################################################################
-def makeCanvas(histo,title,triggerName,folder):
-	h = histo
-	leg = TLegend(0.5,0.2,0.9,0.30, "HLT "+folder)
-	leg.SetBorderSize(0)
-	leg.SetFillStyle(0)
-	leg.SetTextSize(0.04)
-	leg.AddEntry(h, triggerName,"l")
-	c = TCanvas("c","Efficiency")
-	h.Draw()
-	leg.Draw()
-	c.SetGrid()
-	ATLASLabel(0.2,0.2)
-	if folder=="TPAnalysis":
-		c.Print("plot_"+title+"_"+triggerName+"_TPAnalysis."+fileformat)
-	else:
-		c.Print("plot_"+title+"_"+triggerName+"_Analysis."+fileformat)
-
-def setPlots(plots):
-    colors=[1,2,1,2,4]
-    marker=[4,2,4,2,5]
-
-    icolor=0
-    for iplot in plots:
-         iplot.SetStats(False)
-         iplot.SetLineColor(colors[icolor])
-         iplot.SetMarkerStyle(marker[icolor])
-         iplot.SetMarkerSize(0.3)
-         iplot.SetMarkerColor(iplot.GetLineColor())
-         icolor+=1
-
-def produceCanvas(triggerName,folder,inputfile):
-
-        level_A = "L2"
-        level_B = "HLT"
-        level_C = "L1Calo"
-        level_D = "L2Calo"
-        level_E = "EFCalo"
-
-        histEffEt_A  = TH1F()
-        histEffEta_A = TH1F()
-        histEffPhi_A = TH1F()
-        histEffEt_B  = TH1F()
-        histEffEta_B = TH1F()
-        histEffPhi_B = TH1F()
-        histEffEt_C  = TH1F()
-        histEffEta_C = TH1F()
-        histEffPhi_C = TH1F()
-        histEffEt_D  = TH1F()
-        histEffEta_D = TH1F()
-        histEffPhi_D = TH1F()
-        histEffEt_E  = TH1F()
-        histEffEta_E = TH1F()
-        histEffPhi_E = TH1F()
-
-        histEffEt_A, histEffEta_A, histEffPhi_A, hMu_A = getTH1FsfromFile(inputfile,triggerName,folder,level_A)
-        histEffEt_B, histEffEta_B, histEffPhi_B, hMu_B = getTH1FsfromFile(inputfile,triggerName,folder,level_B)
-        histEffEt_C, histEffEta_C, histEffPhi_C, hMu_C = getTH1FsfromFile(inputfile,triggerName,folder,level_C)
-        histEffEt_D, histEffEta_D, histEffPhi_D, hMu_D = getTH1FsfromFile(inputfile,triggerName,folder,level_D)
-        histEffEt_E, histEffEta_E, histEffPhi_E, hMu_E = getTH1FsfromFile(inputfile,triggerName,folder,level_E)
-
-        effplots=[histEffEt_A,histEffEt_B,histEffEt_C,histEffEt_D,histEffEt_E]
-        etaplots=[histEffEta_A,histEffEta_B,histEffEta_C,histEffEta_D,histEffEta_E]
-        phiplots=[histEffPhi_A,histEffPhi_B,histEffPhi_C,histEffPhi_D,histEffPhi_E]
-        muplots=[hMu_A,hMu_B,hMu_C,hMu_D,hMu_E]
-
-        plots=[effplots,etaplots,phiplots,muplots]
-        for iplots in plots:
-            setPlots(iplots)
-
-        ####################
-        ## some customization to the range of phi effs
-
-        histEffEta_A.GetYaxis().SetRangeUser(0.75, 1)
-        histEffEta_B.GetYaxis().SetRangeUser(0.75, 1)
-        histEffEta_C.GetYaxis().SetRangeUser(0.75, 1)
-        histEffEta_D.GetYaxis().SetRangeUser(0.75, 1)
-
-        histEffPhi_A.GetYaxis().SetRangeUser(0.75, 1)
-        histEffPhi_B.GetYaxis().SetRangeUser(0.75, 1)
-        histEffPhi_C.GetYaxis().SetRangeUser(0.75, 1)
-        histEffPhi_D.GetYaxis().SetRangeUser(0.75, 1)
-        ##########################
-
-        canv = TCanvas("canv","Efficiency")
-        canv.Divide(4,4)
-
-        leg1 = TLegend(0.4,0.2,0.75,0.40, triggerName)
-        leg2 = TLegend(0.4,0.2,0.75,0.50, triggerName)
-        leg3 = TLegend(0.4,0.2,0.75,0.40, triggerName)
-        leg4 = TLegend(0.4,0.2,0.75,0.40, triggerName)
-        leg1.SetBorderSize(0)
-        leg2.SetBorderSize(0)
-        leg3.SetBorderSize(0)
-        leg4.SetBorderSize(0)
-        leg4.SetBorderSize(0)
-        leg1.SetTextSize(0.05)
-        leg2.SetTextSize(0.05)
-        leg3.SetTextSize(0.05)
-        leg4.SetTextSize(0.05)
-
-        leg1.AddEntry(histEffEt_A, "L2Efficiencies","l")
-        leg1.AddEntry(histEffEt_B, "HLTEfficiencies","l")
-
-        leg2.AddEntry(histEffEt_C, "L1CaloEfficiencies","l")
-        leg2.AddEntry(histEffEt_D, "L2CaloEfficiencies","l")
-        leg2.AddEntry(histEffEt_E, "EFCaloEfficiencies","l")
-
-        leg3.AddEntry(histEffEt_D, "L2CaloEfficiencies","l")
-        leg3.AddEntry(histEffEt_E, "EFCaloEfficiencies","l")
-        
-        leg4.AddEntry(histEffEt_C, "L1CaloEfficiencies","l")
-        
-        SetOwnership( leg1, 0 )   # 0 = release (not keep), 1 = keep
-        SetOwnership( leg2, 0 )   # 0 = release (not keep), 1 = keep
-        SetOwnership( leg3, 0 )   # 0 = release (not keep), 1 = keep
-        SetOwnership( leg4, 0 )   # 0 = release (not keep), 1 = keep
-
-        canv.cd(1)
-        histEffEt_A.Draw()
-        histEffEt_B.Draw("SAME")
-        leg1.Draw()
-
-        canv.cd(2)
-        histEffEta_A.Draw()
-        histEffEta_B.Draw("SAME")
-
-        canv.cd(3)
-        histEffPhi_A.Draw()
-        histEffPhi_B.Draw("SAME")
-
-        canv.cd(4)
-        hMu_A.Draw()
-        hMu_B.Draw("SAME")
-
-        canv.cd(5)
-        histEffEt_C.Draw()
-        histEffEt_D.Draw("SAME")
-        histEffEt_E.Draw("SAME")
-        leg2.Draw()
-
-        canv.cd(6)
-        histEffEta_C.Draw()
-        histEffEta_D.Draw("SAME")
-        histEffEta_E.Draw("SAME")
-
-        canv.cd(7)
-        histEffPhi_C.Draw()
-        histEffPhi_D.Draw("SAME")
-        histEffPhi_E.Draw("SAME")
-
-        canv.cd(9)
-        histEffEt_D.Draw()
-        histEffEt_E.Draw("SAME")
-        leg3.Draw()
-
-        canv.cd(10)
-        histEffEta_D.Draw()
-        histEffEta_E.Draw("SAME")
-
-        canv.cd(11)
-        histEffPhi_D.Draw()
-        histEffPhi_E.Draw("SAME")
-
-        canv.cd(13)
-        histEffEt_C.Draw()
-        leg4.Draw()
-
-        canv.cd(14)
-        histEffEta_C.Draw()
-
-        canv.cd(15)
-        histEffPhi_C.Draw()
-
-        for i in range(9):
-            canv.cd(i+1).SetGrid()
-            canv.cd(i+1).Update()
-
-        return canv
-#########################################################################################
-### Main program
-#########################################################################################
-
-
-
-SetAtlasStyle()
-
-name=triggerName+"_Efficiencies"+".ps"
-canv=TCanvas()
-canv.Print(name+"[")
-canv=produceCanvas(triggerName,folder,inputfile)           
-canv.Print(name)
-
-ineffNames=[['IsEmFailLoose','IsEmFailMedium','IsEmFailTight'],['IsEmLHFailLoose','IsEmLHFailMedium','IsEmLHFailTight']] 
-colors=[2,3,4]
-canv2=TCanvas()
-canv2.Divide(1,2)
-ipad=1
-for iname in ineffNames:
-    canv2.cd(ipad)
-    ic=0
-    for iplot in iname:
-        hist = getSingleTH1F(inputfile,triggerName,iplot,folder,"Efficiency","HLT")
-        hist.SetLineColor(colors[ic])
-        hist.Draw("SAME")
-        ic+=1
-    ipad+=1 
-
-canv2.Print(name)    
-canv2.Print(name+"]")    
-
-        
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficienciesCompDS.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficienciesCompDS.py
deleted file mode 100644
index b6d98e4616e560ce4d1b08e82ad1476908d94065..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficienciesCompDS.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-# 
-# plotEfficiencies.py -b <root file 1> <root file 2> <trigger name> <folder>
-#
-
-from sys import argv, exit
-
-from ROOT import TFile, TH1F
-from ROOT import TCanvas, TLegend
-from ROOT import SetOwnership
-
-from AtlasStyle import *
-from getHistograms import *
-
-#########################################################################################
-def makeCanvas(histo1,histo2,title,triggerName,folder):
-	h1 = histo1
-	h2 = histo2
-	h2.SetMarkerColor(2)
-	h2.SetLineColor(2)
-	leg = TLegend(0.5,0.2,0.9,0.30, "HLT "+folder+" - "+triggerName)
-	leg.SetBorderSize(0)
-	leg.SetFillStyle(0)
-	leg.SetTextSize(0.04)
-	leg.AddEntry(h1, filename1,"l")
-	leg.AddEntry(h2, filename2,"l")
-	c = TCanvas("c","Efficiency",800,600)
-	h1.Draw()
-	h2.Draw("SAME")
-	leg.Draw()
-	c.SetGrid()
-	ATLASLabel(0.2,0.2)
-	if folder=="TPAnalysis":
-		c.Print("plot_"+title+"_"+triggerName+"_TPAnalysis.pdf")
-	else:
-		c.Print("plot_"+title+"_"+triggerName+"_Analysis.pdf")
-
-
-#########################################################################################
-### Main program
-#########################################################################################
-
-if(len(argv)<5):
-	print "usage: plotEfficiencies.py -b <root file 1> <root file 2> <trigger name> <folder>"
-	exit(2)
-elif(len(argv)==5):
-  filename1 = argv[2]
-  filename2 = argv[3]
-  triggerName = argv[4]
-  folder = "Analysis"
-  print "ROOT File : ", filename1, filename2
-  print "Trigger name :", triggerName
-  inputfile1 = TFile(filename1)
-  inputfile2 = TFile(filename2)
-elif(len(argv)==6):
-  filename1 = argv[2]
-  filename2 = argv[3]
-  triggerName = argv[4]
-  folder = argv[5]
-  if (folder!="TPAnalysis") or (folder!="Analysis"):
-  	print "Last argument is wrong"
-  print "ROOT File : ", filename1, filename2
-  print "Trigger name :", triggerName
-  inputfile1 = TFile(filename1)
-  inputfile2 = TFile(filename2)
-else:
-    print "usage: plotEfficiencies.py -b <root file 1> <root file 2> <trigger name> <folder>"
-    exit(2)
-
-SetAtlasStyle()
-hEt1, hEta1, hPhi1, hMu1 = getTH1FsfromFile(inputfile1,triggerName,folder)
-hEt2, hEta2, hPhi2, hMu2 = getTH1FsfromFile(inputfile2,triggerName,folder)
-makeCanvas(hEt1,hEt2,"Et",triggerName,folder)
-makeCanvas(hEta1,hEta2,"Eta",triggerName,folder)
-makeCanvas(hPhi1,hPhi2,"Phi",triggerName,folder)
-makeCanvas(hMu1,hMu2,"Mu",triggerName,folder)
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficienciesCompTriggers.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficienciesCompTriggers.py
deleted file mode 100644
index f9fbcfe4a8eb6682b071d962f0ff0bae4e4b3c68..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotEfficienciesCompTriggers.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-# 
-# plotEfficiencies.py -b <root file 1> <trigger name 1> <trigger name 2> <folder>"
-#
-
-from sys import argv, exit
-
-from ROOT import TFile, TH1F
-from ROOT import TCanvas, TLegend
-from ROOT import SetOwnership
-
-from AtlasStyle import *
-from getHistograms import *
-
-
-#########################################################################################
-def makeCanvas(histo1,histo2,title,triggerName1,triggerName2,folder):
-	h1 = histo1
-	h2 = histo2
-	h2.SetMarkerColor(2)
-	h2.SetLineColor(2)
-	leg = TLegend(0.5,0.2,0.9,0.30, "HLT "+folder+" - ")
-	leg.SetBorderSize(0)
-	leg.SetFillStyle(0)
-	leg.SetTextSize(0.04)
-	leg.AddEntry(h1, triggerName1,"l")
-	leg.AddEntry(h2, triggerName2,"l")
-	c = TCanvas("c","Efficiency",800,600)
-	h1.Draw()
-	h2.Draw("SAME")
-	leg.Draw()
-	c.SetGrid()
-	ATLASLabel(0.2,0.2)
-	if folder=="TPAnalysis":
-		c.Print("plot_"+title+"_"+triggerName1+"_"+triggerName2+"_TPAnalysis.pdf")
-	else:
-		c.Print("plot_"+title+"_"+triggerName1+"_"+triggerName2+"_Analysis.pdf")
-
-
-#########################################################################################
-### Main program
-#########################################################################################
-
-if(len(argv)<5):
-	print "usage: plotEfficiencies.py -b <root file 1> <trigger name 1> <trigger name 2> <folder>"
-	exit(2)
-elif(len(argv)==5):
-  filename1 = argv[2]
-  triggerName1 = argv[3]
-  triggerName2 = argv[4]
-  folder = "Analysis"
-  print "ROOT File : ", filename1
-  print "Trigger name :", triggerName1, triggerName2
-  inputfile1 = TFile(filename1)
-elif(len(argv)==6):
-  filename1 = argv[2]
-  triggerName1 = argv[3]
-  triggerName2 = argv[4]
-  folder = argv[5]
-  if (folder!="TPAnalysis") or (folder!="Analysis"):
-  	print "Last argument is wrong"
-  print "ROOT File : ", filename1
-  print "Trigger name :", triggerName1,triggerName2
-  inputfile1 = TFile(filename1)
-else:
-    print "usage: plotEfficiencies.py -b <root file 1> <trigger name 1> <trigger name 2> <folder>"
-    exit(2)
-
-SetAtlasStyle()
-hEt1, hEta1, hPhi1, hMu1 = getTH1FsfromFile(inputfile1,triggerName1,folder)
-hEt2, hEta2, hPhi2, hMu2 = getTH1FsfromFile(inputfile1,triggerName2,folder)
-makeCanvas(hEt1,hEt2,"Et",triggerName1,triggerName2,folder)
-makeCanvas(hEta1,hEta2,"Eta",triggerName1,triggerName2,folder)
-makeCanvas(hPhi1,hPhi2,"Phi",triggerName1,triggerName2,folder)
-makeCanvas(hMu1,hMu2,"Mu",triggerName1,triggerName2,folder)
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotExtras.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotExtras.py
deleted file mode 100644
index 2fe16583636da63b85b583bc810081e00afe2ebf..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotExtras.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-# 
-# python plotDistributions.py -b -i histo.root -t e24_lhtight_iloose
-#
-
-from sys import argv, exit
-
-from ROOT import TFile, TH1F
-from ROOT import TCanvas, TLegend
-from ROOT import SetOwnership
-
-from AtlasStyle import *
-from getHistograms import *
-
-#########################################################################################
-### Main program
-#########################################################################################
-
-if(len(argv)<4):
-	print "usage: plotEfficiencies.py -b <root file> <trigger name> <folder> <file format>"
-	exit(2)
-elif(len(argv)==5):
-  filename = argv[2]
-  folder = argv[3]
-  fileformat = argv[4]
-  if (folder!="TPAnalysis") or (folder!="Analysis"):
-    print "Last argument is wrong"
-  print "ROOT File : ", filename
-  inputfile = TFile(filename)
-else:
-    print "usage: plotEfficiencies.py -b <root file> <trigger name> <folder> <file format>"
-    exit(2)
-
-#SetAtlasStyle()
-# I want titles
-#atlasStyle = AtlasStyle()
-#atlasStyle.SetOptTitle(1)
-#gROOT.SetStyle("ATLAS")
-#gROOT.ForceStyle()
-
-basePath1="HLT/Egamma/Analysis/"
-basePath2="HLT/Egamma/TPAnalysis/"
-plots=["hlt_el_et","l1_rot_et"]
-tpplots=["nProbes","nProbesL1","nProbesL2Calo","nProbesEFCalo","nProbesHLT","EffL1","EffL2","EffEFCalo","EffHLT"]
-name="Analysis_Event"+".ps"
-c=TCanvas()
-c.Print(name+"[")
-c=TCanvas()
-c.SetBottomMargin(0.5)
-print basePath1+"trigger_counts"
-h=inputfile.Get(basePath1+"trigger_counts")
-h.SetStats(0)
-h.GetXaxis().SetTitle("")
-h.Draw()
-c.Print(name)
-h=inputfile.Get(basePath1+"electrons")
-h.Draw()
-c.Print(name)
-for iplot in tpplots:
-    print basePath2+"/"+iplot
-    h=inputfile.Get(basePath2+"/"+iplot)
-    h.SetStats(0)
-    h.GetXaxis().SetTitle("")
-    h.Draw()
-    c.Print(name)
-c2=TCanvas()
-c2.Divide(2,2)
-c2.cd(1)
-h=inputfile.Get(basePath1+"hlt_el_et")
-h.Draw()
-c2.cd(2)
-h=inputfile.Get(basePath1+"l1_roi_et")
-h.Draw()
-c2.cd(3)
-h=inputfile.Get(basePath1+"hlt_el_eta_phi")
-h.Draw("colz")
-c2.cd(4)
-h=inputfile.Get(basePath1+"l1_eta_phi")
-h.Draw("colz")
-c2.Print(name)
-c.Print(name+"]"); 
-
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotPerformance.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotPerformance.py
deleted file mode 100644
index de6d644e4bbec42e9961357490a08c43991457ca..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/plotPerformance.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-# 
-# python plotEfficiencies.py -b -i histo.root -t e24_lhtight_iloose
-#
-
-from sys import argv, exit
-import argparse
-
-parser = argparse.ArgumentParser()
-parser.add_argument('--file', type=str,help='input file')
-parser.add_argument('--folder', type=str,choices=["Analysis","TPAnalysis"],help='folder: Analysis or TPAnalysis')
-parser.add_argument('--fileformat', type=str,help='filetype: eps, pdf, ps, ...')
-parser.add_argument('--trigger', type=str,help='trigger')
-parser.add_argument('--trigger2', type=str,help='trigger to compare')
-parser.add_argument('--hist',type=str,choices=["HLT:et","eta","phi","Reta",
-    "Rhad","Rhad1","Rphi","charge",
-    "d0","d0sig","deta1","deta2","dphi2",
-    "dphiresc","e011","e132","e237","e277",
-    "e2tsts1","eprobht","eratio","ethad","ethad1",
-    "f1","f3","npixhits","nscthits","weta1","weta2",
-    "EFCalo:energy","energyBE0","energyBE1","energyBE2","energyBE3","eta","eta_calo","phi","phi_calo"],help='histograms')
-parser.add_argument('--level',type=str,help='trigger level: HLT, L1Calo, L2, L2Calo, EFCalo')
-parser.add_argument('--type',type=str,help='Choices: Distributions or Resolutions')
-args = parser.parse_args()
-
-import ROOT
-from ROOT import TFile, TH1F
-from ROOT import TCanvas, TLegend
-from ROOT import SetOwnership
-ROOT.gROOT.SetBatch(True)
-
-from AtlasStyle import *
-from getHistograms import *
-
-inputfile=TFile(args.file)
-triggerName=args.trigger
-triggerName2=args.trigger2
-folder=args.folder
-fileformat=args.fileformat
-level=args.level
-hist = args.hist
-type = args.type
-
-#########################################################################################
-def makeCanvas(histo1,title,triggerName,level,folder):
-	h1 = histo1
-	leg = TLegend(0.5,0.2,0.9,0.30, "HLT "+folder)
-	leg.SetBorderSize(0)
-	leg.SetFillStyle(0)
-	leg.SetTextSize(0.04)
-	leg.AddEntry(h1, triggerName,"l")
-	c = TCanvas("c","Efficiency",800,600)
-	h1.Draw()
-	leg.Draw()
-	c.SetGrid()
-	ATLASLabel(0.2,0.2)
-	if folder=="TPAnalysis":
-		c.Print("plot_"+title+"_"+triggerName+"_"+level+"_TPAnalysis."+fileformat)
-	else:
-		c.Print("plot_"+title+"_"+triggerName+"_"+level+"_Analysis."+fileformat)
-
-#########################################################################################
-def makeCanvas2(histo1,histo2,title,triggerName,level,folder):
-	h1 = histo1
-        h2 = histo2
-        h1.SetMarkerStyle(20)
-        h1.SetMarkerColor(2)
-        h1.SetLineColor(2)
-        h2.SetMarkerStyle(22)
-        h2.SetMarkerColor(4)
-        h2.SetLineColor(4)
-	leg = TLegend(0.5,0.2,0.9,0.30, "HLT "+folder)
-	leg.SetBorderSize(0)
-	leg.SetFillStyle(0)
-	leg.SetTextSize(0.04)
-	leg.AddEntry(h1, triggerName,"p")
-	leg.AddEntry(h2, triggerName2,"p")
-	c = TCanvas("c","Efficiency",800,600)
-	h1.Draw()
-        h2.Draw("SAME")
-	leg.Draw()
-	c.SetGrid()
-	ATLASLabel(0.2,0.2)
-	if folder=="TPAnalysis":
-		c.Print("plot_"+title+"_"+triggerName+"_"+triggerName2+"_"+level+"_TPAnalysis."+fileformat)
-	else:
-		c.Print("plot_"+title+"_"+triggerName+"_"+triggerName2+"_"+level+"_Analysis."+fileformat)
-#########################################################################################
-### Main program
-#########################################################################################
-
-
-SetAtlasStyle()
-if(args.hist):    
-    h=getSingleTH1F(inputfile,triggerName,hist,folder,type,level)
-    makeCanvas(h,args.hist+"_"+type,triggerName,level,folder)
-elif(args.trigger2):
-    hEt, hEta, hPhi, hMu = getTH1FsfromFile(inputfile,triggerName,folder,level)
-    h2Et, h2Eta, h2Phi, h2Mu = getTH1FsfromFile(inputfile,triggerName2,folder,level)
-    makeCanvas2(hEt,h2Et,"Et",triggerName,level,folder)
-    makeCanvas2(hEta,h2Eta,"Eta",triggerName,level,folder)
-    makeCanvas2(hPhi,h2Phi,"Phi",triggerName,level,folder)
-    makeCanvas2(hMu,h2Mu,"Mu",triggerName,level,folder)
-else:
-    hEt, hEta, hPhi, hMu = getTH1FsfromFile(inputfile,triggerName,folder,level)
-    makeCanvas(hEt,"Et",triggerName,level,folder)
-    makeCanvas(hEta,"Eta",triggerName,level,folder)
-    makeCanvas(hPhi,"Phi",triggerName,level,folder)
-    makeCanvas(hMu,"Mu",triggerName,level,folder)
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/trigEgammaDQ.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/trigEgammaDQ.py
new file mode 100644
index 0000000000000000000000000000000000000000..3309d9656a219b6e1e47953cce725eb894ea96ce
--- /dev/null
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/trigEgammaDQ.py
@@ -0,0 +1,377 @@
+#! /usr/bin/env python
+
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+import sys, optparse, shutil, os, argparse
+from sys import argv, exit
+import subprocess
+
+__doc__ = """\
+Recurvsively search input HIST file starting from HLT/Egamma and generate performance plots 
+"""
+
+parser = argparse.ArgumentParser(description = __doc__)
+parser.add_argument('--file', type=str,help='input file') 
+parser.add_argument('--run', type=str,default="",help='run number')
+parser.add_argument('--t0', type=bool,default=False,help='t0 input file')
+parser.add_argument('--ref', type=str,default="",help='reference file') 
+parser.add_argument('--refrun', type=str,default="",help='reference run number for T0 file') 
+args = parser.parse_args()
+
+import ROOT 
+from ROOT import TFile, TH1F, TH2,TGaxis
+from ROOT import TCanvas, TLegend
+from ROOT import SetOwnership
+
+from TrigEgammaAnalysisTools.TrigEgammaDataQuality import TrigEgammaPlotHolder
+from AtlasStyle import *
+
+dqlist = {'Efficiency':['eff_et','eff_eta','eff_phi','eff_mu']}
+dqlevel = ['HLT','L1Calo']
+complist={'L1_EM20VH':'L1_EM20VHI',
+        'L1_EM20VHI':'HLT_e24_lhtight_nod0_ivarloose',
+        'L1_EM22VHI':'HLT_e26_lhtight_nod0_ivarloose',
+        'HLT_e24_lhmedium_L1EM20VH':'HLT_e24_lhmedium_L1EM20VHI',
+        'HLT_e24_lhmedium_L1EM20VHI':'HLT_e24_lhmedium_ivarloose',
+        'HLT_e24_lhmedium_ivarloose':'HLT_e24_lhmedium_nod0_ivarloose',
+        'HLT_e24_lhmedium_nod0_ivarloose':'HLT_e24_lhtight_nod0_ivarloose',
+        }
+
+#########################################################
+
+def setCanvas(c):
+    ROOT.gStyle.SetOptStat(0)
+    ROOT.gStyle.SetOptTitle(0)
+    c.SetHighLightColor(2)
+    c.SetFillColor(0)
+    c.SetBorderMode(0)
+    c.SetBorderSize(2)
+    c.SetTickx(1)
+    c.SetTicky(1)
+    c.SetLeftMargin(0.16)                                  
+    c.SetRightMargin(0.05)                                     
+    c.SetTopMargin(0.05)                                        
+    c.SetFrameBorderMode(0)                                           
+    c.SetFrameBorderMode(0)                                              
+
+def makeCanvas(h1,trigger,name,run="",lumi=""):
+    c = TCanvas()
+    hname=h1.GetName()
+    if('eff' in hname):
+        h1.SetMaximum(1.4)
+        h1.SetMinimum(0.)
+        h1.GetYaxis().SetTitle("Efficiency")
+    else:
+        TGaxis.SetMaxDigits(2);
+    
+    h1.Draw()
+    leg = TLegend(0.4,0.2,0.70,0.30)
+    setLegend1(leg,h1,trigger)
+    ATLASLabel(0.2,0.87,"Internal")
+    ATLASRunNumberLabel(0.7,0.85,run)
+    ATLASLumiLabel(0.2,0.85,lumi)
+    oname="plot_Run_"+run+"_"+hname+"_"+trigger+"_"+name+".eps"
+    #oname2="plot_Run_"+trigger+"_"+hname+"_"+name+".C"
+    gPad.RedrawAxis()
+    c.Print(oname)
+    #c.SaveAs(oname2)
+    return oname
+
+def makeCanvas2(h1,h2,title,name,name2,run="",lumi="",run2=""):
+    c = TCanvas()
+    hname=h1.GetName()
+    if('eff' in hname):
+        h1.SetMaximum(1.4)
+        h1.SetMinimum(0.)
+        h1.GetYaxis().SetTitle("Efficiency")
+        h2.SetMaximum(1.4)
+        h2.SetMinimum(0.)
+    else:
+        TGaxis.SetMaxDigits(2);
+    
+    h1.SetMarkerStyle(24)
+    h1.SetMarkerColor(1)
+    h1.SetLineColor(1)
+    h2.SetMarkerStyle(22)
+    h2.SetMarkerColor(4)
+    h2.SetLineColor(4)
+    
+    h1.Draw()
+    h2.Draw("SAME")
+    leg = TLegend(0.4,0.2,0.7,0.40)
+    if not run2:
+        setLegend2(leg,h1,h2,name,name2)
+    else:
+        setLegend2(leg,h1,h2,name,run2)
+    ATLASLabel(0.2,0.85,"Internal")
+    ATLASRunNumberLabel(0.7,0.85,run)
+    ATLASLumiLabel(0.2,0.85,lumi)
+    oname="plot_Run_"+run+"_"+hname+"_"+name+"_"+name2+".eps"
+    #oname2="plot_Run_"+run+"_"+hname+"_"+name+"_"+name2+".C"
+    gPad.RedrawAxis()
+    c.Print(oname)
+    #c.SaveAs(oname2)
+    return oname
+
+def setLegend1(leg,histo1,trigName):
+   #TLegend *leg = new TLegend(0.40,0.25,0.75,0.35,NULL,"brNDC");
+    leg.SetBorderSize(0)
+    leg.SetTextFont(42)
+    leg.SetTextSize(0.042)
+    leg.SetLineColor(1)
+    leg.SetLineStyle(1)
+    leg.SetLineWidth(1)
+    leg.SetFillColor(0)
+    leg.SetFillStyle(0)
+    leg.AddEntry(histo1,trigName,"p")
+    leg.Draw()
+
+def setLegend2(leg,histo1,histo2,trigName,trigName2):
+   #TLegend *leg = new TLegend(0.40,0.25,0.75,0.35,NULL,"brNDC");
+    leg.SetBorderSize(0)
+    leg.SetTextFont(42)
+    leg.SetTextSize(0.042)
+    leg.SetLineColor(1)
+    leg.SetLineStyle(1)
+    leg.SetLineWidth(1)
+    leg.SetFillColor(0)
+    leg.SetFillStyle(0)
+    leg.AddEntry(histo1,trigName,"p")
+    leg.AddEntry(histo2,trigName2,"p")
+    leg.Draw()
+
+def montage(plotlist,name):
+    print name
+    plot_names_str = ' '.join(plotlist)
+    cmd = 'montage -tile 2x2 -geometry 800x800+3+3 {0} {1}'.format(plot_names_str, name + '.pdf')
+    subprocess.call(cmd, shell=True)
+    cmd = 'tar -czf {0} *.eps --remove-files'.format(name + '.tar.gz')
+    subprocess.call(cmd, shell=True)
+
+def sortPlots(histos,path,holder):
+    
+    tname, tplot, run = parseName(path)
+    holder.setRunNumber(run) 
+    # The following is ridiculous 
+    for l in dqlevel:
+        if(l in tplot):
+            holder.updateTriggers(tname)
+            for t in dqlist.keys():
+                if(t in tplot):
+                    toplot=dqlist[t]
+                    plotlist=[]
+                    hlist=[]
+                    for h in histos:
+                        if(h.GetName() in toplot):
+                            hlist.append(h)
+                    holder.updatePlots(tname,tplot,hlist)
+    
+
+def parseName(fpath):
+    dlist=fpath.split("/")
+    tplot=""
+    tname=""
+    run=""
+    flist=dlist[0].split(".")
+    if(len(flist)>1):
+        run=flist[1]
+    #print run
+    if("Shifter" in fpath):
+        tname=dlist.pop()
+    elif("Expert" in fpath):  
+        tplot=dlist.pop()
+        tplot+="_"+dlist.pop()
+    for l in dlist:
+        if("HLT_" in l):
+            tname = l
+        if("L1_" in l):
+            tname = l
+    return tname, tplot, run    
+
+def objectsInDir(rdir,holder):
+    histos=[]
+    for key in rdir.GetListOfKeys():
+        cl = key.GetClassName(); rcl = ROOT.TClass.GetClass(cl)
+        if ' ' in key.GetName():
+            print 'WARNING: cannot have spaces in histogram names for han config; not including %s %s' % (cl, key.GetName())
+            continue
+        if rcl.InheritsFrom('TDirectory'):
+            recurse(key.ReadObj(),holder)
+        elif rcl.InheritsFrom('TH1'):
+
+            if '/' in key.GetName():
+                print 'WARNING: cannot have slashes in histogram names, encountered in directory %s, histogram %s' % (rdir.GetPath(), key.GetName())
+                continue
+            if key.GetName() == 'summary':
+                print 'WARNING: cannot have histogram named summary, encountered in %s' % rdir.GetPath()
+                continue
+            histos.append(key.ReadObj())
+            fpath = rdir.GetPath()
+            name = (fpath + '/' + key.GetName()).lstrip('/')
+            #print name, fpath
+    if(len(histos) > 0):        
+        sortPlots(histos,fpath,holder)
+
+def recurse(rdir,holder):
+    for key in rdir.GetListOfKeys():
+        cl = key.GetClassName(); rcl = ROOT.TClass.GetClass(cl); kname=key.GetName()
+        if ' ' in kname:
+            print 'WARNING: cannot have spaces in histogram names for han config; not including %s %s' % (cl, key.GetName())
+            continue
+        elif rcl.InheritsFrom('TDirectory'):
+            objectsInDir(key.ReadObj(),holder)
+
+def createTriggerPlots(holder):
+    slist=[]
+    for key in dqlist:
+        for trigger in holder.Triggers:
+            h1 = holder.getPlots(trigger,key) 
+            print h1
+            plist=[]
+            for h in h1:
+                pname1=makeCanvas(h,trigger,key,holder.RunNumber,holder.Lumi)
+                plist.append(pname1)
+                slist.append(pname1)
+            #if(len(h1)>0):
+                #montage(plist,trigger+'_'+key)       
+    return slist
+
+def createTriggerComparisonPlots(holder):
+    slist=[]
+    for key in dqlist:
+        for trigger in holder.Triggers:
+            h1 = holder.getPlots(trigger,key) 
+            print h1
+            if(trigger in complist):
+                h2 = holder.getPlots(complist[trigger],key)
+                print h2
+            i=0
+            pclist=[]
+            for h in h1:
+                if(trigger in complist):
+                    pname2=makeCanvas2(h,h2[i],h.GetName(),trigger,complist[trigger],holder.RunNumber,holder.Lumi)
+                    pclist.append(pname2)
+                    slist.append(pname2)
+                i+=1
+            #if(len(pclist)>0):
+                #montage(pclist,trigger+"_"+complist[trigger])   
+    return slist           
+
+def createReferencePlots(holder,rholder):
+    slist=[]
+    for key in dqlist:
+        for trigger in holder.Triggers:
+            h1 = holder.getPlots(trigger,key)
+            h2 = rholder.getPlots(trigger,key) 
+            print h1
+            plist=[]
+            i=0
+            if h2:
+                for h in h1:
+                    pname1=makeCanvas2(h,h2[i],h.GetName(),trigger,"Ref",holder.RunNumber,holder.Lumi,rholder.RunNumber)
+                    plist.append(pname1)
+                    slist.append(pname1)
+                    i+=1
+    return slist
+
+def createPlots(holder):
+    slist1 = createTriggerPlots(holder)
+    slist2 = createTriggerComparisonPlots(holder)
+    slist=slist1+slist2
+    mname='TrigEgammaDQSummary_Run_'+holder.RunNumber
+    montage(slist,mname)
+
+
+def process(infname, basepath, run="", rinfname="", rbasepath=""):
+    lumi=""
+    lbset=""
+    if run:
+        from TrigCostPython import TrigCostCool
+        lbset=TrigCostCool.GetLumiblocks(int(run),-1,-1,"")
+    
+        if(lbset): 
+            print "%-40s % 9.2g %-10s" % ("Recorded Luminosity:  ",lbset.GetRecordedLumi()/(1e6),"pb^{-1}")
+            lumi=str(round(lbset.GetRecordedLumi()/(1e6),1))
+
+    import re
+    f = ROOT.TFile.Open(infname, 'READ')
+    if not f.IsOpen():
+        print 'ERROR: cannot open %s' % infname
+        return
+    topindir = f.Get(basepath)
+    if not topindir:
+        raise ValueError("Path %s doesn't exist in input file" % basepath)
+    holder = TrigEgammaPlotHolder('holder')
+    holder.setLumi(lumi)
+    recurse(topindir,holder)
+    #print holder.Efficiency
+    print holder.RunNumber
+    print holder.Triggers
+    createPlots(holder)
+
+    if rinfname:
+        f2 = ROOT.TFile.Open(rinfname, 'READ')
+        if not f2.IsOpen():
+            print 'ERROR: cannot open %s' % rinfname
+            return
+        rtopindir = f2.Get(rbasepath)
+        if not rtopindir:
+            raise ValueError("Path %s doesn't exist in input file" % rbasepath)
+        rholder = TrigEgammaPlotHolder('rholder')
+        rholder.setLumi(lumi)
+        #print rholder.Efficiency
+        recurse(rtopindir,rholder)
+        print rholder.RunNumber
+        print rholder.Triggers
+        slist=createReferencePlots(holder,rholder)
+        mname='TrigEgammaDQSummary_Run_'+holder.RunNumber+'_refRun_'+rholder.RunNumber
+        montage(slist,mname)
+    
+    if lbset:
+        print "-------------------------------------------------------------------------"
+        print "Lumiblock Info("+str(lbset.lbbeg)+","+str(lbset.lbend)+")"
+        print "-------------------------------------------------------------------------"
+        print
+        print "%-40s % 9.5g %-10s" % ("Integrated Time:      ",lbset.GetTotalTime(),"seconds")
+        print "%-40s % 9.5g %-10s" % ("Live Time:            ",lbset.GetLiveTime(),"seconds")
+        print "%-40s % 9.2g %-10s" % ("Delivered Luminosity: ",lbset.GetDeliveredLumi()/(1e6),"pb^{-1}")
+        print "%-40s % 9.2g %-10s" % ("Recorded Luminosity:  ",lbset.GetRecordedLumi()/(1e6),"pb^{-1}")
+        print "%-39s % 9.3e %-10s" % ("Mean Instantaneous Luminosity:",lbset.GetDeliveredLumi()/lbset.GetTotalTime()*1e30,"1/(cm^2 s)")
+        print "%-40s % 9.2e %-10s" % ("Live-Time-Averaged # Bunches:",lbset.GetLiveTimeAveragedBunches(),"")
+        print "%-40s % 9.2e %-10s" % ("Integrated-Time-Averaged # Bunches:",lbset.GetIntegratedTimeAveragedBunches(),"")
+
+def setDefaults():
+    SetAtlasStyle()
+    ROOT.gROOT.SetBatch(True)
+    ROOT.gStyle.SetPalette(1)
+
+def main():
+    
+    setDefaults()
+    
+    if(args.t0):
+        if not args.run:
+            print 'Run number not given'
+            sys.exit(2)
+    
+        run='run_'+args.run
+        path=run+"/HLT/Egamma/Expert"
+    else:
+        path= "HLT/Egamma/Expert"
+    
+    if(args.ref):
+        rpath=""
+        if(args.refrun):
+            rpath='run_'+args.refrun+'/HLT/Egamma/Expert'
+        else:
+            rpath='HLT/Egamma/Expert'
+        process(args.file,path,args.run,args.ref,rpath)
+    else:
+        process(args.file,path,args.run)
+
+if __name__=="__main__":
+    #os.environ['TDAQ_ERS_NO_SIGNAL_HANDLERS']='1'
+    main()
+
+         
+    
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/wrapper.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/wrapper.py
deleted file mode 100644
index 557feaf75b4d25c88d86f22b383994219868fda5..0000000000000000000000000000000000000000
--- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/wrapper.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-
-##
-# this is to call macros for Efficiencies and Distributions
-##
-
-import sys,os
-import argparse
-parser = argparse.ArgumentParser()
-parser.add_argument('--file', type=str,help='input file')
-parser.add_argument('--folder', type=str,help='folder')
-parser.add_argument('--fileformat', type=str,help='filetype')
-parser.add_argument('--triggers', nargs='*',type=str,help='triggers')
-args = parser.parse_args()
-root_file=args.file
-triggerlist=args.triggers
-folder=args.folder
-fileformat=args.fileformat # not used
-print triggerlist
-print root_file
-
-stringcommand='plotExtras.py -b '+root_file +' '+folder+' '+fileformat
-os.system('python '+stringcommand)
-
-for triggername in triggerlist:
-    stringcommand='plotEfficiencies.py -b '+root_file+' '+triggername+' '+folder+' '+fileformat
-    os.system('python '+stringcommand)
-
-    stringcommand='plotDistributions.py -b '+root_file+' '+triggername+' '+folder+' '+fileformat
-    os.system('python '+stringcommand)
-
-# merge pdfs
-os.system('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=false -sOutputFile=output_singlepage.pdf *.ps')
diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaDataQuality.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaDataQuality.py
new file mode 100644
index 0000000000000000000000000000000000000000..b6850b7cb5a19682077df8c0aeeb63d71bd2f990
--- /dev/null
+++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaDataQuality.py
@@ -0,0 +1,61 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+# Various classes for retaining 
+# pertinent information for Data Quality assessment
+# Allows for easy use of creating DQ plots in 
+# trigEgammaDQ.py
+
+# Class to retain maps of trigger names and plots
+class TrigEgammaPlotHolder:
+    def __init__(self,name):
+        self.name = name
+        self.RunNumber=""
+        self.Lumi=""
+        self.Triggers=[]
+        self.Efficiency={}
+        self.Distribution={}
+        self.Resolution={}
+        self.Category={}
+        self.Map={'Efficiency':self.Efficiency,
+                'Distribution':self.Distribution,
+                'Resolution':self.Resolution,
+                'Category':self.Category}
+    def setRunNumber(self,run):
+        if not self.RunNumber:
+            self.RunNumber=run
+    def setLumi(self,lumi):
+        if not self.Lumi:
+            self.Lumi=lumi
+
+    def updateTriggers(self,trigger):
+        if(trigger not in self.Triggers):
+            self.Triggers.append(trigger)
+
+    def updateEfficiency(self,trigger,histos):
+        self.Efficiency.update({trigger:histos})
+    def updateDistribution(self,trigger,histos):
+        self.Distribution.update({trigger:histos})
+    def updateResolution(self,trigger,histos):
+        self.Resolution.update({trigger:histos})
+    def updateCategory(self,trigger,histos):
+        self.Category.update({trigger:histos})
+
+    def updatePlots(self,trigger,plot,histos):
+        if('Efficiency' in plot):
+            self.updateEfficiency(trigger,histos)
+        elif('Distributions' in plot):
+            self.updateDistribution(trigger,histos)
+        elif('Resolutions' in plot):
+            self.updateResolution(trigger,histos)
+        else:
+            print 'No update'
+
+    def getPlots(self,trigger,plot):
+        group = self.Map[plot]
+        if(trigger in group):
+            return group[trigger]
+        else:
+            return []
+
+
+