ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaEmulationToolMT.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2022 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
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(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
88 Trig::TrigData &output,
89 unsigned int condition) const
90{
91 output.clear();
92
93 if(!roi) {
94 ATH_MSG_DEBUG("no Roi!");
95 return false;
96 }
97
98
99 // Link all selectors with this trig object to easy acesss throut of the chain
100 // Avoid multiple selectors
101 output.egammaElectronCBTools=m_egammaElectronCBTools;
102 output.egammaElectronDNNTools=m_egammaElectronDNNTools;
103 output.egammaElectronLHTools=m_egammaElectronLHTools;
104 output.egammaPhotonCBTools=m_egammaPhotonCBTools;
105 output.ringerTools=m_ringerTools;
106
107
108 if(output.signature == "electron"){
109 for (auto& trigger : m_electronTrigList){
110
111 if(boost::contains(output.trigger,"gsf") && !boost::contains(trigger,"gsf")) continue;
112 if(boost::contains(output.trigger,"lrt") && !boost::contains(trigger,"lrt")) continue;
113
114 ATH_MSG_DEBUG("Matching with " << trigger );
115
116
117 auto vec_el_linkInfo = match()->getFeatures<xAOD::ElectronContainer>(roi,trigger,condition);
118
119 if( !vec_el_linkInfo.empty() ){
120
121 output.clear();
122
123 // Step 5
124 {
125 for(auto&featLinkInfo : vec_el_linkInfo)
126 {
127 if(!featLinkInfo.isValid()) continue;
128 auto el = *featLinkInfo.link;
129 output.electrons.push_back(el);
130 }
131 }
132
133 // Step 3
134 {
135 auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(roi,trigger,condition);
136 for(auto& featLinkInfo : vec_feat){
137 if(!featLinkInfo.isValid()) continue;
138 output.clusters.push_back(*featLinkInfo.link);
139 }
140 }
141
142 // Step 2
143 {
144 auto vec_feat = match()->getFeatures<xAOD::TrigElectronContainer>(roi, trigger, condition);
145 for ( auto& featLinkInfo : vec_feat ){
146 if(!featLinkInfo.isValid()) continue;
147 output.trig_electrons.push_back(*featLinkInfo.link);
148 }
149 }
150
151 // Step 1
152 {
153 // get rings from container access
154 output.rings = match()->getRingsFeature(roi);
155 if(output.rings){
156 output.emCluster = output.rings->emCluster();
157 }
158 }
159
160
161
162 // Step 0
163 {
164 // L1Calo (step 0)
165 output.l1 = match()->getL1Feature(roi);
166 auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(roi,trigger, condition);
167 if(featLinkInfo.isValid()){
168 output.roi = *featLinkInfo.link;
169 }
170 }
171
172 ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No"));
173 ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No"));
174 ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No"));
175 ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No"));
176 ATH_MSG_DEBUG( "L2 Electrons = " << (output.trig_electrons.size()));
177 ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size());
178 ATH_MSG_DEBUG( "HLT el = " << output.electrons.size());
179
180 }// has electron
181
182 // stop the trigger loop since we have all features inside
183 if(output.isValid())
184 return true;
185
186 }// Loop over triggers
187
188 }else if (output.signature == "photon"){
189
190 for (auto& trigger : m_photonTrigList){
191
192 auto vec_ph_linkInfo = match()->getFeatures<xAOD::PhotonContainer>(roi,trigger,condition);
193
194 if( !vec_ph_linkInfo.empty() ){
195
196 // clean all vectors before fill it
197 output.clear();
198
199 // Step 5
200 {
201 for(auto&featLinkInfo : vec_ph_linkInfo){
202 if(!featLinkInfo.isValid()) continue;
203 output.photons.push_back(*featLinkInfo.link);
204 }
205 }
206
207 // Step 3
208 {
209 auto vec_feat = match()->getFeatures<xAOD::CaloClusterContainer>(roi,trigger,condition);
210 for(auto& featLinkInfo : vec_feat){
211 if(!featLinkInfo.isValid()) continue;
212 output.clusters.push_back(*featLinkInfo.link);
213 }
214 }
215
216 // Step 1
217 {
218 auto featLinkInfo = match()->getFeature<xAOD::TrigEMClusterContainer>(roi,trigger);
219 if(featLinkInfo.isValid()){
220 output.emCluster = *featLinkInfo.link;
221 }
222 // get rings from container access
223 output.rings = match()->getRingsFeature(roi);
224
225 }
226
227 // Step 0
228 {
229 // L1Calo (step 0)
230 output.l1 = match()->getL1Feature(roi);
231 auto featLinkInfo = match()->getFeature<TrigRoiDescriptorCollection>(roi,trigger);
232 if(featLinkInfo.isValid()){
233 output.roi = *featLinkInfo.link;
234 }
235 }
236
237 ATH_MSG_DEBUG( "L1 RoI TDET = " << (output.roi?"Yes":"No"));
238 ATH_MSG_DEBUG( "L1 RoI EmTau = " << (output.l1?"Yes":"No"));
239 ATH_MSG_DEBUG( "L2 Cluster = " << (output.emCluster?"Yes":"No"));
240 ATH_MSG_DEBUG( "L2 Rings = " << (output.rings?"Yes":"No"));
241 ATH_MSG_DEBUG( "L2 Photon = " << (output.trig_photon?"Yes":"No"));
242 ATH_MSG_DEBUG( "HLT Cluster = " << output.clusters.size());
243 ATH_MSG_DEBUG( "HLT ph = " << output.photons.size());
244 }// has electron
245
246 // stop the trigger loop since we have all features inside
247 if(output.isValid()) return true;
248
249 }// Loop over triggers
250 }
251
252
253 return false;
254}
255
256
257//**********************************************************************
258
259
260
261TrigData::TrigData( const std::string& name )
262{
263 this->signature = "electron"; // default
264 if(boost::contains(name,"HLT_e")) this->signature = "electron";
265 else if(boost::contains(name,"HLT_g")) this->signature = "photon";
266}
267
268
270{
271 this->electrons.clear();
272 this->trig_electrons.clear();
273 this->clusters.clear();
274 this->photons.clear();
275 this->roi = nullptr;
276 this->l1 = nullptr;
277 this->emCluster = nullptr;
278 this->rings = nullptr;
279 this->trig_photon = nullptr;
280}
281
282
284{
285 bool passed = (this->roi && this->l1 && this->emCluster && this->rings);
286 if (this->signature == "photon"){
287 return (this->trig_photon && !this->photons.empty() && passed);
288 }else if (this->signature == "electron"){
289 return (!this->trig_electrons.empty() && !this->electrons.empty() && passed);
290 }else{
291 return false;
292 }
293}
294
295
296bool TrigData::isPassed( const xAOD::Photon *ph , const std::string& pidname ) const
297{
298 if (pidname=="tight"){
299 return (bool)this->egammaPhotonCBTools[0]->accept(ph);
300 }else if (pidname=="medium"){
301 return (bool)this->egammaPhotonCBTools[1]->accept(ph);
302 }else if (pidname=="loose"){
303 return (bool)this->egammaPhotonCBTools[2]->accept(ph);
304 }else{
305 return true;
306 }
307}
308
309bool TrigData::isPassed( const xAOD::Electron *el , float avgmu, const std::string& pidname ) const
310{
311 if (pidname=="lhtight"){
312 return (bool)this->egammaElectronLHTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu );
313 }else if (pidname=="lhmedium"){
314 return (bool)this->egammaElectronLHTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu );
315 }else if (pidname=="lhloose"){
316 return (bool)this->egammaElectronLHTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu );
317 }else if (pidname=="lhvloose"){
318 return (bool)this->egammaElectronLHTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu );
319 }else if (pidname=="dnntight"){
320 return (bool)this->egammaElectronDNNTools[0]->accept(Gaudi::Hive::currentContext(),el,avgmu );
321 }else if (pidname=="dnnmedium"){
322 return (bool)this->egammaElectronDNNTools[1]->accept(Gaudi::Hive::currentContext(),el,avgmu );
323 }else if (pidname=="dnnloose"){
324 return (bool)this->egammaElectronDNNTools[2]->accept(Gaudi::Hive::currentContext(),el,avgmu );
325 }else if (pidname=="dnnvloose"){
326 return (bool)this->egammaElectronDNNTools[3]->accept(Gaudi::Hive::currentContext(),el,avgmu );
327 }else if (pidname=="tight"){
328 return (bool)this->egammaElectronCBTools[0]->accept(Gaudi::Hive::currentContext(),el );
329 }else if (pidname=="medium"){
330 return (bool)this->egammaElectronCBTools[1]->accept(Gaudi::Hive::currentContext(),el );
331 }else if (pidname=="loose"){
332 return (bool)this->egammaElectronCBTools[2]->accept(Gaudi::Hive::currentContext(),el );
333 }else{
334 return true;
335 }
336}
337
338
339bool TrigData::isPassed( const xAOD::TrigRingerRings *cl , float avgmu, const std::string& pidname ) const
340{
341 if (pidname=="tight"){
342 float output = this->ringerTools[0]->predict(cl);
343 return (bool)this->ringerTools[0]->accept(cl, output, avgmu);
344 }else if (pidname=="medium"){
345 float output = this->ringerTools[1]->predict(cl);
346 return (bool)this->ringerTools[1]->accept(cl, output, avgmu);
347 }else if (pidname=="loose"){
348 float output = this->ringerTools[2]->predict(cl);
349 return (bool)this->ringerTools[2]->accept(cl, output, avgmu);
350 }else if (pidname=="vloose"){
351 float output = this->ringerTools[3]->predict(cl);
352 return (bool)this->ringerTools[3]->accept(cl, output, avgmu);
353 }else{
354 return true;
355 }
356}
357
358
359
#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
asg::AcceptData emulate(const TrigCompositeUtils::Decision *dec, const std::string &trigger, bool &valid) const
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
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".