From 8d37365ba111b72d624a10b8047f1ff2d9644cc8 Mon Sep 17 00:00:00 2001 From: Joao Victor Da Fonseca Pinto <joao.victor.da.fonseca.pinto@cern.ch> Date: Mon, 2 Aug 2021 18:07:02 +0000 Subject: [PATCH] More one Round with the Trigger e/g emulator code --- .../ConfiguredAsgPhotonIsEMSelectors.py | 3 +- .../TrigEgammaEmulationTool/CMakeLists.txt | 1 + .../Root/TrigEgammaEmulationChain.cxx | 2 +- .../TrigEgammaEmulationFastCaloHypoTool.cxx | 28 +- ...ammaEmulationPrecisionElectronHypoTool.cxx | 31 +- ...EgammaEmulationPrecisionPhotonHypoTool.cxx | 24 +- .../Root/TrigEgammaEmulationToolMT.cxx | 393 +++++++++++------- .../ITrigEgammaEmulationChain.h | 2 +- .../TrigEgammaEmulationBaseHypoTool.h | 2 +- .../TrigEgammaEmulationFastCaloHypoTool.h | 6 + .../TrigEgammaEmulationFastElectronHypoTool.h | 1 + .../TrigEgammaEmulationInfo.h | 79 ---- ...EgammaEmulationPrecisionElectronHypoTool.h | 8 + ...igEgammaEmulationPrecisionPhotonHypoTool.h | 7 +- .../TrigEgammaEmulationToolMT.h | 114 +++-- .../python/TrigEgammaEmulationToolConfigMT.py | 313 +++++++++----- .../src/TrigEgammaEmulationToolTest.cxx | 280 +++++++++++++ .../src/TrigEgammaEmulationToolTest.h | 69 +++ .../TrigEgammaEmulationTool_entries.cxx | 3 + .../Root/TrigEgammaMatchingToolMT.cxx | 4 +- .../python/TrigEgammaMonitCategoryMT.py | 9 +- .../python/TrigEgammaMonitorAlgorithm.py | 5 + .../python/TrigEgammaMonitoringMTConfig.py | 13 +- .../python/HLTMenuConfig/Egamma/EgammaDefs.py | 5 +- 24 files changed, 1003 insertions(+), 399 deletions(-) delete mode 100644 Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationInfo.h create mode 100644 Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.cxx create mode 100644 Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.h diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgPhotonIsEMSelectors.py b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgPhotonIsEMSelectors.py index d2e0b619d7d..54933681f33 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgPhotonIsEMSelectors.py +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/python/ConfiguredAsgPhotonIsEMSelectors.py @@ -12,7 +12,8 @@ Description: Apply the default configurations for the AsgPhotonIsEMSelector, # Import the needed general stuff from PATCore.HelperUtils import SetToolProperties -from AthenaCommon import CfgMgr +from AthenaConfiguration.ComponentFactory import CompFactory as CfgMgr + import sys # Import the needed stuff specific to the PhotonPhotonSelectorTools diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/CMakeLists.txt b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/CMakeLists.txt index 75178bd28d0..0ec4040c24d 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/CMakeLists.txt +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/CMakeLists.txt @@ -21,6 +21,7 @@ atlas_add_library( TrigEgammaEmulationToolLib xAODBase xAODCaloEvent xAODEgamma xAODTracking xAODTrigCalo xAODTrigRinger xAODTrigger RingerSelectorToolsLib AthOnnxruntimeServiceLib + AthenaMonitoringKernelLib AthenaMonitoringLib ) atlas_add_component( TrigEgammaEmulationTool diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationChain.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationChain.cxx index 3f2a74bd462..a65c84fd231 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationChain.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationChain.cxx @@ -20,7 +20,7 @@ TrigEgammaEmulationChain::TrigEgammaEmulationChain( const std::string& myname ) StatusCode TrigEgammaEmulationChain::initialize() { - ATH_CHECK( m_steps.retrieve()); + ATH_CHECK( m_steps.retrieve() ); //add cuts into TAccept m_accept.addCut("L1Calo" , "Trigger L1Calo step" ); diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationFastCaloHypoTool.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationFastCaloHypoTool.cxx index ca3a84f4493..c0f24a73ba4 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationFastCaloHypoTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationFastCaloHypoTool.cxx @@ -14,6 +14,15 @@ TrigEgammaEmulationFastCaloHypoTool::TrigEgammaEmulationFastCaloHypoTool( const //!========================================================================== +StatusCode TrigEgammaEmulationFastCaloHypoTool::initialize() +{ + ATH_CHECK( TrigEgammaEmulationBaseHypoTool::initialize()); + return StatusCode::SUCCESS; +} + +//!========================================================================== + + bool TrigEgammaEmulationFastCaloHypoTool::emulate(const Trig::TrigData &input, bool &pass ) const { @@ -260,23 +269,12 @@ bool TrigEgammaEmulationFastCaloHypoTool::decide_ringer( const Trig::TrigData &i return false; } - std::string pidName = m_pidName; - if( boost::contains( pidName , "tight") ){ - float output = input.ringerTools[0]->predict( input.rings ); - return bool( input.ringerTools[0]->accept(input.rings, output, avgmu() ) ); - }else if( boost::contains( pidName , "medium")){ - float output = input.ringerTools[1]->predict( input.rings ); - return bool( input.ringerTools[1]->accept(input.rings, output, avgmu() ) ); - }else if( boost::contains( pidName , "vloose")){ - float output = input.ringerTools[3]->predict( input.rings ); - return bool( input.ringerTools[3]->accept(input.rings, output, avgmu() ) ); - }else if( boost::contains( pidName , "loose")){ - float output = input.ringerTools[2]->predict( input.rings ); - return bool( input.ringerTools[2]->accept(input.rings, output, avgmu() ) ); - } + + bool pass = input.isPassed( input.rings, avgmu(), m_pidName); + // got this far => passed! - return true; + return pass; } diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionElectronHypoTool.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionElectronHypoTool.cxx index e532929ded8..cfdee07c317 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionElectronHypoTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionElectronHypoTool.cxx @@ -14,6 +14,14 @@ TrigEgammaEmulationPrecisionElectronHypoTool::TrigEgammaEmulationPrecisionElectr //================================================================= +StatusCode TrigEgammaEmulationPrecisionElectronHypoTool::initialize() +{ + ATH_CHECK( TrigEgammaEmulationBaseHypoTool::initialize()); + return StatusCode::SUCCESS; +} + +//!========================================================================== + bool TrigEgammaEmulationPrecisionElectronHypoTool::emulate(const Trig::TrigData &input, bool &pass) const { @@ -23,6 +31,11 @@ bool TrigEgammaEmulationPrecisionElectronHypoTool::emulate(const Trig::TrigData if( input.electrons.empty() ) return false; + if (m_acceptAll){ + pass=true; + return true; + } + for ( const auto& el : input.electrons ) { if( decide( input, el ) ){ @@ -66,6 +79,11 @@ bool TrigEgammaEmulationPrecisionElectronHypoTool::decide( const Trig::TrigDat auto pClus = el->caloCluster(); + if(!pClus){ + ATH_MSG_DEBUG("No calo cluster for this electron"); + return false; + } + float absEta = std::abs( pClus->eta() ); ATH_MSG_DEBUG("absEta: "<<absEta); @@ -145,18 +163,7 @@ bool TrigEgammaEmulationPrecisionElectronHypoTool::decide( const Trig::TrigDat ATH_MSG_DEBUG("Average mu " << avgmu()); - bool pass=false; - if (m_pidName=="lhtight"){ - pass = (bool)input.egammaElectronLHTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu()); - }else if (m_pidName=="lhmedium"){ - pass = (bool)input.egammaElectronLHTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu()); - }else if (m_pidName=="lhloose"){ - pass = (bool)input.egammaElectronLHTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu()); - }else if (m_pidName=="lhvloose"){ - pass = (bool)input.egammaElectronLHTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu()); - }else{ - pass = true; - } + bool pass = input.isPassed(el , avgmu(), m_pidName); float Rhad1(0), Rhad(0), Reta(0), Rphi(0), e277(0), weta2c(0), //emax2(0), diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionPhotonHypoTool.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionPhotonHypoTool.cxx index c11f664ff96..116b517dfea 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionPhotonHypoTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationPrecisionPhotonHypoTool.cxx @@ -10,7 +10,13 @@ TrigEgammaEmulationPrecisionPhotonHypoTool::TrigEgammaEmulationPrecisionPhotonHy : TrigEgammaEmulationBaseHypoTool(myname) {} +//!========================================================================== +StatusCode TrigEgammaEmulationPrecisionPhotonHypoTool::initialize() +{ + ATH_CHECK( TrigEgammaEmulationBaseHypoTool::initialize()); + return StatusCode::SUCCESS; +} //!========================================================================== @@ -64,6 +70,12 @@ bool TrigEgammaEmulationPrecisionPhotonHypoTool::decide( const Trig::TrigData & auto pClus = ph->caloCluster(); + if(!pClus){ + ATH_MSG_DEBUG("No calo cluster for this photon"); + return false; + } + + float absEta = std::abs( pClus->eta() ); const int cutIndex = findCutIndex( absEta ); @@ -125,17 +137,7 @@ bool TrigEgammaEmulationPrecisionPhotonHypoTool::decide( const Trig::TrigData & // Apply phootn offline like selection - bool pass=false; - - if (m_pidName=="tight"){ - pass = (bool)input.egammaPhotonCBTools[0]->accept(ph); - }else if (m_pidName=="medium"){ - pass = (bool)input.egammaPhotonCBTools[1]->accept(ph); - }else if (m_pidName=="loose"){ - pass = (bool)input.egammaPhotonCBTools[2]->accept(ph); - }else{ - pass = true; - } + bool pass = input.isPassed(ph, m_pidName); diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationToolMT.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationToolMT.cxx index af39c857c5e..ec94c1bc7b5 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationToolMT.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/Root/TrigEgammaEmulationToolMT.cxx @@ -19,24 +19,26 @@ TrigEgammaEmulationToolMT::TrigEgammaEmulationToolMT( const std::string& myname declareProperty( "MatchTool" , m_matchTool ); } - //********************************************************************** + StatusCode TrigEgammaEmulationToolMT::initialize() { ATH_CHECK(m_matchTool.retrieve()); //Enable expert methods ATH_CHECK(m_trigdec.retrieve()); - m_trigdec->ExperimentalAndExpertMethods()->enable(); // retrieve all hypo chains ATH_CHECK( m_hypoTools.retrieve() ); + + + ATH_CHECK( m_ringerTools.retrieve() ); + ATH_CHECK( m_egammaPhotonCBTools.retrieve() ); + ATH_CHECK( m_egammaElectronDNNTools.retrieve() ); + ATH_CHECK( m_egammaElectronCBTools.retrieve() ); + ATH_CHECK( m_egammaElectronLHTools.retrieve() ); + ATH_CHECK( m_ringerTools.retrieve() ); - ATH_CHECK( m_egammaElectronDNNTools.retrieve() ); - ATH_CHECK( m_egammaElectronCBTools.retrieve() ); - ATH_CHECK( m_egammaElectronLHTools.retrieve() ); - ATH_CHECK( m_egammaPhotonCBTools.retrieve() ); - ATH_CHECK( m_ringerTools.retrieve() ); //add cuts into TAccept m_accept.addCut("L1Calo" , "Trigger L1Calo step" ); @@ -57,23 +59,16 @@ asg::AcceptData TrigEgammaEmulationToolMT::emulate(const TrigCompositeUtils::Dec { asg::AcceptData acceptData (&m_accept); - for ( auto& tool : m_hypoTools ){ - + for ( auto& tool : m_hypoTools ) + { if( tool->chain() == trigger ) { - Trig::TrigData input(tool->signature()); - match(roi, input); - - if(input.isValid()){ - input.egammaElectronDNNTools = m_egammaElectronDNNTools; - input.egammaElectronCBTools = m_egammaElectronCBTools; - input.egammaElectronLHTools = m_egammaElectronLHTools; - input.egammaPhotonCBTools = m_egammaPhotonCBTools; - input.ringerTools = m_ringerTools; + Trig::TrigData input(trigger); + if(!match(roi, input)) return acceptData; + if(input.isValid()) return tool->emulate(input); - } - } + }// Loop over all hypo tool chains return acceptData; @@ -82,171 +77,273 @@ asg::AcceptData TrigEgammaEmulationToolMT::emulate(const TrigCompositeUtils::Dec //********************************************************************** -bool TrigEgammaEmulationToolMT::match( const TrigCompositeUtils::Decision *roi, Trig::TrigData &output) const +bool TrigEgammaEmulationToolMT::match( const TrigCompositeUtils::Decision *roi, + Trig::TrigData &output, + unsigned int condition) const { - if(output.signature == "electron"){ - return match_electron(roi, output, m_trigElectronList); - }else if (output.signature == "photon"){ - return match_photon(roi, output, m_trigPhotonList); - }else{ + output.clear(); + + if(!roi) { + ATH_MSG_INFO("no Roi!"); return false; } -} + // Link all selectors with this trig object to easy acesss throut of the chain + // Avoid multiple selectors + output.egammaElectronCBTools=m_egammaElectronCBTools; + output.egammaElectronDNNTools=m_egammaElectronDNNTools; + output.egammaElectronLHTools=m_egammaElectronLHTools; + output.egammaPhotonCBTools=m_egammaPhotonCBTools; + output.ringerTools=m_ringerTools; -//********************************************************************** -bool TrigEgammaEmulationToolMT::match_electron( const TrigCompositeUtils::Decision *roi , - Trig::TrigData &output, - std::vector<std::string> trigList ) const -{ - unsigned int condition=TrigDefs::includeFailedDecisions; - output.clear(); + if(output.signature == "electron"){ + for (auto& trigger : m_electronTrigList){ - if(!roi) return false; + if(boost::contains(output.trigger,"gsf") && !boost::contains(trigger,"gsf")) continue; + if(boost::contains(output.trigger,"lrt") && !boost::contains(trigger,"lrt")) continue; - for (auto& trigger : trigList){ - auto vec_el_linkInfo = match()->getFeatures<xAOD::ElectronContainer>(roi,trigger,condition); + auto vec_el_linkInfo = match()->getFeatures<xAOD::ElectronContainer>(roi,trigger,condition); - if( !vec_el_linkInfo.empty() ){ + if( !vec_el_linkInfo.empty() ){ - output.clear(); + output.clear(); - // Step 5 - { - for(auto&featLinkInfo : vec_el_linkInfo){ - if(!featLinkInfo.isValid()) continue; - output.electrons.push_back(*featLinkInfo.link); + // Step 5 + { + for(auto&featLinkInfo : vec_el_linkInfo){ + if(!featLinkInfo.isValid()) continue; + output.electrons.push_back(*featLinkInfo.link); + } } - } + // Step 3 + { + auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(roi,trigger,condition); + for(auto& featLinkInfo : vec_feat){ + if(!featLinkInfo.isValid()) continue; + output.clusters.push_back(*featLinkInfo.link); + } + } - // Step 3 - { - auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(roi,trigger,condition); - for(auto& featLinkInfo : vec_feat){ - if(!featLinkInfo.isValid()) continue; - output.clusters.push_back(*featLinkInfo.link); + // Step 2 + { + auto vec_feat = match()->getFeatures<xAOD::TrigElectronContainer>(roi, trigger, condition); + for ( auto& featLinkInfo : vec_feat ){ + if(!featLinkInfo.isValid()) continue; + output.trig_electrons.push_back(*featLinkInfo.link); + } } - } - - // Step 2 - { - auto vec_feat = match()->getFeatures<xAOD::TrigElectronContainer>(roi, trigger, condition); - for ( auto& featLinkInfo : vec_feat ){ - if(!featLinkInfo.isValid()) continue; - output.trig_electrons.push_back(*featLinkInfo.link); - } - } - - // Step 1 - { - auto featLinkInfo = match()->getFeature<xAOD::TrigEMClusterContainer>(roi,trigger); - if(featLinkInfo.isValid()){ - output.emCluster = *featLinkInfo.link; + + // Step 1 + { + auto featLinkInfo = match()->getFeature<xAOD::TrigEMClusterContainer>(roi,trigger); + if(featLinkInfo.isValid()){ + output.emCluster = *featLinkInfo.link; + } + // get rings from container access + output.rings = match()->getRingsFeature(roi); + } - } - - // Step 0 - { - // L1Calo (step 0) - output.l1 = match()->getL1Feature(roi); - auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(roi,trigger); - if(featLinkInfo.isValid()){ - output.roi = *featLinkInfo.link; + + + + // Step 0 + { + // L1Calo (step 0) + output.l1 = match()->getL1Feature(roi); + auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(roi,trigger); + if(featLinkInfo.isValid()){ + output.roi = *featLinkInfo.link; + } } - } + + ATH_MSG_INFO( "L1 RoI TDET = " << (output.roi?"Yes":"No")); + ATH_MSG_INFO( "L1 RoI EmTau = " << (output.l1?"Yes":"No")); + ATH_MSG_INFO( "L2 Cluster = " << (output.emCluster?"Yes":"No")); + ATH_MSG_INFO( "L2 Rings = " << (output.rings?"Yes":"No")); + ATH_MSG_INFO( "L2 Electrons = " << (output.trig_electrons.size())); + ATH_MSG_INFO( "HLT Cluster = " << output.clusters.size()); + ATH_MSG_INFO( "HLT el = " << output.electrons.size()); + + }// has electron + + // stop the trigger loop since we have all features inside + if(output.isValid()) + return true; + }// Loop over triggers + + }else if (output.signature == "photon"){ + + for (auto& trigger : m_photonTrigList){ + + auto vec_ph_linkInfo = match()->getFeatures<xAOD::PhotonContainer>(roi,trigger,condition); + + if( !vec_ph_linkInfo.empty() ){ + + // clean all vectors before fill it + output.clear(); + + // Step 5 + { + for(auto&featLinkInfo : vec_ph_linkInfo){ + if(!featLinkInfo.isValid()) continue; + output.photons.push_back(*featLinkInfo.link); + } + } + + // Step 3 + { + auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(roi,trigger,condition); + for(auto& featLinkInfo : vec_feat){ + if(!featLinkInfo.isValid()) continue; + output.clusters.push_back(*featLinkInfo.link); + } + } + + // Step 1 + { + auto featLinkInfo = match()->getFeature<xAOD::TrigEMClusterContainer>(roi,trigger); + if(featLinkInfo.isValid()){ + output.emCluster = *featLinkInfo.link; + } + // get rings from container access + output.rings = match()->getRingsFeature(roi); + } - ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No")); - ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No")); - ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No")); - ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No")); - ATH_MSG_DEBUG( "L2 Electrons = " << (output.trig_electrons.size())); - ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size()); - ATH_MSG_DEBUG( "HLT el = " << output.electrons.size()); - }// has electron + // Step 0 + { + // L1Calo (step 0) + output.l1 = match()->getL1Feature(roi); + auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(roi,trigger); + if(featLinkInfo.isValid()){ + output.roi = *featLinkInfo.link; + } + } - // stop the trigger loop since we have all features inside - if(output.isValid()) return true; + ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No")); + ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No")); + ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No")); + ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No")); + ATH_MSG_DEBUG( "L2 Photon = " << (output.trig_photon?"Yes":"No")); + ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size()); + ATH_MSG_DEBUG( "HLT ph = " << output.photons.size()); + }// has electron - }// Loop over triggers + // stop the trigger loop since we have all features inside + if(output.isValid()) return true; + + }// Loop over triggers + } return false; } + //********************************************************************** -bool TrigEgammaEmulationToolMT::match_photon( const TrigCompositeUtils::Decision *roi , - Trig::TrigData &output, - std::vector<std::string> trigList ) const + +TrigData::TrigData( std::string name ) { - unsigned int condition=TrigDefs::includeFailedDecisions; - output.clear(); + this->signature = "electron"; // default + if(boost::contains(name,"HLT_e")) this->signature = "electron"; + else if(boost::contains(name,"HLT_g")) this->signature = "photon"; +} - if(!roi) return false; - for (auto& trigger : trigList){ +void TrigData::clear() +{ + this->electrons.clear(); + this->trig_electrons.clear(); + this->clusters.clear(); + this->photons.clear(); + this->roi = nullptr; + this->l1 = nullptr; + this->emCluster = nullptr; + this->rings = nullptr; + this->trig_photon = nullptr; +} - auto vec_ph_linkInfo = match()->getFeatures<xAOD::PhotonContainer>(roi,trigger,condition); - if( !vec_ph_linkInfo.empty() ){ +bool TrigData::isValid() const +{ + return (this->roi && this->l1 && this->emCluster && this->rings); + if (this->signature == "photon"){ + return (this->trig_photon && !this->photons.empty()); + }else if (this->signature == "electron"){ + return (!this->trig_electrons.empty() && !this->electrons.empty()); + }else{ + return false; + } +} - // clean all vectors before fill it - output.clear(); - - // Step 5 - { - for(auto&featLinkInfo : vec_ph_linkInfo){ - if(!featLinkInfo.isValid()) continue; - output.photons.push_back(*featLinkInfo.link); - } - } - - // Step 3 - { - auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(roi,trigger,condition); - for(auto& featLinkInfo : vec_feat){ - if(!featLinkInfo.isValid()) continue; - output.clusters.push_back(*featLinkInfo.link); - } - } - // Step 1 - { - auto featLinkInfo = match()->getFeature<xAOD::TrigEMClusterContainer>(roi,trigger); - if(featLinkInfo.isValid()){ - output.emCluster = *featLinkInfo.link; - } - } - - // Step 0 - { - // L1Calo (step 0) - output.l1 = match()->getL1Feature(roi); - auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(roi,trigger); - if(featLinkInfo.isValid()){ - output.roi = *featLinkInfo.link; - } - } - - ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No")); - ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No")); - ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No")); - ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No")); - ATH_MSG_DEBUG( "L2 Photon = " << (output.trig_photon?"Yes":"No")); - ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size()); - ATH_MSG_DEBUG( "HLT ph = " << output.photons.size()); - }// has electron - - // stop the trigger loop since we have all features inside - if(output.isValid()) return true; - - }// Loop over triggers +bool TrigData::isPassed( const xAOD::Photon *ph , std::string pidname ) const +{ + if (pidname=="tight"){ + return (bool)this->egammaPhotonCBTools[0]->accept(ph); + }else if (pidname=="medium"){ + return (bool)this->egammaPhotonCBTools[1]->accept(ph); + }else if (pidname=="loose"){ + return (bool)this->egammaPhotonCBTools[2]->accept(ph); + }else{ + return true; + } +} - return false; +bool TrigData::isPassed( const xAOD::Electron *el , float avgmu, std::string pidname ) const +{ + if (pidname=="lhtight"){ + return (bool)this->egammaElectronLHTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="lhmedium"){ + return (bool)this->egammaElectronLHTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="lhloose"){ + return (bool)this->egammaElectronLHTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="lhvloose"){ + return (bool)this->egammaElectronLHTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="dnntight"){ + return (bool)this->egammaElectronDNNTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="dnnmedium"){ + return (bool)this->egammaElectronDNNTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="dnnloose"){ + return (bool)this->egammaElectronDNNTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="dnnvloose"){ + return (bool)this->egammaElectronDNNTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu ); + }else if (pidname=="tight"){ + return (bool)this->egammaElectronCBTools[0]->accept(Gaudi::Hive::currentContext(),el ); + }else if (pidname=="medium"){ + return (bool)this->egammaElectronCBTools[1]->accept(Gaudi::Hive::currentContext(),el ); + }else if (pidname=="loose"){ + return (bool)this->egammaElectronCBTools[2]->accept(Gaudi::Hive::currentContext(),el ); + }else{ + return true; + } } + + +bool TrigData::isPassed( const xAOD::TrigRingerRings *cl , float avgmu, std::string pidname ) const +{ + if (pidname=="tight"){ + float output = this->ringerTools[0]->predict(cl); + return (bool)this->ringerTools[0]->accept(cl, output, avgmu); + }else if (pidname=="medium"){ + float output = this->ringerTools[1]->predict(cl); + return (bool)this->ringerTools[1]->accept(cl, output, avgmu); + }else if (pidname=="loose"){ + float output = this->ringerTools[2]->predict(cl); + return (bool)this->ringerTools[2]->accept(cl, output, avgmu); + }else if (pidname=="vloose"){ + float output = this->ringerTools[3]->predict(cl); + return (bool)this->ringerTools[3]->accept(cl, output, avgmu); + }else{ + return true; + } +} + + + diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/ITrigEgammaEmulationChain.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/ITrigEgammaEmulationChain.h index 29285b79885..4522044b5b7 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/ITrigEgammaEmulationChain.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/ITrigEgammaEmulationChain.h @@ -10,11 +10,11 @@ #include "PATCore/AcceptInfo.h" #include "PATCore/AcceptData.h" #include "TrigEgammaEmulationTool/TrigEgammaEmulationToolMT.h" -#include "TrigEgammaEmulationTool/TrigEgammaEmulationInfo.h" namespace Trig{ + class TrigData; class ITrigEgammaEmulationChain: virtual public asg::IAsgTool { diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationBaseHypoTool.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationBaseHypoTool.h index 4e5ff2e6db3..7e03cec0316 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationBaseHypoTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationBaseHypoTool.h @@ -28,7 +28,7 @@ namespace Trig{ TrigEgammaEmulationBaseHypoTool(const std::string& myname); ~TrigEgammaEmulationBaseHypoTool()=default; - StatusCode initialize(); + virtual StatusCode initialize() override; bool emulate( const TrigData &, bool &) const {return true;}; diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastCaloHypoTool.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastCaloHypoTool.h index d100279a9d2..79eb5fc8b66 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastCaloHypoTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastCaloHypoTool.h @@ -26,6 +26,8 @@ namespace Trig{ /* emulate */ virtual bool emulate( const Trig::TrigData &input, bool &pass ) const override; + virtual StatusCode initialize() override; + private: bool decide( const Trig::TrigData &input ) const; @@ -54,6 +56,10 @@ namespace Trig{ Gaudi::Property< float > m_detacluster { this, "dETACLUSTERthr", 0. , "" }; Gaudi::Property< float > m_dphicluster { this, "dPHICLUSTERthr", 0. , "" }; + + + + }; diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastElectronHypoTool.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastElectronHypoTool.h index ce641166c20..27bbdd8a0ef 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastElectronHypoTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationFastElectronHypoTool.h @@ -24,6 +24,7 @@ namespace Trig{ virtual bool emulate( const Trig::TrigData &input, bool &pass ) const override; + private: bool decide( const Trig::TrigData &input , const xAOD::TrigElectron* electron) const; diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationInfo.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationInfo.h deleted file mode 100644 index 42983effb6a..00000000000 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationInfo.h +++ /dev/null @@ -1,79 +0,0 @@ - -#ifndef TrigEgammaEmulationInfo_h -#define TrigEgammaEmulationInfo_h - -#include <string> -#include "xAODTrigger/EmTauRoIContainer.h" -#include "xAODTrigCalo/TrigEMClusterContainer.h" -#include "xAODCaloEvent/CaloClusterContainer.h" -#include "xAODEgamma/EgammaContainer.h" -#include "xAODEgamma/ElectronContainer.h" -#include "xAODEgamma/PhotonContainer.h" -#include "xAODTrigRinger/TrigRingerRingsContainer.h" -#include "xAODTracking/TrackParticleContainer.h" -#include "xAODEgamma/EgammaxAODHelpers.h" - -#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" -#include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h" -#include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h" -#include "RingerSelectorTools/AsgRingerSelectorTool.h" -#include "ElectronPhotonSelectorTools/AsgElectronSelectorTool.h" - - - - -namespace Trig{ - - -struct TrigData{ - - TrigData( std::string type): signature(type) {} - std::string signature; - const TrigRoiDescriptor *roi; - const xAOD::EmTauRoI *l1; - const xAOD::TrigEMCluster *emCluster; - const xAOD::TrigRingerRings *rings; - const xAOD::TrigPhoton* trig_photon; - std::vector<const xAOD::CaloCluster*> clusters; - std::vector<const xAOD::TrigElectron*> trig_electrons; - std::vector<const xAOD::Electron*> electrons; - std::vector<const xAOD::Photon*> photons; - - - /* precision electron selectors */ - ToolHandleArray<IAsgElectronLikelihoodTool> egammaElectronDNNTools; - ToolHandleArray<IAsgElectronIsEMSelector> egammaElectronCBTools; - ToolHandleArray<IAsgElectronLikelihoodTool> egammaElectronLHTools; - - /* precision photon selectors */ - ToolHandleArray< IAsgPhotonIsEMSelector > egammaPhotonCBTools; - - /* ringer selectors */ - ToolHandleArray<Ringer::IAsgRingerSelectorTool> ringerTools; - - - bool isValid(){ - return (roi && l1 && emCluster && rings); - if (signature == "photon"){ - return (trig_photon && !photons.empty()); - }else if (signature == "electron"){ - return (!trig_electrons.empty() && !electrons.empty()); - }else{ - return false; - } - } - void clear(){ - electrons.clear(); trig_electrons.clear(); clusters.clear(); photons.clear(); - roi = nullptr; - l1 = nullptr; - emCluster = nullptr; - rings = nullptr; - trig_photon = nullptr; - } - -}; - -} - - -#endif \ No newline at end of file diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionElectronHypoTool.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionElectronHypoTool.h index 464d7ae4f78..0109bfbdc15 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionElectronHypoTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionElectronHypoTool.h @@ -12,6 +12,7 @@ #include "TrigEgammaEmulationTool/TrigEgammaEmulationBaseHypoTool.h" #include "TrigEgammaEmulationTool/ITrigEgammaEmulationBaseHypoTool.h" + namespace Trig{ @@ -29,6 +30,8 @@ namespace Trig{ virtual bool emulate( const TrigData &input, bool &pass) const override; + virtual StatusCode initialize() override; + private: bool decide( const Trig::TrigData &input, const xAOD::Electron *el) const; @@ -42,6 +45,11 @@ namespace Trig{ Gaudi::Property< std::vector<float> > m_eTthr { this, "ETthr", {}, "ET Threshold" }; Gaudi::Property<float> m_d0{ this, "d0Cut", -1, "d0 cut" }; + Gaudi::Property<bool> m_acceptAll{ this, "AcceptAll", false, "Accept all events" }; + + + + }; diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionPhotonHypoTool.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionPhotonHypoTool.h index ae105f15e7f..482c6a7daf8 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionPhotonHypoTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionPhotonHypoTool.h @@ -29,7 +29,9 @@ namespace Trig{ virtual bool emulate( const TrigData &input, bool &pass) const override; - + virtual StatusCode initialize() override; + + private: bool decide( const TrigData &input, const xAOD::Photon *ph ) const; @@ -43,6 +45,9 @@ namespace Trig{ Gaudi::Property< std::vector<float> > m_etabin { this, "EtaBins", {} , "Bins of eta" }; Gaudi::Property< std::vector<float> > m_eTthr { this, "ETthr", {}, "ET Threshold" }; + + + }; diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationToolMT.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationToolMT.h index 5b30e079804..2f96f38c48b 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationToolMT.h +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/TrigEgammaEmulationTool/TrigEgammaEmulationToolMT.h @@ -6,27 +6,90 @@ #ifndef TrigEgammaEmulationToolMT_H #define TrigEgammaEmulationToolMT_H - +// Core staff #include "TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h" #include "TrigEgammaEmulationTool/ITrigEgammaEmulationChain.h" -#include "TrigEgammaEmulationTool/TrigEgammaEmulationInfo.h" #include "TrigDecisionTool/TrigDecisionTool.h" #include "GaudiKernel/SystemOfUnits.h" #include "PATCore/AcceptInfo.h" #include "PATCore/AcceptData.h" #include "AsgTools/AsgTool.h" - -#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" +// Selector includes #include "EgammaAnalysisInterfaces/IAsgPhotonIsEMSelector.h" +#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" #include "EgammaAnalysisInterfaces/IAsgElectronIsEMSelector.h" -#include "RingerSelectorTools/IAsgRingerSelectorTool.h" #include "ElectronPhotonSelectorTools/AsgElectronSelectorTool.h" +#include "RingerSelectorTools/IAsgRingerSelectorTool.h" +// EDM includes +#include "xAODTrigger/EmTauRoIContainer.h" +#include "xAODTrigCalo/TrigEMClusterContainer.h" +#include "xAODCaloEvent/CaloClusterContainer.h" +#include "xAODEgamma/EgammaContainer.h" +#include "xAODEgamma/ElectronContainer.h" +#include "xAODEgamma/PhotonContainer.h" +#include "xAODTrigRinger/TrigRingerRingsContainer.h" +#include "xAODTracking/TrackParticleContainer.h" +#include "xAODEgamma/EgammaxAODHelpers.h" + namespace Trig{ +class TrigData{ + + public: + TrigData( std::string ); + ~TrigData()=default; + + void clear(); + bool isValid() const; + + + bool isPassed( const xAOD::Photon *ph , std::string pidname ) const; + bool isPassed( const xAOD::Electron *el , float avgmu, std::string pidname ) const; + bool isPassed( const xAOD::TrigRingerRings *rings , float avgmu, std::string pidname ) const; + + + public: + + // chain name + std::string trigger; + // signature slice type: electron or photon only + std::string signature; + + // L1 object + const TrigRoiDescriptor *roi; + // L1 legacy object + const xAOD::EmTauRoI *l1; + // Step 1 cluster + const xAOD::TrigEMCluster *emCluster; + // Step 1 rings + const xAOD::TrigRingerRings *rings; + // Step 2 photon object + const xAOD::TrigPhoton* trig_photon; + // Step 3 clusters + std::vector<const xAOD::CaloCluster*> clusters; + // Step 2 electrons + std::vector<const xAOD::TrigElectron*> trig_electrons; + // Step 4 electrons + std::vector<const xAOD::Electron*> electrons; + // Step 4 photons + std::vector<const xAOD::Photon*> photons; + + + /* Step 4 photon selectors */ + ToolHandleArray< IAsgPhotonIsEMSelector > egammaPhotonCBTools; + /* Step 4 electron selectors */ + ToolHandleArray<AsgElectronSelectorTool> egammaElectronDNNTools; + ToolHandleArray<IAsgElectronIsEMSelector> egammaElectronCBTools; + ToolHandleArray<IAsgElectronLikelihoodTool> egammaElectronLHTools; + // Step 1 electron ringer selectors + ToolHandleArray<Ringer::IAsgRingerSelectorTool> ringerTools; +}; + + class TrigEgammaEmulationToolMT: public asg::AsgTool { @@ -43,43 +106,42 @@ class TrigEgammaEmulationToolMT: public asg::AsgTool asg::AcceptData emulate(const TrigCompositeUtils::Decision *dec, std::string trigger) const; + bool match( const TrigCompositeUtils::Decision *dec , Trig::TrigData &, unsigned int condition=TrigDefs::includeFailedDecisions ) const; + private: /* hypo tools */ ToolHandleArray<Trig::ITrigEgammaEmulationChain> m_hypoTools{ this, "HypoTools", {}, "Hypo tools" }; - /* electron selectors */ - ToolHandleArray<IAsgElectronLikelihoodTool> m_egammaElectronDNNTools{ this, "ElectronDNNSelectorTools", {},"DNN tools" }; - ToolHandleArray<IAsgElectronIsEMSelector> m_egammaElectronCBTools{ this, "ElectronCBSelectorTools", {},"Cut-based tools" }; - ToolHandleArray<IAsgElectronLikelihoodTool> m_egammaElectronLHTools{ this, "ElectronLHSelectorTools", {},"Likelihood tools" }; - - /* photon selectors */ - ToolHandleArray< IAsgPhotonIsEMSelector > m_egammaPhotonCBTools { this, "PhotonCBSelectorTools", {} , "Cut-based tools"}; - - /* ringer selectors */ - ToolHandleArray<Ringer::IAsgRingerSelectorTool> m_ringerTools{ this, "RingerTools", {}, "Ringer tools" }; - - /*! Trigger decision tool */ ToolHandle<Trig::TrigDecisionTool> m_trigdec; /* Trigger e/g matching tool */ ToolHandle<TrigEgammaMatchingToolMT> m_matchTool; - /* Trigger Match list for electrons */ - Gaudi::Property< std::vector<std::string> > m_trigElectronList { this, "ElectronTriggerList", {} , "" }; - /* Trigger Match list for photons */ - Gaudi::Property< std::vector<std::string> > m_trigPhotonList { this, "PhotonTriggerList", {} , "" }; /*! Accept */ asg::AcceptInfo m_accept; + Gaudi::Property<std::vector<std::string>> m_electronTrigList{ this, "ElectronTriggerList", {}}; + Gaudi::Property<std::vector<std::string>> m_photonTrigList{ this, "PhotonTriggerList", {}}; const ToolHandle<TrigEgammaMatchingToolMT>& match() const {return m_matchTool;} - bool match( const TrigCompositeUtils::Decision *dec , Trig::TrigData & ) const; - /*! fill all features from electron support chains */ - bool match_electron( const TrigCompositeUtils::Decision *dec , Trig::TrigData & , std::vector<std::string> ) const; - /*! fill all features from photon support chains */ - bool match_photon( const TrigCompositeUtils::Decision *dec , Trig::TrigData & , std::vector<std::string> ) const; + + /* + * e/g selectors + */ + + + /* photon selectors */ + ToolHandleArray< IAsgPhotonIsEMSelector > m_egammaPhotonCBTools { this, "PhotonCBSelectorTools", {} , "Cut-based tools"}; + + /* electron selectors */ + ToolHandleArray<AsgElectronSelectorTool> m_egammaElectronDNNTools{ this, "ElectronDNNSelectorTools", {},"DNN tools" }; + ToolHandleArray<IAsgElectronIsEMSelector> m_egammaElectronCBTools{ this, "ElectronCBSelectorTools", {},"Cut-based tools" }; + ToolHandleArray<IAsgElectronLikelihoodTool> m_egammaElectronLHTools{ this, "ElectronLHSelectorTools", {},"Likelihood tools" }; + + // electron ringer selectors + ToolHandleArray<Ringer::IAsgRingerSelectorTool> m_ringerTools{ this, "RingerTools", {}, "Ringer tools" }; }; diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/python/TrigEgammaEmulationToolConfigMT.py b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/python/TrigEgammaEmulationToolConfigMT.py index f83485e353d..98dd9e42e79 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/python/TrigEgammaEmulationToolConfigMT.py +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/python/TrigEgammaEmulationToolConfigMT.py @@ -2,125 +2,250 @@ # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # +from AthenaConfiguration.ComponentFactory import CompFactory +from TrigEgammaMonitoring.TrigEgammaMonitCategoryMT import single_electron_triggers, single_photon_triggers -# -# Configure legacy L1 -# -def createL1Calo( name , info, OutputLevel=0 ): - - from AthenaConfiguration.ComponentFactory import CompFactory - from AthenaCommon.SystemOfUnits import GeV - import re - - #chainName = info['chainName'] - L1Item = info['chainParts'][0]['L1threshold'] - L1thr = float( re.findall(r'\d+', L1Item)[0] ) - wp = 0 # default - - # [Default, Tight , Medium, Loose ] - HadCoreCutMin = [ 1.0 , 1.0 , 1.0 , 1.0 ] - HadCoreCutOff = [-0.2 , -0,2 , -0.2 , -0.2 ] - HadCoreSlope = [ 1/23. , 1/23., 1/23., 1/23.] - EmIsolCutMin = [ 2.0 , 1.0 , 1.0 , 1.5 ] - EmIsolCutOff = [-1.8 , -2.6 , -2.0 , -1.8 ] - EmIsolSlope = [ 1/8. , 1/8. , 1/8. , 1/8. ] - - # Configure L1 - L1CaloTool = CompFactory.Trig.TrigEgammaEmulationL1CaloHypoTool( - name = name, - L1Item = L1Item, - L1Thr = L1thr * GeV, - HadCoreCutMin = HadCoreCutMin[wp], - HadCoreCutOff = HadCoreCutOff[wp], - HadCoreSlope = HadCoreSlope[wp], - EmIsolCutMin = EmIsolCutMin[wp], - EmIsolCutOff = EmIsolCutOff[wp], - EmIsolSlope = EmIsolSlope[wp], - IsolCutMax = 50, - OutputLevel = OutputLevel) - - return L1CaloTool # -# Setup chain by name (only single chains) +# emulator config class # -def setupChain( trigger , OutputLevel=0): +class TrigEgammaEmulationToolConfig: - from AthenaConfiguration.ComponentFactory import CompFactory + # + # Constructor + # + def __init__(self, name, triggerList, OutputLevel = 0, + ElectronTriggerList=single_electron_triggers, + PhotonTriggerList=single_photon_triggers): + + self.name = name + self.__chains = [] + self.TriggerList = triggerList + self.OutputLevel = OutputLevel + self.ElectronTriggerList = ElectronTriggerList + self.PhotonTriggerList = PhotonTriggerList + + # configure everything + self.configure() + - from TriggerMenuMT.HLTMenuConfig.Menu.DictFromChainName import dictFromChainName - d = dictFromChainName(trigger) + def __call__(self): + return self.__emulator + + # + # Configure emulator tool + # + def configure(self): + + + from TriggerMenuMT.HLTMenuConfig.Egamma.EgammaDefs import createTrigEgammaPrecisionElectronLHSelectors + from TriggerMenuMT.HLTMenuConfig.Egamma.EgammaDefs import createTrigEgammaPrecisionElectronDNNSelectors + from TriggerMenuMT.HLTMenuConfig.Egamma.EgammaDefs import createTrigEgammaPrecisionElectronCBSelectors + from TriggerMenuMT.HLTMenuConfig.Egamma.EgammaDefs import createTrigEgammaPrecisionPhotonSelectors + from TriggerMenuMT.HLTMenuConfig.Egamma.EgammaDefs import createTrigEgammaFastCaloSelectors + + # setup all chains + for trigger in self.TriggerList: + self.setupChain(trigger) + + # create the emulator tool + self.__emulator = CompFactory.Trig.TrigEgammaEmulationToolMT( self.name, + HypoTools = self.__chains, + ElectronTriggerList = self.ElectronTriggerList, + PhotonTriggerList = self.PhotonTriggerList ) + + self.__emulator.RingerTools = createTrigEgammaFastCaloSelectors() + self.__emulator.ElectronLHSelectorTools = createTrigEgammaPrecisionElectronLHSelectors() + self.__emulator.ElectronCBSelectorTools = createTrigEgammaPrecisionElectronCBSelectors() + self.__emulator.ElectronDNNSelectorTools = createTrigEgammaPrecisionElectronDNNSelectors() + self.__emulator.PhotonCBSelectorTools = createTrigEgammaPrecisionPhotonSelectors() + + + # + # Setup chain by name (only single chains) + # + def setupChain( self, trigger ): - signature = d['signatures'][0] - from pprint import pprint - pprint(d) + import cppyy + cppyy.load_library('libElectronPhotonSelectorToolsDict') - from TrigEgammaHypo.TrigEgammaFastCaloHypoTool import TrigEgammaFastCaloHypoToolFromDict - from TrigEgammaHypo.TrigEgammaFastElectronHypoTool import TrigEgammaFastElectronHypoToolFromDict - from TrigEgammaHypo.TrigEgammaFastPhotonHypoTool import TrigEgammaFastPhotonHypoToolFromDict - from TrigEgammaHypo.TrigEgammaPrecisionCaloHypoTool import TrigEgammaPrecisionCaloHypoToolFromDict - from TrigEgammaHypo.TrigEgammaPrecisionElectronHypoTool import TrigEgammaPrecisionElectronHypoToolFromDict - from TrigEgammaHypo.TrigEgammaPrecisionPhotonHypoTool import TrigEgammaPrecisionPhotonHypoToolFromDict - from TrigEgammaHypo.TrigEgammaPrecisionTrackingHypoTool import TrigEgammaPrecisionTrackingHypoToolFromDict - # Configure L1Calo - L1CaloTool = createL1Calo(trigger + "_Step0" , d) + from TriggerMenuMT.HLTMenuConfig.Menu.DictFromChainName import dictFromChainName + d = dictFromChainName(trigger) - # Configure HLT - FastCaloTool = TrigEgammaFastCaloHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationFastCaloHypoTool(trigger+'_Step1') ) - PrecisionCaloTool = TrigEgammaPrecisionCaloHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionCaloHypoTool(trigger+'_Step3')) - PrecisionTrackingTool = TrigEgammaPrecisionTrackingHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionTrackingHypoTool(trigger+'_Step4')) - - if signature == 'Electron': - FastTool = TrigEgammaFastElectronHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationFastElectronHypoTool(trigger+'_Step2')) - PrecisionTool = TrigEgammaPrecisionElectronHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionElectronHypoTool(trigger+'_Step5')) - elif signature == 'Photon': - FastTool = TrigEgammaFastPhotonHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationFastPhotonHypoTool(trigger+'_Step2')) - PrecisionTool = TrigEgammaPrecisionPhotonHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionPhotonHypoTool(trigger+'_Step5')) + signature = d['signatures'][0] + from pprint import pprint + pprint(d) + from TrigEgammaHypo.TrigEgammaFastCaloHypoTool import TrigEgammaFastCaloHypoToolFromDict + from TrigEgammaHypo.TrigEgammaFastElectronHypoTool import TrigEgammaFastElectronHypoToolFromDict + from TrigEgammaHypo.TrigEgammaFastPhotonHypoTool import TrigEgammaFastPhotonHypoToolFromDict + from TrigEgammaHypo.TrigEgammaPrecisionCaloHypoTool import TrigEgammaPrecisionCaloHypoToolFromDict + from TrigEgammaHypo.TrigEgammaPrecisionElectronHypoTool import TrigEgammaPrecisionElectronHypoToolFromDict + from TrigEgammaHypo.TrigEgammaPrecisionPhotonHypoTool import TrigEgammaPrecisionPhotonHypoToolFromDict + from TrigEgammaHypo.TrigEgammaPrecisionTrackingHypoTool import TrigEgammaPrecisionTrackingHypoToolFromDict - chain = CompFactory.Trig.TrigEgammaEmulationChain( - name = trigger, - L1Seed = L1CaloTool, - Steps = [FastCaloTool, FastTool, PrecisionCaloTool, PrecisionTrackingTool, PrecisionTool], - Chain = trigger, - Signature = signature.lower(), - OutputLevel = OutputLevel - ) + # Configure L1Calo + L1CaloTool = self.setupL1Calo(trigger + "_Step0" , d) - return chain + # Configure HLT + FastCaloTool = TrigEgammaFastCaloHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationFastCaloHypoTool(trigger+'_Step1') ) + PrecisionCaloTool = TrigEgammaPrecisionCaloHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionCaloHypoTool(trigger+'_Step3')) + PrecisionTrackingTool = TrigEgammaPrecisionTrackingHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionTrackingHypoTool(trigger+'_Step4')) + if signature == 'Electron': + FastTool = TrigEgammaFastElectronHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationFastElectronHypoTool(trigger+'_Step2')) + PrecisionTool = TrigEgammaPrecisionElectronHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionElectronHypoTool(trigger+'_Step5')) + elif signature == 'Photon': + FastTool = TrigEgammaFastPhotonHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationFastPhotonHypoTool(trigger+'_Step2')) + PrecisionTool = TrigEgammaPrecisionPhotonHypoToolFromDict(d, tool = CompFactory.Trig.TrigEgammaEmulationPrecisionPhotonHypoTool(trigger+'_Step5')) -def createEmulator( name, TriggerList=[], ElectronTriggerList=[], PhotonTriggerList=[]): + chain = CompFactory.Trig.TrigEgammaEmulationChain( + name = trigger, + L1Seed = L1CaloTool, + Steps = [FastCaloTool, FastTool, PrecisionCaloTool, PrecisionTrackingTool, PrecisionTool], + Chain = trigger, + Signature = signature.lower(), + OutputLevel = self.OutputLevel + ) + + self.__chains.append(chain) - #from TriggerMenuMT.HLTMenuConfig.Egamma.EgammaDefs import createTrigEgammaPrecisionElectronLHSelectors - from AthenaConfiguration.ComponentFactory import CompFactory - hypos = [] - # setup all chains - for trigger in TriggerList: - chain = setupChain(trigger) - hypos.append(chain) # - # create emulator + # Configure legacy L1 # - emulator = CompFactory.Trig.TrigEgammaEmulationToolMT(name, - #ElectronLHTools = createTrigEgammaPrecisionElectronLHSelectors(), - #PhotonIsEMTools = createTrigEgammaPrecisionPhotonSelectors(), - ElectronTriggerList = ElectronTriggerList, - PhotonTriggerList = PhotonTriggerList, - HypoTools = hypos, - ) + def setupL1Calo( self, name , info): + + from AthenaConfiguration.ComponentFactory import CompFactory + from AthenaCommon.SystemOfUnits import GeV + import re + + #chainName = info['chainName'] + L1Item = info['chainParts'][0]['L1threshold'] + L1thr = float( re.findall(r'\d+', L1Item)[0] ) + + print('AKI JOAO L1') + print(L1Item) + print(L1thr) + + wp = 0 # default + + # [Default, Tight , Medium, Loose ] + HadCoreCutMin = [ 1.0 , 1.0 , 1.0 , 1.0 ] + HadCoreCutOff = [-0.2 , -0,2 , -0.2 , -0.2 ] + HadCoreSlope = [ 1/23. , 1/23., 1/23., 1/23.] + EmIsolCutMin = [ 2.0 , 1.0 , 1.0 , 1.5 ] + EmIsolCutOff = [-1.8 , -2.6 , -2.0 , -1.8 ] + EmIsolSlope = [ 1/8. , 1/8. , 1/8. , 1/8. ] + + # Configure L1 + L1CaloTool = CompFactory.Trig.TrigEgammaEmulationL1CaloHypoTool( + name = name, + L1Item = L1Item, + L1Thr = L1thr * GeV, + HadCoreCutMin = HadCoreCutMin[wp], + HadCoreCutOff = HadCoreCutOff[wp], + HadCoreSlope = HadCoreSlope[wp], + EmIsolCutMin = EmIsolCutMin[wp], + EmIsolCutOff = EmIsolCutOff[wp], + EmIsolSlope = EmIsolSlope[wp], + IsolCutMax = 50, + OutputLevel = self.OutputLevel) - return emulator + return L1CaloTool + + + + + +def TrigEgammaEmulationToolTestConfig(inputFlags): + + from AthenaConfiguration.ComponentFactory import CompFactory + triggerList = [ "HLT_e17_lhvloose_L1EM15VHI", + "HLT_e5_etcut_L1EM3", + "HLT_e26_lhtight_L1EM22VHI", + "HLT_g20_loose_L1EM15"] + + '''Function to configures some algorithms in the monitoring system.''' + # The following class will make a sequence, configure algorithms, and link + from AthenaMonitoring import AthMonitorCfgHelper + helper = AthMonitorCfgHelper(inputFlags,'TrigEgammaEmulationToolTestCfg') + + test = helper.addAlgorithm( CompFactory.TrigEgammaEmulationToolTest("EmulationTest") ) + acc = helper.resobj + EgammaMatchTool = CompFactory.TrigEgammaMatchingToolMT() + EgammaMatchTool.DeltaR=0.4 + acc.addPublicTool(EgammaMatchTool) + + emulator = TrigEgammaEmulationToolConfig("EmulatorTool", triggerList) + acc.addPublicTool(emulator()) + test.MatchTool = EgammaMatchTool + test.EmulatorTool = emulator() + test.ElectronTriggerList = [ + #"HLT_e5_etcut_L1EM3", + "HLT_e17_lhvloose_L1EM15VHI", + #"HLT_e26_lhtight_L1EM22VHI", + ] + test.PhotonTriggerList = [] + + # include some monitoring histograms + basepath = '/HLT/EgammaMon' + for trigger in triggerList: + cutLabels = ['L1Calo','L2Calo','L2','EFCalo','HLT'] + monGroup = helper.addGroup( test, trigger, basepath+'/EgammaEmulationTest/'+trigger ) + monGroup.defineHistogram("decisions", type='TH1I', path='', title="Event Selection; Cut ; Count", + xbins=len(cutLabels), xmin=0, xmax=len(cutLabels), xlabels=cutLabels) + monGroup.defineHistogram("emulations", type='TH1I', path='', title="Event Selection; Cut ; Count", + xbins=len(cutLabels), xmin=0, xmax=len(cutLabels), xlabels=cutLabels) + + + + return helper.result() + + + if __name__=='__main__': - triggerList = [ "HLT_g20_loose_L1EM15", - "HLT_e28_lhtight_ivarloose_L1EM22VHI"] + # ATR-11839 to fix the egammaPid import + from PyUtils.Helpers import ROOT6Setup + ROOT6Setup() + + # Setup the Run III behavior + from AthenaCommon.Configurable import Configurable + Configurable.configurableRun3Behavior = 1 + + # Setup logs + from AthenaCommon.Logging import log + from AthenaCommon.Constants import INFO + log.setLevel(INFO) + + # Set the Athena configuration flags + from AthenaConfiguration.AllConfigFlags import ConfigFlags + + path = '/afs/cern.ch/work/j/jodafons/public/valid_sampleA/valid1.361106.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zee.recon.AOD.e5112_s3214_d1663_r12711_tid25855934_00/AOD.25855934._000067.pool.root.1' + + ConfigFlags.Input.Files = [path] + ConfigFlags.Input.isMC = True + ConfigFlags.Output.HISTFileName = 'TrigEgammaMonitorOutput.root' + ConfigFlags.lock() + + # Initialize configuration object, add accumulator, merge, and run. + from AthenaConfiguration.MainServicesConfig import MainServicesCfg + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + cfg = MainServicesCfg(ConfigFlags) + cfg.merge(PoolReadCfg(ConfigFlags)) + testAcc = TrigEgammaEmulationToolTestConfig(ConfigFlags) + cfg.merge(testAcc) + + # If you want to turn on more detailed messages ... + cfg.printConfig(withDetails=False) # set True for exhaustive info + cfg.run(-1) #use cfg.run(20) to only run on first 20 events + + - emulator = createEmulator( "EmulatorTool", triggerList ) \ No newline at end of file diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.cxx new file mode 100644 index 00000000000..a9a94c04e09 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.cxx @@ -0,0 +1,280 @@ + +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +// TrigEgammaMatchingToolTest.cxx + +#include "TrigEgammaEmulationToolTest.h" + + + +//********************************************************************** + +TrigEgammaEmulationToolTest::TrigEgammaEmulationToolTest(const std::string& name, ISvcLocator* pSvcLocator ) + : AthMonitorAlgorithm( name, pSvcLocator ), + m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool") +{ + declareProperty("MatchTool" , m_matchTool ); + declareProperty("EmulatorTool" , m_emulatorTool ); +} + +//********************************************************************** + +TrigEgammaEmulationToolTest::~TrigEgammaEmulationToolTest() { } + +//********************************************************************** + +StatusCode TrigEgammaEmulationToolTest::initialize() { + + ATH_MSG_INFO("Initializing " << name() << "..."); + ATH_CHECK(AthMonitorAlgorithm::initialize()); + ATH_MSG_INFO("Retrieving tools..."); + + ATH_CHECK(m_trigdec.retrieve()); + ATH_CHECK(m_offElectronKey.initialize()); + ATH_CHECK(m_offPhotonKey.initialize()); + ATH_CHECK(m_matchTool.retrieve()); + ATH_CHECK(m_emulatorTool.retrieve()); + + m_trigdec->ExperimentalAndExpertMethods()->enable(); + + m_accept.addCut("L1Calo",""); + m_accept.addCut("L2Calo",""); + m_accept.addCut("L2",""); + m_accept.addCut("EFCalo",""); + m_accept.addCut("EFTrack",""); + m_accept.addCut("HLT",""); + + + return StatusCode::SUCCESS; +} + + +//********************************************************************** + + +StatusCode TrigEgammaEmulationToolTest::fillHistograms( const EventContext &ctx ) const +{ + ATH_MSG_INFO("=============== Start Event ==============="); + + SG::ReadHandle<xAOD::EventInfo> eventInfo = GetEventInfo (ctx); + if( !eventInfo.isValid() ){ + ATH_MSG_WARNING("Failed to retrieve EventInfo"); + return StatusCode::SUCCESS; + } + if (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error) { + ATH_MSG_WARNING("Event not passing LAr"); + return StatusCode::SUCCESS; + } + + SG::ReadHandle<xAOD::ElectronContainer> offElectrons(m_offElectronKey, ctx); + if(!offElectrons.isValid()) + { + ATH_MSG_WARNING("Failed to retrieve offline Electrons "); + return StatusCode::SUCCESS; + } + + ATH_MSG_INFO( "Electron size is " << offElectrons->size() ); + + for (const auto &trigger : m_electronTriggerList) + { + auto info = getInfo(trigger); + ATH_MSG_INFO(trigger); + for (const auto &el : *offElectrons) + { + const TrigCompositeUtils::Decision *dec=nullptr; + m_matchTool->match(el,trigger,dec, TrigDefs::includeFailedDecisions); + + if (!dec) { + ATH_MSG_INFO("e/g matching fail. skip..."); + continue; + } + + auto accept = setAccept(dec, info); + auto emu_accept = m_emulatorTool->emulate( dec, info.trigger ); + + ATH_MSG_INFO( "trigger: " << info.trigger << " (tdt/emu)"); + ATH_MSG_INFO( "L1Calo : " << accept.getCutResult(0) << " / " << emu_accept.getCutResult(0)); + ATH_MSG_INFO( "L2Calo : " << accept.getCutResult(1) << " / " << emu_accept.getCutResult(1)); + ATH_MSG_INFO( "L2 : " << accept.getCutResult(2) << " / " << emu_accept.getCutResult(2)); + ATH_MSG_INFO( "EFCalo : " << accept.getCutResult(3) << " / " << emu_accept.getCutResult(3)); + ATH_MSG_INFO( "HLT : " << accept.getCutResult(5) << " / " << emu_accept.getCutResult(5)); + + auto monGroup = getGroup( trigger ); + + + // Fill trigger decision tool steps + if (accept.getCutResult(0)){ + fillLabel(monGroup, "decisions", "L1Calo"); + if (accept.getCutResult(1)){ + fillLabel(monGroup, "decisions", "L2Calo"); + if(accept.getCutResult(2)){ + fillLabel(monGroup, "decisions", "L2"); + if(accept.getCutResult(3)){ + fillLabel(monGroup, "decisions", "EFCalo"); + if(accept.getCutResult(5)){ + fillLabel(monGroup, "decisions", "HLT"); + } + } + } + } + } + + // Fill emulation + if (emu_accept.getCutResult(0)){ + fillLabel(monGroup, "emulations", "L1Calo"); + if (emu_accept.getCutResult(1)){ + fillLabel(monGroup, "emulations", "L2Calo"); + if(emu_accept.getCutResult(2)){ + fillLabel(monGroup, "emulations", "L2"); + if(emu_accept.getCutResult(3)){ + fillLabel(monGroup, "emulations", "EFCalo"); + if(emu_accept.getCutResult(5)){ + fillLabel(monGroup, "emulations", "HLT"); + } + } + } + } + } + + + + + } + } + + + ATH_MSG_INFO("================= End Event ================="); + + return StatusCode::SUCCESS; +} + + + +//********************************************************************** + + + +asg::AcceptData TrigEgammaEmulationToolTest::setAccept( const TrigCompositeUtils::Decision *dec, + const TrigEgammaEmulationToolTest::TrigInfo info) const +{ + + ATH_MSG_DEBUG("setAccept"); + unsigned int condition=TrigDefs::includeFailedDecisions; + + asg::AcceptData acceptData (&m_accept); + bool passedL1Calo=false; + bool passedL2Calo=false; + bool passedEFCalo=false; + bool passedL2=false; + bool passedEFTrk=false; + bool passedEF=false; + + if (dec) { + + auto trigger = info.trigger; + // Step 1 + passedL1Calo = m_matchTool->ancestorPassed<TrigRoiDescriptorCollection>( dec , trigger , "initialRois", condition); + + if( passedL1Calo ){ // HLT item get full decision + // Step 2 + passedL2Calo = m_matchTool->ancestorPassed<xAOD::TrigEMClusterContainer>(dec, trigger, m_matchTool->key("FastCalo"), condition); + + if(passedL2Calo){ + + // Step 3 + if(info.type == "electron"){ + std::string key = m_matchTool->key("FastElectrons"); + if(info.lrt) key = m_matchTool->key("FastElectrons_LRT"); + passedL2 = m_matchTool->ancestorPassed<xAOD::TrigElectronContainer>(dec, trigger, key, condition); + }else if(info.type == "photon"){ + passedL2 = m_matchTool->ancestorPassed<xAOD::TrigPhotonContainer>(dec, trigger, m_matchTool->key("FastPhotons"), condition); + } + + if(passedL2){ + + + // Step 4 + std::string key = m_matchTool->key("PrecisionCalo"); + if(info.lrt) key = m_matchTool->key("PrecisionCalo_LRT"); + passedEFCalo = m_matchTool->ancestorPassed<xAOD::CaloClusterContainer>(dec, trigger, key, condition); + + if(passedEFCalo){ + + // Step 5 + passedEFTrk=true;// Assume true for photons + + // Step 6 + if(info.trigger == "electron"){ + if( info.etcut || info.idperf){// etcut or idperf + passedEF = true; // since we dont run the preciseElectron step + }else{ + std::string key = m_matchTool->key("Electrons"); + if(info.lrt) key = m_matchTool->key("Electrons_LRT"); + if(info.gsf) key = m_matchTool->key("Electrons_GSF"); + passedEF = m_matchTool->ancestorPassed<xAOD::ElectronContainer>(dec, trigger, key, condition); + } + + }else if(info.type == "photon"){ + if (info.etcut){ + passedEF = true; // since we dont run the precisePhoton step + }else{ + passedEF = m_matchTool->ancestorPassed<xAOD::PhotonContainer>(dec, trigger, m_matchTool->key("Photons"), condition); + } + } + } // EFCalo + }// L2 + }// L2Calo + }// L2Calo + + } + + 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; +} + +//********************************************************************** + + +TrigEgammaEmulationToolTest::TrigInfo TrigEgammaEmulationToolTest::getInfo( std::string trigger ) const +{ + std::string type = "electron"; // default + std::vector<std::string> strs; + boost::split(strs,trigger,boost::is_any_of("_")); + if(boost::contains(trigger,"HLT_e")) type = "electron"; + else if(boost::contains(trigger,"HLT_g")) type = "photon"; + bool idperf = boost::contains(trigger, "idperf"); + bool etcut = boost::contains(trigger, "etcut"); + bool lrt = boost::contains(trigger, "lrt"); + bool gsf = boost::contains(trigger, "gsf"); + std::string str_thr = strs.at(1); + str_thr.erase(0, 1); + float et = atof(str_thr.c_str()); + return TrigEgammaEmulationToolTest::TrigInfo{trigger,type,et,etcut,idperf,gsf,lrt}; +} + +//********************************************************************** + + +void TrigEgammaEmulationToolTest::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 ); +} + + diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.h b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.h new file mode 100644 index 00000000000..342001cbd17 --- /dev/null +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/TrigEgammaEmulationToolTest.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +*/ + +// TrigEgammaMatchingToolTest.h + +#ifndef TrigEgammaEmulationToolTest_H +#define TrigEgammaEmulationToolTest_H + +#include "AthenaMonitoring/AthMonitorAlgorithm.h" +#include "AthenaMonitoringKernel/GenericMonitoringTool.h" +#include "TrigEgammaMatchingTool/TrigEgammaMatchingToolMT.h" +#include "TrigEgammaEmulationTool/TrigEgammaEmulationToolMT.h" +#include "xAODEgamma/ElectronContainer.h" +#include "xAODEgamma/PhotonContainer.h" + + +class TrigEgammaEmulationToolTest : public AthMonitorAlgorithm +{ + public: + + struct TrigInfo{ + std::string trigger; + std::string type; + float threshold; + bool etcut; + bool idperf; + bool gsf; + bool lrt; + }; + + + public: + /// Constructor with parameters: + TrigEgammaEmulationToolTest(const std::string& name, ISvcLocator* pSvcLocator); + /// Destructor: + virtual ~TrigEgammaEmulationToolTest(); + + /// Athena algorithm's Hooks + virtual StatusCode initialize() override; + virtual StatusCode fillHistograms(const EventContext& ctx) const override; + + + private: + + asg::AcceptInfo m_accept; + + ToolHandle<Trig::TrigDecisionTool> m_trigdec; + ToolHandle<TrigEgammaMatchingToolMT> m_matchTool; + ToolHandle<Trig::TrigEgammaEmulationToolMT> m_emulatorTool; + + Gaudi::Property<std::vector<std::string>> m_electronTriggerList {this, "ElectronTriggerList", {}, }; + Gaudi::Property<std::vector<std::string>> m_photonTriggerList {this, "PhotonTriggerList", {}, }; + + SG::ReadHandleKey<xAOD::ElectronContainer> m_offElectronKey{ this, "ElectronKey", "Electrons", ""}; + SG::ReadHandleKey<xAOD::PhotonContainer> m_offPhotonKey{ this, "PhotonKey", "Photons", ""}; + + asg::AcceptData setAccept( const TrigCompositeUtils::Decision *dec, + const TrigEgammaEmulationToolTest::TrigInfo info) const; + + TrigEgammaEmulationToolTest::TrigInfo getInfo( std::string trigger ) const; + + + void fillLabel( const ToolHandle<GenericMonitoringTool>& groupHandle, + const std::string &histname, + const std::string &label ) const; +}; + +#endif diff --git a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/components/TrigEgammaEmulationTool_entries.cxx b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/components/TrigEgammaEmulationTool_entries.cxx index 33ad424a9e6..da4be540b0d 100644 --- a/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/components/TrigEgammaEmulationTool_entries.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaEmulationTool/src/components/TrigEgammaEmulationTool_entries.cxx @@ -12,6 +12,8 @@ #include "TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionPhotonHypoTool.h" #include "TrigEgammaEmulationTool/TrigEgammaEmulationPrecisionTrackingHypoTool.h" +#include "../TrigEgammaEmulationToolTest.h" + DECLARE_COMPONENT( Trig::TrigEgammaEmulationToolMT ) DECLARE_COMPONENT( Trig::TrigEgammaEmulationChain ) @@ -26,3 +28,4 @@ DECLARE_COMPONENT( Trig::TrigEgammaEmulationPrecisionPhotonHypoTool ) DECLARE_COMPONENT( Trig::TrigEgammaEmulationPrecisionTrackingHypoTool ) +DECLARE_COMPONENT(TrigEgammaEmulationToolTest) \ No newline at end of file diff --git a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx index ca296827a3d..e466d736bce 100644 --- a/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaMatchingTool/Root/TrigEgammaMatchingToolMT.cxx @@ -238,7 +238,9 @@ const xAOD::TrigRingerRings* TrigEgammaMatchingToolMT::getRingsFeature( const Tr if( !rg_cont.isValid() ) return nullptr; for( const auto *rg : *rg_cont ){ - if(rg->emCluster()->RoIword()==(*initRoi.link)->roiWord()) + const xAOD::TrigEMCluster *cl = rg->emCluster(); + if(!cl) continue; + if(cl->RoIword()==(*initRoi.link)->roiWord()) return rg; } return nullptr; diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategoryMT.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategoryMT.py index 163c0682333..9f6f78e0a7d 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategoryMT.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitCategoryMT.py @@ -88,4 +88,11 @@ validation_Zee = [ 'HLT_e26_lhtight_e15_etcut_Zee_L1EM22VHI', 'HLT_e26_lhtight_e15_etcut_idperf_Zee_L1EM22VHI', 'HLT_e20_lhtight_ivarloose_L1ZAFB-25DPHI-eEM18I' - ] # adding Zee/special chains later + ] # adding Zee/special chains later + +# +# All single triggers +# +single_electron_triggers = set(monitoring_electron + monitoringTP_electron + validation_electron + validationTP_electron) +single_photon_triggers = set(monitoring_photon + validation_photon) + diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py index 7f2b242f467..847dd8fd2e2 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitorAlgorithm.py @@ -44,6 +44,11 @@ def TrigEgammaMonConfig(inputFlags): if __name__=='__main__': + + # ATR-11839 to fix the egammaPid import + from PyUtils.Helpers import ROOT6Setup + ROOT6Setup() + # Setup the Run III behavior from AthenaCommon.Configurable import Configurable Configurable.configurableRun3Behavior = 1 diff --git a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py index f9ed236acc3..48b61d837b4 100644 --- a/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py +++ b/Trigger/TrigMonitoring/TrigEgammaMonitoring/python/TrigEgammaMonitoringMTConfig.py @@ -242,7 +242,6 @@ class TrigEgammaMonAlgBuilder: LooseDNNElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20210430/ElectronDNNMulticlassLoose.conf" MediumDNNElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20210430/ElectronDNNMulticlassMedium.conf" TightDNNElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20210430/ElectronDNNMulticlassTight.conf" - # cutbased for photons TightPhotonSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMTightSelectorCutDefs.conf" MediumPhotonSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMMediumSelectorCutDefs.conf" @@ -262,7 +261,6 @@ class TrigEgammaMonAlgBuilder: LooseDNNElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20210430/ElectronDNNMulticlassLoose.conf" MediumDNNElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20210430/ElectronDNNMulticlassMedium.conf" TightDNNElectronSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc16_20210430/ElectronDNNMulticlassTight.conf" - # cut based for photons TightPhotonSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMTightSelectorCutDefs.conf" MediumPhotonSelector.ConfigFile = "ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMMediumSelectorCutDefs.conf" @@ -274,6 +272,12 @@ class TrigEgammaMonAlgBuilder: + if self.emulation: + from TrigEgammaEmulationTool.TrigEgammaEmulationToolConfigMT import TrigEgammaEmulationToolConfig + triggerList = self.tpList + emulator = TrigEgammaEmulationToolConfig("EgammaEmulationTool", triggerList) + acc.addPublicTool(emulator()) + if self.activate_zee: @@ -300,8 +304,9 @@ class TrigEgammaMonAlgBuilder: self.zeeMonAlg.TagTriggerList=self.tagItems self.zeeMonAlg.TriggerList=self.tpList self.zeeMonAlg.DetailedHistograms=self.detailedHistograms - self.zeeMonAlg.DoEmulation = False - + if self.emulation: + self.zeeMonAlg.DoEmulation = True + self.zeeMonAlg.EmulationTool = emulator() if self.activate_jpsiee: diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/EgammaDefs.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/EgammaDefs.py index c3da5898d77..698fc671060 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/EgammaDefs.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Egamma/EgammaDefs.py @@ -32,7 +32,7 @@ class TrigEgammaKeys(object): TrigElectronTracksCollectionName = recordable('HLT_IDTrack_Electron_IDTrig') pidVersion = 'rel22_20210611' dnnVersion = 'mc16_20210430' - ringerVersion = 'TrigL2_20210227_r3' + ringerVersion = 'TrigL2_20210702_r4' @@ -238,8 +238,7 @@ def createTrigEgammaFastCaloSelectors(ConfigFilePath=None): # We should include the ringer here if not ConfigFilePath: - #ConfigFilePath = 'RingerSelectorTools/'+TrigEgammaKeys.ringerVersion - ConfigFilePath = TrigEgammaKeys.ringerVersion + ConfigFilePath = 'RingerSelectorTools/'+TrigEgammaKeys.ringerVersion SelectorNames = collections.OrderedDict({ -- GitLab