ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaEmulationToolMT.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#include "boost/algorithm/string.hpp"
7
8using namespace Trig;
9
10
11
12//**********************************************************************
13
15 : AsgTool(myname),
16 m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"),
17 m_matchTool("Trig::TrigEgammaMatchingToolMT/TrigEgammaMatchingToolMT")
18{
19 declareProperty( "MatchTool" , m_matchTool );
20}
21
22//**********************************************************************
23
25{
26 ATH_CHECK(m_matchTool.retrieve());
27
28 //Enable expert methods
29 ATH_CHECK(m_trigdec.retrieve());
30
31 // retrieve all hypo chains
32 ATH_CHECK( m_hypoTools.retrieve() );
33
34
35 ATH_CHECK( m_egammaPhotonCBTools.retrieve() );
39 ATH_CHECK( m_ringerTools.retrieve() );
40
41
42 //add cuts into TAccept
43 m_accept.addCut("L1Calo" , "Trigger L1Calo step" );
44 m_accept.addCut("L2Calo" , "Trigger L2Calo step" );
45 m_accept.addCut("L2" , "Trigger L2Electron step" );
46 m_accept.addCut("EFCalo" , "Trigger EFCalo step" );
47 m_accept.addCut("EFTrack" , "Trigger EFTrack step" );
48 m_accept.addCut("HLT" , "Trigger HLT decision" );
49
50
51 return StatusCode::SUCCESS;
52}
53
54//**********************************************************************
55
58 const std::string& trigger, bool &valid) const
59{
60 asg::AcceptData acceptData (&m_accept);
61 valid=false;
62 for ( auto& tool : m_hypoTools )
63 {
64 if( tool->chain() == trigger )
65 {
66 Trig::TrigData input(trigger);
67 if(!match(ctx, roi, input)) return acceptData;
68
69 // Check of the match procedure has all objects inside
70 if(!input.isValid()){
71 ATH_MSG_WARNING("Its not possible to find all trigger features for this RoI. Skip emulation.");
72 return acceptData;
73 }
74
75 valid=true;
76 return tool->emulate(input);
77
78 }// Tool
79
80 }// Loop over all hypo tool chains
81
82 return acceptData;
83}
84
85
86//**********************************************************************
87
88bool TrigEgammaEmulationToolMT::match( const EventContext& ctx,
90 Trig::TrigData &output,
91 unsigned int condition) const
92{
93 output.clear();
94
95 if(!roi) {
96 ATH_MSG_DEBUG("no Roi!");
97 return false;
98 }
99
100
101 // Link all selectors with this trig object to easy acesss throut of the chain
102 // Avoid multiple selectors
103 output.egammaElectronCBTools=m_egammaElectronCBTools;
104 output.egammaElectronDNNTools=m_egammaElectronDNNTools;
105 output.egammaElectronLHTools=m_egammaElectronLHTools;
106 output.egammaPhotonCBTools=m_egammaPhotonCBTools;
107 output.ringerTools=m_ringerTools;
108
109
110 if(output.signature == "electron"){
111 for (auto& trigger : m_electronTrigList){
112
113 if(boost::contains(output.trigger,"gsf") && !boost::contains(trigger,"gsf")) continue;
114 if(boost::contains(output.trigger,"lrt") && !boost::contains(trigger,"lrt")) continue;
115
116 ATH_MSG_DEBUG("Matching with " << trigger );
117
118
119 auto vec_el_linkInfo = match()->getFeatures<xAOD::ElectronContainer>(ctx,roi,trigger,condition);
120
121 if( !vec_el_linkInfo.empty() ){
122
123 output.clear();
124
125 // Step 5
126 {
127 for(auto&featLinkInfo : vec_el_linkInfo)
128 {
129 if(!featLinkInfo.isValid()) continue;
130 auto el = *featLinkInfo.link;
131 output.electrons.push_back(el);
132 }
133 }
134
135 // Step 3
136 {
137 auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(ctx,roi,trigger,condition);
138 for(auto& featLinkInfo : vec_feat){
139 if(!featLinkInfo.isValid()) continue;
140 output.clusters.push_back(*featLinkInfo.link);
141 }
142 }
143
144 // Step 2
145 {
146 auto vec_feat = match()->getFeatures<xAOD::TrigElectronContainer>(ctx,roi, trigger, condition);
147 for ( auto& featLinkInfo : vec_feat ){
148 if(!featLinkInfo.isValid()) continue;
149 output.trig_electrons.push_back(*featLinkInfo.link);
150 }
151 }
152
153 // Step 1
154 {
155 // get rings from container access
156 output.rings = match()->getRingsFeature(ctx, roi);
157 if(output.rings){
158 output.emCluster = output.rings->emCluster();
159 }
160 }
161
162
163
164 // Step 0
165 {
166 // L1Calo (step 0)
167 output.l1 = match()->getL1Feature(ctx, roi);
168 auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(ctx,roi,trigger, condition);
169 if(featLinkInfo.isValid()){
170 output.roi = *featLinkInfo.link;
171 }
172 }
173
174 ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No"));
175 ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No"));
176 ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No"));
177 ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No"));
178 ATH_MSG_DEBUG( "L2 Electrons = " << (output.trig_electrons.size()));
179 ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size());
180 ATH_MSG_DEBUG( "HLT el = " << output.electrons.size());
181
182 }// has electron
183
184 // stop the trigger loop since we have all features inside
185 if(output.isValid())
186 return true;
187
188 }// Loop over triggers
189
190 }else if (output.signature == "photon"){
191
192 for (auto& trigger : m_photonTrigList){
193
194 auto vec_ph_linkInfo = match()->getFeatures<xAOD::PhotonContainer>(ctx,roi,trigger,condition);
195
196 if( !vec_ph_linkInfo.empty() ){
197
198 // clean all vectors before fill it
199 output.clear();
200
201 // Step 5
202 {
203 for(auto&featLinkInfo : vec_ph_linkInfo){
204 if(!featLinkInfo.isValid()) continue;
205 output.photons.push_back(*featLinkInfo.link);
206 }
207 }
208
209 // Step 3
210 {
211 auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(ctx,roi,trigger,condition);
212 for(auto& featLinkInfo : vec_feat){
213 if(!featLinkInfo.isValid()) continue;
214 output.clusters.push_back(*featLinkInfo.link);
215 }
216 }
217
218 // Step 1
219 {
220 auto featLinkInfo = match()->getFeature<xAOD::TrigEMClusterContainer>(ctx,roi,trigger);
221 if(featLinkInfo.isValid()){
222 output.emCluster = *featLinkInfo.link;
223 }
224 // get rings from container access
225 output.rings = match()->getRingsFeature(ctx, roi);
226
227 }
228
229 // Step 0
230 {
231 // L1Calo (step 0)
232 output.l1 = match()->getL1Feature(ctx, roi);
233 auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(ctx,roi,trigger);
234 if(featLinkInfo.isValid()){
235 output.roi = *featLinkInfo.link;
236 }
237 }
238
239 ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No"));
240 ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No"));
241 ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No"));
242 ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No"));
243 ATH_MSG_DEBUG( "L2 Photon = " << (output.trig_photon?"Yes":"No"));
244 ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size());
245 ATH_MSG_DEBUG( "HLT ph = " << output.photons.size());
246 }// has electron
247
248 // stop the trigger loop since we have all features inside
249 if(output.isValid()) return true;
250
251 }// Loop over triggers
252 }
253
254
255 return false;
256}
257
258
259//**********************************************************************
260
261
262
263TrigData::TrigData( const std::string& name )
264{
265 this->signature = "electron"; // default
266 if(boost::contains(name,"HLT_e")) this->signature = "electron";
267 else if(boost::contains(name,"HLT_g")) this->signature = "photon";
268}
269
270
272{
273 this->electrons.clear();
274 this->trig_electrons.clear();
275 this->clusters.clear();
276 this->photons.clear();
277 this->roi = nullptr;
278 this->l1 = nullptr;
279 this->emCluster = nullptr;
280 this->rings = nullptr;
281 this->trig_photon = nullptr;
282}
283
284
286{
287 bool passed = (this->roi && this->l1 && this->emCluster && this->rings);
288 if (this->signature == "photon"){
289 return (this->trig_photon && !this->photons.empty() && passed);
290 }else if (this->signature == "electron"){
291 return (!this->trig_electrons.empty() && !this->electrons.empty() && passed);
292 }else{
293 return false;
294 }
295}
296
297
298bool TrigData::isPassed( const xAOD::Photon *ph , const std::string& pidname ) const
299{
300 if (pidname=="tight"){
301 return (bool)this->egammaPhotonCBTools[0]->accept(ph);
302 }else if (pidname=="medium"){
303 return (bool)this->egammaPhotonCBTools[1]->accept(ph);
304 }else if (pidname=="loose"){
305 return (bool)this->egammaPhotonCBTools[2]->accept(ph);
306 }else{
307 return true;
308 }
309}
310
311bool TrigData::isPassed( const xAOD::Electron *el , float avgmu, const std::string& pidname ) const
312{
313 if (pidname=="lhtight"){
314 return (bool)this->egammaElectronLHTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu );
315 }else if (pidname=="lhmedium"){
316 return (bool)this->egammaElectronLHTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu );
317 }else if (pidname=="lhloose"){
318 return (bool)this->egammaElectronLHTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu );
319 }else if (pidname=="lhvloose"){
320 return (bool)this->egammaElectronLHTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu );
321 }else if (pidname=="dnntight"){
322 return (bool)this->egammaElectronDNNTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu );
323 }else if (pidname=="dnnmedium"){
324 return (bool)this->egammaElectronDNNTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu );
325 }else if (pidname=="dnnloose"){
326 return (bool)this->egammaElectronDNNTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu );
327 }else if (pidname=="dnnvloose"){
328 return (bool)this->egammaElectronDNNTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu );
329 }else if (pidname=="tight"){
330 return (bool)this->egammaElectronCBTools[0]->accept(Gaudi::Hive::currentContext(),el );
331 }else if (pidname=="medium"){
332 return (bool)this->egammaElectronCBTools[1]->accept(Gaudi::Hive::currentContext(),el );
333 }else if (pidname=="loose"){
334 return (bool)this->egammaElectronCBTools[2]->accept(Gaudi::Hive::currentContext(),el );
335 }else{
336 return true;
337 }
338}
339
340
341bool TrigData::isPassed( const xAOD::TrigRingerRings *cl , float avgmu, const std::string& pidname ) const
342{
343 if (pidname=="tight"){
344 float output = this->ringerTools[0]->predict(cl);
345 return (bool)this->ringerTools[0]->accept(cl, output, avgmu);
346 }else if (pidname=="medium"){
347 float output = this->ringerTools[1]->predict(cl);
348 return (bool)this->ringerTools[1]->accept(cl, output, avgmu);
349 }else if (pidname=="loose"){
350 float output = this->ringerTools[2]->predict(cl);
351 return (bool)this->ringerTools[2]->accept(cl, output, avgmu);
352 }else if (pidname=="vloose"){
353 float output = this->ringerTools[3]->predict(cl);
354 return (bool)this->ringerTools[3]->accept(cl, output, avgmu);
355 }else{
356 return true;
357 }
358}
359
360
361
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< const xAOD::Photon * > photons
std::vector< const xAOD::TrigElectron * > trig_electrons
bool isPassed(const xAOD::Photon *ph, const std::string &pidname) const
ToolHandleArray< IAsgPhotonIsEMSelector > egammaPhotonCBTools
std::vector< const xAOD::Electron * > electrons
const xAOD::EmTauRoI * l1
ToolHandleArray< IAsgElectronLikelihoodTool > egammaElectronLHTools
ToolHandleArray< IAsgElectronIsEMSelector > egammaElectronCBTools
const xAOD::TrigPhoton * trig_photon
std::vector< const xAOD::CaloCluster * > clusters
const xAOD::TrigEMCluster * emCluster
ToolHandleArray< Ringer::IAsgRingerSelectorTool > ringerTools
TrigData(const std::string &)
const TrigRoiDescriptor * roi
const xAOD::TrigRingerRings * rings
ToolHandleArray< AsgElectronSelectorTool > egammaElectronDNNTools
ToolHandle< TrigEgammaMatchingToolMT > m_matchTool
ToolHandleArray< IAsgElectronIsEMSelector > m_egammaElectronCBTools
const ToolHandle< TrigEgammaMatchingToolMT > & match() const
StatusCode initialize()
Dummy implementation of the initialisation function.
ToolHandleArray< IAsgElectronLikelihoodTool > m_egammaElectronLHTools
ToolHandleArray< AsgElectronSelectorTool > m_egammaElectronDNNTools
Gaudi::Property< std::vector< std::string > > m_photonTrigList
ToolHandleArray< Trig::ITrigEgammaEmulationChain > m_hypoTools
ToolHandleArray< IAsgPhotonIsEMSelector > m_egammaPhotonCBTools
Gaudi::Property< std::vector< std::string > > m_electronTrigList
ToolHandle< Trig::TrigDecisionTool > m_trigdec
Trigger decision tool.
ToolHandleArray< Ringer::IAsgRingerSelectorTool > m_ringerTools
asg::AcceptData emulate(const EventContext &ctx, const TrigCompositeUtils::Decision *dec, const std::string &trigger, bool &valid) const
TrigEgammaEmulationToolMT(const std::string &myname)
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
The common trigger namespace for trigger analysis tools.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
TrigElectronContainer_v1 TrigElectronContainer
Declare the latest version of the container.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TrigRingerRings_v2 TrigRingerRings
Define the latest version of the TrigRingerRings class.
TrigEMClusterContainer_v1 TrigEMClusterContainer
Define the latest version of the trigger EM cluster container.
Photon_v1 Photon
Definition of the current "egamma version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Electron_v1 Electron
Definition of the current "egamma version".