From 16ad93fb1f60e62187bfceefab4c543c3557b00d Mon Sep 17 00:00:00 2001 From: Julie Kirk Date: Tue, 29 Oct 2019 08:34:16 +0000 Subject: [PATCH] Revert "Merge branch 'master-TrigEgammaMonitoring-MTupgrade1' into 'master'" This reverts merge request !25098 --- .../TrigEgammaAnalysisTools/CMakeLists.txt | 14 +- .../Root/EfficiencyTool.cxx | 98 +- .../Root/TH1Wrapper.cxx | 35 - .../Root/TH2Wrapper.cxx | 31 - .../Root/TrigEgammaAnalysisBaseTool.cxx | 437 +++--- .../Root/TrigEgammaDistTool.cxx | 54 +- .../Root/TrigEgammaEventSelection.cxx | 1209 +++++++++++++++ .../Root/TrigEgammaNavAnalysisTool.cxx | 158 +- .../Root/TrigEgammaNavTPAnalysisTool.cxx | 255 ++- .../Root/TrigEgammaPhysValBase.cxx | 1005 ++++++++++++ .../Root/TrigEgammaPlotTool.cxx | 1364 +++++++++++++++++ .../Root/TrigEgammaResolutionTool.cxx | 88 +- .../TrigEgammaAnalysisTools/EfficiencyTool.h | 20 +- .../IMonitoringGroupLookup.h | 22 - .../ITrigEgammaAnalysisBaseTool.h | 22 +- .../ITrigEgammaPlotTool.h | 54 + .../TrigEgammaAnalysisTools/TH1Wrapper.h | 32 - .../TrigEgammaAnalysisTools/TH2Wrapper.h | 29 - .../TrigEgammaAnalysisBaseTool.h | 228 ++- .../TrigEgammaDistTool.h | 19 +- .../TrigEgammaEventSelection.h | 118 ++ .../TrigEgammaNavAnalysisTool.h | 12 +- .../TrigEgammaNavBaseTool.h | 40 +- .../TrigEgammaNavTPAnalysisTool.h | 12 +- .../TrigEgammaNavTPBaseTool.h | 49 +- .../TrigEgammaPhysValBase.h | 276 ++++ .../TrigEgammaPlotTool.h | 134 ++ .../TrigEgammaResolutionTool.h | 25 +- .../python/TrigEgammaAnalysisToolsConfig.py | 101 +- .../src/TrigEgammaAnalysisAlg.cxx | 89 ++ .../src/TrigEgammaAnalysisAlg.h | 43 + .../src/TrigEgammaMonTool.cxx | 98 ++ .../src/TrigEgammaMonTool.h | 25 + .../src/TrigEgammaPhysValMonTool.cxx | 42 + .../src/TrigEgammaPhysValMonTool.h | 19 + .../src/TrigEgammaTDToolTest.cxx | 131 ++ .../src/TrigEgammaTDToolTest.h | 43 + .../TrigEgammaAnalysisTools_entries.cxx | 25 +- .../TrigEgammaMonitoring/CMakeLists.txt | 9 +- .../python/TrigEgammaMonitorAlgorithm.py | 25 +- .../python/TrigEgammaMonitoringConfig.py | 208 ++- .../python/TrigEgammaMonitoringConfigRun3.py | 201 +-- .../python/TrigEgammaMonitoringHistDefs.py | 50 +- .../src/TrigEgammaMonitorAlgorithm.cxx | 111 +- .../src/TrigEgammaMonitorAlgorithm.h | 27 +- 45 files changed, 5552 insertions(+), 1535 deletions(-) delete mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH1Wrapper.cxx delete mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH2Wrapper.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaEventSelection.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPhysValBase.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx delete mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/IMonitoringGroupLookup.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h delete mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH1Wrapper.h delete mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH2Wrapper.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaEventSelection.h mode change 100644 => 100755 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavBaseTool.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPhysValBase.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPlotTool.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.h diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt index 7968bb79f06..7a5ff4dd491 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt @@ -34,7 +34,6 @@ atlas_depends_on_subdirs( PUBLIC PhysicsAnalysis/AnalysisCommon/PATCore PRIVATE Control/AthenaBaseComps - Control/AthenaMonitoringKernel Control/AthenaMonitoring Control/StoreGate GaudiKernel @@ -45,7 +44,7 @@ find_package( ROOT COMPONENTS Core Hist Tree ) # Component(s) in the package: atlas_add_library( TrigEgammaAnalysisToolsLib - Root/*.cxx + TrigEgammaAnalysisTools/*.h Root/*.cxx PUBLIC_HEADERS TrigEgammaAnalysisTools INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} @@ -58,18 +57,17 @@ atlas_add_library( TrigEgammaAnalysisToolsLib PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} TrigConfxAODLib ) atlas_add_component( TrigEgammaAnalysisTools + src/*.h src/*.cxx + Root/*.cxx src/components/*.cxx - INCLUDE_DIRS ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} - TrigEgammaAnalysisToolsLib - AthenaBaseComps AthenaMonitoringLib AthenaMonitoringKernelLib - StoreGateLib SGtests GaudiKernel ) + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AsgTools xAODCaloEvent xAODMissingET xAODEgamma xAODEventInfo xAODJet xAODTracking xAODTrigCalo xAODTrigEgamma xAODTrigRinger xAODCaloRings xAODTrigger xAODTruth LumiBlockCompsLib ElectronPhotonSelectorToolsLib egammaMVACalibLib TrigDecisionToolLib TrigEgammaMatchingToolLib TrigEgammaEmulationToolLib TrigConfHLTData TrigSteeringEvent TrigHLTMonitoringLib AthenaBaseComps AthenaMonitoringLib StoreGateLib SGtests GaudiKernel PATCoreLib ) # Install files from the package: atlas_install_python_modules( python/TrigEgamma*.py ) atlas_install_joboptions( share/test*.py ) -atlas_install_generic( share/trigEgammaDQ.py share/get_trigEgammaDQ.sh +atlas_install_generic( share/trigEgammaDQ.py share/get_trigEgammaDQ.sh DESTINATION share EXECUTABLE ) diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx index 6f7f16fe237..f4baf74a26d 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx @@ -16,7 +16,7 @@ #include //********************************************************************** -EfficiencyTool::EfficiencyTool(const std::string& myname): +EfficiencyTool::EfficiencyTool(const std::string& myname): TrigEgammaAnalysisBaseTool(myname) { m_detailedHists=false; @@ -51,24 +51,24 @@ bool EfficiencyTool::analyseIsEMLH(const xAOD::Electron *eg, const std::string p bool failIsEMLH = true; try{ - ATH_MSG_DEBUG("Running selectionisEM("<selectionisEM(pidword); - - failIsEMLH = false; - for (int ii = 0; ii < 11; ii++) { - if ((isem >> ii) & 0x1) { - failIsEMLH = true; - hist1(fail)->Fill(ii + 0.5); - hist1(ineff)->Fill(ii + 3.5, 1); - } - } + ATH_MSG_DEBUG("Running selectionisEM("<selectionisEM(pidword); + + failIsEMLH = false; + for (int ii = 0; ii < 11; ii++) { + if ((isem >> ii) & 0x1) { + failIsEMLH = true; + hist1(fail)->Fill(ii + 0.5); + hist1(ineff)->Fill(ii + 3.5, 1); + } + } } catch (const ValidationException &e) { - ATH_MSG_WARNING("Exception thrown: " << e.msg() ); - ATH_MSG_WARNING("Is " << pidword << " is a valid one? returning failed...."); - failIsEMLH = true; + ATH_MSG_WARNING("Exception thrown: " << e.msg() ); + ATH_MSG_WARNING("Is " << pidword << " is a valid one? returning failed...."); + failIsEMLH = true; } catch(...) { - ATH_MSG_WARNING("Unknown exception caught in analyseIsEMLH ... Is " << pidword << " is a valid one? returning failed...."); - failIsEMLH = true; + ATH_MSG_WARNING("Unknown exception caught in analyseIsEMLH ... Is " << pidword << " is a valid one? returning failed...."); + failIsEMLH = true; } return failIsEMLH; @@ -155,7 +155,7 @@ void EfficiencyTool::fillInefficiency(const std::string& pid, const std::string // Fill Reco efficiency (find a nearby object) /*if(clus) hist1("eff_hltreco")->Fill("Cluster", 1); else hist1("eff_hltreco")->Fill("Cluster",0); - + if(trk) hist1("eff_hltreco")->Fill("Track", 1); else hist1("eff_hltreco")->Fill("Track",0); @@ -164,12 +164,12 @@ void EfficiencyTool::fillInefficiency(const std::string& pid, const std::string if(selEF) hist1("eff_hltreco")->Fill("Electron", 1); else hist1("eff_hltreco")->Fill("Electron",0);*/ - + std::bitset<4> reco; //Electron, cluster, track, photon bool failiso = false; bool failbits = false; - + if(selEF != nullptr) reco.set(0); if(clus != nullptr) reco.set(1); if(trk != nullptr) reco.set(2); @@ -248,31 +248,31 @@ void EfficiencyTool::fillInefficiency(const std::string& pid, const std::string } // hist1(ineff)->Fill(n + 12.5, 1); // total (HLT) - + // if(reco.test(3) && reco.test(1)) hist1(ineff)->Fill(n + 7.5, 1); //Has cluster and photon --> should be same as cluster only? - + float lastbinfail = hist1(fail)->GetNbinsX() - 1; hist1(fail)->Fill(lastbinfail + 0.5); - + if (selPh == nullptr) ATH_MSG_DEBUG("fillIneffiency::No photon found!"); if (selEF != nullptr){ ATH_MSG_DEBUG("REGTEST::Inefficiency Electron pt, eta, phi "<< selEF->pt() << " " << selEF->eta() << " " << selEF->phi()); } else { if (trk == nullptr && clus != nullptr){ - ATH_MSG_DEBUG("fillInefficiency::No Electron, nearby cluster"); + ATH_MSG_DEBUG("fillInefficiency::No Electron, nearby cluster"); // No electron candidate but we have photon // Do something for hasCluster hist1(fail)->Fill((lastbinfail - 3) + 0.5); } if (clus == nullptr && trk != nullptr){ - ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); + ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); // No electron candidate but we have photon // Do something for hasCluster hist1(fail)->Fill((lastbinfail - 2) + 0.5); } if (clus == nullptr && trk == nullptr){ - ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); + ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); // Unknown failure hist1(fail)->Fill((lastbinfail - 1) + 0.5); } @@ -284,7 +284,7 @@ void EfficiencyTool::fillInefficiency(const std::string& pid, const std::string hist1(ineff)->Fill(lastbin, 1); } -void EfficiencyTool::inefficiency(const std::string& pid, const std::string basePath,const float etthr, +void EfficiencyTool::inefficiency(const std::string& pid, const std::string basePath,const float etthr, std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj, const asg::AcceptData& acceptData) { @@ -293,7 +293,7 @@ void EfficiencyTool::inefficiency(const std::string& pid, const std::string base // Inefficiency analysis float et = 0.0; const xAOD::Egamma* eg = pairObj.first; - const HLT::TriggerElement *feat = pairObj.second; + const HLT::TriggerElement *feat = pairObj.second; if(xAOD::EgammaHelpers::isElectron(pairObj.first)){ ATH_MSG_DEBUG("Offline Electron"); const xAOD::Electron* el = static_cast(eg); @@ -304,7 +304,7 @@ void EfficiencyTool::inefficiency(const std::string& pid, const std::string base float eta = eg->eta(); float phi = eg->phi(); ATH_MSG_DEBUG("INEFF::Offline et, eta, phi " << et << " " << eta << " " << phi); - + const xAOD::Electron* selEF = nullptr; const xAOD::Photon* selPh = nullptr; const xAOD::CaloCluster* selClus = nullptr; @@ -325,7 +325,7 @@ void EfficiencyTool::inefficiency(const std::string& pid, const std::string base hist1("eff_triggerstep")->Fill("HLT",acceptData.getCutResult("HLT")); // Fill efficiency plot for HLT trigger steps - if(!acceptData.getCutResult("HLT")/* || !acceptData.getCutResult("EFTrack")*/ || !acceptData.getCutResult("EFCalo") || + if(!acceptData.getCutResult("HLT")/* || !acceptData.getCutResult("EFTrack")*/ || !acceptData.getCutResult("EFCalo") || !acceptData.getCutResult("L2") || !acceptData.getCutResult("L2Calo")) { ATH_MSG_DEBUG("INEFF::Retrieve features for EF containers only "); ATH_MSG_DEBUG("INEFF::Retrieve EF Electron"); @@ -394,7 +394,7 @@ void EfficiencyTool::inefficiency(const std::string& pid, const std::string base if (selPh) hist1("eff_hltreco")->Fill("PhotonMatch",1); else hist1("eff_hltreco")->Fill("PhotonMatch", 0); } - else{ + else{ hist1("eff_hltreco")->Fill("Photon", 0); hist1("eff_hltreco")->Fill("PhotonMatch", 0); } @@ -429,7 +429,7 @@ void EfficiencyTool::inefficiency(const std::string& pid, const std::string base for (const auto groupname : groupnames) for (int ibin = 0; ibin < hist1("IneffisEM" + pid + groupname)->GetNbinsX(); ibin++) hist1("IneffisEM" + pid + groupname)->Fill(ibin + 0.5, 0); - } + } } } ATH_MSG_DEBUG("End Inefficiency Analysis ======================= " << basePath); @@ -455,7 +455,7 @@ void EfficiencyTool::fillEfficiency(const std::string dir,bool isPassed,const fl float pt = eg->pt()/1e3; float avgmu=getAvgMu(); float npvtx=getNPVtx(); - ATH_MSG_DEBUG("Mu " << avgmu << " " << getAvgOnlineMu() << " " << getAvgOfflineMu()); + ATH_MSG_DEBUG("Mu " << avgmu << " " << getAvgOnlineMu() << " " << getAvgOfflineMu()); ATH_MSG_DEBUG("PID decision efficiency " << eg->auxdecor(pidword)); if(pid){ hist1("et")->Fill(et); @@ -521,22 +521,20 @@ void EfficiencyTool::fillEfficiency(const std::string dir,bool isPassed,const fl StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo info, std::vector> pairObjs) { - ATH_MSG_DEBUG("Executing EfficiencyTool for " << basePath); - if(m_tp) return StatusCode::SUCCESS; - + // Removing Prescale check, in reprocessing L1AfterPrescale always false // /*if(isPrescaled(info.trigName)){ ATH_MSG_DEBUG(info.trigName << " prescaled, skipping"); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; }*/ - + const std::string dir = basePath+"/"+info.trigName; const float etthr = info.trigThrHLT; const std::string pidword = info.trigPidDecorator; const std::string pid = info.trigPidDecorator.substr(2); - + ATH_MSG_DEBUG("Efficiency for " << info.trigName << " " < algnames; algnames.push_back("Efficiency"); if( m_doEmulation ) algnames.push_back("Emulation"); - + unsigned ialg=0; for (auto algname : algnames){ - + // ialg = 0 is decision from TDT tool (Efficency dir) [default] // ialg = 1 is decision from emulator tool (Emulation dir) asg::AcceptData acceptData (&getAccept()); @@ -592,7 +590,7 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo this->fillEfficiency(dir+"/"+algname+"/L1Calo",acceptData.getCutResult("L1Calo"),etthr,pidword,pairObj.first); else { this->fillEfficiency(dir+"/"+algname+"/HLT",acceptData.getCutResult("HLT"),etthr,pidword,pairObj.first); - this->fillEfficiency(dir+"/"+algname+"/L2Calo",acceptData.getCutResult("L2Calo"),etthr,pidword,pairObj.first,m_detailedHists); + this->fillEfficiency(dir+"/"+algname+"/L2Calo",acceptData.getCutResult("L2Calo"),etthr,pidword,pairObj.first,m_detailedHists); this->fillEfficiency(dir+"/"+algname+"/L2",acceptData.getCutResult("L2"),etthr,pidword,pairObj.first,m_detailedHists); this->fillEfficiency(dir+"/"+algname+"/EFCalo",acceptData.getCutResult("EFCalo"),etthr,pidword,pairObj.first,m_detailedHists); this->fillEfficiency(dir+"/"+algname+"/L1Calo",acceptData.getCutResult("L1Calo"),etthr,pidword,pairObj.first); @@ -610,7 +608,7 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo } ATH_MSG_DEBUG("Complete efficiency"); } - + ialg++; }// Loop over efficiency (and or) Emulation @@ -618,15 +616,3 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo return StatusCode::SUCCESS; } - -void EfficiencyTool::setDetail(bool doDetail) { - m_detailedHists = doDetail; -} - -void EfficiencyTool::setTP(bool tp) { - m_tp = tp; -} - -void EfficiencyTool::setEmulation(bool doEmu) { - m_doEmulation = doEmu; -} diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH1Wrapper.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH1Wrapper.cxx deleted file mode 100644 index d8c1788486d..00000000000 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH1Wrapper.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#include "TrigEgammaAnalysisTools/TH1Wrapper.h" - -#include "AthenaMonitoringKernel/MonitoredGroup.h" -#include "AthenaMonitoringKernel/MonitoredScalar.h" - - -namespace TrigEgammaAnalysisTools { - - TH1Wrapper::TH1Wrapper(const ToolHandle& groupHandle, const std::string& histname) : - m_groupHandle(groupHandle), - m_histname(histname) - {} - - void TH1Wrapper::Fill(double value) const { - auto v = Monitored::Scalar(m_histname, value); - Monitored::Group(m_groupHandle, v).fill(); - } - - void TH1Wrapper::Fill(double value, double weight) const { - // should distinguish TH1 weighted filling and TProfile filling - auto v = Monitored::Scalar(m_histname, value); - auto w = Monitored::Scalar(m_histname+"#w", weight); - Monitored::Group(m_groupHandle, v, w).fill(); - } - - void TH1Wrapper::Fill(const char * namex, double /*w*/) const { - auto count = Monitored::Scalar( m_histname, namex ); - Monitored::Group(m_groupHandle, count).fill(); - } - -} // end of namespace TrigEgammaAnalysisTools diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH2Wrapper.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH2Wrapper.cxx deleted file mode 100644 index 32e145a0356..00000000000 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TH2Wrapper.cxx +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#include "TrigEgammaAnalysisTools/TH2Wrapper.h" - -#include "AthenaMonitoringKernel/MonitoredGroup.h" -#include "AthenaMonitoringKernel/MonitoredScalar.h" - - -namespace TrigEgammaAnalysisTools { - - TH2Wrapper::TH2Wrapper(const ToolHandle& groupHandle, const std::string& histname) : - m_groupHandle(groupHandle), - m_histname(histname) - {} - - void TH2Wrapper::Fill(double valueX, double valueY) const { - auto x = Monitored::Scalar(m_histname+"#1", valueX); - auto y = Monitored::Scalar(m_histname+"#2", valueY); - Monitored::Group(m_groupHandle, x, y).fill(); - } - void TH2Wrapper::Fill(double valueX, double valueY, double weight) const { - // should distinguish TH2 weighted filling and TProfile2D filling - auto x = Monitored::Scalar(m_histname+"#1", valueX); - auto y = Monitored::Scalar(m_histname+"#2", valueY); - auto w = Monitored::Scalar(m_histname+"#w", weight); - Monitored::Group(m_groupHandle, x, y, w).fill(); - } - -} // end of namespace TrigEgammaAnalysisTools diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx index be554a9b51c..e32e8c6bd0c 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx @@ -17,10 +17,12 @@ * Methods that maps trigger pid name to egamma Pid string * Helper methods for plotting Egamma variables **********************************************************************/ - +#include "TROOT.h" #include "TH1.h" #include "TH2.h" #include "TTree.h" +#include "TProfile.h" +#include "TProfile2D.h" #include #include #include @@ -35,6 +37,7 @@ #include "TrigEgammaEmulationTool/TrigEgammaEmulationTool.h" #include "TrigSteeringEvent/TrigRoiDescriptorCollection.h" #include "TrigDecisionTool/TrigDecisionTool.h" +#include "AthenaMonitoring/ManagedMonitorToolBase.h" #include "StoreGate/ReadCondHandle.h" using namespace std; @@ -54,8 +57,8 @@ TrigEgammaAnalysisBaseTool( const std::string& myname ) declareProperty("MatchTool",m_matchTool); declareProperty("EmulationTool",m_emulationTool); declareProperty("doEmulation", m_doEmulation=false)->declareUpdateHandler(&TrigEgammaAnalysisBaseTool::updateEmulation,this); - // declareProperty("PlotTool",m_plot); // will be removed after migration completed - // declareProperty("Tools", m_tools); // in header, private tools + declareProperty("PlotTool",m_plot); + declareProperty("Tools", m_tools); declareProperty("ElectronKey",m_offElContKey="Electrons"); declareProperty("PhotonKey",m_offPhContKey="Photons"); declareProperty("File",m_file=""); @@ -71,8 +74,8 @@ TrigEgammaAnalysisBaseTool( const std::string& myname ) m_storeGate = nullptr; m_histsvc = nullptr; - //m_parent = nullptr; - + m_parent = nullptr; + // just for compile HLT::TriggerElement* t = nullptr; const xAOD::TrigElectronContainer* a = getFeature(t); @@ -81,7 +84,7 @@ TrigEgammaAnalysisBaseTool( const std::string& myname ) bool b1 = ancestorPassed(t); (void)a; (void)b; (void)a1; (void)b1; - + // Coverity fix m_nGoodVertex=0; m_nPVertex=0; @@ -93,26 +96,26 @@ TrigEgammaAnalysisBaseTool( const std::string& myname ) } void TrigEgammaAnalysisBaseTool::updateDetail(Property& /*p*/){ - //plot()->setDetail(m_detailedHists); + plot()->setDetail(m_detailedHists); // Detail for tools needs to be reset for every call in Analysis for( auto& tool : m_tools) { - tool->setDetail(m_detailedHists); + tool->setDetail(m_detailedHists); } } void TrigEgammaAnalysisBaseTool::updateAltBinning(Property& /*p*/){ - //plot()->setAltBinning(m_doJpsiee); + plot()->setAltBinning(m_doJpsiee); } void TrigEgammaAnalysisBaseTool::updateTP(Property& /*p*/){ - //plot()->setTP(m_tp); + plot()->setTP(m_tp); for( auto& tool : m_tools) { tool->setTP(m_tp); } } void TrigEgammaAnalysisBaseTool::updateEmulation(Property& /*p*/){ - //plot()->setEmulation(m_doEmulation); + plot()->setEmulation(m_doEmulation); for( auto& tool : m_tools) { tool->setEmulation(m_doEmulation); ATH_MSG_INFO("updateEmulation() property for tool with name: " << tool->name()); @@ -141,12 +144,12 @@ StatusCode TrigEgammaAnalysisBaseTool::initialize() { ATH_CHECK( m_luminosityCondDataKey.initialize() ); - if (m_lumiBlockMuTool.retrieve().isFailure()) { + if (m_lumiBlockMuTool.retrieve().isFailure()) { ATH_MSG_WARNING("Unable to retrieve LumiBlockMuTool"); - } else { + } else { ATH_MSG_INFO("Successfully retrieved LumiBlockMuTool"); - } - + } + if ( (m_trigdec.retrieve()).isFailure() ){ ATH_MSG_ERROR("Could not retrieve Trigger Decision Tool! Can't work"); return StatusCode::FAILURE; @@ -154,25 +157,26 @@ StatusCode TrigEgammaAnalysisBaseTool::initialize() { //Enable expert methods m_trigdec->ExperimentalAndExpertMethods()->enable(); + //TrigEgammaPlotTool - //if(m_parent) m_plot->setParent(m_parent); + if(m_parent) m_plot->setParent(m_parent); /*sc = m_plot->initialize(); if( sc.isFailure() ) { ATH_MSG_ERROR("Unable to locate TrigEgammaPlotTool"); return sc; }*/ - + try { ATH_MSG_DEBUG("child Initialize " << name()); sc = childInitialize(); - if ( (m_electronIsEMTool.retrieve()).isFailure() ){ - ATH_MSG_ERROR( "Could not retrieve Selector Tool! Can't work"); - return StatusCode::FAILURE; - } - if ( (m_electronLHTool.retrieve()).isFailure() ){ - ATH_MSG_ERROR( "Could not retrieve Selector Tool! Can't work"); - return StatusCode::FAILURE; - } + if ( (m_electronIsEMTool.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve Selector Tool! Can't work"); + return StatusCode::FAILURE; + } + if ( (m_electronLHTool.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve Selector Tool! Can't work"); + return StatusCode::FAILURE; + } } catch(const ValidationException &e) { ATH_MSG_ERROR("Exception thrown: " << e.msg()); return StatusCode::FAILURE; @@ -181,25 +185,11 @@ StatusCode TrigEgammaAnalysisBaseTool::initialize() { return StatusCode::FAILURE; } - ATH_MSG_DEBUG("Retrieving subtools... " << m_tools.size()); - - for ( const auto htool : m_tools ) { - ATH_MSG_DEBUG("Retrieving "<< htool <<"..." ); - StatusCode sc = htool.retrieve(); - if ( ! sc.isSuccess() ) { - ATH_MSG_ERROR("Tool retrieval failed: " << htool); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG("...//" ); - } - - ATH_MSG_DEBUG("Subtools retrieval completed."); - // propagate the emulation tool for all tools if( m_doEmulation ){ for( auto& tool : m_tools) { ATH_MSG_INFO("Propagate emulation tool handler to: " << tool->name() ); - tool->setEmulationTool(m_emulationTool); + tool->setEmulationTool(m_emulationTool); } } @@ -214,7 +204,7 @@ StatusCode TrigEgammaAnalysisBaseTool::initialize() { ATH_MSG_ERROR("Unknown exception caught, while initializing"); return StatusCode::FAILURE; } - + }*/ for(const auto cut:m_trigLevel) m_accept.addCut(cut,cut); @@ -223,12 +213,12 @@ StatusCode TrigEgammaAnalysisBaseTool::initialize() { StatusCode TrigEgammaAnalysisBaseTool::book() { StatusCode sc = StatusCode::FAILURE; - //for( auto& tool : m_tools) { - // tool->setPlotTool(m_plot); - //} + for( auto& tool : m_tools) { + tool->setPlotTool(m_plot); + } try { - ATH_MSG_DEBUG("child Book " << name()); + ATH_MSG_DEBUG("child Initialize " << name()); sc = childBook(); } catch(const ValidationException &e) { ATH_MSG_ERROR("ValidationException thrown: " << e.msg()); @@ -240,23 +230,6 @@ StatusCode TrigEgammaAnalysisBaseTool::book() { ATH_MSG_ERROR("Unknown exception caught, while initializing"); return StatusCode::FAILURE; } - - if (! m_MGlookup.isValid() ) { - ATH_MSG_ERROR("Tool parent does not provides capability to lookup Monitoring groups by name"); - return StatusCode::FAILURE; - } - - for ( auto htool : m_tools ) { - ATH_MSG_INFO("Booking "<< htool <<"..." ); - htool->setMGLookup(m_MGlookup); - sc = htool->book(); - if ( ! sc.isSuccess() ) { - ATH_MSG_ERROR("Tool book failed:" << htool); - return StatusCode::FAILURE; - } - ATH_MSG_INFO("...//" ); - } - return sc; } @@ -297,7 +270,7 @@ StatusCode TrigEgammaAnalysisBaseTool::finalize() { ATH_MSG_ERROR("Unknown exception caught, while finalizing " << tool->name() ); return StatusCode::FAILURE; } - + } try { @@ -320,65 +293,41 @@ void TrigEgammaAnalysisBaseTool::print() const { ATH_MSG_ALWAYS("This message always appears."); } -ToolHandle TrigEgammaAnalysisBaseTool::findGroup( const std::string& name ) const { - return m_MGlookup->findGroup(name); -} - void TrigEgammaAnalysisBaseTool::cd(const std::string &dir) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::cd ('"<< dir << "') called"); - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::cd@name='"<< name() << "'"); -// plot()->cd(dir); + plot()->cd(dir); } void TrigEgammaAnalysisBaseTool::addDirectory(const std::string &dir) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::addDirectory('"<< dir << "') called"); -// plot()->addDirectory(dir); + plot()->addDirectory(dir); } -void TrigEgammaAnalysisBaseTool::addHistogram(TH1 */*h*/, const std::string &/*dir*/) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::addHistogram TH1 called"); -// plot()->addHistogram(h,dir); -} -void TrigEgammaAnalysisBaseTool::addHistogram(TH2 */*h*/, const std::string &/*dir*/) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::addHistogram TH2 called"); -// plot()->addHistogram(h,dir); +void TrigEgammaAnalysisBaseTool::addHistogram(TH1 *h, const std::string &dir) { + plot()->addHistogram(h,dir); } -void TrigEgammaAnalysisBaseTool::addTree(TTree */*t*/, const std::string &/*dir*/) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::addTree called"); -// plot()->addTree(t,dir); +void TrigEgammaAnalysisBaseTool::addHistogram(TH2 *h, const std::string &dir) { + plot()->addHistogram(h,dir); } -void TrigEgammaAnalysisBaseTool::setLabels(TH1* /*histo*/, const std::vector& /*labels*/) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::setLabels called"); -// plot()->setLabels(histo,labels); +void TrigEgammaAnalysisBaseTool::addTree(TTree *t, const std::string &dir) { + plot()->addTree(t,dir); } -std::unique_ptr TrigEgammaAnalysisBaseTool::hist1(const ToolHandle& mgHandle, const std::string &histName) { - return std::make_unique(mgHandle, histName); +void TrigEgammaAnalysisBaseTool::setLabels(TH1* histo, const std::vector& labels) { + plot()->setLabels(histo,labels); } -std::unique_ptr TrigEgammaAnalysisBaseTool::hist2(const ToolHandle& mgHandle, const std::string &histName) { - return std::make_unique(mgHandle, histName); +TH1 *TrigEgammaAnalysisBaseTool::hist1(const std::string &histName, const std::string &dir) { + return plot()->hist1(histName,dir); } -std::unique_ptr TrigEgammaAnalysisBaseTool::hist1(const std::string &histName/*, const std::string &dir*/) { - ATH_MSG_WARNING("Transitional TrigEgammaAnalysisBaseTool::hist1('"<< histName <<"') called"); - return std::make_unique(m_TMPgroupHandle, histName); -// return plot()->hist1(histName,dir); -} - -std::unique_ptr TrigEgammaAnalysisBaseTool::hist2(const std::string &histName/*, const std::string &dir*/) { - ATH_MSG_WARNING("Transitional TrigEgammaAnalysisBaseTool::hist2('"<< histName <<"') called"); - return std::make_unique(m_TMPgroupHandle, histName); -// return plot()->hist2(histName,dir); +TH2 *TrigEgammaAnalysisBaseTool::hist2(const std::string &histName, const std::string &dir) { + return plot()->hist2(histName,dir); } TTree *TrigEgammaAnalysisBaseTool::tree(const std::string &treeName, const std::string &dir) { - ATH_MSG_WARNING("Old TrigEgammaAnalysisBaseTool::tree('"<< treeName << "', '" << dir <<"') called"); - //return plot()->tree(treeName,dir); - return 0; // cause a crash for debug + return plot()->tree(treeName,dir); } // adds entry in TrigInfo map to retrieve later via trigger name @@ -412,20 +361,20 @@ void TrigEgammaAnalysisBaseTool::setTrigInfo(const std::string trigger){ else getL1Item(trigger); std::string decorator="is"+pidname; - if(isL1) etthr=l1thr; // Should be handled elsewhere + if(isL1) etthr=l1thr; // Should be handled elsewhere TrigInfo info{trigger,type,l1item,l1type,pidname,decorator,isL1,perf,etcut,etthr,l1thr,m_forceTrigEmulation}; m_trigInfo[trigger] = info; - + m_forceTrigEmulation=false; //hack disable } // return the TrigInfo from trigger name TrigInfo TrigEgammaAnalysisBaseTool::getTrigInfo(const std::string trigger) { return m_trigInfo[trigger]; } -void TrigEgammaAnalysisBaseTool::parseTriggerName(const std::string trigger, std::string defaultPid,bool &isL1,std::string &type, +void TrigEgammaAnalysisBaseTool::parseTriggerName(const std::string trigger, std::string defaultPid,bool &isL1,std::string &type, float &threshold, float &l1threshold, std::string &l1type, std::string &pidname, bool &etcut, bool &perf){ - + // Analyze L1 or HLT item bool result = boost::starts_with( trigger , "L1" ); if (result) { @@ -463,12 +412,12 @@ void TrigEgammaAnalysisBaseTool::parseTriggerName(const std::string trigger, std ATH_MSG_DEBUG("Perf " << perf << " " << pidname ); } else if(boost::contains(strs.at(1),"L2Star")){ - pidname = defaultPid; + pidname = defaultPid; perf=true; ATH_MSG_DEBUG("L2Star " << perf << " " << pidname ); } else if(boost::contains(strs.at(1),"hiptrt")){ - pidname = defaultPid; + pidname = defaultPid; perf=true; ATH_MSG_DEBUG("hiptrt " << perf << " " << pidname ); } @@ -476,15 +425,15 @@ void TrigEgammaAnalysisBaseTool::parseTriggerName(const std::string trigger, std pidname = defaultPid; etcut=true; } - // HI is not working in master any more. So commenting out untill fixed + // HI is not working in master any more. So commenting out untill fixed // else { - // if (type == "electron" && boost::contains(trigger, "ion")){ - // ATH_MSG_DEBUG("Heavy ion electron chain being used. Using LHMediumHI tune for offline."); - // pidname="LHMediumHI"; - // } else { - // pidname = getProbePid(strs.at(1)); - // } - // } + // if (type == "electron" && boost::contains(trigger, "ion")){ + // ATH_MSG_DEBUG("Heavy ion electron chain being used. Using LHMediumHI tune for offline."); + // pidname="LHMediumHI"; + // } else { + // pidname = getProbePid(strs.at(1)); + // } + // } //Get the L1 information @@ -503,7 +452,7 @@ void TrigEgammaAnalysisBaseTool::parseTriggerName(const std::string trigger, std str_thr.erase( 0, 1); threshold = atof(str_thr.c_str()); - isL1=false; + isL1=false; ATH_MSG_DEBUG(trigger << " " << type << " " << pidname << " " << threshold); } @@ -523,7 +472,7 @@ bool TrigEgammaAnalysisBaseTool::splitTriggerName(const std::string trigger, std for(unsigned int i=1; ibook(basePath).isFailure()) ATH_MSG_ERROR("Unable to book histos for " << basePath); + //if(plot()->book(basePath).isFailure()) ATH_MSG_ERROR("Unable to book histos for " << basePath); } bool TrigEgammaAnalysisBaseTool::isIsolated(const xAOD::Electron *eg, const std::string isolation){ @@ -623,43 +572,43 @@ bool TrigEgammaAnalysisBaseTool::isPrescaled(const std::string trigger){ asg::AcceptData TrigEgammaAnalysisBaseTool::setAccept(const HLT::TriggerElement *te,const TrigInfo info){ - + ATH_MSG_DEBUG("setAccept"); asg::AcceptData acceptData (&m_accept); bool passedL1Calo=false; bool passedL2Calo=false; bool passedEFCalo=false; bool passedL2=false; - bool passedEFTrk=false; + bool passedEFTrk=false; bool passedEF=false; - + passedL1Calo = ancestorPassed(te); bool hasRnn = false; if(getFeature(te)){ hasRnn=true; } - + ATH_MSG_DEBUG("Rnn container " << getSGContainsRnn()); ATH_MSG_DEBUG("TrigPhotonContainer " << getSGContainsTrigPhoton()); - + if(getSGContainsRnn()){ if(getFeature(te)){ hasRnn=true; } } - + if(!info.trigL1){ // HLT item get full decision ATH_MSG_DEBUG("Check for active features: TrigEMCluster,CaloClusterContainer"); ATH_MSG_DEBUG("Check for active RNN feature: " << hasRnn); - + // Added Ringer step in electron sequence // If feature attached, check if TE active if(hasRnn){ passedL2Calo=ancestorPassed(te); } else { - passedL2Calo = ancestorPassed(te); + passedL2Calo = ancestorPassed(te); } passedEFCalo = ancestorPassed(te,"TrigEFCaloCalibFex"); @@ -701,11 +650,11 @@ float TrigEgammaAnalysisBaseTool::dR(const float eta1, const float phi1, const f Pi() - fabs(phi1 - phi2); return sqrt(deta*deta + dphi*dphi); } - + float TrigEgammaAnalysisBaseTool::getEta2(const xAOD::Egamma* eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - return fabs(cluster->etaBE(2)); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return fabs(cluster->etaBE(2)); } else return -99.; } @@ -713,16 +662,16 @@ float TrigEgammaAnalysisBaseTool::getEt(const xAOD::Electron* eg){ if(eg && (eg->caloCluster()) && (eg->trackParticle())){ const xAOD::TrackParticle *trk=eg->trackParticle(); const xAOD::CaloCluster *clus=eg->caloCluster(); - float eta = fabs(trk->eta()); - return clus->e()/cosh(eta); + float eta = fabs(trk->eta()); + return clus->e()/cosh(eta); } else return -99.; } float TrigEgammaAnalysisBaseTool::getEtCluster37(const xAOD::Egamma* eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - float eta2 = fabs(cluster->etaBE(2)); - return cluster->e()/cosh(eta2); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + float eta2 = fabs(cluster->etaBE(2)); + return cluster->e()/cosh(eta2); } else return -99.; } @@ -738,13 +687,13 @@ float TrigEgammaAnalysisBaseTool::getDEmaxs1(const xAOD::Egamma *eg){ else return -99.; } float TrigEgammaAnalysisBaseTool::rTRT (const xAOD::Electron* eg) { - if(eg && eg->trackParticle()){ + if(eg && eg->trackParticle()){ uint8_t trtHits = 0; eg->trackParticleSummaryValue(trtHits,xAOD::numberOfTRTHits); - uint8_t trtHTHits = 0; + uint8_t trtHTHits = 0; eg->trackParticleSummaryValue(trtHTHits,xAOD::numberOfTRTHighThresholdHits); if(trtHits!=0) { - return ( (double)trtHTHits / (double)trtHits ); + return ( (double)trtHTHits / (double)trtHits ); } else return -99.; } @@ -752,7 +701,7 @@ float TrigEgammaAnalysisBaseTool::rTRT (const xAOD::Electron* eg) { } float TrigEgammaAnalysisBaseTool::getSigmaD0(const xAOD::Electron *eg){ - const xAOD::TrackParticle* t = eg->trackParticle(); + const xAOD::TrackParticle* t = eg->trackParticle(); float d0sigma=0.; if (t) { @@ -767,7 +716,7 @@ float TrigEgammaAnalysisBaseTool::getSigmaD0(const xAOD::Electron *eg){ } float TrigEgammaAnalysisBaseTool::getD0sig(const xAOD::Electron *eg){ - const xAOD::TrackParticle* t = eg->trackParticle(); + const xAOD::TrackParticle* t = eg->trackParticle(); float d0sigma=0.; if (t) { @@ -784,41 +733,41 @@ float TrigEgammaAnalysisBaseTool::getD0sig(const xAOD::Electron *eg){ float TrigEgammaAnalysisBaseTool::getEnergyBE0(const xAOD::Egamma *eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - return cluster->energyBE(0); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(0); } else return 0; } float TrigEgammaAnalysisBaseTool::getEnergyBE1(const xAOD::Egamma *eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - return cluster->energyBE(1); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(1); } else return 0.; } float TrigEgammaAnalysisBaseTool::getEnergyBE2(const xAOD::Egamma *eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - return cluster->energyBE(2); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(2); } else return 0.; } float TrigEgammaAnalysisBaseTool::getEnergyBE3(const xAOD::Egamma *eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - return cluster->energyBE(3); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(3); } else return 0.; } float TrigEgammaAnalysisBaseTool::getEaccordion(const xAOD::Egamma *eg){ if(eg && (eg->caloCluster())){ - const xAOD::CaloCluster* cluster = eg->caloCluster(); - float ebe1 = cluster->energyBE(1); - float ebe2 = cluster->energyBE(2); + const xAOD::CaloCluster* cluster = eg->caloCluster(); + float ebe1 = cluster->energyBE(1); + float ebe2 = cluster->energyBE(2); float ebe3 = cluster->energyBE(3); return (ebe1+ebe2+ebe3); } @@ -828,9 +777,9 @@ float TrigEgammaAnalysisBaseTool::getEaccordion(const xAOD::Egamma *eg){ float TrigEgammaAnalysisBaseTool::getE0Eaccordion(const xAOD::Egamma *eg){ if(eg && (eg->caloCluster())){ const xAOD::CaloCluster* cluster = eg->caloCluster(); - float ebe0 = cluster->energyBE(0); - float ebe1 = cluster->energyBE(1); - float ebe2 = cluster->energyBE(2); + float ebe0 = cluster->energyBE(0); + float ebe1 = cluster->energyBE(1); + float ebe2 = cluster->energyBE(2); float ebe3 = cluster->energyBE(3); float eacc = ebe1+ebe2+ebe3; if(eacc==0.) return 0.; @@ -841,12 +790,12 @@ float TrigEgammaAnalysisBaseTool::getE0Eaccordion(const xAOD::Egamma *eg){ void TrigEgammaAnalysisBaseTool::setAvgOfflineMu() { float mu=0.; - + if(m_lumiBlockMuTool) mu=(float)m_lumiBlockMuTool->averageInteractionsPerCrossing(); else ATH_MSG_WARNING("Missing LumiBlockMuTool"); - + ATH_MSG_DEBUG("Offline Lumi " << mu); m_offmu=mu; } @@ -866,101 +815,101 @@ float TrigEgammaAnalysisBaseTool::getAvgMu(){ return m_onlmu; else if(m_offmu!=0.){ ATH_MSG_DEBUG("Using Offline Lumi info"); - return m_offmu; - } + return m_offmu; + } else if(m_onlmu==0. && m_offmu==0.){ ATH_MSG_DEBUG("Average Pileup 0.0 , no Lumi info."); return 0.0; } return 0.; } -/*! Macros for plotting */ +/*! Macros for plotting */ #define GETTER(_name_) float TrigEgammaAnalysisBaseTool::getShowerShape_##_name_(const xAOD::Egamma* eg) \ { float val{-99}; \ eg->showerShapeValue(val,xAOD::EgammaParameters::_name_); \ - return val; } + return val; } GETTER(e011) - GETTER(e132) + GETTER(e132) GETTER(e237) GETTER(e277) - GETTER(ethad) - GETTER(ethad1) + GETTER(ethad) + GETTER(ethad1) GETTER(weta1) GETTER(weta2) GETTER(f1) - GETTER(e2tsts1) + GETTER(e2tsts1) GETTER(emins1) GETTER(emaxs1) GETTER(wtots1) - GETTER(fracs1) - GETTER(Reta) - GETTER(Rphi) - GETTER(f3) + GETTER(fracs1) + GETTER(Reta) + GETTER(Rphi) + GETTER(f3) GETTER(f3core) GETTER(Eratio) GETTER(Rhad) - GETTER(Rhad1) -GETTER(DeltaE) + GETTER(Rhad1) +GETTER(DeltaE) #undef GETTER // GETTER for Isolation monitoring #define GETTER(_name_) float TrigEgammaAnalysisBaseTool::getIsolation_##_name_(const xAOD::Electron* eg) \ { float val{-99}; \ eg->isolationValue(val,xAOD::Iso::_name_); \ - return val; } + return val; } GETTER(ptcone20) GETTER(ptcone30) - GETTER(ptcone40) + GETTER(ptcone40) GETTER(ptvarcone20) GETTER(ptvarcone30) - GETTER(ptvarcone40) -#undef GETTER + GETTER(ptvarcone40) +#undef GETTER #define GETTER(_name_) float TrigEgammaAnalysisBaseTool::getIsolation_##_name_(const xAOD::Egamma* eg) \ { float val{-99}; \ eg->isolationValue(val,xAOD::Iso::_name_); \ - return val; } + return val; } GETTER(etcone20) GETTER(etcone30) - GETTER(etcone40) + GETTER(etcone40) GETTER(topoetcone20) GETTER(topoetcone30) - GETTER(topoetcone40) -#undef GETTER + GETTER(topoetcone40) +#undef GETTER - // GETTERs for CaloCluster monitoring + // GETTERs for CaloCluster monitoring #define GETTER(_name_) float TrigEgammaAnalysisBaseTool::getCluster_##_name_(const xAOD::Egamma* eg) \ { if(eg && eg->caloCluster()) \ return eg->caloCluster()->_name_(); \ else return -99.;} GETTER(et) GETTER(phi) -GETTER(eta) +GETTER(eta) #undef GETTER - // GETTERs for Track monitoring + // GETTERs for Track monitoring #define GETTER(_name_) float TrigEgammaAnalysisBaseTool::getTrack_##_name_(const xAOD::Electron* eg) \ { if(eg && eg->trackParticle()) \ return eg->trackParticle()->_name_(); \ else return -99.;} GETTER(pt) GETTER(phi) - GETTER(eta) - GETTER(d0) -GETTER(z0) + GETTER(eta) + GETTER(d0) +GETTER(z0) #undef GETTER - // GETTERs for Track details monitoring + // GETTERs for Track details monitoring #define GETTER(_name_) float TrigEgammaAnalysisBaseTool::getTrackSummary_##_name_(const xAOD::Electron* eg) \ { uint8_t val_uint8{0}; \ if(eg){ \ eg->trackParticleSummaryValue(val_uint8,xAOD::_name_); \ return val_uint8; } \ else return -99; } - GETTER(numberOfInnermostPixelLayerHits) - GETTER(numberOfInnermostPixelLayerOutliers) + GETTER(numberOfInnermostPixelLayerHits) + GETTER(numberOfInnermostPixelLayerOutliers) GETTER(numberOfPixelHits) GETTER(numberOfPixelOutliers) - GETTER(numberOfSCTHits) - GETTER(numberOfSCTOutliers) + GETTER(numberOfSCTHits) + GETTER(numberOfSCTOutliers) GETTER(numberOfTRTHits) GETTER(numberOfTRTHighThresholdHits) GETTER(numberOfTRTHighThresholdOutliers) @@ -980,7 +929,7 @@ GETTER(numberOfTRTXenonHits) else return -99; } GETTER(eProbabilityComb) GETTER(eProbabilityHT) -GETTER(pixeldEdx) +GETTER(pixeldEdx) #undef GETTER // GETTERs for Calo-Track monitoring @@ -991,17 +940,17 @@ GETTER(pixeldEdx) return val; } GETTER(deltaEta0) GETTER(deltaPhi0) - GETTER(deltaPhiRescaled0) + GETTER(deltaPhiRescaled0) GETTER(deltaEta1) GETTER(deltaPhi1) - GETTER(deltaPhiRescaled1) + GETTER(deltaPhiRescaled1) GETTER(deltaEta2) GETTER(deltaPhi2) - GETTER(deltaPhiRescaled2) + GETTER(deltaPhiRescaled2) GETTER(deltaEta3) GETTER(deltaPhi3) -GETTER(deltaPhiRescaled3) -#undef GETTER +GETTER(deltaPhiRescaled3) +#undef GETTER std::string TrigEgammaAnalysisBaseTool::getProbePid(const std::string pidtype){ static std::map PidMap; //no longer class member but static @@ -1027,12 +976,12 @@ std::string TrigEgammaAnalysisBaseTool::getL1Item(std::string trigger){ std::string L1_seed = ""; if(trig_conf != nullptr){ ATH_MSG_DEBUG("TrigConf available"); - L1_seed = trig_conf->lower_chain_name(); //L1 trigger seed + L1_seed = trig_conf->lower_chain_name(); //L1 trigger seed } - return L1_seed; + return L1_seed; } -void TrigEgammaAnalysisBaseTool::parseCaloRingsLayers( unsigned layer, unsigned &minRing, +void TrigEgammaAnalysisBaseTool::parseCaloRingsLayers( unsigned layer, unsigned &minRing, unsigned &maxRing, std::string &caloLayerName) { if(layer == 0){minRing = 0; maxRing = 7 ; caloLayerName = "PreSampler";} @@ -1043,8 +992,8 @@ void TrigEgammaAnalysisBaseTool::parseCaloRingsLayers( unsigned layer, unsigned if(layer == 5){minRing = 92; maxRing = 95; caloLayerName = "HAD2";} if(layer == 6){minRing = 96; maxRing = 99; caloLayerName = "HAD3";} } - - + + bool TrigEgammaAnalysisBaseTool::getTrigCaloRings( const xAOD::TrigEMCluster *emCluster, std::vector &ringsE){ ringsE.clear(); if(!emCluster) return false; @@ -1067,36 +1016,36 @@ bool TrigEgammaAnalysisBaseTool::getTrigCaloRings( const xAOD::TrigEMCluster *em bool TrigEgammaAnalysisBaseTool::getCaloRings( const xAOD::Electron * el, std::vector &ringsE ){ - + if(!el) return false; ringsE.clear(); auto ringsELReader = xAOD::getCaloRingsReader(); - // First, check if we can retrieve decoration: + // First, check if we can retrieve decoration: const xAOD::CaloRingsLinks *caloRingsLinks(nullptr); - try { + try { ATH_MSG_DEBUG("getCaloRingsReader->operator()(*el)"); - caloRingsLinks = &(ringsELReader->operator()(*el)); - } catch ( const std::exception &e) { - ATH_MSG_WARNING("Couldn't retrieve CaloRingsELVec. Reason: " << e.what()); + caloRingsLinks = &(ringsELReader->operator()(*el)); + } catch ( const std::exception &e) { + ATH_MSG_WARNING("Couldn't retrieve CaloRingsELVec. Reason: " << e.what()); return false; - } + } if( caloRingsLinks ){ - if ( caloRingsLinks->empty() ){ + if ( caloRingsLinks->empty() ){ ATH_MSG_WARNING("Particle does not have CaloRings decoratorion."); return false; } const xAOD::CaloRings *clrings=nullptr; try { - // For now, we are using only the first cluster + // For now, we are using only the first cluster clrings = *(caloRingsLinks->at(0)); } catch(const std::exception &e){ - ATH_MSG_WARNING("Couldn't retrieve CaloRings. Reason: " << e.what()); + ATH_MSG_WARNING("Couldn't retrieve CaloRings. Reason: " << e.what()); return false; } - // For now, we are using only the first cluster + // For now, we are using only the first cluster if(clrings) { ATH_MSG_DEBUG("exportRingsTo..."); clrings->exportRingsTo(ringsE); @@ -1130,7 +1079,7 @@ void TrigEgammaAnalysisBaseTool::calculatePileupPrimaryVertex(){ (nTrackParticles >= 2 && vxContainer->at(ivx)->vertexType() == xAOD::VxType::PileUp) ) m_nPVertex++; }// loop over vertexs - } + } }// protection ATH_MSG_DEBUG("calculatePileupPrimaryVertex(): nPileupPrimaryVtx = " << m_nPVertex); } @@ -1150,8 +1099,8 @@ MonteCarlo::PDGID TrigEgammaAnalysisBaseTool::pdgid(const xAOD::Egamma *eg, cons e=true; size_t nParents = mc->nParents(); for(size_t iparent = 0; iparent < nParents; ++iparent){ - if((mc->parent(iparent))->isZ()) Z = true; - if((mc->parent(iparent))->isW()) W = true; + if((mc->parent(iparent))->isZ()) Z = true; + if((mc->parent(iparent))->isW()) W = true; } }else if(mc->isPhoton()){ g=true; @@ -1174,9 +1123,9 @@ MonteCarlo::PDGID TrigEgammaAnalysisBaseTool::pdgid(const xAOD::Egamma *eg, cons return MonteCarlo::PDGID::ZMother; }else if(e && W){ return MonteCarlo::PDGID::WMother; - }else if(e && !(Z||W)){ + }else if(e && !(Z||W)){ return MonteCarlo::PDGID::Electron; - }else if(g){ + }else if(g){ return MonteCarlo::PDGID::Photon; }else{ return MonteCarlo::PDGID::Unknown; @@ -1186,7 +1135,7 @@ MonteCarlo::PDGID TrigEgammaAnalysisBaseTool::pdgid(const xAOD::Egamma *eg, cons } bool TrigEgammaAnalysisBaseTool::write_trigger_list( const std::vector &triggerList ){ - + std::ofstream ofile("HLTTriggerList.txt"); if (!ofile.is_open()) return false; ofile << "=================> List of triggers <==================\n"; @@ -1197,44 +1146,6 @@ bool TrigEgammaAnalysisBaseTool::write_trigger_list( const std::vector MGlookup) { - m_MGlookup = MGlookup; -} - -void TrigEgammaAnalysisBaseTool::setDetail(bool detail) { - m_detailedHists=detail; -} - -void TrigEgammaAnalysisBaseTool::setTP(bool tp) { - m_tp=tp; -} - -void TrigEgammaAnalysisBaseTool::setEmulation(bool doEmu) { - m_doEmulation=doEmu; -} - -void TrigEgammaAnalysisBaseTool::setEmulationTool(ToolHandle tool) { - m_emulationTool=tool; -} - -void TrigEgammaAnalysisBaseTool::setPVertex(const float onvertex, const float ngoodvertex) { - m_nPVertex = onvertex; - m_nGoodVertex = ngoodvertex; -} - -void TrigEgammaAnalysisBaseTool::setAvgMu(const float onlmu, const float offmu) { - m_onlmu=onlmu; - m_offmu=offmu; -} - -void TrigEgammaAnalysisBaseTool::setSGContainsRnn(bool contains) { - m_sgContainsRnn=contains; -} - -void TrigEgammaAnalysisBaseTool::setSGContainsTrigPhoton(bool contains) { - m_sgContainsTrigPhoton=contains; -} - // definitions const std::vector TrigEgammaAnalysisBaseTool::m_trigLevel = {"L1Calo","L2Calo","L2","EFCalo","EFTrack","HLT"}; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx index 5b4cf372ddf..c26e62ee4b7 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ /********************************************************************** @@ -51,7 +51,7 @@ StatusCode TrigEgammaDistTool::childFinalize(){ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo info, std::vector> pairObjs){ ATH_MSG_DEBUG("Executing Distribution for " << basePath); - + // Require that at least 1 offline selected object in event // Trigger distributions not entirely dependent from offline analysis // @@ -78,7 +78,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i } } else { - + for(const auto pairObj : pairObjs){ fillShowerShapes(dir+"Offline",pairObj.first); // Fill Offline shower shapes if(xAOD::EgammaHelpers::isElectron(pairObj.first)) { // Fill offline tracking @@ -266,7 +266,7 @@ void TrigEgammaDistTool::fillEFCalo(const std::string &dir, const xAOD::CaloClus ATH_MSG_DEBUG("Energy " << clus->e()/1.e3); ATH_MSG_DEBUG("eta " << clus->eta()); ATH_MSG_DEBUG("phi " << clus->phi()); - + double tmpeta = -999.; if(!clus->retrieveMoment(xAOD::CaloCluster::ETACALOFRAME,tmpeta)) tmpeta=-999.; @@ -275,7 +275,7 @@ void TrigEgammaDistTool::fillEFCalo(const std::string &dir, const xAOD::CaloClus tmpphi=-999.; ATH_MSG_DEBUG("etacalo " << tmpeta); ATH_MSG_DEBUG("phicalo " << tmpphi); - + hist1("energyBE0")->Fill(clus->energyBE(0)/1.e3); hist1("energyBE1")->Fill(clus->energyBE(1)/1.e3); hist1("energyBE2")->Fill(clus->energyBE(2)/1.e3); @@ -345,24 +345,26 @@ void TrigEgammaDistTool::fillShowerShapes(const std::string &dir,const xAOD::Ega hist1("topoetcone20_rel")->Fill(getIsolation_topoetcone20(eg)/eg->pt()); hist1("topoetcone40_shift_rel")->Fill((getIsolation_topoetcone40(eg)-2450)/eg->pt()); } - // Fill the LH discriminant for LH tight medium and loose -> Not working *YET* in master. I'll keep it here so I can uncomment when fixed - // ATH_MSG_DEBUG("Computing the lh discriminant!"); - // auto ctx = Gaudi::Hive::currentContext() ; - // try { - // hist1("lhtight_discriminant")->Fill(m_electronLHTool[0]->calculate(ctx, eg)); - // hist1("lhmedium_discriminant")->Fill(m_electronLHTool[1]->calculate(ctx, eg)); - // hist1("lhloose_discriminant")->Fill(m_electronLHTool[2]->calculate(ctx, eg)); - // } catch(const ValidationException &e) { - // ATH_MSG_WARNING("Exception thrown: " << e.msg() << " not computing lh discriminants!"); - // } catch(...) { - // ATH_MSG_WARNING("Unknown exception caught, while computing lh discriminants!. Ignoring"); - // } - + // Fill the LH discriminant for LH tight medium and loose -> Not working *YET* in master. I'll keep it here so I can uncomment when fixed + // ATH_MSG_DEBUG("Computing the lh discriminant!"); + // auto ctx = Gaudi::Hive::currentContext() ; + // try { + // hist1("lhtight_discriminant")->Fill(m_electronLHTool[0]->calculate(ctx, eg)); + // hist1("lhmedium_discriminant")->Fill(m_electronLHTool[1]->calculate(ctx, eg)); + // hist1("lhloose_discriminant")->Fill(m_electronLHTool[2]->calculate(ctx, eg)); + // } catch(const ValidationException &e) { + // ATH_MSG_WARNING("Exception thrown: " << e.msg() << " not computing lh discriminants!"); + // } catch(...) { + // ATH_MSG_WARNING("Unknown exception caught, while computing lh discriminants!. Ignoring"); + // } + + + } } void TrigEgammaDistTool::fillTracking(const std::string &dir, const xAOD::Electron *eg){ - cd(dir); + cd(dir); ATH_MSG_DEBUG("Fill tracking"); if(!eg) ATH_MSG_WARNING("Electron pointer fails"); else { @@ -382,14 +384,14 @@ void TrigEgammaDistTool::fillTracking(const std::string &dir, const xAOD::Electr hist1("deta2")->Fill(getCaloTrackMatch_deltaEta2(eg)); hist1("dphi2")->Fill(getCaloTrackMatch_deltaPhi2(eg)); hist1("dphiresc")->Fill(getCaloTrackMatch_deltaPhiRescaled2(eg)); - - + + hist1("eprobht")->Fill(getTrackSummaryFloat_eProbabilityHT(eg)); hist1("npixhits")->Fill(getTrackSummary_numberOfPixelHits(eg)); hist1("nscthits")->Fill(getTrackSummary_numberOfSCTHits(eg)); hist1("charge")->Fill(eg->charge()); hist1("ptcone20")->Fill(getIsolation_ptcone20(eg)/1e3); - + hist1("ptvarcone20")->Fill(getIsolation_ptvarcone20(eg)/1e3); // Quantities directly from tracks ATH_MSG_DEBUG("Get track Quantities"); @@ -406,11 +408,3 @@ void TrigEgammaDistTool::fillTracking(const std::string &dir, const xAOD::Electr } } - -void TrigEgammaDistTool::setDetail(bool doDetail) { - m_detailedHists = doDetail; -} - -void TrigEgammaDistTool::setTP(bool tp) { - m_tp = tp; -} diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaEventSelection.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaEventSelection.cxx new file mode 100644 index 00000000000..98545bb95a2 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaEventSelection.cxx @@ -0,0 +1,1209 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +/********************************************************************** + * AsgTool: TrigEgammaEventSelection + * Authors: + * Ryan Mackenzie White + * Denis Damazio + * Contributors: + * Joao Victor da Fonseca Pinto + * Date: Mar 2015 + * Description: + * Derived class for dumping the probe information into a ttree. + * + **********************************************************************/ + +#include "TrigEgammaAnalysisTools/TrigEgammaEventSelection.h" +#include "GaudiKernel/SystemOfUnits.h" +using namespace std; + +TrigEgammaEventSelection::TrigEgammaEventSelection( const std::string& myname ): + TrigEgammaNavTPBaseTool(myname) , TrigEgammaPhysValBase() +{ + m_eventCounter = 0; + declareProperty("CutLabels" , m_cutlabels ); + declareProperty("Analysis" , m_anatype="EventSelection"); + declareProperty("SelectionZ" , m_selectionZ=true ); + declareProperty("SelectionFakes" , m_selectionFakes=false ); + declareProperty("SelectionMC" , m_selectionMC=false ); + declareProperty("SelectionW" , m_selectionW=false ); + declareProperty("SelectionJpsi" , m_selectionJpsi=false ); + declareProperty("DumpTags" , m_dumpTags=false ); + declareProperty("DetailedDataLevel" , m_detailedDataLevel=0 ); + declareProperty("ElectronLHVLooseTool" , m_electronLHVLooseTool ); + + + declareProperty("HLTElectronLikelihoodSelector" , m_HLTElectronLHSelectors ); + declareProperty("EFCaloElectronLikelihoodSelector" , m_EFCaloElectronLHSelectors ); + declareProperty("EFCaloElectronIsEMSelector" , m_EFCaloElectronIsEMSelectors ); + declareProperty("HLTElectronIsEMSelector" , m_HLTElectronIsEMSelectors ); + + m_doCaloRings=false; +} + +StatusCode TrigEgammaEventSelection::childInitialize(){ + + if ( (m_electronLHVLooseTool.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve VeryLoose LH Selector Tool! Can't work"); + return StatusCode::FAILURE; + } + + if ( (m_EFCaloElectronLHSelectors.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve EFCalo LH Selector Tool! Can't work"); + return StatusCode::FAILURE; + } + + if ( (m_EFCaloElectronIsEMSelectors.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve EFCalo IsEM Selector Tool! Can't work"); + return StatusCode::FAILURE; + } + if ( (m_HLTElectronLHSelectors.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve HLT LH Selector Tool! Can't work"); + return StatusCode::FAILURE; + } + if ( (m_HLTElectronIsEMSelectors.retrieve()).isFailure() ){ + ATH_MSG_ERROR( "Could not retrieve HLT IsEM Selector Tool! Can't work"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + + +StatusCode TrigEgammaEventSelection::childBook(){ + + ATH_MSG_DEBUG("Now configuring chains for analysis"); + //Set the base directory from the plot() + m_dir=plot()->getBasePath(); + std::vector chains = tdt()->getListOfTriggers("HLT_e.*, L1_EM.*, HLT_g.*"); + + TrigEgammaAnalysisBaseTool::write_trigger_list(chains); + + if(!getEmulation()){ + ATH_MSG_ERROR("Emulation tool was not set. This tool use the emulation to retrievea all support objects. Please, enable this!"); + return StatusCode::FAILURE; + } + + + for(const auto trigName:m_trigInputList){ + if (std::find(chains.begin(), chains.end(), trigName) != chains.end()){ + if(plot()->getTrigInfoMap().count(trigName) != 0) + ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); + else{ + m_trigList.push_back(trigName); + setTrigInfo(trigName); + } + }else if(getEmulation() && m_forceTrigAttachment){// + ATH_MSG_DEBUG("Trigger doesn't exist in menu. Attach to emulate."); + if(plot()->getTrigInfoMap().count(trigName) == 0){ + std::string parent; + m_trigList.push_back(trigName); + setTrigEmulation(); + setTrigInfo(trigName); + } + }// emulation + } + + // set the correct schema level to save + /* 0 is very slim schema + * 1 is slim + * 2 is full */ + if(m_detailedDataLevel > 0 ){ + m_doL2Detailed=true; + m_doL2CaloDetailed=true; + } + if(m_detailedDataLevel > 1){ + m_doRecoDetailed=true; + m_doMCDetailed=true; + } + + + // Book histograms for average efficiencies and counters + //const int nTrigger = (int) m_trigList.size(); + addDirectory(m_dir+"/Expert/Event"); + std::string histname=m_anatype+"_ProbeCutCounter"; + addHistogram(new TH1F(histname.c_str(), "Number of Probes; Cut ; Count", 12, 0., 12)); + histname=m_anatype+"_TagCutCounter"; + addHistogram(new TH1F(histname.c_str(), "Number of Tags; Cut ; Count", 10, 0., 10)); + histname=m_anatype+"_Mee"; + addHistogram(new TH1F(histname.c_str(), "Offline M(ee); m_ee [GeV] ; Count", 50, m_ZeeMassMin, m_ZeeMassMax)); + histname=m_anatype+"_CutCounter"; + addHistogram(new TH1I(histname.c_str(), "Event Selection; Cut ; Count", 6, 0., 6)); + setLabels(hist1(histname),m_cutlabels); + + + addDirectory(m_dir+"/Egamma"); + + // create the TDT metadata for future access + TTree *tdtMetadata = new TTree("tdt", "Trigger metadata navigation"); + createTDTMetadata( tdtMetadata, m_trigList ); + addTree(tdtMetadata, m_dir+"/Egamma"); + + if(m_selectionZ){ + if(m_dumpTags){ + TTree *tag = new TTree( "tags", "tree of Offline Zee tags"); + bookEventBranches( tag ); + bookElectronBranches( tag ); + bookTriggerBranches( tag ); + bookTDTBranches( tag ); + bookMonteCarloBranches( tag ); + addTree(tag, m_dir+"/Egamma"); + } + TTree *probe = new TTree( "probes", "tree of Zee probes"); + bookEventBranches( probe ); + bookElectronBranches( probe ); + bookTriggerBranches( probe ); + bookTDTBranches( probe ); + bookMonteCarloBranches( probe ); + + addTree(probe, m_dir+"/Egamma"); + } + + if(m_selectionFakes){ + TTree *fakes = new TTree( "fakes", "tree of Fakes"); + bookEventBranches( fakes ); + bookElectronBranches( fakes ); + bookTriggerBranches( fakes ); + bookTDTBranches( fakes ); + bookMonteCarloBranches( fakes ); + addTree(fakes, m_dir+"/Egamma"); + } + + + + // Check for Rnn container in SG + if(m_storeGate->contains("HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFex")){ + ATH_MSG_DEBUG("Rnn container in SG "); + setSGContainsRnn(true); + } + + + if(m_storeGate->contains("ElectronCaloRings")){ + ATH_MSG_DEBUG("Offline electron calo rings in SG"); + m_doCaloRings=true; + } + + + ///Alloc pointers + alloc_space(); + return StatusCode::SUCCESS; +} + +StatusCode TrigEgammaEventSelection::childExecute(){ + + m_eventCounter++; + + cd(m_dir+"/Expert/Event"); + + // Event Wise Selection (independent of the required signatures) + if ( !TrigEgammaNavTPBaseTool::EventWiseSelection() ) return StatusCode::SUCCESS; + + // Pass by errors in EventInfo + if( !TrigEgammaNavTPBaseTool::passesEventCleaning() ) return StatusCode::SUCCESS; + + // nvtx > 0 + if( getNPVtx() <= 0 ) return StatusCode::SUCCESS; + + if(m_selectionZ) + EventSelectionZ(); + + if(m_selectionFakes) + EventSelectionFakes(); + + + return StatusCode::SUCCESS; +} + +bool TrigEgammaEventSelection::EventSelectionZ(){ + + ATH_MSG_INFO("In EventSelectonZ..."); + // execute the standard tag and probe method + TrigEgammaNavTPBaseTool::executeTandP(); + cd(m_dir+"/Egamma"); + + for(auto Z : m_Z){ + const xAOD::Electron *elTag = m_offElectrons->at(Z.first); + const xAOD::Electron *elProbe = m_offElectrons->at(Z.second); + if(m_dumpTags) + fill( tree("tags" , m_dir+"/Egamma") , elTag ); + fill( tree("probes", m_dir+"/Egamma") , elProbe ); + + }// Loop over pairs + + return true; +} + +bool TrigEgammaEventSelection::EventSelectionFakes(){ + + + ATH_MSG_INFO("In EventSelectonFakes..."); + + for(const auto& elTag : *m_offElectrons){ + + // Remove electrons from Z or W if this is Monte Carlo + if(m_selectionMC && !isTruthElectronAny( elTag )) continue; + + if (!elTag->isGoodOQ(xAOD::EgammaParameters::BADCLUSELECTRON)) continue; + + if(!elTag->trackParticle()) continue; + + // Default is 4 GeV + if( !(elTag->e()/cosh(elTag->trackParticle()->eta()) > m_probeMinEt*Gaudi::Units::GeV) ) continue; + + //fiducial detector acceptance region + float absEta = fabs(elTag->caloCluster()->etaBE(2)); + if (absEta > 2.47) continue; + + if( !(getWTransverseMass(elTag) < 40000) ) continue; + + bool passesZveto=true; + + // If we can find any pair that falls in the Zmass window we fail the passesZveto cut + for(const auto& elProbe : *m_offElectrons){ + + if(elTag == elProbe) continue; + + if(!elProbe->isGoodOQ(xAOD::EgammaParameters::BADCLUSELECTRON)) continue; + + if(!elProbe->trackParticle()) continue; + + // Must be higher than 4 GeV + if( (getEt(elProbe)) < 4*Gaudi::Units::GeV) continue; + + if(!TrigEgammaNavTPBaseTool::ApplyElectronPid(elProbe,"LHMedium")) { + ATH_MSG_DEBUG("Probe deas *not* pass LHMedium. Skipping..."); + continue; + } + + //Must be an easy way with IParticle + TLorentzVector el1; + TLorentzVector el2; + el1.SetPtEtaPhiE(elTag->pt(), elTag->trackParticle()->eta(), elTag->trackParticle()->phi(), elTag->e()); + el2.SetPtEtaPhiE(elProbe->pt(), elProbe->trackParticle()->eta(), elProbe->trackParticle()->phi(), elProbe->e()); + float tpPairMass = (el1 + el2).M(); + if( !((tpPairMass > m_ZeeMassMin*Gaudi::Units::GeV) && (tpPairMass < m_ZeeMassMax*Gaudi::Units::GeV))){ + ATH_MSG_DEBUG("tag and probe pair not in Z mass window"); + continue; + }else{ + ATH_MSG_INFO("tag and probe pain in Z mass window. Regect the electron..."); + passesZveto=false; + break; + } + }// Loop over probes electrons + + if(!passesZveto) continue; + + ATH_MSG_INFO("Appling Fire trigger..."); + if(!ApplyFireTriggers( elTag )) continue; + + if(TrigEgammaNavTPBaseTool::ApplyElectronPid(elTag,"LHTight")) continue; + + ATH_MSG_INFO("Fill electron..."); + fill( tree("fakes" , m_dir+"/Egamma") , elTag ); + + + }// Loop over electrons + + return true; +} + + + +bool TrigEgammaEventSelection::fill( TTree *t, const xAOD::Electron *el){ + + + linkEventBranches(t); + linkElectronBranches(t); + linkTriggerBranches(t); + linkMonteCarloBranches(t); + + const HLT::TriggerElement* feat=nullptr; + + if(getEmulation()) + emulation()->match( el, feat ); + else{ + ATH_MSG_ERROR("Emulation tool was not configurated. Impossible to match! Please, see your python config."); + return false; + } + + if(feat){ + clear(); + fillEvent(); + fillElectron( el ); + + if(!fillMonteCarlo( el ) ){ + ATH_MSG_WARNING("Cound not found any TruthParticle for this Electron"); + } + + ///Start trigger analisys... + const xAOD::EmTauRoI *emTauRoI = getFeature(feat); + if(emTauRoI){ + fillEmTauRoI( emTauRoI ); + }else{ + ATH_MSG_WARNING("Cound not found EmTauRoI in this TriggerElement.."); + } + + const xAOD::TrigEMCluster *emCluster = getFeature(feat); + if(emCluster){ + if(!fillTrigEMCluster( emCluster )){ + ATH_MSG_WARNING("Cound not attach the trigEMCluster information into the tree."); + } + + if(!fillTrigCaloRings( feat )){ + ATH_MSG_WARNING("Cound not attach the TrigRingerRings information into the tree."); + } + }///cluster protection + + + const xAOD::TrigElectronContainer *trigElCont = getFeature(feat); + // Level 2 ID+Calo + if(trigElCont){ + for(const auto& trigEl : *trigElCont){ + if(!fillTrigElectron(trigEl)) { + ATH_MSG_WARNING("Cound not attach the trigElectron information into the tree."); + } + }// loop over all trigElectrons for this feat + } + + const xAOD::CaloClusterContainer *caloCont = getFeature(feat); + if(caloCont){ + for(const auto& cl : *caloCont){ + if(!fillCaloCluster(cl)){ + ATH_MSG_WARNING("Cound not attach the CaloCluster information into the tree."); + } + }// loop over calo cluster + } + + + const xAOD::ElectronContainer *elCont = getFeature(feat); + + if(elCont){ + for(const auto& hlt_el : *elCont){ + if(!fillHLTElectron(hlt_el)) + ATH_MSG_WARNING("Cound not attach the HLT Electron information into the tree."); + } + } + + + fillTDT( el, feat ); + + + ATH_MSG_INFO("recording trigger information into the file."); + t->Fill(); + }//loop over trigger objects + + return true; +} + + +bool TrigEgammaEventSelection::fillTDT(const xAOD::Electron *el , const HLT::TriggerElement *te){ + + ATH_MSG_DEBUG("FillTDT..."); + for(auto& trigItem : m_trigList){ + + const HLT::TriggerElement* feat=nullptr; + match()->match(el, trigItem, feat); + if(feat){ + asg::AcceptData acceptData = setAccept(feat, getTrigInfo(trigItem)); + bool passedL1Calo = acceptData.getCutResult("L1Calo"); + bool passedL2Calo = acceptData.getCutResult("L2Calo"); + bool passedL2 = acceptData.getCutResult("L2"); + bool passedEFCalo = acceptData.getCutResult("EFCalo"); + bool passedHLT = acceptData.getCutResult("HLT"); + m_trig_tdt_L1_calo_accept->push_back( int(passedL1Calo) ); + m_trig_tdt_L2_calo_accept->push_back( int(passedL2Calo) ); + m_trig_tdt_L2_el_accept->push_back( int(passedL2) ); + m_trig_tdt_EF_calo_accept->push_back( int(passedEFCalo) ); + m_trig_tdt_EF_el_accept->push_back( int(passedHLT) ); + //m_trig_tdt_emu_decision_mask + count("tdt_"+trigItem+"_total"); + if(passedL1Calo) count("tdt_"+trigItem+"_L1Calo"); + if(passedL2Calo) count("tdt_"+trigItem+"_L2Calo"); + if(passedL2) count("tdt_"+trigItem+"_L2" ); + if(passedEFCalo) count("tdt_"+trigItem+"_EFCalo"); + if(passedHLT) count("tdt_"+trigItem+"_HLT" ); + + }else{ + m_trig_tdt_L1_calo_accept->push_back( -1 ); + m_trig_tdt_L2_calo_accept->push_back( -1 ); + m_trig_tdt_L2_el_accept->push_back( -1 ); + m_trig_tdt_EF_calo_accept->push_back( -1 ); + m_trig_tdt_EF_el_accept->push_back( -1 ); + } + + if(te && getEmulation()){ + asg::AcceptData acceptData = emulation()->executeTool(te, trigItem); + bool passedL1Calo = acceptData.getCutResult("L1Calo"); + bool passedL2Calo = acceptData.getCutResult("L2Calo"); + bool passedL2 = acceptData.getCutResult("L2"); + bool passedEFCalo = acceptData.getCutResult("EFCalo"); + bool passedHLT = acceptData.getCutResult("HLT"); + m_trig_tdt_emu_L1_calo_accept->push_back( int(passedL1Calo) ); + m_trig_tdt_emu_L2_calo_accept->push_back( int(passedL2Calo) ); + m_trig_tdt_emu_L2_el_accept->push_back( int(passedL2) ); + m_trig_tdt_emu_EF_calo_accept->push_back( int(passedEFCalo) ); + m_trig_tdt_emu_EF_el_accept->push_back( int(passedHLT) ); + //m_trig_tdt_emu_decision_mask + count("emu_"+trigItem+"_total"); + if(passedL1Calo) count("emu_"+trigItem+"_L1Calo"); + if(passedL2Calo) count("emu_"+trigItem+"_L2Calo"); + if(passedL2) count("emu_"+trigItem+"_L2" ); + if(passedEFCalo) count("emu_"+trigItem+"_EFCalo"); + if(passedHLT) count("emu_"+trigItem+"_HLT" ); + }else{ + m_trig_tdt_emu_L1_calo_accept->push_back( -1 ); + m_trig_tdt_emu_L2_calo_accept->push_back( -1 ); + m_trig_tdt_emu_L2_el_accept->push_back( -1 ); + m_trig_tdt_emu_EF_calo_accept->push_back( -1 ); + m_trig_tdt_emu_EF_el_accept->push_back( -1 ); + } + + + }// Loop over triggers + + + return true; + +} + + + +bool TrigEgammaEventSelection::fillTrigCaloRings( const HLT::TriggerElement *feat ){ + + ATH_MSG_DEBUG("FillTrigCaloRings..."); + /* try to get the calo rings energy for this TE!*/ + const xAOD::TrigRingerRings *ringer = getFeature(feat); + if(ringer){// from this TE + for(unsigned r=0; rsize(); ++r){ + m_trig_L2_calo_rings->push_back(ringer->rings()[r]); + } + }else{// from others TEs + const xAOD::TrigEMCluster *emCluster = getFeature(feat); + if(emCluster){ + // try to match without any other cluster. + TrigEgammaAnalysisBaseTool::getTrigCaloRings(emCluster, *m_trig_L2_calo_rings); + }else{ + return false; + } + } + + if(getSGContainsRnn()){ + /* try to retrieve the NN output from this TE*/ + const xAOD::TrigRNNOutput *rnn = getFeature(feat); + if(rnn){ + for(unsigned o=0; ornnDecision().size(); ++o) + m_trig_L2_calo_rnnOutput->push_back(rnn->rnnDecision()[o]); + }else{ + ATH_MSG_WARNING("Cound not attach the TrigRNNOutput information into the tree."); + } + } + return true; +} + + + + +bool TrigEgammaEventSelection::ApplyFireTriggers( const xAOD::Electron *el){ + + float et = getEt(el); + + std::string trigger=""; + + if(et < 5*Gaudi::Units::GeV){ + return false; + }else if(et >= 5*Gaudi::Units::GeV && et < 10*Gaudi::Units::GeV){ + trigger = "HLT_e5_etcut"; + }else if(et >= 10*Gaudi::Units::GeV && et < 15*Gaudi::Units::GeV){ + trigger = "HLT_e10_etcut_L1EM7"; + }else if(et >= 15*Gaudi::Units::GeV && et < 20*Gaudi::Units::GeV){ + trigger = "HLT_e15_etcut_L1EM7"; + }else if(et >= 20*Gaudi::Units::GeV && et < 25*Gaudi::Units::GeV){ + trigger = "HLT_e20_etcut_L1EM12"; + }else if(et >= 25*Gaudi::Units::GeV && et < 30*Gaudi::Units::GeV){ + trigger = "HLT_e25_etcut_L1EM15"; + }else if(et >= 30*Gaudi::Units::GeV && et < 40*Gaudi::Units::GeV){ + trigger = "HLT_e30_etcut_L1EM15"; + }else if(et >= 40*Gaudi::Units::GeV && et < 50*Gaudi::Units::GeV){ + trigger = "HLT_e40_etcut_L1EM15"; + }else if(et >= 50*Gaudi::Units::GeV && et < 60*Gaudi::Units::GeV){ + trigger = "HLT_e50_etcut_L1EM15"; + }else if(et >= 50*Gaudi::Units::GeV && et < 60*Gaudi::Units::GeV){ + trigger = "HLT_e60_etcut"; + }else if(et >= 60*Gaudi::Units::GeV && et < 70*Gaudi::Units::GeV){ + trigger = "HLT_e70_etcut"; + }else if(et >= 70*Gaudi::Units::GeV && et < 80*Gaudi::Units::GeV){ + trigger = "HLT_e80_etcut"; + }else if(et >= 80*Gaudi::Units::GeV && et < 100*Gaudi::Units::GeV){ + trigger = "HLT_e100_etcut"; + }else if(et >= 100*Gaudi::Units::GeV && et < 120*Gaudi::Units::GeV){ + trigger = "HLT_e120_etcut"; + }else{ + return true; + } + + const HLT::TriggerElement *te; + match()->match(el,trigger,te); + bool passedHLT = ancestorPassed(te); + + if(!passedHLT) return false; + + return true; +} + + + +StatusCode TrigEgammaEventSelection::childFinalize(){ + + for(auto& trigItem : m_trigList){ + ATH_MSG_DEBUG("From TDT tool:"); + ATH_MSG_DEBUG(trigItem << " total = " << m_countMap["tdt_"+trigItem+"_total"] ); + ATH_MSG_DEBUG(trigItem << " L1Calo = " << m_countMap["tdt_"+trigItem+"_L1Calo"]); + ATH_MSG_DEBUG(trigItem << " L2Calo = " << m_countMap["tdt_"+trigItem+"_L2Calo"]); + ATH_MSG_DEBUG(trigItem << " L2 = " << m_countMap["tdt_"+trigItem+"_L2"] ); + ATH_MSG_DEBUG(trigItem << " EFCalo = " << m_countMap["tdt_"+trigItem+"_EFCalo"]); + ATH_MSG_DEBUG(trigItem << " HLT = " << m_countMap["tdt_"+trigItem+"_HLT"] ); + ATH_MSG_DEBUG("From emulation tool:"); + ATH_MSG_DEBUG(trigItem << " total = " << m_countMap["emu_"+trigItem+"_total"] ); + ATH_MSG_DEBUG(trigItem << " L1Calo = " << m_countMap["emu_"+trigItem+"_L1Calo"]); + ATH_MSG_DEBUG(trigItem << " L2Calo = " << m_countMap["emu_"+trigItem+"_L2Calo"]); + ATH_MSG_DEBUG(trigItem << " L2 = " << m_countMap["emu_"+trigItem+"_L2"] ); + ATH_MSG_DEBUG(trigItem << " EFCalo = " << m_countMap["emu_"+trigItem+"_EFCalo"]); + ATH_MSG_DEBUG(trigItem << " HLT = " << m_countMap["emu_"+trigItem+"_HLT"] ); + } + return StatusCode::SUCCESS; +} + + +bool TrigEgammaEventSelection::fillEmTauRoI( const xAOD::EmTauRoI *emTauRoI ){ + + ATH_MSG_DEBUG("FillEmTauRoI..."); + m_trig_L1_eta = emTauRoI->eta(); + m_trig_L1_phi = emTauRoI->phi(); + m_trig_L1_emClus = emTauRoI->emClus(); + m_trig_L1_tauClus = emTauRoI->tauClus(); + m_trig_L1_emIsol = emTauRoI->emIsol(); + m_trig_L1_hadIsol = emTauRoI->hadIsol(); + m_trig_L1_hadCore = emTauRoI->hadCore(); + return true; +} + +bool TrigEgammaEventSelection::fillTrigEMCluster( const xAOD::TrigEMCluster *emCluster ){ + + ATH_MSG_DEBUG("FillTrigEMCluster..."); + m_trig_L2_calo_et = emCluster->et(); + m_trig_L2_calo_eta = emCluster->eta(); + m_trig_L2_calo_phi = emCluster->phi(); + m_trig_L2_calo_emaxs1 = emCluster->emaxs1(); + m_trig_L2_calo_e2tsts1 = emCluster->e2tsts1(); + m_trig_L2_calo_e237 = emCluster->e237(); + m_trig_L2_calo_e277 = emCluster->e277(); + m_trig_L2_calo_ehad1 = emCluster->ehad1(); + m_trig_L2_calo_weta2 = emCluster->weta2(); + m_trig_L2_calo_wstot = emCluster->wstot(); + m_trig_L2_calo_fracs1 = emCluster->fracs1(); + for(unsigned i=0; ienergySample().size(); ++i){ + m_trig_L2_calo_energySample->push_back( emCluster->energySample().at(i)); + } + + return true; +} + + +bool TrigEgammaEventSelection::fillTrigElectron( const xAOD::TrigElectron *trigEl ){ + ATH_MSG_DEBUG("FillTrigElectron..."); + //const xAOD::TrackParticle* trkIter = trigEl->trackParticle(); + //if (trkIter==nullptr) return false; // disconsider candidates without track + //int algoId = 0; + //if ( trkIter->patternRecoInfo()[xAOD::TrackPatternRecoInfo::FastTrackFinderSeed] ) algoId=9; + //if ( trkIter->patternRecoInfo()[xAOD::TrackPatternRecoInfo::strategyA] ) algoId=5; + //if ( trkIter->patternRecoInfo()[xAOD::TrackPatternRecoInfo::strategyB] ) algoId=6; + //if ( trkIter->patternRecoInfo()[xAOD::TrackPatternRecoInfo::strategyC] ) algoId=7; + + //m_trig_L2_el_trackAlgID ->push_back(algoId); + m_trig_L2_el_caloEta ->push_back(trigEl->caloEta()); + m_trig_L2_el_trkClusDphi ->push_back(trigEl->trkClusDphi()); + m_trig_L2_el_trkClusDeta ->push_back(trigEl->trkClusDeta()); + m_trig_L2_el_pt ->push_back(trigEl->pt()); + m_trig_L2_el_phi ->push_back(trigEl->phi()); + m_trig_L2_el_eta ->push_back(trigEl->eta()); + m_trig_L2_el_etOverPt ->push_back(trigEl->etOverPt()); + m_trig_L2_el_nTRTHits ->push_back(trigEl->nTRTHits()); + m_trig_L2_el_nTRTHiThresholdHits->push_back(trigEl->nTRTHiThresholdHits()); + m_trig_L2_el_charge ->push_back(trigEl->charge()); + return true; +} + + +bool TrigEgammaEventSelection::fillCaloCluster( const xAOD::CaloCluster *cluster){ + + ATH_MSG_DEBUG("FillCaloCluster..."); + m_trig_EF_calo_et->push_back(cluster->et()); + m_trig_EF_calo_eta->push_back(cluster->eta()); + m_trig_EF_calo_phi->push_back(cluster->phi()); + m_trig_EF_calo_etaBE2->push_back(cluster->etaBE(2)); + m_trig_EF_calo_e->push_back(cluster->e()); + + return true; +} + +bool TrigEgammaEventSelection::fillEvent(){ + ///Event information + ATH_MSG_DEBUG("FillEvent..."); + m_runNumber = m_eventInfo->runNumber(); + m_eventNumber = m_eventInfo->eventNumber(); + m_lumiBlock = m_eventInfo->lumiBlock(); + m_avgmu=getAvgMu(); + return true; +} + +bool TrigEgammaEventSelection::fillElectron( const xAOD::Electron *el ){ + + ATH_MSG_DEBUG("FillElectron..."); + ///Cluster information + uint8_t nblayerhits(0); + uint8_t nblayerolhits(0); + uint8_t npixhits(0); + uint8_t npixolhits(0); + uint8_t nscthits(0); + uint8_t nsctolhits(0); + uint8_t ntrthighthreshits(0); + uint8_t ntrthighthresolhits(0); + uint8_t ntrthits(0); + uint8_t ntrtolhits(0); + uint8_t ntrtxenonhits(0); + uint8_t npixdeadsensors(0); + uint8_t nsctdeadsensors(0); + uint8_t expectblayerhit(true); + uint8_t expectNextToInnerMostLayer(true); + uint8_t nNextToInnerMostLayerHits(0); + uint8_t nNextToInnerMostLayerOutliers(0); + float val(0); + bool hasCalo(false); + bool hasTrack(false); + + + + m_el_e = el->e(); + m_el_et = el->pt(); + m_el_eta = el->eta(); + m_el_phi = el->phi(); + + el->showerShapeValue( m_el_ethad1 , xAOD::EgammaParameters::ShowerShapeType::ethad1 ); + el->showerShapeValue( m_el_ehad1 , xAOD::EgammaParameters::ShowerShapeType::ehad1 ); + el->showerShapeValue( m_el_f1 , xAOD::EgammaParameters::ShowerShapeType::f1 ); // LH + el->showerShapeValue( m_el_f3 , xAOD::EgammaParameters::ShowerShapeType::f3 ); // LH + el->showerShapeValue( m_el_f1core , xAOD::EgammaParameters::ShowerShapeType::f1core ); + el->showerShapeValue( m_el_f3core , xAOD::EgammaParameters::ShowerShapeType::f3core ); + el->showerShapeValue( m_el_weta1 , xAOD::EgammaParameters::ShowerShapeType::weta1 ); // LH (new) + el->showerShapeValue( m_el_weta2 , xAOD::EgammaParameters::ShowerShapeType::weta2 ); // LH + el->showerShapeValue( m_el_wtots1 , xAOD::EgammaParameters::ShowerShapeType::wtots1 ); + el->showerShapeValue( m_el_fracs1 , xAOD::EgammaParameters::ShowerShapeType::fracs1 ); + el->showerShapeValue( m_el_Reta , xAOD::EgammaParameters::ShowerShapeType::Reta ); // LH + el->showerShapeValue( m_el_Rphi , xAOD::EgammaParameters::ShowerShapeType::Rphi ); // LH + el->showerShapeValue( m_el_Eratio , xAOD::EgammaParameters::ShowerShapeType::Eratio ); // LH + el->showerShapeValue( m_el_Rhad , xAOD::EgammaParameters::ShowerShapeType::Rhad ); // LH + el->showerShapeValue( m_el_Rhad1 , xAOD::EgammaParameters::ShowerShapeType::Rhad1 ); // LH + el->showerShapeValue( m_el_deltaE , xAOD::EgammaParameters::ShowerShapeType::DeltaE ); // LH + el->showerShapeValue( m_el_e277 , xAOD::EgammaParameters::ShowerShapeType::e277 ); // LH + ///Combined track/Cluter information + el->trackCaloMatchValue( m_el_deta2 , xAOD::EgammaParameters::TrackCaloMatchType::deltaEta2 ); + el->trackCaloMatchValue( m_el_dphi2 , xAOD::EgammaParameters::TrackCaloMatchType::deltaPhi2 ); + el->trackCaloMatchValue( m_el_dphiresc , xAOD::EgammaParameters::TrackCaloMatchType::deltaPhiRescaled0 ); + m_el_deltaPhiRescaled2 = get_el_deltaPhiRescaled2(el); // LH + m_el_deltaEta1 = get_el_deltaEta1(el); // LH + + if(el->caloCluster()){ + hasCalo=true; + m_el_calo_et = getCluster_et( el ); + m_el_calo_eta = getCluster_eta( el ); + m_el_calo_phi = getCluster_phi( el ); + m_el_calo_etaBE2 = el->caloCluster()->etaBE(2); // LH + m_el_calo_e = el->caloCluster()->e(); // LH + } + + ///Track particle information + const xAOD::TrackParticle *track = el->trackParticle(); + if(track){ + hasTrack=true; + track->summaryValue( nblayerhits , xAOD::SummaryType::numberOfBLayerHits ); + track->summaryValue( nblayerolhits , xAOD::SummaryType::numberOfBLayerOutliers ); + track->summaryValue( npixhits , xAOD::SummaryType::numberOfPixelHits ); + track->summaryValue( npixolhits , xAOD::SummaryType::numberOfPixelOutliers ); + track->summaryValue( npixdeadsensors , xAOD::SummaryType::numberOfPixelDeadSensors); + track->summaryValue( nscthits , xAOD::SummaryType::numberOfSCTHits ); + track->summaryValue( nsctolhits , xAOD::SummaryType::numberOfSCTOutliers ); + track->summaryValue( nsctdeadsensors , xAOD::SummaryType::numberOfSCTDeadSensors); + track->summaryValue( ntrthits , xAOD::SummaryType::numberOfTRTHits); + track->summaryValue( ntrtolhits , xAOD::SummaryType::numberOfTRTOutliers ); + track->summaryValue( ntrthighthreshits , xAOD::SummaryType::numberOfTRTHighThresholdHits ); + track->summaryValue( ntrthighthresolhits , xAOD::SummaryType::numberOfTRTHighThresholdOutliers ); + track->summaryValue( ntrtxenonhits , xAOD::SummaryType::numberOfTRTXenonHits ); + track->summaryValue( expectblayerhit , xAOD::SummaryType::expectBLayerHit ); + track->summaryValue( expectNextToInnerMostLayer , xAOD::expectNextToInnermostPixelLayerHit); + track->summaryValue( nNextToInnerMostLayerHits , xAOD::numberOfNextToInnermostPixelLayerHits); + track->summaryValue( nNextToInnerMostLayerOutliers, xAOD::numberOfNextToInnermostPixelLayerOutliers); + + m_el_trk_pt = track->pt(); + m_el_trk_eta = track->eta(); + m_el_trk_charge = track->charge(); // LH + m_el_trk_qOverP = track->qOverP(); // LH + m_el_trk_sigd0 = get_el_sigd0(el); // LH + m_el_trk_d0 = get_el_d0(el); // LH + m_el_trk_eProbabilityHT = get_el_eProbabilityHT(el); // LH + m_el_trk_transformed_eProbabilityHT=get_el_transformed_eProbabilityHT(el); // LH + m_el_trk_d0significance = get_el_d0significance(el); + m_el_trk_deltaPOverP = get_el_DeltaPOverP(el); // LH + + } + + ///Extra information about pileup + m_el_nGoodVtx = getNGoodVertex(); + m_el_nPileupPrimaryVtx = getNPVtx(); + + auto ctx = Gaudi::Hive::currentContext() ; + // rerun Likelihood Veryloose selector tool + bool accept=(bool)m_electronLHVLooseTool->accept(ctx,el, getAvgMu()); + m_el_lhVLoose = accept; + m_el_loose = ApplyElectronPid(el, "Loose"); + m_el_medium = ApplyElectronPid(el, "Medium"); + m_el_tight = ApplyElectronPid(el, "Tight"); + m_el_lhLoose = ApplyElectronPid(el, "LHLoose"); + m_el_lhMedium = ApplyElectronPid(el, "LHMedium"); + m_el_lhTight = ApplyElectronPid(el, "LHTight"); + + + // Do not change this order! + m_el_trk_summaryValues->push_back( nblayerhits ); + m_el_trk_summaryValues->push_back( nblayerolhits ); + m_el_trk_summaryValues->push_back( npixhits ); + m_el_trk_summaryValues->push_back( npixolhits ); + m_el_trk_summaryValues->push_back( npixdeadsensors ); + m_el_trk_summaryValues->push_back( nscthits ); + m_el_trk_summaryValues->push_back( nsctolhits ); + m_el_trk_summaryValues->push_back( nsctdeadsensors ); + m_el_trk_summaryValues->push_back( ntrthits ); + m_el_trk_summaryValues->push_back( ntrtolhits ); + m_el_trk_summaryValues->push_back( ntrthighthreshits ); + m_el_trk_summaryValues->push_back( ntrthighthresolhits ); + m_el_trk_summaryValues->push_back( ntrtxenonhits ); + m_el_trk_summaryValues->push_back( expectblayerhit ); + m_el_trk_summaryValues->push_back( expectNextToInnerMostLayer ); + m_el_trk_summaryValues->push_back( nNextToInnerMostLayerHits ); + m_el_trk_summaryValues->push_back( nNextToInnerMostLayerOutliers ); + + //Add isolations values + el->isolationValue(val,xAOD::Iso::etcone20); + m_el_etCone->push_back(val); + el->isolationValue(val,xAOD::Iso::etcone30); + m_el_etCone->push_back(val); + el->isolationValue(val,xAOD::Iso::etcone40); + m_el_etCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptcone20); + m_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptcone30); + m_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptcone40); + m_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptvarcone20); + m_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptvarcone30); + m_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptvarcone40); + m_el_ptCone->push_back(val); + + m_el_hasCalo=hasCalo; + m_el_hasTrack=hasTrack; + + + if(m_doCaloRings){ + ATH_MSG_DEBUG("Fill Electron calo rings..."); + if(!TrigEgammaAnalysisBaseTool::getCaloRings( el , *m_el_ringsE)){ + ATH_MSG_WARNING("Could not attach the calorRings information."); + } + } + + + + return true; +} + + +bool TrigEgammaEventSelection::fillHLTElectron( const xAOD::Electron *el ){ + + ATH_MSG_DEBUG("FillHLTElectron..."); + float calo_e(0); + float calo_et(0); + float calo_eta(0); + float calo_phi(0); + float calo_etaBE2(0); + float eta(0); + float et(0); + //float eta2(0); + float phi(0); + float pt(0); + float trk_eta(0); + float ethad1(0); + float ehad1(0); + float f1(0); + float f3(0); + float f1core(0); + float f3core(0); + float weta1(0); + float weta2(0); + float wtots1(0); + float fracs1(0); + float Reta(0); + float Rphi(0); + float Eratio(0); + float Rhad(0); + float Rhad1(0); + float deta1(0); + float deta2(0); + float dphi2(0); + float dphiresc(0); + float charge(0); + float qOverP(0); + float sigd0(0); + float d0(0); + //float eprobht(0); + float eProbabilityHT(0); + float transformed_eProbabilityHT(0); + float d0significance(0); + float deltaPhiRescaled2(0); + float deltaPOverP(0); + float e(0); + float e277(0); + float deltaE(0); + uint8_t nblayerhits(0); + uint8_t nblayerolhits(0); + uint8_t npixhits(0); + uint8_t npixolhits(0); + uint8_t nscthits(0); + uint8_t nsctolhits(0); + uint8_t ntrthighthreshits(0); + uint8_t ntrthighthresolhits(0); + uint8_t ntrthits(0); + uint8_t ntrtolhits(0); + uint8_t ntrtxenonhits(0); + uint8_t npixdeadsensors(0); + uint8_t nsctdeadsensors(0); + uint8_t expectblayerhit(true); + uint8_t expectNextToInnerMostLayer(true); + uint8_t nNextToInnerMostLayerHits(0); + uint8_t nNextToInnerMostLayerOutliers(0); + float val(0) ; + + bool hasCalo(false); + bool hasTrack(false); + + + ATH_MSG_DEBUG("FillElectron..."); + + ///Cluster information + e = el->e(); + et = el->pt(); + eta = el->eta(); + phi = el->phi(); + + el->showerShapeValue( ethad1 , xAOD::EgammaParameters::ShowerShapeType::ethad1 ); + el->showerShapeValue( ehad1 , xAOD::EgammaParameters::ShowerShapeType::ehad1 ); + el->showerShapeValue( f1 , xAOD::EgammaParameters::ShowerShapeType::f1 ); // LH, isEM + el->showerShapeValue( f3 , xAOD::EgammaParameters::ShowerShapeType::f3 ); // LH, isEM + el->showerShapeValue( f1core , xAOD::EgammaParameters::ShowerShapeType::f1core ); + el->showerShapeValue( f3core , xAOD::EgammaParameters::ShowerShapeType::f3core ); // isEM + el->showerShapeValue( weta1 , xAOD::EgammaParameters::ShowerShapeType::weta1 ); // LH, isEM (new) + el->showerShapeValue( weta2 , xAOD::EgammaParameters::ShowerShapeType::weta2 ); // LH, isEM + el->showerShapeValue( wtots1 , xAOD::EgammaParameters::ShowerShapeType::wtots1 ); // LH, isEM + el->showerShapeValue( fracs1 , xAOD::EgammaParameters::ShowerShapeType::fracs1 ); // isEM + el->showerShapeValue( Reta , xAOD::EgammaParameters::ShowerShapeType::Reta ); // LH, isEM + el->showerShapeValue( Rphi , xAOD::EgammaParameters::ShowerShapeType::Rphi ); // LH, isEM + el->showerShapeValue( Eratio , xAOD::EgammaParameters::ShowerShapeType::Eratio ); // LH, isEM + el->showerShapeValue( Rhad , xAOD::EgammaParameters::ShowerShapeType::Rhad ); // LH, isEM + el->showerShapeValue( Rhad1 , xAOD::EgammaParameters::ShowerShapeType::Rhad1 ); // LH, isEM + el->showerShapeValue( e277 , xAOD::EgammaParameters::e277 ); // isEM (new) + el->showerShapeValue( deltaE , xAOD::EgammaParameters::DeltaE ); // isEM (new) + + ///Combined track/Cluter information + el->trackCaloMatchValue( deta2 , xAOD::EgammaParameters::TrackCaloMatchType::deltaEta2 ); + el->trackCaloMatchValue( dphi2 , xAOD::EgammaParameters::TrackCaloMatchType::deltaPhi2 ); + el->trackCaloMatchValue( dphiresc , xAOD::EgammaParameters::TrackCaloMatchType::deltaPhiRescaled0 ); + deltaPhiRescaled2 = get_el_deltaPhiRescaled2(el); // LH + deta1 = get_el_deltaEta1(el); // LH + + if(el->caloCluster()){ + hasCalo=true; + calo_et = getCluster_et( el ); + calo_eta = getCluster_eta( el ); + calo_phi = getCluster_phi( el ); + calo_etaBE2 = el->caloCluster()->etaBE(2); // LH + calo_e = el->caloCluster()->e(); // LH + } + + + + ///Track particle information + const xAOD::TrackParticle *track = el->trackParticle(); + if(track){ + hasTrack=true; + // track->summaryValue( eprobht , xAOD::SummaryType::eProbabilityHT ); // LH + track->summaryValue( nblayerhits , xAOD::SummaryType::numberOfBLayerHits ); // LH, isEM + track->summaryValue( nblayerolhits , xAOD::SummaryType::numberOfBLayerOutliers ); // LH, isEM + track->summaryValue( npixhits , xAOD::SummaryType::numberOfPixelHits ); // LH, isEM + track->summaryValue( npixolhits , xAOD::SummaryType::numberOfPixelOutliers ); // isEM + track->summaryValue( npixdeadsensors , xAOD::SummaryType::numberOfPixelDeadSensors); // LH, isEM + track->summaryValue( nscthits , xAOD::SummaryType::numberOfSCTHits ); // LH, isEM + track->summaryValue( nsctolhits , xAOD::SummaryType::numberOfSCTOutliers ); // isEM + track->summaryValue( nsctdeadsensors , xAOD::SummaryType::numberOfSCTDeadSensors); // isEM + track->summaryValue( ntrthits , xAOD::SummaryType::numberOfTRTHits); // isEM + track->summaryValue( ntrtolhits , xAOD::SummaryType::numberOfTRTOutliers ); // isEM + track->summaryValue( ntrthighthreshits , xAOD::SummaryType::numberOfTRTHighThresholdHits ); // isEM + track->summaryValue( ntrthighthresolhits , xAOD::SummaryType::numberOfTRTHighThresholdOutliers ); // isEM + track->summaryValue( ntrtxenonhits , xAOD::SummaryType::numberOfTRTXenonHits ); // isEM + track->summaryValue( expectblayerhit , xAOD::SummaryType::expectBLayerHit ); // LH, isEM + track->summaryValue( expectNextToInnerMostLayer , xAOD::expectNextToInnermostPixelLayerHit); // LH, isEM + track->summaryValue( nNextToInnerMostLayerHits , xAOD::numberOfNextToInnermostPixelLayerHits); // LH, isEM + track->summaryValue( nNextToInnerMostLayerOutliers, xAOD::numberOfNextToInnermostPixelLayerOutliers); // LH, isEM + + pt = track->pt(); + trk_eta = track->eta(); // LH + charge = track->charge(); // LH + qOverP = track->qOverP(); // LH, isEM + sigd0 = get_el_sigd0(el); // LH + d0 = get_el_d0(el); // LH, isEM + eProbabilityHT = get_el_eProbabilityHT(el); // LH, isEM + transformed_eProbabilityHT=get_el_transformed_eProbabilityHT(el); // LH + d0significance = get_el_d0significance(el); + deltaPOverP = get_el_DeltaPOverP(el); // LH + } + + auto avgmu=getAvgMu(); + + m_trig_EF_el_hasCalo ->push_back( hasCalo ); + m_trig_EF_el_hasTrack ->push_back( hasTrack ); + + auto ctx = Gaudi::Hive::currentContext(); + m_trig_EF_calo_tight ->push_back((bool)(m_EFCaloElectronIsEMSelectors[0]->accept(ctx,el))); + m_trig_EF_calo_medium ->push_back((bool)(m_EFCaloElectronIsEMSelectors[1]->accept(ctx,el))); + m_trig_EF_calo_loose ->push_back((bool)(m_EFCaloElectronIsEMSelectors[2]->accept(ctx,el))); + m_trig_EF_calo_lhtight ->push_back((bool)(m_EFCaloElectronLHSelectors[0]->accept(ctx,el,avgmu))); + m_trig_EF_calo_lhmedium ->push_back((bool)(m_EFCaloElectronLHSelectors[1]->accept(ctx,el,avgmu))); + m_trig_EF_calo_lhloose ->push_back((bool)(m_EFCaloElectronLHSelectors[2]->accept(ctx,el,avgmu))); + m_trig_EF_calo_lhvloose ->push_back((bool)(m_EFCaloElectronLHSelectors[3]->accept(ctx,el,avgmu))); + + m_trig_EF_el_tight ->push_back((bool)(m_HLTElectronIsEMSelectors[0]->accept(ctx,el))); + m_trig_EF_el_medium ->push_back((bool)(m_HLTElectronIsEMSelectors[1]->accept(ctx,el))); + m_trig_EF_el_loose ->push_back((bool)(m_HLTElectronIsEMSelectors[2]->accept(ctx,el))); + m_trig_EF_el_lhtight ->push_back((bool)(m_HLTElectronLHSelectors[0]->accept(ctx,el,avgmu))); + m_trig_EF_el_lhmedium ->push_back((bool)(m_HLTElectronLHSelectors[1]->accept(ctx,el,avgmu))); + m_trig_EF_el_lhloose ->push_back((bool)(m_HLTElectronLHSelectors[2]->accept(ctx,el,avgmu))); + m_trig_EF_el_lhvloose ->push_back((bool)(m_HLTElectronLHSelectors[3]->accept(ctx,el,avgmu))); + + m_trig_EF_el_calo_et ->push_back( calo_et); + m_trig_EF_el_calo_eta ->push_back( calo_eta ); + m_trig_EF_el_calo_phi ->push_back( calo_phi ); + m_trig_EF_el_calo_etaBE2 ->push_back( calo_etaBE2 ); + m_trig_EF_el_calo_e ->push_back( calo_e ); + + m_trig_EF_el_et ->push_back( et ); + m_trig_EF_el_eta ->push_back( eta ); + m_trig_EF_el_phi ->push_back( phi ); + m_trig_EF_el_e ->push_back( e ); + m_trig_EF_el_e277 ->push_back( e277 ); + m_trig_EF_el_deltaE ->push_back( deltaE ); + m_trig_EF_el_ethad1 ->push_back( ethad1 ); + m_trig_EF_el_ehad1 ->push_back( ehad1 ); + m_trig_EF_el_f1 ->push_back( f1 ); + m_trig_EF_el_f3 ->push_back( f3 ); + m_trig_EF_el_f1core ->push_back( f1core ); + m_trig_EF_el_f3core ->push_back( f3core ); + m_trig_EF_el_weta1 ->push_back( weta1 ); + m_trig_EF_el_weta2 ->push_back( weta2 ); + m_trig_EF_el_wtots1 ->push_back( wtots1 ); + m_trig_EF_el_fracs1 ->push_back( fracs1 ); + m_trig_EF_el_Reta ->push_back( Reta ); + m_trig_EF_el_Rphi ->push_back( Rphi ); + m_trig_EF_el_Eratio ->push_back( Eratio ); + m_trig_EF_el_Rhad ->push_back( Rhad ); + m_trig_EF_el_Rhad1 ->push_back( Rhad1 ); + m_trig_EF_el_deta2 ->push_back( deta2 ); + m_trig_EF_el_dphi2 ->push_back( dphi2 ); + m_trig_EF_el_dphiresc ->push_back( dphiresc ); + m_trig_EF_el_deltaEta1 ->push_back( deta1 ); + m_trig_EF_el_deltaPhiRescaled2 ->push_back( deltaPhiRescaled2 ); + + m_trig_EF_el_trk_pt ->push_back( pt ); + m_trig_EF_el_trk_eta ->push_back( trk_eta ); + m_trig_EF_el_trk_charge ->push_back( charge ); + m_trig_EF_el_trk_qOverP ->push_back( qOverP ); + m_trig_EF_el_trk_sigd0 ->push_back( sigd0 ); + m_trig_EF_el_trk_d0 ->push_back( d0 ); + m_trig_EF_el_trk_eProbabilityHT ->push_back( eProbabilityHT ); + m_trig_EF_el_trk_transformed_eProbabilityHT ->push_back( transformed_eProbabilityHT ); + m_trig_EF_el_trk_d0significance ->push_back( d0significance ); + m_trig_EF_el_trk_deltaPOverP ->push_back( deltaPOverP ); + + + m_trig_EF_el_trk_summaryValues->push_back( nblayerhits ); + m_trig_EF_el_trk_summaryValues->push_back( nblayerolhits ); + m_trig_EF_el_trk_summaryValues->push_back( npixhits ); + m_trig_EF_el_trk_summaryValues->push_back( npixolhits ); + m_trig_EF_el_trk_summaryValues->push_back( npixdeadsensors ); + m_trig_EF_el_trk_summaryValues->push_back( nscthits ); + m_trig_EF_el_trk_summaryValues->push_back( nsctolhits ); + m_trig_EF_el_trk_summaryValues->push_back( nsctdeadsensors ); + m_trig_EF_el_trk_summaryValues->push_back( ntrthits ); + m_trig_EF_el_trk_summaryValues->push_back( ntrtolhits ); + m_trig_EF_el_trk_summaryValues->push_back( ntrthighthreshits ); + m_trig_EF_el_trk_summaryValues->push_back( ntrthighthresolhits ); + m_trig_EF_el_trk_summaryValues->push_back( ntrtxenonhits ); + m_trig_EF_el_trk_summaryValues->push_back( expectblayerhit ); + m_trig_EF_el_trk_summaryValues->push_back( expectNextToInnerMostLayer ); + m_trig_EF_el_trk_summaryValues->push_back( nNextToInnerMostLayerHits ); + m_trig_EF_el_trk_summaryValues->push_back( nNextToInnerMostLayerOutliers ); + + //Add isolations values + el->isolationValue(val,xAOD::Iso::etcone20); + m_trig_EF_el_etCone->push_back(val); + el->isolationValue(val,xAOD::Iso::etcone30); + m_trig_EF_el_etCone->push_back(val); + el->isolationValue(val,xAOD::Iso::etcone40); + m_trig_EF_el_etCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptcone20); + m_trig_EF_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptcone30); + m_trig_EF_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptcone40); + m_trig_EF_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptvarcone20); + m_trig_EF_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptvarcone30); + m_trig_EF_el_ptCone->push_back(val); + el->isolationValue(val,xAOD::Iso::ptvarcone40); + m_trig_EF_el_ptCone->push_back(val); + + + return true; +} + + + +// if true: is Z or W Or not MC if false: not electron or not Z||W mother +bool TrigEgammaEventSelection::isTruthElectronAny(const xAOD::Egamma *eg ){ + if(m_truthContainer){ + const xAOD::TruthParticle *mc=nullptr; + MonteCarlo::PDGID pdg = pdgid(eg, m_truthContainer,mc); + if(mc){ + bool Z,W,e; + Z=W=e=false; + if(pdg == MonteCarlo::PDGID::ZMother) Z = true; + if(pdg == MonteCarlo::PDGID::WMother) W = true; + if(mc->isElectron()) e=true; + return !(e && (Z||W)); + } + } + return true; +} + + +bool TrigEgammaEventSelection::fillMonteCarlo(const xAOD::Egamma *eg){ + + if(m_truthContainer){ + const xAOD::TruthParticle *mc=nullptr; + MonteCarlo::PDGID pdg = pdgid(eg, m_truthContainer,mc); + if(mc){ + m_mc_hasMC = true; + m_mc_pt = mc->pt(); + m_mc_eta = mc->eta(); + m_mc_phi = mc->phi(); + m_mc_isTop = mc->isTop(); + m_mc_isQuark = mc->isQuark(); + m_mc_isParton = mc->isParton(); + m_mc_isMeson = mc->isMeson(); + m_mc_isTau = mc->isTau(); + m_mc_isMuon = mc->isMuon(); + m_mc_isPhoton = mc->isPhoton(); + m_mc_isElectron = mc->isElectron(); + if(pdg == MonteCarlo::PDGID::ZMother) m_mc_hasZMother = true; + if(pdg == MonteCarlo::PDGID::WMother) m_mc_hasWMother = true; + return true; + }//has match + }//has truth container + return false; +} + + +bool TrigEgammaEventSelection::fillCaloRings( const xAOD::Electron *el ){ + return TrigEgammaAnalysisBaseTool::getCaloRings(el, *m_el_ringsE ); +} + + +//! ============================================================================================================ + + +double TrigEgammaEventSelection::get_el_sigd0(const xAOD::Electron *el){ + float vard0 = el->trackParticle()->definingParametersCovMatrix()(0,0); // Cov matrix in vector form + if(vard0>0.0) + return sqrt(vard0); // variance of d0 + return 0.0; +} + +double TrigEgammaEventSelection::get_el_d0(const xAOD::Electron *el){ + return el->trackParticle()->d0(); +} + + +double TrigEgammaEventSelection::get_el_eProbabilityHT(const xAOD::Electron *el){ + float TRT_PID = 0; + el->trackParticle()->summaryValue(TRT_PID, xAOD::eProbabilityHT); + return TRT_PID; +} + + +double TrigEgammaEventSelection::get_el_transformed_eProbabilityHT(const xAOD::Electron *el){ + double TRT_PID = get_el_eProbabilityHT(el); + double epsilon = 1e-30; + if(TRT_PID >= 1.0) TRT_PID = 1.0 - 1.e-15; + else if(TRT_PID <= epsilon) TRT_PID = epsilon; + double tau = 15.0; + TRT_PID = -(1/tau) * log( (1.0/TRT_PID) - 1.0); + return TRT_PID; +} + + +double TrigEgammaEventSelection::get_el_d0significance(const xAOD::Electron *el){ + double d0 = get_el_d0(el); + double sigd0 = get_el_sigd0(el); + return (sigd0 != 0) ? fabs(d0/sigd0) : 0; +} + +double TrigEgammaEventSelection::get_el_deltaPhiRescaled2(const xAOD::Electron *el){ + float deltaPhiRescaled2 = 0; + el->trackCaloMatchValue(deltaPhiRescaled2, xAOD::EgammaParameters::deltaPhiRescaled2); + return deltaPhiRescaled2; +} + + +double TrigEgammaEventSelection::get_el_deltaEta1(const xAOD::Electron *el){ + float deltaEta1 = 0; + el->trackCaloMatchValue(deltaEta1, xAOD::EgammaParameters::deltaEta1); + return deltaEta1; +} + + +double TrigEgammaEventSelection::get_el_DeltaPOverP(const xAOD::Electron *el){ + unsigned int index; + if(el->trackParticle()->indexOfParameterAtPosition(index,xAOD::LastMeasurement)){ + double LMPX = el->trackParticle()->parameterPX(index); + double LMPY = el->trackParticle()->parameterPY(index); + double LMPZ = el->trackParticle()->parameterPZ(index); + double refittedTrack_LMP = sqrt(LMPX*LMPX + LMPY*LMPY + LMPZ*LMPZ); + double refittedTrack_LMqOverP = el->trackParticle()->charge() / refittedTrack_LMP; + double unrefittedTrack_qOverP = el->trackParticle()->qOverP(); + return 1 - (unrefittedTrack_qOverP / refittedTrack_LMqOverP); + } + else + return 0.0; +} + + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx index 947b3b8abf8..df95ba0164a 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx @@ -6,9 +6,9 @@ using namespace std; -TrigEgammaNavAnalysisTool::TrigEgammaNavAnalysisTool( const std::string& myname ): TrigEgammaNavBaseTool(myname) +TrigEgammaNavAnalysisTool::TrigEgammaNavAnalysisTool( const std::string& myname ): TrigEgammaNavBaseTool(myname) { - + declareProperty("IsEMLabels",m_labels); m_eventCounter=0; } @@ -22,92 +22,76 @@ StatusCode TrigEgammaNavAnalysisTool::childInitialize(){ } StatusCode TrigEgammaNavAnalysisTool::childBook(){ - ATH_MSG_INFO("Now configuring chains for analysis: " << name() ); - // Remove calls to plot() - Run3 migration + ATH_MSG_DEBUG("Now configuring chains for analysis"); //Set the base directory from the plot() - //m_dir=plot()->getBasePath(); + m_dir=plot()->getBasePath(); std::vector chains = tdt()->getListOfTriggers("HLT_e.*, L1_EM.*, HLT_g.*"); - ATH_MSG_DEBUG("Trigger chains from TDT: " << chains ); - - - // - m_trigList = m_trigInputList; - - // - // Temporary suppress code below, - // - - // for(const auto trigName:m_trigInputList){ - // if (std::find(chains.begin(), chains.end(), trigName) != chains.end()){ - // if(plot()->getTrigInfoMap().count(trigName) != 0) - // ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); - // else { - // m_trigList.push_back(trigName); - // setTrigInfo(trigName); - // } - // } - // // Special code to attach trigger without of the menu - // else if(getEmulation() && m_forceTrigAttachment){// - // ATH_MSG_INFO("Trigger doesn't exist in menu. Attach to emulate."); - // if(plot()->getTrigInfoMap().count(trigName) == 0){ - // m_trigList.push_back(trigName); - // setTrigEmulation(); - // setTrigInfo(trigName); - // } - // } - // } + for(const auto trigName:m_trigInputList){ + if (std::find(chains.begin(), chains.end(), trigName) != chains.end()){ + if(plot()->getTrigInfoMap().count(trigName) != 0) + ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); + else { + m_trigList.push_back(trigName); + setTrigInfo(trigName); + } + } + // Special code to attach trigger without of the menu + else if(getEmulation() && m_forceTrigAttachment){// + ATH_MSG_INFO("Trigger doesn't exist in menu. Attach to emulate."); + if(plot()->getTrigInfoMap().count(trigName) == 0){ + m_trigList.push_back(trigName); + setTrigEmulation(); + setTrigInfo(trigName); + } + } + + } // Container level kinematic histograms + addDirectory(m_dir+"/Expert/Event"); + const int nTrigger = (int) m_trigList.size(); + + std::string histname=m_anatype+"_electrons"; + addHistogram(new TH1F(histname.c_str(), "Offline Electrons; ; N_{electrons}", 6, 1., 6)); + std::vector el_labels; + el_labels.push_back("loose"); + el_labels.push_back("medium"); + el_labels.push_back("tight"); + el_labels.push_back("lhloose"); + el_labels.push_back("lhmedium"); + el_labels.push_back("lhtight"); + setLabels(plot()->hist1(histname),el_labels); + + histname=m_anatype+"_trigger_counts"; + if(nTrigger>0) { + addHistogram(new TH1F(histname.c_str(), "Trigger Counts; Trigger ; Count", nTrigger, 0, nTrigger)); + setLabels(plot()->hist1(m_anatype+"_trigger_counts"),m_trigList); + } + - // - // Histograms definitions moved to python - // - // addDirectory(m_dir+"/Expert/Event"); - // const int nTrigger = (int) m_trigList.size(); - - //std::string histname=m_anatype+"_electrons"; - // addHistogram(new TH1F(histname.c_str(), "Offline Electrons; ; N_{electrons}", 6, 1., 6)); - // std::vector el_labels; - // el_labels.push_back("loose"); - // el_labels.push_back("medium"); - // el_labels.push_back("tight"); - // el_labels.push_back("lhloose"); - // el_labels.push_back("lhmedium"); - // el_labels.push_back("lhtight"); - // setLabels(plot()->hist1(histname),el_labels); - - // histname=m_anatype+"_trigger_counts"; - // if(nTrigger>0) { - // addHistogram(new TH1F(histname.c_str(), "Trigger Counts; Trigger ; Count", nTrigger, 0, nTrigger)); - // setLabels(plot()->hist1(m_anatype+"_trigger_counts"),m_trigList); - // } - - - // plot()->setEmulation(getEmulation()); - // if(plot()->book(getTrigInfoMap()).isFailure()) { - // ATH_MSG_ERROR("Unable to book histos for " << m_dir); - // return StatusCode::FAILURE; - // } + plot()->setEmulation(getEmulation()); + if(plot()->book(getTrigInfoMap()).isFailure()) { + ATH_MSG_ERROR("Unable to book histos for " << m_dir); + return StatusCode::FAILURE; + } return StatusCode::SUCCESS; } -StatusCode TrigEgammaNavAnalysisTool::childExecute() /* const */ { +StatusCode TrigEgammaNavAnalysisTool::childExecute(){ ATH_MSG_DEBUG("Executing TrigEgammaValidationTool"); m_eventCounter++; - // cd(m_dir+"/Expert/Event"); // replaced by findGroup("Expert_Event") - auto eventMG = findGroup("Expert_Event"); - + cd(m_dir+"/Expert/Event"); if( !TrigEgammaNavBaseTool::EventWiseSelection() ) { ATH_MSG_DEBUG("Fails EventWise selection"); return StatusCode::SUCCESS; //return nicely } // Check for Rnn container in SG if(m_storeGate->contains("HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFex")){ - ATH_MSG_DEBUG("Rnn container in SG "); + ATH_MSG_DEBUG("Rnn container in SG "); setSGContainsRnn(true); } if(m_storeGate->contains("HLT_xAOD__TrigPhotonContainer_L2PhotonFex")){ @@ -124,17 +108,15 @@ StatusCode TrigEgammaNavAnalysisTool::childExecute() /* const */ { // Check HLTResult if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis"); - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } int ilist=0; - ATH_MSG_DEBUG("Chains for Analysis " << m_trigList); - for(const auto trigger : m_trigList){ - ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger - << " " << getTrigInfo(trigger).trigName); + ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger + << " " << getTrigInfo(trigger).trigName); // Trigger counts - //cd(m_dir+"/Expert/Event"); // replaced by findGroup("Expert_Event") - if(tdt()->isPassed(trigger)) hist1(eventMG, m_anatype+"_trigger_counts")->Fill(m_trigList.at(ilist).c_str(),1); + cd(m_dir+"/Expert/Event"); + if(tdt()->isPassed(trigger)) hist1(m_anatype+"_trigger_counts")->Fill(m_trigList.at(ilist).c_str(),1); std::string basePath = m_dir+"/"+trigger+"/Distributions/"; const TrigInfo info = getTrigInfo(trigger); if ( TrigEgammaNavBaseTool::executeNavigation(info).isFailure() ){ @@ -144,34 +126,30 @@ StatusCode TrigEgammaNavAnalysisTool::childExecute() /* const */ { // Fill distributions / trigger for( auto& tool : m_tools) { // Set detail level from analysis tool each time - tool->setDetail(getDetail()); - tool->setTP(getTP()); + tool->setDetail(getDetail()); + tool->setTP(getTP()); tool->setEmulation(getEmulation()); tool->setPVertex(getNPVtx(), getNGoodVertex()); tool->setAvgMu(getAvgOnlineMu(),getAvgOfflineMu()); - ATH_MSG_DEBUG("TE Tool... name="<toolExecute(m_dir+"/Expert",info,m_objTEList).isFailure()) { + ATH_MSG_DEBUG("TE Tool..."); + if(tool->toolExecute(m_dir+"/Expert",info,m_objTEList).isFailure()) ATH_MSG_DEBUG("TE Tool Fails");// Requires offline match - } - ATH_MSG_DEBUG("TE Tool executed successfully name="<setTP(getTP()); - //if(plot()->finalizeShifterHistos(getTrigInfoMap()).isFailure()) { - // ATH_MSG_ERROR("Unable to book histos for " << m_dir); - // return StatusCode::FAILURE; - //} - + plot()->setTP(getTP()); + if(plot()->finalizeShifterHistos(getTrigInfoMap()).isFailure()) { + ATH_MSG_ERROR("Unable to book histos for " << m_dir); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; } diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx index d8d4d645ea9..71a4ad01aa2 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx @@ -26,7 +26,7 @@ TrigEgammaNavTPAnalysisTool( const std::string& myname ) declareProperty("CutLabels",m_cutlabels); declareProperty("ProbeLabels",m_probelabels); declareProperty("TagLabels",m_taglabels); - + // Coverity m_eventInfo=nullptr; m_eventCounter=0; @@ -39,105 +39,90 @@ StatusCode TrigEgammaNavTPAnalysisTool::childInitialize(){ return StatusCode::SUCCESS; } StatusCode TrigEgammaNavTPAnalysisTool::childBook(){ - ATH_MSG_INFO("Now configuring chains for analysis: " << name() ); - - // Remove calls to plot() - Run3 migration + ATH_MSG_DEBUG("Now configuring chains for analysis"); //Set the base directory from the plot() - //m_dir=plot()->getBasePath(); + m_dir=plot()->getBasePath(); std::vector chains = tdt()->getListOfTriggers("HLT_e.*, L1_EM.*, HLT_g.*"); - ATH_MSG_DEBUG("Trigger chains from TDT: " << chains ); - - // - m_trigList = m_trigInputList; - - // - // Temporary suppress code below, - // - - // for(const auto trigName:m_trigInputList){ - // if (std::find(chains.begin(), chains.end(), trigName) != chains.end()){ - // if(plot()->getTrigInfoMap().count(trigName) != 0) - // ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); - // else { - // m_trigList.push_back(trigName); - // setTrigInfo(trigName); - // } - // } - // - // // specail code to add trigger without the menu - // else if(getEmulation() && m_forceTrigAttachment){// - // ATH_MSG_INFO("Trigger doesn't exist in menu. Attach to emulate."); - // if(plot()->getTrigInfoMap().count(trigName) == 0){ - // m_trigList.push_back(trigName); - // setTrigEmulation(); - // setTrigInfo(trigName); - // } - // }// emulation - // } - - // - // Histograms definitions moved to python - // + for(const auto trigName:m_trigInputList){ + if (std::find(chains.begin(), chains.end(), trigName) != chains.end()){ + if(plot()->getTrigInfoMap().count(trigName) != 0) + ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); + else { + m_trigList.push_back(trigName); + setTrigInfo(trigName); + } + } + // specail code to add trigger without the menu + else if(getEmulation() && m_forceTrigAttachment){// + ATH_MSG_INFO("Trigger doesn't exist in menu. Attach to emulate."); + if(plot()->getTrigInfoMap().count(trigName) == 0){ + m_trigList.push_back(trigName); + setTrigEmulation(); + setTrigInfo(trigName); + } + }// emulation + } // Book histograms for average efficiencies and counters - // const int nTrigger = (int) m_trigList.size(); - // addDirectory(m_dir+"/Expert/Event"); - // std::string histname=m_anatype+"_ProbeCutCounter"; - // addHistogram(new TH1F(histname.c_str(), "Number of Probes; Cut ; Count", 12, 0., 12)); - // histname=m_anatype+"_TagCutCounter"; - // addHistogram(new TH1F(histname.c_str(), "Number of Tags; Cut ; Count", 10, 0., 10)); - // histname=m_anatype+"_Mee"; - // addHistogram(new TH1F(histname.c_str(), "Offline M(ee); m_ee [GeV] ; Count", 50, m_ZeeMassMin, m_ZeeMassMax)); - // histname=m_anatype+"_CutCounter"; - // addHistogram(new TH1I(histname.c_str(), "Event Selection; Cut ; Count", 6, 0., 6)); - // if(nTrigger>0){ - // histname=m_anatype+"_trigger_counts"; - // addHistogram(new TH1F(histname.c_str(), "Trigger Counts; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_nProbes"; - // addHistogram(new TH1F(histname.c_str(), "Number of Probes; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_nProbesL1"; - // addHistogram(new TH1F(histname.c_str(), "Number of L1 Probes; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_nProbesL2"; - // addHistogram(new TH1F(histname.c_str(), "Number of L2 Probes; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_nProbesL2Calo"; - // addHistogram(new TH1F(histname.c_str(), "Number of L2Calo Probes; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_nProbesEFCalo"; - // addHistogram(new TH1F(histname.c_str(), "Number of EFCalo Probes; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_nProbesHLT"; - // addHistogram(new TH1F(histname.c_str(), "Number of HLT Probes; Trigger ; Count", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_EffL1"; - // addHistogram(new TProfile(histname.c_str(), "Average L1 Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_EffL2"; - // addHistogram(new TProfile(histname.c_str(), "Average L2 Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_EffL2Calo"; - // addHistogram(new TProfile(histname.c_str(), "Average L2Calo Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_EffEFCalo"; - // addHistogram(new TProfile(histname.c_str(), "Average EFCalo Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); - // histname=m_anatype+"_EffHLT"; - // addHistogram(new TProfile(histname.c_str(), "Average HLT Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); - // - // setLabels(plot()->hist1(m_anatype+"_trigger_counts"),m_trigList); - // setLabels(hist1(m_anatype+"_nProbes"),m_trigList); - // setLabels(hist1(m_anatype+"_nProbesL1"),m_trigList); - // setLabels(hist1(m_anatype+"_nProbesL2"),m_trigList); - // setLabels(hist1(m_anatype+"_nProbesL2Calo"),m_trigList); - // setLabels(hist1(m_anatype+"_nProbesEFCalo"),m_trigList); - // setLabels(hist1(m_anatype+"_nProbesHLT"),m_trigList); - // - // setLabels(hist1(m_anatype+"_EffL1"),m_trigList); - // setLabels(hist1(m_anatype+"_EffL2"),m_trigList); - // setLabels(hist1(m_anatype+"_EffL2Calo"),m_trigList); - // setLabels(hist1(m_anatype+"_EffEFCalo"),m_trigList); - // setLabels(hist1(m_anatype+"_EffHLT"),m_trigList); - // setLabels(hist1(m_anatype+"_CutCounter"),m_cutlabels); - // } + const int nTrigger = (int) m_trigList.size(); + addDirectory(m_dir+"/Expert/Event"); + std::string histname=m_anatype+"_ProbeCutCounter"; + addHistogram(new TH1F(histname.c_str(), "Number of Probes; Cut ; Count", 12, 0., 12)); + histname=m_anatype+"_TagCutCounter"; + addHistogram(new TH1F(histname.c_str(), "Number of Tags; Cut ; Count", 10, 0., 10)); + histname=m_anatype+"_Mee"; + addHistogram(new TH1F(histname.c_str(), "Offline M(ee); m_ee [GeV] ; Count", 50, m_ZeeMassMin, m_ZeeMassMax)); + histname=m_anatype+"_CutCounter"; + addHistogram(new TH1I(histname.c_str(), "Event Selection; Cut ; Count", 6, 0., 6)); + if(nTrigger>0){ + histname=m_anatype+"_trigger_counts"; + addHistogram(new TH1F(histname.c_str(), "Trigger Counts; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_nProbes"; + addHistogram(new TH1F(histname.c_str(), "Number of Probes; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_nProbesL1"; + addHistogram(new TH1F(histname.c_str(), "Number of L1 Probes; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_nProbesL2"; + addHistogram(new TH1F(histname.c_str(), "Number of L2 Probes; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_nProbesL2Calo"; + addHistogram(new TH1F(histname.c_str(), "Number of L2Calo Probes; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_nProbesEFCalo"; + addHistogram(new TH1F(histname.c_str(), "Number of EFCalo Probes; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_nProbesHLT"; + addHistogram(new TH1F(histname.c_str(), "Number of HLT Probes; Trigger ; Count", nTrigger, 0., nTrigger)); + histname=m_anatype+"_EffL1"; + addHistogram(new TProfile(histname.c_str(), "Average L1 Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); + histname=m_anatype+"_EffL2"; + addHistogram(new TProfile(histname.c_str(), "Average L2 Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); + histname=m_anatype+"_EffL2Calo"; + addHistogram(new TProfile(histname.c_str(), "Average L2Calo Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); + histname=m_anatype+"_EffEFCalo"; + addHistogram(new TProfile(histname.c_str(), "Average EFCalo Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); + histname=m_anatype+"_EffHLT"; + addHistogram(new TProfile(histname.c_str(), "Average HLT Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger)); + + setLabels(plot()->hist1(m_anatype+"_trigger_counts"),m_trigList); + setLabels(hist1(m_anatype+"_nProbes"),m_trigList); + setLabels(hist1(m_anatype+"_nProbesL1"),m_trigList); + setLabels(hist1(m_anatype+"_nProbesL2"),m_trigList); + setLabels(hist1(m_anatype+"_nProbesL2Calo"),m_trigList); + setLabels(hist1(m_anatype+"_nProbesEFCalo"),m_trigList); + setLabels(hist1(m_anatype+"_nProbesHLT"),m_trigList); + + setLabels(hist1(m_anatype+"_EffL1"),m_trigList); + setLabels(hist1(m_anatype+"_EffL2"),m_trigList); + setLabels(hist1(m_anatype+"_EffL2Calo"),m_trigList); + setLabels(hist1(m_anatype+"_EffEFCalo"),m_trigList); + setLabels(hist1(m_anatype+"_EffHLT"),m_trigList); + setLabels(hist1(m_anatype+"_CutCounter"),m_cutlabels); + } + + plot()->setEmulation(getEmulation()); + if(plot()->book(getTrigInfoMap()).isFailure()){ + ATH_MSG_ERROR("Unable to book histos for " << m_dir); + return StatusCode::FAILURE; + } - //plot()->setEmulation(getEmulation()); - //if(plot()->book(getTrigInfoMap()).isFailure()){ - // ATH_MSG_ERROR("Unable to book histos for " << m_dir); - // return StatusCode::FAILURE; - //} return StatusCode::SUCCESS; } @@ -149,13 +134,12 @@ void TrigEgammaNavTPAnalysisTool::bookPerSignature(const std::string trigger){ } -StatusCode TrigEgammaNavTPAnalysisTool::childExecute() /* const */ { +StatusCode TrigEgammaNavTPAnalysisTool::childExecute() +{ m_eventCounter++; - // cd(m_dir+"/Expert/Event"); // replaced by findGroup("Expert_Event") - auto eventMG = findGroup("Expert_Event"); - - hist1(eventMG, m_anatype+"_CutCounter")->Fill("Events",1); + cd(m_dir+"/Expert/Event"); + hist1(m_anatype+"_CutCounter")->Fill("Events",1); if ( !TrigEgammaNavTPBaseTool::EventWiseSelection() ){ ATH_MSG_DEBUG("Fails EventWise selection"); @@ -175,7 +159,7 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute() /* const */ { tool->setSGContainsTrigPhoton(getSGContainsTrigPhoton()); } // Event Wise Selection (independent of the required signatures) - hist1(eventMG, m_anatype+"_CutCounter")->Fill("EventWise",1); + hist1(m_anatype+"_CutCounter")->Fill("EventWise",1); // Select TP Pairs ATH_MSG_DEBUG("Execute TP selection"); TrigEgammaNavTPBaseTool::executeTandP(); @@ -190,20 +174,20 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute() /* const */ { std::string probeTrigger = m_trigList.at(ilist); const char * cprobeTrigger = m_trigList.at(ilist).c_str(); ATH_MSG_DEBUG("Start Chain Analysis ============================= " << probeTrigger); - // cd(m_dir+"/Expert/Event"); // replaced by findGroup("Expert_Event") - if(tdt()->isPassed(probeTrigger)) hist1(eventMG, m_anatype+"_trigger_counts")->Fill(cprobeTrigger,1); - + cd(m_dir+"/Expert/Event"); + if(tdt()->isPassed(probeTrigger)) hist1(m_anatype+"_trigger_counts")->Fill(cprobeTrigger,1); + const TrigInfo info = getTrigInfo(probeTrigger); std::string trigName=probeTrigger; - + ATH_MSG_DEBUG("Trigger " << probeTrigger << " pidword " << info.trigPidDecorator << " threshold " << info.trigThrHLT); TrigEgammaNavTPBaseTool::matchObjects(trigName); // Just for counting ATH_MSG_DEBUG("Probes " << m_probeElectrons.size() << " Pairs " << m_pairObj.size() ); for( auto& tool : m_tools) { - tool->setDetail(getDetail()); - tool->setTP(getTP()); + tool->setDetail(getDetail()); + tool->setTP(getTP()); tool->setEmulation(getEmulation()); tool->setPVertex(getNPVtx(), getNGoodVertex()); tool->setAvgMu(getAvgOnlineMu(),getAvgOfflineMu()); @@ -211,57 +195,56 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute() /* const */ { ATH_MSG_DEBUG("TE Tool Fails");// Requires offline match } if(isPrescaled(probeTrigger)){ - ATH_MSG_DEBUG(probeTrigger << " prescaled, skipping efficiency"); + ATH_MSG_DEBUG(probeTrigger << " prescaled, skipping efficiency"); continue; //Account for L1 and HLT prescale, discard event } for(unsigned int i=0;i (m_pairObj[i].first); float et = getEt(offEl)/1e3; - if(et < info.trigThrHLT-5.0) continue; - if(!offEl->auxdecor(info.trigPidDecorator)) continue; + if(et < info.trigThrHLT-5.0) continue; + if(!offEl->auxdecor(info.trigPidDecorator)) continue; const HLT::TriggerElement* feat = m_pairObj[i].second; asg::AcceptData acceptData = setAccept(feat,info); //Sets the trigger accepts - // cd(m_dir+"/Expert/Event"); // replaced by findGroup("Expert_Event") - if(et > info.trigThrHLT + 1.0) { - hist1(eventMG, m_anatype+"_nProbes")->Fill(cprobeTrigger,1); - } + cd(m_dir+"/Expert/Event"); + if(et > info.trigThrHLT + 1.0) + hist1(m_anatype+"_nProbes")->Fill(cprobeTrigger,1); if ( feat ) { if(et > info.trigThrHLT + 1.0){ - hist1(eventMG, m_anatype+"_EffL1")->Fill(cprobeTrigger,acceptData.getCutResult("L1Calo")); - hist1(eventMG, m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,acceptData.getCutResult("L2Calo")); - hist1(eventMG, m_anatype+"_EffL2")->Fill(cprobeTrigger,acceptData.getCutResult("L2")); - hist1(eventMG, m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,acceptData.getCutResult("EFCalo")); - hist1(eventMG, m_anatype+"_EffHLT")->Fill(cprobeTrigger,acceptData.getCutResult("HLT")); + hist1(m_anatype+"_EffL1")->Fill(cprobeTrigger,acceptData.getCutResult("L1Calo")); + hist1(m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,acceptData.getCutResult("L2Calo")); + hist1(m_anatype+"_EffL2")->Fill(cprobeTrigger,acceptData.getCutResult("L2")); + hist1(m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,acceptData.getCutResult("EFCalo")); + hist1(m_anatype+"_EffHLT")->Fill(cprobeTrigger,acceptData.getCutResult("HLT")); if( acceptData.getCutResult("L1Calo")){ - hist1(eventMG, m_anatype+"_nProbesL1")->Fill(cprobeTrigger,1); + hist1(m_anatype+"_nProbesL1")->Fill(cprobeTrigger,1); } if( acceptData.getCutResult("L2Calo") ){ - hist1(eventMG, m_anatype+"_nProbesL2Calo")->Fill(cprobeTrigger,1); + hist1(m_anatype+"_nProbesL2Calo")->Fill(cprobeTrigger,1); } if( acceptData.getCutResult("L2") ){ - hist1(eventMG, m_anatype+"_nProbesL2")->Fill(cprobeTrigger,1); + hist1(m_anatype+"_nProbesL2")->Fill(cprobeTrigger,1); } if( acceptData.getCutResult("EFCalo") ){ - hist1(eventMG, m_anatype+"_nProbesEFCalo")->Fill(cprobeTrigger,1); + hist1(m_anatype+"_nProbesEFCalo")->Fill(cprobeTrigger,1); } if( acceptData.getCutResult("HLT") ){ - hist1(eventMG, m_anatype+"_nProbesHLT")->Fill(cprobeTrigger,1); + hist1(m_anatype+"_nProbesHLT")->Fill(cprobeTrigger,1); } } } // Features // Fill TProfile for no feature found (means no match) else { - hist1(eventMG, m_anatype+"_EffL1")->Fill(cprobeTrigger,0); - hist1(eventMG, m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,0); - hist1(eventMG, m_anatype+"_EffL2")->Fill(cprobeTrigger,0); - hist1(eventMG, m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,0); - hist1(eventMG, m_anatype+"_EffHLT")->Fill(cprobeTrigger,0); + hist1(m_anatype+"_EffL1")->Fill(cprobeTrigger,0); + hist1(m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,0); + hist1(m_anatype+"_EffL2")->Fill(cprobeTrigger,0); + hist1(m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,0); + hist1(m_anatype+"_EffHLT")->Fill(cprobeTrigger,0); } } // End loop over electrons } // End loop over trigger list - // cd(m_dir+"/Expert/Event"); // replaced by findGroup("Expert_Event") - hist1(eventMG, m_anatype+"_CutCounter")->Fill("Success",1); + cd(m_dir+"/Expert/Event"); + hist1(m_anatype+"_CutCounter")->Fill("Success",1); ATH_MSG_DEBUG("Clear decorations"); //clearDecorations(); return StatusCode::SUCCESS; @@ -270,12 +253,10 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute() /* const */ { StatusCode TrigEgammaNavTPAnalysisTool::childFinalize() { ATH_MSG_DEBUG("Processed N events " << m_eventCounter); - ATH_MSG_WARNING("Old TrigEgammaNavTPAnalysisTool::childFinalize. plot() removal refactor TODO"); - - //plot()->setTP(getTP()); - //if(plot()->finalizeShifterHistos(getTrigInfoMap()).isFailure()) { - // ATH_MSG_ERROR("Unable to book histos for " << m_dir); - // return StatusCode::FAILURE; - //} + plot()->setTP(getTP()); + if(plot()->finalizeShifterHistos(getTrigInfoMap()).isFailure()) { + ATH_MSG_ERROR("Unable to book histos for " << m_dir); + return StatusCode::FAILURE; + } return StatusCode::SUCCESS; } diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPhysValBase.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPhysValBase.cxx new file mode 100644 index 00000000000..c5c99d9f982 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPhysValBase.cxx @@ -0,0 +1,1005 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include +#include "TrigEgammaAnalysisTools/TrigEgammaPhysValBase.h" +using namespace std; + +TrigEgammaPhysValBase::TrigEgammaPhysValBase(){ + + m_el_ringsE=nullptr; + m_trig_L1_thrNames=nullptr; + m_trig_L2_calo_energySample=nullptr; + m_trig_L2_calo_rings=nullptr; + m_trig_L2_el_trackAlgID=nullptr; + m_trig_L2_el_pt=nullptr; + m_trig_L2_el_eta=nullptr; + m_trig_L2_el_caloEta=nullptr; + m_trig_L2_el_phi=nullptr; + m_trig_L2_el_charge=nullptr; + m_trig_L2_el_nTRTHits=nullptr; + m_trig_L2_el_nTRTHiThresholdHits=nullptr; + m_trig_L2_el_etOverPt=nullptr; + m_trig_L2_el_trkClusDeta=nullptr; + m_trig_L2_el_trkClusDphi=nullptr; + m_trig_EF_calo_et=nullptr; + m_trig_EF_calo_eta=nullptr; + + m_doMCDetailed=false; + m_doL2Detailed=false; + m_doL2CaloDetailed=false; + m_doRecoDetailed=false; +} + +/* + * book, link, clear, alloc and release method divide in: + * trigger, Egamma and MonteCarlo data base. + */ +template +void TrigEgammaPhysValBase::InitBranch(TTree* fChain, std::string branch_name, T* param, bool message){ + + std::string bname = branch_name; + if (fChain->GetAlias(bname.c_str())) + bname = std::string(fChain->GetAlias(bname.c_str())); + + if (!fChain->FindBranch(bname.c_str()) && message) { + return; + } + fChain->SetBranchStatus(bname.c_str(), 1.); + fChain->SetBranchAddress(bname.c_str(), param); +} + +void TrigEgammaPhysValBase::bookEventBranches(TTree *t){ + + t->Branch("RunNumber", &m_runNumber); + t->Branch("EventNumber", &m_eventNumber); + t->Branch("LumiBlock", &m_lumiBlock); + t->Branch("avgmu", &m_avgmu); +} + +void TrigEgammaPhysValBase::bookTriggerBranches(TTree *t){ + + // Level L1 cluster + t->Branch( "trig_L1_eta", &m_trig_L1_eta); + t->Branch( "trig_L1_phi", &m_trig_L1_phi); + t->Branch( "trig_L1_emClus", &m_trig_L1_emClus); + t->Branch( "trig_L1_tauClus", &m_trig_L1_tauClus); + t->Branch( "trig_L1_emIsol", &m_trig_L1_emIsol); + t->Branch( "trig_L1_hadIsol", &m_trig_L1_hadIsol); + t->Branch( "trig_L1_hadCore", &m_trig_L1_hadCore); + t->Branch( "trig_L2_calo_et", &m_trig_L2_calo_et); + t->Branch( "trig_L2_calo_eta", &m_trig_L2_calo_eta); + t->Branch( "trig_L2_calo_phi", &m_trig_L2_calo_phi); + + if(m_doL2CaloDetailed){ + t->Branch( "trig_L2_calo_e237", &m_trig_L2_calo_e237 ); + t->Branch( "trig_L2_calo_e277", &m_trig_L2_calo_e277 ); + t->Branch( "trig_L2_calo_fracs1", &m_trig_L2_calo_fracs1); + t->Branch( "trig_L2_calo_weta2", &m_trig_L2_calo_weta2); + t->Branch( "trig_L2_calo_ehad1", &m_trig_L2_calo_ehad1); + t->Branch( "trig_L2_calo_emaxs1", &m_trig_L2_calo_emaxs1); + t->Branch( "trig_L2_calo_e2tsts1", &m_trig_L2_calo_e2tsts1); + t->Branch( "trig_L2_calo_wstot", &m_trig_L2_calo_wstot); + t->Branch( "trig_L2_calo_energySample",&m_trig_L2_calo_energySample); + } + + t->Branch( "trig_L2_calo_rings", &m_trig_L2_calo_rings ); + t->Branch( "trig_L2_calo_rnnOutput", &m_trig_L2_calo_rnnOutput ); + + + if(m_doL2Detailed){ + t->Branch( "trig_L2_el_pt" , &m_trig_L2_el_pt ); + t->Branch( "trig_L2_el_eta", &m_trig_L2_el_eta); + t->Branch( "trig_L2_el_phi", &m_trig_L2_el_phi ); + t->Branch( "trig_L2_el_caloEta", &m_trig_L2_el_caloEta ); + t->Branch( "trig_L2_el_charge", &m_trig_L2_el_charge); + t->Branch( "trig_L2_el_nTRTHits", &m_trig_L2_el_nTRTHits); + t->Branch( "trig_L2_el_nTRTHiThresholdHits", &m_trig_L2_el_nTRTHiThresholdHits); + t->Branch( "trig_L2_el_etOverPt" , &m_trig_L2_el_etOverPt ); + t->Branch( "trig_L2_el_trkClusDeta" , &m_trig_L2_el_trkClusDeta ); + t->Branch( "trig_L2_el_trkClusDphi" , &m_trig_L2_el_trkClusDphi ); + t->Branch( "trig_L2_el_trackAlgID" , &m_trig_L2_el_trackAlgID ); + } + + t->Branch( "trig_EF_calo_e", &m_trig_EF_calo_e ); + t->Branch( "trig_EF_calo_et", &m_trig_EF_calo_et ); + t->Branch( "trig_EF_calo_eta", &m_trig_EF_calo_eta ); + t->Branch( "trig_EF_calo_phi", &m_trig_EF_calo_phi ); + t->Branch( "trig_EF_calo_etaBE2", &m_trig_EF_calo_etaBE2 ); + +#define BRANCH(_name_) t->Branch( #_name_ , & m_##_name_ );\ + + BRANCH( trig_EF_calo_tight ); + BRANCH( trig_EF_calo_medium ); + BRANCH( trig_EF_calo_loose ); + BRANCH( trig_EF_calo_lhtight ); + BRANCH( trig_EF_calo_lhmedium ); + BRANCH( trig_EF_calo_lhloose ); + BRANCH( trig_EF_calo_lhvloose ); + + BRANCH( trig_EF_el_calo_e ); + BRANCH( trig_EF_el_calo_et ); + BRANCH( trig_EF_el_calo_eta ); + BRANCH( trig_EF_el_calo_phi ); + BRANCH( trig_EF_el_calo_etaBE2 ); + + BRANCH( trig_EF_el_hasCalo ); + BRANCH( trig_EF_el_hasTrack ); + BRANCH( trig_EF_el_e ); + BRANCH( trig_EF_el_et ); + BRANCH( trig_EF_el_eta ); + BRANCH( trig_EF_el_phi ); + BRANCH( trig_EF_el_e277 ); + BRANCH( trig_EF_el_ethad1 ); + BRANCH( trig_EF_el_ehad1 ); + BRANCH( trig_EF_el_f1 ); + BRANCH( trig_EF_el_f3 ); + BRANCH( trig_EF_el_f1core ); + BRANCH( trig_EF_el_f3core ); + BRANCH( trig_EF_el_weta1 ); + BRANCH( trig_EF_el_weta2 ); + BRANCH( trig_EF_el_wtots1 ); + BRANCH( trig_EF_el_fracs1 ); + BRANCH( trig_EF_el_Reta ); + BRANCH( trig_EF_el_Rphi ); + BRANCH( trig_EF_el_Eratio ); + BRANCH( trig_EF_el_Rhad ); + BRANCH( trig_EF_el_Rhad1 ); + BRANCH( trig_EF_el_deta2 ); + BRANCH( trig_EF_el_dphi2 ); + BRANCH( trig_EF_el_dphiresc ); + BRANCH( trig_EF_el_deltaPhiRescaled2 ); + BRANCH( trig_EF_el_deltaEta1 ); + BRANCH( trig_EF_el_deltaE ); + BRANCH( trig_EF_el_etCone ); + BRANCH( trig_EF_el_ptCone ); + + BRANCH( trig_EF_el_trk_pt ); + BRANCH( trig_EF_el_trk_eta ); + BRANCH( trig_EF_el_trk_charge ); + BRANCH( trig_EF_el_trk_qOverP ); + BRANCH( trig_EF_el_trk_sigd0 ); + BRANCH( trig_EF_el_trk_d0 ); + BRANCH( trig_EF_el_trk_eProbabilityHT ); + BRANCH( trig_EF_el_trk_transformed_eProbabilityHT ); + BRANCH( trig_EF_el_trk_d0significance ); + BRANCH( trig_EF_el_trk_deltaPOverP ); + BRANCH( trig_EF_el_trk_summaryValues ); + + BRANCH( trig_EF_el_tight ); + BRANCH( trig_EF_el_medium ); + BRANCH( trig_EF_el_loose ); + BRANCH( trig_EF_el_lhtight ); + BRANCH( trig_EF_el_lhmedium ); + BRANCH( trig_EF_el_lhloose ); + BRANCH( trig_EF_el_lhvloose ); + + + +#undef BRANCH + + + +} + + + +void TrigEgammaPhysValBase::bookElectronBranches(TTree *t){ + + t->Branch("el_calo_e", &m_el_calo_e); + t->Branch("el_calo_et", &m_el_calo_et); + t->Branch("el_calo_eta", &m_el_calo_eta); + t->Branch("el_calo_etaBE2", &m_el_calo_etaBE2); + t->Branch("el_calo_phi", &m_el_calo_phi); + + t->Branch("el_hasCalo", &m_el_hasCalo ); + t->Branch("el_hasTrack", &m_el_hasTrack ); + t->Branch("el_e", &m_el_e ); + t->Branch("el_et", &m_el_et ); + t->Branch("el_eta", &m_el_eta ); + t->Branch("el_phi", &m_el_phi ); + + if(m_doRecoDetailed){ + t->Branch("el_ethad1", &m_el_ethad1); + t->Branch("el_ehad1", &m_el_ehad1); + t->Branch("el_e277", &m_el_e277); + t->Branch("el_f1", &m_el_f1); + t->Branch("el_f3", &m_el_f3); + t->Branch("el_f1core", &m_el_f1core); + t->Branch("el_f3core", &m_el_f3core); + t->Branch("el_weta1", &m_el_weta1); + t->Branch("el_weta2", &m_el_weta2); + t->Branch("el_wtots1", &m_el_wtots1); + t->Branch("el_fracs1", &m_el_fracs1); + t->Branch("el_Reta", &m_el_Reta); + t->Branch("el_Rphi", &m_el_Rphi); + t->Branch("el_Eratio", &m_el_Eratio); + t->Branch("el_Rhad", &m_el_Rhad); + t->Branch("el_Rhad1", &m_el_Rhad1); + t->Branch("el_deta2", &m_el_deta2); + t->Branch("el_dphi2", &m_el_dphi2); + t->Branch("el_dphiresc", &m_el_dphiresc); + t->Branch("el_deltaPhiRescaled2" , &m_el_deltaPhiRescaled2 ); + t->Branch("el_deltaEta1" , &m_el_deltaEta1 ); + t->Branch("el_deltaE", &m_el_deltaE ); + t->Branch("el_etCone" , &m_el_etCone ); + t->Branch("el_ptCone" , &m_el_ptCone ); + + + t->Branch("el_trk_pt", &m_el_trk_pt ); + t->Branch("el_trk_eta", &m_el_trk_eta ); + t->Branch("el_trk_charge", &m_el_trk_charge); + t->Branch("el_trk_qOverP", &m_el_trk_qOverP); + t->Branch("el_trk_sigd0" , &m_el_trk_sigd0 ); + t->Branch("el_trk_d0" , &m_el_trk_d0 ); + t->Branch("el_trk_eProbabilityHT" , &m_el_trk_eProbabilityHT ); + t->Branch("el_trk_transformed_eProbabilityHT", &m_el_trk_transformed_eProbabilityHT); + t->Branch("el_trk_d0significance" , &m_el_trk_d0significance ); + t->Branch("el_trk_deltaPOverP" , &m_el_trk_deltaPOverP ); + t->Branch("el_trk_summaryValues" , &m_el_trk_summaryValues ); + } + + t->Branch("el_ringsE", &m_el_ringsE ); + t->Branch("el_nGoodVtx", &m_el_nGoodVtx); + t->Branch("el_nPileupPrimaryVtx", &m_el_nPileupPrimaryVtx); + + + t->Branch("el_loose", &m_el_loose ); + t->Branch("el_medium", &m_el_medium ); + t->Branch("el_tight", &m_el_tight ); + t->Branch("el_lhvloose", &m_el_lhVLoose ); + t->Branch("el_lhloose", &m_el_lhLoose ); + t->Branch("el_lhmedium", &m_el_lhMedium ); + t->Branch("el_lhtight", &m_el_lhTight ); + t->Branch("el_multiLepton", &m_el_multiLepton); + + + +} + + +void TrigEgammaPhysValBase::createTDTMetadata( TTree *t, std::vector trigList ){ + + std::vector *trig_tdt_triggerList; + t->Branch("trig_tdt_triggerList", &trig_tdt_triggerList ); + trig_tdt_triggerList = new std::vector(); + for(auto& trigger : trigList ){ + trig_tdt_triggerList->push_back(trigger); + } + t->Fill(); + delete trig_tdt_triggerList; +} + + +void TrigEgammaPhysValBase::bookTDTBranches(TTree *t){ + + t->Branch("trig_tdt_L1_calo_accept", &m_trig_tdt_L1_calo_accept); + t->Branch("trig_tdt_L2_calo_accept", &m_trig_tdt_L2_calo_accept); + t->Branch("trig_tdt_L2_el_accept", &m_trig_tdt_L2_el_accept ); + t->Branch("trig_tdt_EF_calo_accept", &m_trig_tdt_EF_calo_accept); + t->Branch("trig_tdt_EF_el_accept", &m_trig_tdt_EF_el_accept ); + t->Branch("trig_tdt_emu_L1_calo_accept", &m_trig_tdt_emu_L1_calo_accept); + t->Branch("trig_tdt_emu_L2_calo_accept", &m_trig_tdt_emu_L2_calo_accept); + t->Branch("trig_tdt_emu_L2_el_accept", &m_trig_tdt_emu_L2_el_accept ); + t->Branch("trig_tdt_emu_EF_calo_accept", &m_trig_tdt_emu_EF_calo_accept); + t->Branch("trig_tdt_emu_EF_el_accept", &m_trig_tdt_emu_EF_el_accept ); + +} + + + +void TrigEgammaPhysValBase::bookMonteCarloBranches(TTree *t){ + // Monte Carlo + t->Branch("mc_hasMC", &m_mc_hasMC); + t->Branch("mc_pt", &m_mc_pt); + t->Branch("mc_eta", &m_mc_eta); + t->Branch("mc_phi", &m_mc_phi); + + if(m_doMCDetailed){ + t->Branch("mc_isTop", &m_mc_isTop); + t->Branch("mc_isParton", &m_mc_isParton); + t->Branch("mc_isMeson", &m_mc_isMeson); + t->Branch("mc_isTau", &m_mc_isTau); + t->Branch("mc_isMuon", &m_mc_isMuon); + } + + t->Branch("mc_isPhoton", &m_mc_isPhoton); + t->Branch("mc_isElectron", &m_mc_isElectron); + t->Branch("mc_hasZMother", &m_mc_hasZMother); + t->Branch("mc_hasWMother", &m_mc_hasWMother); +} + + +void TrigEgammaPhysValBase::linkTDTBranches(TTree *t){ + + InitBranch( t, "trig_tdt_L1_calo_accept", &m_trig_tdt_L1_calo_accept); + InitBranch( t, "trig_tdt_L2_calo_accept", &m_trig_tdt_L2_calo_accept); + InitBranch( t, "trig_tdt_L2_el_accept", &m_trig_tdt_L2_el_accept ); + InitBranch( t, "trig_tdt_EF_calo_accept", &m_trig_tdt_EF_calo_accept); + InitBranch( t, "trig_tdt_EF_el_accept", &m_trig_tdt_EF_el_accept ); + InitBranch( t, "trig_tdt_emu_L1_calo_accept", &m_trig_tdt_emu_L1_calo_accept); + InitBranch( t, "trig_tdt_emu_L2_calo_accept", &m_trig_tdt_emu_L2_calo_accept); + InitBranch( t, "trig_tdt_emu_L2_el_accept", &m_trig_tdt_emu_L2_el_accept ); + InitBranch( t, "trig_tdt_emu_EF_calo_accept", &m_trig_tdt_emu_EF_calo_accept); + InitBranch( t, "trig_tdt_emu_EF_el_accept", &m_trig_tdt_emu_EF_el_accept ); + +} + + + +void TrigEgammaPhysValBase::linkEventBranches(TTree *t){ + + InitBranch( t, "RunNumber", &m_runNumber); + InitBranch( t, "EventNumber", &m_eventNumber); + InitBranch( t, "LumiBlock", &m_lumiBlock); + InitBranch( t, "avgmu", &m_avgmu); +} + +void TrigEgammaPhysValBase::linkElectronBranches( TTree *t ){ + + InitBranch( t, "el_calo_e", &m_el_calo_e); + InitBranch( t, "el_calo_et", &m_el_calo_et); + InitBranch( t, "el_calo_eta", &m_el_calo_eta); + InitBranch( t, "el_calo_etaBE2", &m_el_calo_etaBE2); + InitBranch( t, "el_calo_phi", &m_el_calo_phi); + + InitBranch( t, "el_hasCalo", &m_el_hasCalo); + InitBranch( t, "el_hasTrack", &m_el_hasTrack); + InitBranch( t, "el_e", &m_el_e); + InitBranch( t, "el_et", &m_el_et); + InitBranch( t, "el_eta", &m_el_eta); + InitBranch( t, "el_phi", &m_el_phi); + + + if(m_doRecoDetailed){ + InitBranch( t, "el_ethad1", &m_el_ethad1); + InitBranch( t, "el_ehad1", &m_el_ehad1); + InitBranch( t, "el_f1", &m_el_f1); + InitBranch( t, "el_f3", &m_el_f3); + InitBranch( t, "el_f1core", &m_el_f1core); + InitBranch( t, "el_f3core", &m_el_f3core); + InitBranch( t, "el_weta1", &m_el_weta2); + InitBranch( t, "el_weta2", &m_el_weta2); + InitBranch( t, "el_wtots1", &m_el_wtots1); + InitBranch( t, "el_fracs1", &m_el_fracs1); + InitBranch( t, "el_Reta", &m_el_Reta); + InitBranch( t, "el_Rphi", &m_el_Rphi); + InitBranch( t, "el_Eratio", &m_el_Eratio); + InitBranch( t, "el_Rhad", &m_el_Rhad); + InitBranch( t, "el_Rhad1", &m_el_Rhad1); + InitBranch( t, "el_deta2", &m_el_deta2); + InitBranch( t, "el_dphi2", &m_el_dphi2); + InitBranch( t, "el_dphiresc", &m_el_dphiresc); + InitBranch( t, "el_deltaPhiRescaled2" , &m_el_deltaPhiRescaled2 ); + InitBranch( t, "el_e277" , &m_el_e277 ); + InitBranch( t, "el_deltaE" , &m_el_e277 ); + InitBranch( t, "el_deltaEta1" , &m_el_deltaEta1 ); + InitBranch( t, "el_etCone" , &m_el_etCone ); + InitBranch( t, "el_ptCone" , &m_el_ptCone ); + + InitBranch( t, "el_trk_pt", &m_el_trk_pt); + InitBranch( t, "el_trk_eta" , &m_el_trk_eta); + InitBranch( t, "el_trk_charge", &m_el_trk_charge); + InitBranch( t, "el_trk_qOverP", &m_el_trk_qOverP); + InitBranch( t, "el_trk_deltaPOverP" , &m_el_trk_deltaPOverP ); + InitBranch( t, "el_trk_sigd0" , &m_el_trk_sigd0 ); + InitBranch( t, "el_trk_d0" , &m_el_trk_d0 ); + InitBranch( t, "el_trk_eProbabilityHT" , &m_el_trk_eProbabilityHT ); + InitBranch( t, "el_trk_transformed_eProbabilityHT", &m_el_trk_transformed_eProbabilityHT); + InitBranch( t, "el_trk_d0significance" , &m_el_trk_d0significance ); + InitBranch( t, "el_trk_summaryValues" , &m_el_trk_summaryValues ); + + + } + + InitBranch( t, "el_nGoodVtx", &m_el_nGoodVtx); + InitBranch( t, "el_ringsE", &m_el_ringsE ); + InitBranch( t, "el_nPileupPrimaryVtx", &m_el_nPileupPrimaryVtx); + + InitBranch( t, "el_loose", &m_el_loose ); + InitBranch( t, "el_medium", &m_el_medium ); + InitBranch( t, "el_tight", &m_el_tight ); + InitBranch( t, "el_lhvloose", &m_el_lhVLoose ); + InitBranch( t, "el_lhloose", &m_el_lhLoose ); + InitBranch( t, "el_lhmedium", &m_el_lhMedium ); + InitBranch( t, "el_lhtight", &m_el_lhTight ); + InitBranch( t, "el_multiLepton", &m_el_multiLepton); +} + + + +void TrigEgammaPhysValBase::linkTriggerBranches( TTree *t ){ + + InitBranch(t, "trig_L1_eta", &m_trig_L1_eta); + InitBranch(t, "trig_L1_phi", &m_trig_L1_phi); + InitBranch(t, "trig_L1_emClus", &m_trig_L1_emClus); + InitBranch(t, "trig_L1_tauClus", &m_trig_L1_tauClus); + InitBranch(t, "trig_L1_emIsol", &m_trig_L1_emIsol); + InitBranch(t, "trig_L1_hadIsol", &m_trig_L1_hadIsol); + InitBranch(t, "trig_L1_hadCore", &m_trig_L1_hadCore); + InitBranch(t, "trig_L2_calo_et", &m_trig_L2_calo_et); + InitBranch(t, "trig_L2_calo_eta", &m_trig_L2_calo_eta); + InitBranch(t, "trig_L2_calo_phi", &m_trig_L2_calo_phi); + + if(m_doL2CaloDetailed){ + InitBranch(t, "trig_L2_calo_e237", &m_trig_L2_calo_e237 ); + InitBranch(t, "trig_L2_calo_e277", &m_trig_L2_calo_e277 ); + InitBranch(t, "trig_L2_calo_fracs1", &m_trig_L2_calo_fracs1); + InitBranch(t, "trig_L2_calo_weta2", &m_trig_L2_calo_weta2); + InitBranch(t, "trig_L2_calo_ehad1", &m_trig_L2_calo_ehad1); + InitBranch(t, "trig_L2_calo_emaxs1", &m_trig_L2_calo_emaxs1); + InitBranch(t, "trig_L2_calo_e2tsts1", &m_trig_L2_calo_e2tsts1); + InitBranch(t, "trig_L2_calo_wstot", &m_trig_L2_calo_wstot); + InitBranch(t, "trig_L2_calo_energySample", &m_trig_L2_calo_energySample); + } + + InitBranch(t, "trig_L2_calo_rings", &m_trig_L2_calo_rings ); + InitBranch(t, "trig_L2_calo_rnnOutput", &m_trig_L2_calo_rnnOutput); + + if(m_doL2Detailed){ + InitBranch(t, "trig_L2_el_trackAlgID" , &m_trig_L2_el_trackAlgID ); + InitBranch(t, "trig_L2_el_pt" , &m_trig_L2_el_pt ); + InitBranch(t, "trig_L2_el_eta", &m_trig_L2_el_eta); + InitBranch(t, "trig_L2_el_phi", &m_trig_L2_el_phi ); + InitBranch(t, "trig_L2_el_caloEta", &m_trig_L2_el_caloEta ); + InitBranch(t, "trig_L2_el_charge", &m_trig_L2_el_charge); + InitBranch(t, "trig_L2_el_nTRTHits", &m_trig_L2_el_nTRTHits); + InitBranch(t, "trig_L2_el_nTRTHiThresholdHits", &m_trig_L2_el_nTRTHiThresholdHits); + InitBranch(t, "trig_L2_el_etOverPt" , &m_trig_L2_el_etOverPt ); + InitBranch(t, "trig_L2_el_trkClusDeta" , &m_trig_L2_el_trkClusDeta ); + InitBranch(t, "trig_L2_el_trkClusDphi" , &m_trig_L2_el_trkClusDphi ); + + } + + + +#define INIT(_name_) TrigEgammaPhysValBase::InitBranch(t, #_name_, & m_##_name_);\ + + INIT( trig_EF_calo_et ); + INIT( trig_EF_calo_eta ); + INIT( trig_EF_calo_phi ); + INIT( trig_EF_calo_etaBE2 ); + INIT( trig_EF_calo_e ); + + INIT( trig_EF_el_calo_e ); + INIT( trig_EF_el_calo_et ); + INIT( trig_EF_el_calo_eta ); + INIT( trig_EF_el_calo_phi ); + INIT( trig_EF_el_calo_etaBE2 ); + + INIT( trig_EF_el_hasCalo ); + INIT( trig_EF_el_hasTrack ); + INIT( trig_EF_el_et ); + INIT( trig_EF_el_eta ); + INIT( trig_EF_el_phi ); + INIT( trig_EF_el_e ); + INIT( trig_EF_el_ethad1 ); + INIT( trig_EF_el_ehad1 ); + INIT( trig_EF_el_f1 ); + INIT( trig_EF_el_f3 ); + INIT( trig_EF_el_f1core ); + INIT( trig_EF_el_f3core ); + INIT( trig_EF_el_weta1 ); + INIT( trig_EF_el_weta2 ); + INIT( trig_EF_el_wtots1 ); + INIT( trig_EF_el_fracs1 ); + INIT( trig_EF_el_Reta ); + INIT( trig_EF_el_Rphi ); + INIT( trig_EF_el_Eratio ); + INIT( trig_EF_el_Rhad ); + INIT( trig_EF_el_Rhad1 ); + INIT( trig_EF_el_deta2 ); + INIT( trig_EF_el_dphi2 ); + INIT( trig_EF_el_e277 ); + INIT( trig_EF_el_deltaE ); + INIT( trig_EF_el_dphiresc ); + INIT( trig_EF_el_deltaPhiRescaled2 ); + INIT( trig_EF_el_deltaEta1 ); + INIT( trig_EF_el_etCone ); + INIT( trig_EF_el_ptCone ); + + INIT( trig_EF_el_trk_pt ); + INIT( trig_EF_el_trk_eta ); + INIT( trig_EF_el_trk_charge ); + INIT( trig_EF_el_trk_qOverP ); + INIT( trig_EF_el_trk_sigd0 ); + INIT( trig_EF_el_trk_d0 ); + INIT( trig_EF_el_trk_eProbabilityHT ); + INIT( trig_EF_el_trk_transformed_eProbabilityHT ); + INIT( trig_EF_el_trk_d0significance ); + INIT( trig_EF_el_trk_deltaPOverP ); + INIT( trig_EF_el_trk_summaryValues ); + + INIT( trig_EF_calo_tight ); + INIT( trig_EF_calo_medium ); + INIT( trig_EF_calo_loose ); + INIT( trig_EF_calo_lhtight ); + INIT( trig_EF_calo_lhmedium ); + INIT( trig_EF_calo_lhloose ); + INIT( trig_EF_calo_lhvloose ); + INIT( trig_EF_el_tight ); + INIT( trig_EF_el_medium ); + INIT( trig_EF_el_loose ); + INIT( trig_EF_el_lhtight ); + INIT( trig_EF_el_lhmedium ); + INIT( trig_EF_el_lhloose ); + INIT( trig_EF_el_lhvloose ); + + + +#undef INIT + + +} + + + +void TrigEgammaPhysValBase::linkMonteCarloBranches(TTree *t){ + + InitBranch(t, "mc_hasMC", &m_mc_hasMC); + InitBranch(t, "mc_pt", &m_mc_pt); + InitBranch(t, "mc_eta", &m_mc_eta); + InitBranch(t, "mc_phi", &m_mc_phi); + + if(m_doMCDetailed){ + InitBranch(t, "mc_isTop", &m_mc_isTop); + InitBranch(t, "mc_isParton", &m_mc_isParton); + InitBranch(t, "mc_isMeson", &m_mc_isMeson); + InitBranch(t, "mc_isTau", &m_mc_isTau); + InitBranch(t, "mc_isMuon", &m_mc_isMuon); + } + + InitBranch(t, "mc_isPhoton", &m_mc_isPhoton); + InitBranch(t, "mc_isElectron", &m_mc_isElectron); + InitBranch(t, "mc_hasZMother", &m_mc_hasZMother); + InitBranch(t, "mc_hasWMother", &m_mc_hasWMother); +} + + +void TrigEgammaPhysValBase::clear(){ + + ///EventInfo + m_runNumber = 0; + m_eventNumber = 0; + m_lumiBlock = 0; + m_avgmu = 0; + + ///Egamma + m_el_hasCalo = false; + m_el_hasTrack = false; + + + m_el_calo_e = 0; + m_el_calo_et = 0; + m_el_calo_eta = 0; + m_el_calo_phi = 0; + m_el_calo_etaBE2 = 0; + + m_el_e = 0; + m_el_et = 0; + m_el_eta = 0; + m_el_phi = 0; + m_el_ethad1 = 0; + m_el_ehad1 = 0; + m_el_f1 = 0; + m_el_f3 = 0; + m_el_f1core = 0; + m_el_f3core = 0; + m_el_weta1 = 0; + m_el_weta2 = 0; + m_el_wtots1 = 0; + m_el_fracs1 = 0; + m_el_e277 = 0; + m_el_Reta = 0; + m_el_Rphi = 0; + m_el_Eratio = 0; + m_el_Rhad = 0; + m_el_Rhad1 = 0; + m_el_deta2 = 0; + m_el_dphi2 = 0; + m_el_dphiresc = 0; + m_el_deltaPhiRescaled2 = 0; + m_el_deltaEta1 = 0; + m_el_deltaE = 0; + m_el_etCone ->clear(); + m_el_ptCone ->clear(); + + m_el_trk_pt = 0; + m_el_trk_eta = 0; + m_el_trk_charge = 0; + m_el_trk_sigd0 = 0; + m_el_trk_d0 = 0; + m_el_trk_eProbabilityHT = 0; + m_el_trk_transformed_eProbabilityHT=0; + m_el_trk_d0significance = 0; + m_el_trk_deltaPOverP = 0; + m_el_trk_qOverP = 0; + m_el_trk_summaryValues ->clear(); + + + + m_el_medium = false; + m_el_tight = false; + m_el_lhVLoose = false; + m_el_lhLoose = false; + m_el_lhMedium = false; + m_el_lhTight = false; + m_el_rgLoose = false; + m_el_rgMedium = false; + m_el_rgTight = false; + m_el_multiLepton = false; + + m_el_nGoodVtx = -1; + m_el_nPileupPrimaryVtx = -1; + m_el_ringsE ->clear(); + + // Trigger L1 + m_trig_L1_eta = 0; + m_trig_L1_phi = 0; + m_trig_L1_emClus = 0; + m_trig_L1_tauClus = 0; + m_trig_L1_emIsol = 0; + m_trig_L1_hadIsol = 0; + m_trig_L1_hadCore = 0; + + // Trigger L2 Calo + m_trig_L2_calo_et = 0; + m_trig_L2_calo_eta = 0; + m_trig_L2_calo_phi = 0; + m_trig_L2_calo_e237 = 0; + m_trig_L2_calo_e277 = 0; + m_trig_L2_calo_fracs1 = 0; + m_trig_L2_calo_weta2 = 0; + m_trig_L2_calo_ehad1 = 0; + m_trig_L2_calo_emaxs1 = 0; + m_trig_L2_calo_e2tsts1 = 0; + m_trig_L2_calo_wstot = 0; + + + m_trig_L2_calo_energySample ->clear(); + m_trig_L2_calo_rings ->clear(); + m_trig_L2_calo_rnnOutput ->clear(); + + + // L2 Electron + m_trig_L2_el_pt ->clear(); + m_trig_L2_el_eta ->clear(); + m_trig_L2_el_phi ->clear(); + m_trig_L2_el_charge ->clear(); + m_trig_L2_el_caloEta ->clear(); + m_trig_L2_el_trkClusDeta ->clear(); + m_trig_L2_el_trkClusDphi ->clear(); + m_trig_L2_el_etOverPt ->clear(); + m_trig_L2_el_nTRTHits ->clear(); + m_trig_L2_el_nTRTHiThresholdHits ->clear(); + m_trig_L2_el_trackAlgID ->clear(); + + m_trig_EF_el_hasCalo ->clear(); + m_trig_EF_el_hasTrack ->clear(); + + // EF Calo + m_trig_EF_calo_e ->clear(); + m_trig_EF_calo_et ->clear(); + m_trig_EF_calo_eta ->clear(); + m_trig_EF_calo_phi ->clear(); + m_trig_EF_calo_etaBE2 ->clear(); + + m_trig_EF_calo_tight ->clear(); + m_trig_EF_calo_medium ->clear(); + m_trig_EF_calo_loose ->clear(); + m_trig_EF_calo_lhtight ->clear(); + m_trig_EF_calo_lhmedium ->clear(); + m_trig_EF_calo_lhloose ->clear(); + m_trig_EF_calo_lhvloose ->clear(); + + // HLT electron + m_trig_EF_el_calo_e ->clear(); + m_trig_EF_el_calo_et ->clear(); + m_trig_EF_el_calo_eta ->clear(); + m_trig_EF_el_calo_phi ->clear(); + m_trig_EF_el_calo_etaBE2 ->clear(); + + m_trig_EF_el_e ->clear(); + m_trig_EF_el_et ->clear(); + m_trig_EF_el_eta ->clear(); + m_trig_EF_el_phi ->clear(); + m_trig_EF_el_deltaE ->clear(); + m_trig_EF_el_ethad1 ->clear(); + m_trig_EF_el_ehad1 ->clear(); + m_trig_EF_el_f1 ->clear(); + m_trig_EF_el_f3 ->clear(); + m_trig_EF_el_f1core ->clear(); + m_trig_EF_el_f3core ->clear(); + m_trig_EF_el_weta1 ->clear(); + m_trig_EF_el_weta2 ->clear(); + m_trig_EF_el_wtots1 ->clear(); + m_trig_EF_el_fracs1 ->clear(); + m_trig_EF_el_Reta ->clear(); + m_trig_EF_el_Rphi ->clear(); + m_trig_EF_el_Eratio ->clear(); + m_trig_EF_el_Rhad ->clear(); + m_trig_EF_el_Rhad1 ->clear(); + m_trig_EF_el_e277 ->clear(); + m_trig_EF_el_deta2 ->clear(); + m_trig_EF_el_dphi2 ->clear(); + m_trig_EF_el_dphiresc ->clear(); + m_trig_EF_el_deltaPhiRescaled2 ->clear(); + m_trig_EF_el_deltaEta1 ->clear(); + m_trig_EF_el_etCone ->clear(); + m_trig_EF_el_ptCone ->clear(); + + m_trig_EF_el_trk_pt ->clear(); + m_trig_EF_el_trk_eta ->clear(); + m_trig_EF_el_trk_charge ->clear(); + m_trig_EF_el_trk_qOverP ->clear(); + m_trig_EF_el_trk_sigd0 ->clear(); + m_trig_EF_el_trk_d0 ->clear(); + m_trig_EF_el_trk_eProbabilityHT ->clear(); + m_trig_EF_el_trk_transformed_eProbabilityHT->clear(); + m_trig_EF_el_trk_d0significance ->clear(); + m_trig_EF_el_trk_deltaPOverP ->clear(); + m_trig_EF_el_trk_summaryValues ->clear(); + + + m_trig_EF_el_tight ->clear(); + m_trig_EF_el_medium ->clear(); + m_trig_EF_el_loose ->clear(); + m_trig_EF_el_lhtight ->clear(); + m_trig_EF_el_lhmedium ->clear(); + m_trig_EF_el_lhloose ->clear(); + m_trig_EF_el_lhvloose ->clear(); + + m_trig_tdt_L1_calo_accept ->clear(); + m_trig_tdt_L2_calo_accept ->clear(); + m_trig_tdt_L2_el_accept ->clear(); + m_trig_tdt_EF_calo_accept ->clear(); + m_trig_tdt_EF_el_accept ->clear(); + m_trig_tdt_emu_L1_calo_accept ->clear(); + m_trig_tdt_emu_L2_calo_accept ->clear(); + m_trig_tdt_emu_L2_el_accept ->clear(); + m_trig_tdt_emu_EF_calo_accept ->clear(); + m_trig_tdt_emu_EF_el_accept ->clear(); + + ///Monte Carlo + m_mc_hasMC = false; + m_mc_pt = -1; + m_mc_eta = -1; + m_mc_phi = -1; + m_mc_isTop = false; + m_mc_isParton = false; + m_mc_isMeson = false; + m_mc_isTau = false; + m_mc_isMuon = false; + m_mc_isPhoton = false; + m_mc_isElectron = false; + m_mc_hasZMother = false; + m_mc_hasWMother = false; + + +} + +void TrigEgammaPhysValBase::alloc_space(){ + + m_el_ringsE = new std::vector(); + m_el_trk_summaryValues = new std::vector(); + m_el_etCone = new std::vector(); + m_el_ptCone = new std::vector(); + + + m_trig_L2_calo_energySample = new std::vector(); + m_trig_L2_calo_rings = new std::vector(); + m_trig_L2_calo_rnnOutput = new std::vector(); + + m_trig_L2_el_trackAlgID = new std::vector(); + m_trig_L2_el_eta = new std::vector(); + m_trig_L2_el_phi = new std::vector(); + m_trig_L2_el_caloEta = new std::vector(); + m_trig_L2_el_trkClusDeta = new std::vector(); + m_trig_L2_el_trkClusDphi = new std::vector(); + m_trig_L2_el_pt = new std::vector(); + m_trig_L2_el_etOverPt = new std::vector(); + m_trig_L2_el_nTRTHits = new std::vector(); + m_trig_L2_el_nTRTHiThresholdHits = new std::vector(); + m_trig_L2_el_charge = new std::vector(); + + m_trig_EF_calo_et = new std::vector(); + m_trig_EF_calo_eta = new std::vector(); + m_trig_EF_calo_phi = new std::vector(); + m_trig_EF_calo_etaBE2 = new std::vector(); + m_trig_EF_calo_e = new std::vector(); + + m_trig_EF_el_calo_et = new std::vector(); + m_trig_EF_el_calo_eta = new std::vector(); + m_trig_EF_el_calo_phi = new std::vector(); + m_trig_EF_el_calo_etaBE2 = new std::vector(); + m_trig_EF_el_calo_e = new std::vector(); + + m_trig_EF_el_hasCalo = new std::vector(); + m_trig_EF_el_hasTrack = new std::vector(); + + m_trig_EF_el_et = new std::vector(); + m_trig_EF_el_eta = new std::vector(); + m_trig_EF_el_phi = new std::vector(); + m_trig_EF_el_e = new std::vector(); + m_trig_EF_el_deltaE = new std::vector(); + m_trig_EF_el_ethad1 = new std::vector(); + m_trig_EF_el_ehad1 = new std::vector(); + m_trig_EF_el_f1 = new std::vector(); + m_trig_EF_el_f3 = new std::vector(); + m_trig_EF_el_f1core = new std::vector(); + m_trig_EF_el_f3core = new std::vector(); + m_trig_EF_el_weta1 = new std::vector(); + m_trig_EF_el_weta2 = new std::vector(); + m_trig_EF_el_wtots1 = new std::vector(); + m_trig_EF_el_fracs1 = new std::vector(); + m_trig_EF_el_e277 = new std::vector(); + m_trig_EF_el_Reta = new std::vector(); + m_trig_EF_el_Rphi = new std::vector(); + m_trig_EF_el_Eratio = new std::vector(); + m_trig_EF_el_Rhad = new std::vector(); + m_trig_EF_el_Rhad1 = new std::vector(); + m_trig_EF_el_deta2 = new std::vector(); + m_trig_EF_el_dphi2 = new std::vector(); + m_trig_EF_el_dphiresc = new std::vector(); + m_trig_EF_el_deltaPhiRescaled2 = new std::vector(); + m_trig_EF_el_deltaEta1 = new std::vector(); + m_trig_EF_el_etCone = new std::vector(); + m_trig_EF_el_ptCone = new std::vector(); + + m_trig_EF_el_trk_pt = new std::vector(); + m_trig_EF_el_trk_eta = new std::vector(); + m_trig_EF_el_trk_charge = new std::vector(); + m_trig_EF_el_trk_qOverP = new std::vector(); + m_trig_EF_el_trk_sigd0 = new std::vector(); + m_trig_EF_el_trk_d0 = new std::vector(); + m_trig_EF_el_trk_eProbabilityHT = new std::vector(); + m_trig_EF_el_trk_transformed_eProbabilityHT = new std::vector(); + m_trig_EF_el_trk_d0significance = new std::vector(); + m_trig_EF_el_trk_deltaPOverP = new std::vector(); + m_trig_EF_el_trk_summaryValues = new std::vector(); + + m_trig_EF_calo_tight = new std::vector(); + m_trig_EF_calo_medium = new std::vector(); + m_trig_EF_calo_loose = new std::vector(); + m_trig_EF_calo_lhtight = new std::vector(); + m_trig_EF_calo_lhmedium = new std::vector(); + m_trig_EF_calo_lhloose = new std::vector(); + m_trig_EF_calo_lhvloose = new std::vector(); + + m_trig_EF_el_tight = new std::vector(); + m_trig_EF_el_medium = new std::vector(); + m_trig_EF_el_loose = new std::vector(); + m_trig_EF_el_lhtight = new std::vector(); + m_trig_EF_el_lhmedium = new std::vector(); + m_trig_EF_el_lhloose = new std::vector(); + m_trig_EF_el_lhvloose = new std::vector(); + + m_trig_tdt_L1_calo_accept = new std::vector(); + m_trig_tdt_L2_calo_accept = new std::vector(); + m_trig_tdt_L2_el_accept = new std::vector(); + m_trig_tdt_EF_calo_accept = new std::vector(); + m_trig_tdt_EF_el_accept = new std::vector(); + + m_trig_tdt_emu_L1_calo_accept = new std::vector(); + m_trig_tdt_emu_L2_calo_accept = new std::vector(); + m_trig_tdt_emu_L2_el_accept = new std::vector(); + m_trig_tdt_emu_EF_calo_accept = new std::vector(); + m_trig_tdt_emu_EF_el_accept = new std::vector(); + + + +} + +void TrigEgammaPhysValBase::release_space(){ + + delete m_el_ringsE ; + delete m_el_trk_summaryValues ; + delete m_el_etCone ; + delete m_el_ptCone ; + + + + delete m_trig_L2_calo_energySample; + delete m_trig_L2_calo_rings ; + delete m_trig_L2_calo_rnnOutput ; + delete m_trig_L2_el_trackAlgID ; + delete m_trig_L2_el_pt ; + delete m_trig_L2_el_eta ; + delete m_trig_L2_el_caloEta ; + delete m_trig_L2_el_phi ; + delete m_trig_L2_el_charge ; + delete m_trig_L2_el_nTRTHits ; + delete m_trig_L2_el_nTRTHiThresholdHits ; + delete m_trig_L2_el_etOverPt ; + delete m_trig_L2_el_trkClusDeta ; + delete m_trig_L2_el_trkClusDphi ; + + delete m_trig_EF_calo_et ; + delete m_trig_EF_calo_eta ; + delete m_trig_EF_calo_phi ; + delete m_trig_EF_calo_etaBE2 ; + delete m_trig_EF_calo_e ; + + delete m_trig_EF_el_calo_et ; + delete m_trig_EF_el_calo_eta ; + delete m_trig_EF_el_calo_phi ; + delete m_trig_EF_el_calo_etaBE2 ; + delete m_trig_EF_el_calo_e ; + + delete m_trig_EF_el_et ; + delete m_trig_EF_el_eta ; + delete m_trig_EF_el_phi ; + delete m_trig_EF_el_e ; + delete m_trig_EF_el_deltaE ; + delete m_trig_EF_el_ethad1 ; + delete m_trig_EF_el_ehad1 ; + delete m_trig_EF_el_f1 ; + delete m_trig_EF_el_f3 ; + delete m_trig_EF_el_f1core ; + delete m_trig_EF_el_f3core ; + delete m_trig_EF_el_weta1 ; + delete m_trig_EF_el_weta2 ; + delete m_trig_EF_el_wtots1 ; + delete m_trig_EF_el_fracs1 ; + delete m_trig_EF_el_e277 ; + delete m_trig_EF_el_Reta ; + delete m_trig_EF_el_Rphi ; + delete m_trig_EF_el_Eratio ; + delete m_trig_EF_el_Rhad ; + delete m_trig_EF_el_Rhad1 ; + delete m_trig_EF_el_deta2 ; + delete m_trig_EF_el_dphi2 ; + delete m_trig_EF_el_dphiresc ; + delete m_trig_EF_el_deltaPhiRescaled2 ; + delete m_trig_EF_el_deltaEta1 ; + delete m_trig_EF_el_etCone ; + delete m_trig_EF_el_ptCone ; + + delete m_trig_EF_el_trk_pt ; + delete m_trig_EF_el_trk_eta ; + delete m_trig_EF_el_trk_charge ; + delete m_trig_EF_el_trk_qOverP ; + delete m_trig_EF_el_trk_sigd0 ; + delete m_trig_EF_el_trk_d0 ; + delete m_trig_EF_el_trk_eProbabilityHT ; + delete m_trig_EF_el_trk_transformed_eProbabilityHT ; + delete m_trig_EF_el_trk_d0significance ; + delete m_trig_EF_el_trk_deltaPOverP ; + delete m_trig_EF_el_trk_summaryValues ; + + delete m_trig_EF_calo_tight ; + delete m_trig_EF_calo_medium ; + delete m_trig_EF_calo_loose ; + delete m_trig_EF_calo_lhtight ; + delete m_trig_EF_calo_lhmedium ; + delete m_trig_EF_calo_lhloose ; + delete m_trig_EF_calo_lhvloose ; + delete m_trig_EF_el_tight ; + delete m_trig_EF_el_medium ; + delete m_trig_EF_el_loose ; + delete m_trig_EF_el_lhtight ; + delete m_trig_EF_el_lhmedium ; + delete m_trig_EF_el_lhloose ; + delete m_trig_EF_el_lhvloose ; + + delete m_trig_tdt_L1_calo_accept ; + delete m_trig_tdt_L2_calo_accept ; + delete m_trig_tdt_L2_el_accept ; + delete m_trig_tdt_EF_calo_accept ; + delete m_trig_tdt_EF_el_accept ; + delete m_trig_tdt_emu_L1_calo_accept ; + delete m_trig_tdt_emu_L2_calo_accept ; + delete m_trig_tdt_emu_L2_el_accept ; + delete m_trig_tdt_emu_EF_calo_accept ; + delete m_trig_tdt_emu_EF_el_accept ; + + + + delete m_trig_EF_el_hasCalo ; + delete m_trig_EF_el_hasTrack ; + + +} + + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx new file mode 100644 index 00000000000..a50f2e7c869 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx @@ -0,0 +1,1364 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Plot Tool -- for all your plotting needs + +// +#include "TrigEgammaAnalysisTools/TrigEgammaPlotTool.h" +#include "TrigEgammaAnalysisTools/ValidationException.h" + +#include "TROOT.h" +#include "TH1.h" +#include "TH2.h" +#include "TTree.h" +#include "TProfile.h" +#include "TProfile2D.h" + +#include +#include +#include +#include +#include +#include "boost/algorithm/string.hpp" +#include +#include +#include "StoreGate/StoreGateSvc.h" +#include "AthenaMonitoring/ManagedMonitorToolBase.h" + +TrigEgammaPlotTool:: +TrigEgammaPlotTool( const std::string& myname ) + : AsgTool(myname) +{ + declareProperty("DirectoryPath",m_baseDir="/HLT/Egamma"); + declareProperty("doJpsiee",m_doJpsiee=false); + declareProperty("TPTrigger",m_tp=false); + declareProperty("MaM",m_mam); + declareProperty("Efficiency",m_effplots); + declareProperty("Distribution",m_distplots); + declareProperty("Resolution",m_resplots); + + // Coverity + m_storeGate = nullptr; + m_histsvc = nullptr; + m_parent = nullptr; + m_nEtbins=0; + m_nEtabins=0; + m_ndefaultEtbins=0; + m_ndefaultEtabins=0; + m_ncoarseEtbins=0; + m_ncoarseEtabins=0; + m_detailedHists=false; +} + +StatusCode TrigEgammaPlotTool::initialize() { + + ATH_MSG_VERBOSE( "Initialising tool " << name() ); + + StatusCode sc; + + sc = service("StoreGateSvc", m_storeGate); + if(sc.isFailure()) { + ATH_MSG_ERROR( "Unable to locate Service StoreGateSvc" ); + return sc; + } + + sc = service("THistSvc", m_histsvc); + if( sc.isFailure() ) { + ATH_MSG_ERROR("Unable to locate Service THistSvc"); + return sc; + } + // Clear map of histograms first ... don't delete anything, as ROOT takes care of this! + if (m_hist1.size() != 0) + m_hist1.clear(); + if (m_hist2.size() != 0) + m_hist2.clear(); + if (m_tree.size() != 0) + m_tree.clear(); + + // Initialize private member + if ( m_detailedHists ) { + TH1::SetDefaultSumw2(); + TH2::SetDefaultSumw2(); + } + + m_label_trigstep.push_back("L2CaloCont"); + m_label_trigstep.push_back("L2Calo"); + m_label_trigstep.push_back("L2Cont"); + m_label_trigstep.push_back("L2"); + m_label_trigstep.push_back("L2TrackCont"); + m_label_trigstep.push_back("EFCaloCont"); + m_label_trigstep.push_back("EFCalo"); + m_label_trigstep.push_back("EFTrackCont"); + m_label_trigstep.push_back("EFTrack"); + m_label_trigstep.push_back("HLTCont"); + m_label_trigstep.push_back("HLT"); + + + m_label_hltobj.push_back("ClusterCont"); + m_label_hltobj.push_back("Cluster"); + m_label_hltobj.push_back("ClusterMatch"); + m_label_hltobj.push_back("TrackCont"); + m_label_hltobj.push_back("Track"); + m_label_hltobj.push_back("TrackMatch"); + m_label_hltobj.push_back("PhotonCont"); + m_label_hltobj.push_back("Photon"); + m_label_hltobj.push_back("PhotonMatch"); + m_label_hltobj.push_back("ElectronCont"); + m_label_hltobj.push_back("Electron"); + m_label_hltobj.push_back("ElectronMatch"); + + + m_label_hltte.push_back("L1Calo"); + m_label_hltte.push_back("L2Calo"); + m_label_hltte.push_back("L2"); + m_label_hltte.push_back("EFCalo"); + m_label_hltte.push_back("EFTrack"); + m_label_hltte.push_back("HLT"); + + return sc; +} + +void TrigEgammaPlotTool::copyArrayToVector(std::vector vec,float arr[], int n) {vec.insert(vec.end(), &arr[0], &arr[n]);} +void TrigEgammaPlotTool::copyArrayToVector(std::vector vec,double arr[], int n) {vec.insert(vec.end(), &arr[0], &arr[n]);} + +void TrigEgammaPlotTool::setBinning(){ + + + // Method to define all binning required that is variable + // Arrays are copied to vectors that are class members + + //Ensure vectors are cleared since book method called from tools + m_etbins.clear(); + m_etabins.clear(); + m_defaultEtbins.clear(); + m_defaultEtabins.clear(); + m_coarseEtbins.clear(); + m_coarseEtabins.clear(); + + // Binning as defined in TP framework + double coarse_eta_bins[9] ={-2.47,-1.52,-1.37,-0.60,0.00,0.60,1.37,1.52,2.47}; + + double coarse_et_bins[7] = {4.,20.,30.,40.,50.,60.,150.}; + + double default_eta_bins[21] = {-2.47,-2.37,-2.01,-1.81,-1.52,-1.37,-1.15,-0.80,-0.60,-0.10,0.00, + 0.10, 0.60, 0.80, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47}; + + double default_et_bins[14] = {4.,7.,10.,15.,20.,25.,30.,35.,40.,45.,50.,60.,80.,150.}; + + float etabins[21]={-2.47,-2.37,-2.01,-1.81,-1.52,-1.37,-1.15,-0.8,-0.6,-0.1, + 0.0,0.1,0.6,0.8,1.15,1.37,1.52,1.81,2.01,2.37,2.47}; + + // TH2 with variable bin x-Axis, but constant bin y-Axis takes only Double_t arrays + float etbins_Zee[31]={0.,2.,4.,6.,8.,10., + 12.,14.,16.,18.,20.,22.,24.,26.,28., + 30.,32.,34.,36.,38.,40.,42.,44.,46.,48.,50.,55.,60.,65.,70.,100.}; + + float etbins_Jpsiee[52]={ 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, + 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, + 10,10.5,11,11.5,12,12.5,13,13.5,14,14.5, + 15,15.5,16,16.5,17,17.5,18,18.5,19,19.5, + 20,20.5,21,21.5,22,22.5,23,23.5,24,24.5, + 25,25.5}; + + + if(m_doJpsiee){ + m_nEtbins=51; + //copyArrayToVector(m_etbins,etbins_Jpsiee,m_nEtbins+1); + //data.assign(newData, newData + count); + m_etbins.insert(m_etbins.end(), &etbins_Jpsiee[0], &etbins_Jpsiee[m_nEtbins+1]); + } + else { + m_nEtbins=30; + //copyArrayToVector(m_etbins,etbins_Zee,m_nEtbins+1); + m_etbins.insert(m_etbins.end(), &etbins_Zee[0], &etbins_Zee[m_nEtbins+1]); + } + + // Define the binning + m_nEtabins=20; + m_ndefaultEtbins=13; + m_ndefaultEtabins=20; + m_ncoarseEtbins=6; + m_ncoarseEtabins=8; + + //Fill the arrays + m_etabins.insert(m_etabins.end(), &etabins[0], &etabins[m_nEtabins+1]); + m_defaultEtbins.insert(m_defaultEtbins.end(), &default_et_bins[0], &default_et_bins[m_ndefaultEtbins+1]); + m_defaultEtabins.insert(m_defaultEtabins.end(), &default_eta_bins[0], &default_eta_bins[m_ndefaultEtabins+1]); + m_coarseEtbins.insert(m_coarseEtbins.end(), &coarse_et_bins[0], &coarse_et_bins[m_ncoarseEtbins+1]); + m_coarseEtabins.insert(m_coarseEtabins.end(), &coarse_eta_bins[0], &coarse_eta_bins[m_ncoarseEtabins+1]); +} + +StatusCode TrigEgammaPlotTool::book(std::map trigInfo){ + + setBinning(); + bool badconfig=false; + for(const auto info:trigInfo){ + // Check for existing trigger in list + if(m_trigInfo.count(info.first) != 0) { + ATH_MSG_ERROR("Trigger booked! Check list of triggers in tools"); + badconfig=true; + continue; + } + m_trigInfo.insert(info); + ATH_MSG_INFO("Book " << info.first); + if(info.second.trigL1){ + bookL1Histos(info.second); + }else if(m_tp) { //For TP triggers just monitor the distributions + const std::string basePath=m_baseDir+"/Expert/"+info.first; + std::vector dirnames; + dirnames.push_back(basePath + "/Distributions/Offline"); + dirnames.push_back(basePath + "/Distributions/HLT"); + for (const auto dir:dirnames){ + ATH_MSG_VERBOSE(dir); + addDirectory(dir); + bookDistributionHistos(dir); + bookEgammaDistributionHistos(dir); + if(info.second.trigType=="electron") + bookElectronDistributionHistos(dir); + addHistogram(new TH1F("rejection","N_{TE}; #Step",6,0,6)); + setLabels(hist1("rejection"),m_label_hltte); + } + } + else + bookExpertHistos(info.second); + } + bookShifterHistos(); + if(badconfig) return StatusCode::FAILURE; + return StatusCode::SUCCESS; +} + +void TrigEgammaPlotTool::bookShifterHistos(){ + std::string dirmam; + std::string dirtrig; + std::string fullPath; + std::string category=""; + std::vector::iterator dirItr; + std::map::iterator histItr; + // Book histograms from existing expert plots + for(const auto info:m_trigInfo){ + ATH_MSG_INFO(info.first << " "); + if(getCategoryFromTrigger(info.first,category)){ + dirtrig=m_baseDir+"/Expert/"+info.first; + dirmam=m_baseDir+"/Shifter/"+category; + dirItr = std::find(m_dir.begin(), m_dir.end(), dirmam); + if (dirItr == m_dir.end()){ + ATH_MSG_DEBUG("MaM Booking " << category << " " << info.first); + addDirectory(dirmam); + //Add contents of the histograms + if(m_tp){ + for(const auto plot:m_distplots){ + fullPath = getPath(plot, dirtrig+"/Distributions/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + addHistogram((TH1*)hist1(plot,dirtrig+"/Distributions/HLT")->Clone()); + } + } + else { + for(const auto plot:m_effplots){ + fullPath = getPath(plot, dirtrig+"/Efficiency/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + addHistogram((TH1*)hist1(plot,dirtrig+"/Efficiency/HLT")->Clone()); + } + for(const auto plot:m_distplots){ + fullPath = getPath(plot, dirtrig+"/Distributions/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + addHistogram((TH1*)hist1(plot,dirtrig+"/Distributions/HLT")->Clone()); + } + for(const auto plot:m_resplots){ + fullPath = getPath(plot, dirtrig+"/Resolutions/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + addHistogram((TH1*)hist1(plot,dirtrig+"/Resolutions/HLT")->Clone()); + } + } + } + } + } +} + +StatusCode TrigEgammaPlotTool::execute(){ + return StatusCode::SUCCESS; +} + +bool TrigEgammaPlotTool::getCategoryFromTrigger(const std::string trigger,std::string &category){ + for(const auto mam:m_mam){ + if(mam.second == trigger){ + category=mam.first; + return true; + } + } + return false; +} + +// Copy contents to shifter plots +StatusCode TrigEgammaPlotTool::finalizeShifterHistos(std::map trigInfo){ + ATH_MSG_INFO("Finalize " << name() << " " << m_tp ); + std::string dirmam; + std::string dirtrig; + std::string category=""; + std::string fullPath; + std::map::iterator histItr; + for(const auto info:trigInfo){ + if(getCategoryFromTrigger(info.first,category)){ + dirtrig=m_baseDir+"/Expert/"+info.first; + dirmam=m_baseDir+"/Shifter/"+category; + if(m_tp){ + ATH_MSG_INFO("Finalize " << name() << " " << info.first << " " << m_tp ); + for(const auto plot:m_distplots){ + fullPath = getPath(plot, dirtrig+"/Distributions/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + hist1(plot,dirmam)->Add(hist1(plot,dirtrig+"/Distributions/HLT")); + } + + } + else { + ATH_MSG_INFO("Finalize " << name() << " " << info.first << " " << m_tp ); + for(const auto plot:m_effplots){ + fullPath = getPath(plot, dirtrig+"/Efficiency/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + hist1(plot,dirmam)->Add(hist1(plot,dirtrig+"/Efficiency/HLT")); + } + for(const auto plot:m_distplots){ + fullPath = getPath(plot, dirtrig+"/Distributions/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + hist1(plot,dirmam)->Add(hist1(plot,dirtrig+"/Distributions/HLT")); + } + for(const auto plot:m_resplots){ + fullPath = getPath(plot, dirtrig+"/Resolutions/HLT"); + histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + ATH_MSG_DEBUG("MaM skip " << plot << " " << fullPath); + else + hist1(plot,dirmam)->Add(hist1(plot,dirtrig+"/Resolutions/HLT")); + } + } + } + } + return StatusCode::SUCCESS; +} + +StatusCode TrigEgammaPlotTool::finalize(){ + return StatusCode::SUCCESS; +} + +void TrigEgammaPlotTool::cd(const std::string &dir) { + // Check if it exists! + m_currentDir = dir; +} + +void TrigEgammaPlotTool::addDirectory(const std::string &dir) { + m_dir.push_back(dir); + std::stringstream ss; + // This is not needed, get this from the file path from histobase + // Set via the m_dir property in all the tool classes + // ss << "HLT/Egamma/" << dir; + // + cd(dir); +} + + +void TrigEgammaPlotTool::addHistogram(TH1 *h, const std::string &dir) { + ATH_MSG_VERBOSE("Adding Histogram"); + if (!h) + throw ValidationException("TrigEgammaPlotTool::addHistogram(TH1 *h == 0, ...)!"); + + std::vector::iterator dirItr; + std::string theDir; + if (dir == "") { + theDir = m_currentDir; + } else { + theDir = dir; + } + + dirItr = std::find(m_dir.begin(), m_dir.end(), theDir); + if (dirItr == m_dir.end()) + throw ValidationException(std::string(std::string("Adding histogram ") + h->GetName()) + std::string(" failed: no directory named ") + theDir); + + std::stringstream ss; + ss << "/" << m_file << "/" << theDir << "/" << h->GetName(); + + + if(m_parent){ + std::set::const_iterator itr = m_mongroups.find( theDir ); + if ( itr==m_mongroups.end() ) { + m_mongroups.insert( theDir ); + /// create actual mongroup + m_parent->addMonGroup(new ManagedMonitorToolBase::MonGroup(m_parent,theDir,ManagedMonitorToolBase::run)); //Can be per run or per lumi block + } + m_parent->addHistogram(h,theDir); + ATH_MSG_VERBOSE("IHLTMonTool Booked Histogram in folder " << theDir); + } + else{ + ATH_MSG_VERBOSE("Registering histogram with THistSvc"); + StatusCode sc; + sc = m_histsvc->regHist(ss.str(), h); + if (sc.isFailure()) { + throw ValidationException(std::string("Failure registering histogram ") + ss.str()); + } + } + + ATH_MSG_VERBOSE("Registered histogram " << ss.str()); + m_hist1.insert(std::pair(ss.str(), h)); +} + +void TrigEgammaPlotTool::addHistogram(TH2 *h, const std::string &dir) { + if (!h) + throw ValidationException("TrigEgammaPlotTool::addHistogram(TH2 *h == 0, ...)!"); + + std::vector::iterator dirItr; + std::string theDir; + if (dir == "") { + theDir = m_currentDir; + } else { + theDir = dir; + } + + dirItr = std::find(m_dir.begin(), m_dir.end(), theDir); + if (dirItr == m_dir.end()) + throw ValidationException(std::string(std::string("Adding histogram ") + h->GetName()) + std::string(" failed: no directory named ") + theDir); + + std::stringstream ss; + ss << "/" << m_file << "/" << theDir << "/" << h->GetName(); + if(m_parent) { + std::set::const_iterator itr = m_mongroups.find( theDir ); + if ( itr==m_mongroups.end() ) { + m_mongroups.insert( theDir ); + /// create actual mongroup + m_parent->addMonGroup(new ManagedMonitorToolBase::MonGroup(m_parent,theDir,ManagedMonitorToolBase::run)); //Can be per run or per lumi block + } + m_parent->addHistogram(h,theDir); + } + else if(!m_parent){ + StatusCode sc; + sc = m_histsvc->regHist(ss.str(), h); + if (sc.isFailure()) { + throw ValidationException(std::string("Failure registering histogram ") + ss.str()); + } + } + + m_hist2.insert(std::pair(ss.str(), h)); +} + +void TrigEgammaPlotTool::addTree(TTree *t, const std::string &dir) { + if (!t) + throw ValidationException("TrigEgammaPlotTool::addTree(TTree *t == 0, ...)!"); + + + std::vector::iterator dirItr; + std::string theDir; + if (dir == "") { + theDir = m_currentDir; + } else { + theDir = dir; + } + + dirItr = std::find(m_dir.begin(), m_dir.end(), theDir); + if (dirItr == m_dir.end()) + throw ValidationException(std::string(std::string("Adding tree ") + t->GetName()) + std::string(" failed: no directory named ") + theDir); + + std::stringstream ss; + ss << "/" << m_file << "/" << theDir << "/" << t->GetName(); + + if(m_parent){ + std::set::const_iterator itr = m_mongroups.find( theDir ); + if ( itr==m_mongroups.end() ) { + m_mongroups.insert( theDir ); + /// create actual mongroup + m_parent->addMonGroup(new ManagedMonitorToolBase::MonGroup(m_parent,theDir,ManagedMonitorToolBase::run)); //Can be per run or per lumi block + } + m_parent->addTree(t,theDir); + + }else if(!m_parent){ + StatusCode sc; + sc = m_histsvc->regTree(ss.str(), t); + if (sc.isFailure()) { + throw ValidationException(std::string("Failure registering tree ") + ss.str()); + } + } + + + m_tree.insert(std::pair(ss.str(), t)); +} + +void TrigEgammaPlotTool::setLabels(TH1* histo, const std::vector& labels) { + if ( ! labels.empty() ){ + for ( int i = 0; i < std::min( (int)labels.size(), (int)histo->GetNbinsX() ); ++i ) { + int bin = i+1; + histo->GetXaxis()->SetBinLabel(bin, labels[i].c_str()); + ATH_MSG_VERBOSE("setting label X" << labels[i] << " for bin " << bin); + } + + for ( int i = (int)histo->GetNbinsX(); i < std::min( (int)labels.size(), (int)histo->GetNbinsX()+(int)histo->GetNbinsY() ); ++i ) { + int bin = i+1-(int)histo->GetNbinsX(); + histo->GetYaxis()->SetBinLabel(bin, labels[i].c_str()); + ATH_MSG_VERBOSE("setting label Y" << labels[i] << " for bin " << bin); + } + } +} +void TrigEgammaPlotTool::getHistsFromPath(const std::vector &pattern, const std::vector ¬pattern, std::map &ret) { + for (std::map::const_iterator i = m_hist1.begin(); i != m_hist1.end(); i++) { + bool goodToGo = true; + for (std::vector::const_iterator pat_it = pattern.begin(); pat_it != pattern.end(); pat_it++) { + if (i->first.find(*pat_it) == std::string::npos) { + goodToGo = false; + break; + } + } + + if (!goodToGo) + continue; + + for (std::vector::const_iterator pat_it = notpattern.begin(); pat_it != notpattern.end(); pat_it++) { + if (i->first.find(*pat_it) != std::string::npos) { + goodToGo = false; + break; + } + } + if (goodToGo) + ret.insert(std::pair(i->first, i->second)); + } +} + +std::string TrigEgammaPlotTool::getPath(const std::string &histName, const std::string &dir) { + std::string theDir; + + std::vector::iterator dirItr; + if (dir == "") { + theDir = m_currentDir; + } else { + theDir = dir; + } + + //ATH_MSG_DEBUG("getPath " << m_file << " " << theDir << " " << histName); + dirItr = std::find(m_dir.begin(), m_dir.end(), theDir); + if (dirItr == m_dir.end()) + throw ValidationException(std::string(std::string("Getting object ") + histName) + std::string(" failed: no directory named ") + theDir); + + std::stringstream ss; + ss << "/" << m_file << "/" << theDir << "/" << histName; + return ss.str(); +} + +TH1 *TrigEgammaPlotTool::hist1(const std::string &histName, const std::string &dir) { + std::string fullPath = getPath(histName, dir); + std::map::iterator histItr = m_hist1.find(fullPath); + if (histItr == m_hist1.end()) + throw ValidationException(std::string(std::string("Getting histogram with path ") + fullPath) + std::string(" failed! No such object!")); + if (!histItr->second) + throw ValidationException(std::string(std::string("Getting histogram with path ") + fullPath) + std::string(" failed! It is a nullptr pointer!")); + + return histItr->second; +} + +TH2 *TrigEgammaPlotTool::hist2(const std::string &histName, const std::string &dir) { + std::string fullPath = getPath(histName, dir); + std::map::iterator histItr = m_hist2.find(fullPath); + if (histItr == m_hist2.end()) + throw ValidationException(std::string(std::string("Getting histogram with path ") + fullPath) + std::string(" failed! No such object!")); + if (!histItr->second) + throw ValidationException(std::string(std::string("Getting histogram with path ") + fullPath) + std::string(" failed! It is a nullptr pointer!")); + + return histItr->second; +} +TTree *TrigEgammaPlotTool::tree(const std::string &treeName, const std::string &dir) { + std::string fullPath = getPath(treeName, dir); + std::map::iterator treeItr = m_tree.find(fullPath); + if (treeItr == m_tree.end()) + throw ValidationException(std::string(std::string("Getting tree with path ") + fullPath) + std::string(" failed! No such object!")); + if (!treeItr->second) + throw ValidationException(std::string(std::string("Getting tree with path ") + fullPath) + std::string(" failed! It is a nullptr pointer!")); + + return treeItr->second; +} + + +void TrigEgammaPlotTool::bookAbsResolutionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("res_pt", "HLT p_{T} resolution; (p_{T}(on)-p_{T}(off)) ; Count", 200, -1.5, 1.5)); + addHistogram(new TH1F("res_et", "HLT E_{T} resolution; (E_{T}(on)-E_{T}(off)) ; Count", 200, -0.5, 0.5)); + addHistogram(new TH1F("res_eta", "#eta resolution; (#eta(on)-#eta(off)) ; Count", 40, -0.001, 0.001)); + addHistogram(new TH1F("res_phi", "#phi resolution; (#phi(on)-#phi(off)) ; Count", 40, -0.001, 0.001)); + + addHistogram(new TH2F("res_etVsEta", "HLT E_{T} resolution as function of #eta; #eta; (E_{T}(on)-E_{T}(off)); Count", + 50, -2.47, 2.47, + 200, -0.1, 0.1)); + addHistogram(new TH2F("res_etVsEt", "HLT E_{T} resolution as function of E_{T}; E_{T} [GeV]; (E_{T}(on)-E_{T}(off)); Count", + 50, 0., 100., + 200, -0.1, 0.1)); + + addHistogram(new TH2F("res_ptcone20_relVsEta", "HLT ptcone20/pt resolution as function of #eta; #eta; on-off; Count", + 50, -2.47, 2.47, + 200, -0.2, 0.2)); + addHistogram(new TH2F("res_ptcone20_relVsEt", "HLT ptcone20/pt resolution as function of E_{T}; E_{T} [GeV]; on-off; Count", + 50, 0., 100., + 200, -0.2, 0.2)); + addHistogram(new TH2F("res_ptcone20VsMu", "HLT ptcone20 resolution as function of avg #mu; #mu; on-off; Count", + 50, 0, 100, + 200, -20, 20)); + addHistogram(new TH2F("res_ptcone20_relVsMu", "HLT ptcone20/pt resolution as function of avg #mu; #mu; on-off; Count", + 50, 0, 100, + 200, -0.2, 0.2)); + addHistogram(new TH2F("res_ptcone20_onVsOff", "online ptcone20 vs offline ptcone20; offline [MeV]; online [MeV]; Count", + 200, 0.0, 10000.0, + 200, 0.0, 10000.0)); + addHistogram(new TH2F("res_ptcone20_rel_onVsOff", "online ptcone20/pt vs offline ptcone20/pt; offline; online; Count", + 200, 0.0, 0.2, + 200, 0.0, 0.2)); + + addHistogram(new TH1F("res_etInEta0", "HLT E_{T} resolution in #eta = [0,1.37]; (E_{T}(on)-E_{T}(off)) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_etInEta1", "HLT E_{T} resolution in #eta = [1.37,1.52]; (E_{T}(on)-E_{T}(off)) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_etInEta2", "HLT E_{T} resolution in #eta = [1.55,1.8]; (E_{T}(on)-E_{T}(off)) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_etInEta3", "HLT E_{T} resolution in #eta = [1.8,2.45]; (E_{T}(on)-E_{T}(off)) ; Count", 200, -0.1, 0.1)); + + // Relative resolutions + //addHistogram(new TH1F("res_e011", "e011 resolution; (e011(on)-e011(off)) ; Count", 50, -0.05, 0.05)); + //addHistogram(new TH1F("res_e132", "e132 resolution; (e132(on)-e132(off)) ; Count", 50, -0.05, 0.05)); + //addHistogram(new TH1F("res_e237", "e237 resolution; (e237(on)-e237(off)) ; Count", 50, -0.05, 0.05)); + //addHistogram(new TH1F("res_e277", "e277 resolution; (e277(on)-e277(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_ethad", "ethad resolution; (ethad(on)-ethad(off)) ; Count", 100, -10, 10)); + addHistogram(new TH1F("res_ethad1", "ethad1 resolution; (ethad1(on)-ethad1(off)) ; Count", 100, -10, 10)); + addHistogram(new TH1F("res_Rhad", "Rhad resolution; (Rhad(on)-Rhad(off)) ; Count", 50, -10., 10.)); + addHistogram(new TH1F("res_Rhad1", "Rhad1; Rhad1 resolution; (Rhad1(on)-Rhad1(off));Count", 50, -10., 10.)); + addHistogram(new TH1F("res_Reta", "Reta resolution; (Reta(on)-Reta(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_Rphi", "Rphi resolution; (Rphi(on)-Rphi(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_weta1", "weta1 resolution; (weta1(on)-weta1(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_weta2", "weta2 resolution; (weta2(on)-weta2(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_f1", "f1 resolution; (f1(on)-f1(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_f3", "f3 resolution; (f3(on)-f3(off)) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_eratio", "eratio resolution; (eratio(on)-eratio(off)) ; Count", 200, -0.001, 0.001)); + addHistogram(new TH1F("res_deta1", "deta1; deta1 ; (deta1(on)-deta1(off))", 100, -1., 1.)); + addHistogram(new TH1F("res_deta2", "deta2; deta2 ; (deta2(on)-deta2(off))", 100, -1., 1.)); + addHistogram(new TH1F("res_dphi2", "dphi2; dphi2 ; (dphi2(on)-dphi2(off))", 100, -1., 1.)); + addHistogram(new TH1F("res_dphiresc", "dphiresc; (dphires(on)-dphires(off)) ; Count", 100, -1., 1.)); + addHistogram(new TH1F("res_d0", "resolution d0; (d0(on)-d0(off)) ; Count", 100, -0.5, 0.5)); + addHistogram(new TH1F("res_d0sig", "resolution d0sig; (d0sig(on)-d0sig(off)) ; Count", 50, -10, 10)); + addHistogram(new TH1F("res_eprobht","resolution eProbHT; (eProbHT(on)-eProbHT(off)); Count",50, -1, 1)); + // TRT + addHistogram(new TH2F("res_eprobhtVsPt", "eProbHT resolution as function of p_{T}; p_{T} [GeV]; (eprobHT(on)-eprobHT(off)); Count", + 50, 0., 100., + 50, -1., 1.)); + addHistogram(new TH2F("res_eprobht_onVsOff", "online eprobHT vs offline eprobHT; offline ; online ; Count", + 50, 0., 1., + 50, 0., 1.)); + addHistogram(new TH1F("res_nscthits","resolution nSCTHit; (nSCTHits(on)-nSCTHits(off); Count",20, -10, 10)); + addHistogram(new TH1F("res_npixhits","resolution nPixHit; (nPixHits(on)-nPixHits(off)); Count",10, -5, 5)); + addHistogram(new TH1F("res_ptcone20", "resolution ptcone20; ptcone20 (on-off); Count", 200, -20, 20)); + addHistogram(new TH1F("res_ptcone20_rel", "resolution ptcone20/pt; ptcone20/pt (on-off); Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_wtots1", "wtots1 resolution; (wtots1(on)-wtots1(off)) ; Count", 50, -0.05, 0.05)); + +} + +void TrigEgammaPlotTool::bookResolutionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("res_et", "E_{T} resolution; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 100, -0.1, 0.1)); + addHistogram(new TH1F("res_eta", "#eta resolution; (#eta(on)-#eta(off))/#eta(off) ; Count", 40, -0.001, 0.001)); + addHistogram(new TH1F("res_phi", "#phi resolution; (#phi(on)-#phi(off))/#phi(off) ; Count", 40, -0.001, 0.001)); + addHistogram(new TH2F("res_etVsEta", "E_{T} resolution as function of #eta; #eta; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 25, -2.5, 2.5, + 50, -0.1, 0.1)); + addHistogram(new TH2F("res_etVsEt", "E_{T} resolution as function of E_{T}; E_{T} [GeV]; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 25, 0., 100., + 50, -0.1, 0.1)); + addHistogram(new TH1F("res_ethad", "ethad resolution; (ethad(on)-ethad(off))/ethad(off) ; Count", 20, -5, 5)); + addHistogram(new TH1F("res_ethad1", "ethad1 resolution; (ethad1(on)-ethad1(off))/ethad1(off) ; Count", 20, -5, 5)); + addHistogram(new TH1F("res_Rhad", "Rhad resolution; (Rhad(on)-Rhad(off))/Rhad(off) ; Count", 20, -10., 10.)); + addHistogram(new TH1F("res_Rhad1", "Rhad1; Rhad1 resolution; (Rhad1(on)-Rhad1(off))/Rhad1(off)", 20, -10., 10.)); + addHistogram(new TH1F("res_Reta", "Reta resolution; (Reta(on)-Reta(off))/Reta(off) ; Count", 20, -0.01, 0.01)); + addHistogram(new TH1F("res_Rphi", "Rphi resolution; (Rphi(on)-Rphi(off))/Rphi(off) ; Count", 20, -0.01, 0.01)); + addHistogram(new TH1F("res_weta1", "weta1 resolution; (weta1(on)-weta1(off))/weta1(off) ; Count", 20, -0.05, 0.05)); + addHistogram(new TH1F("res_weta2", "weta2 resolution; (weta2(on)-weta2(off))/weta2(off) ; Count", 20, -0.05, 0.05)); + addHistogram(new TH1F("res_f1", "f1 resolution; (f1(on)-f1(off))/f1(off) ; Count", 20, -0.05, 0.05)); + addHistogram(new TH1F("res_f3", "f3 resolution; (f3(on)-f3(off))/f3(off) ; Count", 20, -0.05, 0.05)); + addHistogram(new TH1F("res_eratio", "eratio resolution; (eratio(on)-eratio(off))/eratio(off) ; Count", 20, -0.001, 0.001)); + +} + +void TrigEgammaPlotTool::bookElectronResolutionHistos(const std::string &directory){ + cd(directory); + //Electron + addHistogram(new TH1F("res_pt", "p_{T} resolution; (p_{T}(on)-p_{T}(off))/p_{T}(off) ; Count", 120, -1.5, 1.5)); + addHistogram(new TH1F("res_deta1", "deta1; deta1 ; (deta1(on)-deta1(off))/deta1(off)", 100, -1., 1.)); + addHistogram(new TH1F("res_deta2", "deta2; deta2 ; (deta2(on)-deta2(off))/deta2(off)", 100, -1., 1.)); + addHistogram(new TH1F("res_dphi2", "dphi2; dphi2 ; (dphi2(on)-dphi2(off))/dphi2(off)", 100, -1., 1.)); + addHistogram(new TH1F("res_dphiresc", "dphiresc; (dphires(on)-dphires(off))/dphires(off) ; Count", 100, -1., 1.)); + addHistogram(new TH1F("res_d0", "resolution d0; (d0(on)-d0(off)) ; Count", 100, -0.5, 0.5)); + addHistogram(new TH1F("res_d0sig", "resolution d0sig; (d0sig(on)-d0sig(off)) ; Count", 50, -10, 10)); + addHistogram(new TH1F("res_eprobht","resolution eProbHT; (eProbHT(on)-eProbHT(off)); Count",50, -1, 1)); + addHistogram(new TH1F("res_nscthits","resolution nSCTHit; (nSCTHits(on)-nSCTHits(off); Count",20, -10, 10)); + addHistogram(new TH1F("res_npixhits","resolution nPixHit; (nPixHits(on)-nPixHits(off)); Count",10, -5, 5)); + // TRT + addHistogram(new TH2F("res_eprobhtVsPt", "eProbHT resolution as function of p_{T}; p_{T} [GeV]; (eprobHT(on)-eprobHT(off)); Count", + 50, 0., 100., + 50, -1., 1.)); + addHistogram(new TH2F("res_eprobht_onVsOff", "online eprobHT vs offline eprobHT; offline ; online ; Count", + 50, 0., 1., + 50, 0., 1.)); +} + +void TrigEgammaPlotTool::bookElectronIsoResolutionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("res_ptcone20", "resolution ptcone20; ptcone20 (on-off)/off; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_ptcone20_rel", "resolution ptcone20/pt; ptcone20/pt (on-off)/off; Count", 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptcone20_relVsEta", "HLT ptcone20/pt resolution as function of #eta; #eta; (on-off)/off; Count", + 50, -2.47, 2.47, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptcone20_relVsEt", "HLT ptcone20/pt resolution as function of E_{T}; E_{T} [GeV]; (on-off)/off; Count", + 50, 0., 100., + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptcone20VsMu", "HLT ptcone20 resolution as function of avg #mu; #mu; (on-off)/off; Count", + 50, 0, 100, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptcone20_relVsMu", "HLT ptcone20/pt resolution as function of avg #mu; #mu; (on-off)/off; Count", + 50, 0, 100, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptcone20_onVsOff", "online ptcone20 vs offline ptcone20; offline [MeV]; online [MeV]; Count", + 100, 0.0, 10000.0, + 100, 0.0, 10000.0)); + addHistogram(new TH2F("res_ptcone20_rel_onVsOff", "online ptcone20/pt vs offline ptcone20/pt; offline; online; Count", + 100, 0.0, 0.2, + 100, 0.0, 0.2)); + + addHistogram(new TH1F("res_ptvarcone20", "resolution ptvarcone20; ptvarcone20 (on-off)/off; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_ptvarcone20_rel", "resolution ptvarcone20/pt; ptvarcone20/pt (on-off)/off; Count", 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptvarcone20_relVsEta", "HLT ptvarcone20/pt resolution as function of #eta; #eta; (on-off)/off; Count", + 50, -2.47, 2.47, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptvarcone20_relVsEt", "HLT ptvarcone20/pt resolution as function of E_{T}; E_{T} [GeV]; (on-off)/off; Count", + 50, 0., 100., + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptvarcone20VsMu", "HLT ptvarcone20 resolution as function of avg #mu; #mu; (on-off)/off; Count", + 50, 0, 100, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptvarcone20_relVsMu", "HLT ptvarcone20/pt resolution as function of avg #mu; #mu; (on-off)/off; Count", + 50, 0, 100, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_ptvarcone20_onVsOff", "online ptvarcone20 vs offline ptvarcone20; offline [MeV]; online [MeV]; Count", + 100, 0.0, 10000.0, + 100, 0.0, 10000.0)); + addHistogram(new TH2F("res_ptvarcone20_rel_onVsOff", "online ptvarcone20/pt vs offline ptvarcone20/pt; offline; online; Count", + 100, 0.0, 0.2, + 100, 0.0, 0.2)); + +} + +void TrigEgammaPlotTool::bookPhotonResolutionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("res_et_cnv", "HLT E_{T} resolution for converted Photons; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_et_uncnv", "HLT E_{T} resolution for unconverted Photons; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + + addHistogram(new TH2F("res_cnv_etVsEta", "HLT E_{T} resolution as function of #eta for converted Photons; #eta; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 50, -2.47, 2.47, + 200, -0.1, 0.1)); + addHistogram(new TH2F("res_cnv_etVsEt", "HLT E_{T} resolution as function of E_{T} for converted Photons; E_{T} [GeV]; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 50, 0., 100., + 200, -0.1, 0.1)); + + addHistogram(new TH2F("res_uncnv_etVsEta", "HLT E_{T} resolution as function of #eta for unconverted Photons; #eta; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 50, -2.47, 2.47, + 200, -0.1, 0.1)); + addHistogram(new TH2F("res_uncnv_etVsEt", "HLT E_{T} resolution as function of E_{T} for unconverted Photons; E_{T} [GeV]; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 50, 0., 100., + 200, -0.1, 0.1)); + addHistogram(new TH1F("res_cnv_etInEta0", "HLT E_{T} resolution in #eta = [0,1.37]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_cnv_etInEta1", "HLT E_{T} resolution in #eta = [1.37,1.52]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_cnv_etInEta2", "HLT E_{T} resolution in #eta = [1.55,1.8]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_cnv_etInEta3", "HLT E_{T} resolution in #eta = [1.8,2.45]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + + addHistogram(new TH1F("res_uncnv_etInEta0", "HLT E_{T} resolution in #eta = [0,1.37]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_uncnv_etInEta1", "HLT E_{T} resolution in #eta = [1.37,1.52]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_uncnv_etInEta2", "HLT E_{T} resolution in #eta = [1.55,1.8]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_uncnv_etInEta3", "HLT E_{T} resolution in #eta = [1.8,2.45]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + +} +void TrigEgammaPlotTool::bookPhotonIsoResolutionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("res_topoetcone20", "resolution topoetcone20; ptcone20 (on-off)/off; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_topoetcone20_rel", "resolution topoetcone20/pt; ptcone20/pt (on-off)/off; Count", 100, -0.1, 0.1)); + addHistogram(new TH2F("res_topoetcone20_relVsEta", "HLT topoetcone20/pt resolution as function of #eta; #eta; (on-off)/off; Count", + 50, -2.47, 2.47, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_topoetcone20_relVsEt", "HLT topoetcone20/pt resolution as function of E_{T}; E_{T} [GeV]; (on-off)/off; Count", + 50, 0., 100., + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_topoetcone20VsMu", "HLT topoetcone20 resolution as function of avg #mu; #mu; (on-off)/off; Count", + 50, 0, 100, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_topoetcone20_relVsMu", "HLT topoetcone20/pt resolution as function of avg #mu; #mu; (on-off)/off; Count", + 50, 0, 100, + 100, -0.1, 0.1)); + addHistogram(new TH2F("res_topoetcone20_onVsOff", "online topoetcone20 vs offline topoetcone20; offline [GeV]; online [GeV]; Count", + 100, -10.0, 10.0, + 100, -10.0, 10.0)); + addHistogram(new TH2F("res_topoetcone20_rel_onVsOff", "online topoetcone20/pt vs offline topoetcone20/pt; offline; online; Count", + 100, -0.5, 0.5, + 100, -0.5, 0.5)); + addHistogram(new TH2F("res_topoetcone40_shift_onVsOff", "online topoetcone40-2.45 GeV vs offline topoetcone40-2.45 GeV; offline [GeV]; online [GeV]; Count", + 100, -10.0, 10.0, + 100, -10.0, 10.0)); + addHistogram(new TH2F("res_topoetcone40_shift_rel_onVsOff", "online (topoetcone40-2.45 GeV)/pt vs offline (topoetcone40-2.45 GeV)/pt; offline; online; Count", + 100, -0.5, 0.5, + 100, -0.5, 0.5)); +} + +void TrigEgammaPlotTool::bookExpertResolutionHistos(const std::string &directory){ + cd(directory); + + addHistogram(new TH1F("res_etInEta0", "HLT E_{T} resolution in #eta = [0,1.37]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_etInEta1", "HLT E_{T} resolution in #eta = [1.37,1.52]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_etInEta2", "HLT E_{T} resolution in #eta = [1.55,1.8]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + addHistogram(new TH1F("res_etInEta3", "HLT E_{T} resolution in #eta = [1.8,2.45]; (E_{T}(on)-E_{T}(off))/E_{T}(off) ; Count", 200, -0.1, 0.1)); + + + // Relative resolutions + //addHistogram(new TH1F("res_e011", "e011 resolution; (e011(on)-e011(off))/e011(off) ; Count", 50, -0.05, 0.05)); + //addHistogram(new TH1F("res_e132", "e132 resolution; (e132(on)-e132(off))/e132(off) ; Count", 50, -0.05, 0.05)); + //addHistogram(new TH1F("res_e237", "e237 resolution; (e237(on)-e237(off))/e237(off) ; Count", 50, -0.05, 0.05)); + //addHistogram(new TH1F("res_e277", "e277 resolution; (e277(on)-e277(off))/e277(off) ; Count", 50, -0.05, 0.05)); + addHistogram(new TH1F("res_wtots1", "wtots1 resolution; (wtots1(on)-wtots1(off))/wtots1(off) ; Count", 50, -0.05, 0.05)); + + + //Detailed resolution plots + if ( m_detailedHists ) { + addHistogram(new TH2F("res_ethadVsEta", "HLT E_{T} Had resolution as function of #eta; #eta; (ethad(on)-ethad(off))/ethad(off); Count", + 50, -2.47, 2.47, + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_ethadVsEt", "HLT E_{T} Had resolution as function of E_{T}; E_{T} [GeV]; (ethad(on)-ethad(off))/ethad(off); Count", + 50, 0., 100., + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_ethad1VsEta", "HLT E_{T} Had1 resolution as function of #eta; #eta; (ethad1(on)-ethad1(off))/ethad1(off); Count", + 50, -2.47, 2.47, + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_ethad1VsEt", "HLT E_{T} Had1 resolution as function of E_{T}; E_{T} [GeV]; (ethad1(on)-ethad1(off))/ethad1(off); Count", + 50, 0., 100., + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_RhadVsEta", "HLT E_{T} Rhad resolution as function of #eta; #eta; (Rhad(on)-Rhad(off))/Rhad(off); Count", + 50, -2.47, 2.47, + 50, -10, 10)); + addHistogram(new TH2F("res_RhadVsEt", "HLT E_{T} RHad resolution as function of E_{T}; E_{T} [GeV]; (Rhad(on)-Rhad(off))/Rhad(off); Count", + 50, 0., 100., + 50, -10, 10)); + addHistogram(new TH2F("res_Rhad1VsEta", "HLT E_{T} Rhad1 resolution as function of #eta; #eta; (Rhad1(on)-Rhad1(off))/Rhad1(off); Count", + 50, -2.47, 2.47, + 50, -10, 10)); + addHistogram(new TH2F("res_Rhad1VsEt", "HLT E_{T} RHad1 resolution as function of E_{T}; E_{T} [GeV]; (Rhad1(on)-Rhad1(off))/Rhad1(off); Count", + 50, 0., 100., + 50, -10, 10)); + addHistogram(new TH2F("res_RetaVsEta", "HLT Reta resolution as function of #eta; #eta; (Reta(on)-Reta(off))/Reta(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_RetaVsEt", "HLT Reta resolution as function of E_{T}; E_{T} [GeV]; (Reta(on)-Reta(off))/Reta(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_RphiVsEta", "HLT Rphi resolution as function of #eta; #eta; (Rphi(on)-Rphi(off))/Rphi(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_RphiVsEt", "HLT Rphi resolution as function of E_{T}; E_{T} [GeV]; (Rphi(on)-Rphi(off))/Rphi(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta1VsEta", "HLT weta1 resolution as function of #eta; #eta; (weta1(on)-weta1(off))/weta1(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta1VsEt", "HLT weta1 resolution as function of E_{T}; E_{T} [GeV]; (weta1(on)-weta1(off))/weta1(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta2VsEta", "HLT weta2 resolution as function of #eta; #eta; (weta2(on)-weta2(off))/weta2(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta2VsEt", "HLT weta2 resolution as function of E_{T}; E_{T} [GeV]; (weta2(on)-weta2(off))/weta2(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_wtots1VsEta", "HLT wtots1 resolution as function of #eta; #eta; (wtots1(on)-wtots1off))/wtots1(off); Count", + 50,-2.47,2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_wtots1VsEt", "HLT wtots1 resolution as function of E_{T}; E_{T} [GeV]; (wtots1(on)-wtots1(off))/wtots1(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f1VsEta", "HLT f1 resolution as function of #eta; #eta; (f1(on)-f1(off))/f1(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f1VsEt", "HLT f1 resolution as function of E_{T}; E_{T} [GeV]; (f1(on)-f1(off))/f1(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f3VsEta", "HLT f3 resolution as function of #eta; #eta; (f3(on)-f3(off))/f3(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f3VsEt", "HLT f3 resolution as function of E_{T}; E_{T} [GeV]; (f3(on)-f3(off))/f3(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_e2tsts1VsEta", "HLT e2tsts1 resolution as function of #eta; #eta; (e2tsts1(on)-e2tsts1(off))/e2tsts1(off); Count", + 50, -2.47, 2.47, + 50, -10, 10)); + addHistogram(new TH2F("res_e2tsts1VsEt", "HLT e2tsts1 resolution as function of E_{T}; E_{T} [GeV]; (e2tsts1(on)-e2tsts1(off))/e2tsts1(off); Count", + 50, 0., 100., + 50, -10, 10)); + addHistogram(new TH2F("res_eratioVsEta", "HLT eratio resolution as function of #eta; #eta; (eratio(on)-eratio(off))/eratio(off); Count", + 50, -2.47, 2.47, + 50, -0.001, 0.001)); + addHistogram(new TH2F("res_eratioVsEt", "HLT eratio resolution as function of E_{T}; E_{T} [GeV]; (eratio(on)-eratio(off))/eratio(off); Count", + 50, 0., 100., + 50, -0.001, 0.001)); + + } +} + +void TrigEgammaPlotTool::bookExpertL2CaloResolutionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH2F("res_f3VsEta", "L2Calo f3 resolution as function of #eta; #eta; (f3(on)-f3(off))/f3(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f3VsEt", "L2Calo f3 resolution as function of E_{T}; E_{T} [GeV]; (f3(on)-f3(off))/f3(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f1VsEta", "L2Calo f1 resolution as function of #eta; #eta; (f1(on)-f1(off))/f1(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_f1VsEt", "L2Calo f1 resolution as function of E_{T}; E_{T} [GeV]; (f1(on)-f1(off))/f1(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta2VsEta", "L2Calo weta2 resolution as function of #eta; #eta; (weta2(on)-weta2(off))/weta2(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta2VsEt", "L2Calo weta2 resolution as function of E_{T}; E_{T} [GeV]; (weta2(on)-weta2(off))/weta2(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta1VsEta", "L2Calo weta1 resolution as function of #eta; #eta; (weta1(on)-weta1(off))/weta1(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_weta1VsEt", "L2Calo weta1 resolution as function of E_{T}; E_{T} [GeV]; (weta1(on)-weta1(off))/weta1(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_RetaVsEta", "L2Calo Reta resolution as function of #eta; #eta; (Reta(on)-Reta(off))/Reta(off); Count", + 50, -2.47, 2.47, + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_RetaVsEt", "L2Calo Reta resolution as function of E_{T}; E_{T} [GeV]; (Reta(on)-Reta(off))/Reta(off); Count", + 50, 0., 100., + 50, -0.05, 0.05)); + addHistogram(new TH2F("res_Rhad1VsEta", "L2Calo E_{T} Rhad1 resolution as function of #eta; #eta; (Rhad1(on)-Rhad1(off))/Rhad1(off); Count", + 50, -2.47, 2.47, + 50, -10, 10)); + addHistogram(new TH2F("res_Rhad1VsEt", "L2Calo E_{T} RHad1 resolution as function of E_{T}; E_{T} [GeV]; (Rhad1(on)-Rhad1(off))/Rhad1(off); Count", + 50, 0., 100., + 50, -10, 10)); + addHistogram(new TH2F("res_RhadVsEta", "L2Calo E_{T} Rhad resolution as function of #eta; #eta; (Rhad(on)-Rhad(off))/Rhad(off); Count", + 50, -2.47, 2.47, + 50, -10, 10)); + addHistogram(new TH2F("res_RhadVsEt", "L2Calo E_{T} RHad resolution as function of E_{T}; E_{T} [GeV]; (Rhad(on)-Rhad(off))/Rhad(off); Count", + 50, 0., 100., + 50, -10, 10)); + addHistogram(new TH2F("res_ethad1VsEta", "L2Calo E_{T} Had1 resolution as function of #eta; #eta; (ethad1(on)-ethad1(off))/ethad1(off); Count", + 50, -2.47, 2.47, + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_ethad1VsEt", "L2Calo E_{T} Had1 resolution as function of E_{T}; E_{T} [GeV]; (ethad1(on)-ethad1(off))/ethad1(off); Count", + 50, 0., 100., + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_ethadVsEta", "L2Calo E_{T} Had resolution as function of #eta; #eta; (ethad(on)-ethad(off))/ethad(off); Count", + 50, -2.47, 2.47, + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_ethadVsEt", "L2Calo E_{T} Had resolution as function of E_{T}; E_{T} [GeV]; (ethad(on)-ethad(off))/ethad(off); Count", + 50, 0., 100., + 50, -0.5, 0.5)); + addHistogram(new TH2F("res_eratioVsEta", "L2Calo eratio resolution as function of #eta; #eta; (eratio(on)-eratio(off))/eratio(off); Count", + 50, -2.47, 2.47, + 50, -0.001, 0.001)); + addHistogram(new TH2F("res_eratioVsEt", "L2Calo eratio resolution as function of E_{T}; E_{T} [GeV]; (eratio(on)-eratio(off))/eratio(off); Count", + 50, 0., 100., + 50, -0.001, 0.001)); +} + +void TrigEgammaPlotTool::bookDistributionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("et", "ET; ET [GeV] ; Count", 100, 0., 100.)); + addHistogram(new TH1F("eta", "eta; eta ; Count", m_nEtabins,m_etabins.data())); + addHistogram(new TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)); +} + +void TrigEgammaPlotTool::bookEgammaDistributionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("highet", "Offline E_{T}; E_{T} [GeV] ; Count", 100, 0., 2000.)); + //addHistogram(new TH1F("e011", "e011; e011 ; Count", 165, -15., 150.)); + //addHistogram(new TH1F("e132", "e132; e132 ; Count", 165, -15., 150.)); + //addHistogram(new TH1F("e237", "e237; e237 ; Count", 215, -15., 200.)); + //addHistogram(new TH1F("e277", "e277; e277 ; Count", 215, -15., 200.)); + addHistogram(new TH1F("ethad", "ethad; ethad ; Count", 20, -10, 10)); + addHistogram(new TH1F("ethad1", "ethad1; ehad1 ; Count", 20, -10, 10)); + addHistogram(new TH1F("weta1", "weta1; weta1 ; Count", 12, 0.4, 1.)); + addHistogram(new TH1F("weta2", "weta2; weta2 ; Count", 20, 0., 0.02)); + //addHistogram(new TH1F("wtots1", "wtots1; wtots1 ; Count", 50, 0., 0.05)); + addHistogram(new TH1F("f1", "f1; f1 ; Count", 11, -0.1, 1.)); + addHistogram(new TH1F("f3", "f3; f3 ; Count", 21, -0.1, 0.2)); + addHistogram(new TH1F("Reta", "Reta; Reta ; Count", 15, 0., 1.5)); + addHistogram(new TH1F("Rphi", "Rphi; Rphi ; Count", 15, 0., 1.5)); + addHistogram(new TH1F("Rhad", "Rhad; Rhad ; Count", 35, -0.3, 0.3)); + addHistogram(new TH1F("Rhad1", "Rhad1; Rhad1 ; Count", 30, -0.3, 0.3)); + addHistogram(new TH1F("eratio","eratio; eratio; Count",20, 0, 2)); + addHistogram(new TH1F("topoetcone20", "topoetcone20; topoetcone20 [GeV] ; Count", 100, -10.0, 10.0)); + addHistogram(new TH1F("topoetcone20_rel", "topoetcone20/pt; topoetcone20/pt ; Count", 100, -0.5, 0.5)); + addHistogram(new TH1F("topoetcone40_shift", "topoetcone40-2.45 GeV; topoetcone40-2.45 GeV [GeV] ; Count", 100, -10.0, 10.0)); + addHistogram(new TH1F("topoetcone40_shift_rel", "(topoetcone40-2.45 GeV)/pt; (topoetcone40-2.45 GeV)/pt ; Count", 100, -0.5, 0.5)); +} + +void TrigEgammaPlotTool::bookElectronDistributionHistos(const std::string &directory){ + cd(directory); + addHistogram(new TH1F("pt", "p_{T}; p_{T} [GeV] ; Count", 100,0.,100.)); + addHistogram(new TH1F("deta1", "deta1; deta1 ; Count", 40, -0.01, 0.01)); + addHistogram(new TH1F("deta1_EMECA", "deta1 EMEC-A; deta1 ; Count", 40, -0.01, 0.01)); + addHistogram(new TH1F("deta1_EMECC", "deta1 EMEC-C; deta1 ; Count", 40, -0.01, 0.01)); + addHistogram(new TH1F("deta1_EMEBA", "deta1 EMEB-A; deta1 ; Count", 40, -0.01, 0.01)); + addHistogram(new TH1F("deta1_EMEBC", "deta1 EMEB-A; deta1 ; Count", 40, -0.01, 0.01)); + addHistogram(new TH1F("deta2", "deta2; deta2 ; Count", 40, -0.01, 0.01)); + addHistogram(new TH1F("dphi2", "dphi2; dphi2 ; Count", 40, -0.1, 0.1)); + addHistogram(new TH1F("dphiresc", "dphiresc; dphiresc ; Count", 40, -0.1, 0.1)); + addHistogram(new TH1F("d0", "d0; d0 ; Count", 40, -1, 1)); + addHistogram(new TH1F("d0sig", "d0sig; d0sig ; Count", 40, -10, 10)); + addHistogram(new TH1F("eprobht","eProbHT; eProbHT; Count",20, 0, 1.)); + addHistogram(new TH1F("nscthits","nSCTHit; nSCTHits; Count",20, 0, 20)); + addHistogram(new TH1F("npixhits","nPixHit; nPixHits; Count",10, 0, 10)); + addHistogram(new TH1F("charge","charge; charge; Count", 4,-2,2)); + addHistogram(new TH1F("ptcone20", "ptcone20; ptcone20; Count", 50, 0.0, 5.0)); + addHistogram(new TH1F("ptcone20_rel", "ptcone20/pt; ptcone20/pt; Count", 50, 0.0, 1.0)); + addHistogram(new TH1F("ptvarcone20", "ptcone20; ptcone20; Count", 50, 0.0, 5.0)); + addHistogram(new TH1F("ptvarcone20_rel", "ptcone20/pt; ptcone20/pt; Count", 50, 0.0, 1.0)); + addHistogram(new TH1F("lhtight_discriminant", "lh tight discriminant; lh tight discriminant; Count", 50, -5.,2.)); + addHistogram(new TH1F("lhmedium_discriminant", "lh medium discriminant; lh medium discriminant; Count", 50, -5.,2.)); + addHistogram(new TH1F("lhloose_discriminant", "lh loose discriminant; lh loose discriminant; Count", 50, -5.,2.)); + + if(m_detailedHists){ + addHistogram(new TH2F("deta1_vs_clusterEta", "HLT deta1 as function of cluster #eta; #eta; deta1; Count", + 50, -2.47, 2.47, + 90, -0.03, 0.03)); + } + +} + +void TrigEgammaPlotTool::bookEfficiency2DHistos(const std::string &directory){ + cd(directory); + + addHistogram(new TH2F("match_coarse_et_eta","Trigger Matched Offline #eta vs et; E_{T} GeV ;#eta; Count", + m_ncoarseEtbins, m_coarseEtbins.data(), m_ncoarseEtabins, m_coarseEtabins.data())); + addHistogram(new TH2F("coarse_et_eta","Trigger Matched Offline #eta vs et; E_{T} GeV ;#eta; Count", + m_ncoarseEtbins, m_coarseEtbins.data(), m_ncoarseEtabins, m_coarseEtabins.data())); + addHistogram(new TProfile2D("eff_coarse_et_eta","#epsilon(#eta,E_{T}); E_{T} GeV ;#eta; Count", + m_ncoarseEtbins, m_coarseEtbins.data(), m_ncoarseEtabins, m_coarseEtabins.data())); + + if(m_detailedHists){ + addHistogram(new TH2F("match_et_eta","Trigger Matched Offline #eta vs et; E_{T} GeV ;#eta; Count", + m_ndefaultEtbins, m_defaultEtbins.data(), m_ndefaultEtabins, m_defaultEtabins.data())); + addHistogram(new TH2F("et_eta","Trigger Matched Offline #eta vs et; E_{T} GeV ;#eta; Count", + m_ndefaultEtbins, m_defaultEtbins.data(), m_ndefaultEtabins, m_defaultEtabins.data())); + addHistogram(new TProfile2D("eff_et_eta","#epsilon(#eta,E_{T}); E_{T} GeV ;#eta; Count", + m_ndefaultEtbins, m_defaultEtbins.data(), m_ndefaultEtabins, m_defaultEtabins.data())); + } + +} + +void TrigEgammaPlotTool::bookEfficiencyTProfile(const std::string &directory){ + cd(directory); + addHistogram(new TProfile("eff_pt", "#epsilon(p_T); p_{T} ; Efficiency",m_nEtbins,m_etbins.data())); + addHistogram(new TProfile("eff_et", "#epsilon(E_T); E_{T} [GeV] ; Efficiency", m_nEtbins,m_etbins.data())); + addHistogram(new TProfile("eff_highet", "#epsilon(E_T); E_{T} [GeV] ; Efficiency", 40, 0., 1000.)); + addHistogram(new TProfile("eff_eta", "#epsilon(#eta); #eta ; Efficiency", m_nEtabins, m_etabins.data())); + addHistogram(new TProfile("eff_phi", "#epsilon(#phi); #phi ; Efficiency", 20, -3.2, 3.2)); + addHistogram(new TProfile("eff_mu", "#epsilon(<#mu>); <#mu> ; Efficiency", 16, 0, 80)); + + if(m_detailedHists) + addHistogram(new TProfile("eff_npvtx", "#epsilon(npvtx); npvtx ; Efficiency", 16, 0, 80)); +} + +void TrigEgammaPlotTool::bookEfficiencyHistos(const std::string &directory){ + cd(directory); + bookEfficiencyTProfile(directory); + // Numerator + addHistogram(new TH1F("match_pt", "Trigger Matched Offline p_{T}; p_{T} [GeV] ; Count", m_nEtbins,m_etbins.data())); + addHistogram(new TH1F("match_et", "Trigger Matched Offline E_{T}; E_{T} [GeV]; Count", m_nEtbins,m_etbins.data())); + addHistogram(new TH1F("match_highet", "Trigger Matched Offline E_{T}; E_{T} [GeV]; Count", 40, 0., 1000.)); + addHistogram(new TH1F("match_eta", "Trigger Matched Offline #eta; #eta ; Count",m_nEtabins,m_etabins.data())); + addHistogram(new TH1F("match_phi", "Trigger Matched #phi; #phi ; Count", 20, -3.2, 3.2)); + addHistogram(new TH1F("match_mu", "Trigger Matched <#mu>; <#mu> ; Count", 16, 0, 80)); + if(m_detailedHists) + addHistogram(new TH1F("match_npvtx", "Trigger Matched npvtx; npvtx ; Count", 16, 0, 80)); + + // Denominator + addHistogram(new TH1F("pt", "Offline p_{T}; p_{T} [GeV] ; Count",m_nEtbins,m_etbins.data())); + addHistogram(new TH1F("et", "Offline E_{T}; E_{T} [GeV] ; Count", m_nEtbins,m_etbins.data())); + addHistogram(new TH1F("highet", "Offline E_{T}; E_{T} [GeV] ; Count", 40, 0., 1000.)); + addHistogram(new TH1F("eta", "Offline #eta; #eta ; Count", m_nEtabins,m_etabins.data())); + addHistogram(new TH1F("phi", "Offline #phi; #phi ; Count", 20, -3.2, 3.2)); + addHistogram(new TH1F("mu", "<#mu>; <#mu> ; Count", 16, 0, 80)); + if(m_detailedHists) + addHistogram(new TH1F("npvtx", "npvtx; npvtx ; Count", 16, 0, 80)); +} + +void TrigEgammaPlotTool::bookL1Histos(TrigInfo trigInfo){ + const std::string basePath=m_baseDir+"/Expert/"+trigInfo.trigName; + std::vector dirnames; + + std::string dirname=basePath + "/Efficiency/L1Calo"; + addDirectory(dirname); + bookEfficiencyHistos(dirname); + bookEfficiency2DHistos(dirname); + + if (m_doEmulation){ + dirname=basePath + "/Emulation/L1Calo"; + addDirectory(dirname); + bookEfficiencyHistos(dirname); + bookEfficiency2DHistos(dirname); + }//book emulation + + dirname=basePath + "/Distributions/L1Calo"; + addDirectory(dirname); + addHistogram(new TH1F("energy", "Cluster Energy; E [GeV] ; Count", 100, 0., 200.)); + addHistogram(new TH1F("roi_et", "RoI word Cluster Energy; E [GeV] ; Count", 100, 0., 200.)); + addHistogram(new TH1F("emIso", "EM Isolation; E [GeV] ; Count", 50, -1., 20.)); + addHistogram(new TH1F("hadCore", "Hadronic Isolation; E [GeV] ; Count", 50, -1., 20.)); + addHistogram(new TH1F("eta", "eta; eta ; Count", 50, -2.5, 2.5)); + addHistogram(new TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)); + addHistogram(new TH2F("emClusVsEta", "L1 Cluster Energy vs L1 #eta; #eta; E [GeV]; Count", + 51, -2.55, 2.55, + 60, 0, 60)); + addHistogram(new TH2F("emClusVsEmIsol", "L1 Cluster Energy vs emIsol; emIsol [GeV]; E [GeV]; Count", + 20, -0.1, 9.9, + 60, 0, 60)); + addHistogram(new TH2F("emClusVsHadCore", "L1 Cluster Energy vs hadCore; hadCore [GeV]; E [GeV]; Count", + 10, -0.1, 4.9, + 60, 0, 60)); + + dirname=basePath + "/Distributions/RoI"; + addDirectory(dirname); + addHistogram(new TH1F("roi_eta", "RoI #eta; #eta ; Count", 51, -2.55, 2.55)); + addHistogram(new TH1F("roi_phi", "RoI #phi; #phi ; Count", 20, -3.2, 3.2)); + + dirnames.clear(); + dirnames.push_back(basePath + "/Resolutions/L1Calo"); + ATH_MSG_VERBOSE("Creating L1Calo resolution hists"); + for (int i = 0; i < (int) dirnames.size(); i++) { + addDirectory(dirnames[i]); + addHistogram(new TH2F("res_etVsEta", "L1 cluster Energy resolution as function of L1 #eta; #eta; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", + 50, -2.55, 2.55, + 200, -1., 1.)); + } + dirnames.clear(); + dirnames.push_back(basePath + "/AbsResolutions/L1Calo"); + ATH_MSG_VERBOSE("Creating L1Calo Abs resolution hists"); + for (int i = 0; i < (int) dirnames.size(); i++) { + addDirectory(dirnames[i]); + addHistogram(new TH2F("res_etVsEta", "L1 cluster Energy resolution as function of L1 #eta; #eta; E_{T}(on)-E_{T}(off); Count", + 51, -2.55, 2.55, + 200, -100., 100.)); + } + +} + + +void TrigEgammaPlotTool::bookExpertHistos(TrigInfo trigInfo){ + + const std::string basePath=m_baseDir+"/Expert/"+trigInfo.trigName; + std::string dirname; + std::vector dirnames; + + bookL1Histos(trigInfo); + + std::vector algnames; + algnames.push_back("Efficiency"); // Default + if(m_doEmulation) algnames.push_back("Emulation"); + + // Loop over sub directorys + for ( auto algname : algnames){ + + dirname=basePath + "/"+algname+"/HLT"; + addDirectory(dirname); + bookEfficiencyHistos(dirname); + bookEfficiency2DHistos(dirname); + dirnames.push_back(basePath + "/"+algname+"/L2Calo"); + dirnames.push_back(basePath + "/"+algname+"/L2"); + dirnames.push_back(basePath + "/"+algname+"/EFCalo"); + + for (const auto dir:dirnames) { + addDirectory(dir); + bookEfficiencyHistos(dir); + if ( m_detailedHists ) + bookEfficiency2DHistos(dir); + } + + dirnames.clear(); + dirname=basePath + "/"+algname+"/HLT"; + cd(dirname); + if(trigInfo.trigType=="electron"){ + addHistogram(new TProfile("eff_triggerstep","eff_triggerstep",11,0,11)); + addHistogram(new TProfile("eff_hltreco","eff_hltreco",12,0,12)); + setLabels(hist1("eff_triggerstep"),m_label_trigstep); + setLabels(hist1("eff_hltreco"),m_label_hltobj); + + // Labels + std::vector label_failisem {"ClusterEtaRange","ConversionMatch", + "ClusterHadronicLeakage","ClusterMiddleEnergy","ClusterMiddleEratio37","ClusterMiddleEratio33","ClusterMiddleWidth", + "f3","ClusterStripsEratio","ClusterStripsDeltaEmax2","ClusterStripsDeltaE","ClusterStripsWtot","ClusterStripsFracm","ClusterStripsWeta1c", + "empty14","ClusterStripsDEmaxs1", + "TrackBlayer","TrackPixel","TrackSi","TrackA0","TrackMatchEta","TrackMatchPhi","TrackMatchEoverP","TrackTRTeProbabilityHT_Electron", + "TrackTRThits","TrackTRTratio","TrackTRTratio90","TrackA0Tight","TrackMatchEtaTight","Isolation","ClusterIsolation","TrackIsolation", + "No Track","No Cluster","No Object","Total"}; + + std::vector label_failisemlh {"Kinematic","NSi","NPix","NBlayer","Conversion","LH","A0","dEta","dPhiRes","WstotHighET","EoverPHighEt", + "No Track","No Cluster","No Object","Total"}; + + std::vector label_ineffisem {"L2Calo", "L2", "EFCalo",/* "EFTrack",*/ "Shower shape", "TrkClus", "Track", "TRT", "Track & TRT", "TrkClus & Trk & TRT", "IsEM", "Isolation", "isEMLH and Iso", "Track & Cluster", "No cluster", "No track", "No object", "Some object", "Unknown w/o electron", "Unknown w/ electron", "Sum", "Total"}; + + std::vector label_ineffisemlh {"L2Calo", "L2", "EFCalo",/* "EFTrack",*/ "Kinematic", "NSi", "NPix", "NBlayer", "Conversion", "LH", "A0", "dEta", "dPhiRes", "WstotHighET", "EoverPHighEt", "isEMLH", "Isolation", "isEMLH & Iso", "Track & Cluster", "No cluster", "No track", "No object", "Some object", "Unknown w/o electron", "Unknown w/ electron", "Sum", "Total"}; + + std::vector label_isem_trk {"TrackBlayer_Electron","TrackPixel_Electron","TrackSi_Electron","TrackA0Tight_Electron","Total"}; + std::vector label_isem_trkclus {"#eta match","#phi match","E/p match","TrackMatchEtaTight_Electron","Total"}; + std::vector label_isem_trt {"TrackTRTeProbabilityHT_Electron","TrackTRThits_Electron","TrackTRTratio_Electron","TrackTRTratio90_Electron","TrackA0Tight_Electron","Total"}; + + std::string pid = trigInfo.trigPidDecorator.substr(2); + const std::string fail = "FailisEM" + pid; + const std::string ineffisEM = "IneffisEM" + pid; + + if (boost::contains(pid, "LH")) { + addHistogram(new TH1F(fail.c_str(), fail.c_str(), 15, 0, 15)); + addHistogram(new TProfile(ineffisEM.c_str(), ineffisEM.c_str(), 26, 0, 26)); + setLabels(hist1(fail), label_failisemlh); + setLabels(hist1(ineffisEM), label_ineffisemlh); + } + else { + addHistogram(new TH1F(fail.c_str(), fail.c_str(), 36, 0, 36)); + addHistogram(new TProfile(ineffisEM.c_str(), ineffisEM.c_str(), 22, 0, 22)); + setLabels(hist1(fail), label_ineffisem); + setLabels(hist1(ineffisEM), label_failisem); + + const std::string ineffTrk = ineffisEM + "Trk"; + const std::string ineffTrkClus = ineffisEM + "TrkClus"; + const std::string ineffTRT = ineffisEM + "TRT"; + addHistogram(new TProfile(ineffTrk.c_str(), ineffTrk.c_str(), 6, 0, 6)); + addHistogram(new TProfile(ineffTrkClus.c_str(), ineffTrkClus.c_str(), 5, 0, 5)); + addHistogram(new TProfile(ineffTRT.c_str(), ineffTRT.c_str(), 5, 0, 5)); + setLabels(hist1(ineffTrk), label_isem_trk); + setLabels(hist1(ineffTrkClus), label_isem_trkclus); + setLabels(hist1(ineffTRT), label_isem_trt); + } + } + + if ( m_detailedHists ) { + std::vector effdirs; + effdirs.push_back(basePath + "/"+algname+"/HLT/Loose"); + effdirs.push_back(basePath + "/"+algname+"/HLT/Medium"); + effdirs.push_back(basePath + "/"+algname+"/HLT/Tight"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LHLoose"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LHMedium"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LHTight"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LooseIso"); + effdirs.push_back(basePath + "/"+algname+"/HLT/MediumIso"); + effdirs.push_back(basePath + "/"+algname+"/HLT/TightIso"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LHLooseIso"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LHMediumIso"); + effdirs.push_back(basePath + "/"+algname+"/HLT/LHTightIso"); + for (const auto effdir:effdirs) { + addDirectory(effdir); + bookEfficiencyHistos(effdir); + bookEfficiency2DHistos(effdir); + } + }// detailerhistos + + dirnames.clear(); + }// loop over Efficiency (and or) Emulation + + + dirnames.push_back(basePath + "/Distributions/Offline"); + dirnames.push_back(basePath + "/Distributions/HLT"); + for (const auto dir:dirnames){ + ATH_MSG_VERBOSE(dir); + addDirectory(dir); + bookEgammaDistributionHistos(dir); + if(trigInfo.trigType=="electron") + bookElectronDistributionHistos(dir); + addHistogram(new TH1F("rejection","N_{TE}; #Step",6,0,6)); + setLabels(hist1("rejection"),m_label_hltte); + } + + dirname=basePath + "/Distributions/EFCalo"; + dirnames.push_back(dirname); + addDirectory(dirname); + addHistogram(new TH1F("energyBE0", "Cluster Energy BE0; E [GeV] ; Count", 50, 0., 100.)); + addHistogram(new TH1F("energyBE1", "Cluster Energy BE1; E [GeV] ; Count", 50, 0., 100.)); + addHistogram(new TH1F("energyBE2", "Cluster Energy BE2; E [GeV] ; Count", 50, 0., 100.)); + addHistogram(new TH1F("energyBE3", "Cluster Energy BE3; E [GeV] ; Count", 50, 0., 100.)); + addHistogram(new TH1F("energy", "Cluster Energy; E [GeV] ; Count", 50, 0., 100.)); + addHistogram(new TH1F("eta_calo", "eta_calo; eta_calo ; Count", 50, -2.47, 2.47)); + addHistogram(new TH1F("phi_calo", "phi_calo; phi_calo ; Count", 50, -3.14, 3.14)); + + if(trigInfo.trigType=="photon"){ + dirname=basePath + "/Distributions/L2Photon"; + addDirectory(dirname); + bookDistributionHistos(dirname); + } + + if(trigInfo.trigType=="electron"){ + dirname=basePath + "/Distributions/L2Electron"; + addDirectory(dirname); + bookDistributionHistos(dirname); + addHistogram(new TH1F("trkClusDeta", "Trk Clus Deta; deta ; Count", 50, -0.5, 0.5)); + addHistogram(new TH1F("trkClusDphi", "Trk Clus Dphi; dphi ; Count", 50, -0.5, 0.5)); + } + + dirname=basePath + "/Distributions/L2Calo"; + dirnames.push_back(dirname); + addDirectory(dirname); + + //Book the kinematic plots for each trigger level + for(const auto dir:dirnames) + bookDistributionHistos(dir); + + // Resolution + dirname=basePath + "/Resolutions/HLT"; + addDirectory(dirname); + bookResolutionHistos(dirname); + if(trigInfo.trigType=="electron"){ + bookElectronResolutionHistos(dirname); + if(boost::contains(trigInfo.trigName,"iloose") || boost::contains(trigInfo.trigName,"ivarloose")) + bookElectronIsoResolutionHistos(dirname); + } + if(trigInfo.trigType=="photon"){ + bookPhotonResolutionHistos(dirname); + if(boost::contains(trigInfo.trigName,"icaloloose") ||boost::contains(trigInfo.trigName,"icalovloose") || boost::contains(trigInfo.trigName,"icalotight")) + bookPhotonIsoResolutionHistos(dirname); + } + + bookExpertResolutionHistos(dirname); + + if(m_detailedHists){ + dirname=basePath + "/AbsResolutions/HLT"; + addDirectory(dirname); + bookAbsResolutionHistos(dirname); + } + + if(m_detailedHists){ + dirname=basePath + "/Resolutions/L2Calo"; + addDirectory(dirname); + bookResolutionHistos(dirname); + bookExpertL2CaloResolutionHistos(dirname); + } + + dirname=basePath + "/Resolutions/L2Calo_vs_HLT"; + addDirectory(dirname); + bookResolutionHistos(dirname); + if(m_detailedHists) bookExpertL2CaloResolutionHistos(dirname); +} + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx index 56cf8cf3b09..66e0a7441e5 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ /********************************************************************** @@ -43,8 +43,6 @@ StatusCode TrigEgammaResolutionTool::childFinalize(){ StatusCode TrigEgammaResolutionTool::toolExecute(const std::string basePath,TrigInfo info, std::vector> pairObjs){ - ATH_MSG_DEBUG("Executing ResolutionTool for " << basePath); - if(m_tp) return StatusCode::SUCCESS; const std::string dir = basePath+"/"+info.trigName; bool filliso=false; @@ -53,7 +51,7 @@ StatusCode TrigEgammaResolutionTool::toolExecute(const std::string basePath,Trig ATH_MSG_DEBUG("Executing resolution for " << dir); for(const auto pairObj : pairObjs){ const xAOD::Egamma* eg =pairObj.first; - const HLT::TriggerElement *feat = pairObj.second; + const HLT::TriggerElement *feat = pairObj.second; if ( feat!=nullptr ) { // Final cuts done here @@ -71,13 +69,13 @@ StatusCode TrigEgammaResolutionTool::toolExecute(const std::string basePath,Trig if(eg->type()==xAOD::Type::Electron){ const xAOD::Electron* el = static_cast (eg); float et = getEt(el)/1e3; - if(et < info.trigThrHLT-5.0) continue; - if(!eg->auxdecor(info.trigPidDecorator)) continue; + if(et < info.trigThrHLT-5.0) continue; + if(!eg->auxdecor(info.trigPidDecorator)) continue; resolutionElectron(dir,pairObj,filliso); } // Offline object Electron else if(eg->type()==xAOD::Type::Photon){ float et = getCluster_et(eg)/1e3; - if(et < info.trigThrHLT-5.0) continue; + if(et < info.trigThrHLT-5.0) continue; resolutionPhoton(dir,pairObj,filliso); } // Offline photon } @@ -96,7 +94,7 @@ void TrigEgammaResolutionTool::resolutionPhoton(const std::string basePath,std:: if(pairObj.second){ if(ancestorPassed(pairObj.second)) phEF=closestObject(pairObj,dRmax); - if(phEF){ + if(phEF){ if(dRmax < 0.05){ fillHLTResolution(dir1,phEF,pairObj.first); if(filliso) fillIsolationResolution(dir1,phEF,pairObj.first); @@ -115,13 +113,13 @@ void TrigEgammaResolutionTool::resolutionElectron(const std::string basePath,std std::string dir7 = basePath + "/Resolutions/L1Calo"; std::string dir8 = basePath + "/AbsResolutions/L1Calo"; - + float dRmax = 100; const xAOD::Electron *elEF = nullptr; if(pairObj.second){ if(ancestorPassed(pairObj.second)) elEF=closestObject(pairObj,dRmax); - if(elEF){ + if(elEF){ if(dRmax < 0.05){ fillHLTResolution(dir1,elEF,pairObj.first); if(filliso) fillIsolationResolution(dir1,elEF,pairObj.first); @@ -132,7 +130,7 @@ void TrigEgammaResolutionTool::resolutionElectron(const std::string basePath,std fillL2CaloResolution(dir6,clus,elEF); } } - } + } // L1 resolutions auto itEmTau = tdt()->ancestor(pairObj.second); const xAOD::EmTauRoI *l1 = itEmTau.cptr(); @@ -152,7 +150,7 @@ void TrigEgammaResolutionTool::resolutionL2Photon(const std::string dir,std::pai if(pairObj.second){ if(ancestorPassed(pairObj.second)) phL2=closestObject(pairObj,dRmax); - if(phL2){ + if(phL2){ if(dRmax < 0.05){ //Do something here } @@ -163,13 +161,13 @@ void TrigEgammaResolutionTool::resolutionL2Photon(const std::string dir,std::pai void TrigEgammaResolutionTool::resolutionL2Electron(const std::string dir,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj){ cd(dir); - + float dRmax = 100; const xAOD::TrigElectron *elL2 = nullptr; if(pairObj.second){ if(ancestorPassed(pairObj.second)) elL2=closestObject(pairObj,dRmax); - if(elL2){ + if(elL2){ if(dRmax < 0.05){ //Do something here } @@ -248,8 +246,8 @@ void TrigEgammaResolutionTool::fillHLTResolution(const std::string dir,const xAO if(val_off!=0.) hist1("res_d0")->Fill(getTrack_d0(elonl)-val_off); val_off=getD0sig(eloff); if(val_off!=0.) hist1("res_d0sig")->Fill(getD0sig(elonl)-val_off); - - // Absolute resolution on track summary ints/floats + + // Absolute resolution on track summary ints/floats val_off=getTrackSummaryFloat_eProbabilityHT(eloff); hist1("res_eprobht")->Fill( (getTrackSummaryFloat_eProbabilityHT(elonl)-val_off)); hist2("res_eprobht_onVsOff")->Fill(val_off, @@ -259,7 +257,7 @@ void TrigEgammaResolutionTool::fillHLTResolution(const std::string dir,const xAO hist1("res_npixhits")->Fill(getTrackSummary_numberOfPixelHits(elonl)-getTrackSummary_numberOfPixelHits(elonl)); hist1("res_nscthits")->Fill(getTrackSummary_numberOfSCTHits(elonl)-getTrackSummary_numberOfSCTHits(elonl)); - } else { + } else { val_off=getCluster_et(off); if(val_off!=0.){ hist1("res_et")->Fill((getCluster_et(onl)-val_off)/val_off); @@ -453,7 +451,7 @@ void TrigEgammaResolutionTool::fillIsolationResolution(const std::string dir,con float val_off=getIsolation_ptcone20(eloff); hist2("res_ptcone20_onVsOff")->Fill(val_off, getIsolation_ptcone20(elonl)); - if (getEt(elonl) > 0. && getEt(eloff) > 0.){ + if (getEt(elonl) > 0. && getEt(eloff) > 0.){ hist2("res_ptvarcone20_rel_onVsOff")->Fill(getIsolation_ptvarcone20(eloff)/getEt(eloff), getIsolation_ptvarcone20(elonl)/getEt(elonl)); hist2("res_ptcone20_rel_onVsOff")->Fill(getIsolation_ptcone20(eloff)/getEt(eloff), @@ -532,7 +530,7 @@ void TrigEgammaResolutionTool::fillIsolationResolution(const std::string dir,con } void TrigEgammaResolutionTool::fillHLTAbsResolution(const std::string dir,const xAOD::Egamma *onl, const xAOD::Egamma *off){ - + cd(dir); ATH_MSG_DEBUG("Fill Abs Resolution"); if(xAOD::EgammaHelpers::isElectron(onl)){ @@ -540,7 +538,7 @@ void TrigEgammaResolutionTool::fillHLTAbsResolution(const std::string dir,const const xAOD::Electron* eloff =static_cast (off); hist1("res_pt")->Fill((getTrack_pt(elonl)-getTrack_pt(eloff))); hist1("res_et")->Fill((getEt(elonl)-getEt(eloff))/getEt(eloff)); - + const float onl_eta=onl->eta(); const float feta = fabs(onl_eta); const float off_eta=off->eta(); @@ -574,15 +572,15 @@ void TrigEgammaResolutionTool::fillHLTAbsResolution(const std::string dir,const getIsolation_ptcone20(elonl)/getEt(elonl)); } - if( feta < 1.37 ) - hist1("res_etInEta0")->Fill((getEt(elonl)-getEt(eloff))); - else if( feta >=1.37 && feta <= 1.52 ) - hist1("res_etInEta1")->Fill((getEt(elonl)-getEt(eloff))); - else if( feta >= 1.55 && feta < 1.8 ) - hist1("res_etInEta2")->Fill((getEt(elonl)-getEt(eloff))); - else if( feta >= 1.8 && feta < 2.45 ) - hist1("res_etInEta3")->Fill((getEt(elonl)-getEt(eloff))); - + if( feta < 1.37 ) + hist1("res_etInEta0")->Fill((getEt(elonl)-getEt(eloff))); + else if( feta >=1.37 && feta <= 1.52 ) + hist1("res_etInEta1")->Fill((getEt(elonl)-getEt(eloff))); + else if( feta >= 1.55 && feta < 1.8 ) + hist1("res_etInEta2")->Fill((getEt(elonl)-getEt(eloff))); + else if( feta >= 1.8 && feta < 2.45 ) + hist1("res_etInEta3")->Fill((getEt(elonl)-getEt(eloff))); + hist1("res_deta1")->Fill((getCaloTrackMatch_deltaEta1(elonl)-getCaloTrackMatch_deltaEta1(eloff))); hist1("res_deta2")->Fill((getCaloTrackMatch_deltaEta2(elonl)-getCaloTrackMatch_deltaEta2(eloff))); hist1("res_dphi2")->Fill((getCaloTrackMatch_deltaPhi2(elonl)-getCaloTrackMatch_deltaPhi2(eloff))); @@ -593,26 +591,26 @@ void TrigEgammaResolutionTool::fillHLTAbsResolution(const std::string dir,const hist1("res_npixhits")->Fill(getTrackSummary_numberOfPixelHits(elonl)-getTrackSummary_numberOfPixelHits(elonl)); hist1("res_nscthits")->Fill(getTrackSummary_numberOfSCTHits(elonl)-getTrackSummary_numberOfSCTHits(elonl)); } - else{ + else{ hist1("res_et")->Fill((getCluster_et(onl)-getCluster_et(off))); hist1("res_eta")->Fill((onl->eta()-off->eta())); hist1("res_phi")->Fill((onl->phi()-off->phi())); hist2("res_etVsEta")->Fill(onl->eta(), - (getCluster_et(onl)-getCluster_et(off))); + (getCluster_et(onl)-getCluster_et(off))); hist2("res_etVsEt")->Fill( getCluster_et(onl)/1e3, - (getCluster_et(onl)-getCluster_et(off))); + (getCluster_et(onl)-getCluster_et(off))); float feta = fabs(onl->eta()); if( feta < 1.37 ) - hist1("res_etInEta0")->Fill((getCluster_et(onl)-getCluster_et(off))); + hist1("res_etInEta0")->Fill((getCluster_et(onl)-getCluster_et(off))); else if( feta >=1.37 && feta <= 1.52 ) - hist1("res_etInEta1")->Fill((getCluster_et(onl)-getCluster_et(off))); + hist1("res_etInEta1")->Fill((getCluster_et(onl)-getCluster_et(off))); else if( feta >= 1.55 && feta < 1.8 ) - hist1("res_etInEta2")->Fill((getCluster_et(onl)-getCluster_et(off))); + hist1("res_etInEta2")->Fill((getCluster_et(onl)-getCluster_et(off))); else if( feta >= 1.8 && feta < 2.45 ) - hist1("res_etInEta3")->Fill((getCluster_et(onl)-getCluster_et(off))); + hist1("res_etInEta3")->Fill((getCluster_et(onl)-getCluster_et(off))); } - + /*hist1("res_e011")->Fill((getShowerShape_e011(onl)-getShowerShape_e011(off))); hist1("res_e132")->Fill((getShowerShape_e132(onl)-getShowerShape_e132(off))); hist1("res_e237")->Fill((getShowerShape_e237(onl)-getShowerShape_e237(off))); @@ -656,9 +654,9 @@ void TrigEgammaResolutionTool::fillL2CaloResolution(const std::string dir,const float elonl_ethad = elonl->energy( CaloSampling::HEC0 ); elonl_ethad += elonl->energy( CaloSampling::HEC1 ); elonl_ethad += elonl->energy( CaloSampling::HEC2 ); elonl_ethad += elonl->energy( CaloSampling::HEC3 ); - elonl_ethad += elonl->energy( CaloSampling::TileBar0 ); elonl_ethad += elonl->energy( CaloSampling::TileExt0 ); - elonl_ethad += elonl->energy( CaloSampling::TileBar1 ); elonl_ethad += elonl->energy( CaloSampling::TileExt1 ); - elonl_ethad += elonl->energy( CaloSampling::TileBar2 ); elonl_ethad += elonl->energy( CaloSampling::TileExt2 ); + elonl_ethad += elonl->energy( CaloSampling::TileBar0 ); elonl_ethad += elonl->energy( CaloSampling::TileExt0 ); + elonl_ethad += elonl->energy( CaloSampling::TileBar1 ); elonl_ethad += elonl->energy( CaloSampling::TileExt1 ); + elonl_ethad += elonl->energy( CaloSampling::TileBar2 ); elonl_ethad += elonl->energy( CaloSampling::TileExt2 ); elonl_ethad /= TMath::CosH(elonl->eta() ); val_off=getShowerShape_ethad(off); if(val_off!=0.){ @@ -750,7 +748,7 @@ void TrigEgammaResolutionTool::fillL2CaloResolution(const std::string dir,const } } float onl_eratio = 999.0; - if ( fabsf(onl->emaxs1() + onl->e2tsts1()) > 0.01 ) + if ( fabsf(onl->emaxs1() + onl->e2tsts1()) > 0.01 ) onl_eratio = (onl->emaxs1() - onl->e2tsts1()) / (onl->emaxs1() + onl->e2tsts1()); val_off=getShowerShape_Eratio(off); if(val_off!=0.){ @@ -764,11 +762,3 @@ void TrigEgammaResolutionTool::fillL2CaloResolution(const std::string dir,const } } // Electron } - -void TrigEgammaResolutionTool::setDetail(bool doDetail) { - m_detailedHists = doDetail; -} - -void TrigEgammaResolutionTool::setTP(bool tp) { - m_tp = tp; -} diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h index 479f632f565..14a3a4a0c26 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h @@ -15,16 +15,16 @@ class EfficiencyTool public: EfficiencyTool( const std::string& myname ); - virtual ~EfficiencyTool() {}; + ~EfficiencyTool() {}; - virtual StatusCode childInitialize() override; - virtual StatusCode childBook() override; - virtual StatusCode childExecute() override; - virtual StatusCode childFinalize() override; - virtual StatusCode toolExecute(const std::string,const TrigInfo,std::vector> pairObjs) override; - virtual void setDetail(bool doDetail) override; - virtual void setTP(bool tp) override; - virtual void setEmulation(bool doEmu) override; + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); + StatusCode toolExecute(const std::string,const TrigInfo,std::vector> pairObjs); + void setDetail(bool doDetail){ m_detailedHists = doDetail; } + void setTP(bool tp){ m_tp = tp; } + void setEmulation(bool doEmu){ m_doEmulation = doEmu;} private: @@ -33,7 +33,7 @@ protected: void inefficiency(const std::string&,const std::string,const float,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj, const asg::AcceptData& acceptData); void fillInefficiency(const std::string&,const std::string,const xAOD::Electron *,const xAOD::Photon *,const xAOD::CaloCluster *,const xAOD::TrackParticle *, - const asg::AcceptData& acceptData); + const asg::AcceptData& acceptData); bool analyseIsEM(const xAOD::Electron *,const std::string); bool analyseIsEMLH(const xAOD::Electron *,const std::string/*,const std::bitset<4>*/); /*! Include more detailed histograms */ diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/IMonitoringGroupLookup.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/IMonitoringGroupLookup.h deleted file mode 100644 index 8f56a54390f..00000000000 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/IMonitoringGroupLookup.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -// IMonitoringGroupLookup.h - -#ifndef IMonitoringGroupLookup_H -#define IMonitoringGroupLookup_H - -#include "GaudiKernel/INamedInterface.h" -#include "AthenaMonitoringKernel/GenericMonitoringTool.h" - -class IMonitoringGroupLookup : virtual public INamedInterface { - public: - /// InterfaceID - DeclareInterfaceID( IMonitoringGroupLookup, 1, 0 ); - - virtual ToolHandle findGroup( const std::string& name ) const = 0; - -}; - -#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h index f340e5902a0..2b201ce5354 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h @@ -8,19 +8,20 @@ #define ITrigEgammaAnalysisBaseTool_H #include "AsgTools/IAsgTool.h" -//#include "GaudiKernel/ITHistSvc.h" -//#include "GaudiKernel/IInterface.h" -//#include "TrigHLTMonitoring/IHLTMonTool.h" -//#include "TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/IInterface.h" +#include "TrigHLTMonitoring/IHLTMonTool.h" +#include "TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h" #include "TrigEgammaEmulationTool/ITrigEgammaEmulationTool.h" //#include "StoreGate/StoreGateSvc.h" #include "xAODEgamma/Egamma.h" #include "TrigConfHLTData/HLTTriggerElement.h" -#include "TrigEgammaAnalysisTools/TrigEgammaInfo.h" -#include "TrigEgammaAnalysisTools/IMonitoringGroupLookup.h" +#include "TH1.h" +#include "TH2.h" +#include "TTree.h" #include @@ -33,8 +34,8 @@ public: virtual StatusCode book()=0; virtual StatusCode execute()=0; virtual StatusCode finalize()=0; -// virtual void setParent(IHLTMonTool *)=0; -// virtual void setPlotTool(ToolHandle)=0; + virtual void setParent(IHLTMonTool *)=0; + virtual void setPlotTool(ToolHandle)=0; virtual void setDetail(bool)=0; virtual void setTP(bool)=0; virtual void setEmulation(bool)=0; @@ -42,9 +43,8 @@ public: virtual void setAvgMu(const float, const float)=0; virtual void setPVertex(const float, const float)=0; virtual void setSGContainsRnn(bool)=0; - virtual void setSGContainsTrigPhoton(bool)=0; - virtual void setMGLookup(SmartIF MGlookup) = 0; - + virtual void setSGContainsTrigPhoton(bool)=0; + virtual StatusCode childInitialize(){return StatusCode::SUCCESS;}; virtual StatusCode childBook(){return StatusCode::SUCCESS;}; virtual StatusCode childExecute(){return StatusCode::SUCCESS;}; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h new file mode 100644 index 00000000000..821fcd70855 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ITrigEgammaPlotTool.h + +#ifndef ITrigEgammaPlotTool_H +#define ITrigEgammaPlotTool_H + +#include "AsgTools/IAsgTool.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/IInterface.h" +#include "TrigHLTMonitoring/IHLTMonTool.h" +#include "TrigEgammaAnalysisTools/TrigEgammaInfo.h" +//#include "StoreGate/StoreGateSvc.h" + +#include "xAODEgamma/Egamma.h" +#include "TrigConfHLTData/HLTTriggerElement.h" + +#include "TH1.h" +#include "TH2.h" +#include "TTree.h" +#include + +class ITrigEgammaPlotTool : virtual public asg::IAsgTool { + ASG_TOOL_INTERFACE(ITrigEgammaPlotTool) + +public: + + virtual StatusCode initialize()=0; + virtual StatusCode book(std::map)=0; + virtual StatusCode execute()=0; + virtual StatusCode finalize()=0; + virtual StatusCode finalizeShifterHistos(std::map)=0; + virtual void setParent(IHLTMonTool *)=0; + virtual void setDetail(bool)=0; + virtual void setAltBinning(bool)=0; + virtual void setTP(bool)=0; + virtual void setEmulation(bool)=0; + virtual std::string getBasePath()=0; + virtual void cd(const std::string &dir)=0; + virtual void addDirectory(const std::string &s)=0; + virtual void addHistogram(TH1 *h, const std::string &dir = "")=0; + virtual void addHistogram(TH2 *h, const std::string &dir = "")=0; + virtual void addTree(TTree *t, const std::string &dir = "")=0; + + virtual TH1 *hist1(const std::string &histName, const std::string &dir = "")=0; + virtual TH2 *hist2(const std::string &histName, const std::string &dir = "")=0; + virtual TTree *tree(const std::string &treeName, const std::string &dir = "")=0; + virtual void setLabels(TH1* histo, const std::vector& labels)=0; + virtual std::map getTrigInfoMap()=0; +}; + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH1Wrapper.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH1Wrapper.h deleted file mode 100644 index c47c15bddc4..00000000000 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH1Wrapper.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TrigEgammaAnalysisTools_TH1Wrapper_H -#define TrigEgammaAnalysisTools_TH1Wrapper_H - -#include -#include "GaudiKernel/ToolHandle.h" -#include "AthenaMonitoringKernel/GenericMonitoringTool.h" - -namespace TrigEgammaAnalysisTools { - - class TH1Wrapper { - - public: - TH1Wrapper(const ToolHandle& groupHandle, const std::string& histname); - ~TH1Wrapper() {} - void Fill(double value) const; - void Fill(double value, double weight) const; - void Fill(const char * /*namex*/, double /*w*/) const; - int GetNbinsX() const { return 0; } // To be redesigned and removed - void AddBinContent(int /*bin*/) const {} // To be redesigned and removed - - private: - const ToolHandle& m_groupHandle; - std::string m_histname; - }; - -} // end of namespace TrigEgammaAnalysisTools - -#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH2Wrapper.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH2Wrapper.h deleted file mode 100644 index b8b77dc31d8..00000000000 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TH2Wrapper.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TrigEgammaAnalysisTools_TH2Wrapper_H -#define TrigEgammaAnalysisTools_TH2Wrapper_H - -#include -#include "GaudiKernel/ToolHandle.h" -#include "AthenaMonitoringKernel/GenericMonitoringTool.h" - -namespace TrigEgammaAnalysisTools { - - class TH2Wrapper { - - public: - TH2Wrapper(const ToolHandle& groupHandle, const std::string& histname); - ~TH2Wrapper() {} - void Fill(double valueX, double valueY) const; - void Fill(double valueX, double valueY, double weight) const; - - private: - const ToolHandle& m_groupHandle; - std::string m_histname; - }; - -} // end of namespace TrigEgammaAnalysisTools - -#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h index c586f689aa1..19d61b0bf0b 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h @@ -11,10 +11,10 @@ #include "PATCore/AcceptData.h" #include "TrigDecisionTool/TrigDecisionTool.h" #include "TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h" -//#include "TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h" +#include "TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h" #include "TrigEgammaEmulationTool/ITrigEgammaEmulationTool.h" #include "TrigEgammaEmulationTool/TrigEgammaEmulationTool.h" -//#include "TrigHLTMonitoring/IHLTMonTool.h" +#include "TrigHLTMonitoring/IHLTMonTool.h" #include "LumiBlockComps/ILumiBlockMuTool.h" #include "LumiBlockData/LuminosityCondData.h" #include "xAODTruth/TruthParticle.h" @@ -23,36 +23,25 @@ #include "xAODEgamma/Egamma.h" #include "xAODEgamma/ElectronContainer.h" #include "xAODEgamma/PhotonContainer.h" -//#include "xAODEgamma/EgammaxAODHelpers.h" -//#include "xAODEgamma/ElectronAuxContainer.h" -//#include "xAODTrigRinger/TrigRingerRings.h" -//#include "xAODTrigRinger/TrigRingerRingsContainer.h" -//#include "xAODTrigRinger/TrigRNNOutput.h" -//#include "xAODTrigRinger/TrigRNNOutputContainer.h" -//#include "xAODTracking/TrackParticleContainer.h" +#include "xAODEgamma/EgammaxAODHelpers.h" +#include "xAODEgamma/ElectronAuxContainer.h" +#include "xAODTrigRinger/TrigRingerRings.h" +#include "xAODTrigRinger/TrigRingerRingsContainer.h" +#include "xAODTrigRinger/TrigRNNOutput.h" +#include "xAODTrigRinger/TrigRNNOutputContainer.h" +#include "xAODTracking/TrackParticleContainer.h" #include "xAODTrigger/TrigPassBits.h" -//#include "xAODEgamma/PhotonAuxContainer.h" -//#include "xAODCaloRings/RingSet.h" -//#include "xAODCaloRings/RingSetContainer.h" -#include "xAODCaloRings/CaloRings.h" -#include "xAODCaloRings/CaloRingsContainer.h" -#include "xAODCaloRings/tools/getCaloRingsDecorator.h" +#include "xAODEgamma/PhotonAuxContainer.h" +#include "xAODCaloRings/RingSet.h" +#include "xAODCaloRings/RingSetContainer.h" +#include "xAODCaloRings/CaloRings.h" +#include "xAODCaloRings/CaloRingsContainer.h" +#include "xAODCaloRings/tools/getCaloRingsDecorator.h" #include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h" #include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h" #include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" #include "StoreGate/ReadCondHandleKey.h" -#include "TH1.h" -#include "TH2.h" -#include "TTree.h" - -#include -#include "TrigEgammaAnalysisTools/TH1Wrapper.h" -#include "TrigEgammaAnalysisTools/TH2Wrapper.h" - -#include "AthenaMonitoringKernel/GenericMonitoringTool.h" -#include "TrigEgammaAnalysisTools/IMonitoringGroupLookup.h" - class TrigEgammaAnalysisBaseTool : public asg::AsgTool, virtual public ITrigEgammaAnalysisBaseTool { @@ -61,35 +50,31 @@ ASG_TOOL_CLASS(TrigEgammaAnalysisBaseTool, ITrigEgammaAnalysisBaseTool) public: TrigEgammaAnalysisBaseTool( const std::string& myname); - virtual ~TrigEgammaAnalysisBaseTool() {}; + ~TrigEgammaAnalysisBaseTool() {}; - virtual StatusCode initialize() override; - virtual StatusCode book() override; - virtual StatusCode execute() override; - virtual StatusCode finalize() override; + StatusCode initialize() ; + StatusCode book() ; + StatusCode execute() ; + StatusCode finalize() ; template std::unique_ptr createBits(const T* CONT, const B* BITS); template std::unique_ptr getBits(const HLT::TriggerElement* te,const T* CONT); template const T* getFeature(const HLT::TriggerElement* te,const std::string key=""); template bool ancestorPassed(const HLT::TriggerElement* te,const std::string key=""); - template const T1* closestObject(const std::pair, + template const T1* closestObject(const std::pair, float &, bool usePassbits=true,const std::string key=""); // Interface class methods needed to pass information to additional tools or to set common tools - //void setParent(IHLTMonTool *parent) override { m_parent = parent;}; - //void setPlotTool(ToolHandle tool) override {m_plot=tool;} - virtual void setMGLookup(SmartIF MGlookup) override; - - virtual void setDetail(bool detail) override; - virtual void setTP(bool tp) override; - virtual void setEmulation(bool doEmu) override; - virtual void setEmulationTool(ToolHandle tool) override; - virtual void setPVertex(const float onvertex, const float ngoodvertex) override; - virtual void setAvgMu(const float onlmu, const float offmu) override; //For tools called by tools - - virtual void setSGContainsRnn(bool contains) override; - virtual void setSGContainsTrigPhoton(bool contains) override; - - - //* Deperatated methods to be removed later *// + void setParent(IHLTMonTool *parent) { m_parent = parent;}; + void setPlotTool(ToolHandle tool) {m_plot=tool;} + void setDetail(bool detail) {m_detailedHists=detail;} + void setTP(bool tp) {m_tp=tp;} + void setEmulation(bool doEmu) {m_doEmulation=doEmu;} + void setEmulationTool(ToolHandle tool) {m_emulationTool=tool;} + void setPVertex(const float onvertex, const float ngoodvertex) {m_nPVertex = onvertex; m_nGoodVertex = ngoodvertex;} + void setAvgMu(const float onlmu, const float offmu) {m_onlmu=onlmu; m_offmu=offmu;} //For tools called by tools + + void setSGContainsRnn(bool contains) {m_sgContainsRnn=contains;} + void setSGContainsTrigPhoton(bool contains) {m_sgContainsTrigPhoton=contains;} + // Set current MonGroup void cd(const std::string &dir); // Accessor members @@ -97,27 +82,16 @@ public: void addHistogram(TH1 *h, const std::string &dir = ""); void addHistogram(TH2 *h, const std::string &dir = ""); void addTree(TTree *t, const std::string &dir = ""); - //* *************************************** *// - - ToolHandle findGroup( const std::string& name ) const; - std::unique_ptr hist1(const ToolHandle& mgHandle, const std::string &histName); - std::unique_ptr hist2(const ToolHandle& mgHandle, const std::string &histName); - // Transitional methods - std::unique_ptr hist1(const std::string &histName/*, const std::string &dir = ""*/); - std::unique_ptr hist2(const std::string &histName/*, const std::string &dir = ""*/); + TH1 *hist1(const std::string &histName, const std::string &dir = ""); + TH2 *hist2(const std::string &histName, const std::string &dir = ""); TTree *tree(const std::string &treeName, const std::string &dir = ""); - - //* Deperatated methods to be removed later *// void setLabels(TH1* histo, const std::vector& labels); - void setLabels(std::unique_ptr /*histo*/, const std::vector& /*labels*/) {}; // explicitely do nothing - void setLabels(std::unique_ptr /*histo*/, const std::vector& /*labels*/) {}; // explicitely do nothing - //* *************************************** *// - + virtual void print() const; - + private: - + /*! Property update handlers */ void updateDetail(Property& p); void updateAltBinning(Property& p); @@ -135,32 +109,30 @@ private: /*! Helper strings for trigger level analysis */ static const std::vector m_trigLevel; static const std::map m_trigLvlMap; - + /*! Cache pileup info */ float m_onlmu; float m_offmu; - float m_nGoodVertex; + float m_nGoodVertex; float m_nPVertex; - + /*! Hook to check for RNN features in SG */ bool m_sgContainsRnn; bool m_sgContainsTrigPhoton; - // Properties + // Properties ToolHandle m_trigdec; ToolHandle m_matchTool; ToolHandle m_emulationTool; - //ToolHandle m_plot; + ToolHandle m_plot; - ToolHandle m_TMPgroupHandle; - SmartIF m_MGlookup; protected: // Methods ///*! Offline isEM Selectors */ - ToolHandleArray m_electronIsEMTool;//{this,"ElectronIsEMSelector",{}}; + ToolHandleArray m_electronIsEMTool; /*! Offline LH Selectors */ - ToolHandleArray m_electronLHTool;//{this,"ElectronLikelihoodTool",{}}; - ToolHandle m_electronLHVLooseTool;//{this,"ElectronLHVLooseTool", ""}; + ToolHandleArray m_electronLHTool; + ToolHandle m_electronLHVLooseTool; /*! Simple setter to pick up correct probe PID for given trigger */ void parseTriggerName(const std::string,const std::string, bool&, std::string &,float &, float &, std::string &,std::string &, bool&, bool&); /*! Split double object trigger in two simple object trigger */ @@ -170,7 +142,7 @@ protected: /*! Check if electron fulfils isolation criteria */ bool isIsolated(const xAOD::Electron*, const std::string); - bool isPrescaled(const std::string); + bool isPrescaled(const std::string); std::string getProbePid(const std::string);// {return m_offProbeTightness;} /*! book common histograms for analysis */ @@ -178,12 +150,12 @@ protected: void setTrigInfo(const std::string); void setTrigEmulation(){m_forceTrigEmulation=true;}; - + TrigInfo getTrigInfo(const std::string); std::map getTrigInfoMap() { return m_trigInfo; } - + float dR(const float, const float, const float, const float); - + /*! Helper functions now part of base class */ float getEta2(const xAOD::Egamma* eg); float getEt(const xAOD::Electron* eg); @@ -210,12 +182,12 @@ protected: void calculatePileupPrimaryVertex(); float getNPVtx(){return m_nPVertex;} float getNGoodVertex(){return m_nGoodVertex;} - + /* Protection for Holders not in AOD */ bool getSGContainsRnn() { return m_sgContainsRnn;} bool getSGContainsTrigPhoton() { return m_sgContainsTrigPhoton;} - /* trig rings and offline rings helper method for feature extraction from xaod */ + /* trig rings and offline rings helper method for feature extraction from xaod */ bool getCaloRings( const xAOD::Electron *, std::vector & ); bool getTrigCaloRings( const xAOD::TrigEMCluster *, std::vector & ); void parseCaloRingsLayers( unsigned layer, unsigned &minRing, unsigned &maxRing, std::string &caloLayerName); @@ -226,7 +198,7 @@ protected: MonteCarlo::PDGID pdgid(const xAOD::Egamma *, const xAOD::TruthParticleContainer *,const xAOD::TruthParticle *&); /*! Retrieve ToolHandles */ - //ITrigEgammaPlotTool *plot(){return nullptr; }//&*m_plot;} + ITrigEgammaPlotTool *plot(){return &*m_plot;} Trig::TrigDecisionTool *tdt(){return &*m_trigdec;}; Trig::ITrigEgammaMatchingTool *match(){return &*m_matchTool;} Trig::ITrigEgammaEmulationTool *emulation(){return &*m_emulationTool;} @@ -239,21 +211,21 @@ protected: // AcceptInfo/Data const asg::AcceptInfo& getAccept() const {return m_accept;} asg::AcceptData setAccept(const HLT::TriggerElement *,const TrigInfo); - + //Class Members // Athena services StoreGateSvc * m_storeGate; ITHistSvc* m_histsvc; - //IHLTMonTool *m_parent; + IHLTMonTool *m_parent; // ToolHandles - ToolHandleArray m_tools{this,"Tools",{}}; + ToolHandleArray m_tools; /*! Luminosity data */ SG::ReadCondHandleKey m_luminosityCondDataKey; //{ (AthAlgTool*)this, "LuminosityCondDataKey", "LuminosityCondData", "", "" }; /*! Online Lumi tool */ ToolHandle m_lumiBlockMuTool; // This would retrieve the offline - + /*! Set Jpsiee */ bool m_doJpsiee; /*! TP Trigger Analysis */ @@ -283,30 +255,30 @@ protected: /*! default probe pid for trigitems that don't have pid in their name */ std::string m_defaultProbePid; - /*! C Macros for plotting */ + /*! C Macros for plotting */ #define GETTER(_name_) float getShowerShape_##_name_(const xAOD::Egamma* eg); GETTER(e011) - GETTER(e132) + GETTER(e132) GETTER(e237) GETTER(e277) - GETTER(ethad) - GETTER(ethad1) + GETTER(ethad) + GETTER(ethad1) GETTER(weta1) GETTER(weta2) GETTER(f1) - GETTER(e2tsts1) + GETTER(e2tsts1) GETTER(emins1) GETTER(emaxs1) GETTER(wtots1) - GETTER(fracs1) - GETTER(Reta) - GETTER(Rphi) - GETTER(f3) + GETTER(fracs1) + GETTER(Reta) + GETTER(Rphi) + GETTER(f3) GETTER(f3core) GETTER(Eratio) GETTER(Rhad) - GETTER(Rhad1) - GETTER(DeltaE) + GETTER(Rhad1) + GETTER(DeltaE) #undef GETTER @@ -314,44 +286,44 @@ protected: #define GETTER(_name_) float getIsolation_##_name_(const xAOD::Electron* eg); GETTER(ptcone20) GETTER(ptcone30) - GETTER(ptcone40) + GETTER(ptcone40) GETTER(ptvarcone20) GETTER(ptvarcone30) - GETTER(ptvarcone40) -#undef GETTER + GETTER(ptvarcone40) +#undef GETTER #define GETTER(_name_) float getIsolation_##_name_(const xAOD::Egamma* eg); GETTER(etcone20) GETTER(etcone30) - GETTER(etcone40) + GETTER(etcone40) GETTER(topoetcone20) GETTER(topoetcone30) - GETTER(topoetcone40) -#undef GETTER - // GETTERs for CaloCluster monitoring + GETTER(topoetcone40) +#undef GETTER + // GETTERs for CaloCluster monitoring #define GETTER(_name_) float getCluster_##_name_(const xAOD::Egamma* eg); GETTER(et) GETTER(phi) - GETTER(eta) + GETTER(eta) #undef GETTER - // GETTERs for Track monitoring + // GETTERs for Track monitoring #define GETTER(_name_) float getTrack_##_name_(const xAOD::Electron* eg); GETTER(pt) GETTER(phi) - GETTER(eta) - GETTER(d0) - GETTER(z0) + GETTER(eta) + GETTER(d0) + GETTER(z0) #undef GETTER - // GETTERs for Track details monitoring + // GETTERs for Track details monitoring #define GETTER(_name_) float getTrackSummary_##_name_(const xAOD::Electron* eg); - GETTER(numberOfInnermostPixelLayerHits) - GETTER(numberOfInnermostPixelLayerOutliers) + GETTER(numberOfInnermostPixelLayerHits) + GETTER(numberOfInnermostPixelLayerOutliers) GETTER(numberOfPixelHits) GETTER(numberOfPixelOutliers) - GETTER(numberOfSCTHits) - GETTER(numberOfSCTOutliers) + GETTER(numberOfSCTHits) + GETTER(numberOfSCTOutliers) GETTER(numberOfTRTHits) GETTER(numberOfTRTHighThresholdHits) GETTER(numberOfTRTHighThresholdOutliers) @@ -365,37 +337,37 @@ protected: #define GETTER(_name_) float getTrackSummaryFloat_##_name_(const xAOD::Electron* eg); GETTER(eProbabilityComb) GETTER(eProbabilityHT) - GETTER(pixeldEdx) + GETTER(pixeldEdx) #undef GETTER // GETTERs for Calo-Track monitoring #define GETTER(_name_) float getCaloTrackMatch_##_name_(const xAOD::Electron* eg); GETTER(deltaEta0) GETTER(deltaPhi0) - GETTER(deltaPhiRescaled0) + GETTER(deltaPhiRescaled0) GETTER(deltaEta1) GETTER(deltaPhi1) - GETTER(deltaPhiRescaled1) + GETTER(deltaPhiRescaled1) GETTER(deltaEta2) GETTER(deltaPhi2) - GETTER(deltaPhiRescaled2) + GETTER(deltaPhiRescaled2) GETTER(deltaEta3) GETTER(deltaPhi3) - GETTER(deltaPhiRescaled3) -#undef GETTER + GETTER(deltaPhiRescaled3) +#undef GETTER }; -/** Main feature of the code +/** Main feature of the code * templates the TE to get a feature * or find the passing TE * **********************/ // Attempt to create a unique_ptr from existing xAOD::TrigPassBits -// crashes at container_clid and AuxVectorData line 424(359) +// crashes at container_clid and AuxVectorData line 424(359) // when retrieving the cached auxid variable from store // Assuming my attempt to utilise smart pointers breaks the caching of aux data in ESDtoAOD. // // Instead template the conversion and always create transient passBit -template +template std::unique_ptr< xAOD::TrigPassBits> TrigEgammaAnalysisBaseTool::createBits(const CONT* container, const BITS* passbits){ ATH_MSG_DEBUG("Converting "<< ClassID_traits< BITS >::ID() ); std::unique_ptr xbits(new xAOD::TrigPassBits()); @@ -415,7 +387,7 @@ std::unique_ptr< xAOD::TrigPassBits> TrigEgammaAnalysisBaseTool::createBits(cons } -template +template std::unique_ptr< xAOD::TrigPassBits> TrigEgammaAnalysisBaseTool::getBits(const HLT::TriggerElement* te,const CONT* container){ // For conversion of 2015/2016 data const TrigPassBits *bits = getFeature(te); @@ -428,7 +400,7 @@ std::unique_ptr< xAOD::TrigPassBits> TrigEgammaAnalysisBaseTool::getBits(const H const xAOD::TrigPassBits *xbits=getFeature(te); if(xbits){ ATH_MSG_DEBUG("create bits xAOD to xAOD"); - return createBits(container,xbits); + return createBits(container,xbits); } else return nullptr; @@ -459,14 +431,14 @@ const T1* TrigEgammaAnalysisBaseTool::closestObject(const std::pair(pairObj.second,key); if(cont==nullptr) return nullptr; std::unique_ptr bits = getBits(pairObj.second,cont); - - if(usePassbits){ + + if(usePassbits){ if(bits==nullptr) return nullptr; } const T1 *cl = nullptr; - float dr=0.; + float dr=0.; for(const auto& obj : *cont){ - if( usePassbits && !bits->isPassing(obj,cont) ) continue; + if( usePassbits && !bits->isPassing(obj,cont) ) continue; if(obj==nullptr) continue; dr=dR(eta,phi,obj->eta(),obj->phi()); if ( dr> pairObjs) override; - virtual void setDetail(bool doDetail) override; - virtual void setTP(bool tp) override; + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); + StatusCode toolExecute(const std::string,const TrigInfo,std::vector> pairObjs); + void setDetail(bool doDetail){ m_detailedHists = doDetail; } + void setTP(bool tp){ m_tp = tp; } +protected: private: /*! fill kinematic histograms, et,eta,phi,lumi and efficiency */ void fillShowerShapes(const std::string &, const xAOD::Egamma *); // Online and Offline fillers diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaEventSelection.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaEventSelection.h new file mode 100644 index 00000000000..eb112b0d1a4 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaEventSelection.h @@ -0,0 +1,118 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef TRIGEGAMMAANALYSISTOOLS_TRIGEGAMMANAVTPNTUPLE_H +#define TRIGEGAMMAANALYSISTOOLS_TRIGEGAMMANAVTPNTUPLE_H + +#include "TrigEgammaAnalysisTools/TrigEgammaNavTPBaseTool.h" +#include "TrigEgammaAnalysisTools/TrigEgammaPhysValBase.h" +#include "xAODTracking/TrackParticle.h" +#include "xAODTracking/Vertex.h" +#include "xAODEventInfo/EventInfo.h" +#include "xAODEgamma/EgammaEnums.h" +#include "xAODTracking/TrackingPrimitives.h" +#include + +class TrigEgammaEventSelection : public TrigEgammaNavTPBaseTool, public TrigEgammaPhysValBase, + virtual public ITrigEgammaAnalysisBaseTool +{ + ASG_TOOL_CLASS(TrigEgammaEventSelection, ITrigEgammaAnalysisBaseTool) + + public: + + TrigEgammaEventSelection( const std::string& myname ); + ~TrigEgammaEventSelection() {}; + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); + + private: + + /* Dump trigger and offline probe object */ + bool EventSelectionZ(); + bool EventSelectionFakes(); + + bool ApplyFireTriggers( const xAOD::Electron *el); + bool isTruthElectronAny(const xAOD::Egamma *eg ); + + bool fill(TTree *t, const xAOD::Electron *el ); + + /* parse between objects and local variables connected to the + * ttree pointer */ + bool fillEvent ( ); + bool fillMonteCarlo ( const xAOD::Egamma *eg ); + bool fillElectron ( const xAOD::Electron *el ); + bool fillCaloRings ( const xAOD::Electron *el ); + bool fillEmTauRoI ( const xAOD::EmTauRoI *emTauRoI ); + bool fillTrigEMCluster( const xAOD::TrigEMCluster *emCluster ); + bool fillTrigElectron ( const xAOD::TrigElectron *trigEl ); + bool fillCaloCluster ( const xAOD::CaloCluster *cluster ); + bool fillAccept ( const HLT::TriggerElement * ); + bool fillTrigCaloRings( const HLT::TriggerElement *feat ); + bool fillHLTElectron ( const xAOD::Electron *el ); + bool fillTDT ( const xAOD::Electron *el , const HLT::TriggerElement *te ); + + // Helper methods + double get_el_sigd0(const xAOD::Electron *el); + double get_el_d0(const xAOD::Electron *el); + double get_el_eProbabilityHT(const xAOD::Electron *el); + double get_el_transformed_eProbabilityHT(const xAOD::Electron *el); + double get_el_d0significance(const xAOD::Electron *el); + double get_el_deltaPhiRescaled2(const xAOD::Electron *el); + double get_el_deltaEta1(const xAOD::Electron *el); + double get_el_DeltaPOverP(const xAOD::Electron *el); + + + private: + + std::mapm_countMap; + + void count( std::string key ){ + if(m_countMap.find(key) == m_countMap.end()){ + m_countMap[key]= 1; + }else{ + m_countMap[key]++; + } + } + + + + + ToolHandleArray m_EFCaloElectronIsEMSelectors; + ToolHandleArray m_HLTElectronIsEMSelectors; + ToolHandleArray m_EFCaloElectronLHSelectors; + ToolHandleArray m_HLTElectronLHSelectors; + ToolHandle m_electronLHVLooseTool; + + std::vector m_supportingTrigList; + int m_detailedDataLevel; + bool m_selectionZ; + bool m_selectionW; + bool m_selectionMC; + bool m_selectionJpsi; + bool m_selectionFakes; + bool m_doCaloRings; + bool m_dumpTags; + +#define GETTER(_name_) void get_##_name_(const xAOD::Electron*, float); + GETTER(trig_EF_calo_isLHTightCaloOnly_rel21_20170217 ) + GETTER(trig_EF_calo_isLHMediumCaloOnly_rel21_20170217) + GETTER(trig_EF_calo_isLHLooseCaloOnly_rel21_20170217 ) + GETTER(trig_EF_calo_isLHVLooseCaloOnly_rel21_20170217) + GETTER(trig_EF_el_isLHTight_rel21_20170217 ) + GETTER(trig_EF_el_isLHMedium_rel21_20170217) + GETTER(trig_EF_el_isLHLoose_rel21_20170217 ) + GETTER(trig_EF_el_isLHVLoose_rel21_20170217) + GETTER(trig_EF_el_isLHTightNoD0_rel21_20170217 ) + GETTER(trig_EF_el_isLHMediumNoD0_rel21_20170217) + GETTER(trig_EF_el_isLHLooseNoD0_rel21_20170217 ) + GETTER(trig_EF_el_isLHVLooseNoD0_rel21_20170217) +#undef GETTER + + +}; + + + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavAnalysisTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavAnalysisTool.h index 05cfd33ae78..070dbe386c6 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavAnalysisTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavAnalysisTool.h @@ -1,7 +1,7 @@ // -*- C++ -*- /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TrigEgammaNavAnalysisTool_H @@ -14,12 +14,12 @@ class TrigEgammaNavAnalysisTool : public TrigEgammaNavBaseTool, ASG_TOOL_CLASS(TrigEgammaNavAnalysisTool, ITrigEgammaAnalysisBaseTool) public: TrigEgammaNavAnalysisTool( const std::string& myname ); - virtual ~TrigEgammaNavAnalysisTool() {}; + ~TrigEgammaNavAnalysisTool() {}; - virtual StatusCode childInitialize() override; - virtual StatusCode childBook() override; - virtual StatusCode childExecute() override; - virtual StatusCode childFinalize() override; + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); protected: private: diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavBaseTool.h old mode 100644 new mode 100755 index 91d6a1656d6..d4bd4be0060 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavBaseTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavBaseTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TrigEgammaNavBaseTool_H @@ -46,12 +46,12 @@ class TrigEgammaNavBaseTool public: TrigEgammaNavBaseTool( const std::string& myname ); - virtual ~TrigEgammaNavBaseTool() {}; + ~TrigEgammaNavBaseTool() {}; - virtual StatusCode childInitialize() override; - virtual StatusCode childBook() override; - virtual StatusCode childExecute() override; - virtual StatusCode childFinalize() override; + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); protected: /*! EventWise Selection */ bool EventWiseSelection(); @@ -59,19 +59,19 @@ protected: StatusCode executeNavigation(const TrigInfo); /*! Tag Electron selection */ - bool passedTrigger(const HLT::TriggerElement* obj); + bool passedTrigger(const HLT::TriggerElement* obj); /*! Rerun offline selection */ bool ApplyElectronPid(const xAOD::Electron *eg, const std::string pidname); /*! Clears list of probes after each trigger item per event */ - void clearList(); + void clearList(); /*! vector of offline object and matched TE */ std::vector > m_objTEList; /*! List of triggers from menu */ std::vector m_trigInputList; /*! List of trigger categories for MaM */ - //std::vector m_categories; + //std::vector m_categories; /*! List of triggers to study */ - std::vector m_trigList; + std::vector m_trigList; /*! Base Directory name for each algorithm */ std::string m_dir; /*! Directory name for each algorithm */ @@ -85,12 +85,12 @@ protected: const xAOD::TruthParticleContainer* m_truthContainer; private: - + /*! navigation method called by executeNavigation */ - StatusCode executeElectronNavigation(const std::string trigItem,float,std::string); + StatusCode executeElectronNavigation(const std::string trigItem,float,std::string); /*! navigation method called by executeNavigation */ - StatusCode executePhotonNavigation(const std::string trigItem,float); - + StatusCode executePhotonNavigation(const std::string trigItem,float); + // ToolHandles // Offline ++ selectors // In python order will matter. Should always be tight, medium, loose @@ -102,17 +102,17 @@ private: const xAOD::PhotonContainer* m_offPhotons; /*! Jet container for probe selection */ const xAOD::JetContainer* m_jets; - + /* TP selection properties */ - + /*! Define the PID for tag electron */ std::string m_offTagTightness; - /*! define the Pid of Probe from the trigger name */ + /*! define the Pid of Probe from the trigger name */ std::string m_offProbeTightness; /*! Map of trigger name and L1 item */ //std::map m_triggerMap; /*! Define isolation working point for Probe electron */ - std::string m_offProbeIsolation; + std::string m_offProbeIsolation; /* Define the pidname for data collection using experimentalSelection methods*/ std::string m_electronFilterType; /* Define the pidname for data collection using experimentalSelection methods*/ @@ -129,8 +129,8 @@ protected:/// Protect type is used here becouse this can be access by inheritanc /* force et cluster cut*/ bool m_forceEtThr; /*! Remove crack region for Probe default True */ - bool m_rmCrack; - /* force experimentalSelection selection*/ + bool m_rmCrack; + /* force experimentalSelection selection*/ bool m_forceVetoVeryLoose; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPAnalysisTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPAnalysisTool.h index 6528391afbf..7c0c70a8de5 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPAnalysisTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPAnalysisTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TrigEgammaNavTPAnalysisTool_H @@ -15,12 +15,12 @@ class TrigEgammaNavTPAnalysisTool public: TrigEgammaNavTPAnalysisTool( const std::string& myname ); - virtual ~TrigEgammaNavTPAnalysisTool() {}; + ~TrigEgammaNavTPAnalysisTool() {}; - virtual StatusCode childInitialize () override; - virtual StatusCode childBook() override; - virtual StatusCode childExecute() override; - virtual StatusCode childFinalize() override; + StatusCode childInitialize (); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); private: diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPBaseTool.h index c92e61eda09..5a07d7ad8b3 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPBaseTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaNavTPBaseTool.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef TrigEgammaNavTPBaseTool_H #define TrigEgammaNavTPBaseTool_H #include "TrigConfHLTData/HLTFrame.h" #include "TrigConfHLTData/HLTTriggerElement.h" +//#include "TrigNavigation/Navigation.h" #include "TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h" #include "xAODEventInfo/EventInfo.h" @@ -32,7 +33,7 @@ #include "xAODTrigger/EmTauRoIContainer.h" namespace Trig{ - class FeatureContainer; + class FeatureContainer; } class TrigEgammaNavTPBaseTool: public TrigEgammaAnalysisBaseTool, @@ -40,27 +41,27 @@ class TrigEgammaNavTPBaseTool: public TrigEgammaAnalysisBaseTool, ASG_TOOL_CLASS(TrigEgammaNavTPBaseTool, ITrigEgammaAnalysisBaseTool) public: - + TrigEgammaNavTPBaseTool( const std::string& myname ); - virtual ~TrigEgammaNavTPBaseTool() {}; - - virtual StatusCode childInitialize() override; - virtual StatusCode childBook() override; - virtual StatusCode childExecute() override; - virtual StatusCode childFinalize() override; - + ~TrigEgammaNavTPBaseTool() {}; + + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); + protected: - + /*! things like LAr-error, Tile-error, etc, should come here */ - bool EventWiseSelection(); + bool EventWiseSelection(); /*! pass without detector errors */ bool passesEventCleaning(); /*! at least one chain should pass. e28_tight_iloose? */ bool MinimalTriggerRequirement (); /*! Tag and Probe method called by derived classes */ - void executeTandP(); + void executeTandP(); /*! Match probes called by derived classes */ - void matchObjects(const std::string trigItem); + void matchObjects(const std::string trigItem); /*! Tag Electron selection */ bool isTagElectron(const xAOD::Electron *el); /*! Rerun offline selection */ @@ -68,9 +69,9 @@ class TrigEgammaNavTPBaseTool: public TrigEgammaAnalysisBaseTool, /*! Rerun offline selection */ void DressPid(const xAOD::Electron *eg); /*! Probe selection */ - bool isGoodProbeElectron(const xAOD::Electron *el);//,const std::string,const float,const std::string); + bool isGoodProbeElectron(const xAOD::Electron *el);//,const std::string,const float,const std::string); /*! Event-wise trigger selection */ - bool passedTrigger(const HLT::TriggerElement* obj); + bool passedTrigger(const HLT::TriggerElement* obj); /*! Clears list of probes after each trigger item per event */ void clearProbeList(); /*! Clears list of matched probes after each trigger item per event */ @@ -122,7 +123,7 @@ class TrigEgammaNavTPBaseTool: public TrigEgammaAnalysisBaseTool, float m_tagMinEt; /*! Minimum probe Et */ float m_probeMinEt; - + // Containers /*! Event Wise offline ElectronContainer Access and end iterator */ const xAOD::ElectronContainer* m_offElectrons; @@ -134,30 +135,30 @@ class TrigEgammaNavTPBaseTool: public TrigEgammaAnalysisBaseTool, const xAOD::EventInfo* m_eventInfo; /* Truth Container */ const xAOD::TruthParticleContainer* m_truthContainer; - + private: // In python order will matter. Should always be tight, medium, loose // Order no longer important since using a map - + std::map< std::string, unsigned int > m_PidToolMap; /*! Pass a string to pick up correct selector */ - //std::map< std::string, std::string > m_PidMap; /*! Map trigger pid to selector pid */ - + //std::map< std::string, std::string > m_PidMap; /*! Map trigger pid to selector pid */ + /* TP selection properties */ /*! Not needed */ // unsigned int m_isEMoffTag; /*! Define the PID for tag electron */ std::string m_offTagTightness; - /*! define the Pid of Probe from the trigger name */ + /*! define the Pid of Probe from the trigger name */ std::string m_offProbeTightness; - /*! define the Pid of Probe from the user */ + /*! define the Pid of Probe from the user */ std::string m_defaultProbeTightness; /*! force user defined probe for pid triggers */ bool m_forceProbePid; /*! Trigger for tag and event wise selection */ std::vector m_tagTrigList; /*! Apply nearby jet selection */ - bool m_applyJetNearProbeSelection; + bool m_applyJetNearProbeSelection; /*! force probe isolation */ bool m_forceProbeIsolation; /*! Define isolation working point for Probe electron */ diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPhysValBase.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPhysValBase.h new file mode 100644 index 00000000000..6b77c0d095a --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPhysValBase.h @@ -0,0 +1,276 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGEGAMMAANALYSISTOOLS_TRIGEGAMMAPHYSVALBASE_H +#define TRIGEGAMMAANALYSISTOOLS_TRIGEGAMMAPHYSVALBASE_H + +#include "xAODEventInfo/EventInfo.h" +#include "xAODTruth/TruthParticle.h" +#include "xAODTruth/TruthParticleContainer.h" +#include "xAODEventInfo/EventInfo.h" +#include "xAODEgamma/EgammaEnums.h" +#include "xAODTracking/TrackingPrimitives.h" +#include "TrigDecisionTool/TrigDecisionTool.h" +#include "TTree.h" + +class TrigEgammaPhysValBase +{ + public: + TrigEgammaPhysValBase(); + ~TrigEgammaPhysValBase() {}; + + protected: + /* helper function */ + template void InitBranch(TTree* fChain, std::string branch_name, T* param, bool message = true); + + /* Create branches */ + void bookEventBranches( TTree *t ); + void bookElectronBranches( TTree *t ); + void bookTriggerBranches( TTree *t ); + void bookMonteCarloBranches( TTree *t ); + void bookTDTBranches( TTree *t ); + + /* uses InitBranch to connect the local variable and ttree pointer */ + void linkEventBranches( TTree *t); + void linkElectronBranches( TTree *t); + void linkTriggerBranches( TTree *t); + void linkSelectorBranches( TTree *t); + void linkMonteCarloBranches( TTree *t); + void linkTDTBranches( TTree *t); + + /* Space memory manager */ + void alloc_space(); + void release_space(); + void clear(); + void createTDTMetadata( TTree *t, std::vector trigList ); + + bool m_doMCDetailed; + bool m_doL2Detailed; + bool m_doL2CaloDetailed; + bool m_doRecoDetailed; + + /* Branch variables */ + uint32_t m_runNumber{}; + unsigned long long m_eventNumber{}; + unsigned int m_eventCounter{}; + float m_avgmu{}; + float m_lumiBlock{}; + + /* Egamma */ + + bool m_el_hasCalo ; + bool m_el_hasTrack ; + float m_el_e; + float m_el_et; + float m_el_eta; + float m_el_phi; + float m_el_ethad1; + float m_el_ehad1; + float m_el_f1; + float m_el_f3; + float m_el_f1core; + float m_el_f3core; + float m_el_weta1; + float m_el_weta2; + float m_el_wtots1; + float m_el_fracs1; + float m_el_Reta; + float m_el_Rphi; + float m_el_Eratio; + float m_el_Rhad; + float m_el_Rhad1; + float m_el_deta1; + float m_el_deta2; + float m_el_dphi2; + float m_el_dphiresc; + float m_el_deltaPhiRescaled2; + float m_el_deltaEta1; + float m_el_deltaE; + float m_el_e277; + std::vector *m_el_etCone; + std::vector *m_el_ptCone; + + + + float m_el_trk_pt; + float m_el_trk_eta; + float m_el_trk_charge; + float m_el_trk_sigd0; + float m_el_trk_d0; + float m_el_trk_eProbabilityHT; + float m_el_trk_transformed_eProbabilityHT; + float m_el_trk_d0significance; + float m_el_trk_deltaPOverP; + float m_el_trk_qOverP; + std::vector *m_el_trk_summaryValues; + + bool m_el_loose{}; + bool m_el_medium{}; + bool m_el_tight{}; + bool m_el_lhVLoose{}; + bool m_el_lhLoose{}; + bool m_el_lhMedium{}; + bool m_el_lhTight{}; + bool m_el_rgLoose{}; + bool m_el_rgMedium{}; + bool m_el_rgTight{}; + bool m_el_multiLepton{}; + std::vector *m_el_ringsE; + int m_el_nGoodVtx{}; + int m_el_nPileupPrimaryVtx{}; + ///Egamma Calo + float m_el_calo_et{}; + float m_el_calo_eta{}; + float m_el_calo_phi{}; + float m_el_calo_etaBE2{}; + float m_el_calo_e{}; + // Level 1 + float m_trig_L1_eta{}; + float m_trig_L1_phi{}; + float m_trig_L1_emClus{}; + float m_trig_L1_tauClus{}; + float m_trig_L1_emIsol{}; + float m_trig_L1_hadIsol{}; + float m_trig_L1_hadCore{}; + std::vector *m_trig_L1_thrNames; + + // Level 2 Calo + float m_trig_L2_calo_et{}; + float m_trig_L2_calo_eta{}; + float m_trig_L2_calo_phi{}; + float m_trig_L2_calo_e237{}; + float m_trig_L2_calo_e277{}; + float m_trig_L2_calo_fracs1{}; + float m_trig_L2_calo_weta2{}; + float m_trig_L2_calo_ehad1{}; + float m_trig_L2_calo_emaxs1{}; + float m_trig_L2_calo_e2tsts1{}; + float m_trig_L2_calo_wstot{}; + float m_trig_L2_calo_nnOutput{}; + std::vector *m_trig_L2_calo_energySample; + std::vector *m_trig_L2_calo_rings; + std::vector *m_trig_L2_calo_rnnOutput; + // level 2 id + std::vector *m_trig_L2_el_trackAlgID; + std::vector *m_trig_L2_el_pt; + std::vector *m_trig_L2_el_caloEta; + std::vector *m_trig_L2_el_eta; + std::vector *m_trig_L2_el_phi; + std::vector *m_trig_L2_el_charge; + std::vector *m_trig_L2_el_nTRTHits; + std::vector *m_trig_L2_el_nTRTHiThresholdHits; + std::vector *m_trig_L2_el_etOverPt; + std::vector *m_trig_L2_el_trkClusDeta; + std::vector *m_trig_L2_el_trkClusDphi; + + // EFCalo and HLT steps + + std::vector *m_trig_EF_calo_e; + std::vector *m_trig_EF_calo_et; + std::vector *m_trig_EF_calo_eta; + std::vector *m_trig_EF_calo_phi; + std::vector *m_trig_EF_calo_etaBE2; + + std::vector *m_trig_EF_el_calo_e; + std::vector *m_trig_EF_el_calo_et; + std::vector *m_trig_EF_el_calo_eta; + std::vector *m_trig_EF_el_calo_phi; + std::vector *m_trig_EF_el_calo_etaBE2; + + std::vector *m_trig_EF_el_e; + std::vector *m_trig_EF_el_et; + std::vector *m_trig_EF_el_eta; + std::vector *m_trig_EF_el_phi; + std::vector *m_trig_EF_el_ethad1; + std::vector *m_trig_EF_el_ehad1; + std::vector *m_trig_EF_el_f1; + std::vector *m_trig_EF_el_f3; + std::vector *m_trig_EF_el_f1core; + std::vector *m_trig_EF_el_f3core; + std::vector *m_trig_EF_el_weta1; + std::vector *m_trig_EF_el_weta2; + std::vector *m_trig_EF_el_wtots1; + std::vector *m_trig_EF_el_fracs1; + std::vector *m_trig_EF_el_Reta; + std::vector *m_trig_EF_el_Rphi; + std::vector *m_trig_EF_el_Eratio; + std::vector *m_trig_EF_el_Rhad; + std::vector *m_trig_EF_el_Rhad1; + std::vector *m_trig_EF_el_deta2; + std::vector *m_trig_EF_el_dphi2; + std::vector *m_trig_EF_el_dphiresc; + std::vector *m_trig_EF_el_e277; + std::vector *m_trig_EF_el_deltaPhiRescaled2; + std::vector *m_trig_EF_el_deltaEta1; + std::vector *m_trig_EF_el_deltaE; + std::vector *m_trig_EF_el_etCone; + std::vector *m_trig_EF_el_ptCone; + + + std::vector *m_trig_EF_el_trk_pt; + std::vector *m_trig_EF_el_trk_eta; + std::vector *m_trig_EF_el_trk_charge; + std::vector *m_trig_EF_el_trk_sigd0; + std::vector *m_trig_EF_el_trk_d0; + std::vector *m_trig_EF_el_trk_eProbabilityHT; + std::vector *m_trig_EF_el_trk_transformed_eProbabilityHT; + std::vector *m_trig_EF_el_trk_d0significance; + std::vector *m_trig_EF_el_trk_deltaPOverP; + std::vector *m_trig_EF_el_trk_qOverP; + std::vector *m_trig_EF_el_trk_summaryValues; + + + std::vector *m_trig_EF_el_hasCalo ; + std::vector *m_trig_EF_el_hasTrack ; + + + + std::vector *m_trig_EF_el_loose; + std::vector *m_trig_EF_el_medium; + std::vector *m_trig_EF_el_tight; + std::vector *m_trig_EF_el_lhvloose; + std::vector *m_trig_EF_el_lhloose; + std::vector *m_trig_EF_el_lhmedium; + std::vector *m_trig_EF_el_lhtight; + std::vector *m_trig_EF_calo_loose; + std::vector *m_trig_EF_calo_medium; + std::vector *m_trig_EF_calo_tight; + std::vector *m_trig_EF_calo_lhvloose; + std::vector *m_trig_EF_calo_lhloose; + std::vector *m_trig_EF_calo_lhmedium; + std::vector *m_trig_EF_calo_lhtight; + + std::vector *m_trig_tdt_L1_calo_accept; + std::vector *m_trig_tdt_L2_calo_accept; + std::vector *m_trig_tdt_L2_el_accept ; + std::vector *m_trig_tdt_EF_calo_accept; + std::vector *m_trig_tdt_EF_el_accept ; + std::vector *m_trig_tdt_emu_L1_calo_accept; + std::vector *m_trig_tdt_emu_L2_calo_accept; + std::vector *m_trig_tdt_emu_L2_el_accept ; + std::vector *m_trig_tdt_emu_EF_calo_accept; + std::vector *m_trig_tdt_emu_EF_el_accept ; + + + + // Monte Carlo + bool m_mc_hasMC{} ; + float m_mc_pt{} ; + float m_mc_eta{} ; + float m_mc_phi{} ; + bool m_mc_isTop{} ; + bool m_mc_isParton{} ; + bool m_mc_isMeson{} ; + bool m_mc_isQuark{} ; + bool m_mc_isTau{} ; + bool m_mc_isMuon{} ; + bool m_mc_isPhoton{} ; + bool m_mc_isElectron{}; + bool m_mc_hasZMother{}; + bool m_mc_hasWMother{}; + +}; + + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPlotTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPlotTool.h new file mode 100644 index 00000000000..fd45b130a13 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaPlotTool.h @@ -0,0 +1,134 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGEGAMMAANALYSISTOOLS_EGAMMA_H_ +#define TRIGEGAMMAANALYSISTOOLS_EGAMMA_H_ + + +#include "TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h" +#include "AsgTools/AsgTool.h" +#include "TrigHLTMonitoring/IHLTMonTool.h" +class TrigEgammaPlotTool +: public asg::AsgTool, + virtual public ITrigEgammaPlotTool { + ASG_TOOL_CLASS(TrigEgammaPlotTool, ITrigEgammaPlotTool) + + public: + TrigEgammaPlotTool( const std::string& myname); + ~TrigEgammaPlotTool() {}; + + StatusCode initialize(); + StatusCode book(std::map trigInfo); + StatusCode execute(); + StatusCode finalizeShifterHistos(std::map trigInfo); + StatusCode finalize(); + void setParent(IHLTMonTool *parent){ m_parent = parent;}; + void setDetail(bool doDetail){ m_detailedHists = doDetail; } + void setTP(bool tp){ m_tp = tp; } + void setEmulation(bool doEmu){ m_doEmulation = doEmu;} + void setAltBinning(bool doAltBins){ m_doJpsiee = doAltBins; } + std::string getBasePath() { return m_baseDir; } + std::map getTrigInfoMap() { return m_trigInfo; } + // Set current MonGroup + void cd(const std::string &dir); + + // Accessor members + void addDirectory(const std::string &s); + void addHistogram(TH1 *h, const std::string &dir = ""); + void addHistogram(TH2 *h, const std::string &dir = ""); + void addTree(TTree *t, const std::string &dir = ""); + + TH1 *hist1(const std::string &histName, const std::string &dir = ""); + TH2 *hist2(const std::string &histName, const std::string &dir = ""); + TTree *tree(const std::string &treeName, const std::string &dir = ""); + void setLabels(TH1* histo, const std::vector& labels); + + protected: + + private: + // Athena services + StoreGateSvc * m_storeGate; + ITHistSvc* m_histsvc; + IHLTMonTool *m_parent; + + // Infra-structure members + std::string m_file; + std::set m_mongroups; // MonGroups for T0 + std::vector m_dir; // maintain directories + std::map m_hist1; // maintain histograms + std::map m_hist2; // maintain histograms + std::map m_tree; // maintain trees + + // Book-keeping the current mon group + std::string m_currentDir; + std::string m_baseDir; + + // Arrays for bin limits + int m_nEtbins; + int m_nEtabins; + int m_ndefaultEtbins; //2D + int m_ndefaultEtabins; //2D + int m_ncoarseEtbins; //2D + int m_ncoarseEtabins; //2D + std::vector m_etbins; + std::vector m_etabins; + std::vector m_defaultEtbins; + std::vector m_defaultEtabins; + std::vector m_coarseEtbins; + std::vector m_coarseEtabins; + + //Strings for bin labels + std::vector m_label_trigstep; + std::vector m_label_hltobj; + std::vector m_label_hltte; + std::vector m_label_isem; + + //Strings for shifter histograms + std::vector m_effplots; + std::vector m_distplots; + std::vector m_resplots; + + /*! creates map of trigger name and TrigInfo struct */ + std::map m_trigInfo; + /* ************************************************** + * Menu Aware Monitoring Map category to trigger name + * 1-1 mapping of category to trigger name + * **************************************************/ + std::map m_mam; + + // Properties + bool m_doJpsiee; + bool m_detailedHists; + bool m_tp; + bool m_doEmulation; + + // Methods + void setBinning(); + + void copyArrayToVector(std::vector vec,float arr[], int n); + void copyArrayToVector(std::vector vec,double arr[],int n); + bool getCategoryFromTrigger(const std::string,std::string &); + void getHistsFromPath(const std::vector &pattern, const std::vector ¬pattern, std::map &ret); + std::string getPath(const std::string &histName, const std::string &dir = ""); + void bookExpertHistos(TrigInfo); + void bookL1Histos(TrigInfo); + void bookShifterHistos(); + //void bookAnalysisHistos(const std::string dir); + void bookEfficiencyTProfile(const std::string &dir); + void bookEfficiencyHistos(const std::string &dir); + void bookEfficiency2DHistos(const std::string &dir); + void bookEgammaDistributionHistos(const std::string &dir); + void bookElectronDistributionHistos(const std::string &dir); + void bookDistributionHistos(const std::string &dir); + void bookResolutionHistos(const std::string &dir); + void bookElectronResolutionHistos(const std::string &dir); + void bookElectronIsoResolutionHistos(const std::string &dir); + void bookPhotonResolutionHistos(const std::string &dir); + void bookPhotonIsoResolutionHistos(const std::string &dir); + void bookExpertResolutionHistos(const std::string &dir); + void bookExpertL2CaloResolutionHistos(const std::string &dir); + void bookAbsResolutionHistos(const std::string &dir); + }; +#endif + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h index bcde87241e4..112a81a74ca 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TrigEgammaResolutionTool_H @@ -15,24 +15,25 @@ class TrigEgammaResolutionTool public: TrigEgammaResolutionTool( const std::string& myname ); - virtual ~TrigEgammaResolutionTool() {}; - - virtual StatusCode childInitialize() override; - virtual StatusCode childBook() override; - virtual StatusCode childExecute() override; - virtual StatusCode childFinalize() override; - virtual StatusCode toolExecute(const std::string,const TrigInfo,std::vector> pairObjs) override; - virtual void setDetail(bool doDetail) override; - virtual void setTP(bool tp) override; - + ~TrigEgammaResolutionTool() {}; + + StatusCode childInitialize(); + StatusCode childBook(); + StatusCode childExecute(); + StatusCode childFinalize(); + StatusCode toolExecute(const std::string,const TrigInfo,std::vector> pairObjs); + void setDetail(bool doDetail){ m_detailedHists = doDetail; } + void setTP(bool tp){ m_tp = tp; } +protected: private: + void fillL2CaloResolution(const std::string, const xAOD::TrigEMCluster *,const xAOD::Egamma *); void fillHLTResolution(const std::string, const xAOD::Egamma *,const xAOD::Egamma *); void fillIsolationResolution(const std::string, const xAOD::Egamma *,const xAOD::Egamma *); void fillHLTAbsResolution(const std::string, const xAOD::Egamma *,const xAOD::Egamma *); void fillL1CaloResolution(const std::string, const xAOD::EmTauRoI*, const xAOD::Egamma*); void fillL1CaloAbsResolution(const std::string, const xAOD::EmTauRoI*, const xAOD::Egamma*); - + /*! Resolution methods */ void resolutionPhoton(const std::string,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj,bool); void resolutionElectron(const std::string,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj,bool); diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaAnalysisToolsConfig.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaAnalysisToolsConfig.py index 4c87a21086a..d0c27a70144 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaAnalysisToolsConfig.py +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/python/TrigEgammaAnalysisToolsConfig.py @@ -5,7 +5,7 @@ from TrigEgammaAnalysisTools import TrigEgammaAnalysisToolsConf from AthenaCommon import CfgMgr from AthenaCommon.AppMgr import ToolSvc -from egammaRec.Factories import ToolFactory, PublicToolFactory, FcnWrapper, AlgFactory, getPropertyValue +from egammaRec.Factories import PublicToolFactory,FcnWrapper,AlgFactory, getPropertyValue import PyUtils.RootUtils as ru ROOT = ru.import_root() @@ -63,8 +63,8 @@ LuminosityCondAlgOnlineDefault (suffix = 'Online') IneffLabels=["ClusterEtaRange","ConversionMatch","ClusterHadronicLeakage","ClusterMiddleEnergy","ClusterMiddleEratio37","ClusterMiddleEratio33","ClusterMiddleWidth","f3","ClusterStripsEratio","ClusterStripsDeltaEmax2","ClusterStripsDeltaE","ClusterStripsWtot","ClusterStripsFracm","ClusterStripsWeta1c","empty14","ClusterStripsDEmaxs1","TrackBlayer","TrackPixel","TrackSi","TrackA0","TrackMatchEta","TrackMatchPhi","TrackMatchEoverP","TrackTRTeProbabilityHT_Electron","TrackTRThits","TrackTRTratio","TrackTRTratio90","TrackA0Tight","TrackMatchEtaTight","Isolation","ClusterIsolation","TrackIsolation","No Track","No Cluster","No Object"] -from TrigEgammaAnalysisTools.TrigEgammaProbelist import monitoring_mam, monitoring_electron, monitoring_photon -from TrigEgammaAnalysisTools.TrigEgammaProbelist import monitoringTP_electron, monitoringTP_electronZee, monitoringTP_electronJpsiee +from TrigEgammaAnalysisTools.TrigEgammaProbelist import monitoring_mam, monitoring_electron, monitoring_photon +from TrigEgammaAnalysisTools.TrigEgammaProbelist import monitoringTP_electron, monitoringTP_electronZee, monitoringTP_electronJpsiee from TrigEgammaMatchingTool.TrigEgammaMatchingToolConf import Trig__TrigEgammaMatchingTool @@ -72,31 +72,30 @@ EgammaMatchTool = Trig__TrigEgammaMatchingTool() EgammaMatchTool.OutputLevel=2 ToolSvc += EgammaMatchTool -# Not used in Run 3 # Plot Tool sets the base path for histograms of all tools -#TrigEgammaPlotTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaPlotTool, name="TrigEgammaPlotTool", -# DirectoryPath="/HLT/Egamma", -# MaM=monitoring_mam, -# Efficiency=["eff_et","eff_eta","eff_mu"], -# Distribution=["et","eta"], -# Resolution=["res_et","res_eta"], -# OutputLevel=0) - -EfficiencyTool = ToolFactory(TrigEgammaAnalysisToolsConf.EfficiencyTool, +TrigEgammaPlotTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaPlotTool, name="TrigEgammaPlotTool", + DirectoryPath="/HLT/Egamma", + MaM=monitoring_mam, + Efficiency=["eff_et","eff_eta","eff_mu"], + Distribution=["et","eta"], + Resolution=["res_et","res_eta"], + OutputLevel=0) + +EfficiencyTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.EfficiencyTool, name="EfficiencyTool", - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, isEMResultNames=["Tight","Medium","Loose"], LHResultNames=["LHTight","LHMedium","LHLoose"], OutputLevel=0) -ResolutionTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaResolutionTool, +ResolutionTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaResolutionTool, name="ResolutionTool", - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, OutputLevel=0) -DistTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaDistTool, +DistTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaDistTool, name="DistTool", - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, OutputLevel=0) # import emulator egamma trigger tool @@ -110,22 +109,22 @@ DistTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaDistTool, # Build factory -TrigEgammaNavTPAnalysisTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaNavTPAnalysisTool, name = "TrigEgammaNavTPAnalysisTool", +TrigEgammaNavTPAnalysisTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaNavTPAnalysisTool, name = "TrigEgammaNavTPAnalysisTool", Analysis='Zee', ElectronKey = 'Electrons', MatchTool = EgammaMatchTool, - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, #EmulationTool=EmulationTool, Tools=[EfficiencyTool,ResolutionTool,DistTool], isEMResultNames=["Tight","Medium","Loose"], LHResultNames=["LHTight","LHMedium","LHLoose"], ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector], - ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], + ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], ZeeLowerMass=80, ZeeUpperMass=100, - OfflineTagSelector='Tight', # 1=tight, 2=medium, 3=loose - OfflineProbeSelector='Loose', - ForceProbePid=False, + OfflineTagSelector='Tight', # 1=tight, 2=medium, 3=loose + OfflineProbeSelector='Loose', + ForceProbePid=False, OppositeCharge=True, doJpsiee=False, doEmulation=False, @@ -141,23 +140,23 @@ TrigEgammaNavTPAnalysisTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgamma TagLabels=["Electrons","HasTrack","HasCluster","GoodPid","Et","Eta","IsGoodOQ","PassTrigger","MatchTrigger"], ) -TrigEgammaNavTPJpsieeAnalysisTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaNavTPAnalysisTool, +TrigEgammaNavTPJpsieeAnalysisTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaNavTPAnalysisTool, name = "TrigEgammaNavTPJpsieeAnalysisTool", Analysis='Jpsiee', ElectronKey = 'Electrons', MatchTool = EgammaMatchTool, - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, #EmulationTool=EmulationTool, Tools=[EfficiencyTool], isEMResultNames=["Tight","Medium","Loose"], LHResultNames=["LHTight","LHMedium","LHLoose"], ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector], - ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], + ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], ZeeLowerMass=2, ZeeUpperMass=5, - OfflineTagSelector='Tight', # 1=tight, 2=medium, 3=loose - OfflineProbeSelector='Loose', - ForceProbePid=False, + OfflineTagSelector='Tight', # 1=tight, 2=medium, 3=loose + OfflineProbeSelector='Loose', + ForceProbePid=False, OppositeCharge=True, doJpsiee=True, doEmulation=False, @@ -173,15 +172,15 @@ TrigEgammaNavTPJpsieeAnalysisTool = ToolFactory(TrigEgammaAnalysisToolsConf.Trig TagLabels=["Electrons","HasTrack","HasCluster","GoodPid","Et","Eta","PassTrigger","MatchTrigger"], ) -TrigEgammaNavAnalysisTool = ToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaNavAnalysisTool, name ="TrigEgammaNavAnalysisTool", +TrigEgammaNavAnalysisTool = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaNavAnalysisTool, name ="TrigEgammaNavAnalysisTool", Analysis='Analysis', ElectronKey = 'Electrons', MatchTool = EgammaMatchTool, - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, #EmulationTool=EmulationTool, Tools=[EfficiencyTool,ResolutionTool,DistTool], ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector], - ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], + ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], ElectronLHVLooseTool=VeryLooseLHSelector, IsEMLabels=IneffLabels, TriggerList=monitoring_electron + monitoring_photon, @@ -228,13 +227,13 @@ def setRunFlag( runFlag ): print 'Wrong run flag configuration' -# Not used in Run 3 -# # The main algorithm -# # Add triggerlist tools to ToolHandleArray -# TrigEgammaAnalysisAlg = AlgFactory(TrigEgammaAnalysisToolsConf.TrigEgammaAnalysisAlg, -# name='TrigEgammaAnalysisAlg', -# Tools = FcnWrapper(getAllTools), -# ) + +# The main algorithm +# Add triggerlist tools to ToolHandleArray +TrigEgammaAnalysisAlg = AlgFactory(TrigEgammaAnalysisToolsConf.TrigEgammaAnalysisAlg, + name='TrigEgammaAnalysisAlg', + Tools = FcnWrapper(getAllTools), + ) @@ -249,8 +248,8 @@ def getEventSelectionTool(runFlag): getElectronLikelihoodSelectorNoD0 from AthenaCommon import CfgMgr from AthenaCommon.AppMgr import ToolSvc - # create all selector list. Here, the order is matter. Please check the - + # create all selector list. Here, the order is matter. Please check the + setRunFlag(runFlag) if runFlag == '2017': @@ -269,13 +268,13 @@ def getEventSelectionTool(runFlag): else: print 'Wrong run flag configuration' - + # create the event selection tool TrigEgammaEventSelection = PublicToolFactory(TrigEgammaAnalysisToolsConf.TrigEgammaEventSelection, name ="TrigEgammaEventSelection", Analysis='EventsSelection', ElectronKey = 'Electrons', MatchTool = EgammaMatchTool, - #PlotTool=TrigEgammaPlotTool, + PlotTool=TrigEgammaPlotTool, EmulationTool=EmulationTool, # The emulation must be on in this tool. doEmulation=True, Tools=[], @@ -284,9 +283,9 @@ def getEventSelectionTool(runFlag): ElectronLHVLooseTool=VeryLooseLHSelector, ZeeLowerMass=80, ZeeUpperMass=100, - OfflineTagSelector='Tight', # 1=tight, 2=medium, 3=loose - OfflineProbeSelector='Loose', - ForceProbePid=False, + OfflineTagSelector='Tight', # 1=tight, 2=medium, 3=loose + OfflineProbeSelector='Loose', + ForceProbePid=False, OppositeCharge=True, RemoveCrack=False, OfflineTagMinEt=25, @@ -308,11 +307,11 @@ def getEventSelectionTool(runFlag): HLTElectronLikelihoodSelector=HLTLikelihoodSelectorList, HLTElectronIsEMSelector=HLTIsEMSelectorList, ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector], - ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], - + ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector], + ) - - + + # Return the template return TrigEgammaEventSelection diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.cxx new file mode 100644 index 00000000000..5bfd6fa6889 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.cxx @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TrigEgammaAnalysisAlg.cxx + +#include "TrigEgammaAnalysisAlg.h" +#include "GaudiKernel/Property.h" +#include "TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h" +#include "AsgTools/AsgTool.h" + +using std::string; + +//********************************************************************** + +TrigEgammaAnalysisAlg:: +TrigEgammaAnalysisAlg(const std::string& name, + ISvcLocator* pSvcLocator ) +: ::AthAlgorithm( name, pSvcLocator ) { + declareProperty( "Tools", m_asgtools); +} + +//********************************************************************** + +TrigEgammaAnalysisAlg::~TrigEgammaAnalysisAlg() { } + +//********************************************************************** + +StatusCode TrigEgammaAnalysisAlg::initialize() { + StatusCode sc; + ATH_MSG_INFO("Initializing " << name() << "..."); + ATH_MSG_INFO("Retrieving tools..."); + sc = m_asgtools.retrieve(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool retrieval failed."); + } + ATH_MSG_INFO("Tool retrieval completed."); + unsigned int ntool = m_asgtools.size(); + ATH_MSG_INFO(" Tool count: " << ntool); + for ( unsigned int itool=0; itoolname()); + m_asgtools[itool]->print(); + sc = m_asgtools[itool]->book(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool booking failed."); + } + } + ATH_MSG_DEBUG("Initialize complete"); + return StatusCode::SUCCESS; +} + +//********************************************************************** + +StatusCode TrigEgammaAnalysisAlg::finalize() { + ATH_MSG_INFO ("Finalizing " << name() << "..."); + StatusCode sc; + for ( ToolHandleArray::const_iterator itoo=m_asgtools.begin(); + itoo!=m_asgtools.end(); ++itoo ) { + ToolHandle htool = *itoo; + sc = htool->finalize(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool finalize failed."); + } + } + return StatusCode::SUCCESS; +} + +//********************************************************************** + +StatusCode TrigEgammaAnalysisAlg::execute() { + ATH_MSG_DEBUG ("Executing " << name() << "..."); + // Loop over hello tools. + ATH_MSG_DEBUG("Looping over ASG tools."); + string line = "---------------------------------------------------"; + ATH_MSG_DEBUG(line); + StatusCode sc; + for ( ToolHandleArray::const_iterator itoo=m_asgtools.begin(); + itoo!=m_asgtools.end(); ++itoo ) { + ToolHandle htool = *itoo; + sc = htool->execute(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool execute failed."); + } + ATH_MSG_INFO(line); + } + return StatusCode::SUCCESS; +} + +//********************************************************************** diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.h new file mode 100644 index 00000000000..f50ac2d152c --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaAnalysisAlg.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TrigEgammaAnalysisAlg.h + +#ifndef TrigEgammaAnalysisAlg_H +#define TrigEgammaAnalysisAlg_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" + +class ITrigEgammaAnalysisBaseTool; +class IExecuteTool; + +class TrigEgammaAnalysisAlg : public AthAlgorithm { + +public: + + /// Constructor with parameters: + TrigEgammaAnalysisAlg(const std::string& name, ISvcLocator* pSvcLocator); + + /// Destructor: + ~TrigEgammaAnalysisAlg(); + + /// Athena algorithm's Hooks + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + +private: + + /// Default constructor: + TrigEgammaAnalysisAlg(); + +private: + + /// Athena configured tools + ToolHandleArray< ITrigEgammaAnalysisBaseTool > m_asgtools; + +}; + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx new file mode 100644 index 00000000000..84c3551dfeb --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx @@ -0,0 +1,98 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/********************************************************************** + * IHLTMonTool: TrigEgammaMonTool + * Author: + * Ryan Mackenzie White + * Date: May 2015 + * Description: + * Generic HLTMonBase tool class for trigger egamma analysis. + * Inherits from IHLTMonTool and provides the wrapper + * for the base analysis class to run at T0. + * All analysis classes derive the original base class + **********************************************************************/ +#include "TrigEgammaMonTool.h" +#include "AthenaMonitoring/AthenaMonManager.h" +#include "AthenaMonitoring/ManagedMonitorToolTest.h" +#include "TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h" +#include "AsgTools/AsgTool.h" + +TrigEgammaMonTool:: +TrigEgammaMonTool( const std::string & type, const std::string & name, const IInterface* parent) + :IHLTMonTool(type, name, parent) +{ + declareProperty( "Tools", m_asgToolNames); +} + +TrigEgammaMonTool::~TrigEgammaMonTool(){} + + +StatusCode TrigEgammaMonTool::init(){ + return StatusCode::SUCCESS; +} + +StatusCode TrigEgammaMonTool::book(){ + ATH_MSG_INFO("Initializing " << name() << "..."); + ATH_MSG_INFO("Retrieving tools..." << m_asgToolNames.size()); + + for(const auto toolname : m_asgToolNames){ + ATH_MSG_INFO("Add "<(toolname)); + } + for ( ToolHandleArray::const_iterator itoo=m_asgtools.begin(); + itoo!=m_asgtools.end(); ++itoo ) { + ATH_MSG_INFO("Initializing..." ); + ToolHandle htool = *itoo; + htool->setParent(this); + StatusCode sc = htool->initialize(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool retrieval failed:" << htool); + return StatusCode::FAILURE; + } + sc = htool->book(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool book failed:" << htool); + return StatusCode::FAILURE; + } + } + + ATH_MSG_INFO("Tool retrieval completed."); + return StatusCode::SUCCESS; +} + +StatusCode TrigEgammaMonTool::fill(){ + ATH_MSG_DEBUG ("Executing " << name() << "..."); + // Loop over hello tools. + ATH_MSG_DEBUG("Looping over ASG tools."); + std::string line = "---------------------------------------------------"; + ATH_MSG_DEBUG(line); + for ( ToolHandleArray::const_iterator itoo=m_asgtools.begin(); + itoo!=m_asgtools.end(); ++itoo ) { + ToolHandle htool = *itoo; + StatusCode sc = htool->execute(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool execute failed."); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG(line); + } + return StatusCode::SUCCESS; +} + +StatusCode TrigEgammaMonTool::proc(){ + // Finalize the efficiency for end of run + if(!endOfRunFlag()){ return(StatusCode::SUCCESS); } + ATH_MSG_INFO ("Finalizing " << name() << "..."); + for ( ToolHandleArray::const_iterator itoo=m_asgtools.begin(); + itoo!=m_asgtools.end(); ++itoo ) { + ToolHandle htool = *itoo; + StatusCode sc = htool->finalize(); + if ( ! sc.isSuccess() ) { + ATH_MSG_ERROR("Tool finalize failed."); + return StatusCode::FAILURE; + } + } + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.h new file mode 100644 index 00000000000..3497aeac04b --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef __TRIGEGAMMAMONTOOL_H +#define __TRIGEGAMMAMONTOOL_H +#include "TrigHLTMonitoring/IHLTMonTool.h" +class ITrigEgammaAnalysisBaseTool; +class TrigEgammaMonTool : public IHLTMonTool { + + public: + TrigEgammaMonTool( const std::string & type, const std::string & name, const IInterface* parent); + virtual ~TrigEgammaMonTool(); + virtual StatusCode init(); + virtual StatusCode book(); + virtual StatusCode fill(); + virtual StatusCode proc(); + private: + ToolHandleArray< ITrigEgammaAnalysisBaseTool > m_asgtools; + std::vector m_asgToolNames; + protected: + +}; +#endif //__TRIGEGAMMAANALYSIST0BASETOOL_H + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.cxx new file mode 100644 index 00000000000..d3aee65b2ce --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.cxx @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/********************************************************************** + * TrigEgammaMonTool:TrigEgammaPhysValMonTool + * Author: + * Ryan Mackenzie White + * Date: May 2015 + * Description: + * Wrapper class for PhysValMon framework + **********************************************************************/ +#include "TrigEgammaPhysValMonTool.h" + +TrigEgammaPhysValMonTool:: +TrigEgammaPhysValMonTool( const std::string & type, const std::string & name, const IInterface* parent) + :TrigEgammaMonTool(type, name, parent) +{ +} + +TrigEgammaPhysValMonTool::~TrigEgammaPhysValMonTool(){} + +StatusCode TrigEgammaPhysValMonTool::initialize(){ + StatusCode sc = TrigEgammaMonTool::initialize(); + return sc; +} + +StatusCode TrigEgammaPhysValMonTool::bookHistograms(){ + StatusCode sc = TrigEgammaMonTool::book(); + return sc; +} + +StatusCode TrigEgammaPhysValMonTool::fillHistograms(){ + StatusCode sc = TrigEgammaMonTool::fill(); + return sc; +} + +StatusCode TrigEgammaPhysValMonTool::procHistograms(){ + StatusCode sc = TrigEgammaMonTool::proc(); + return sc; +} + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.h new file mode 100644 index 00000000000..b59010ac700 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaPhysValMonTool.h @@ -0,0 +1,19 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef __TRIGEGAMMAPHYSVALMONTOOL_H +#define __TRIGEGAMMAPHYSVALMONTOOL_H + +#include "TrigEgammaMonTool.h" +class TrigEgammaPhysValMonTool: public TrigEgammaMonTool { + public: + TrigEgammaPhysValMonTool( const std::string & type, const std::string & name, const IInterface* parent); + virtual ~TrigEgammaPhysValMonTool(); + virtual StatusCode initialize(); + virtual StatusCode bookHistograms(); + virtual StatusCode fillHistograms(); + virtual StatusCode procHistograms(); + +}; +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.cxx new file mode 100644 index 00000000000..238827bf56a --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.cxx @@ -0,0 +1,131 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TrigEgammaTDToolTest.cxx + +#include "TrigEgammaTDToolTest.h" +#include "GaudiKernel/Property.h" +#include "xAODEgamma/ElectronContainer.h" +#include "xAODEgamma/PhotonContainer.h" +using std::string; + +//********************************************************************** + +TrigEgammaTDToolTest:: +TrigEgammaTDToolTest(const std::string& name, + ISvcLocator* pSvcLocator ) +: ::AthAlgorithm( name, pSvcLocator ), + m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool") +{ + declareProperty("TrigEgammaMatchingTool",m_matchTool); +} + +//********************************************************************** + +TrigEgammaTDToolTest::~TrigEgammaTDToolTest() { } + +//********************************************************************** + +StatusCode TrigEgammaTDToolTest::initialize() { + ATH_MSG_INFO("Initializing " << name() << "..."); + ATH_MSG_INFO("Retrieving tools..."); + if ( (m_trigdec.retrieve()).isFailure() ){ + ATH_MSG_ERROR("Could not retrieve Trigger Decision Tool! Can't work"); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} + +//********************************************************************** + +StatusCode TrigEgammaTDToolTest::finalize() { + ATH_MSG_INFO ("Finalizing " << name() << "..."); + for (auto iter = m_counterBits.begin(); iter != m_counterBits.end(); iter++) { + ATH_MSG_INFO(iter->first << " == " << iter->second); + } + + return StatusCode::SUCCESS; +} + +//********************************************************************** + +StatusCode TrigEgammaTDToolTest::execute() { + ATH_MSG_INFO ("Executing " << name() << "..."); + ATH_MSG_INFO( "L1: " << m_trigdec->isPassed( "L1_.*" ) + << ", L2: " << m_trigdec->isPassed( "L2_.*" ) + << ", EF: " << m_trigdec->isPassed( "EF_.*" ) + << ", HLT: " << m_trigdec->isPassed( "HLT_.*" ) ); + auto chainGroups = m_trigdec->getChainGroup("HLT_e.*"); + + for(auto &trig : chainGroups->getListOfTriggers()) { + if(m_trigdec->isPassed(trig)) + ATH_MSG_INFO("Passed: " << trig); + m_counterBits[trig]+=m_trigdec->isPassed(trig); + + } + + //Check Containers + + const xAOD::ElectronContainer *offElectrons = 0; + const xAOD::ElectronContainer *onlElectrons = 0; + if ( (evtStore()->retrieve(offElectrons,"Electrons")).isFailure() ){ + ATH_MSG_ERROR("Failed to retrieve offline Electrons "); + } + ATH_MSG_INFO("Offline Electron container size " << offElectrons->size()); + for(const auto& eg : *offElectrons){ + if (eg) { + ATH_MSG_INFO(" REGTEST: egamma energy: " << eg->e()); + ATH_MSG_INFO(" REGTEST: egamma eta: " << eg->eta() ); + ATH_MSG_INFO(" REGTEST: egamma phi: " << eg->phi() ); + for(auto &trig : chainGroups->getListOfTriggers()){ + trig.erase(0,4); + if(m_matchTool->match(eg,trig)) ATH_MSG_DEBUG("REGTEST:: Matched Electron with tool for " << trig); + } + + } else{ + ATH_MSG_INFO(" REGTEST: problems with egamma pointer"); + } + if(eg->trackParticle()){ + ATH_MSG_INFO(" REGTEST: pt= " << eg->trackParticle()->pt()); + ATH_MSG_INFO(" REGTEST: charge= " << eg->trackParticle()->charge()) ; + ATH_MSG_INFO(" REGTEST: eta= " << eg->trackParticle()->eta()); + ATH_MSG_INFO(" REGTEST: phi= " << eg->trackParticle()->phi()) ; + } + if(eg->caloCluster()){ + ATH_MSG_INFO(" REGTEST: et= " << eg->caloCluster()->et()); + ATH_MSG_INFO(" REGTEST: eta= " << eg->caloCluster()->eta()); + ATH_MSG_INFO(" REGTEST: phi= " << eg->caloCluster()->phi()) ; + } + else ATH_MSG_INFO("No caloCluster"); + } + if ( (evtStore()->retrieve(onlElectrons,"HLT_xAOD__ElectronContainer_egamma_Electrons")).isFailure() ){ + ATH_MSG_ERROR("Failed to retrieve offline Electrons "); + } + ATH_MSG_INFO("Online Electron container size " << onlElectrons->size()); + for(const auto& eg : *onlElectrons){ + if (eg) { + ATH_MSG_INFO(" REGTEST: egamma energy: " << eg->e()); + ATH_MSG_INFO(" REGTEST: egamma eta: " << eg->eta() ); + ATH_MSG_INFO(" REGTEST: egamma phi: " << eg->phi() ); + + } else{ + ATH_MSG_INFO(" REGTEST: problems with egamma pointer"); + } + if(eg->trackParticle()){ + ATH_MSG_INFO(" REGTEST: pt= " << eg->trackParticle()->pt()); + ATH_MSG_INFO(" REGTEST: charge= " << eg->trackParticle()->charge()) ; + ATH_MSG_INFO(" REGTEST: eta= " << eg->trackParticle()->eta()); + ATH_MSG_INFO(" REGTEST: phi= " << eg->trackParticle()->phi() ); + } + if(eg->caloCluster()){ + ATH_MSG_INFO(" REGTEST: et= " << eg->caloCluster()->et()); + ATH_MSG_INFO(" REGTEST: eta= " << eg->caloCluster()->eta()); + ATH_MSG_INFO(" REGTEST: phi= " << eg->caloCluster()->phi()) ; + } + else ATH_MSG_INFO("No caloCluster"); + } + return StatusCode::SUCCESS; +} + +//********************************************************************** diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.h new file mode 100644 index 00000000000..0b888d77ced --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaTDToolTest.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +// TrigEgammaTDToolTest.h + +#ifndef TrigEgammaTDToolTest_H +#define TrigEgammaTDToolTest_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" + +#include "TrigDecisionTool/TrigDecisionTool.h" +#include "TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h" +class IExecuteTool; + +class TrigEgammaTDToolTest : public AthAlgorithm { + +public: + + /// Constructor with parameters: + TrigEgammaTDToolTest(const std::string& name, ISvcLocator* pSvcLocator); + + /// Destructor: + ~TrigEgammaTDToolTest(); + + /// Athena algorithm's Hooks + StatusCode initialize(); + StatusCode execute(); + StatusCode finalize(); + +private: + + /// Default constructor: + TrigEgammaTDToolTest(); + +private: + ToolHandle m_trigdec; + ToolHandle m_matchTool; + std::map m_counterBits; +}; + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/components/TrigEgammaAnalysisTools_entries.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/components/TrigEgammaAnalysisTools_entries.cxx index 07de3e95b6f..ce69fbe9a86 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/components/TrigEgammaAnalysisTools_entries.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/components/TrigEgammaAnalysisTools_entries.cxx @@ -1,11 +1,30 @@ +#include "TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h" +#include "../TrigEgammaMonTool.h" +#include "../TrigEgammaPhysValMonTool.h" +#include "TrigEgammaAnalysisTools/TrigEgammaNavBaseTool.h" #include "TrigEgammaAnalysisTools/TrigEgammaNavAnalysisTool.h" +#include "TrigEgammaAnalysisTools/TrigEgammaNavTPBaseTool.h" #include "TrigEgammaAnalysisTools/TrigEgammaNavTPAnalysisTool.h" #include "TrigEgammaAnalysisTools/EfficiencyTool.h" #include "TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h" #include "TrigEgammaAnalysisTools/TrigEgammaDistTool.h" +#include "TrigEgammaAnalysisTools/TrigEgammaPlotTool.h" +#include "TrigEgammaAnalysisTools/TrigEgammaEventSelection.h" +#include "../TrigEgammaAnalysisAlg.h" +#include "../TrigEgammaTDToolTest.h" +DECLARE_COMPONENT(TrigEgammaAnalysisBaseTool) +DECLARE_COMPONENT(TrigEgammaMonTool) +DECLARE_COMPONENT(TrigEgammaPhysValMonTool) +DECLARE_COMPONENT(TrigEgammaNavTPBaseTool) DECLARE_COMPONENT(TrigEgammaNavAnalysisTool) +DECLARE_COMPONENT(TrigEgammaNavBaseTool) DECLARE_COMPONENT(TrigEgammaNavTPAnalysisTool) -DECLARE_COMPONENT(EfficiencyTool) -DECLARE_COMPONENT(TrigEgammaResolutionTool) -DECLARE_COMPONENT(TrigEgammaDistTool) +DECLARE_COMPONENT(EfficiencyTool) +DECLARE_COMPONENT(TrigEgammaResolutionTool) +DECLARE_COMPONENT(TrigEgammaDistTool) +DECLARE_COMPONENT(TrigEgammaPlotTool) +DECLARE_COMPONENT(TrigEgammaEventSelection) +DECLARE_COMPONENT(TrigEgammaAnalysisAlg) +DECLARE_COMPONENT(TrigEgammaTDToolTest) + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt b/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt index 8b8725a8de2..58e8ad85552 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt @@ -11,12 +11,15 @@ atlas_depends_on_subdirs( PUBLIC Trigger/TrigEvent/TrigInDetEvent Trigger/TrigEvent/TrigParticle Trigger/TrigEvent/TrigSteeringEvent - Trigger/TrigAnalysis/TrigEgammaAnalysisTools - Control/AthenaMonitoring ) + Control/AthenaMonitoring ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread MathMore Minuit Minuit2 Matrix Physics HistPainter Rint Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 ) atlas_add_component( TrigEgammaMonitoring src/*.cxx src/components/*.cxx - LINK_LIBRARIES TrigEgammaAnalysisToolsLib GaudiKernel AthenaMonitoringLib ) + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel AthenaMonitoringLib ) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py index 1824602157d..012d39ed54a 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py @@ -18,12 +18,6 @@ from TrigEgammaMonitoring.TrigEgammaMonitoringConfigRun3 import TrigEgammaMonToo def TrigEgammaMonConfig(inputFlags): '''Function to configures some algorithms in the monitoring system.''' - ### STEP 1 ### - # Define one top-level monitoring algorithm. The new configuration - # framework uses a component accumulator. - from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator - result = ComponentAccumulator() - # The following class will make a sequence, configure algorithms, and link # them to GenericMonitoringTools from AthenaMonitoring import AthMonitorCfgHelper @@ -35,21 +29,12 @@ def TrigEgammaMonConfig(inputFlags): montoolCfg.bookHistograms(histogramsRoot, helper) - from AthenaCommon.AppMgr import ToolSvc - - result.addService(ToolSvc) - ### STEP 6 ### # Finalize. The return value should be a tuple of the ComponentAccumulator # and the sequence containing the created algorithms. If we haven't called - # any configuration other than the AthMonitorCfgHelper here, then we can + # any configuration other than the AthMonitorCfgHelper here, then we can # just return directly (and not create "result" above) - #return helper.result() - - # # Otherwise, merge with result object and return - acc = helper.result() - result.merge(acc) - return result - + return helper.result() + if __name__=='__main__': # Setup the Run III behavior from AthenaCommon.Configurable import Configurable @@ -67,11 +52,11 @@ if __name__=='__main__': ConfigFlags.Input.Files = [nightly+file] ConfigFlags.Input.isMC = False ConfigFlags.Output.HISTFileName = 'TrigEgammaMonitorOutput.root' - + ConfigFlags.lock() # Initialize configuration object, add accumulator, merge, and run. - from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg + from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg cfg = MainServicesSerialCfg() cfg.merge(PoolReadCfg(ConfigFlags)) diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfig.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfig.py index 968fba47feb..0df7c6c23d0 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfig.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfig.py @@ -31,11 +31,11 @@ log_trigeg = logging.getLogger( 'TrigEgammaMonitoringConfig' ) from AthenaCommon.Constants import VERBOSE, DEBUG, INFO, ERROR from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConfig import TrigEgammaNavAnalysisTool,TrigEgammaNavTPAnalysisTool,TrigEgammaNavTPJpsieeAnalysisTool -from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConfig import EfficiencyTool, ResolutionTool, DistTool #, TrigEgammaPlotTool -#from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConf import TrigEgammaMonTool +from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConfig import EfficiencyTool, ResolutionTool, DistTool, TrigEgammaPlotTool +from TrigEgammaAnalysisTools.TrigEgammaAnalysisToolsConf import TrigEgammaMonTool -# Move the ProbeList into MonitCategory to keep all configuration in TrigEgammaMonitoring -from TrigEgammaMonitoring.TrigEgammaMonitCategory import * +# Move the ProbeList into MonitCategory to keep all configuration in TrigEgammaMonitoring +from TrigEgammaMonitoring.TrigEgammaMonitCategory import * if not 'DQMonFlags' in dir(): from AthenaMonitoring.DQMonFlags import DQMonFlags as dqflags @@ -45,7 +45,7 @@ if not 'DQMonFlags' in dir(): class TrigEgammaMonToolBuilder: _configured = False _get_monitoring_mode_success = False - + pp_mode = False pPb_mode = False HI_mode = False @@ -56,7 +56,7 @@ class TrigEgammaMonToolBuilder: basePath = 'HLT/Egamma' debugLevel = INFO detailLevel = False - + # Add a flag to enable emulation __acceptable_keys_list=['derivation','emulation'] emulation = False @@ -64,13 +64,13 @@ class TrigEgammaMonToolBuilder: tagItems = [] JpsitagItems = [] - + electronList = [] photonList = [] tpList = [] jpsiList = [] mam = {} - + monTool=[] def __init__(self,**kwargs): @@ -86,7 +86,7 @@ class TrigEgammaMonToolBuilder: self.config() print('monTool') print(self.monTool) - + def config(self): log_trigeg.info("TrigEgammaMonToolBuilder.config()") self._get_monitoring_mode_success = self.get_monitoring_mode() @@ -103,10 +103,10 @@ class TrigEgammaMonToolBuilder: def get_monitoring_mode(self): log_trigeg.info("TrigEgammaMonToolBuilder.get_monitoring_mode()") self.data_type = dqflags.monManDataType() - if self.data_type == 'monteCarlo': + if self.data_type == 'monteCarlo': self.mc_mode = True return True - elif self.data_type == 'collisions': + elif self.data_type == 'collisions': self.pp_mode = True return True elif self.data_type == 'heavyioncollisions': @@ -123,8 +123,8 @@ class TrigEgammaMonToolBuilder: log_trigeg.info("TrigEgammaMonToolBuilder.setProperties()") self.basePath = 'HLT/Egamma' self.debug = INFO - self.tagItems = monitoring_tags - self.JpsitagItems = monitoring_jpsitags + self.tagItems = monitoring_tags + self.JpsitagItems = monitoring_jpsitags if self.pp_mode == True: self.setDefaultProperties() elif self.cosmic_mode == True: @@ -159,13 +159,13 @@ class TrigEgammaMonToolBuilder: def configureElectronMonTool(self,plotTool,toolList): log_trigeg.info("TrigEgammaMonToolBuilder.configureElectronMonTool()") - #from AthenaCommon.AppMgr import ToolSvc - #ToolSvc += plotTool() - #for t in toolList: - # ToolSvc += t() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += plotTool() + for t in toolList: + ToolSvc += t() ElectronAnalysis = TrigEgammaNavAnalysisTool(name='HLTEgammaElectronAnalysis', Analysis='Electrons', - #PlotTool=plotTool, + PlotTool=plotTool, Tools=toolList, TriggerList=self.electronList, ForceProbeIsolation=True, @@ -173,27 +173,22 @@ class TrigEgammaMonToolBuilder: File="", OutputLevel=self.debugLevel,DetailedHistograms=self.detailLevel) - return [ ElectronAnalysis ] - def configurePhotonMonTool(self,plotTool,toolList): PhotonAnalysis = TrigEgammaNavAnalysisTool(name='HLTEgammaPhotonAnalysis', Analysis='Photons', - #PlotTool=plotTool, + PlotTool=plotTool, Tools=toolList, TriggerList=self.photonList, File="", OutputLevel=self.debugLevel,DetailedHistograms=self.detailLevel) - return [ PhotonAnalysis ] - - - def configureTPMonTool(self,plotTool,toolList): + def configureTPMonTool(self,plotTool,toolList): if self.emulation == True: from TrigEgammaEmulationTool.TrigEgammaEmulationToolConfig import TrigEgammaEmulationTool HLTEgammaEmulationTool=TrigEgammaEmulationTool.copy(name="TrigEgammaEmulationTool",TriggerList=self.tpList) TPAnalysis = TrigEgammaNavTPAnalysisTool(name='HLTEgammaTPAnalysis', Analysis='Zee', - #PlotTool=plotTool, + PlotTool=plotTool, EmulationTool=HLTEgammaEmulationTool, doEmulation=True, Tools=toolList, @@ -206,7 +201,7 @@ class TrigEgammaMonToolBuilder: else: TPAnalysis = TrigEgammaNavTPAnalysisTool(name='HLTEgammaTPAnalysis', Analysis='Zee', - #PlotTool=plotTool, + PlotTool=plotTool, Tools=toolList, TriggerList=self.tpList, DefaultProbePid="LHMedium", @@ -216,111 +211,90 @@ class TrigEgammaMonToolBuilder: TagTriggerList=self.tagItems, RemoveCrack=False, OutputLevel=self.debugLevel,DetailedHistograms=self.detailLevel) - - return [ TPAnalysis ] - - def configureJpsiMonTool(self,plotTool,toolList): + + def configureJpsiMonTool(self,plotTool,toolList): JpsiTPAnalysis = TrigEgammaNavTPJpsieeAnalysisTool(name='HLTEgammaTPJpsieeAnalysis', Analysis='Jpsiee', - #PlotTool=plotTool, + PlotTool=plotTool, Tools=toolList, TriggerList=self.jpsiList, File="", OfflineTagSelector='LHTight', #OfflineProbeSelector='LHMedium', TagTriggerList= self.JpsitagItems) - - return [ JpsiTPAnalysis ] - - - def configureAllMonTools(self,plotTool,toolList): - res = [] - res += self.configureElectronMonTool(plotTool,toolList) - res += self.configurePhotonMonTool(plotTool,toolList) - res += self.configureTPMonTool(plotTool,toolList) - res += self.configureJpsiMonTool(plotTool,toolList) - - return res - + def configureAllMonTools(self,plotTool,toolList): + self.configureElectronMonTool(plotTool,toolList) + self.configurePhotonMonTool(plotTool,toolList) + self.configureTPMonTool(plotTool,toolList) + self.configureJpsiMonTool(plotTool,toolList) + def configureTools(self): - HLTEgammaPlotTool = None - # Not used in Run 3 - #TrigEgammaPlotTool.copy(name="HLTEgammaPlotTool", - # DirectoryPath=self.basePath, - # MaM=self.mam, - # Efficiency=plots_efficiency, - # Distribution=plots_distribution, - # Resolution=plots_resolution, - # OutputLevel=self.debugLevel) - - HLTEgammaEffTool = EfficiencyTool.copy(name="HLTEgammaEffTool", - #PlotTool=HLTEgammaPlotTool, - OutputLevel=self.debugLevel) - HLTEgammaResTool = ResolutionTool.copy(name="HLTEgammaResTool", - #PlotTool=HLTEgammaPlotTool, - OutputLevel=self.debugLevel) - HLTEgammaDistTool = DistTool.copy(name="HLTEgammaDistTool", - #PlotTool=HLTEgammaPlotTool, - OutputLevel=self.debugLevel) - + HLTEgammaPlotTool = TrigEgammaPlotTool.copy(name="HLTEgammaPlotTool", + DirectoryPath=self.basePath, + MaM=self.mam, + Efficiency=plots_efficiency, + Distribution=plots_distribution, + Resolution=plots_resolution, + OutputLevel=self.debugLevel) + + HLTEgammaEffTool = EfficiencyTool.copy(name="HLTEgammaEffTool",PlotTool=HLTEgammaPlotTool,OutputLevel=self.debugLevel) + HLTEgammaResTool = ResolutionTool.copy(name="HLTEgammaResTool",PlotTool=HLTEgammaPlotTool,OutputLevel=self.debugLevel) + HLTEgammaDistTool = DistTool.copy(name="HLTEgammaDistTool",PlotTool=HLTEgammaPlotTool,OutputLevel=self.debugLevel) + toolList = [HLTEgammaEffTool,HLTEgammaResTool,HLTEgammaDistTool] # For MaM, most important is the list of triggers to monitor # Use the MaM categories from those lists - - # Since we load the tools by name below - # Need to ensure the correct tools are configured + + # Since we load the tools by name below + # Need to ensure the correct tools are configured # for each monitoring mode - res = [] if self.mc_mode == True or self.pp_mode == True: if(self.derivation == True or self.emulation == True): - res += self.configureTPMonTool(HLTEgammaPlotTool,toolList) + self.configureTPMonTool(HLTEgammaPlotTool,toolList) else: - res += self.configureAllMonTools(HLTEgammaPlotTool,toolList) + self.configureAllMonTools(HLTEgammaPlotTool,toolList) elif self.HI_mode == True or self.pPb_mode == True or self.cosmic_mode == True: - res += self.configureElectronMonTool(HLTEgammaPlotTool,toolList) - res += self.configurePhotonMonTool(HLTEgammaPlotTool,toolList) + self.configureElectronMonTool(HLTEgammaPlotTool,toolList) + self.configurePhotonMonTool(HLTEgammaPlotTool,toolList) else: - res += self.configureAllMonTools(HLTEgammaPlotTool,toolList) - - return res - - # Not used in Run3 - #def configureDefaultMonTool(self): - # log_trigeg.info("Default configuration of HLTEgammaMon") - # tool = TrigEgammaMonTool( name = "HLTEgammaMon", - # histoPathBase=self.basePath, - # IgnoreTruncationCheck=True, - # Tools=[ "TrigEgammaNavAnalysisTool/HLTEgammaPhotonAnalysis", - # "TrigEgammaNavAnalysisTool/HLTEgammaElectronAnalysis", - # "TrigEgammaNavTPAnalysisTool/HLTEgammaTPAnalysis", - # "TrigEgammaNavTPAnalysisTool/HLTEgammaTPJpsieeAnalysis"]) - # return tool - - # Not used in Run3 - #def configureMonTool(self): - # from AthenaCommon.AppMgr import ToolSvc - # toolList=['TrigEgammaMonTool/HLTEgammaMon']; - # if self.mc_mode == True or self.pp_mode == True: - # if(self.derivation == True or self.emulation==True): - # tool = TrigEgammaMonTool( name = "HLTEgammaMon", - # histoPathBase=self.basePath, - # IgnoreTruncationCheck=True, - # Tools=["TrigEgammaNavTPAnalysisTool/HLTEgammaTPAnalysis"]) - # else: - # tool = self.configureDefaultMonTool() - # elif self.HI_mode == True or self.pPb_mode == True: - # tool = TrigEgammaMonTool( name = "HLTEgammaMon", - # histoPathBase=self.basePath, - # IgnoreTruncationCheck=True, - # Tools=["TrigEgammaNavAnalysisTool/HLTEgammaPhotonAnalysis", - # "TrigEgammaNavAnalysisTool/HLTEgammaElectronAnalysis"]) - # elif self.cosmic_mode == True: - # tool = TrigEgammaMonTool( name = "HLTEgammaMon", - # histoPathBase=self.basePath, - # IgnoreTruncationCheck=True, - # Tools=["TrigEgammaNavAnalysisTool/HLTEgammaPhotonAnalysis", - # "TrigEgammaNavAnalysisTool/HLTEgammaElectronAnalysis"]) - # else: - # tool = self.configureDefaultMonTool() - # - # return [tool] + self.configureAllMonTools(HLTEgammaPlotTool,toolList) + + + def configureDefaultMonTool(self): + log_trigeg.info("Default configuration of HLTEgammaMon") + tool = TrigEgammaMonTool( name = "HLTEgammaMon", + histoPathBase=self.basePath, + IgnoreTruncationCheck=True, + Tools=[ "TrigEgammaNavAnalysisTool/HLTEgammaPhotonAnalysis", + "TrigEgammaNavAnalysisTool/HLTEgammaElectronAnalysis", + "TrigEgammaNavTPAnalysisTool/HLTEgammaTPAnalysis", + "TrigEgammaNavTPAnalysisTool/HLTEgammaTPJpsieeAnalysis"]) + return tool + + def configureMonTool(self): + from AthenaCommon.AppMgr import ToolSvc + toolList=['TrigEgammaMonTool/HLTEgammaMon']; + if self.mc_mode == True or self.pp_mode == True: + if(self.derivation == True or self.emulation==True): + tool = TrigEgammaMonTool( name = "HLTEgammaMon", + histoPathBase=self.basePath, + IgnoreTruncationCheck=True, + Tools=["TrigEgammaNavTPAnalysisTool/HLTEgammaTPAnalysis"]) + else: + tool = self.configureDefaultMonTool() + elif self.HI_mode == True or self.pPb_mode == True: + tool = TrigEgammaMonTool( name = "HLTEgammaMon", + histoPathBase=self.basePath, + IgnoreTruncationCheck=True, + Tools=["TrigEgammaNavAnalysisTool/HLTEgammaPhotonAnalysis", + "TrigEgammaNavAnalysisTool/HLTEgammaElectronAnalysis"]) + elif self.cosmic_mode == True: + tool = TrigEgammaMonTool( name = "HLTEgammaMon", + histoPathBase=self.basePath, + IgnoreTruncationCheck=True, + Tools=["TrigEgammaNavAnalysisTool/HLTEgammaPhotonAnalysis", + "TrigEgammaNavAnalysisTool/HLTEgammaElectronAnalysis"]) + else: + tool = self.configureDefaultMonTool() + + return [tool] diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfigRun3.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfigRun3.py index 2a76d796419..469953c4869 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfigRun3.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringConfigRun3.py @@ -12,7 +12,7 @@ log_trigeg = logging.getLogger( 'TrigEgammaMonitoringConfigRun3' ) from TrigEgammaMonitoring.TrigEgammaMonitoringConfig import TrigEgammaMonToolBuilder -from TrigEgammaMonitoring.TrigEgammaMonitoringHistDefs import TH1F, TH1I, TProfile, TH2F, TProfile2D +from TrigEgammaMonitoring.TrigEgammaMonitoringHistDefs import TH1F, TProfile, TH2F, TProfile2D class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): _parent_attrs = [ @@ -137,9 +137,6 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): log_trigeg.info('TrigEgammaMonToolBuilderRun3.__init__') def config(self): - """Override TrigEgammaMonToolBuilder.config retrieve only configuration flags - and do not create old tools instances. - """ log_trigeg.info('TrigEgammaMonToolBuilderRun3.config') self._get_monitoring_mode_success = self.get_monitoring_mode() #print self._get_monitoring_mode_success @@ -208,7 +205,6 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): def bookHistograms(self, histogramsRoot, helper): self._setBinning() - self.debugLevel = 2 # DEBUG for triggerChain in self.tagItems: self.defineExpertHistograms(histogramsRoot, helper, 'ExpertTrigEgammaMonAlg', triggerChain) @@ -219,12 +215,7 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): for triggerChain in self.photonList: self.defineExpertHistograms(histogramsRoot, helper, 'ExpertTrigEgammaMonAlg', triggerChain) - #self.defineExpertEventHistograms(histogramsRoot, helper, 'ExpertTrigEgammaMonAlg') - def defineExpertHistograms(self, rootpath, helper, algnameprefix, triggerChain): - """ - Defines algorithm instance for trigger chain-specific monitoring - """ ### STEP 2 ### # Adding an algorithm to the helper. Here, we will use the example @@ -241,22 +232,9 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): # some generic property # trigEgammaMonAlg.RandomHist = True # to enable a trigger filter, for example: - #trigEgammaMonAlg.TriggerChain = triggerChain #!! Temporary skip TriggerChain setup + trigEgammaMonAlg.TriggerChain = triggerChain trigEgammaMonAlg.OutputLevel = 2 # DEBUG - ### STEP 4 ### - # Add some tools. N.B. Do not use your own trigger decision tool. Use the - # standard one that is included with AthMonitorAlgorithm. - - # # First, add a tool that's set up by a different configuration function. - # # In this case, CaloNoiseToolCfg returns its own component accumulator, - # # which must be merged with the one from this function. - # from CaloTools.CaloNoiseToolConfig import CaloNoiseToolCfg - # caloNoiseAcc, caloNoiseTool = CaloNoiseToolCfg(inputFlags) - # result.merge(caloNoiseAcc) - # trigEgammaMonAlg.CaloNoiseTool = caloNoiseTool - - trigEgammaMonAlg.Tools = self.configureTools() # # Then, add a tool that doesn't have its own configuration function. In # # this example, no accumulator is returned, so no merge is necessary. @@ -266,7 +244,7 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): # Add a generic monitoring tool (a "group" in old language). The returned # object here is the standard GenericMonitoringTool. - self.bookExpertHistos(trigEgammaMonAlg, rootpath+'/Expert/'+triggerChain, helper, triggerChain, 'Expert') + self.bookExpertHistos(trigEgammaMonAlg, rootpath+'/Expert/'+triggerChain, helper, triggerChain) trigMonGroup = helper.addGroup( trigEgammaMonAlg, @@ -281,140 +259,6 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): trigMonGroup.defineHistogram('lb', title='Luminosity Block;lb;Events', path='TestEgammaMonitor',xbins=1000,xmin=-0.5,xmax=999.5) - trigMonGroup.defineHistogram('r#x,r#y;dist_xy', type='TH2F', title='Cirle #rho;x;y', - path='TestEgammaMonitor',xbins=100,xmin=-5,xmax=5, ybins=100,ymin=-5,ymax=5) - trigMonGroup.defineHistogram('t#x,t#y;test_xy', type='TH2F', title='This is a test;x;y', - path='TestEgammaMonitor',xbins=100,xmin=-5,xmax=5, ybins=100,ymin=-5,ymax=5) - - def defineExpertEventAlg(self, rootpath, helper, algnameprefix): - """ - Defines algorithm instance for event-wide monitoring (all triggers, triggers comparison) - """ - - ### STEP 2 ### - # Adding an algorithm to the helper. Here, we will use the example - # algorithm in the AthenaMonitoring package. Just pass the type to the - # helper. Then, the helper will instantiate an instance and set up the - # base class configuration following the inputFlags. The returned object - # is the algorithm. - #The added algorithm must exist as a .h file - from TrigEgammaMonitoring.TrigEgammaMonitoringConf import TrigEgammaMonitorAlgorithm - trigEgammaMonAlg = helper.addAlgorithm(TrigEgammaMonitorAlgorithm, algnameprefix+'__Event') - - ### STEP 3 ### - # Edit properties of a algorithm - # some generic property - # trigEgammaMonAlg.RandomHist = True - # to enable a trigger filter, for example: - trigEgammaMonAlg.OutputLevel = 2 # DEBUG - - ### STEP 4 ### - # Add some tools. N.B. Do not use your own trigger decision tool. Use the - # standard one that is included with AthMonitorAlgorithm. - - # # First, add a tool that's set up by a different configuration function. - # # In this case, CaloNoiseToolCfg returns its own component accumulator, - # # which must be merged with the one from this function. - # from CaloTools.CaloNoiseToolConfig import CaloNoiseToolCfg - # caloNoiseAcc, caloNoiseTool = CaloNoiseToolCfg(inputFlags) - # result.merge(caloNoiseAcc) - # trigEgammaMonAlg.CaloNoiseTool = caloNoiseTool - - trigEgammaMonAlg.Tools = self.configureTools() - trigEgammaMonAlg.IsChainSpecific = False - - # # Then, add a tool that doesn't have its own configuration function. In - # # this example, no accumulator is returned, so no merge is necessary. - # from MyDomainPackage.MyDomainPackageConf import MyDomainTool - # trigEgammaMonAlg.MyDomainTool = MyDomainTool() - - # Add a generic monitoring tool (a "group" in old language). The returned - # object here is the standard GenericMonitoringTool. - - trigMonGroup = helper.addGroup( - trigEgammaMonAlg, - 'TrigEgammaMonitor', - rootpath+'/Expert/Test' - ) - - ### STEP 5 ### - # Configure histograms - #NB! The histograms defined here must match the ones in the cxx file exactly - - trigMonGroup.defineHistogram('lb', title='Luminosity Block;lb;Events', - path='TestEgammaMonitor',xbins=1000,xmin=-0.5,xmax=999.5) - - trigMonGroup.defineHistogram('r#x,r#y;dist_xy', type='TH2F', title='Cirle #rho;x;y', - path='TestEgammaMonitor',xbins=100,xmin=-5,xmax=5, ybins=100,ymin=-5,ymax=5) - trigMonGroup.defineHistogram('t#x,t#y;test_xy', type='TH2F', title='This is a test;x;y', - path='TestEgammaMonitor',xbins=100,xmin=-5,xmax=5, ybins=100,ymin=-5,ymax=5) - - - def defineExpertEventHistograms(self, monAlg, basePath, helper, triggerStream, monnameprefix='TrigEgammaMonitor'): - - # 'Electrons' and 'Photons' - _evtMonGroup = self.createMonGroup(monAlg, helper, basePath, ('Event', ), monnameprefix ) - - _el_ph_trigs = { - 'Electrons' : self.electronList, - 'Photons' : self.photonList - } - - for anatype, trigs in _el_ph_trigs.iteritems(): - histname=anatype+"_electrons" - _evtMonGroup.defineHistogram(histname, type='TH1F', title="Offline Electrons; ; N_{electrons}", - path='/', xbins=6, xmin=1., xmax=6, labels=("loose", "medium", "tight", "lhloose", "lhmedium", "lhtight") ) - - histname=anatype+"_trigger_counts" - nTrigger = len(trigs) - # in original C++ code (TrigEgammaNavAnalysisTool::childBook) histograms are defined dynamicaly - # as intersection of defined TriggerList (`trigs` here) and triggers available in data - if nTrigger > 0: - _evtMonGroup.defineHistogram(histname, type='TH1F', title="Trigger Counts; Trigger ; Count", - path='/', xbins=nTrigger, xmin=0, xmax=nTrigger, labels=trigs) - - - # 'Zee' and 'Jpsiee' Tag-and-Probe - - _tp_trigs = { - 'Zee' : self.tpList, - 'Jpsiee' : self.jpsiList - } - - for anatype, trigs in _tp_trigs.iteritems(): - self.addHistogram(_evtMonGroup, TH1F(anatype+"_ProbeCutCounter", "Number of Probes; Cut ; Count", 12, 0., 12)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_TagCutCounter", "Number of Tags; Cut ; Count", 10, 0., 10)) - - anaTool = self.findToolForAna(monAlg.Tools, anatype) - if anaTool: - self.addHistogram(_evtMonGroup, TH1F(anatype+"_Mee", "Offline M(ee); m_ee [GeV] ; Count", 50, anaTool.ZeeLowerMass, anaTool.ZeeUpperMass)) - - self.addHistogram(_evtMonGroup, TH1I(anatype+"_CutCounter", "Event Selection; Cut ; Count", 6, 0., 6, - labels=anaTool.CutLabels ) ) - - nTrigger = len(trigs) - if nTrigger > 0: - self.addHistogram(_evtMonGroup, TH1F(anatype+"_trigger_counts", "Trigger Counts; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_nProbes", "Number of Probes; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_nProbesL1", "Number of L1 Probes; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_nProbesL2", "Number of L2 Probes; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_nProbesL2Calo", "Number of L2Calo Probes; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_nProbesEFCalo", "Number of EFCalo Probes; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TH1F(anatype+"_nProbesHLT", "Number of HLT Probes; Trigger ; Count", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TProfile(anatype+"_EffL1", "Average L1 Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TProfile(anatype+"_EffL2", "Average L2 Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TProfile(anatype+"_EffL2Calo", "Average L2Calo Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TProfile(anatype+"_EffEFCalo", "Average EFCalo Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger, labels=trigs)) - self.addHistogram(_evtMonGroup, TProfile(anatype+"_EffHLT", "Average HLT Efficiency; Trigger ; #epsilon", nTrigger, 0., nTrigger, labels=trigs)) - - def findToolForAna(self, tools, anatype): - for t in tools: - if t.Analysis == anatype: - return t - - return None - - def isL1trigger(self, trigStream): return trigStream.startswith('L1') @@ -442,7 +286,6 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): return helper.addGroup(monAlg, grpName, grpPath ) def bookExpertHistos(self, monAlg, basePath, helper, triggerStream, monnameprefix='TrigEgammaMonitor'): - self.defineExpertEventHistograms(monAlg, basePath, helper, triggerStream, monnameprefix) self.bookL1Histos(monAlg, basePath, helper, triggerStream, monnameprefix) algnames = ["Efficiency"] @@ -451,13 +294,13 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): # Loop over Efficiency (and or) Emulation for algname in algnames: - _ehltMonGroup = self.createMonGroup(monAlg, helper, basePath, (algname, 'HLT'), monnameprefix ) + _ehltMonGroup = self.createMonGroup(monAlg, helper, basePath, (algname, 'HLT') ) self.bookEfficiencyHistos(_ehltMonGroup) self.bookEfficiency2DHistos(_ehltMonGroup) for subgroups in [ (algname,'L2Calo'), (algname, 'L2'), (algname,'EFCalo') ]: - _subgrpMonGroup = self.createMonGroup(monAlg, helper, basePath, subgroups, monnameprefix ) + _subgrpMonGroup = self.createMonGroup(monAlg, helper, basePath, subgroups ) self.bookEfficiencyHistos(_subgrpMonGroup) if self.detailLevel: self.bookEfficiency2DHistos(_subgrpMonGroup) @@ -511,7 +354,7 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): ( algname, 'HLT', 'LHTightIso' ), ] for effdir in effdirs: - _effdirMonGroup = self.createMonGroup(monAlg, helper, basePath, effdir, monnameprefix ) + _effdirMonGroup = self.createMonGroup(monAlg, helper, basePath, effdir ) self.bookEfficiencyHistos(_effdirMonGroup) self.bookEfficiency2DHistos(_effdirMonGroup) @@ -521,8 +364,8 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): # Distributions histograms dirnames = [ - self.createMonGroup(monAlg, helper, basePath, ('Distributions','Offline'), monnameprefix ), - self.createMonGroup(monAlg, helper, basePath, ('Distributions', 'HLT'), monnameprefix ), + self.createMonGroup(monAlg, helper, basePath, ('Distributions','Offline') ), + self.createMonGroup(monAlg, helper, basePath, ('Distributions', 'HLT') ), ] for subgrp in dirnames: self.bookEgammaDistributionHistos(subgrp) @@ -531,7 +374,7 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): self.addHistogram(subgrp, TH1F("rejection","N_{TE}; #Step",6,0,6, labels=self._label_hltte)) - _efcaloMonGroup = self.createMonGroup(monAlg, helper, basePath, ('Distributions', 'EFCalo'), monnameprefix ) + _efcaloMonGroup = self.createMonGroup(monAlg, helper, basePath, ('Distributions', 'EFCalo') ) dirnames.append(_efcaloMonGroup) self.addHistogram(_efcaloMonGroup, TH1F("energyBE0", "Cluster Energy BE0; E [GeV] ; Count", 50, 0., 100.)) self.addHistogram(_efcaloMonGroup, TH1F("energyBE1", "Cluster Energy BE1; E [GeV] ; Count", 50, 0., 100.)) @@ -542,16 +385,16 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): self.addHistogram(_efcaloMonGroup, TH1F("phi_calo", "phi_calo; phi_calo ; Count", 50, -3.14, 3.14)) if self.triggerType(triggerStream) == 'photon': - _l2phMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L2Photon'), monnameprefix ) + _l2phMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L2Photon') ) self.bookDistributionHistos(_l2phMonGroup) if self.triggerType(triggerStream) == 'electron': - _l2elMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L2Electron'), monnameprefix ) + _l2elMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L2Electron') ) self.bookDistributionHistos(_l2elMonGroup) self.addHistogram(_l2elMonGroup, TH1F("trkClusDeta", "Trk Clus Deta; deta ; Count", 50, -0.5, 0.5)) self.addHistogram(_l2elMonGroup, TH1F("trkClusDphi", "Trk Clus Dphi; dphi ; Count", 50, -0.5, 0.5)) - _l2caloMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L2Calo'), monnameprefix ) + _l2caloMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L2Calo') ) dirnames.append(_l2caloMonGroup) #Book the kinematic plots for each trigger level @@ -559,7 +402,7 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): self.bookDistributionHistos(dirgrp) # Resolution - _hltresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'HLT'), monnameprefix ) + _hltresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'HLT') ) self.bookResolutionHistos(_hltresMonGroup) if self.triggerType(triggerStream) == 'electron': self.bookElectronResolutionHistos(_hltresMonGroup) @@ -574,31 +417,31 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): self.bookExpertResolutionHistos(_hltresMonGroup) if self.detailLevel: - _hltabsresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'AbsResolutions', 'HLT'), monnameprefix ) + _hltabsresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'AbsResolutions', 'HLT') ) self.bookAbsResolutionHistos(_hltabsresMonGroup) if self.detailLevel: - _l2caloresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'L2Calo'), monnameprefix ) + _l2caloresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'L2Calo') ) self.bookResolutionHistos(_l2caloresMonGroup) self.bookExpertL2CaloResolutionHistos(_l2caloresMonGroup) - _l2calohltresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'L2Calo_vs_HLT'), monnameprefix ) + _l2calohltresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'L2Calo_vs_HLT') ) self.bookResolutionHistos(_l2calohltresMonGroup) if self.detailLevel: self.bookExpertL2CaloResolutionHistos(_l2calohltresMonGroup) # end of bookExpertHistos def bookL1Histos(self, monAlg, basePath, helper, triggerStream, monnameprefix='TrigEgammaMonitor'): - _l1caloeffMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Efficiency', 'L1Calo'), monnameprefix ) + _l1caloeffMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Efficiency', 'L1Calo') ) self.bookEfficiencyHistos(_l1caloeffMonGroup) self.bookEfficiency2DHistos(_l1caloeffMonGroup) if self.emulation: - _l1caloemuMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Emulation', 'L1Calo'), monnameprefix ) + _l1caloemuMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Emulation', 'L1Calo') ) self.bookEfficiencyHistos(_l1caloemuMonGroup) self.bookEfficiency2DHistos(_l1caloemuMonGroup) - _l1calodistMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L1Calo'), monnameprefix ) + _l1calodistMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'L1Calo') ) self.addHistogram(_l1calodistMonGroup, TH1F("energy", "Cluster Energy; E [GeV] ; Count", 100, 0., 200.)) self.addHistogram(_l1calodistMonGroup, TH1F("roi_et", "RoI word Cluster Energy; E [GeV] ; Count", 100, 0., 200.)) self.addHistogram(_l1calodistMonGroup, TH1F("emIso", "EM Isolation; E [GeV] ; Count", 50, -1., 20.)) @@ -615,16 +458,16 @@ class TrigEgammaMonToolBuilderRun3(TrigEgammaMonToolBuilder): 10, -0.1, 4.9, 60, 0, 60)) - _roidistMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'RoI'), monnameprefix ) + _roidistMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Distributions', 'RoI') ) self.addHistogram(_roidistMonGroup, TH1F("roi_eta", "RoI #eta; #eta ; Count", 51, -2.55, 2.55)) self.addHistogram(_roidistMonGroup, TH1F("roi_phi", "RoI #phi; #phi ; Count", 20, -3.2, 3.2)) - _l1caloresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'L1Calo'), monnameprefix ) + _l1caloresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'Resolutions', 'L1Calo') ) self.addHistogram(_l1caloresMonGroup, TH2F("res_etVsEta", "L1 cluster Energy resolution as function of L1 #eta; #eta; (E_{T}(on)-E_{T}(off))/E_{T}(off); Count", 50, -2.55, 2.55, 200, -1., 1.)) - _l1caloabsresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'AbsResolutions', 'L1Calo'), monnameprefix ) + _l1caloabsresMonGroup = self.createMonGroup(monAlg, helper, basePath, ( 'AbsResolutions', 'L1Calo') ) self.addHistogram(_l1caloabsresMonGroup, TH2F("res_etVsEta", "L1 cluster Energy resolution as function of L1 #eta; #eta; E_{T}(on)-E_{T}(off); Count", 51, -2.55, 2.55, 200, -100., 100.)) diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringHistDefs.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringHistDefs.py index 80b528a3782..ddc38a55dc7 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringHistDefs.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringHistDefs.py @@ -10,14 +10,11 @@ class HistDefinition(object): def __setitem__(self, key, value): self.kwargs[key] = value +# Emulate multiple ROOT C++ constructors to minimize retyping of histograms definitions -def _define1D(name, title, nxbins, bins_par2, bins_par3=None, path='/', **kwargs): - """ - Emulate multiple ROOT C++ constructors to minimize retyping of histograms definitions - - TH1F (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup) -- signature 1 - TH1F (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins) -- signature 2 - """ +# TH1F (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup) -- signature 1 +# TH1F (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins) -- signature 2 +def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='/', **kwargs): res = HistDefinition(name) res['type'] = 'TH1F' @@ -35,32 +32,20 @@ def _define1D(name, title, nxbins, bins_par2, bins_par3=None, path='/', **kwargs return res -def TH1F(*args, **kwargs): - res = _define1D(*args, **kwargs) - res['type'] = 'TH1F' - return res - -def TH1I(*args, **kwargs): - res = _define1D(*args, **kwargs) - res['type'] = 'TH1I' - return res - def TProfile(*args, **kwargs): - res = _define1D(*args, **kwargs) - res.name = '{0}#1,{0}#2;{0}'.format(res.name) # Create two monitored variables with automatic names (; alias=hist name in ROOT), the same names created in C++ at filling time + res = TH1F(*args, **kwargs) + res.name = res.name+','+res.name # Temporary emulate two monitored variables res['type'] = 'TProfile' return res -def _define2D(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='/', **kwargs): - """ - Emulate multiple ROOT C++ constructors to minimize retyping of histograms definitions +# TH2F (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup) -- signature 1 +# TH2F (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins, Int_t nbinsy, Double_t ylow, Double_t yup) -- signature 2 +# TH2F (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, const Double_t *ybins) -- signature 3 +# TH2F (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins, Int_t nbinsy, const Double_t *ybins) -- signature 4 +def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='/', **kwargs): - TH2F (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup) -- signature 1 - TH2F (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins, Int_t nbinsy, Double_t ylow, Double_t yup) -- signature 2 - TH2F (const char *name, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, const Double_t *ybins) -- signature 3 - TH2F (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins, Int_t nbinsy, const Double_t *ybins) -- signature 4 - """ - res = HistDefinition(name) + res = HistDefinition(name+','+name) # Temporary emulate two monitored variables + res['type'] = 'TH2F' res['title'] = title if isinstance(bins_par2, (list, tuple) ): # signature 2 or 4 @@ -87,14 +72,9 @@ def _define2D(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=No res.kwargs.update(kwargs) return res -def TH2F(name, *args, **kwargs): - res = _define2D(name, *args, **kwargs) - res.name = '{0}#1,{0}#2;{0}'.format(res.name) # Create two monitored variables with automatic names (; alias=hist name in ROOT), the same names created in C++ at filling time - res['type'] = 'TH2F' - return res def TProfile2D(name, *args, **kwargs): - res = _define2D(name, *args, **kwargs) - res.name = '{0}#1,{0}#2,{0}#3;{0}'.format(res.name) # Create tree monitored variables with automatic names (; alias=hist name in ROOT), the same names created in C++ at filling time + res = TH2F(name, *args, **kwargs) + res.name = res.name+','+name # Temporary emulate three monitored variables res['type'] = 'TProfile2D' return res diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.cxx index 069781a8805..7f2307cb8df 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.cxx +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.cxx @@ -5,59 +5,21 @@ #include "TrigEgammaMonitorAlgorithm.h" #include "TRandom3.h" -#include "TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h" - TrigEgammaMonitorAlgorithm::TrigEgammaMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) - : base_class(name, pSvcLocator) -{ - declareProperty("IsChainSpecific", m_isChainSpecific=true); -} + : AthMonitorAlgorithm(name,pSvcLocator) +{} TrigEgammaMonitorAlgorithm::~TrigEgammaMonitorAlgorithm() {} StatusCode TrigEgammaMonitorAlgorithm::initialize() { - ATH_MSG_INFO("Initializing " << name() << "..."); - - StatusCode sc = AthMonitorAlgorithm::initialize(); - if ( ! sc.isSuccess() ) { - ATH_MSG_ERROR("Error initialize parent"); - return StatusCode::FAILURE; - } - - ATH_MSG_INFO("Retrieving tools... " << m_tools.size()); - - for ( const auto htool : m_tools ) { - ATH_MSG_INFO("Retrieving "<< htool <<"..." ); - StatusCode sc = htool.retrieve(); - if ( ! sc.isSuccess() ) { - ATH_MSG_ERROR("Tool retrieval failed: " << htool); - return StatusCode::FAILURE; - } - ATH_MSG_INFO("...//" ); - } - - for ( auto htool : m_tools ) { - ATH_MSG_INFO("Initializing "<< htool <<"..." ); - htool->setMGLookup(this); - ATH_MSG_INFO("...//" ); - ATH_MSG_INFO("Booking "<< htool <<"..." ); - sc = htool->book(); - if ( ! sc.isSuccess() ) { - ATH_MSG_ERROR("Tool book failed:" << htool); - return StatusCode::FAILURE; - } - ATH_MSG_INFO("...//" ); - } - - ATH_MSG_INFO("Tools retrieval completed."); - return StatusCode::SUCCESS; + return AthMonitorAlgorithm::initialize(); } StatusCode TrigEgammaMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const { - //using namespace Monitored; + using namespace Monitored; // Declare the quantities which should be monitored //NB! The variables and histograms defined here must match the ones in the py file exactly! @@ -73,11 +35,6 @@ StatusCode TrigEgammaMonitorAlgorithm::fillHistograms( const EventContext& ctx ) auto phi = Monitored::Scalar("phi",0.0); - auto r_x = Monitored::Scalar("r#x",0.0); - auto r_y = Monitored::Scalar("r#y",0.0); - auto t_x = Monitored::Scalar("t#x",0.0); - auto t_y = Monitored::Scalar("t#y",0.0); - //Access a hard-coded trigger chain //(this should probably be moved elsewhere and done in a more automatic way in the future) //m_trigItems.push_back("HLT_e24_lhtight_nod0"); @@ -112,66 +69,20 @@ StatusCode TrigEgammaMonitorAlgorithm::fillHistograms( const EventContext& ctx ) res_etInEta0 = (r.Rndm()-0.5)/5; - // Alternative fill method. Get the group yourself, and pass it to the fill function. - auto tool = getGroup("TrigEgammaMonitor"); - float aphi = 0.0; - unsigned int codepoints[] = {0x0308BD20, 0x04888520, 0x04889DE0, 0x04888520, 0x033BBD20, 0x00000000, 0x181E9324, - 0x240294A4, 0x240E94BC, 0x3C0267A4, 0x241E64A4, 0x00000000, 0xA639EEE9, 0xA950224B, 0x4950E24F, 0x4F50224D, 0x4939EEE9, 0x00000000}; - for( int i=0; i<100; i++) { - aphi = (r.Rndm()-0.5)*2*3.1415; - - const float radius = r.Gaus(0, 0.2)+(cos(7*aphi)+3); - const float f_x = r.Uniform(-5, 5); - const float f_y = r.Uniform(-5, 5); - - r_x = radius*cos(aphi); - r_y = radius*sin(aphi); - ATH_MSG_DEBUG("Test fill r#x, r#y: " << i); - - fill(tool, r_x, r_y); - - if ((codepoints[int(1.6*(5-f_y)+0.5)] >> int((f_x+5)*3.1+0.5))&0x1) { - t_x = f_x*0.9; - t_y = f_y*0.9; - fill(tool, t_x, t_y); - } - } + phi = (r.Rndm()-0.5)*2*3.1415; // Fill. First argument is the tool (GMT) name as defined in the py file, // all others are the variables to be saved. //fill("TrigEgammaMonitor",lumiPerBCID,lb); - fill("TrigEgammaMonitor", lb, run); - - - if (m_isChainSpecific) { - //fill("TrigEgammaMonitor_AbsResolutions_HLT", res_etInEta0); - - phi = aphi; - - fill("Expert_Distributions_L1Calo", phi); + fill("TrigEgammaMonitor",lb); - phi = aphi*aphi/3.1415; + // Alternative fill method. Get the group yourself, and pass it to the fill function. + auto tool = getGroup("TrigEgammaMonitor"); + fill(tool,run); - fill("Expert_Distributions_HLT", phi); - } + //fill("TrigEgammaMonitor_AbsResolutions_HLT", res_etInEta0); - ATH_MSG_DEBUG ("Executing " << name() << "..."); - // Loop over monitoring tools - ATH_MSG_DEBUG("Looping over monitoring tools."); - const std::string line = "---------------------------------------------------"; - ATH_MSG_DEBUG(line); - for ( auto htool : m_tools ) { - StatusCode sc = htool->execute(); - if ( ! sc.isSuccess() ) { - ATH_MSG_ERROR("Tool execute failed: " << htool); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG(line); - } + fill("TrigEgammaMonitor_Distributions_L1Calo", phi); return StatusCode::SUCCESS; } - -ToolHandle TrigEgammaMonitorAlgorithm::findGroup( const std::string& name ) const { - return getGroup(name); -} diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.h b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.h index ce21bc31509..3798904e8f4 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.h +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAlgorithm.h @@ -8,26 +8,15 @@ #include "AthenaMonitoring/AthMonitorAlgorithm.h" #include "AthenaMonitoring/Monitored.h" -#include "TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h" -#include "TrigEgammaAnalysisTools/IMonitoringGroupLookup.h" -class TrigEgammaMonitorAlgorithm : public extends { - public: - TrigEgammaMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~TrigEgammaMonitorAlgorithm(); - virtual StatusCode initialize() override; - virtual StatusCode fillHistograms( const EventContext& ctx ) const override; - - // IMonitoringGroupLookup implementation - ToolHandle findGroup( const std::string& name ) const override; - - private: - ///Name of the trigger items to be monitored. - //std::vector m_trigItems; - // Using the new way to declare JO properties: Gaudi::Property m_myProperty {this,"MyProperty",0}; - ToolHandleArray< ITrigEgammaAnalysisBaseTool > m_tools {this,"Tools",{}}; ///< Array of Egamma Monitoring Tools - /*! Is monitoring trigger chain specific default True */ - bool m_isChainSpecific; +class TrigEgammaMonitorAlgorithm : public AthMonitorAlgorithm { + public: + TrigEgammaMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + virtual ~TrigEgammaMonitorAlgorithm(); + virtual StatusCode initialize() override; + virtual StatusCode fillHistograms( const EventContext& ctx ) const override; + ///Name of the trigger items to be monitored. + //std::vector m_trigItems; }; #endif -- GitLab