diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/CMakeLists.txt b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/CMakeLists.txt index 364be430ff4b9a0c10f86b68ce8bf76d2dd1fe23..79db3b49f8e722b3065c7739da9ebf3e37795b34 100644 --- a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/CMakeLists.txt +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/CMakeLists.txt @@ -5,28 +5,27 @@ # Declare the package name: atlas_subdir( TrigEgammaMatchingTool ) -# Extra dependencies, based on the build environment: -set( extra_deps ) -if( NOT XAOD_STANDALONE ) - set( extra_deps Control/AthenaBaseComps GaudiKernel ) - endif() # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC - Control/AthToolSupport/AsgTools Event/xAOD/xAODCaloEvent Event/xAOD/xAODEgamma Event/xAOD/xAODTracking Event/xAOD/xAODTrigCalo Event/xAOD/xAODTrigEgamma + Event/xAOD/xAODMuon + Event/xAOD/xAODTau + Event/xAOD/xAODTrigger Trigger/TrigAnalysis/TrigDecisionTool Trigger/TrigConfiguration/TrigConfHLTData Trigger/TrigEvent/TrigSteeringEvent + Trigger/TrigSteer/DecisionHandling PRIVATE - Event/xAOD/xAODMuon - Event/xAOD/xAODTau - Event/xAOD/xAODTrigger - ${extra_deps} ) + Control/AthToolSupport/AsgTools + Control/AthenaMonitoring + Control/StoreGate + Control/AthenaBaseComps + GaudiKernel ) @@ -38,18 +37,16 @@ atlas_add_library( TrigEgammaMatchingToolLib Root/*.cxx PUBLIC_HEADERS TrigEgammaMatchingTool PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES AsgTools xAODCaloEvent xAODEgamma xAODTracking xAODTrigCalo xAODTrigEgamma TrigConfHLTData TrigSteeringEvent TrigDecisionToolLib + LINK_LIBRARIES AsgTools xAODCaloEvent xAODEgamma xAODTracking xAODTrigCalo xAODTrigEgamma TrigConfHLTData + TrigSteeringEvent TrigDecisionToolLib DecisionHandlingLib AthenaMonitoringLib PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} xAODMuon xAODTau xAODTrigger ) -if( NOT XAOD_STANDALONE ) atlas_add_component( TrigEgammaMatchingTool src/*.h src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODCaloEvent xAODEgamma xAODTracking xAODTrigCalo xAODTrigEgamma TrigDecisionToolLib TrigConfHLTData TrigSteeringEvent AthenaBaseComps xAODMuon xAODTau xAODTrigger GaudiKernel TrigEgammaMatchingToolLib ) - -endif() + LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODCaloEvent xAODEgamma xAODTracking xAODTrigCalo xAODTrigEgamma + TrigDecisionToolLib TrigConfHLTData TrigSteeringEvent AthenaBaseComps xAODMuon xAODTau xAODTrigger GaudiKernel + TrigEgammaMatchingToolLib AthenaMonitoringLib StoreGateLib) -# Install files from the package: -atlas_install_joboptions( share/*.py ) diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingTool.cxx b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingTool.cxx index da0dbfd2e1fecdc13541722da7232fb6ff6fb67c..59e2c648583a3ec1ce947e0d1f1d1558253ff0e8 100644 --- a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingTool.cxx @@ -28,13 +28,6 @@ namespace Trig { TrigEgammaMatchingTool::~TrigEgammaMatchingTool(){ } - StatusCode TrigEgammaMatchingTool::finalize() { - return StatusCode::SUCCESS; - } - - StatusCode TrigEgammaMatchingTool::execute() { - return StatusCode::SUCCESS; - } StatusCode TrigEgammaMatchingTool::initialize() { // Greet the user: @@ -56,11 +49,11 @@ namespace Trig { * Note does not use DeactiviateTEs * Returns closest EF object to offline object * Requires TrigPassBits only works in Athena*/ - const xAOD::Egamma* TrigEgammaMatchingTool::closestHLTObject(const xAOD::Egamma *eg,const std::string trigger){ + const xAOD::Egamma* TrigEgammaMatchingTool::closestHLTObject(const xAOD::Egamma *eg,const std::string &trigger){ - if(eg==NULL) { - ATH_MSG_DEBUG("NULL Offline object"); - return NULL; + if(eg==nullptr) { + ATH_MSG_DEBUG("nullptr Offline object"); + return nullptr; } Trig::FeatureContainer fc = m_trigDecTool->features(trigger); double deltaR=0.; @@ -73,13 +66,13 @@ namespace Trig { for(auto feat : vec){ const xAOD::ElectronContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_DEBUG("Electron container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("Electron container from TE nullptr"); continue; } for(const auto& el : *cont){ - if(el == NULL) { - ATH_MSG_DEBUG("Electron from TE NULL"); + if(el == nullptr) { + ATH_MSG_DEBUG("Electron from TE nullptr"); continue; } deltaR = dR(elOff->trackParticle()->eta(),elOff->trackParticle()->phi(), el->trackParticle()->eta(),el->trackParticle()->phi()); @@ -96,13 +89,13 @@ namespace Trig { const std::vector< Trig::Feature<xAOD::PhotonContainer> > vec = fc.get<xAOD::PhotonContainer>("egamma_Photons"); for(auto feat : vec){ const xAOD::PhotonContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_DEBUG("Photon Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("Photon Container from TE nullptr"); continue; } for(const auto& ph : *cont){ - if(ph == NULL) { - ATH_MSG_DEBUG("Photon from TE NULL"); + if(ph == nullptr) { + ATH_MSG_DEBUG("Photon from TE nullptr"); continue; } deltaR = dR(phOff->caloCluster()->eta(),phOff->caloCluster()->phi(), ph->caloCluster()->eta(),ph->caloCluster()->phi()); @@ -119,7 +112,7 @@ namespace Trig { /*! Calls match with a FeatureContainer for a given triggerfor HLT only * Note does not use DeactiviateTEs */ - bool TrigEgammaMatchingTool::matchHLT(const xAOD::Egamma *eg,const std::string trigger){ + bool TrigEgammaMatchingTool::matchHLT(const xAOD::Egamma *eg,const std::string &trigger){ ATH_MSG_DEBUG("matchHLT"); Trig::FeatureContainer fc = m_trigDecTool->features(trigger); ATH_MSG_DEBUG("FeatureContainer"); @@ -135,13 +128,13 @@ namespace Trig { ATH_MSG_DEBUG("Container Feature"); for(const auto feat : vec){ const xAOD::ElectronContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_DEBUG("Electron container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("Electron container from TE nullptr"); continue; } for(const auto& el : *cont){ - if(el == NULL) { - ATH_MSG_WARNING("Electron from TE NULL"); + if(el == nullptr) { + ATH_MSG_WARNING("Electron from TE nullptr"); continue; } deltaR = dR(eg->eta(),eg->phi(), el->eta(),el->phi()); @@ -164,13 +157,13 @@ namespace Trig { #endif // XAOD_ANALYSIS for(const auto feat : vec){ const xAOD::PhotonContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_DEBUG("Photon Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("Photon Container from TE nullptr"); continue; } for(const auto& ph : *cont){ - if(ph == NULL) { - ATH_MSG_DEBUG("Photon from TE NULL"); + if(ph == nullptr) { + ATH_MSG_DEBUG("Photon from TE nullptr"); continue; } deltaR = dR(phOff->eta(),phOff->phi(), ph->eta(),ph->phi()); @@ -183,8 +176,8 @@ namespace Trig { return false; // No match } - bool TrigEgammaMatchingTool::matchHLTPhoton(const xAOD::Photon *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ - finalFC=NULL; + bool TrigEgammaMatchingTool::matchHLTPhoton(const xAOD::Photon *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ + finalFC=nullptr; ATH_MSG_DEBUG("Match HLT Photon"); // Get the container of online electrons associated to passed items auto fc = (m_trigDecTool->features(trigger,TrigDefs::alsoDeactivateTEs)); @@ -202,14 +195,14 @@ namespace Trig { double deltaR=0.; for(auto feat : vec){ const xAOD::PhotonContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_DEBUG("Photon Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("Photon Container from TE nullptr"); continue; } ATH_MSG_DEBUG("EF Size " << cont->size()); for(const auto& ph : *cont){ - if(ph == NULL) { - ATH_MSG_DEBUG("Photon from TE NULL"); + if(ph == nullptr) { + ATH_MSG_DEBUG("Photon from TE nullptr"); continue; } deltaR = dR(eg->eta(),eg->phi(), ph->eta(),ph->phi()); @@ -222,9 +215,9 @@ namespace Trig { return false; } - bool TrigEgammaMatchingTool::matchHLTElectron(const xAOD::Electron *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ + bool TrigEgammaMatchingTool::matchHLTElectron(const xAOD::Electron *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ ATH_MSG_DEBUG("Match HLT electron"); - finalFC=NULL; + finalFC=nullptr; // Get the container of online electrons associated to passed items auto fc = (m_trigDecTool->features(trigger,TrigDefs::alsoDeactivateTEs)); @@ -237,31 +230,31 @@ namespace Trig { double deltaR=0.; for(auto feat : vec){ const xAOD::ElectronContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_WARNING("Electron Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_WARNING("Electron Container from TE nullptr"); continue; } ATH_MSG_DEBUG("EF Size " << cont->size()); for(const auto& el : *cont){ - if(el == NULL) { - ATH_MSG_DEBUG("Electron from TE NULL"); + if(el == nullptr) { + ATH_MSG_DEBUG("Electron from TE nullptr"); continue; } deltaR = dR(eg->eta(),eg->phi(), el->eta(),el->phi()); if(deltaR < m_dR){ finalFC = (feat.te()); - ATH_MSG_DEBUG("Electron finalFC matches offline"); + ATH_MSG_DEBUG("Electron finalFC matches offline"); return true; } } } - ATH_MSG_DEBUG("Reached the end in matchHLTElectron. So didn't match!"); + ATH_MSG_DEBUG("Reached the end in matchHLTElectron. So didn't match!"); return false; } - bool TrigEgammaMatchingTool::matchHLTCalo(const xAOD::Egamma *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ + bool TrigEgammaMatchingTool::matchHLTCalo(const xAOD::Egamma *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ ATH_MSG_DEBUG("Match HLT CaloCluster"); - finalFC=NULL; + finalFC=nullptr; auto fc = (m_trigDecTool->features(trigger,TrigDefs::alsoDeactivateTEs)); #ifdef XAOD_ANALYSIS const auto vec = fc.containerFeature<xAOD::CaloClusterContainer>("TrigEFCaloCalibFex",TrigDefs::alsoDeactivateTEs); @@ -274,13 +267,13 @@ namespace Trig { for(auto feat : vec){ const xAOD::CaloClusterContainer *cont = feat.cptr(); ATH_MSG_DEBUG("EF Calo Size " << cont->size()); - if(cont == NULL) { - ATH_MSG_DEBUG("CaloCluster Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("CaloCluster Container from TE nullptr"); continue; } for(const auto& clus : *cont){ - if(clus == NULL) { - ATH_MSG_DEBUG("CaloCluster from TE NULL"); + if(clus == nullptr) { + ATH_MSG_DEBUG("CaloCluster from TE nullptr"); continue; } deltaR = dR(eg->eta(),eg->phi(), clus->eta(),clus->phi()); @@ -294,8 +287,8 @@ namespace Trig { } - bool TrigEgammaMatchingTool::matchL2Photon(const xAOD::Photon *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ - finalFC=NULL; + bool TrigEgammaMatchingTool::matchL2Photon(const xAOD::Photon *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ + finalFC=nullptr; ATH_MSG_DEBUG("Match L2 Photon"); auto fc = (m_trigDecTool->features(trigger,TrigDefs::alsoDeactivateTEs)); @@ -308,14 +301,14 @@ namespace Trig { double deltaR=0.; for(auto feat : vec){ const xAOD::TrigPhotonContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_WARNING("TrigPhoton Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_WARNING("TrigPhoton Container from TE nullptr"); continue; } ATH_MSG_DEBUG("L2 Size " << cont->size()); for(const auto& l2 : *cont){ - if(l2 == NULL) { - ATH_MSG_DEBUG("TrigElectron from TE NULL"); + if(l2 == nullptr) { + ATH_MSG_DEBUG("TrigElectron from TE nullptr"); continue; } deltaR = dR(eg->eta(),eg->phi(), l2->eta(),l2->phi()); @@ -328,8 +321,8 @@ namespace Trig { return false; } - bool TrigEgammaMatchingTool::matchL2Electron(const xAOD::Electron *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ - finalFC=NULL; + bool TrigEgammaMatchingTool::matchL2Electron(const xAOD::Electron *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ + finalFC=nullptr; ATH_MSG_DEBUG("Match L2 Electron"); auto fc = (m_trigDecTool->features(trigger,TrigDefs::alsoDeactivateTEs)); #ifdef XAOD_ANALYSIS @@ -341,14 +334,14 @@ namespace Trig { double deltaR=0.; for(auto feat : vec){ const xAOD::TrigElectronContainer *cont = feat.cptr(); - if(cont == NULL) { - ATH_MSG_DEBUG("TrigElectron Container from TE NULL"); + if(cont == nullptr) { + ATH_MSG_DEBUG("TrigElectron Container from TE nullptr"); continue; } ATH_MSG_DEBUG("L2 Size " << cont->size()); for(const auto& l2 : *cont){ - if(l2 == NULL) { - ATH_MSG_DEBUG("TrigElectron from TE NULL"); + if(l2 == nullptr) { + ATH_MSG_DEBUG("TrigElectron from TE nullptr"); continue; } deltaR = dR(eg->eta(),eg->phi(), l2->eta(),l2->phi()); @@ -362,8 +355,8 @@ namespace Trig { } - bool TrigEgammaMatchingTool::matchL2Calo(const xAOD::Egamma *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ - finalFC=NULL; + bool TrigEgammaMatchingTool::matchL2Calo(const xAOD::Egamma *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ + finalFC=nullptr; auto fc = (m_trigDecTool->features(trigger,TrigDefs::alsoDeactivateTEs)); #ifdef XAOD_ANALYSIS ATH_MSG_DEBUG("No matching for TrigEMCluster in AnalysisBase"); @@ -374,8 +367,8 @@ namespace Trig { ATH_MSG_DEBUG("L2 FC Size " << vec.size()); for(auto feat : vec){ const xAOD::TrigEMCluster *em = feat.cptr(); - if(em == NULL) { - ATH_MSG_DEBUG("TrigEMCluster from TE NULL"); + if(em == nullptr) { + ATH_MSG_DEBUG("TrigEMCluster from TE nullptr"); continue; } ATH_MSG_DEBUG("TrigEMCluster << " << em->et() ); @@ -391,8 +384,8 @@ namespace Trig { } - bool TrigEgammaMatchingTool::matchL1( const xAOD::Egamma* eg, const std::string trigger,const HLT::TriggerElement*& finalFC ){ - finalFC=NULL; + bool TrigEgammaMatchingTool::matchL1( const xAOD::Egamma* eg, const std::string &trigger,const HLT::TriggerElement*& finalFC ){ + finalFC=nullptr; #ifdef XAOD_ANALYSIS if(m_trigDecTool->isPassed("L1_EM.*")) return true; @@ -404,8 +397,8 @@ namespace Trig { for (auto initRoi: initRois) { auto itEmTau = m_trigDecTool->ancestor<xAOD::EmTauRoI>(initRoi); const xAOD::EmTauRoI *l1 = itEmTau.cptr(); - if(l1 == NULL) { - ATH_MSG_DEBUG("EMTauRoI from TE NULL"); + if(l1 == nullptr) { + ATH_MSG_DEBUG("EMTauRoI from TE nullptr"); return false; } deltaR = dR(eg->eta(),eg->phi(), l1->eta(),l1->phi()); @@ -421,7 +414,7 @@ namespace Trig { } /*bool TrigEgammaMatchingTool::matchL1( const xAOD::Egamma* eg, const std::string trigger){ - finalFC=NULL; + finalFC=nullptr; #ifdef XAOD_ANALYSIS if(m_trigDecTool->isPassed("L1_EM.*")) return true; @@ -433,8 +426,8 @@ namespace Trig { auto cont = m_trigDecTool->ancestor<xAOD::EmTauRoIContainer>(initRois); for(const auto &l1 : cont){ //const xAOD::EmTauRoI *l1 = feat.cptr(); - if(l1 == NULL) { - ATH_MSG_DEBUG("EMTauRoI from TE NULL"); + if(l1 == nullptr) { + ATH_MSG_DEBUG("EMTauRoI from TE nullptr"); return false; } @@ -454,18 +447,18 @@ namespace Trig { return false; // otherwise, someone matched! }*/ - bool TrigEgammaMatchingTool::match(const xAOD::Egamma *eg,const std::string trigger,const HLT::TriggerElement*& finalFC){ - // Set TE to NULL + bool TrigEgammaMatchingTool::match(const xAOD::Egamma *eg,const std::string &trigger,const HLT::TriggerElement*& finalFC){ + // Set TE to nullptr // If no match easy check - finalFC=NULL; + finalFC=nullptr; ATH_MSG_DEBUG("Match objec with trigger " << trigger); if(xAOD::EgammaHelpers::isElectron(eg)){ const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg); if( matchHLTElectron(el,trigger,finalFC) ) { - ATH_MSG_DEBUG("Matchched!"); - return true; - } + ATH_MSG_DEBUG("Matchched!"); + return true; + } } else if(xAOD::EgammaHelpers::isPhoton(eg)){ const xAOD::Photon* ph =static_cast<const xAOD::Photon*> (eg); @@ -483,25 +476,25 @@ namespace Trig { } if( matchL2Calo(eg,trigger,finalFC) ) return true; if( matchL1(eg,trigger,finalFC) ) return true; - ATH_MSG_DEBUG("match() failed!"); + ATH_MSG_DEBUG("match() failed!"); return false;// otherwise, someone matched!*/ } /*! Calls match with a TE, so recursive matching to L1 * Check that the HLT Electron or Photon ancester passed */ - bool TrigEgammaMatchingTool::match(const xAOD::Egamma *eg,const std::string trigger){ + bool TrigEgammaMatchingTool::match(const xAOD::Egamma *eg,const std::string &trigger){ const HLT::TriggerElement* finalFC; bool passed = false; if( match(eg,trigger,finalFC) ){ - if( finalFC == NULL) return false; + if( finalFC == nullptr) return false; if(xAOD::EgammaHelpers::isElectron(eg)){ - if ( (m_trigDecTool->ancestor<xAOD::ElectronContainer>(finalFC)).te() != NULL){ + if ( (m_trigDecTool->ancestor<xAOD::ElectronContainer>(finalFC)).te() != nullptr){ if( (m_trigDecTool->ancestor<xAOD::ElectronContainer>(finalFC)).te()->getActiveState()) passed = true; } } else if(xAOD::EgammaHelpers::isPhoton(eg)){ - if ( (m_trigDecTool->ancestor<xAOD::PhotonContainer>(finalFC)).te() != NULL){ + if ( (m_trigDecTool->ancestor<xAOD::PhotonContainer>(finalFC)).te() != nullptr){ if( (m_trigDecTool->ancestor<xAOD::PhotonContainer>(finalFC)).te()->getActiveState()) passed = true; } diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..dda8ae6c3cb2a70e7ff46f25e2ad3a49df083ec0 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx @@ -0,0 +1,183 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h" +#include "DecisionHandling/TrigCompositeUtils.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" +#include "DecisionHandling/HLTIdentifier.h" +#include "boost/algorithm/string.hpp" +#include <typeinfo> +#include <string> + + +using namespace TrigCompositeUtils; +using namespace Trig; + + + + +/* + * TrigEgammaMatchinTool API + */ + + +TrigEgammaMatchingToolMT::TrigEgammaMatchingToolMT( const std::string& name ): + asg::AsgTool( name ), + m_trigDecTool("Trig::TrigDecisionTool/TrigDecisionTool") +{ +} + + + +TrigEgammaMatchingToolMT::~TrigEgammaMatchingToolMT() +{ +} + + + + +StatusCode TrigEgammaMatchingToolMT::initialize() +{ + ATH_CHECK(tdt().retrieve()); + + ATH_CHECK( m_emTauRoIKey.initialize() ); + m_keys[ "Electron"] = "HLT_egamma_Electrons" ; + m_keys[ "Photon"] = "HLT_egamma_Photons" ; + m_keys[ "Track"] = ""; + m_keys[ "EFCalo"] = "HLT_CaloEMClusters" ; + m_keys[ "L2Electron"] = "HLT_L2Electrons" ; + m_keys[ "L2Photon"] = "HLT_L2Photons" ; + m_keys[ "L2Calo"] = "HLT_L2CaloEMClusters" ; + m_keys[ "L1Calo"] = "LVL1EmTauRoIs" ; + + return StatusCode::SUCCESS; +} + + + +std::string TrigEgammaMatchingToolMT::key( std::string key) const +{ + return m_keys.at(key); +} + + +bool TrigEgammaMatchingToolMT::match(const xAOD::Egamma *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match decec with trigger " << trigger); + if(xAOD::EgammaHelpers::isElectron(eg)){ + const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg); + if( matchHLTElectron(el,trigger,dec) ) { + ATH_MSG_DEBUG("Matched!"); + return true; + } + }else if(xAOD::EgammaHelpers::isPhoton(eg)){ + const xAOD::Photon* ph =static_cast<const xAOD::Photon*> (eg); + if( matchHLTPhoton(ph,trigger,dec) ) return true; + } + + if( matchHLTCalo(eg,trigger,dec) ) return true; + + if(xAOD::EgammaHelpers::isElectron(eg)){ + const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg); + if( matchL2Electron(el,trigger,dec) ) return true; + + }else if(xAOD::EgammaHelpers::isPhoton(eg)){ + const xAOD::Photon* ph =static_cast<const xAOD::Photon*> (eg); + if( matchL2Photon(ph,trigger,dec) ) return true; + } + + if( matchL1(eg,trigger,dec) ) return true; + ATH_MSG_DEBUG("match() failed!"); + return false; +} + + +bool TrigEgammaMatchingToolMT::match(const xAOD::Egamma *eg,const std::string &trigger ) const +{ + const TrigCompositeUtils::Decision *dec=nullptr; + if( match( eg, trigger, dec ) ){ + if( dec ){ + if(xAOD::EgammaHelpers::isElectron(eg)){ + return ancestorPassed<xAOD::ElectronContainer>(dec, trigger,key("Electron")); + } + if(xAOD::EgammaHelpers::isPhoton(eg)){ + return ancestorPassed<xAOD::PhotonContainer>(dec, trigger, key("Photon")); + } + } + } + return false; +} + + + +bool TrigEgammaMatchingToolMT::matchHLTPhoton(const xAOD::Photon *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match HLT Photon"); + return closestObject<xAOD::PhotonContainer>( eg, dec, trigger, key("Photon") ); +} + + +bool TrigEgammaMatchingToolMT::matchHLTElectron(const xAOD::Electron *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match HLT Electron"); + return closestObject<xAOD::ElectronContainer>( eg, dec , trigger, key("Electron") ); +} + + +bool TrigEgammaMatchingToolMT::matchHLTCalo(const xAOD::Egamma *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match HLT Calo"); + return closestObject<xAOD::CaloClusterContainer>( eg, dec, trigger, key("EFCalo") ); +} + + +bool TrigEgammaMatchingToolMT::matchL2Photon(const xAOD::Photon *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match L2 Photon"); + return closestObject<xAOD::TrigPhotonContainer>( eg, dec, trigger, key("L2Photon") ); +} + + +bool TrigEgammaMatchingToolMT::matchL2Electron(const xAOD::Electron *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match L2 Photon"); + return closestObject<xAOD::TrigElectronContainer>( eg, dec, trigger, key("L2Electron") ); +} + + +bool TrigEgammaMatchingToolMT::matchL2Calo(const xAOD::Egamma *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match L2 Calo"); + return closestObject<xAOD::TrigEMClusterContainer>( eg, dec, trigger, key("L2Calo") ); +} + + +bool TrigEgammaMatchingToolMT::matchL1( const xAOD::Egamma* eg, const std::string &trigger, const TrigCompositeUtils::Decision *&dec ) const +{ + ATH_MSG_DEBUG("Match L1 Calo"); + double deltaR=0.; + auto initRois = tdt()->features<TrigRoiDescriptorCollection>(trigger,TrigDefs::includeFailedDecisions,"", + TrigDefs::allFeaturesOfType,"initialRoI"); + if( initRois.size() < 1) return false; + for( auto &initRoi: initRois ){ + if( !initRoi.link.isValid() ) continue; + deltaR = dR(eg->eta(),eg->phi(), (*initRoi.link)->eta(),(*initRoi.link)->phi()); + if(deltaR < (float)m_dRL1){ + dec=initRoi.source; + return true; + } + } + + return false; +} + + + + + + + + + diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h index b48f5e953f325cf87801b07005df2e6d788ab86c..54d9eb321c86190e4ac6c8595463ff04fd03cb7d 100644 --- a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h @@ -2,8 +2,8 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#ifndef ITRIGEGAMMAMATCHINGTOOL_H_ -#define ITRIGEGAMMAMATCHINGTOOL_H_ +#ifndef ITrigEgammaMatchingTool_H +#define ITrigEgammaMatchingTool_H #include "AsgTools/IAsgTool.h" #include "TrigConfHLTData/HLTFrame.h" @@ -30,13 +30,11 @@ namespace Trig{ ASG_TOOL_INTERFACE( Trig::ITrigEgammaMatchingTool ) public: - virtual StatusCode initialize(void) = 0; - virtual StatusCode execute()=0; - virtual StatusCode finalize()=0; - virtual bool match(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&)=0; - virtual bool match(const xAOD::Egamma *,const std::string)=0; - virtual bool matchHLT(const xAOD::Egamma *,const std::string)=0; - virtual const xAOD::Egamma* closestHLTObject(const xAOD::Egamma *,const std::string)=0; + virtual StatusCode initialize() = 0; + virtual bool match(const xAOD::Egamma *,const std::string&,const HLT::TriggerElement*&)=0; + virtual bool match(const xAOD::Egamma *,const std::string&)=0; + virtual bool matchHLT(const xAOD::Egamma *,const std::string&)=0; + virtual const xAOD::Egamma* closestHLTObject(const xAOD::Egamma *,const std::string&)=0; protected: private: diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingTool.h b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingTool.h index 8bb52d5b7790625d36bcedacaadc3604c22fc38e..d3df41261057f404efe0cf898bffb887ea472d3a 100644 --- a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingTool.h @@ -2,18 +2,18 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#ifndef TRIGEGAMMAMATCHINGTOOL_H_ -#define TRIGEGAMMAMATCHINGTOOL_H_ +#ifndef TrigEgammaMatchingTool_H +#define TrigEgammaMatchingTool_H +#include "TrigDecisionTool/TrigDecisionTool.h" #include "TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h" #include "xAODEgamma/EgammaxAODHelpers.h" -//#include "AsgTools/AsgToolsConf.h" #include "AsgTools/AsgMetadataTool.h" #include "AsgTools/AsgTool.h" #include "AsgTools/ToolHandle.h" #include <iostream> -#include "TrigDecisionTool/TrigDecisionTool.h" + namespace Trig{ class TrigEgammaMatchingTool : @@ -29,17 +29,17 @@ class TrigEgammaMatchingTool : virtual ~TrigEgammaMatchingTool(); - virtual StatusCode initialize(void); - virtual StatusCode execute(); - virtual StatusCode finalize(); + virtual StatusCode initialize() override; + + /*! Egamma trigger matching which returns TE */ - bool match(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&); + bool match(const xAOD::Egamma *,const std::string&,const HLT::TriggerElement*&); /*! Egamma trigger matching to HLT Electron/Photon with DeactivatedTE*/ - bool match(const xAOD::Egamma *,const std::string); + bool match(const xAOD::Egamma *,const std::string&); /*! Egamma trigger matching to HLT Electron/Photon Only */ - bool matchHLT(const xAOD::Egamma *,const std::string); + bool matchHLT(const xAOD::Egamma *,const std::string&); /*! Egamma trigger matching to HLT Electron/Photon only -- returns nearest object */ - const xAOD::Egamma* closestHLTObject(const xAOD::Egamma *,const std::string); + const xAOD::Egamma* closestHLTObject(const xAOD::Egamma *,const std::string&); double dR(const double, const double, const double, const double); double m_dR; double m_dRL1; @@ -49,13 +49,13 @@ class TrigEgammaMatchingTool : template<class T> const T* getFeature(const HLT::TriggerElement* te); template<class T> bool ancestorPassed(const HLT::TriggerElement* te); - bool matchHLTElectron(const xAOD::Electron *,const std::string,const HLT::TriggerElement*&); - bool matchHLTPhoton(const xAOD::Photon *,const std::string,const HLT::TriggerElement*&); - bool matchHLTCalo(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&); - bool matchL2Electron(const xAOD::Electron *,const std::string,const HLT::TriggerElement*&); - bool matchL2Photon(const xAOD::Photon *,const std::string,const HLT::TriggerElement*&); - bool matchL2Calo(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&); - bool matchL1(const xAOD::Egamma *,const std::string,const HLT::TriggerElement*&); + bool matchHLTElectron(const xAOD::Electron *,const std::string&,const HLT::TriggerElement*&); + bool matchHLTPhoton(const xAOD::Photon *,const std::string&,const HLT::TriggerElement*&); + bool matchHLTCalo(const xAOD::Egamma *,const std::string&,const HLT::TriggerElement*&); + bool matchL2Electron(const xAOD::Electron *,const std::string&,const HLT::TriggerElement*&); + bool matchL2Photon(const xAOD::Photon *,const std::string&,const HLT::TriggerElement*&); + bool matchL2Calo(const xAOD::Egamma *,const std::string&,const HLT::TriggerElement*&); + bool matchL1(const xAOD::Egamma *,const std::string&,const HLT::TriggerElement*&); }; } diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h new file mode 100644 index 0000000000000000000000000000000000000000..6b7e759c1b3b152975463d54760ee3f2d55bddc2 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h @@ -0,0 +1,92 @@ +/* + * (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef TrigEgammaMatchingToolMT_H +#define TrigEgammaMatchingToolMT_H + +#include "GaudiKernel/Property.h" +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" +#include "TrigDecisionTool/TrigDecisionTool.h" +#include "xAODTrigger/EmTauRoIContainer.h" +#include "xAODTrigCalo/TrigEMClusterContainer.h" +#include "xAODTrigEgamma/TrigPhotonContainer.h" +#include "xAODTrigEgamma/TrigElectronContainer.h" +#include "xAODCaloEvent/CaloClusterContainer.h" +#include "xAODEgamma/ElectronContainer.h" +#include "xAODEgamma/PhotonContainer.h" +#include "xAODEgamma/EgammaxAODHelpers.h" + + + + + +class TrigEgammaMatchingToolMT : public asg::AsgTool + +{ + ASG_TOOL_INTERFACE( TrigEgammaMatchingToolMT ) + ASG_TOOL_CLASS0( TrigEgammaMatchingToolMT ) + + public: + + TrigEgammaMatchingToolMT( const std::string& name ); + + + ~TrigEgammaMatchingToolMT(); + StatusCode initialize(); + + + bool match(const xAOD::Egamma *,const std::string&) const; + bool match(const xAOD::Egamma *,const std::string&, const TrigCompositeUtils::Decision *&) const; + + std::string key( std::string ) const; + + template<class T> bool ancestorPassed( const TrigCompositeUtils::Decision*, const std::string trigger , const std::string key) const; + + template<class T> TrigCompositeUtils::LinkInfo<T> getFeature( const TrigCompositeUtils::Decision *, std::string trigger ) const; + template<class T> std::vector<TrigCompositeUtils::LinkInfo<T>> getFeatures( const TrigCompositeUtils::Decision *, std::string trigger ) const; + template<class T> std::vector<TrigCompositeUtils::LinkInfo<T>> getFeatures( const TrigCompositeUtils::Decision *, std::string trigger, std::string key ) const; + + + const xAOD::EmTauRoI* getL1Feature( const TrigCompositeUtils::Decision * ) const; + + + private: + + bool matchHLTElectron(const xAOD::Electron *,const std::string &, const TrigCompositeUtils::Decision *&) const; + bool matchHLTPhoton( const xAOD::Photon *,const std::string &, const TrigCompositeUtils::Decision *&) const; + bool matchHLTCalo( const xAOD::Egamma *,const std::string &, const TrigCompositeUtils::Decision *&) const; + bool matchL2Electron( const xAOD::Electron *,const std::string &, const TrigCompositeUtils::Decision *&) const; + bool matchL2Photon( const xAOD::Photon *,const std::string &, const TrigCompositeUtils::Decision *&) const; + bool matchL2Calo( const xAOD::Egamma *,const std::string &, const TrigCompositeUtils::Decision *&) const; + bool matchL1( const xAOD::Egamma *,const std::string &, const TrigCompositeUtils::Decision *&) const; + + template<class T> bool closestObject( const xAOD::Egamma *, const TrigCompositeUtils::Decision *&, std::string trigger, std::string key ) const; + + + inline double dR(const double eta1, const double phi1, const double eta2, const double phi2) const + { + double deta = std::abs(eta1 - eta2); + double dphi = std::abs(phi1 - phi2) < TMath::Pi() ? std::abs(phi1 - phi2) : 2*TMath::Pi() - std::abs(phi1 - phi2); + return sqrt(deta*deta + dphi*dphi); + }; + + + std::map<std::string,std::string> m_keys; + + ToolHandle<Trig::TrigDecisionTool> m_trigDecTool{this, "TriggerTool", ""}; + const ToolHandle<Trig::TrigDecisionTool>& tdt() const { return m_trigDecTool; }; + + Gaudi::Property<float> m_dR{this, "DeltaR", 0.07}; + Gaudi::Property<float> m_dRL1{this, "L1DeltaR", 0.15}; + SG::ReadHandleKey<xAOD::EmTauRoIContainer> m_emTauRoIKey{this, "EmTauRoIKey" , "LVL1EmTauRoIs", ""}; + +}; + + + + +#include "TrigEgammaMatchingToolMT.icc" + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.icc b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.icc new file mode 100644 index 0000000000000000000000000000000000000000..288f5c0898ad6a3861ea984c5ea76658235b68df --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.icc @@ -0,0 +1,207 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + + +using namespace TrigCompositeUtils; + + +// L2Calo, L2Electron, L2Photon, EFCalo, Electron and Photon trigger passed access +template<class T> +inline bool TrigEgammaMatchingToolMT::ancestorPassed( const TrigCompositeUtils::Decision *dec, const std::string trigger, const std::string key) const +{ + + if( !dec ) return false; + HLT::Identifier id(trigger); + auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( dec, "initialRoI"); + if( !initRoi.link.isValid() ) + return false; + + auto vec = tdt()->features< T >(trigger,TrigDefs::includeFailedDecisions ,key); + + for( auto &featLinkInfo : vec ) + { + auto roi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(featLinkInfo.source, "initialRoI"); + if( ! roi.isValid()) continue; + if( (*roi.link)->roiWord() == (*initRoi.link)->roiWord()) + { + const auto *fDec = featLinkInfo.source; + return (std::find(fDec->decisions().begin(), fDec->decisions().end(), id.numeric()) != fDec->decisions().end()); + } + } + return false; +} + + +// L1Calo trigger passed access +template<> +inline bool TrigEgammaMatchingToolMT::ancestorPassed<TrigRoiDescriptorCollection>( const TrigCompositeUtils::Decision *dec, + const std::string trigger, const std::string /*key*/) const +{ + if( !dec ) return false; + HLT::Identifier id(trigger); + auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( dec, "initialRoI"); + if( !initRoi.link.isValid() ) + return false; + + auto vec = tdt()->features<TrigRoiDescriptorCollection>(trigger,TrigDefs::includeFailedDecisions,"", + TrigDefs::allFeaturesOfType,"initialRoI"); + + for( auto &featLinkInfo : vec ) + { + if( (*featLinkInfo.link)->roiWord() == (*initRoi.link)->roiWord()) + { + const auto *fDec = featLinkInfo.source; + return (std::find(fDec->decisions().begin(), fDec->decisions().end(), id.numeric()) != fDec->decisions().end()); + } + } + return false; +} + + + + +template<class T> +inline bool TrigEgammaMatchingToolMT::closestObject( const xAOD::Egamma *eg, const TrigCompositeUtils::Decision *&dec, std::string trigger, std::string key ) const +{ + double deltaR=0.; + auto vec = tdt()->features<T>(trigger,TrigDefs::includeFailedDecisions ,key); + for( auto &featLinkInfo : vec ){ + if(! featLinkInfo.isValid() ) continue; + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + deltaR = dR(eg->eta(),eg->phi(), feat->eta(),feat->phi()); + if(deltaR < (float)m_dR){ + dec = featLinkInfo.source; + return true; + } + } + return false; +} + + +template<class T> +inline std::vector<LinkInfo<T>> TrigEgammaMatchingToolMT::getFeatures( const TrigCompositeUtils::Decision *dec , std::string trigger, std::string key) +const +{ + std::vector<LinkInfo<T>> vec; + auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(dec, "initialRoI"); + if( !initRoi.link.isValid() ) return vec; + + auto vec_dec = tdt()->features<T>(trigger, TrigDefs::includeFailedDecisions, key); + for ( auto& featLinkInfo : vec_dec ){ + if( !featLinkInfo.isValid() ) continue; + auto roi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(featLinkInfo.source, "initialRoI"); + if( ! roi.isValid()) continue; + if( (*roi.link)->roiWord() == (*initRoi.link)->roiWord() ) + vec.push_back( featLinkInfo ); + } + return vec; +} + + +inline const xAOD::EmTauRoI* TrigEgammaMatchingToolMT::getL1Feature( const TrigCompositeUtils::Decision *dec ) const +{ + if( !dec ) return nullptr; + auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(dec, "initialRoI"); + if( !initRoi.link.isValid() ) return nullptr; + + SG::ReadHandle<xAOD::EmTauRoIContainer> l1_cont( m_emTauRoIKey, Gaudi::Hive::currentContext()); + if( !l1_cont.isValid() ) return nullptr; + + for( const auto *l1 : *l1_cont ){ + if ( l1->roiType() != xAOD::EmTauRoI::RoIType::EMRoIWord) continue; + if((*initRoi.link)->roiWord()==l1->roiWord()){ + return l1; + } + } + return nullptr; +} + + +// L1Calo +template<> +inline LinkInfo<TrigRoiDescriptorCollection> TrigEgammaMatchingToolMT::getFeature<TrigRoiDescriptorCollection>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(dec, "initialRoI"); + if( initRoi.link.isValid() ){ + auto vec_dec = tdt()->features<TrigRoiDescriptorCollection>(trigger,TrigDefs::includeFailedDecisions,"", + TrigDefs::allFeaturesOfType,"initialRoI"); + for( auto &featLinkInfo: vec_dec ){ + if( !featLinkInfo.isValid() ) continue; + if( (*featLinkInfo.link)->roiWord() == (*initRoi.link)->roiWord() ) return featLinkInfo; + } + } + return LinkInfo<TrigRoiDescriptorCollection>(); +} + + +// L2Calo +template<> +inline LinkInfo<xAOD::TrigEMClusterContainer> TrigEgammaMatchingToolMT::getFeature<xAOD::TrigEMClusterContainer>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + std::vector<LinkInfo<xAOD::TrigEMClusterContainer>> vec = getFeatures<xAOD::TrigEMClusterContainer>(dec, trigger, key("L2Calo") ); + return !vec.empty() ? vec.front() : LinkInfo<xAOD::TrigEMClusterContainer>(); +} + + +// L2Electron +template<> +inline std::vector<LinkInfo<xAOD::TrigElectronContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::TrigElectronContainer>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + return getFeatures<xAOD::TrigElectronContainer>(dec, trigger, key("L2Electron") ); +} + + +// L2Photon +template<> +inline std::vector<LinkInfo<xAOD::TrigPhotonContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::TrigPhotonContainer>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + return getFeatures<xAOD::TrigPhotonContainer>(dec, trigger, key("L2Photon") ); +} + + +// EFCalo +template<> +inline std::vector<LinkInfo<xAOD::CaloClusterContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::CaloClusterContainer>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + return getFeatures<xAOD::CaloClusterContainer>(dec, trigger, key("EFCalo") ); +} + + +// Electron +template<> +inline std::vector<LinkInfo<xAOD::ElectronContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::ElectronContainer>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + return getFeatures<xAOD::ElectronContainer>(dec, trigger, key("Electron") ); +} + + +// Photon +template<> +inline std::vector<LinkInfo<xAOD::PhotonContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::PhotonContainer>( const TrigCompositeUtils::Decision *dec , + std::string trigger) +const +{ + return getFeatures<xAOD::PhotonContainer>(dec, trigger, key("Photon") ); +} + + + + + + + + diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/share/job_match_test.py b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/share/job_match_test.py new file mode 100644 index 0000000000000000000000000000000000000000..4596816cbcbae6179069866e02e95be7c97d70af --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/share/job_match_test.py @@ -0,0 +1,59 @@ +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +from RecExConfig.RecFlags import rec +from RecExConfig.RecAlgsFlags import recAlgs +from InDetRecExample.InDetJobProperties import InDetFlags +InDetFlags.doSecVertexFinder.set_Value_and_Lock(False) +from AthenaCommon.AppMgr import ToolSvc + +import os + +outputName = 'Validation_asdf' + + +athenaCommonFlags.FilesInput=['AOD.pool.root'] +athenaCommonFlags.EvtMax=100 +#athenaCommonFlags.EvtMax=-1 +rec.readAOD=True +# switch off detectors +rec.doForwardDet=False +rec.doInDet=False +rec.doCalo=False +rec.doMuon=False +rec.doEgamma=False +rec.doTrigger = True; recAlgs.doTrigger=False # disable trigger (maybe necessary if detectors switched off) +rec.doMuon=False +rec.doMuonCombined=False +rec.doWriteAOD=False +rec.doWriteESD=False +rec.doDPD=False +rec.doTruth=False + + +# autoconfiguration might trigger undesired feature +rec.doESD.set_Value_and_Lock(False) # uncomment if do not run ESD making algorithms +rec.doWriteESD.set_Value_and_Lock(False) # uncomment if do not write ESD +rec.doAOD.set_Value_and_Lock(False) # uncomment if do not run AOD making algorithms +rec.doWriteAOD.set_Value_and_Lock(False) # uncomment if do not write AOD +rec.doWriteTAG.set_Value_and_Lock(False) # uncomment if do not write TAG +# main jobOption +triggerList = [ + 'HLT_e5_etcut', + ] +include ("RecExCommon/RecExCommon_topOptions.py") +ToolSvc.TrigDecisionTool.TrigDecisionKey='xTrigDecision' +from AthenaCommon.AlgSequence import AlgSequence +theJob = AlgSequence() + +from TrigEgammaMatchingTool.TrigEgammaMatchingToolConf import Trig__TrigEgammaMatchingTool +matchtool = Trig__TrigEgammaMatchingTool("MatchingTool"); +from AthenaCommon.AppMgr import ToolSvc +ToolSvc += matchtool + +from TrigEgammaMatchingTool.TrigEgammaMatchingToolConf import Trig__TrigEgammaMatchingToolTest +alg = Trig__TrigEgammaMatchingToolTest() +alg.TrigEgammaMatchingTool = matchtool +alg.TriggerList = triggerList +alg.OutputLevel = DEBUG +theJob += alg + +include("TriggerTest/TriggerTestCommon.py") diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/TrigEgammaMatchingToolMTTest.cxx b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/TrigEgammaMatchingToolMTTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..10ce7107557bb96c545b782bba049cf115503831 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/TrigEgammaMatchingToolMTTest.cxx @@ -0,0 +1,155 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "TrigEgammaMatchingToolMTTest.h" +#include "DecisionHandling/TrigCompositeUtils.h" + + + + +TrigEgammaMatchingToolMTTest::TrigEgammaMatchingToolMTTest(const std::string& name, ISvcLocator* pSvcLocator ) + : AthMonitorAlgorithm( name, pSvcLocator ), + m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"), + m_matchTool("Trig::TrigEgammaMatchingTool/TrigEgammaMatchingToolMT",this) + +{ + declareProperty("TrigEgammaMatchingToolMT",m_matchTool); + declareProperty("TriggerList",m_triggerList); +} + + + +//********************************************************************** + +StatusCode TrigEgammaMatchingToolMTTest::initialize() { + + ATH_MSG_INFO("Initializing " << name() << "..."); + + ATH_CHECK( m_trigdec.retrieve() ); + ATH_CHECK( m_matchTool.retrieve()); + ATH_CHECK(m_electronKey.initialize()); + + + + return StatusCode::SUCCESS; +} + + + +//********************************************************************** + +void TrigEgammaMatchingToolMTTest::inspect(const std::string trigger,const xAOD::Egamma *eg) const { + + if (eg) { + + ATH_MSG_INFO("Getting all associated objects for " << trigger); + + const TrigCompositeUtils::Decision *dec=nullptr; + + m_matchTool->match( eg, trigger , dec); + + if ( dec ) + { + ATH_MSG_INFO( "Matched!"); + + + auto l1_link = m_matchTool->getFeature<TrigRoiDescriptorCollection>(dec, trigger); + auto emCluster_link = m_matchTool->getFeature<xAOD::TrigEMClusterContainer>( dec , trigger); + auto trig_el_links = m_matchTool->getFeatures<xAOD::TrigElectronContainer>( dec, trigger ); + auto cl_links = m_matchTool->getFeatures<xAOD::CaloClusterContainer>( dec , trigger); + auto el_links = m_matchTool->getFeatures<xAOD::ElectronContainer>( dec , trigger); + + if( l1_link.isValid() ){ + ATH_MSG_INFO( "We found the Roi object link" ); + // Let's get the EMTau + auto l1 = m_matchTool->getL1Feature( l1_link.source ); + if(l1) + ATH_MSG_INFO( "We found the EmTau object" ); + ATH_MSG_INFO( "L1 object state is assigned as " << (l1_link.state==ActiveState::ACTIVE ? "Active" : "Not active") ); + } + + if( emCluster_link.isValid() ){ + ATH_MSG_INFO( "We found the EmCluster object link" ); + ATH_MSG_INFO( "L2Calo object state is assigned as " << (emCluster_link.state==ActiveState::ACTIVE ? "Active" : "Not active") ); + } + + if (trig_el_links.size() > 0){ + ATH_MSG_INFO ( "We found " << trig_el_links.size() << " TrigElectron link objects for this decision souce." ); + for ( auto featLinkInfo : trig_el_links ){ + ATH_MSG_INFO( "L2Electron object state is assigned as " << (featLinkInfo.state==ActiveState::ACTIVE ? "Active" : "Not active") ); + } + } + + if (cl_links.size() > 0){ + ATH_MSG_INFO ( "We found " << cl_links.size() << " CaloCluster link objects for this decision souce." ); + for ( auto featLinkInfo : cl_links ){ + ATH_MSG_INFO( "EFCalo object state is assigned as " << (featLinkInfo.state==ActiveState::ACTIVE ? "Active" : "Not active") ); + } + } + + if (el_links.size() > 0){ + ATH_MSG_INFO ( "We found " << el_links.size() << " CaloCluster link objects for this decision souce." ); + for ( auto featLinkInfo : el_links ){ + ATH_MSG_INFO( "EFCalo object state is assigned as " << (featLinkInfo.state==ActiveState::ACTIVE ? "Active" : "Not active") ); + } + } + + + bool passedHLT = m_matchTool->ancestorPassed<xAOD::ElectronContainer> (dec, trigger , "HLT_egamma_Electrons"); + bool passedEFCalo = m_matchTool->ancestorPassed<xAOD::CaloClusterContainer> (dec, trigger , "HLT_CaloEMClusters"); + bool passedL2 = m_matchTool->ancestorPassed<xAOD::TrigElectronContainer> (dec, trigger , "HLT_L2Electrons"); + bool passedL2Calo = m_matchTool->ancestorPassed<xAOD::TrigEMClusterContainer> (dec, trigger , "HLT_L2CaloEMClusters"); + bool passedL1Calo = m_matchTool->ancestorPassed<TrigRoiDescriptorCollection> (dec, trigger , "initialRois"); + + ATH_MSG_INFO( "L1Calo passed : "<< passedL1Calo ); + ATH_MSG_INFO( "L2Calo passed : "<< passedL2Calo ); + ATH_MSG_INFO( "L2 passed : "<< passedL2 ); + ATH_MSG_INFO( "EFCalo passed : "<< passedEFCalo ); + ATH_MSG_INFO( "HLT passed : "<< passedHLT ); + + }else{ + ATH_MSG_INFO( "Not Matched! There is no Dec object for this trigger " << trigger ); + } + + } + else ATH_MSG_INFO("REGTEST: eg pointer null!"); +} + + +//********************************************************************** + +StatusCode TrigEgammaMatchingToolMTTest::fillHistograms( const EventContext& ctx ) const { + + ATH_MSG_INFO ("Fill histograms " << name() << "..."); + + + SG::ReadHandle<xAOD::ElectronContainer> el_cont(m_electronKey, ctx); + + if( !el_cont.isValid() ){ + ATH_MSG_WARNING("Container "<< m_electronKey << " does not exist or is empty"); + return StatusCode::SUCCESS; + } + + + ATH_MSG_INFO("Offline Electron container size " << el_cont->size()); + + for(const auto &trigger : m_triggerList){ + for(const auto& eg : *el_cont){ + ATH_MSG_INFO("REGTEST:: Electron offline (eta="<<eg->eta()<<",phi="<<eg->phi()<<")"); + inspect(trigger,eg); + + } //End loop of offline electrons + } // End loop over trigger list + + + + return StatusCode::SUCCESS; +} // End execute + + + + + + diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/TrigEgammaMatchingToolMTTest.h b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/TrigEgammaMatchingToolMTTest.h new file mode 100644 index 0000000000000000000000000000000000000000..341b9c54133546f05d36efe8103fa52023876594 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/TrigEgammaMatchingToolMTTest.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef TrigEgammaMatchingToolMTTest_H +#define TrigEgammaMatchingToolMTTest_H + + +#include "TrigDecisionTool/TrigDecisionTool.h" +#include "TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h" +#include "xAODEgamma/ElectronContainer.h" +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "StoreGate/ReadHandleKey.h" +#include <vector> +#include <string> + + +class TrigEgammaMatchingToolMTTest : public AthMonitorAlgorithm { + public: + + TrigEgammaMatchingToolMTTest( const std::string& name, ISvcLocator* pSvcLocator ); + virtual StatusCode initialize() override; + virtual StatusCode fillHistograms( const EventContext& ctx ) const override; + + private: + + + void inspect(const std::string, const xAOD::Egamma *) const ; + + SG::ReadHandleKey<xAOD::ElectronContainer> m_electronKey{this , "ElectronKey", "Electrons", ""}; + + ToolHandle<Trig::TrigDecisionTool> m_trigdec; + ToolHandle<TrigEgammaMatchingToolMT> m_matchTool; + + + std::vector<std::string> m_triggerList; +}; + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/components/TrigEgammaMatchingTool_entries.cxx b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/components/TrigEgammaMatchingTool_entries.cxx index c0b951dcd651f8096b91932670e44430a0f3b6d2..589c376d1b11506f57cdffce4a37bf2c3d80a274 100644 --- a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/components/TrigEgammaMatchingTool_entries.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/src/components/TrigEgammaMatchingTool_entries.cxx @@ -1,6 +1,10 @@ #include "TrigEgammaMatchingTool/TrigEgammaMatchingTool.h" +#include "TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h" #include "../TrigEgammaMatchingToolTest.h" +#include "../TrigEgammaMatchingToolMTTest.h" DECLARE_COMPONENT( Trig::TrigEgammaMatchingTool ) +DECLARE_COMPONENT( TrigEgammaMatchingToolMT ) DECLARE_COMPONENT( Trig::TrigEgammaMatchingToolTest ) +DECLARE_COMPONENT( TrigEgammaMatchingToolMTTest ) diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt b/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt index aa819fa17e53feb02c78bc486d72fea63fadce7f..4c6582517f14a35cb24013a805e9a50ab2c4a122 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/CMakeLists.txt @@ -7,17 +7,68 @@ atlas_subdir( TrigEgammaMonitoring ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC - Trigger/TrigEvent/TrigCaloEvent - Trigger/TrigEvent/TrigInDetEvent - Trigger/TrigEvent/TrigParticle + Control/AthToolSupport/AsgTools + Event/xAOD/xAODCaloEvent + Event/xAOD/xAODEgamma + Event/xAOD/xAODEventInfo + Event/xAOD/xAODJet + Event/xAOD/xAODPrimitives + Event/xAOD/xAODTracking + Event/xAOD/xAODTrigCalo + Event/xAOD/xAODTrigEgamma + Event/xAOD/xAODTrigRinger + Event/xAOD/xAODTrigger + Event/xAOD/xAODTruth + Event/xAOD/xAODMissingET + Event/xAOD/xAODCaloRings + LumiBlock/LumiBlockComps + PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools + Reconstruction/RecoTools/RecoToolInterfaces + Reconstruction/egamma/egammaMVACalib + Trigger/TrigAnalysis/TrigDecisionTool + Trigger/TrigAnalysis/TrigEgammaAnalysisTools + Trigger/TrigAnalysis/TrigEgammaMatchingTool + Trigger/TrigConfiguration/TrigConfHLTData Trigger/TrigEvent/TrigSteeringEvent - Control/AthenaMonitoring ) + Trigger/TrigMonitoring/TrigHLTMonitoring + PhysicsAnalysis/AnalysisCommon/PATCore + PRIVATE + Control/AthenaBaseComps + Control/AthenaMonitoring + Control/StoreGate + GaudiKernel + Trigger/TrigConfiguration/TrigConfxAOD ) +# External dependencies: +find_package( Boost ) +find_package( ROOT COMPONENTS Core Hist Tree ) -# 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/*.h + src/*.cxx + src/components/*.cxx + 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 TrigConfHLTData TrigSteeringEvent TrigHLTMonitoringLib AthenaBaseComps AthenaMonitoringLib StoreGateLib SGtests GaudiKernel PATCoreLib TrigEgammaAnalysisToolsLib) + +# Install files from the package: + # Install files from the package: atlas_install_python_modules( python/*.py ) atlas_install_joboptions( share/*.py ) + + + + + + + + + + + + + + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategory.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategory.py index 1416e24a84cf4a3df7881693912df970e854e362..2d84219e60d20faacc6ba619c0c3e5e3707844e2 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategory.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategory.py @@ -1,5 +1,24 @@ # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +################################ +###### Run-3 develpments ####### +################################ +# Should be removed for future +monitoring_electron_Run3 = ['HLT_e3_etcut_L1EM3','HLT_e5_etcut_L1EM3','HLT_e7_etcut_L1EM3','HLT_e300_etcut_L1EM24VHI'] +monitoring_photon_Run3 = ['HLT_g5_etcut_L1EM3','HLT_g5_loose_L1EM3','HLT_g5_medium_L1EM3','HLT_g5_tight_L1EM3','HLT_g140_loose_L1EM24VH'] +monitoring_tags_Run3 = ['HLT_e26_lhtight_L1EM24VHI'] +monitoringTP_electron_Run3 = ['HLT_e26_lhtight_L1EM24VHI','HLT_e60_lhmedium_L1EM24VHI','HLT_e140_lhloose_L1EM24VHI'] +monitoringTP_Jpsiee_Run3 = [] + + + + +################################################ +# Official triggers +################################################ + + #Categories currently used by offline Egamma TO monitoring tool #Important to keep lists updated primary_single_ele = ['HLT_e24_lhtight_nod0','HLT_e26_lhtight_nod0','HLT_e28_lhtight_nod0','HLT_e60_lhmedium_nod0_L1EM24VHI','HLT_e80_lhmedium_nod0_L1EM24VHI','HLT_e140_lhloose_nod0_L1EM24VHI'] diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py index 681da8a14a93f254527417add884208b7ced7d25..c89e00654f0b2b4e00fd40f8059188e0dfb289aa 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py @@ -18,62 +18,45 @@ log_trigeg = logging.getLogger( 'TrigEgammaMonitorAlgorithm' ) def TrigEgammaMonConfig(inputFlags): '''Function to configures some algorithms in the monitoring system.''' + # The following class will make a sequence, configure algorithms, and link - # them to GenericMonitoringTools from AthenaMonitoring import AthMonitorCfgHelper - #from AthenaConfiguration.ComponentFactory import CompFactory - - - ##from TrigEgammaAnalysisToolsMT.TrigEgammaAnalysisToolsMTConf import TrigEgammaMonAlgorithm helper = AthMonitorCfgHelper(inputFlags,'TrigEgammaAthMonitorCfg') - ##monAlg = helper.addAlgorithm(TrigEgammaMonAlgorithm,'TrigEgammaMonAlg') - - - # configure alg and ana tools - ##from TrigEgammaMonitoring.TrigEgammaMonitoringMTConfig import TrigEgammaMonToolBuilder - # The last arg shold be an config flag for future - # The helper.resobj is the component accumulator created by the helper and will hold all - # algs and tools created by this configuration - ##montoolCfg = TrigEgammaMonToolBuilder( monAlg , "TrigEgammaMonAlg", helper.resobj, '2018') # Using 2018 e/g tunings - - - - - # configure all histograms - ##from TrigEgammaAnalysisToolsMT.TrigEgammaAnalysisMTBuilder import TrigEgammaAnalysisBuilder - ## get the histogram builder for all analysis tools for e/g staff. - ## link the algotihm and helper with the ana builder. - ## All generic monitoring tools will be attached inside of the monAlg and componenet accumulator - ##anatoolCfg = TrigEgammaAnalysisBuilder( helper, monAlg, 'TrigEgammaMonAlg', montoolCfg.basePath , - ## montoolCfg.detailLevel) - - - - - # Get only unique triggers - #triggerList = [] - #for anaTool in montoolCfg.anaTools: - # triggerList.extend(anaTool.TriggerList) - - - # Check there is duplicate trigger into the trigger list. If we have, abort - #if not (len(triggerList) == len(set(triggerList))): - # raise RuntimeError( "There are duplicate trigger into the e/g monitoring list.") - - + from TrigEgammaMonitoring.TrigEgammaMonitoringMTConfig import TrigEgammaMonAlgBuilder + monAlgCfg = TrigEgammaMonAlgBuilder( helper, '2018', detailedHistogram=True ) # Using 2018 e/g tunings + + # Force monitor builder + monAlgCfg.activate_zee=False + monAlgCfg.activate_jpsiee=False + monAlgCfg.activate_electron=True + monAlgCfg.activate_photon=False + # build monitor and book histograms + monAlgCfg.configure() - # Attach the histogram manager my monAlg that pointet to "TrigEgammaMonAlg" - # All hisograms will be "TrigEgammaMonAlg/HLT/Egamma/trigger/..." where - # "TrigEgammaMonAlg" is the monname and HLT/Egamma is the basepath - #for trigger in triggerList: - # anatoolCfg.bookTriggerHistograms( trigger , doJpsiee = True if 'Jpsi' in anaTool.name() else False ) + # Test matching tool + # The following class will make a sequence, configure algorithms, and link + #from AthenaMonitoring import AthMonitorCfgHelper + #helper = AthMonitorCfgHelper(inputFlags,'TrigEgammaAthMonitorCfg') + #from TrigEgammaMatchingTool.TrigEgammaMatchingToolConf import TrigEgammaMatchingToolMTTest, Trig__TrigEgammaMatchingToolMT + #mon = helper.addAlgorithm( TrigEgammaMatchingToolMTTest, "TrigEgammaMatchingToolMTTest" ) + #triggers = [ + # "HLT_e26_etcut_L1EM22VHI", + # "HLT_e26_lhtight_L1EM24VHI", + # "HLT_e300_etcut_L1EM24VHI", + # "HLT_e3_etcut_L1EM3", + # "HLT_e5_etcut_L1EM3", + # "HLT_e7_etcut_L1EM3", + # ] + #tool = Trig__TrigEgammaMatchingToolMT("MatchingTool") + #mon.TrigEgammaMatchingToolMT = tool + #mon.TriggerList = triggers + #helper.resobj.addPublicTool(tool) + - #for anaTool in montoolCfg.anaTools: - # anatoolCfg.bookEventHistograms( anaTool ) @@ -97,15 +80,14 @@ if __name__=='__main__': # Setup logs from AthenaCommon.Logging import log - from AthenaCommon.Constants import DEBUG - log.setLevel(DEBUG) + from AthenaCommon.Constants import INFO + log.setLevel(INFO) # Set the Athena configuration flags from AthenaConfiguration.AllConfigFlags import ConfigFlags - nightly = '/eos/user/f/fernando/data18_13TeV/' - file = 'AOD.15529645._000080.pool.root.1' - ConfigFlags.Input.Files = [nightly+file] + path = '/afs/cern.ch/work/j/jodafons/public/valid_sampleA/AOD.20745922._000041.pool.root.1' + ConfigFlags.Input.Files = [path] ConfigFlags.Input.isMC = False ConfigFlags.Output.HISTFileName = 'TrigEgammaMonitorOutput.root' @@ -123,7 +105,7 @@ if __name__=='__main__': # If you want to turn on more detailed messages ... - trigEgammaMonitorAcc.getEventAlgo('TrigEgammaMonAlg').OutputLevel = 2 # DEBUG - cfg.printConfig(withDetails=True) # set True for exhaustive info + #trigEgammaMonitorAcc.getEventAlgo('TrigEgammaMonAlg').OutputLevel = 2 # DEBUG + cfg.printConfig(withDetails=False) # set True for exhaustive info cfg.run(10) #use cfg.run(20) to only run on first 20 events diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorHelper.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorHelper.py new file mode 100644 index 0000000000000000000000000000000000000000..f45bb179e4cd06cbb0c936e21a7be56fc2aa6378 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorHelper.py @@ -0,0 +1,90 @@ +# +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# + +'''@file TrigEgammaMonitoringConfigRun3.py +@author D. Maximov +@date 2019-07-08 +@brief Run 3 configuration builder. Histograms definitions taken from TrigEgammaPlotTool +''' + + + +class THWrapper(object): + def __init__(self, name): + self.name = name + self.kwargs = {} + + def __setitem__(self, key, value): + self.kwargs[key] = value + + + + +def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs): + + res = THWrapper(name) + res['type'] = 'TH1F' + res['title'] = title + + if isinstance(bins_par2, (list, tuple) ): # signature 2 + res['xbins'] = bins_par2 + else: # signature 1 + res['xbins'] = nxbins + res['xmin'] = bins_par2 + res['xmax'] = bins_par3 + + res['path'] = path + res.kwargs.update(kwargs) + return res + + + + + +def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='/', **kwargs): + + res = THWrapper(name) + res['type'] = 'TH2F' + res['title'] = title + + if isinstance(bins_par2, (list, tuple) ): # signature 2 or 4 + res['xbins'] = bins_par2 + if isinstance(bins_par4, (list, tuple) ): # signature 4 + res['ybins'] = bins_par4 + else: # signature 2 + res['ybins'] = bins_par3 + res['ymin'] = bins_par4 + res['ymax'] = bins_par5 + + else: # signature 1 or 3 + res['xbins'] = nxbins + res['xmin'] = bins_par2 + res['xmax'] = bins_par3 + if isinstance(bins_par5, (list, tuple) ): # signature 3 + res['ybins'] = bins_par5 + else: # signature 1 + res['ybins'] = bins_par4 + res['ymin'] = bins_par5 + res['ymax'] = bins_par6 + + res['path'] = path + res.kwargs.update(kwargs) + return res + + + + + + + +def TProfile(*args, **kwargs): + res = TH1F(*args, **kwargs) + res.name = res.name + res['type'] = 'TProfile' + return res + + + + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..88818fbf724b9ce7a16097aa2438a875e5054e56 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py @@ -0,0 +1,631 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +'''@file TrigEgammaMonitoringConfigRun3.py +@author D. Maximov (histograms), Joao victor Pinto (core) +@date 2019-07-08 +@brief Run 3 configuration builder. Histograms definitions taken from TrigEgammaPlotTool +''' + +from AthenaCommon.Constants import DEBUG +from TrigEgammaMonitoring.TrigEgammaMonitCategory import monitoring_tags_Run3, monitoring_electron_Run3, monitoring_photon_Run3, monitoringTP_electron_Run3, monitoringTP_Jpsiee_Run3 +#from TrigEgammaAnalysisTools.TrigEgammaProbelist import monitoring_electron, monitoring_photon, monitoringTP_electronJpsiee, monitoringTP_electron +from TrigEgammaHypo.TrigEgammaPidTools import ElectronPidTools +from TrigEgammaHypo.TrigEgammaPidTools import PhotonPidTools +import cppyy + +from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.ComponentFactory import CompFactory as CfgMgr + + +if 'DQMonFlags' not in dir(): + from AthenaMonitoring.DQMonFlags import DQMonFlags as dqflags + + + + +class TrigEgammaMonAlgBuilder: + + _configured = False + _get_monitoring_mode_success = False + + data_type = '' + pp_mode = False + pPb_mode = False + HI_mode = False + cosmic_mode = False + mc_mode = False + activate_electron = False + activate_photon = False + activate_zee = False + activate_jpsiee = False + tagItems = [] + JpsitagItems = [] + electronList = [] + photonList = [] + tpList = [] + jpsiList = [] + + # Monitoring algorithms + zeeMonAlg = None + jpsieeMonAlg = None + elMonAlg = None + phMonAlg = None + + + # Add a flag to enable emulation + __acceptable_keys_list=['derivation','emulation', 'debugLevel', 'detailedHistograms','basePath'] + emulation = False + derivation = False + debugLevel = DEBUG + detailedHistograms = False + basePath = 'HLT/EgammaMon' + + + isemnames = ["Tight", "Medium", "Loose"] + lhnames = ["LHTight", "LHMedium", "LHLoose"] + + + def __init__(self, helper, runflag, **kwargs): + + from AthenaCommon.Logging import logging + self.__logger = logging.getLogger( 'TrigEgammaMonAlgBuilder' ) + self.runFlag = runflag + self.helper = helper + if not self._configured: + for key,value in kwargs.items(): + if key in self.__acceptable_keys_list: + setattr(self,key,value) + self.configureMode() + + + + def configureMode(self): + + self.__logger.info("TrigEgammaMonToolBuilder.configureMode()") + self._get_monitoring_mode_success = self.get_monitoring_mode() + if self._get_monitoring_mode_success is False: + self.__logger.warning("HLTMonTriggerList: Error getting monitoring mode, default monitoring lists will be used.") + else: + self.__logger.info("Configuring for %s", self.data_type) + + # Since we load the tools by name below + # Need to ensure the correct tools are configured + # for each monitoring mode + if self.mc_mode is True or self.pp_mode is True: + if(self.derivation is True or self.emulation is True): + self.activate_zee = True + else: + self.activate_zee=True + self.activate_jpsiee=True + self.activate_electron=True + self.activate_photon=True + elif self.HI_mode is True or self.pPb_mode is True or self.cosmic_mode is True: + self.activate_electron=True + self.activate_photon=True + else: + self.activate_zee=True + self.activate_jpsiee=True + self.activate_electron=True + self.activate_photon=True + + + def configure(self): + self.setProperties() + self.configureMonitor() + self.configureHistograms() + + + + + # Implementation of https://its.cern.ch/jira/browse/ATR-13200 + def get_monitoring_mode(self): + + self.__logger.info("TrigEgammaMonToolBuilder.get_monitoring_mode()") + self.data_type = dqflags.monManDataType() + if self.data_type == 'monteCarlo': + self.mc_mode = True + return True + elif self.data_type == 'collisions': + self.pp_mode = True + return True + elif self.data_type == 'heavyioncollisions': + self.HI_mode = True + self.pPb_mode = True + return True + elif self.data_type == 'cosmics': + self.cosmic_mode = True + return True + else: + return False + + + def setProperties(self): + + self.__logger.info("TrigEgammaMonToolBuilder.setProperties()") + self.basePath = 'HLT/EgammaMon' + self.tagItems = monitoring_tags_Run3 + self.JpsitagItems = [] + + if self.pp_mode is True: + self.setDefaultProperties() + elif self.cosmic_mode is True: + # This should be change in future + self.setDefaultProperties() + elif self.HI_mode is True or self.pPb_mode is True: + # This should be change in future + self.setDefaultProperties() + elif self.mc_mode is True: + # This should be change in future + self.setDefaultProperties() + else: + self.__logger.info('No monitoring mode configured, use default') + self.setDefaultProperties() + + + self.__logger.info('Configuring TP electron chains %s',self.tpList) + self.__logger.info('Configuring electron chains %s',self.electronList) + self.__logger.info('Configuring photon chains %s',self.photonList) + + + + def setDefaultProperties(self): + + self.electronList = monitoring_electron_Run3 + self.photonList = monitoring_photon_Run3 + self.tpList = monitoringTP_electron_Run3 + self.jpsiList = monitoringTP_Jpsiee_Run3 + + + # + # Create all minitor algorithms + # + def configureMonitor( self ): + + acc = self.helper.resobj + EgammaMatchTool = CompFactory.TrigEgammaMatchingToolMT() + EgammaMatchTool.OutputLevel=2 + EgammaMatchTool.DeltaR=0.4 + acc.addPublicTool(EgammaMatchTool) + cppyy.loadDictionary('ElectronPhotonSelectorToolsDict') + # Following loads the online selectors + + # setup all pid tools + ElectronPidTools() + PhotonPidTools() + + # Offline selectors -- taken from latest conf + LooseElectronSelector = CfgMgr.AsgElectronIsEMSelector("T0HLTLooseElectronSelector") + MediumElectronSelector = CfgMgr.AsgElectronIsEMSelector("T0HLTMediumElectronSelector") + TightElectronSelector = CfgMgr.AsgElectronIsEMSelector("T0HLTTightElectronSelector") + LooseLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTLooseLHSelector") + MediumLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTMediumLHSelector") + TightLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTTightLHSelector") + VeryLooseLHSelector = CfgMgr.AsgElectronLikelihoodTool("T0HLTVeryLooseLHSelector") + + acc.addPublicTool(LooseElectronSelector) + acc.addPublicTool(MediumElectronSelector) + acc.addPublicTool(TightElectronSelector) + acc.addPublicTool(LooseLHSelector) + acc.addPublicTool(MediumLHSelector) + acc.addPublicTool(TightLHSelector) + acc.addPublicTool(VeryLooseLHSelector) + + if self.runFlag == '2018': + # cut based + LooseElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMLooseSelectorCutDefs.conf" + MediumElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMMediumSelectorCutDefs.conf" + TightElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMTightSelectorCutDefs.conf" + # 2018 (vtest) + LooseLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodLooseOfflineConfig2017_CutBL_Smooth.conf" + MediumLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodMediumOfflineConfig2017_Smooth.conf" + TightLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodTightOfflineConfig2017_Smooth.conf" + VeryLooseLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20170828/ElectronLikelihoodVeryLooseOfflineConfig2017_Smooth.conf" + elif self.runFlag == '2017': + # cut based + LooseElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMLooseSelectorCutDefs.conf" + MediumElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMMediumSelectorCutDefs.conf" + TightElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/ElectronIsEMTightSelectorCutDefs.conf" + # 2017 (v11) + LooseLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth.conf" + MediumLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth.conf" + TightLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodTightOfflineConfig2016_Smooth.conf" + VeryLooseLHSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth.conf" + else: + # raise since the configuration its not defined + raise RuntimeError( 'Wrong run flag configuration' ) + + + if self.activate_zee: + + self.__logger.info( "Creating the Zee monitor algorithm...") + self.zeeMonAlg = self.helper.addAlgorithm( CompFactory.TrigEgammaMonitorTagAndProbeAlgorithm, "TrigEgammaMonitorTagAndProbeAlgorithm_Zee" ) + self.zeeMonAlg.Analysis='Zee' + self.zeeMonAlg.MatchTool = EgammaMatchTool + self.zeeMonAlg.TPTrigger=False + self.zeeMonAlg.ElectronKey = 'Electrons' + self.zeeMonAlg.isEMResultNames=self.isemnames + self.zeeMonAlg.LHResultNames=self.lhnames + self.zeeMonAlg.ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector] + self.zeeMonAlg.ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector] + self.zeeMonAlg.ZeeLowerMass=80 + self.zeeMonAlg.ZeeUpperMass=100 + self.zeeMonAlg.OfflineTagMinEt=25 + self.zeeMonAlg.OfflineTagSelector='LHTight' + self.zeeMonAlg.OfflineProbeSelector='LHLoose' + self.zeeMonAlg.OppositeCharge=True + self.zeeMonAlg.RemoveCrack=False + self.zeeMonAlg.TagTriggerList=self.tagItems + self.zeeMonAlg.TriggerList=self.tpList + self.zeeMonAlg.DetailedHistograms=self.detailHistograms + self.zeeMonAlg.OutputLevel=self.debugLevel + + + if self.activate_jpsiee: + + self.__logger.info( "Creating the Jpsiee monitor algorithm...") + self.jpsieeMonAlg = self.helper.addAlgorithm( CompFactory.TrigEgammaMonitorTagAndProbeAlgorithm, "TrigEgammaMonitorTagAndProbeAlgorithm_Jpsiee" ) + self.jpsieeMonAlg.DoJpsiee=True + self.jpsieeMonAlg.Analysis='Jpsiee' + self.jpsieeMonAlg.MatchTool = EgammaMatchTool + self.jpsieeMonAlg.TPTrigger=False + self.jpsieeMonAlg.ElectronKey = 'Electrons' + self.jpsieeMonAlg.isEMResultNames=self.isemnames + self.jpsieeMonAlg.LHResultNames=self.lhnames + self.jpsieeMonAlg.ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector] + self.jpsieeMonAlg.ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector] + self.jpsieeMonAlg.ZeeLowerMass=2 + self.jpsieeMonAlg.ZeeUpperMass=5 + self.jpsieeMonAlg.OfflineTagMinEt=5 + self.jpsieeMonAlg.OfflineTagSelector='LHTight' + self.jpsieeMonAlg.OfflineProbeSelector='LHLoose' + self.jpsieeMonAlg.OppositeCharge=True + self.jpsieeMonAlg.RemoveCrack=False + self.jpsieeMonAlg.TagTriggerList=self.tagItems + self.jpsieeMonAlg.TriggerList=self.tpList + self.jpsieeMonAlg.DetailedHistograms=self.detailedHistograms + self.jpsieeMonAlg.OutputLevel=self.debugLevel + + + if self.activate_electron: + + self.__logger.info( "Creating the Electron monitor algorithm...") + self.elMonAlg = self.helper.addAlgorithm( CompFactory.TrigEgammaMonitorElectronAlgorithm, "TrigEgammaMonitorElectronAlgorithm" ) + self.elMonAlg.MatchTool = EgammaMatchTool + self.elMonAlg.ElectronKey = 'Electrons' + self.elMonAlg.isEMResultNames=self.isemnames + self.elMonAlg.LHResultNames=self.lhnames + self.elMonAlg.ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector] + self.elMonAlg.ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector] + self.elMonAlg.ForcePidSelection=False + self.elMonAlg.ForceProbeIsolation=False + self.elMonAlg.ForceEtThreshold=True + self.elMonAlg.TriggerList=self.electronList + self.elMonAlg.DetailedHistograms=self.detailedHistograms + self.elMonAlg.OutputLevel=self.debugLevel + + if self.activate_photon: + + self.__logger.info( "Creating the Photon monitor algorithm...") + self.phMonAlg = self.helper.addAlgorithm( CompFactory.TrigEgammaMonitorPhotonAlgorithm, "TrigEgammaMonitorPhotonAlgorithm" ) + self.phMonAlg.MatchTool = EgammaMatchTool + self.phMonAlg.PhotonKey = 'Photons' + self.phMonAlg.isEMResultNames=self.isemnames + self.phMonAlg.LHResultNames=self.lhnames + self.phMonAlg.ElectronIsEMSelector =[TightElectronSelector,MediumElectronSelector,LooseElectronSelector] + self.phMonAlg.ElectronLikelihoodTool =[TightLHSelector,MediumLHSelector,LooseLHSelector] + self.phMonAlg.TriggerList=self.tpList + self.phMonAlg.DetailedHistograms=self.detailedHistograms + self.phMonAlg.OutputLevel=self.debugLevel + + + + + def configureHistograms(self): + + if self.activate_zee and self.zeeMonAlg: + self.setBinning() + self.bookEvent( self.zeeMonAlg, self.zeeMonAlg.Analysis ) + triggers = self.zeeMonAlg.TriggerList; triggers.extend( self.zeeMonAlg.TagTriggerList ) + self.bookExpertHistograms( self.zeeMonAlg, triggers ) + if self.activate_jpsiee and self.jpsieeMonAlg: + self.setBinning(True) + self.bookEvent( self.jpsieeMonAlg, self.jpsieeMonAlg.Analysis ) + triggers = self.jpsieeMonAlg.TriggerList; triggers.extend( self.jpsieeMonAlg.TagTriggerList ) + self.bookExpertHistograms( self.jpsieeMonAlg, triggers ) + + self.setBinning() + if self.activate_electron and self.elMonAlg: + self.bookExpertHistograms( self.elMonAlg, self.elMonAlg.TriggerList ) + if self.activate_photon and self.phMonAlg: + self.bookExpertHistograms( self.phMonAlg, self.phMonAlg.TriggerList ) + + + + def addGroup( self, monAlg, name, path ): + return self.helper.addGroup( monAlg, name, path ) + + def addHistogram(self, monGroup, hist): + monGroup.defineHistogram(hist.name, **hist.kwargs) + + + # + # Booking all histograms + # + def bookExpertHistograms( self, monAlg, triggers ): + + self.__logger.info( "Booking all histograms for alg: %s", monAlg.name ) + + for trigger in triggers: + self.bookL1CaloDistributions( monAlg, trigger ) + self.bookL2CaloDistributions( monAlg, trigger ) + self.bookL2ElectronDistributions( monAlg, trigger ) + self.bookEFCaloDistributions( monAlg, trigger ) + self.bookShowerShapesAndTrackingDistributions( monAlg, trigger, online=True ) + self.bookShowerShapesAndTrackingDistributions( monAlg, trigger, online=False ) + self.bookEfficiencies( monAlg, trigger, "L1Calo" ) + self.bookEfficiencies( monAlg, trigger, "L2Calo" ) + self.bookEfficiencies( monAlg, trigger, "L2" ) + self.bookEfficiencies( monAlg, trigger, "EFCalo" ) + self.bookEfficiencies( monAlg, trigger, "HLT" ) + + if self.detailedHistograms: + for pid in self.isemnames + self.lhnames: + self.bookEfficiencies( monAlg, trigger, "HLT", pid ) + self.bookEfficiencies( monAlg, trigger, "HLT", pid+"Iso" ) + + + + def bookEvent(self, monAlg, analysis): + + #cutLabels = ["Events","LAr","RetrieveElectrons","TwoElectrons","PassTrigger","EventWise","Success"] + #probeLabels=["Electrons","NotTag","OS","SS","ZMass","HasTrack","HasCluster","Eta","Et","IsGoodOQ","GoodPid","NearbyJet","Isolated"] + # Create mon group. The group name should be the path name for map + monGroup = self.addGroup( monAlg, 'Event', self.basePath+'/Expert/Event' ) + monGroup.defineHistogram(analysis+"_CutCounter", type='TH1I', path='/', title="Event Selection; Cut ; Count",xbins=6, xmin=0, xmax=6) + monGroup.defineHistogram(analysis+"_TagCutCounter", type='TH1F', path='', title="Number of Probes; Cut ; Count",xbins=12, xmin=0, xmax=12) + monGroup.defineHistogram(analysis+"_ProbeCutCounter", type='TH1F', path='', title="Number of Probes; Cut ; Count",xbins=12, xmin=0, xmax=12) + monGroup.defineHistogram(analysis+"_Mee", type='TH1F', path='/', title="Offline M(ee); m_ee [GeV] ; Count",xbins=50, xmin=monAlg.ZeeLowerMass, xmax=monAlg.ZeeUpperMass) + + + # + # Book L1Calo distributions + # + def bookL1CaloDistributions( self , monAlg, trigger ): + + from TrigEgammaMonitoring.TrigEgammaMonitorHelper import TH1F + monGroup = self.addGroup( monAlg, trigger+'_Distributions_L1Calo', self.basePath+'/'+trigger+'/Distributions/L1Calo' ) + + self.addHistogram(monGroup, TH1F("energy", "Cluster Energy; E [GeV] ; Count", 100, 0., 200.)) + self.addHistogram(monGroup, TH1F("roi_eta", "RoI word Cluster Energy; E [GeV] ; Count", 100, 0, 200)) + self.addHistogram(monGroup, TH1F("emIso", "EM Isolation; E [GeV] ; Count", 50, -1., 20.)) + self.addHistogram(monGroup, TH1F("hadCore", "HAD Isolation; E [GeV] ; Count", 50, -1., 20.)) + self.addHistogram(monGroup, TH1F("eta", "eta; eta ; Count", 50, -2.5, 2.5)) + self.addHistogram(monGroup, TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)) + + + + # + # Book L2Calo distributions + # + def bookL2CaloDistributions( self , monAlg, trigger ): + + from TrigEgammaMonitoring.TrigEgammaMonitorHelper import TH1F + monGroup = self.addGroup( monAlg, trigger+'_Distributions_L2Calo', self.basePath+'/'+trigger+'/Distributions/L2Calo' ) + + self.addHistogram(monGroup, TH1F("et", "ET; ET [GeV] ; Count", 100, 0., 100.)) + self.addHistogram(monGroup, TH1F("eta", "eta; eta ; Count", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)) + + + # + # book L2 Electron distributions + # + def bookL2ElectronDistributions( self, monAlg, trigger ): + + from TrigEgammaMonitoring.TrigEgammaMonitorHelper import TH1F + monGroup = self.addGroup( monAlg, trigger+'_Distributions_L2Electron', self.basePath+'/'+trigger+'/Distributions/L2' ) + + self.addHistogram(monGroup, TH1F("et", "ET; ET [GeV] ; Count", 100, 0., 100.)) + self.addHistogram(monGroup, TH1F("eta", "eta; eta ; Count", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)) + + + # + # Book EFCalo distributions + # + def bookEFCaloDistributions( self, monAlg, trigger ): + + from TrigEgammaMonitoring.TrigEgammaMonitorHelper import TH1F + monGroup = self.addGroup( monAlg, trigger+'_Distributions_EFCalo', self.basePath+'/'+trigger+'/Distributions/EFCalo' ) + + self.addHistogram(monGroup, TH1F("et", "ET; ET [GeV] ; Count", 100, 0., 100.)) + self.addHistogram(monGroup, TH1F("eta", "eta; eta ; Count", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)) + self.addHistogram(monGroup, TH1F("energy", "Cluster Energy; E [GeV] ; Count", 50, 0., 100.)) + self.addHistogram(monGroup, TH1F("eta_calo", "eta_calo; eta_calo ; Count", 50, -2.47, 2.47)) + self.addHistogram(monGroup, TH1F("phi_calo", "phi_calo; phi_calo ; Count", 50, -3.14, 3.14)) + self.addHistogram(monGroup, TH1F("energyBE0", "Cluster Energy BE0; E [GeV] ; Count", 50, 0., 100.)) + self.addHistogram(monGroup, TH1F("energyBE1", "Cluster Energy BE1; E [GeV] ; Count", 50, 0., 100.)) + self.addHistogram(monGroup, TH1F("energyBE2", "Cluster Energy BE2; E [GeV] ; Count", 50, 0., 100.)) + self.addHistogram(monGroup, TH1F("energyBE3", "Cluster Energy BE3; E [GeV] ; Count", 50, 0., 100.)) + + + + # + # Book Shower shapes + # + def bookShowerShapesAndTrackingDistributions( self, monAlg, trigger, online=True ): + + from TrigEgammaMonitoring.TrigEgammaMonitorHelper import TH1F + monGroup = self.addGroup( monAlg, trigger+'_Distributions_' + ("HLT" if online else "Offline"), + self.basePath+'/'+trigger+'/Distributions/' + ("HLT" if online else "Offline") ) + + self.addHistogram(monGroup, TH1F("ethad", "ethad; ethad ; Count", 20, -10, 10)) + self.addHistogram(monGroup, TH1F("ethad1", "ethad1; ehad1 ; Count", 20, -10, 10)) + self.addHistogram(monGroup, TH1F("Rhad", "Rhad; Rhad ; Count", 35, -0.3, 0.3)) + self.addHistogram(monGroup, TH1F("Rhad1", "Rhad1; Rhad1 ; Count", 30, -0.3, 0.3)) + self.addHistogram(monGroup, TH1F("Reta", "Reta; Reta ; Count", 15, 0., 1.5)) + self.addHistogram(monGroup, TH1F("Rphi", "Rphi; Rphi ; Count", 15, 0., 1.5)) + self.addHistogram(monGroup, TH1F("weta1", "weta1; weta1 ; Count", 12, 0.4, 1.)) + self.addHistogram(monGroup, TH1F("weta2", "weta2; weta2 ; Count", 20, 0., 0.02)) + self.addHistogram(monGroup, TH1F("f1", "f1; f1 ; Count", 11, -0.1, 1.)) + self.addHistogram(monGroup, TH1F("f3", "f3; f3 ; Count", 21, -0.1, 0.2)) + self.addHistogram(monGroup, TH1F("eratio","eratio; eratio; Count",20, 0, 2)) + self.addHistogram(monGroup, TH1F("et", "ET; ET [GeV] ; Count", 100, 0., 100.)) + self.addHistogram(monGroup, TH1F("highet", "Offline E_{T}; E_{T} [GeV] ; Count", 100, 0., 2000.)) + self.addHistogram(monGroup, TH1F("eta", "eta; eta ; Count", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TH1F("phi", "phi; phi ; Count", 20, -3.2, 3.2)) + self.addHistogram(monGroup, TH1F("topoetcone20", "topoetcone20; topoetcone20 [GeV] ; Count", 100, -10.0, 10.0)) + self.addHistogram(monGroup, TH1F("topoetcone20_rel", "topoetcone20/pt; topoetcone20/pt ; Count", 100, -0.5, 0.5)) + self.addHistogram(monGroup, TH1F("topoetcone40_shift", "topoetcone40-2.45 GeV; topoetcone40-2.45 GeV [GeV] ; Count", 100, -10.0, 10.0)) + self.addHistogram(monGroup, TH1F("topoetcone40_shift_rel", "(topoetcone40-2.45 GeV)/pt; (topoetcone40-2.45 GeV)/pt ; Count", 100, -0.5, 0.5)) + + + # Tracking quantities + self.addHistogram(monGroup, TH1F("deta1", "deta1; deta1 ; Count", 40, -0.01, 0.01)) + self.addHistogram(monGroup, TH1F("deta1_EMECA", "deta1 EMEC-A; deta1 ; Count", 40, -0.01, 0.01)) + self.addHistogram(monGroup, TH1F("deta1_EMECC", "deta1 EMEC-C; deta1 ; Count", 40, -0.01, 0.01)) + self.addHistogram(monGroup, TH1F("deta1_EMEBA", "deta1 EMEB-A; deta1 ; Count", 40, -0.01, 0.01)) + self.addHistogram(monGroup, TH1F("deta1_EMEBC", "deta1 EMEB-A; deta1 ; Count", 40, -0.01, 0.01)) + self.addHistogram(monGroup, TH1F("deta2", "deta2; deta2 ; Count", 40, -0.01, 0.01)) + self.addHistogram(monGroup, TH1F("dphi2", "dphi2; dphi2 ; Count", 40, -0.1, 0.1)) + self.addHistogram(monGroup, TH1F("dphiresc", "dphiresc; dphiresc ; Count", 40, -0.1, 0.1)) + self.addHistogram(monGroup, TH1F("eprobht","eProbHT; eProbHT; Count",20, 0, 1.)) + self.addHistogram(monGroup, TH1F("npixhits","nPixHit; nPixHits; Count",10, 0, 10)) + self.addHistogram(monGroup, TH1F("nscthits","nSCTHit; nSCTHits; Count",20, 0, 20)) + self.addHistogram(monGroup, TH1F("charge","charge; charge; Count", 4,-2,2)) + self.addHistogram(monGroup, TH1F("ptcone20", "ptcone20; ptcone20; Count", 50, 0.0, 5.0)) + self.addHistogram(monGroup, TH1F("ptvarcone20", "ptcone20; ptcone20; Count", 50, 0.0, 5.0)) + self.addHistogram(monGroup, TH1F("d0", "d0; d0 ; Count", 40, -1, 1)) + self.addHistogram(monGroup, TH1F("d0sig", "d0sig; d0sig ; Count", 40, -10, 10)) + self.addHistogram(monGroup, TH1F("pt", "p_{T}; p_{T} [GeV] ; Count", 100,0.,100.)) + self.addHistogram(monGroup, TH1F("ptcone20_rel", "ptcone20/pt; ptcone20/pt; Count", 50, 0.0, 1.0)) + self.addHistogram(monGroup, TH1F("ptvarcone20_rel", "ptcone20/pt; ptcone20/pt; Count", 50, 0.0, 1.0)) + + + # + # Book efficiencies + # + def bookEfficiencies(self, monAlg, trigger, level, subgroup=None ): + + from TrigEgammaMonitoring.TrigEgammaMonitorHelper import TH1F, TProfile + if subgroup: + monGroup = self.addGroup( monAlg, trigger+'_Efficiency_'+level+'_'+subgroup, self.basePath+'/'+trigger+'/Efficiency/'+level+'/'+subgroup ) + else: + monGroup = self.addGroup( monAlg, trigger+'_Efficiency_'+level, self.basePath+'/'+trigger+'/Efficiency/'+level ) + + + + # Numerator + self.addHistogram(monGroup, TH1F("match_pt", "Trigger Matched Offline p_{T}; p_{T} [GeV] ; Count", self._nEtbins, self._etbins)) + self.addHistogram(monGroup, TH1F("match_et", "Trigger Matched Offline E_{T}; E_{T} [GeV]; Count", self._nEtbins, self._etbins)) + self.addHistogram(monGroup, TH1F("match_highet", "Trigger Matched Offline E_{T}; E_{T} [GeV]; Count", 40, 0., 1000.)) + self.addHistogram(monGroup, TH1F("match_eta", "Trigger Matched Offline #eta; #eta ; Count", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TH1F("match_phi", "Trigger Matched #phi; #phi ; Count", 20, -3.2, 3.2)) + self.addHistogram(monGroup, TH1F("match_avgmu", "Trigger Matched <#mu>; <#mu> ; Count", 16, 0, 80)) + self.addHistogram(monGroup, TH1F("match_npvtx", "Trigger Matched npvtx; npvtx ; Count", 16, 0, 80)) + + # Denominator + self.addHistogram(monGroup, TH1F("pt", "Offline p_{T}; p_{T} [GeV] ; Count", self._nEtbins, self._etbins)) + self.addHistogram(monGroup, TH1F("et", "Offline E_{T}; E_{T} [GeV] ; Count", self._nEtbins, self._etbins)) + self.addHistogram(monGroup, TH1F("highet", "Offline E_{T}; E_{T} [GeV] ; Count", 40, 0., 1000.)) + self.addHistogram(monGroup, TH1F("eta", "Offline #eta; #eta ; Count", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TH1F("phi", "Offline #phi; #phi ; Count", 20, -3.2, 3.2)) + self.addHistogram(monGroup, TH1F("avgmu", "<#mu>; <#mu> ; Count", 16, 0, 80)) + self.addHistogram(monGroup, TH1F("npvtx", "npvtx; npvtx ; Count", 16, 0, 80)) + + # Efficiency + self.addHistogram(monGroup, TProfile("pt,pt_passed", "#epsilon(p_T); p_{T} ; Efficiency", self._nEtbins, self._etbins)) + self.addHistogram(monGroup, TProfile("et,et_passed", "#epsilon(E_T); E_{T} [GeV] ; Efficiency", self._nEtbins, self._etbins)) + self.addHistogram(monGroup, TProfile("highet,highet_passed", "#epsilon(E_T); E_{T} [GeV] ; Efficiency", 40, 0., 1000.)) + self.addHistogram(monGroup, TProfile("eta,eta_passed", "#epsilon(#eta); #eta ; Efficiency", self._nEtabins, self._etabins)) + self.addHistogram(monGroup, TProfile("phi,phi_passed", "#epsilon(#phi); #phi ; Efficiency", 20, -3.2, 3.2)) + self.addHistogram(monGroup, TProfile("avgmu,avgmu_passed", "#epsilon(<#mu>); <#mu> ; Efficiency", 16, 0, 80)) + self.addHistogram(monGroup, TProfile("npvtx,npvtx_passed", "#epsilon(npvtx); npvtx ; Efficiency", 16, 0, 80)) + + + + + + + + # + # Set binning + # + def setBinning(self, doJpsiee=False): + + """ Method to define all binning required that is variable""" + + # Binning as defined in TP framework + coarse_eta_bins = [-2.47,-1.52,-1.37,-0.60,0.00,0.60,1.37,1.52,2.47] # 9 items + + coarse_et_bins = [4.,20.,30.,40.,50.,60.,150.] # 7 items + + default_eta_bins = [-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] # 21 items + + default_et_bins = [4.,7.,10.,15.,20.,25.,30.,35.,40.,45.,50.,60.,80.,150.] # 14 items + + etabins = [-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] # 21 items + + # TH2 with variable bin x-Axis, but constant bin y-Axis takes only Double_t arrays + etbins_Zee = [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.] # 31 items + + etbins_Jpsiee = [ 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] # 52 items + + + if doJpsiee: + self._nEtbins=51 + self._etbins = etbins_Jpsiee[0:self._nEtbins+1] + else: + self._nEtbins=30 + self._etbins = etbins_Zee[0:self._nEtbins+1] + + # Define the binning + self._nEtabins=20 + self._ndefaultEtbins=13 + self._ndefaultEtabins=20 + self._ncoarseEtbins=6 + self._ncoarseEtabins=8 + + #Fill the arrays + self._etabins = etabins[0:self._nEtabins+1] + self._defaultEtbins = default_et_bins[0:self._ndefaultEtbins+1] + self._defaultEtabins = default_eta_bins[0:self._ndefaultEtabins+1] + self._coarseEtbins = coarse_et_bins[0:self._ncoarseEtbins+1] + self._coarseEtabins = coarse_eta_bins[0:self._ncoarseEtabins+1] + + + + def getTrigInfo( self, trigger ): + + class TrigEgammaInfo(object): + + def __init__(self, trigger): + self.__chain = trigger + + def chain(self): + return self.__chain + + def isL1Item(self): + return True if self.chain().startswith('L1') else False + + def isElectron(self): + return True if (self.isL1Item() or self.chain().startswith('HLT_e')) else False + + def isPhoton(self): + return True if (self.chain().startswith('HLT_g')) else False + + def pidname(self): + return self.chain().split('_')[2] + + return TrigEgammaInfo(trigger) + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAnalysisAlgorithm.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAnalysisAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6cf0aed54ff4e4904d53773377da72809864a4c8 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAnalysisAlgorithm.cxx @@ -0,0 +1,695 @@ + + +#include "TrigEgammaMonitorAnalysisAlgorithm.h" + + +TrigEgammaMonitorAnalysisAlgorithm::TrigEgammaMonitorAnalysisAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ): + TrigEgammaMonitorBaseAlgorithm( name, pSvcLocator ) + +{} + +TrigEgammaMonitorAnalysisAlgorithm::~TrigEgammaMonitorAnalysisAlgorithm() +{} + + +StatusCode TrigEgammaMonitorAnalysisAlgorithm::initialize() +{ + + ATH_CHECK(TrigEgammaMonitorBaseAlgorithm::initialize()); + + return StatusCode::SUCCESS; +} + + + + +// ********************************************************************************* + + + + +void TrigEgammaMonitorAnalysisAlgorithm::fillLabel( const ToolHandle<GenericMonitoringTool>& groupHandle, + const std::string &histname, + const std::string &label ) const +{ + auto mon = Monitored::Scalar<std::string>( histname, label ); + fill( groupHandle, mon ); +} + + + + +// ********************************************************************************* + +void TrigEgammaMonitorAnalysisAlgorithm::fillEfficiencies( std::vector< std::pair< const xAOD::Egamma*, const TrigCompositeUtils::Decision * >> pairObjs, + const TrigInfo info ) const +{ + + std::vector< std::pair< const xAOD::Egamma*, const TrigCompositeUtils::Decision * >> pair_vec; + std::vector< std::pair< const xAOD::Egamma*, const TrigCompositeUtils::Decision * >> pair_iso_vec; + + + for( auto pairObj : pairObjs ){ + + if(pairObj.first->type()==xAOD::Type::Electron){ + const xAOD::Electron* el = static_cast<const xAOD::Electron *> (pairObj.first); + float et = getEt(el)/1e3; + if(et < info.trigThrHLT-5.0) continue; + + }else if(pairObj.first->type()==xAOD::Type::Photon){ + float et = getCluster_et(pairObj.first)/1e3; + if(et < info.trigThrHLT-5.0) continue; + + if(boost::contains(info.trigName,"icalovloose")) { + if (getIsolation_topoetcone20(pairObj.first)/getCluster_et(pairObj.first) >= 0.065) continue; // pass FixedCutLoose offline isolation + } + else { + if ((getIsolation_topoetcone40(pairObj.first)-2450.0)/getCluster_et(pairObj.first) >= 0.022) continue; // pass FixedCutTightCaloOnly offline isolation + } + } // Offline photon + + // Good pair to be measure + pair_vec.push_back(pairObj); + + if( pairObj.first->auxdecor<bool>("Isolated") ){ + pair_iso_vec.push_back(pairObj); + } + } + + + if (info.trigL1){ + fillEfficiency( "L1Calo", "L1Calo" , info.trigPidDecorator, info, pair_vec ); + }else{ + fillEfficiency( "L1Calo" , "L1Calo", info.trigPidDecorator, info, pair_vec ); + fillEfficiency( "L2Calo" , "L2Calo", info.trigPidDecorator, info, pair_vec ); + fillEfficiency( "L2" , "L2" , info.trigPidDecorator, info, pair_vec ); + fillEfficiency( "EFCalo" , "EFCalo", info.trigPidDecorator, info, pair_vec ); + fillEfficiency( "HLT" , "HLT" , info.trigPidDecorator, info, pair_vec ); + + if( m_detailedHists ){ + + for( const auto pid : m_isemname ){ + fillEfficiency( "HLT_" + pid, "HLT", "is"+pid, info, pair_vec ); + fillEfficiency( "HLT_" + pid + "Iso", "HLT", "is"+pid, info, pair_iso_vec ); + } + + for( const auto pid : m_lhname ){ + fillEfficiency( "HLT_" + pid, "HLT", "is"+pid, info, pair_vec ); + fillEfficiency( "HLT_" + pid + "Iso", "HLT", "is"+pid, info, pair_iso_vec ); + } + } + } +} + + + + +void TrigEgammaMonitorAnalysisAlgorithm::fillEfficiency( const std::string &subgroup, + const std::string &level, + const std::string &pidword, + const TrigInfo info, + std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision* >> pairObjs) const +{ + + + + const float etthr = info.trigThrHLT; + const std::string trigger = info.trigName; + + + auto monGroup = getGroup( trigger + "_Efficiency_" + subgroup ); + + + std::vector<float> et_vec, highet_vec, pt_vec, eta_vec, phi_vec, avgmu_vec, npvtx_vec; + std::vector<float> match_et_vec, match_highet_vec, match_pt_vec, match_eta_vec, match_phi_vec, match_avgmu_vec, match_npvtx_vec; + std::vector<bool> et_passed_vec, highet_passed_vec, pt_passed_vec, eta_passed_vec, phi_passed_vec, avgmu_passed_vec, npvtx_passed_vec; + + auto et_col = Monitored::Collection( "et" , et_vec ); + auto highet_col = Monitored::Collection( "highet" , highet_vec ); + auto pt_col = Monitored::Collection( "pt" , pt_vec ); + auto eta_col = Monitored::Collection( "eta" , eta_vec ); + auto phi_col = Monitored::Collection( "phi" , phi_vec ); + auto avgmu_col = Monitored::Collection( "avgmu" , avgmu_vec ); + auto npvtx_col = Monitored::Collection( "npvtx" , npvtx_vec ); + + auto match_et_col = Monitored::Collection( "match_et" , match_et_vec ); + auto match_highet_col = Monitored::Collection( "match_ethigh" , match_highet_vec ); + auto match_pt_col = Monitored::Collection( "match_pt" , match_pt_vec ); + auto match_eta_col = Monitored::Collection( "match_eta" , match_eta_vec ); + auto match_phi_col = Monitored::Collection( "match_phi" , match_phi_vec ); + auto match_avgmu_col = Monitored::Collection( "match_avgmu" , match_avgmu_vec ); + auto match_npvtx_col = Monitored::Collection( "match_npvtx" , match_npvtx_vec ); + + auto et_passed_col = Monitored::Collection( "et_passed" , et_passed_vec ); + auto highet_passed_col = Monitored::Collection( "highet_passed" , highet_passed_vec ); + auto pt_passed_col = Monitored::Collection( "pt_passed" , pt_passed_vec ); + auto eta_passed_col = Monitored::Collection( "eta_passed" , eta_passed_vec ); + auto phi_passed_col = Monitored::Collection( "phi_passed" , phi_passed_vec ); + auto avgmu_passed_col = Monitored::Collection( "avgmu_passed" , avgmu_passed_vec ); + auto npvtx_passed_col = Monitored::Collection( "npvtx_passed" , npvtx_passed_vec ); + + + for( auto pairObj : pairObjs ){ + + auto acceptData = setAccept( pairObj.second, info ); + bool pid=true; + bool isPassed = acceptData.getCutResult( level ); + float et=0.; + const auto *eg = pairObj.first; + ATH_MSG_DEBUG("Default pid " << pid << " te " << isPassed); + if(xAOD::EgammaHelpers::isElectron(eg)){ + ATH_MSG_DEBUG("Offline Electron with pidword " << pidword); + const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg); + pid=el->auxdecor<bool>(pidword); + ATH_MSG_DEBUG("Electron pid " << pid); + et = getEt(el)/1e3; + } + else et=eg->caloCluster()->et()/1e3; + + float eta = eg->caloCluster()->etaBE(2); + float phi = eg->phi(); + float pt = eg->pt()/1e3; + float avgmu=lbAverageInteractionsPerCrossing( Gaudi::Hive::currentContext() ); + float npvtx=0.0; + + ATH_MSG_DEBUG("PID decision efficiency " << eg->auxdecor<bool>(pidword)); + + if(pid){ + et_vec.push_back( et ); + pt_vec.push_back( pt ); + highet_vec.push_back( et ); + + if(et > etthr+1.0){ + eta_vec.push_back(eta); + phi_vec.push_back(phi); + avgmu_vec.push_back(avgmu); + npvtx_vec.push_back(npvtx); + } + + if(isPassed) { + match_et_vec.push_back( et ); + match_pt_vec.push_back( pt ); + match_highet_vec.push_back( et ); + + if(et > etthr+1.0){ + match_eta_vec.push_back(eta); + match_phi_vec.push_back(phi); + match_avgmu_vec.push_back(avgmu); + match_npvtx_vec.push_back(npvtx); + } + + et_passed_vec.push_back( true ); + pt_passed_vec.push_back( true ); + highet_passed_vec.push_back( true ); + + if(et > etthr+1.0){ + eta_passed_vec.push_back( true ); + phi_passed_vec.push_back( true ); + avgmu_passed_vec.push_back( true ); + npvtx_passed_vec.push_back( true ); + } + } // Passes Trigger selection + else { + + et_passed_vec.push_back( false ); + pt_passed_vec.push_back( false ); + highet_passed_vec.push_back( false ); + + if(et > etthr+1.0){ + eta_passed_vec.push_back( false ); + phi_passed_vec.push_back( false ); + avgmu_passed_vec.push_back( false ); + npvtx_passed_vec.push_back( false ); + } + } // Fails Trigger selection + } // Passes offline pid, fill histograms + } + + + fill( monGroup, et_col, highet_col, pt_col, eta_col, phi_col, avgmu_col, npvtx_col, + match_et_col, match_highet_col, match_pt_col, match_eta_col, match_phi_col, match_avgmu_col, match_npvtx_col, + et_passed_col, highet_passed_col, pt_passed_col, eta_passed_col, phi_passed_col, avgmu_passed_col, npvtx_passed_col); + +} + + + +// ********************************************************************************* + + +void TrigEgammaMonitorAnalysisAlgorithm::fillDistributions( std::vector< std::pair< const xAOD::Egamma*, const TrigCompositeUtils::Decision * >> pairObjs, + const TrigInfo info ) const +{ + + const std::string trigger = info.trigName; + + if (info.trigL1){ + + // Fill L1 features + std::vector<const xAOD::EmTauRoI*> l1_vec; + auto initRois = tdt()->features<TrigRoiDescriptorCollection>(trigger,TrigDefs::includeFailedDecisions,"", + TrigDefs::allFeaturesOfType,"initialRoI"); + for( auto &initRoi: initRois ){ + if( !initRoi.link.isValid() ) continue; + auto feat = match()->getL1Feature( initRoi.source ); + if(feat) + l1_vec.push_back(feat); + } + + fillL1Calo( trigger, l1_vec ); + + + }else{ + + + // Offline + std::vector<const xAOD::Egamma*> eg_vec; + std::vector<const xAOD::Electron*> el_vec; + for( auto pairObj: pairObjs ) + { + eg_vec.push_back(pairObj.first); + if( xAOD::EgammaHelpers::isElectron(pairObj.first)){ + const xAOD::Electron* elOff = static_cast<const xAOD::Electron*> (pairObj.first); + el_vec.push_back(elOff); + } + } + + // Offline + fillShowerShapes( trigger, eg_vec, false ); + fillTracking( trigger, el_vec, false ); + + + + if( m_tp ){ + + if( info.trigType == "electron" ){ + // HLT Electron + { + std::vector<const xAOD::Electron*> el_vec; + std::vector<const xAOD::Egamma*> eg_vec; + auto vec = tdt()->features<xAOD::ElectronContainer>(trigger,TrigDefs::includeFailedDecisions ,match()->key("Electron") ); + for( auto &featLinkInfo : vec ){ + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + // If not pass, continue + el_vec.push_back(feat); + eg_vec.push_back(feat); + } + fillShowerShapes( trigger, eg_vec, true ); + fillTracking( trigger, el_vec, true ); + } + + }else{ + ATH_MSG_WARNING( "Chain type not Electron for TP trigger" ); + } + + + }else{ + + // L1Calo + { + // Fill L1 features + std::vector<const xAOD::EmTauRoI*> l1_vec; + auto initRois = tdt()->features<TrigRoiDescriptorCollection>(trigger,TrigDefs::includeFailedDecisions,"", + TrigDefs::allFeaturesOfType,"initialRoI"); + for( auto &initRoi: initRois ){ + if( !initRoi.link.isValid() ) continue; + auto feat = match()->getL1Feature( initRoi.source ); + if(feat) + l1_vec.push_back(feat); + } + + fillL1Calo( trigger, l1_vec ); + } + + + // L2Calo + { + std::vector<const xAOD::TrigEMCluster*> emCluster_vec; + auto vec = tdt()->features<xAOD::TrigEMClusterContainer>(trigger,TrigDefs::includeFailedDecisions ,match()->key("L2Calo") ); + for(auto &featLinkInfo : vec ){ + if(! featLinkInfo.isValid() ) continue; + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + emCluster_vec.push_back(feat); + } + fillL2Calo( trigger, emCluster_vec ); + } + + + // EFCalo + { + std::vector<const xAOD::CaloCluster* > clus_vec; + auto vec = tdt()->features<xAOD::CaloClusterContainer>(trigger,TrigDefs::Physics ,match()->key("EFCalo") ); + for(auto &featLinkInfo : vec ){ + if(! featLinkInfo.isValid() ) continue; + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + clus_vec.push_back(feat); + } + fillEFCalo( trigger, clus_vec ); + } + + + if ( info.trigType == "electron" ){ + + // L2 Electron + { + std::vector<const xAOD::TrigElectron*> el_vec; + // Get only passed objects + auto vec = tdt()->features<xAOD::TrigElectronContainer>(trigger,TrigDefs::Physics ,match()->key("L2Electron") ); + for( auto &featLinkInfo : vec ){ + if(! featLinkInfo.isValid() ) continue; + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + el_vec.push_back(feat); + } + fillL2Electron( trigger, el_vec ); + } + + + // HLT Electron + { + std::vector<const xAOD::Electron*> el_vec; + std::vector<const xAOD::Egamma*> eg_vec; + auto vec = tdt()->features<xAOD::ElectronContainer>(trigger, TrigDefs::Physics ,match()->key("Electron") ); + for( auto &featLinkInfo : vec ){ + if(! featLinkInfo.isValid() ) continue; + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + el_vec.push_back(feat); + eg_vec.push_back(feat); + } + fillShowerShapes( trigger, eg_vec, true ); + fillTracking( trigger, el_vec, true ); + } + + + }else if ( info.trigType == "photon"){ + // HLT Photon + { + std::vector<const xAOD::Egamma*> ph_vec; + auto vec = tdt()->features<xAOD::PhotonContainer>(trigger,TrigDefs::Physics ,match()->key("Photon") ); + for( auto &featLinkInfo : vec ){ + if(! featLinkInfo.isValid() ) continue; + const auto *feat = *(featLinkInfo.link); + if(!feat) continue; + ph_vec.push_back(feat); + } + fillShowerShapes( trigger, ph_vec, true ); + } + }else{ + ATH_MSG_INFO( "Chain type not specified" ); + } + + } + + } +} + + + + +void TrigEgammaMonitorAnalysisAlgorithm::fillL1Calo( const std::string &trigger, std::vector< const xAOD::EmTauRoI* > l1_vec ) const +{ + auto monGroup = getGroup(trigger+"_Distributions_L1Calo"); + + std::vector<float> eta_vec, phi_vec, energy_vec, roi_et_vec, emIso_vec, hadCore_vec; + + auto eta_col = Monitored::Collection( "eta" , eta_vec ); + auto phi_col = Monitored::Collection( "phi" , phi_vec ); + auto energy_col = Monitored::Collection( "energy" , energy_vec ); + auto roi_et_col = Monitored::Collection( "roi_et" , roi_et_vec ); + auto emIso_col = Monitored::Collection( "emIso" , emIso_vec ); + auto hadCore_col = Monitored::Collection( "hadCore" , hadCore_vec ); + + for( auto l1 : l1_vec ) + { + if(!l1) continue; + eta_vec.push_back( l1->eta() ); + phi_vec.push_back( l1->phi() ); + energy_vec.push_back( l1->emClus()/1.e3 ); + roi_et_vec.push_back( l1->eT()/1.e3 ); + emIso_vec.push_back( l1->emIsol()/1.e3 ); + hadCore_vec.push_back( l1->hadCore()/1.e3 ); + } + + fill( monGroup, eta_col, phi_col, energy_col, roi_et_col, emIso_col, hadCore_col ); + +} + + + + + +void TrigEgammaMonitorAnalysisAlgorithm::fillL2Calo(const std::string &trigger, std::vector< const xAOD::TrigEMCluster *> emCluster_vec) const +{ + auto monGroup = getGroup(trigger+"_Distributions_L2Calo"); + + std::vector<float> et_vec, eta_vec, phi_vec; + + auto et_col = Monitored::Collection("et" , et_vec ); + auto eta_col = Monitored::Collection("eta", eta_vec ); + auto phi_col = Monitored::Collection("phi", phi_vec ); + + for ( auto emCluster : emCluster_vec ) + { + if(!emCluster) continue; + et_vec.push_back( emCluster->et()/1.e3 ); + eta_vec.push_back( emCluster->eta() ); + phi_vec.push_back( emCluster->phi() ); + } + + fill( monGroup, et_col, eta_col, phi_col ); + + +} + + + +void TrigEgammaMonitorAnalysisAlgorithm::fillL2Electron(const std::string &trigger, std::vector< const xAOD::TrigElectron* > el_vec) const +{ + + auto monGroup = getGroup(trigger+"_Distributions_L2Electron"); + + std::vector<float> et_vec, eta_vec, phi_vec; + + auto et_col = Monitored::Collection("et" , et_vec ); + auto eta_col = Monitored::Collection("eta", eta_vec ); + auto phi_col = Monitored::Collection("phi", phi_vec ); + + for ( auto el : el_vec ) + { + if(!el) continue; + et_vec.push_back( el->pt()/1.e3 ); + eta_vec.push_back( el->eta() ); + phi_vec.push_back( el->phi() ); + } + + fill( monGroup, et_col, eta_col, phi_col ); +} + +void TrigEgammaMonitorAnalysisAlgorithm::fillEFCalo(const std::string &trigger, std::vector< const xAOD::CaloCluster*> clus_vec) const +{ + + auto monGroup = getGroup( trigger + "_Distributions_EFCalo" ); + + + std::vector<float> energyBE0_vec, energyBE1_vec, energyBE2_vec, energyBE3_vec, + energy_vec, et_vec, eta_vec, phi_vec, eta_calo_vec, phi_calo_vec; + + + + auto energyBE0_col = Monitored::Collection("energyBE0", energyBE0_vec); + auto energyBE1_col = Monitored::Collection("energyBE1", energyBE1_vec); + auto energyBE2_col = Monitored::Collection("energyBE2", energyBE2_vec); + auto energyBE3_col = Monitored::Collection("energyBE3", energyBE3_vec); + auto energy_col = Monitored::Collection("energy" , energy_vec ); + auto et_col = Monitored::Collection("et" , et_vec ); + auto eta_col = Monitored::Collection("eta" , eta_vec ); + auto phi_col = Monitored::Collection("phi" , phi_vec ); + auto eta_calo_col = Monitored::Collection("eta_calo" , eta_calo_vec ); + auto phi_calo_col = Monitored::Collection("phi_calo" , phi_calo_vec ); + + for ( auto clus : clus_vec ) + { + double tmpeta = -999.; + if(!clus->retrieveMoment(xAOD::CaloCluster::ETACALOFRAME,tmpeta)) + tmpeta=-999.; + double tmpphi = -999.; + if(!clus->retrieveMoment(xAOD::CaloCluster::PHICALOFRAME,tmpphi)) + tmpphi=-999.; + + energyBE0_vec.push_back( clus->energyBE(0)/1.e3 ); + energyBE1_vec.push_back( clus->energyBE(1)/1.e3 ); + energyBE2_vec.push_back( clus->energyBE(2)/1.e3 ); + energyBE3_vec.push_back( clus->energyBE(3)/1.e3 ); + energy_vec.push_back( clus->e()/1.e3 ); + et_vec.push_back( clus->et()/1.e3 ); + eta_vec.push_back( clus->eta() ); + phi_vec.push_back( clus->phi() ); + eta_calo_vec.push_back( tmpeta ); + phi_calo_vec.push_back( tmpphi ); + + } + + + fill( monGroup, energyBE0_col, energyBE1_col, energyBE2_col, energyBE3_col, + energy_col, et_col, eta_col, phi_col, eta_calo_col, phi_calo_col); +} + + + + + +void TrigEgammaMonitorAnalysisAlgorithm::fillShowerShapes(const std::string &trigger, std::vector<const xAOD::Egamma*> eg_vec , bool online) const +{ + + ATH_MSG_DEBUG("Fill SS distributions: " << trigger); + auto monGroup = getGroup( trigger + ( online ? "_Distributions_HLT" : "_Distributions_Offline") ); + + std::vector<float> ethad_vec, ethad1_vec, Rhad_vec, Rhad1_vec, Reta_vec, Rphi_vec, weta1_vec, weta2_vec, + f1_vec, f3_vec, eratio_vec, et_vec, highet_vec , eta_vec, phi_vec, topoetcone20_vec, topoetcone40_shift_vec, + topoetcone20_rel_vec, topoetcone40_shift_rel_vec; + + + auto ethad_col = Monitored::Collection("ethad" , ethad_vec ); + auto ethad1_col = Monitored::Collection("ethad1" , ethad1_vec ); + auto Rhad_col = Monitored::Collection("Rhad" , Rhad_vec ); + auto Rhad1_col = Monitored::Collection("Rhad1" , Rhad1_vec ); + auto Reta_col = Monitored::Collection("Reta" , Reta_vec ); + auto Rphi_col = Monitored::Collection("Rphi" , Rphi_vec ); + auto weta1_col = Monitored::Collection("weta1" , weta1_vec ); + auto weta2_col = Monitored::Collection("weta2" , weta2_vec ); + auto f1_col = Monitored::Collection("f1" , f1_vec ); + auto f3_col = Monitored::Collection("f3" , f3_vec ); + auto eratio_col = Monitored::Collection("eratio" , eratio_vec ); + auto et_col = Monitored::Collection("et" , et_vec ); + auto highet_col = Monitored::Collection("highet" , highet_vec ); + auto eta_col = Monitored::Collection("eta" , eta_vec ); + auto phi_col = Monitored::Collection("phi" , phi_vec ); + auto topoetcone20_col = Monitored::Collection("topoetcone20", topoetcone20_vec); + auto topoetcone40_shift_col = Monitored::Collection("topoetcone40_shift", topoetcone40_shift_vec ); + auto topoetcone20_rel_col = Monitored::Collection("topoetcone20_rel", topoetcone20_rel_vec); + auto topoetcone40_shift_rel_col = Monitored::Collection("topoetcone40_shift_rel", topoetcone40_shift_rel_vec ); + + for ( auto eg : eg_vec ){ + + if(!eg) continue; + + ethad_vec.push_back( getShowerShape_ethad(eg)/1e3); + ethad1_vec.push_back( getShowerShape_ethad1(eg)/1e3); + Rhad_vec.push_back( getShowerShape_Rhad(eg)); + Rhad1_vec.push_back( getShowerShape_Rhad(eg)); + Reta_vec.push_back( getShowerShape_Reta(eg)); + Rphi_vec.push_back( getShowerShape_Rphi(eg)); + weta1_vec.push_back( getShowerShape_weta1(eg)); + weta2_vec.push_back( getShowerShape_weta2(eg)); + f1_vec.push_back( getShowerShape_f1(eg)); + f3_vec.push_back( getShowerShape_f3(eg)); + eratio_vec.push_back( getShowerShape_Eratio(eg)); + et_vec.push_back( eg->pt()/1e3); + highet_vec.push_back( eg->pt()/1e3); + eta_vec.push_back( eg->eta()); + phi_vec.push_back( eg->phi()); + topoetcone20_vec.push_back( getIsolation_topoetcone20(eg)/1e3); + topoetcone40_shift_vec.push_back( (getIsolation_topoetcone40(eg)-2450)/1e3 ); + + if (eg->pt() > 0) { + topoetcone20_rel_vec.push_back( getIsolation_topoetcone20(eg)/eg->pt()); + topoetcone40_shift_rel_vec.push_back( (getIsolation_topoetcone40(eg)-2450)/eg->pt() ); + } + + }// Loop over egamma objects + + fill( monGroup, ethad_col, ethad1_col, Rhad_col, Rhad1_col, Reta_col, Rphi_col, weta1_col, weta2_col, + f1_col, f3_col, eratio_col, et_col, highet_col , eta_col, phi_col, topoetcone20_col, topoetcone40_shift_col, + topoetcone20_rel_col, topoetcone40_shift_rel_col ); + +} + + +void TrigEgammaMonitorAnalysisAlgorithm::fillTracking(const std::string &trigger, std::vector< const xAOD::Electron *> eg_vec, bool online ) const +{ + + ATH_MSG_DEBUG("Fill tracking"); + + auto monGroup = getGroup( trigger + ( online ? "_Distributions_HLT" : "_Distributions_Offline") ); + + std::vector<float> deta1_vec, deta1_EMECA_vec, deta1_EMECC_vec, deta1_EMEBA_vec, deta1_EMEBC_vec, deta2_vec, dphi2_vec, + dphiresc_vec, eprobht_vec, npixhits_vec, nscthits_vec, charge_vec, ptcone20_vec, ptvarcone20_vec, d0_vec, d0sig_vec, + pt_vec, ptcone20_rel_vec, ptvarcone20_rel_vec; + + auto deta1_col = Monitored::Collection( "deta1" , deta1_vec ); + auto deta1_EMECA_col = Monitored::Collection( "deta1_EMECA" , deta1_EMECA_vec ); + auto deta1_EMECC_col = Monitored::Collection( "deta1_EMECC" , deta1_EMECC_vec ); + auto deta1_EMEBA_col = Monitored::Collection( "deta1_EMEBA" , deta1_EMEBA_vec ); + auto deta1_EMEBC_col = Monitored::Collection( "deta1_EMEBC" , deta1_EMEBC_vec ); + auto deta2_col = Monitored::Collection( "deta2" , deta2_vec ); + auto dphi2_col = Monitored::Collection( "dphi2" , dphi2_vec ); + auto dphiresc_col = Monitored::Collection( "dphiresc" , dphiresc_vec ); + auto eprobht_col = Monitored::Collection( "eprobht" , eprobht_vec ); + auto npixhits_col = Monitored::Collection( "npixhits" , npixhits_vec ); + auto nscthits_col = Monitored::Collection( "nscthits" , nscthits_vec ); + auto charge_col = Monitored::Collection( "charge" , charge_vec ); + auto ptcone20_col = Monitored::Collection( "ptcone20" , ptcone20_vec ); + auto ptvarcone20_col = Monitored::Collection( "ptvarcone20" , ptvarcone20_vec ); + auto d0_col = Monitored::Collection( "d0" , d0_vec ); + auto d0sig_col = Monitored::Collection( "d0sig" , d0sig_vec ); + auto pt_col = Monitored::Collection( "pt" , pt_vec ); + auto ptcone20_rel_col = Monitored::Collection( "ptcone20_rel", ptcone20_rel_vec ); + auto ptvarcone20_rel_col = Monitored::Collection( "ptvarcone20" , ptvarcone20_rel_vec ); + + + for ( auto eg : eg_vec ){ + + if(!eg) continue; + + float cleta = 0.; + if(eg->caloCluster()) cleta=eg->caloCluster()->eta(); + else cleta=eg->eta(); + + deta1_vec.push_back( getCaloTrackMatch_deltaEta1(eg)); + + if(cleta > 1.375 && cleta < 3.2) + deta1_EMECA_vec.push_back( getCaloTrackMatch_deltaEta1(eg)); + if(cleta < -1.375 && cleta > -3.2) + deta1_EMECC_vec.push_back( getCaloTrackMatch_deltaEta1(eg)); + if(cleta > 0 && cleta < 1.375) + deta1_EMEBA_vec.push_back( getCaloTrackMatch_deltaEta1(eg)); + if(cleta < 0 && cleta > -1.375) + deta1_EMEBC_vec.push_back( getCaloTrackMatch_deltaEta1(eg)); + + deta2_vec.push_back( getCaloTrackMatch_deltaEta2(eg)); + dphi2_vec.push_back( getCaloTrackMatch_deltaPhi2(eg)); + dphiresc_vec.push_back( getCaloTrackMatch_deltaPhiRescaled2(eg)); + eprobht_vec.push_back( getTrackSummaryFloat_eProbabilityHT(eg)); + npixhits_vec.push_back( getTrackSummary_numberOfPixelHits(eg)); + nscthits_vec.push_back( getTrackSummary_numberOfSCTHits(eg)); + charge_vec.push_back( eg->charge()); + ptcone20_vec.push_back( getIsolation_ptcone20(eg)/1e3); + ptvarcone20_vec.push_back( getIsolation_ptvarcone20(eg)/1e3); + + // Quantities directly from tracks + ATH_MSG_DEBUG("Get track Quantities"); + d0_vec.push_back( getTrack_d0(eg)); + d0sig_vec.push_back(getD0sig(eg)); + pt_vec.push_back( getTrack_pt(eg)/1e3); + + if (eg->pt() > 0) { + ptcone20_rel_vec.push_back( getIsolation_ptcone20(eg)/eg->pt()); + ptvarcone20_rel_vec.push_back( getIsolation_ptvarcone20(eg)/eg->pt()); + } + + } + + + fill( monGroup, deta1_col, deta1_EMECA_col, deta1_EMECC_col, deta1_EMEBA_col, deta1_EMEBC_col, deta2_col, dphi2_col, + dphiresc_col, eprobht_col, npixhits_col, nscthits_col, charge_col, ptcone20_col, ptvarcone20_col, d0_col, d0sig_col, + pt_col, ptcone20_rel_col, ptvarcone20_rel_col); + + + +} + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAnalysisAlgorithm.h b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAnalysisAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..20e465d1187471ed3fab68fb93c7fb060fe414fe --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorAnalysisAlgorithm.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef TrigEgammaMonitorAnalysisAlgorithm_H +#define TrigEgammaMonitorAnalysisAlgorithm_H + +#include "TrigEgammaMonitorBaseAlgorithm.h" + + +class TrigEgammaMonitorAnalysisAlgorithm: public TrigEgammaMonitorBaseAlgorithm +{ + + public: + + TrigEgammaMonitorAnalysisAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + + virtual ~TrigEgammaMonitorAnalysisAlgorithm() override; + + virtual StatusCode initialize() override; + + protected: + + void fillLabel( const ToolHandle<GenericMonitoringTool>& groupHandle, const std::string &histname, const std::string &label ) const; + + + // Efficiency monitoring + void fillEfficiencies( std::vector< std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*> > , TrigInfo ) const; + void fillEfficiency( const std::string &subgroup, const std::string &level, const std::string &pidword, const TrigInfo info, + std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision* >> pairObjs) const; + + + void fillDistributions( std::vector< std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*> > , TrigInfo ) const; + void fillL1Calo( const std::string &trigger, std::vector< const xAOD::EmTauRoI* > l1_vec ) const; + void fillL2Calo(const std::string &trigger, std::vector< const xAOD::TrigEMCluster*> emCluster_vec ) const; + void fillL2Electron(const std::string &trigger, std::vector<const xAOD::TrigElectron*> el_vec) const; + void fillEFCalo(const std::string &trigger, std::vector<const xAOD::CaloCluster*> clus_vec) const; + void fillShowerShapes(const std::string &trigger, std::vector<const xAOD::Egamma*> eg_vec, bool online ) const; + void fillTracking(const std::string &trigger, std::vector<const xAOD::Electron *> eg_vec, bool online ) const; + + +}; + +#endif diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorBaseAlgorithm.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorBaseAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3e4b5b5e088bc8763daf9081d68f2f98ee8b4cfa --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorBaseAlgorithm.cxx @@ -0,0 +1,738 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigEgammaMonitorBaseAlgorithm.h" + + + +TrigEgammaMonitorBaseAlgorithm::TrigEgammaMonitorBaseAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) + : AthMonitorAlgorithm(name,pSvcLocator), + m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"), + m_matchTool("Trig::TrigEgammaMatchingToolMT/TrigEgammaMatchingToolMT") +{ + declareProperty( "MatchTool" , m_matchTool ); +} + + +TrigEgammaMonitorBaseAlgorithm::~TrigEgammaMonitorBaseAlgorithm() {} + + + + +StatusCode TrigEgammaMonitorBaseAlgorithm::initialize() +{ + + ATH_CHECK(AthMonitorAlgorithm::initialize()); + ATH_CHECK(m_trigdec.retrieve()); + ATH_CHECK(m_electronIsEMTool.retrieve()); + ATH_CHECK(m_electronLHTool.retrieve()); + + m_trigdec->ExperimentalAndExpertMethods()->enable(); + + return StatusCode::SUCCESS; +} + + +// ************************************************************************************************ + + + + +bool TrigEgammaMonitorBaseAlgorithm::ApplyElectronPid( const xAOD::Electron *eg, const std::string pidname) const +{ + auto ctx = Gaudi::Hive::currentContext() ; + if (pidname == "Tight"){ + return (bool) this->m_electronIsEMTool[0]->accept(ctx,eg); + } + else if (pidname == "Medium"){ + return (bool) this->m_electronIsEMTool[1]->accept(ctx,eg); + } + else if (pidname == "Loose"){ + return (bool) this->m_electronIsEMTool[2]->accept(ctx,eg); + } + else if (pidname == "LHTight"){ + return (bool) this->m_electronLHTool[0]->accept(ctx,eg); + } + else if (pidname == "LHMedium"){ + return (bool) this->m_electronLHTool[1]->accept(ctx,eg); + } + else if (pidname == "LHLoose"){ + return (bool) this->m_electronLHTool[2]->accept(ctx,eg); + } + else ATH_MSG_DEBUG("No Pid tool, continue without PID"); + return false; +} + + + + + +// ************************************************************************************************ + + + +bool TrigEgammaMonitorBaseAlgorithm::isIsolated(const xAOD::Electron *eg, const std::string isolation) const { + ATH_MSG_DEBUG("Apply Isolation " << isolation); + float ptcone20; + eg->isolationValue(ptcone20, xAOD::Iso::ptcone20); + ATH_MSG_DEBUG("ptcone20 " << ptcone20); + if (!(fabs(eg->pt()) > 0)) { + ATH_MSG_DEBUG("Electron pt is zero, can't calculate relative isolation"); + return false; + } + float ptcone20_rel = ptcone20/eg->pt(); + ATH_MSG_DEBUG("Relative isolation value " << ptcone20_rel); + if (isolation == "Loose"){ + if (ptcone20_rel > 0.1) { + ATH_MSG_DEBUG("Probe failing isolation"); + return false; + } else { + ATH_MSG_DEBUG("Probe passing isolation"); + return true; + } + } + else { + ATH_MSG_DEBUG("No valid working point defined for " << isolation << " continue without isolation"); + } + return false; +} + + + +bool TrigEgammaMonitorBaseAlgorithm::isPrescaled(const std::string trigger) const { + + bool efprescale=false; + bool l1prescale=false; + bool prescale=false; + bool rerun=true; //assume rerun for l1 + std::string l1item=""; + + if(boost::starts_with(trigger, "L1" )) + l1item=trigger; + if(boost::starts_with(trigger,"HLT")){ + l1item = getL1Item(trigger); + const unsigned int bit=tdt()->isPassedBits(trigger); + efprescale=bit & TrigDefs::EF_prescaled; + rerun=bit&TrigDefs::EF_resurrected; //Rerun, only check for HLT + } + + + ATH_MSG_DEBUG("Checking prescale for " << trigger << " " << l1item); + const unsigned int l1bit=tdt()->isPassedBits(l1item); + bool l1_afterpre=l1bit&TrigDefs::L1_isPassedAfterPrescale; + bool l1_beforepre=l1bit&TrigDefs::L1_isPassedBeforePrescale; + l1prescale=l1_beforepre && !l1_afterpre; + prescale=efprescale || l1prescale; + ATH_MSG_DEBUG("L1 prescale " << l1item << " " << l1prescale << " before " << l1_beforepre << " after " << l1_afterpre); + ATH_MSG_DEBUG("EF prescale " << trigger << " " << efprescale << " Prescale " << prescale); + if(rerun) return false; // Rerun use the event + if(prescale) return true; // Prescaled, reject event + return false; // Not prescaled, use event +} + + + + +asg::AcceptData TrigEgammaMonitorBaseAlgorithm::setAccept( const TrigCompositeUtils::Decision *dec, const TrigInfo info) const { + + ATH_MSG_DEBUG("setAccept"); + + + asg::AcceptInfo accept; + for(const auto cut:m_trigLevel) accept.addCut(cut,cut); + asg::AcceptData acceptData (&accept); + + + bool passedL1Calo=false; + bool passedL2Calo=false; + bool passedEFCalo=false; + bool passedL2=false; + bool passedEFTrk=false; + bool passedEF=false; + + auto trigger = info.trigName; + + passedL1Calo = match()->ancestorPassed<TrigRoiDescriptorCollection>( dec , trigger , "initialRois"); + + if(!info.trigL1){ // HLT item get full decision + ATH_MSG_DEBUG("Check for active features: TrigEMCluster,CaloClusterContainer"); + + passedL2Calo = match()->ancestorPassed<xAOD::TrigEMClusterContainer>(dec, trigger, "HLT_L2CaloEMClusters"); + passedEFCalo = match()->ancestorPassed<xAOD::CaloClusterContainer>(dec, trigger, "HLT_CaloEMClusters"); + + + if(info.trigType == "electron"){ + ATH_MSG_DEBUG("Check for active features: TrigElectron, ElectronContainer, TrackParticleContainer"); + passedL2 = match()->ancestorPassed<xAOD::TrigElectronContainer>(dec, trigger, "HLT_L2Electrons"); + passedEF = match()->ancestorPassed<xAOD::ElectronContainer>(dec, trigger, "HLT_egamma_Electrons"); + passedEFTrk = true; //match()->ancestorPassed<xAOD::TrackParticleContainer>(dec); + } + else if(info.trigType == "photon"){ + ATH_MSG_DEBUG("Check for active features: TrigPhoton, PhotonContainer"); + passedL2 = match()->ancestorPassed<xAOD::TrigPhotonContainer>(dec, trigger, "HLT_L2Photons"); + passedEF = match()->ancestorPassed<xAOD::PhotonContainer>(dec, trigger, "HLT_egamma_Photons"); + passedEFTrk=true;// Assume true for photons + } + } + + acceptData.setCutResult("L1Calo",passedL1Calo); + acceptData.setCutResult("L2Calo",passedL2Calo); + acceptData.setCutResult("L2",passedL2); + acceptData.setCutResult("EFCalo",passedEFCalo); + acceptData.setCutResult("EFTrack",passedEFTrk); + acceptData.setCutResult("HLT",passedEF); + ATH_MSG_DEBUG("Accept results:"); + ATH_MSG_DEBUG("L1: "<< passedL1Calo); + ATH_MSG_DEBUG("L2Calo: " << passedL2Calo); + ATH_MSG_DEBUG("L2: "<< passedL2); + ATH_MSG_DEBUG("EFCalo: "<< passedEFCalo); + ATH_MSG_DEBUG("HLT: "<<passedEF); + + return acceptData; +} + + + + +float TrigEgammaMonitorBaseAlgorithm::dR(const float eta1, const float phi1, const float eta2, const float phi2) const { + float deta = fabs(eta1 - eta2); + float dphi = fabs(phi1 - phi2) < TMath::Pi() ? fabs(phi1 - phi2) : 2*TMath:: \ + Pi() - fabs(phi1 - phi2); + return sqrt(deta*deta + dphi*dphi); +} + + + + +float TrigEgammaMonitorBaseAlgorithm::getEta2(const xAOD::Egamma* eg) const{ + if(eg && (eg->caloCluster())){ + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return fabs(cluster->etaBE(2)); + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEt(const xAOD::Electron* eg) const{ + 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); + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEtCluster37(const xAOD::Egamma* eg) const{ + if(eg && (eg->caloCluster())){ + const xAOD::CaloCluster* cluster = eg->caloCluster(); + float eta2 = fabs(cluster->etaBE(2)); + return cluster->e()/cosh(eta2); + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getDEmaxs1(const xAOD::Egamma *eg) const{ + if(eg){ + float emax2=0.; + eg->showerShapeValue(emax2, xAOD::EgammaParameters::e2tsts1); + float emax=0.; + eg->showerShapeValue(emax, xAOD::EgammaParameters::emaxs1); + float val = fabs(emax+emax2)>0. ? (emax-emax2)/(emax+emax2) : 0.; + return val; + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::rTRT (const xAOD::Electron* eg) const{ + if(eg && eg->trackParticle()){ + uint8_t trtHits = 0; + eg->trackParticleSummaryValue(trtHits,xAOD::numberOfTRTHits); + uint8_t trtHTHits = 0; + eg->trackParticleSummaryValue(trtHTHits,xAOD::numberOfTRTHighThresholdHits); + if(trtHits!=0) { + return ( (double)trtHTHits / (double)trtHits ); + } + else return -99.; + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getSigmaD0(const xAOD::Electron *eg) const{ + const xAOD::TrackParticle* t = eg->trackParticle(); + float d0sigma=0.; + if (t) + { + float vard0 = t->definingParametersCovMatrix()(0,0); + if (vard0 > 0) { + d0sigma=sqrtf(vard0); + } + else return -99.; + return d0sigma; + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getD0sig(const xAOD::Electron *eg) const{ + const xAOD::TrackParticle* t = eg->trackParticle(); + float d0sigma=0.; + if (t) + { + + float vard0 = t->definingParametersCovMatrix()(0,0); + if (vard0 > 0) { + d0sigma=sqrtf(vard0); + } + else return -99.; + return t->d0()/d0sigma; + } + else return -99.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEnergyBE0(const xAOD::Egamma *eg) const{ + if(eg && (eg->caloCluster())){ + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(0); + } + else return 0; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEnergyBE1(const xAOD::Egamma *eg) const{ + if(eg && (eg->caloCluster())){ + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(1); + } + else return 0.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEnergyBE2(const xAOD::Egamma *eg) const{ + if(eg && (eg->caloCluster())){ + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(2); + } + else return 0.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEnergyBE3(const xAOD::Egamma *eg) const{ + if(eg && (eg->caloCluster())){ + const xAOD::CaloCluster* cluster = eg->caloCluster(); + return cluster->energyBE(3); + } + else return 0.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getEaccordion(const xAOD::Egamma *eg) const{ + if(eg && (eg->caloCluster())){ + 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); + } + else return 0.; +} + + +float TrigEgammaMonitorBaseAlgorithm::getE0Eaccordion(const xAOD::Egamma *eg) const{ + 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 ebe3 = cluster->energyBE(3); + float eacc = ebe1+ebe2+ebe3; + if(eacc==0.) return 0.; + return (ebe0/eacc); + } + else return 0.; +} + + + + + + +/*! Macros for plotting */ +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getShowerShape_##_name_(const xAOD::Egamma* eg) const \ +{ float val{-99}; \ + eg->showerShapeValue(val,xAOD::EgammaParameters::_name_); \ + return val; } + GETTER(e011) + GETTER(e132) + GETTER(e237) + GETTER(e277) + GETTER(ethad) + GETTER(ethad1) + GETTER(weta1) + GETTER(weta2) + GETTER(f1) + GETTER(e2tsts1) + GETTER(emins1) + GETTER(emaxs1) + GETTER(wtots1) + GETTER(fracs1) + GETTER(Reta) + GETTER(Rphi) + GETTER(f3) + GETTER(f3core) + GETTER(Eratio) + GETTER(Rhad) + GETTER(Rhad1) + GETTER(DeltaE) +#undef GETTER + + +// GETTER for Isolation monitoring +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getIsolation_##_name_(const xAOD::Electron* eg) const\ +{ float val{-99}; \ + eg->isolationValue(val,xAOD::Iso::_name_); \ + return val; } + GETTER(ptcone20) + GETTER(ptcone30) + GETTER(ptcone40) + GETTER(ptvarcone20) + GETTER(ptvarcone30) + GETTER(ptvarcone40) +#undef GETTER + + +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getIsolation_##_name_(const xAOD::Egamma* eg) const\ +{ float val{-99}; \ + eg->isolationValue(val,xAOD::Iso::_name_); \ + return val; } + GETTER(etcone20) + GETTER(etcone30) + GETTER(etcone40) + GETTER(topoetcone20) + GETTER(topoetcone30) + GETTER(topoetcone40) +#undef GETTER + + +// GETTERs for CaloCluster monitoring +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getCluster_##_name_(const xAOD::Egamma* eg) const\ +{ if(eg && eg->caloCluster()) \ + return eg->caloCluster()->_name_(); \ + else return -99.;} + GETTER(et) + GETTER(phi) + GETTER(eta) +#undef GETTER + + +// GETTERs for Track monitoring +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrack_##_name_(const xAOD::Electron* eg) const\ +{ if(eg && eg->trackParticle()) \ + return eg->trackParticle()->_name_(); \ + else return -99.;} + GETTER(pt) + GETTER(phi) + GETTER(eta) + GETTER(d0) + GETTER(z0) +#undef GETTER + + +// GETTERs for Track details monitoring +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrackSummary_##_name_(const xAOD::Electron* eg) const \ +{ uint8_t val_uint8{0}; \ + if(eg){ \ + eg->trackParticleSummaryValue(val_uint8,xAOD::_name_); \ + return val_uint8; } \ + else return -99; } + GETTER(numberOfInnermostPixelLayerHits) + GETTER(numberOfInnermostPixelLayerOutliers) + GETTER(numberOfPixelHits) + GETTER(numberOfPixelOutliers) + GETTER(numberOfSCTHits) + GETTER(numberOfSCTOutliers) + GETTER(numberOfTRTHits) + GETTER(numberOfTRTHighThresholdHits) + GETTER(numberOfTRTHighThresholdOutliers) + GETTER(numberOfTRTOutliers) + GETTER(expectInnermostPixelLayerHit) + GETTER(numberOfPixelDeadSensors) + GETTER(numberOfSCTDeadSensors) + GETTER(numberOfTRTXenonHits) +#undef GETTER + + +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrackSummaryFloat_##_name_(const xAOD::Electron* eg) const\ +{ float val_float{0}; \ + if(eg){ \ + eg->trackParticleSummaryValue(val_float,xAOD::_name_); \ + return val_float; } \ + else return -99; } + GETTER(eProbabilityComb) + GETTER(eProbabilityHT) + GETTER(pixeldEdx) +#undef GETTER + + +// GETTERs for Calo-Track monitoring +#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getCaloTrackMatch_##_name_(const xAOD::Electron* eg) const\ +{ float val={-99.}; \ + if(eg){ \ + eg->trackCaloMatchValue(val,xAOD::EgammaParameters::_name_);} \ + return val; } + GETTER(deltaEta0) + GETTER(deltaPhi0) + GETTER(deltaPhiRescaled0) + GETTER(deltaEta1) + GETTER(deltaPhi1) + GETTER(deltaPhiRescaled1) + GETTER(deltaEta2) + GETTER(deltaPhi2) + GETTER(deltaPhiRescaled2) + GETTER(deltaEta3) + GETTER(deltaPhi3) + GETTER(deltaPhiRescaled3) +#undef GETTER + + + +TrigInfo TrigEgammaMonitorBaseAlgorithm::getTrigInfo(const std::string trigger) const{ + return m_trigInfo.at(trigger); +} + + + +// This is not const function and can not be used in execute mode (not thread safe) +// adds entry in TrigInfo map to retrieve later via trigger name +void TrigEgammaMonitorBaseAlgorithm::setTrigInfo(const std::string trigger){ + + /******************************************** + std::string trigName; //Trigger Name + std::string trigType; //Electron or Photon + std::string trigL1Item; //L1 item for HLT + std::string trigL1Type; //VHI + std::string trigPidType; //Loose, Medium, Tight, etc... + bool trigL1; // Level1 Trigger + bool trigPerf; // Performance chain + bool trigEtcut; // Et cut only chain + float trigThrHLT; // HLT Et threshold + float trigThrL1; // L1 Et threshold + *******************************************/ + + std::string type=""; + bool isL1=false; + float etthr=0; + float l1thr=0; + std::string l1type=""; + std::string pidname=""; + bool perf=false; + bool etcut=false; + parseTriggerName(trigger,m_defaultProbePid,isL1,type,etthr,l1thr,l1type,pidname,etcut,perf); // Determines probe PID from trigger + + std::string l1item = ""; + if(isL1) l1item=trigger; + else getL1Item(trigger); + std::string decorator="is"+pidname; + + if(isL1) etthr=l1thr; // Should be handled elsewhere + TrigInfo info{trigger,type,l1item,l1type,pidname,decorator,isL1,perf,etcut,etthr,l1thr,false}; + m_trigInfo[trigger] = info; +} + + + + + + + +bool TrigEgammaMonitorBaseAlgorithm::splitTriggerName(const std::string trigger, + std::string &p1trigger, + std::string &p2trigger) const { + + p1trigger=""; + p2trigger=""; + + std::string hltinfo=trigger; + if(boost::contains(hltinfo,"HLT")) hltinfo.erase(0,4); + std::vector<std::string> strs; + boost::split(strs,hltinfo,boost::is_any_of("_")); + + if((strs.at(0))[0]=='2'){ + ((p1trigger+=("HLT_"+((strs.at(0)).substr(1,(int)strs.at(0).find_last_of(strs.at(0)))))+="_")); + + for(unsigned int i=1; i<strs.size();i++){ + if(strs.at(i)=="Jpsiee") continue; + (p1trigger+="_")+=strs.at(i); + } + + p2trigger=p1trigger; + return true; + } + else{ + + if(strs.size()<4){ + return false; + } + + int index=-1; + p1trigger+=("HLT_"+strs.at(0)); + + for(int i=1; index<0;i++) + { + (p1trigger+="_")+=strs.at(i); + + if(strs.at(i+1)[0]=='e' || strs.at(i+1)[0]=='g') index=(i+1); + } + + p2trigger+=("HLT_"+strs.at(index)); + + for(unsigned int i=index+1; i< strs.size();i++){ + if(strs.at(i)=="Jpsiee") continue; + (p2trigger+="_")+=strs.at(i); + } + return true; + } + + +} + + + +void TrigEgammaMonitorBaseAlgorithm::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) const { + + // Analyze L1 or HLT item + bool result = boost::starts_with( trigger , "L1" ); + if (result) { + std::string l1info = trigger; + l1info.erase(0,4); + l1type = boost::trim_copy_if(l1info, boost::is_digit()); + std::string l1cut = boost::trim_copy_if(l1info, !boost::is_digit()); + l1threshold = atof(l1cut.c_str()); + threshold = l1threshold; + isL1=true; + pidname = defaultPid; + type = "electron"; // for now only electron L1 studies + } + else { + std::string hltinfo=trigger; + if(boost::contains(hltinfo,"HLT")) hltinfo.erase(0,4); + std::string l1item = getL1Item(trigger); + ATH_MSG_DEBUG("Trigger L1item " << trigger << " " << l1item << " " << hltinfo); + std::vector<std::string> strs; + boost::split(strs,hltinfo,boost::is_any_of("_")); + for (std::vector<std::string>::iterator it = strs.begin(); it != strs.end(); ++it) + { + ATH_MSG_DEBUG("Trigger parse " << *it); + } + // Set probe Pid from second part of trigger name + // Non pid triggers use default Probe which is set as a property + + + if(boost::contains(strs.at(0),"e")) type = "electron"; + else if(boost::contains(strs.at(0),"g")) type = "photon"; + else ATH_MSG_ERROR("Cannot set trigger type from name"); + if(boost::contains(strs.at(1),"perf")){ + pidname = defaultPid; + perf=true; + ATH_MSG_DEBUG("Perf " << perf << " " << pidname ); + } + else if(boost::contains(strs.at(1),"L2Star")){ + pidname = defaultPid; + perf=true; + ATH_MSG_DEBUG("L2Star " << perf << " " << pidname ); + } + else if(boost::contains(strs.at(1),"hiptrt")){ + pidname = defaultPid; + perf=true; + ATH_MSG_DEBUG("hiptrt " << perf << " " << pidname ); + } + else if( strs.at(1)== "etcut"){ + pidname = defaultPid; + etcut=true; + } + + //Get the L1 information + + if(boost::contains(strs.back(),"L1")){ + std::string l1info = strs.back(); + l1info.erase(0,4); + l1type = boost::trim_copy_if(l1info, boost::is_digit()); + std::string l1cut = boost::trim_copy_if(l1info, !boost::is_digit()); + l1threshold = atof(l1cut.c_str()); + + ATH_MSG_DEBUG("L1 item " << l1info << " " << l1threshold << " " << l1type); + } + + // Get the threshold + std::string str_thr = strs.at(0); + str_thr.erase( 0, 1); + threshold = atof(str_thr.c_str()); + + isL1=false; + ATH_MSG_DEBUG(trigger << " " << type << " " << pidname << " " << threshold); + } + +} + + + + +std::string TrigEgammaMonitorBaseAlgorithm::getProbePid(const std::string pidtype) const { + // Note vloose/lhvloose trigger mapped to Loose/LHLoose offline PID + return m_pidMap.at(pidtype); +} + + + +std::string TrigEgammaMonitorBaseAlgorithm::getL1Item(std::string trigger) const{ + auto trig_conf = m_trigdec->ExperimentalAndExpertMethods()->getChainConfigurationDetails(trigger); + std::string L1_seed = ""; + if(trig_conf != nullptr){ + ATH_MSG_DEBUG("TrigConf available"); + L1_seed = trig_conf->lower_chain_name(); //L1 trigger seed + } + return L1_seed; +} + + + + + +const std::vector<std::string> TrigEgammaMonitorBaseAlgorithm::m_trigLevel = {"L1Calo","L2Calo","L2","EFCalo","EFTrack","HLT"}; + +const std::map<std::string,std::string> TrigEgammaMonitorBaseAlgorithm::m_trigLvlMap = {{"L1Calo","Trigger L1Calo step"}, + {"L2Calo","Trigger L2Calo step"}, + {"L2","Trigger L2 step"}, + {"EFCalo","Trigger EFCalo step"}, + {"EFTrack","Trigger EFTrack step"}, + {"HLT","Trigger HLT accept"}}; + +const std::map<std::string, std::string> TrigEgammaMonitorBaseAlgorithm::m_pidMap = { {"vloose" , "Loose" }, + {"loose" , "Loose" }, + {"medium" , "Medium" }, + {"tight" , "Tight" }, + {"loose1" , "Loose" }, + {"medium1" , "Medium" }, + {"tight1" , "Tight" }, + {"lhvloose" , "LHLoose" }, + {"lhloose" , "LHLoose" }, + {"lhmedium" , "LHMedium"}, + {"lhtight" , "LHTight" } }; + + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorBaseAlgorithm.h b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorBaseAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..ba63d3ee6fe20aac838f78dfa980d938dade16c7 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorBaseAlgorithm.h @@ -0,0 +1,259 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrigEgammaMonitorBaseAlgorithm_h +#define TrigEgammaMonitorBaseAlgorithm_h + +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h" +#include "TrigEgammaAnalysisTools/TrigEgammaInfo.h" + +#include "AthenaMonitoringKernel/GenericMonitoringTool.h" +#include "TrigDecisionTool/TrigDecisionTool.h" +#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h" +#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h" +#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" + +#include "xAODEventInfo/EventInfo.h" +#include "xAODTruth/TruthParticleContainer.h" +#include "xAODEgamma/Egamma.h" +#include "xAODEgamma/EgammaxAODHelpers.h" +#include "xAODEgamma/ElectronContainer.h" +#include "xAODEgamma/PhotonContainer.h" +#include "xAODTrigEgamma/TrigElectronContainer.h" +#include "xAODTrigEgamma/TrigPhotonContainer.h" +#include "xAODTracking/TrackParticleContainer.h" +#include "xAODTrigCalo/TrigEMClusterContainer.h" +#include "xAODJet/JetContainer.h" +#include "xAODMissingET/MissingETContainer.h" +#include "xAODTrigger/EmTauRoIContainer.h" + +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/ReadCondHandleKey.h" +#include "PATCore/AcceptInfo.h" +#include "PATCore/AcceptData.h" + + + + +class TrigEgammaMonitorBaseAlgorithm : public AthMonitorAlgorithm { + public: + + + TrigEgammaMonitorBaseAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + + + virtual ~TrigEgammaMonitorBaseAlgorithm(); + + virtual StatusCode initialize() override; + + virtual StatusCode fillHistograms(const EventContext& /*ctx*/) const override {return StatusCode::SUCCESS;}; + + private: + + /*! Trigger decision tool */ + ToolHandle<Trig::TrigDecisionTool> m_trigdec; + /*! creates map of trigger name and TrigInfo struct */ + std::map<std::string,TrigInfo> m_trigInfo; + + + static const std::vector<std::string> m_trigLevel; + static const std::map<std::string,std::string> m_trigLvlMap; + static const std::map<std::string, std::string> m_pidMap; + + + + protected: + + /* Trigger e/g matching tool */ + ToolHandle<TrigEgammaMatchingToolMT> m_matchTool; + /*! Offline isEM Selectors */ + ToolHandleArray<IAsgElectronIsEMSelector> m_electronIsEMTool{this,"ElectronIsEMSelector",{}}; + /*! Offline LH Selectors */ + ToolHandleArray<IAsgElectronLikelihoodTool> m_electronLHTool{this,"ElectronLikelihoodTool",{}}; + /*! Offline LH Very loose selector */ + ToolHandle<IAsgElectronLikelihoodTool> m_electronLHVLooseTool{this,"ElectronLHVLooseTool", ""}; + + + /*! TP Trigger Analysis */ + Gaudi::Property<bool> m_tp{this, "TPTrigger", false }; + /*! default probe pid for trigitems that don't have pid in their name */ + Gaudi::Property<std::string> m_defaultProbePid{this, "DefaultProbeSelection", "Loose"}; + /*! isem names */ + Gaudi::Property<std::vector<std::string>> m_isemname{this, "isEMResultNames", {} }; + /*! lh names */ + Gaudi::Property<std::vector<std::string>> m_lhname{this, "LHResultNames", {} }; + /*! Include more detailed histograms */ + Gaudi::Property<bool> m_detailedHists{this, "DetailedHistograms", false}; + + + + /** Helper methods **/ + + /*! Get the trig info map */ + std::map<std::string,TrigInfo> getTrigInfoMap() { return m_trigInfo; } + /*! Get offline electron decision */ + bool ApplyElectronPid(const xAOD::Electron *eg,const std::string) const; + /*! Get the TDT */ + const ToolHandle<Trig::TrigDecisionTool>& tdt() const {return m_trigdec;}; + /*! Get the e/g match tool */ + const ToolHandle<TrigEgammaMatchingToolMT>& match() const {return m_matchTool;} + /*! Set the accept object for all trigger levels */ + asg::AcceptData setAccept(const TrigCompositeUtils::Decision*, const TrigInfo) const; + /*! Get the trigger info parsed from the chain name */ + TrigInfo getTrigInfo(const std::string) const; + /*! Get delta R */ + float dR(const float, const float, const float, const float) const; + /*! 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&) const; + /*! Split double object trigger in two simple object trigger */ + bool splitTriggerName(const std::string, std::string &, std::string &) const; + /*! Creates static map to return L1 item from trigger name */ + std::string getL1Item(std::string trigger) const; + /*! Check if electron fulfils isolation criteria */ + bool isIsolated(const xAOD::Electron*, const std::string) const; + /*! Check if the event is prescaled */ + bool isPrescaled(const std::string) const; + /*! Get the pid name */ + std::string getProbePid(const std::string) const; + /*! Set the trigger info parsed from the chain name */ + void setTrigInfo(const std::string); + + + + /** Features helper **/ + + + + /*! Helper functions now part of base class */ + float getEta2(const xAOD::Egamma* eg) const; + float getEt(const xAOD::Electron* eg) const ; + float getEtCluster37(const xAOD::Egamma* eg) const; + float getDEmaxs1(const xAOD::Egamma *eg) const; + float rTRT (const xAOD::Electron* eg) const; + float getSigmaD0(const xAOD::Electron *eg) const; + float getD0sig(const xAOD::Electron *eg) const; + float getEnergyBE0(const xAOD::Egamma *eg) const; + float getEnergyBE1(const xAOD::Egamma *eg) const; + float getEnergyBE2(const xAOD::Egamma *eg) const; + float getEnergyBE3(const xAOD::Egamma *eg) const; + float getEaccordion(const xAOD::Egamma *eg) const; + float getE0Eaccordion(const xAOD::Egamma *eg) const; + + + + + + + + + + /*! C Macros for plotting */ +#define GETTER(_name_) float getShowerShape_##_name_(const xAOD::Egamma* eg) const; + GETTER(e011) + GETTER(e132) + GETTER(e237) + GETTER(e277) + GETTER(ethad) + GETTER(ethad1) + GETTER(weta1) + GETTER(weta2) + GETTER(f1) + GETTER(e2tsts1) + GETTER(emins1) + GETTER(emaxs1) + GETTER(wtots1) + GETTER(fracs1) + GETTER(Reta) + GETTER(Rphi) + GETTER(f3) + GETTER(f3core) + GETTER(Eratio) + GETTER(Rhad) + GETTER(Rhad1) + GETTER(DeltaE) +#undef GETTER + + + // GETTER for Isolation monitoring +#define GETTER(_name_) float getIsolation_##_name_(const xAOD::Electron* eg) const; + GETTER(ptcone20) + GETTER(ptcone30) + GETTER(ptcone40) + GETTER(ptvarcone20) + GETTER(ptvarcone30) + GETTER(ptvarcone40) +#undef GETTER +#define GETTER(_name_) float getIsolation_##_name_(const xAOD::Egamma* eg) const; + GETTER(etcone20) + GETTER(etcone30) + GETTER(etcone40) + GETTER(topoetcone20) + GETTER(topoetcone30) + GETTER(topoetcone40) +#undef GETTER + // GETTERs for CaloCluster monitoring +#define GETTER(_name_) float getCluster_##_name_(const xAOD::Egamma* eg) const; + GETTER(et) + GETTER(phi) + GETTER(eta) +#undef GETTER + + // GETTERs for Track monitoring +#define GETTER(_name_) float getTrack_##_name_(const xAOD::Electron* eg) const; + GETTER(pt) + GETTER(phi) + GETTER(eta) + GETTER(d0) + GETTER(z0) +#undef GETTER + + + // GETTERs for Track details monitoring +#define GETTER(_name_) float getTrackSummary_##_name_(const xAOD::Electron* eg) const; + GETTER(numberOfInnermostPixelLayerHits) + GETTER(numberOfInnermostPixelLayerOutliers) + GETTER(numberOfPixelHits) + GETTER(numberOfPixelOutliers) + GETTER(numberOfSCTHits) + GETTER(numberOfSCTOutliers) + GETTER(numberOfTRTHits) + GETTER(numberOfTRTHighThresholdHits) + GETTER(numberOfTRTHighThresholdOutliers) + GETTER(numberOfTRTOutliers) + GETTER(expectInnermostPixelLayerHit) + GETTER(numberOfPixelDeadSensors) + GETTER(numberOfSCTDeadSensors) + GETTER(numberOfTRTXenonHits) +#undef GETTER + +#define GETTER(_name_) float getTrackSummaryFloat_##_name_(const xAOD::Electron* eg) const; + GETTER(eProbabilityComb) + GETTER(eProbabilityHT) + GETTER(pixeldEdx) +#undef GETTER + + // GETTERs for Calo-Track monitoring +#define GETTER(_name_) float getCaloTrackMatch_##_name_(const xAOD::Electron* eg) const; + GETTER(deltaEta0) + GETTER(deltaPhi0) + GETTER(deltaPhiRescaled0) + GETTER(deltaEta1) + GETTER(deltaPhi1) + GETTER(deltaPhiRescaled1) + GETTER(deltaEta2) + GETTER(deltaPhi2) + GETTER(deltaPhiRescaled2) + GETTER(deltaEta3) + GETTER(deltaPhi3) + GETTER(deltaPhiRescaled3) +#undef GETTER + + + + + +}; +#endif + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorElectronAlgorithm.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorElectronAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..52b9dae1a9cabf735ed75dcd25561fbe8402a86b --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorElectronAlgorithm.cxx @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigEgammaMonitorElectronAlgorithm.h" + + +using namespace Trig; + + +TrigEgammaMonitorElectronAlgorithm::TrigEgammaMonitorElectronAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ): + TrigEgammaMonitorAnalysisAlgorithm( name, pSvcLocator ) +{} + +TrigEgammaMonitorElectronAlgorithm::~TrigEgammaMonitorElectronAlgorithm() +{} + + + +StatusCode TrigEgammaMonitorElectronAlgorithm::initialize() +{ + + ATH_CHECK(TrigEgammaMonitorAnalysisAlgorithm::initialize()); + ATH_CHECK(m_offElectronKey.initialize()); + + + for(const auto trigName:m_trigInputList) + { + if(getTrigInfoMap().count(trigName) != 0){ + ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); + }else { + m_trigList.push_back(trigName); + setTrigInfo(trigName); + } + } + + + return StatusCode::SUCCESS; +} + + + +StatusCode TrigEgammaMonitorElectronAlgorithm::fillHistograms( const EventContext& ctx ) const +{ + + ATH_MSG_DEBUG("Executing TrigEgammaMonitorElectronAlgorithm"); + + if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ + ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis"); + return StatusCode::SUCCESS; + } + + + ATH_MSG_DEBUG("Chains for Analysis " << m_trigList); + + for(const auto trigger : m_trigList){ + + const TrigInfo info = getTrigInfo(trigger); + + ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger << " " << info.trigName); + + + std::vector< std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> pairObjs; + + if ( executeNavigation( ctx, info.trigName,info.trigThrHLT,info.trigPidType, pairObjs).isFailure() ) + { + ATH_MSG_WARNING("executeNavigation Fails"); + return StatusCode::SUCCESS; + } + + + + + fillDistributions( pairObjs, info ); + fillEfficiencies( pairObjs, info ); + + + ATH_MSG_DEBUG("End Chain Analysis ============================= " << trigger); + } // End loop over trigger list + + + return StatusCode::SUCCESS; +} + + + + + + + +StatusCode TrigEgammaMonitorElectronAlgorithm::executeNavigation( const EventContext& ctx, + std::string trigItem, + float etthr, + std::string pidname, + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision* >> &pairObjs) const +{ + + ATH_MSG_DEBUG("Apply navigation selection "); + + SG::ReadHandle<xAOD::ElectronContainer> offElectrons(m_offElectronKey, ctx); + + if(!offElectrons.isValid()) + { + ATH_MSG_WARNING("Failed to retrieve offline Electrons "); + return StatusCode::FAILURE; + } + + + const std::string decor="is"+pidname; + for(const auto& eg : *offElectrons ){ + + const TrigCompositeUtils::Decision *dec=nullptr; + + if(!eg->trackParticle()){ + ATH_MSG_DEBUG("No track Particle"); + continue; + } + if(!eg->caloCluster()){ + ATH_MSG_DEBUG("No caloCluster"); + continue; + } + + if(m_forceEtThr){///default is true + if( !( getEt(eg) > (etthr-5.)*1.e3) ) continue; + } + + if(m_rmCrack){///default is true + if ( (fabs(eg->eta())>1.37 && fabs(eg->eta())<1.52) || fabs(eg->eta())>2.47 ) continue; + } + + if(m_forcePidSelection){///default is true + if(!ApplyElectronPid(eg,pidname)){ + ATH_MSG_DEBUG("Fails ElectronID "<< pidname); + continue; + } + ATH_MSG_DEBUG("Passes ElectronID "<< pidname); + } + + if (m_forceProbeIsolation) {///default is false + if (!isIsolated(eg, m_offProbeIsolation)) continue;///default is Loose + } + + if(m_forceVetoVeryLoose){///default is false + bool veto = (bool)this->m_electronLHVLooseTool->accept(eg); + if(veto) continue; + } + + xAOD::Electron *el = new xAOD::Electron(*eg); + el->auxdecor<bool>(decor)=static_cast<bool>(true); + + match()->match(el, trigItem, dec); + std::pair< const xAOD::Electron*, const TrigCompositeUtils::Decision * > pair(el,dec); + pairObjs.push_back(pair); + + } + + ATH_MSG_DEBUG("BaseToolMT::Electron TEs " << pairObjs.size() << " found."); + return StatusCode::SUCCESS; +} + + + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorElectronAlgorithm.h b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorElectronAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..c5863b2835b408ac5a30e46317be921b1f0bd9ea --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorElectronAlgorithm.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrigEgammaMonitorElectronAlgorithm_H +#define TrigEgammaMonitorElectronAlgorithm_H + + +#include "TrigEgammaMonitorAnalysisAlgorithm.h" + + + +class TrigEgammaMonitorElectronAlgorithm: public TrigEgammaMonitorAnalysisAlgorithm +{ + + public: + + TrigEgammaMonitorElectronAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + + virtual ~TrigEgammaMonitorElectronAlgorithm() override; + + virtual StatusCode initialize() override; + + virtual StatusCode fillHistograms( const EventContext& ctx) const override; + + + + private: + + + + /*! navigation method called by executeNavigation */ + StatusCode executeNavigation(const EventContext& ctx, const std::string trigItem,float,std::string, + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> &) const; + + + /*! List of triggers to study */ + std::vector<std::string> m_trigList; + + /*! List of triggers from menu */ + Gaudi::Property<std::vector<std::string>> m_trigInputList{this, "TriggerList", {}}; + /*! Directory name for each algorithm */ + Gaudi::Property<std::string> m_anatype{this, "Analysis", "Electron"}; + /*! Define isolation working point for Probe electron */ + Gaudi::Property<std::string> m_offProbeIsolation{ this, "OfflineProbeIsolation", "Loose"}; + /*! force probe isolation */ + Gaudi::Property<bool> m_forceProbeIsolation{this, "ForceProbeIsolation", false}; + /*! force pid and crack selection into electron navigation */ + Gaudi::Property<bool> m_forcePidSelection{ this, "ForcePidSelection", true}; + /* force et cluster cut*/ + Gaudi::Property<bool> m_forceEtThr{ this, "ForceEtThreshold", true}; + /* force experimentalSelection selection*/ + Gaudi::Property<bool> m_forceVetoVeryLoose{ this, "ForceVetoVeryLoose", false}; + /*! Remove crack region for Probe default True */ + Gaudi::Property<bool> m_rmCrack{ this, "RemoveCrack", true}; + + // Containers + /*! Event Wise offline ElectronContainer Access and end iterator */ + SG::ReadHandleKey<xAOD::ElectronContainer> m_offElectronKey{ this, "ElectronKey", "Electrons", ""}; + +}; + +#endif diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorPhotonAlgorithm.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorPhotonAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4092832d1fcefc159470799bc945c13a4849952f --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorPhotonAlgorithm.cxx @@ -0,0 +1,114 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigEgammaMonitorPhotonAlgorithm.h" + + +using namespace Trig; + + +TrigEgammaMonitorPhotonAlgorithm::TrigEgammaMonitorPhotonAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ): + TrigEgammaMonitorAnalysisAlgorithm( name, pSvcLocator ) +{} + +TrigEgammaMonitorPhotonAlgorithm::~TrigEgammaMonitorPhotonAlgorithm() +{} + + + +StatusCode TrigEgammaMonitorPhotonAlgorithm::initialize() +{ + + ATH_CHECK(TrigEgammaMonitorAnalysisAlgorithm::initialize()); + ATH_CHECK(m_offPhotonKey.initialize()); + + return StatusCode::SUCCESS; +} + + +StatusCode TrigEgammaMonitorPhotonAlgorithm::fillHistograms( const EventContext& ctx ) const +{ + + ATH_MSG_DEBUG("Executing TrigEgammaMonitorPhotonAlgorithm"); + + if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ + ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis"); + return StatusCode::SUCCESS; + } + + + ATH_MSG_DEBUG("Chains for Analysis " << m_trigList); + + for(const auto trigger : m_trigList){ + + const TrigInfo info = getTrigInfo(trigger); + + ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger << " " << info.trigName); + + std::vector< std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision * >> pairObjs; + + if ( executeNavigation( ctx, info.trigName,info.trigThrHLT,pairObjs).isFailure() ) + { + ATH_MSG_WARNING("executeNavigation Fails"); + return StatusCode::SUCCESS; + } + + + ATH_MSG_DEBUG("End Chain Analysis ============================= " << trigger); + } // End loop over trigger list + + + return StatusCode::SUCCESS; +} + + + + + +StatusCode TrigEgammaMonitorPhotonAlgorithm::executeNavigation( const EventContext& ctx, std::string trigItem, float etthr, + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision * >> &pairObjs) + const +{ + ATH_MSG_DEBUG("Apply navigation selection"); + + + SG::ReadHandle<xAOD::PhotonContainer> offPhotons(m_offPhotonKey, ctx); + + if(!offPhotons.isValid()) + { + ATH_MSG_WARNING("Failed to retrieve offline Electrons "); + return StatusCode::FAILURE; + } + + + const std::string decor="is"+m_photonPid; + + for(const auto& eg : *offPhotons ){ + const TrigCompositeUtils::Decision *dec=nullptr; + if(!eg->caloCluster()){ + ATH_MSG_DEBUG("No caloCluster"); + continue; + } + if( !(getCluster_et(eg) > (etthr-5.)*Gaudi::Units::GeV)) continue; //Take 2GeV above threshold + if(!eg->passSelection(m_photonPid)) continue; + if(m_doUnconverted){ + if (eg->vertex()){ + ATH_MSG_DEBUG("Removing converted photons, continuing..."); + continue; + } + } + xAOD::Photon *ph = new xAOD::Photon(*eg); + ph->auxdecor<bool>(decor)=static_cast<bool>(true); + match()->match(ph, trigItem, dec); + std::pair< const xAOD::Photon*, const TrigCompositeUtils::Decision * > pair(ph,dec); + pairObjs.push_back(pair); + + } + + ATH_MSG_DEBUG("BaseToolMT::Photon TEs " << pairObjs.size() << " found."); + return StatusCode::SUCCESS; +} + + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorPhotonAlgorithm.h b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorPhotonAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..f8d9f1f54c9c6f2846115d8b4585b7564c70bb12 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorPhotonAlgorithm.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TrigEgammaMonitorPhotonAlgorithm_H +#define TrigEgammaMonitorPhotonAlgorithm_H + + +#include "TrigEgammaMonitorAnalysisAlgorithm.h" + + + + +class TrigEgammaMonitorPhotonAlgorithm: public TrigEgammaMonitorAnalysisAlgorithm +{ + + public: + + TrigEgammaMonitorPhotonAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + + virtual ~TrigEgammaMonitorPhotonAlgorithm() override; + + virtual StatusCode initialize() override; + + virtual StatusCode fillHistograms( const EventContext& ctx) const override; + + + + private: + + + + /*! navigation method called by executeNavigation */ + StatusCode executeNavigation(const EventContext& ctx, const std::string trigItem,float, + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> &) const; + + /*! List of triggers to study */ + std::vector<std::string> m_trigList; + /*! Photon pid word */ + Gaudi::Property<std::string> m_photonPid{this, "PhotonPid","Tight" }; + /*! doUnconverted analysis */ + Gaudi::Property<bool> m_doUnconverted{this, "DoUnconverted", true}; + /*! List of triggers from menu */ + Gaudi::Property<std::vector<std::string>> m_trigInputList{this, "TriggerList", {}}; + /*! Directory name for each algorithm */ + Gaudi::Property<std::string> m_anatype{this, "Analysis", "Photon"}; + + // Containers + /*! Event Wise offline ElectronContainer Access and end iterator */ + SG::ReadHandleKey<xAOD::PhotonContainer> m_offPhotonKey{ this, "PhotonKey", "Photons", ""}; + +}; + +#endif diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorTagAndProbeAlgorithm.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorTagAndProbeAlgorithm.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6b3bcb8aadc16e055315ab415c15f06f9fd52e63 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorTagAndProbeAlgorithm.cxx @@ -0,0 +1,580 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/********************************************************************** + * AsgTool: TrigEgammaNavTPBaseTool + * Authors: + * Joao Victor Pinto <jodafons@cern.ch> + * Description: + * Trigger e/gamma Zee Tag&Probe Base tool class. Inherits from TrigEgammaAnalysisBaseTool. + * Provides methods for selecting T&P pairs, + * matching probes to objects in TE containers. + * Creates a vector of pairs with + * offline electrons probes and the last TE with a match. + * Relies heavily on TrigNavigation, since we use the TriggerDecision. + * All derived classes work with list of probes for a given trigger. + * As input property, pass a list of triggers to study. + **********************************************************************/ + +#include "TrigEgammaMonitorTagAndProbeAlgorithm.h" +#include "TrigConfxAOD/xAODConfigTool.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "string" +#include <algorithm> +#include "boost/algorithm/string.hpp" +#include <boost/tokenizer.hpp> +#include <boost/foreach.hpp> + +//********************************************************************** +using namespace Trig; +using namespace TrigConf; +using namespace xAOD; +using namespace boost; + +TrigEgammaMonitorTagAndProbeAlgorithm::TrigEgammaMonitorTagAndProbeAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ): + TrigEgammaMonitorAnalysisAlgorithm( name, pSvcLocator ) + + +{} + + +TrigEgammaMonitorTagAndProbeAlgorithm::~TrigEgammaMonitorTagAndProbeAlgorithm() +{} + + +StatusCode TrigEgammaMonitorTagAndProbeAlgorithm::initialize() { + + ATH_CHECK(TrigEgammaMonitorBaseAlgorithm::initialize() ); + ATH_CHECK(m_eventInfoKey.initialize()); + ATH_CHECK(m_offElectronKey.initialize()); + ATH_CHECK(m_jetKey.initialize()); + + + ATH_MSG_INFO("Now configuring chains for analysis: " << name() ); + std::vector<std::string> chains = tdt()->getListOfTriggers("HLT_e.*, L1_EM.*, HLT_g.*"); + + for(const auto trigName:m_trigInputList) + { + if (std::find(chains.begin(), chains.end(), trigName) != chains.end()){ + if(getTrigInfoMap().count(trigName) != 0){ + ATH_MSG_WARNING("Trigger already booked, removing from trigger list " << trigName); + }else { + m_trigList.push_back(trigName); + setTrigInfo(trigName); + } + } + } + + return StatusCode::SUCCESS; +} + + + + + +StatusCode TrigEgammaMonitorTagAndProbeAlgorithm::fillHistograms( const EventContext& ctx ) const { + + + std::vector<const xAOD::Electron*> probes; + + // Select TP Pairs + ATH_MSG_DEBUG("Execute TP selection"); + if( !executeTandP(ctx, probes) ){ + ATH_MSG_WARNING("Tag and Probe event failed."); + return StatusCode::SUCCESS; + } + + + // Check HLTResult + if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ + ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis"); + return StatusCode::SUCCESS; + } + + + + for(unsigned int ilist = 0; ilist != m_trigList.size(); ilist++) { + + + std::string probeTrigger = m_trigList.at(ilist); + + /** Pair objects used in executeTool **/ + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> pairObjs; + + ATH_MSG_DEBUG("Start Chain Analysis ============================= " << probeTrigger); + + + const TrigInfo info = getTrigInfo(probeTrigger); + std::string trigName=probeTrigger; + + ATH_MSG_DEBUG("Trigger " << probeTrigger << " pidword " << info.trigPidDecorator << " threshold " << info.trigThrHLT); + matchObjects(trigName, probes, pairObjs); + + // Just for counting + ATH_MSG_DEBUG("Probes " << probes.size() << " Pairs " << pairObjs.size() ); + + // Include fill here + + + } // End loop over trigger list + + + return StatusCode::SUCCESS; +} + + + + + + + + +bool TrigEgammaMonitorTagAndProbeAlgorithm::executeTandP( const EventContext& ctx, std::vector<const xAOD::Electron*> &probeElectrons) const +{ + + auto monGroup = getGroup( "Event" ); + + fillLabel(monGroup, m_anatype+"_CutCounter", "Events"); + + + SG::ReadHandle<xAOD::EventInfo> eventInfo( m_eventInfoKey, ctx ); + if( !eventInfo.isValid() ){ + ATH_MSG_WARNING("Failed to retrieve EventInfo"); + return false; + } + + + if (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error) { + ATH_MSG_WARNING("Event not passing LAr"); + return false; + } + + fillLabel(monGroup, m_anatype+"_CutCounter", "LAr"); + + + + SG::ReadHandle<xAOD::ElectronContainer> offElectrons(m_offElectronKey, ctx); + + if(!offElectrons.isValid()) + { + ATH_MSG_WARNING("Failed to retrieve offline Electrons "); + return false; + } + + fillLabel(monGroup, m_anatype+"_CutCounter", "RetrieveElectrons"); + + + + + + ATH_MSG_DEBUG( "Electron size is " << offElectrons->size() ); + + // Check Size of Electron Container + if ( offElectrons->size() < 2 ) { // Not enough events for T&P + ATH_MSG_DEBUG("Not enough Electrons for T&P"); + return false; + } + + fillLabel(monGroup, m_anatype+"_CutCounter", "TwoElectrons"); + + + + + SG::ReadHandle<xAOD::JetContainer> jets(m_jetKey); + if(!jets.isValid()){ + ATH_MSG_WARNING("Failed to retrieve JetContainer"); + return false; + } + + ATH_MSG_DEBUG( "Jet size is " << jets->size()); + + + if(!m_tagTrigList.empty()){ + if(m_applyMinimalTrigger){ + if ( !minimalTriggerRequirement() ) + return false; + } + fillLabel(monGroup, m_anatype+"_CutCounter", "PassTrigger"); + + }else{ + ATH_MSG_DEBUG("Disable trigger tags because trigger tags list is empty."); + } + + + + + + ATH_MSG_DEBUG("Execute TandP BaseTool " << offElectrons->size()); + for(const auto& elTag : *offElectrons) + { + if( ! isTagElectron( monGroup, elTag) ) continue; + + for(const auto& elProbe : *offElectrons) + { // Dress the probes with updated Pid decision + + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "Electrons"); + + if(elProbe==elTag) continue; + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "NotTags"); + // Check opposite charge + if(m_oppositeCharge && (elProbe->charge() == elTag->charge()) ) continue; + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "OS"); + if(!m_oppositeCharge && (elProbe->charge() != elTag->charge()) ) continue; + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "SS"); + + ATH_MSG_DEBUG("Execute TandP BaseTool OS"); + + if(m_doJpsiee){ + + float Jpsieelifetime = getPseudoLifetime(elTag,elProbe); + + if( dR(elTag->caloCluster()->eta(),elTag->caloCluster()->phi(), + elProbe->caloCluster()->eta(),elProbe->caloCluster()->phi()) <= 0.2 ){ + ATH_MSG_DEBUG("dR(elTag,elProbe)<0.2"); + continue; + + } + else if(Jpsieelifetime<-1 || 0.2<Jpsieelifetime){ + ATH_MSG_DEBUG("tag and probe pair not in Jpsi lifetime window"); + 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*1.e3) && (tpPairMass < m_ZeeMassMax*1.e3))){ + ATH_MSG_DEBUG("tag and probe pair not in Z mass window"); + continue; + } else { + //fill( monGroup, m_anatype+"_ProbeCutCounter", "ZMass"); + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "ZMass"); + + ATH_MSG_DEBUG("tag and probe pair in Z mass window"); + // Probe available. Good Probe? + if(!isGoodProbeElectron(monGroup, elProbe, jets.cptr())) continue; + //fill( monGroup, m_anatype+"_ProbeCutCounter", "GoodProbe"); + + xAOD::Electron *selProbe = new xAOD::Electron(*elProbe); + dressPid(selProbe); + + probeElectrons.push_back(selProbe); + + auto mon_count_probe= Monitored::Scalar<std::string>(m_anatype+"_PorbeCutCounter","GoodProbe"); + auto mon_mee = Monitored::Scalar<float>(m_anatype+"_Mee" , tpPairMass/1.e3 ); + fill( monGroup , mon_count_probe, mon_mee ); + } + } // end of for in Probe + } // end of for in Tags + + + ATH_MSG_DEBUG( "Number of probes found is " << probeElectrons.size() ); + return true; +} + + + +bool TrigEgammaMonitorTagAndProbeAlgorithm::minimalTriggerRequirement() const { + + ATH_MSG_DEBUG("Apply Minimal trigger requirements"); + for(unsigned int ilist = 0; ilist != m_tagTrigList.size(); ilist++) { + std::string tag = m_tagTrigList.at(ilist); + if ( tdt()->isPassed(tag) ) + return true; + } + return false; +} + + + +void TrigEgammaMonitorTagAndProbeAlgorithm::matchObjects(const std::string probeTrigItem, + std::vector<const xAOD::Electron*> probeElectrons, + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision *>> &pairObj ) const +{ + for( const auto *el : probeElectrons) + { + const TrigCompositeUtils::Decision *dec=nullptr; + match()->match(el, probeTrigItem, dec); + std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision *> pairProbe(el,dec); + pairObj.push_back(pairProbe); + } +} + + + + + +bool TrigEgammaMonitorTagAndProbeAlgorithm::isTagElectron( ToolHandle<GenericMonitoringTool> monGroup, + const xAOD::Electron *el) const +{ + fillLabel(monGroup, m_anatype+"_TagCutCounter", "Electrons"); + + + // Tag the event + // Require offline tight electron + // Match to e24_tight1_L1EM20V + ATH_MSG_DEBUG("Selecting Tag Electron"); + + //Check constituents + const xAOD::TrackParticle *trk = el->trackParticle(); + if(!el->trackParticle()){ + ATH_MSG_DEBUG("No track Particle"); + return false; + } + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "HasTrack"); + + + ATH_MSG_DEBUG("Track pt " << trk->pt()); + const xAOD::CaloCluster *clus = el->caloCluster(); + if(!el->caloCluster()){ + ATH_MSG_DEBUG("No caloCluster"); + return false; + } + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "HasCluster"); + + + + ATH_MSG_DEBUG("Cluster E "<<clus->e()); + ATH_MSG_DEBUG("Selecting Tag Electron PID"); + if (!ApplyElectronPid(el, m_offTagTightness)) return false; + fillLabel(monGroup, m_anatype+"_TagCutCounter", "GoodPid"); + + + + + ATH_MSG_DEBUG("Selecting Tag Electron Et"); + //Require Et > 25 GeV + if( !(el->e()/cosh(el->trackParticle()->eta()) > m_tagMinEt*Gaudi::Units::GeV) ){ + return false; + } + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "Et"); + + + + + ATH_MSG_DEBUG("Selecting Tag Electron Eta"); + //fiducial detector acceptance region + float absEta = fabs(el->caloCluster()->etaBE(2)); + if ((absEta > 1.37 && absEta < 1.52) || absEta > 2.47) { + return false; + } + + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "Eta"); + + + + ATH_MSG_DEBUG("Checking electron object quality"); + if (!el->isGoodOQ(xAOD::EgammaParameters::BADCLUSELECTRON)) return false; + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "IsGoodOQ"); + + + + + if(m_tagTrigList.empty()) + { + ATH_MSG_DEBUG("Found a tag electron"); + return true; + } + + + ATH_MSG_DEBUG("Selecting Tag Electron Decision"); + // Check matching to a given trigger + // The statement below is more general + bool tagPassed=false; + for(unsigned int ilist = 0; ilist != m_tagTrigList.size(); ilist++) { + std::string tag = m_tagTrigList.at(ilist); + if(tdt()->isPassed(tag)){ + if(m_tp){ + std::string p1trigger; + std::string p2trigger; + if(splitTriggerName(tag,p1trigger,p2trigger)){ + if(fabs(p1trigger.find("tight"))<14) tag=p1trigger; + if(fabs(p2trigger.find("tight"))<14) tag=p2trigger; + } + if( match()->match(el,tag) ) + tagPassed=true; + } + else{ + tagPassed=true; + } + } + } + if(!tagPassed) { + ATH_MSG_DEBUG("Failed tag trigger "); + return false; + } + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "PassTrigger"); + + + ATH_MSG_DEBUG("Matching Tag Electron FC"); + bool tagMatched=false; + for(unsigned int ilist = 0; ilist != m_tagTrigList.size(); ilist++) { + std::string tag = m_tagTrigList.at(ilist); + if( match()->match(el,tag) ) + tagMatched=true; + } + + if(!tagMatched){ + ATH_MSG_DEBUG("Failed a match "); + return false; // otherwise, someone matched! + } + + fillLabel(monGroup, m_anatype+"_TagCutCounter", "MatchTrigger"); + + ATH_MSG_DEBUG("Found a tag electron"); + return true; +} + + + + + + +bool TrigEgammaMonitorTagAndProbeAlgorithm::isGoodProbeElectron( ToolHandle<GenericMonitoringTool> monGroup, + const xAOD::Electron *el, + const xAOD::JetContainer *jets ) const +{ + + + //Check constituents + if(!el->trackParticle()){ + ATH_MSG_DEBUG("No track Particle"); + return false; + } + + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "HasTrack"); + + if(!el->caloCluster()){ + ATH_MSG_DEBUG("No caloCluster"); + return false; + } + + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "HasCluster"); + + //fiducial detector acceptance region + if(m_rmCrack){ + float absEta = fabs(el->caloCluster()->etaBE(2)); + if ((absEta > 1.37 && absEta < 1.52) || absEta > 2.47) { + return false; + } + } + + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "Eta"); + + + ATH_MSG_DEBUG("Checking electron object quality"); + if (!el->isGoodOQ(xAOD::EgammaParameters::BADCLUSELECTRON)) return false; + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "IsGoodOQ"); + + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "GoodPid"); + + + if(m_applyJetNearProbeSelection){ + TLorentzVector probeCandidate; + probeCandidate.SetPtEtaPhiE(el->pt(), el->trackParticle()->eta(), el->trackParticle()->phi(), el->e()); + Int_t jetsAroundProbeElectron = 0; + for(const auto &i_jet : *jets){ + TLorentzVector jet; + jet.SetPtEtaPhiE(i_jet->pt(), i_jet->eta(), i_jet->phi(), i_jet->e()); + if( (jet.Et() > 20*Gaudi::Units::GeV) && (jet.DeltaR(probeCandidate) < 0.4)) jetsAroundProbeElectron++; + } + //reject if more than 1 jet close to the probe electron + if ( jetsAroundProbeElectron >= 2 ) { + //ATH_MSG_DEBUG("too many jets around object"); + return false; + } + } + fillLabel(monGroup, m_anatype+"_ProbeCutCounter", "NearbyJet"); + + return true; // Good probe electron +} + + + +void TrigEgammaMonitorTagAndProbeAlgorithm::dressPid(const xAOD::Electron *eg) const +{ + auto ctx = Gaudi::Hive::currentContext() ; + for(int ipid=0;ipid<3;ipid++){ + bool accept = (bool) this->m_electronIsEMTool[ipid]->accept(ctx,eg); + const std::string pidname="is"+m_isemname[ipid]; + eg->auxdecor<bool>(pidname)=static_cast<bool>(accept); + } + for(int ipid=0;ipid<2;ipid++){ + bool accept = (bool) this->m_electronLHTool[ipid]->accept(ctx,eg); + const std::string pidname="is"+m_lhname[ipid]; + eg->auxdecor<bool>(pidname)=static_cast<bool>(accept); + } + eg->auxdecor<bool>("Isolated")=isIsolated(eg, m_offProbeIsolation); +} + + + + + + + +float TrigEgammaMonitorTagAndProbeAlgorithm::getPseudoLifetime(const xAOD::Electron *el1,const xAOD::Electron *el2) const +{ + + TLorentzVector el1track; + TLorentzVector el2track; + + float Et1=hypot(el1->caloCluster()->m(),el1->caloCluster()->pt())/cosh(el1->trackParticle()->eta()); + float Et2=hypot(el2->caloCluster()->m(),el2->caloCluster()->pt())/cosh(el1->trackParticle()->eta()); + + el1track.SetPtEtaPhiM(Et1, el1->trackParticle()->eta(), el1->trackParticle()->phi(),0.511); + el2track.SetPtEtaPhiM(Et2, el2->trackParticle()->eta(), el2->trackParticle()->phi(), 0.511); + + float lxy=simple_lxy(0, + el1->trackParticle()->d0() , el2->trackParticle()->d0(), + el1->trackParticle()->phi(), el2->trackParticle()->phi(), + Et1, Et2, + 0.0, 0.0); + + float ptEECalo = (el1track+el2track).Pt(); + + return lxy*3096.916/(0.299792458*ptEECalo); + +} + +double TrigEgammaMonitorTagAndProbeAlgorithm::simple_lxy(int flag, double d1, double d2, double phi1, double phi2, + double pt1, double pt2, double vx, double vy) const +{ + double simple = -99999.; + + //require minimum opening angle of 1 microradian. + if(fabs(phi1 - phi2) < 1e-6) return simple; + + double simpleXv = (-d2*cos(phi1) + d1*cos(phi2)) / sin(phi2-phi1); + double simpleYv = (-d2*sin(phi1) + d1*sin(phi2)) / sin(phi2-phi1); + double rxy = sqrt((simpleXv-vx)*(simpleXv-vx) + + (simpleYv-vy)*(simpleYv-vy) ); + + double f1 = (fabs(pt1)*cos(phi1)+fabs(pt2)*cos(phi2)); + double f2 = (fabs(pt1)*sin(phi1)+fabs(pt2)*sin(phi2)); + double c = sqrt( f1*f1 + f2*f2 ); + + if ( c == 0 ) return simple; + + double a = (simpleXv-vx)*f1; + double b = (simpleYv-vy)*f2; + + if (flag == 1) + return rxy; + else + return (a+b)/c; +} + + + + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorTagAndProbeAlgorithm.h b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorTagAndProbeAlgorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..61804d2ae7f1b23dc189303ee9a503d1883bcec4 --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/TrigEgammaMonitorTagAndProbeAlgorithm.h @@ -0,0 +1,105 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef TrigEgammaMonitorTagAndProbeAlgorithm_H +#define TrigEgammaMonitorTagAndProbeAlgorithm_H + +#include "TrigEgammaMonitorAnalysisAlgorithm.h" + + + + +class TrigEgammaMonitorTagAndProbeAlgorithm: public TrigEgammaMonitorAnalysisAlgorithm +{ + + public: + + TrigEgammaMonitorTagAndProbeAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + + virtual ~TrigEgammaMonitorTagAndProbeAlgorithm() override; + + virtual StatusCode initialize() override; + + virtual StatusCode fillHistograms( const EventContext& ctx) const override; + + + protected: + + /*! Tag and Probe method called by derived classes */ + bool executeTandP( const EventContext& ctx, std::vector<const xAOD::Electron*> & ) const; + + /*! Match probes called by derived classes */ + void matchObjects(const std::string trigItem, std::vector<const xAOD::Electron*>, + std::vector<std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> &) const; + + + + /*! Trigger for tag and event wise selection */ + std::vector<std::string> m_tagTrigList; + /*! List of triggers from menu */ + std::vector<std::string> m_trigInputList; + /*! List of triggers from menu after filter*/ + std::vector<std::string> m_trigList; + + + private: + + /*! at least one chain should pass. e28_tight_iloose? */ + bool minimalTriggerRequirement () const; + /*! Tag Electron selection */ + bool isTagElectron( ToolHandle<GenericMonitoringTool> monGroup, const xAOD::Electron *el) const; + /*! Probe selection */ + bool isGoodProbeElectron( ToolHandle<GenericMonitoringTool> monGroup, const xAOD::Electron *el, const xAOD::JetContainer *) const; + /*! Return pseudo-lifetime of Jpsi */ + float getPseudoLifetime(const xAOD::Electron*,const xAOD::Electron*) const; + /*! Calculate the displacement of the Jpsi vertex w.r.t. the primary vertex in the transverse plane */ + double simple_lxy(int ,double, double, double , double , double , double , double, double ) const; + /*! Rerun offline selection */ + void dressPid(const xAOD::Electron *eg) const; + + + /** Properties **/ + + + + + /*! Zee lower mass cut */ + Gaudi::Property<float> m_ZeeMassMin{ this, "ZeeLowerMass", 80}; + /*! Zee upper mass cut */ + Gaudi::Property<float> m_ZeeMassMax{ this, "ZeeUpperMass", 100}; + /*! Define the PID for tag electron */ + Gaudi::Property<std::string> m_offTagTightness{ this, "OfflineTagSelector", "Tight"}; + /*! define the Pid of Probe from the user */ + Gaudi::Property<std::string> m_offProbeTightness{ this, "OfflineProbeSelector", "Loose"}; + /*! Select opposite or same-sign pairs -- for background studies */ + Gaudi::Property<bool> m_oppositeCharge{ this, "OppositeCharge", true}; + /*! Minimum tag Et */ + Gaudi::Property<float> m_tagMinEt{ this, "OfflineTagMinEt", 25}; + /*! Minimum probe Et */ + Gaudi::Property<float> m_probeMinEt{this, "OfflineProbeMinEt", 4}; + /*! Probe isolation */ + Gaudi::Property<std::string> m_offProbeIsolation{ this, "OfflineProbeIsolation", "Loose"}; + /*! Remove crack region for Probe default True */ + Gaudi::Property<bool> m_rmCrack{this, "RemoveCrack", true}; + /*! Enable the requirement of triggers */ + Gaudi::Property<bool> m_applyMinimalTrigger{this, "ApplyMinimalTrigger", true}; + /*! Apply nearby jet selection */ + Gaudi::Property<bool> m_applyJetNearProbeSelection{this, "ApplyJetNearProbeSelection", true}; + /*! do jpsiee tag and probe */ + Gaudi::Property<bool> m_doJpsiee{this,"DoJpsiee", false}; + /*! analysis name */ + Gaudi::Property<std::string> m_anatype{ this, "Analysis","Zee"}; + + // Containers + /*! Event Wise offline ElectronContainer Access and end iterator */ + SG::ReadHandleKey<xAOD::ElectronContainer> m_offElectronKey{ this, "ElectronKey", "Electrons", ""}; + /*! Jet container for probe selection */ + SG::ReadHandleKey<xAOD::JetContainer> m_jetKey{ this, "JetKey" , "AntiKt4LCTopoJets", ""}; + /*! Event Info key */ + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{ this, "EventInfoKey", "EventInfo", "" }; + + + +}; + +#endif diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/components/.__afs533D b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/components/.__afs533D new file mode 100644 index 0000000000000000000000000000000000000000..7aa2ac6e7edadf269c117be905c1f03992a1ebba --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/components/.__afs533D @@ -0,0 +1,5 @@ +#include "../TrigEgammaMonitorBaseAlgorithm.h" +#include "../TrigEgammaTapMonitorAlgorithm.h" + +DECLARE_COMPONENT(TrigEgammaMonitorBaseAlgorithm) +DECLARE_COMPONENT(TrigEgammaTaPMonitorAlgorithm) diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/components/TrigEgammaMonitoring_entries.cxx b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/components/TrigEgammaMonitoring_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cae19181bf9b7c37976842b1db6accba9e6b3a7d --- /dev/null +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/src/components/TrigEgammaMonitoring_entries.cxx @@ -0,0 +1,14 @@ +#include "../TrigEgammaMonitorBaseAlgorithm.h" +#include "../TrigEgammaMonitorAnalysisAlgorithm.h" +#include "../TrigEgammaMonitorElectronAlgorithm.h" +#include "../TrigEgammaMonitorPhotonAlgorithm.h" +#include "../TrigEgammaMonitorTagAndProbeAlgorithm.h" + +DECLARE_COMPONENT(TrigEgammaMonitorBaseAlgorithm) +DECLARE_COMPONENT(TrigEgammaMonitorAnalysisAlgorithm) +DECLARE_COMPONENT(TrigEgammaMonitorElectronAlgorithm) +DECLARE_COMPONENT(TrigEgammaMonitorPhotonAlgorithm) +DECLARE_COMPONENT(TrigEgammaMonitorTagAndProbeAlgorithm) + + +