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