ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaMatchingToolMT.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
10#include <typeinfo>
11#include <string>
12
13using namespace TrigCompositeUtils;
14using namespace Trig;
15
16
17
18
19/*
20 * TrigEgammaMatchinTool API
21 */
22
23
25 asg::AsgTool( name ),
26 m_trigDecTool("Trig::TrigDecisionTool/TrigDecisionTool")
27{;}
28
29
31
33{
34 ATH_CHECK(tdt().retrieve());
35
36 ATH_CHECK( m_emTauRoIKey.initialize() );
37 ATH_CHECK( m_ringerKey.initialize() );
38
39
40 m_keys[ "Electrons"] = "HLT_egamma_Electrons" ;
41 m_keys[ "Electrons_GSF"] = "HLT_egamma_Electrons_GSF" ; // gsf
42 m_keys[ "Electrons_LRT"] = "HLT_egamma_Electrons_LRT" ; // lrt
43 m_keys[ "Photons"] = "HLT_egamma_Photons" ;
44
45 // intermediate steps
46 m_keys[ "PrecisionCalo_Electron"] = "HLT_CaloEMClusters_Electron";
47 m_keys[ "PrecisionCalo_Photon"] = "HLT_CaloEMClusters_Photon";
48 m_keys[ "PrecisionCalo_LRT"] = "HLT_CaloEMClusters_LRT" ; // lrt
49 m_keys[ "PrecisionCalo_HI"] = "HLT_HICaloEMClusters" ; // ion chains
50
51 // Fast steps
52 m_keys[ "FastElectrons"] = "HLT_FastElectrons" ;
53 m_keys[ "FastElectrons_LRT"] = "HLT_FastElectrons_LRT" ; // lrt
54 m_keys[ "FastPhotons"] = "HLT_FastPhotons" ;
55 m_keys[ "FastCalo"] = "HLT_FastCaloEMClusters" ;
56 // L1
57 m_keys[ "L1Calo"] = "LVL1EmTauRoIs" ;
58 m_keys[ "L1eEM"] = "L1_eEMRoI";
59
60 return StatusCode::SUCCESS;
61}
62
63
65
66std::string TrigEgammaMatchingToolMT::key( const std::string& key) const
67{
68 return m_keys.at(key);
69}
70
72
73bool TrigEgammaMatchingToolMT::isPassed(const EventContext& ctx, const xAOD::Egamma *eg,const std::string &trigger, unsigned int condition ) const
74{
75 const TrigCompositeUtils::Decision *dec=nullptr;
76 if( match( eg, trigger, dec ) ){
77 if( dec ){
79 std::string key = this->key("Electrons_GSF");
80 if(trigger.contains("nogsf")) key=this->key("Electrons");
81 if(trigger.contains("lrt")) key=this->key("Electrons_LRT");
82 return ancestorPassed<xAOD::ElectronContainer>(ctx, dec, trigger,key, condition);
83 }
85 return ancestorPassed<xAOD::PhotonContainer>(ctx, dec, trigger, key("Photons"), condition);
86 }
87 }
88 }
89 return false;
90}
91
93
94bool TrigEgammaMatchingToolMT::match(const xAOD::Egamma *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
95{
96
97 ATH_MSG_DEBUG("Match decec with trigger " << trigger);
99 const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg);
100 if( matchHLTElectron(el,trigger,dec, condition) ) {
101 ATH_MSG_DEBUG("Matched!");
102 return true;
103 }
104 }else if(xAOD::EgammaHelpers::isPhoton(eg)){
105 const xAOD::Photon* ph =static_cast<const xAOD::Photon*> (eg);
106 if( matchHLTPhoton(ph,trigger,dec, condition) ) return true;
107 }
108
109 if( matchHLTCalo(eg,trigger,dec) ) return true;
110
112 const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg);
113 if( matchL2Electron(el,trigger,dec, condition) ) return true;
114
115 }else if(xAOD::EgammaHelpers::isPhoton(eg)){
116 const xAOD::Photon* ph =static_cast<const xAOD::Photon*> (eg);
117 if( matchL2Photon(ph,trigger,dec, condition) ) return true;
118 }
119
120 if( matchL2Calo(eg,trigger,dec, condition) ) return true;
121
122 if( matchL1(eg,trigger,dec, condition) ) return true;
123 ATH_MSG_DEBUG("match() failed!");
124 return false;
125}
126
127
129
130bool TrigEgammaMatchingToolMT::matchHLTPhoton(const xAOD::Photon *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
131{
132 ATH_MSG_DEBUG("Match HLT Photon");
133 return closestObject<xAOD::PhotonContainer>( eg, dec, trigger, key("Photons"), m_dR, condition );
134}
135
137
138bool TrigEgammaMatchingToolMT::matchHLTElectron(const xAOD::Electron *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
139{
140 if (trigger.contains("nogsf")){
141 ATH_MSG_DEBUG("Matched HLT Electron noGSF");
142 return closestObject<xAOD::ElectronContainer>( eg, dec , trigger, key("Electrons"), m_dR, condition );
143 }else if(trigger.contains("lrt")){
144 ATH_MSG_DEBUG("Matched HLT Electron LRT");
145 return closestObject<xAOD::ElectronContainer>( eg, dec , trigger, key("Electrons_LRT"), m_dR, condition );
146 }else {
147 ATH_MSG_DEBUG("Matched HLT Electron");
148 return closestObject<xAOD::ElectronContainer>( eg, dec , trigger, key("Electrons_GSF"), m_dR, condition );
149 }
150}
151
153
154bool TrigEgammaMatchingToolMT::matchHLTCalo(const xAOD::Egamma *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
155{
156 ATH_MSG_DEBUG("Match HLT PrecisionCalo");
157 if(trigger.contains("lrt")){
158 ATH_MSG_DEBUG("Matched HLT PrecisionCalo LRT");
159 return closestObject<xAOD::CaloClusterContainer>( eg, dec, trigger, key("PrecisionCalo_LRT"), m_dR, condition );
160 }else if(trigger.contains("ion")){
161 ATH_MSG_DEBUG("Matched HLT PrecisionCalo Heavy Ion");
162 return closestObject<xAOD::CaloClusterContainer>( eg, dec, trigger, key("PrecisionCalo_HI"), m_dR, condition );
164 ATH_MSG_DEBUG("Matched HLT PrecisionCalo Electron");
165 return closestObject<xAOD::CaloClusterContainer>( eg, dec, trigger, key("PrecisionCalo_Electron"), m_dR, condition );
166 }else if(xAOD::EgammaHelpers::isPhoton(eg)){
167 ATH_MSG_DEBUG("Matched HLT PrecisionCalo Photon");
168 return closestObject<xAOD::CaloClusterContainer>( eg, dec, trigger, key("PrecisionCalo_Photon"), m_dR, condition );
169 }else{
170 ATH_MSG_DEBUG("Match HLT PrecisionCalo failed!");
171 return false;
172 }
173}
174
176
177bool TrigEgammaMatchingToolMT::matchL2Photon(const xAOD::Photon *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
178{
179 ATH_MSG_DEBUG("Match L2 Photon");
180 return closestObject<xAOD::TrigPhotonContainer>( eg, dec, trigger, key("FastPhotons"), m_dR, condition );
181}
182
184
185bool TrigEgammaMatchingToolMT::matchL2Electron(const xAOD::Electron *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
186{
187 ATH_MSG_DEBUG("Match L2 Electron");
188 if(trigger.contains("lrt")){
189 return closestObject<xAOD::TrigElectronContainer>( eg, dec, trigger, key("FastElectrons_LRT"), m_dR, condition );
190 }else{
191 return closestObject<xAOD::TrigElectronContainer>( eg, dec, trigger, key("FastElectrons"), m_dR, condition );
192 }
193}
194
196
197bool TrigEgammaMatchingToolMT::matchL2Calo(const xAOD::Egamma *eg,const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
198{
199 ATH_MSG_DEBUG("Match L2 Calo");
200 return closestObject<xAOD::TrigEMClusterContainer>( eg, dec, trigger, key("FastCalo") , m_dR, condition);
201}
202
204
205bool TrigEgammaMatchingToolMT::matchL1( const xAOD::Egamma* eg, const std::string &trigger, const TrigCompositeUtils::Decision *&dec, unsigned int condition ) const
206{
207 ATH_MSG_DEBUG("Match L1 Calo");
208
209 double deltaR=0.0;
210 auto initRois = tdt()->features<TrigRoiDescriptorCollection>(trigger,condition,"",TrigDefs::allFeaturesOfType,"initialRoI");
211 if( initRois.size() < 1) return false;
212 for( auto &initRoi: initRois ){
213 if( !initRoi.link.isValid() ) continue;
214 deltaR = dR(eg->eta(),eg->phi(), (*initRoi.link)->eta(),(*initRoi.link)->phi());
215 if(deltaR < (float)m_dRL1){
216 dec=initRoi.source;
217 return true;
218 }
219 }
220
221 return false;
222}
223
225
227{
228 if( !dec ) return nullptr;
229 auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(ctx, dec, "initialRoI");
230 if( !initRoi.isValid() ) return nullptr;
231
233 if( !l1_cont.isValid() ) return nullptr;
234
235 for( const auto *l1 : *l1_cont ){
236 if ( l1->roiType() != xAOD::EmTauRoI::RoIType::EMRoIWord) continue;
237 if((*initRoi.link)->roiWord()==l1->roiWord()){
238 return l1;
239 }
240 }
241 return nullptr;
242}
243
245
247{
248 if( !dec ) return nullptr;
249 auto initRoi = TrigCompositeUtils::findLink<xAOD::eFexEMRoIContainer>(ctx, dec, "initialRecRoI");
250 if( !initRoi.isValid() ) return nullptr;
251 return *(initRoi.link);
252}
253
255
257{
258 if( !dec ) return nullptr;
259 auto initRoi = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(ctx, dec, "initialRoI");
260 if( !initRoi.isValid() ) return nullptr;
261
263
264 if( !rg_cont.isValid() ) return nullptr;
265
266 for( const auto *rg : *rg_cont ){
267 const xAOD::TrigEMCluster *cl = rg->emCluster();
268 if(!cl) continue;
269 if(cl->RoIword()==(*initRoi.link)->roiWord())
270 return rg;
271 }
272 return nullptr;
273}
274
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::map< std::string, std::string > m_keys
SG::ReadHandleKey< xAOD::EmTauRoIContainer > m_emTauRoIKey
bool matchHLTPhoton(const xAOD::Photon *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
bool matchL2Calo(const xAOD::Egamma *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
StatusCode initialize()
=======================================================================
bool matchL2Photon(const xAOD::Photon *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
const ToolHandle< Trig::TrigDecisionTool > & tdt() const
std::string key(const std::string &) const
=======================================================================
bool matchHLTElectron(const xAOD::Electron *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
const xAOD::EmTauRoI * getL1Feature(const EventContext &, const TrigCompositeUtils::Decision *) const
=======================================================================
TrigEgammaMatchingToolMT(const std::string &name)
bool matchL2Electron(const xAOD::Electron *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
SG::ReadHandleKey< xAOD::TrigRingerRingsContainer > m_ringerKey
bool matchHLTCalo(const xAOD::Egamma *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
bool match(const xAOD::Egamma *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
bool matchL1(const xAOD::Egamma *, const std::string &, const TrigCompositeUtils::Decision *&, unsigned int condition=TrigDefs::Physics) const
=======================================================================
double dR(const double eta1, const double phi1, const double eta2, const double phi2) const
const xAOD::TrigRingerRings * getRingsFeature(const EventContext &, const TrigCompositeUtils::Decision *) const
=======================================================================
Gaudi::Property< float > m_dR
const xAOD::eFexEMRoI * getL1eEMFeature(const EventContext &, const TrigCompositeUtils::Decision *) const
=======================================================================
bool isPassed(const EventContext &ctx, const xAOD::Egamma *, const std::string &, unsigned int condition=TrigDefs::Physics) const
=======================================================================
bool ancestorPassed(const EventContext &ctx, const TrigCompositeUtils::Decision *, const std::string &trigger, const std::string &key, unsigned int condition=TrigDefs::Physics) const
bool closestObject(const xAOD::Egamma *, const TrigCompositeUtils::Decision *&, const std::string &trigger, const std::string &key, float dR_value, unsigned int condition=TrigDefs::Physics) const
Gaudi::Property< float > m_dRL1
ToolHandle< Trig::TrigDecisionTool > m_trigDecTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition Egamma_v1.cxx:76
@ EMRoIWord
This is a Run 2 EM RoI word.
Definition EmTauRoI_v2.h:47
LinkInfo< T > findLink(const EventContext &ctx, const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
static const unsigned int allFeaturesOfType
Run 3 "enum". Return all features along legs (still with type and container checks).
The common trigger namespace for trigger analysis tools.
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
eFexEMRoI_v1 eFexEMRoI
Define the latest version of the eFexEMRoI class.
Definition eFexEMRoI.h:17
TrigRingerRings_v2 TrigRingerRings
Define the latest version of the TrigRingerRings class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
TrigEMCluster_v1 TrigEMCluster
Define the latest version of the trigger EM cluster class.
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".
EmTauRoI_v2 EmTauRoI
Definition EmTauRoI.h:16