2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 #include <boost/algorithm/string.hpp>
7 // L2Calo, L2Electron, L2Photon, EFCalo, Electron and Photon trigger passed access
9 inline bool TrigEgammaMatchingToolMT::ancestorPassed( const TrigCompositeUtils::Decision *dec, const std::string& trigger, const std::string& key,
10 unsigned int condition) const
13 if( !dec ) return false;
15 auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( dec, "initialRoI");
16 if( !initRoi.isValid() )
19 auto vec = tdt()->features< T >(trigger,condition ,key);
21 for( auto &featLinkInfo : vec )
23 auto roi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(featLinkInfo.source, "initialRoI");
24 if( ! roi.isValid()) continue;
25 if( (*roi.link)->roiWord() == (*initRoi.link)->roiWord())
27 bool passed = (featLinkInfo.state==TrigCompositeUtils::ActiveState::ACTIVE);
28 if(passed) return true;
35 // L1Calo trigger passed access
37 inline bool TrigEgammaMatchingToolMT::ancestorPassed<TrigRoiDescriptorCollection>( const TrigCompositeUtils::Decision *dec,
38 const std::string& trigger, const std::string& /*key*/,
39 unsigned int condition ) const
41 if( !dec ) return false;
42 auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( dec, "initialRoI");
43 if( !initRoi.isValid() )
46 auto vec = tdt()->features<TrigRoiDescriptorCollection>(trigger,condition,"",TrigDefs::allFeaturesOfType,"initialRoI");
48 for( auto &featLinkInfo : vec )
50 if(!featLinkInfo.isValid()) continue;
51 if( (*featLinkInfo.link)->roiWord() == (*initRoi.link)->roiWord())
53 bool passed = (featLinkInfo.state==TrigCompositeUtils::ActiveState::ACTIVE);
54 if(passed) return true;
64 inline bool TrigEgammaMatchingToolMT::closestObject( const xAOD::Egamma *eg, const TrigCompositeUtils::Decision *&dec,
65 const std::string &trigger, const std::string &key ,
66 float dR_value, unsigned int condition
70 auto vec = tdt()->features<T>(trigger, condition ,key);
73 for( auto &featLinkInfo : vec ){
75 if(! featLinkInfo.isValid() ) continue;
76 const auto *feat = *(featLinkInfo.link);
78 deltaR = dR(eg->eta(),eg->phi(), feat->eta(),feat->phi());
79 if(deltaR < dR_value){
80 dec = featLinkInfo.source;
89 inline std::vector<TrigCompositeUtils::LinkInfo<T>> TrigEgammaMatchingToolMT::getFeatures( const TrigCompositeUtils::Decision *dec ,
90 const std::string& trigger, const std::string& key,
91 unsigned int condition)
94 std::vector<TrigCompositeUtils::LinkInfo<T>> vec;
95 auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(dec, "initialRoI");
96 if( !initRoi.isValid() ) return vec;
98 auto vec_dec = tdt()->features<T>(trigger,condition, key);
99 for ( auto& featLinkInfo : vec_dec ){
100 if( !featLinkInfo.isValid() ) continue;
101 auto roi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(featLinkInfo.source, "initialRoI");
102 if( ! roi.isValid()) continue;
103 if( (*roi.link)->roiWord() == (*initRoi.link)->roiWord() )
104 vec.push_back( featLinkInfo );
115 inline TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> TrigEgammaMatchingToolMT::getFeature<TrigRoiDescriptorCollection>( const TrigCompositeUtils::Decision *dec ,
116 const std::string& trigger, unsigned int condition)
119 auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(dec, "initialRoI");
121 if( initRoi.isValid() ){
122 // includeFailedDecisions
124 auto vec_dec = tdt()->features<TrigRoiDescriptorCollection>(trigger, condition,"",TrigDefs::allFeaturesOfType,"initialRoI");
125 for( auto &featLinkInfo: vec_dec ){
126 if( !featLinkInfo.isValid() ) continue;
127 if( (*featLinkInfo.link)->roiWord() == (*initRoi.link)->roiWord() ) return featLinkInfo;
131 return TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection>();
137 inline TrigCompositeUtils::LinkInfo<xAOD::TrigEMClusterContainer> TrigEgammaMatchingToolMT::getFeature<xAOD::TrigEMClusterContainer>( const TrigCompositeUtils::Decision *dec ,
138 const std::string& trigger, unsigned int condition)
141 std::vector<TrigCompositeUtils::LinkInfo<xAOD::TrigEMClusterContainer>> vec = getFeatures<xAOD::TrigEMClusterContainer>(dec, trigger, key("FastCalo") , condition);
142 return !vec.empty() ? vec.front() : TrigCompositeUtils::LinkInfo<xAOD::TrigEMClusterContainer>();
148 inline std::vector<TrigCompositeUtils::LinkInfo<xAOD::TrigElectronContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::TrigElectronContainer>(
149 const TrigCompositeUtils::Decision *dec , const std::string& trigger, unsigned int condition)
152 if(boost::contains(trigger,"lrt")){
153 return getFeatures<xAOD::TrigElectronContainer>(dec, trigger, key("FastElectrons_LRT"), condition);
155 return getFeatures<xAOD::TrigElectronContainer>(dec, trigger, key("FastElectrons"), condition);
162 inline TrigCompositeUtils::LinkInfo<xAOD::TrigPhotonContainer> TrigEgammaMatchingToolMT::getFeature<xAOD::TrigPhotonContainer>(
163 const TrigCompositeUtils::Decision *dec , const std::string& trigger, unsigned int condition)
166 auto vec = getFeatures<xAOD::TrigPhotonContainer>(dec, trigger, key("FastPhotons") , condition);
167 return !vec.empty() ? vec.front() : TrigCompositeUtils::LinkInfo<xAOD::TrigPhotonContainer>();
173 inline std::vector<TrigCompositeUtils::LinkInfo<xAOD::CaloClusterContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::CaloClusterContainer>(
174 const TrigCompositeUtils::Decision *dec , const std::string& trigger, unsigned int condition)
177 std::vector<std::string> parts;
178 boost::split(parts,trigger,boost::is_any_of("_"));
180 if(boost::contains(trigger,"lrt")){
181 return getFeatures<xAOD::CaloClusterContainer>(dec, trigger, key("PrecisionCalo_LRT"), condition );
182 }else if(boost::contains(parts.at(0),"g")){
183 return getFeatures<xAOD::CaloClusterContainer>(dec, trigger, key("PrecisionCalo_Photon"), condition );
185 return getFeatures<xAOD::CaloClusterContainer>(dec, trigger, key("PrecisionCalo_Electron"), condition );
194 inline std::vector<TrigCompositeUtils::LinkInfo<xAOD::ElectronContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::ElectronContainer>(
195 const TrigCompositeUtils::Decision *dec , const std::string& trigger, unsigned int condition)
198 if (boost::contains(trigger,"gsf")){
199 return getFeatures<xAOD::ElectronContainer>(dec, trigger, key("Electrons_GSF") , condition);
200 }else if(boost::contains(trigger,"lrt")){
201 return getFeatures<xAOD::ElectronContainer>(dec, trigger, key("Electrons_LRT") , condition);
203 return getFeatures<xAOD::ElectronContainer>(dec, trigger, key("Electrons") , condition);
210 inline std::vector<TrigCompositeUtils::LinkInfo<xAOD::PhotonContainer>> TrigEgammaMatchingToolMT::getFeatures<xAOD::PhotonContainer>( const TrigCompositeUtils::Decision *dec ,
211 const std::string& trigger, unsigned int condition)
214 return getFeatures<xAOD::PhotonContainer>(dec, trigger, key("Photons"), condition );