ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaMonitorBaseAlgorithm.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
7
8
9TrigEgammaMonitorBaseAlgorithm::TrigEgammaMonitorBaseAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
10 : AthMonitorAlgorithm(name,pSvcLocator),
11 m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"),
12 //m_matchTool("Trig::TrigEgammaMatchingToolMT/TrigEgammaMatchingToolMT")
13 m_matchTool("Trig::R3MatchingTool/TrigR3MatchingTool")
14
15{
16 declareProperty( "MatchTool" , m_matchTool );
17 declareProperty( "EmulationTool" , m_emulatorTool );
18}
19
20
22
23
24
25
27{
28 ATH_MSG_INFO("TrigEgammaMonitorBaseAlgorithm::initialize()...");
30 ATH_MSG_INFO("TrigEgammaMonitorBaseAlgorithm DONE INITIALIZING...");
31 ATH_CHECK(m_trigdec.retrieve());
32 ATH_CHECK(m_photonIsEMTool.retrieve());
33 ATH_CHECK(m_electronIsEMTool.retrieve());
34 ATH_CHECK(m_electronLHTool.retrieve());
35 ATH_CHECK(m_electronDNNTool.retrieve());
36
37 std::vector<std::string> steps = {"L1Calo","L2Calo","L2","EFCalo","EFTrack","HLT"};
38 for(const auto& step:steps)
39 m_accept.addCut(step,step);
40
41
42
43 return StatusCode::SUCCESS;
44}
45
46
47// ************************************************************************************************
48
49bool TrigEgammaMonitorBaseAlgorithm::ApplyElectronPid(const EventContext& ctx, const xAOD::Electron *eg, const std::string& pidname) const
50{
51 if (pidname == "tight"){
52 return (bool) this->m_electronIsEMTool[0]->accept(ctx,eg);
53 }
54 else if (pidname == "medium"){
55 return (bool) this->m_electronIsEMTool[1]->accept(ctx,eg);
56 }
57 else if (pidname == "loose"){
58 return (bool) this->m_electronIsEMTool[2]->accept(ctx,eg);
59 }
60 else if (pidname == "lhtight"){
61 if (!m_doEffwithDNN) return (bool) this->m_electronLHTool[0]->accept(ctx,eg);
62 else return (bool) this->m_electronDNNTool[0]->accept(ctx,eg);
63 }
64 else if (pidname == "lhmedium"){
65 if (!m_doEffwithDNN) return (bool) this->m_electronLHTool[1]->accept(ctx,eg);
66 else return (bool) this->m_electronDNNTool[1]->accept(ctx,eg);
67 }
68 else if (pidname == "lhloose"){
69 if (!m_doEffwithDNN) return (bool) this->m_electronLHTool[2]->accept(ctx,eg);
70 else return (bool) this->m_electronDNNTool[2]->accept(ctx,eg);
71 }
72 else if (pidname == "lhvloose"){
73 return (bool) this->m_electronLHTool[3]->accept(ctx,eg);
74 }
75 else if (pidname == "dnntight"){
76 if (!m_doEffwithLH) return (bool) this->m_electronDNNTool[0]->accept(ctx,eg);
77 else return (bool) this->m_electronLHTool[0]->accept(ctx,eg);
78 }
79 else if (pidname == "dnnmedium"){
80 if (!m_doEffwithLH) return (bool) this->m_electronDNNTool[1]->accept(ctx,eg);
81 else return (bool) this->m_electronLHTool[1]->accept(ctx,eg);
82 }
83 else if (pidname == "dnnloose"){
84 if (!m_doEffwithLH) return (bool) this->m_electronDNNTool[2]->accept(ctx,eg);
85 else return (bool) this->m_electronLHTool[2]->accept(ctx,eg);
86 }
87 else ATH_MSG_DEBUG("No Pid tool, continue without PID");
88 return false;
89}
90
91
92
93// ************************************************************************************************
94
95
96bool TrigEgammaMonitorBaseAlgorithm::ApplyPhotonPid(const EventContext& ctx, const xAOD::Photon *eg, const std::string& pidname) const
97{
98 if (pidname == "tight"){
99 return (bool) this->m_photonIsEMTool[0]->accept(ctx,eg);
100 }
101 else if (pidname == "medium"){
102 return (bool) this->m_photonIsEMTool[1]->accept(ctx,eg);
103 }
104 else if (pidname == "loose"){
105 return (bool) this->m_photonIsEMTool[2]->accept(ctx,eg);
106 }
107 else ATH_MSG_DEBUG("No Pid tool, continue without PID");
108 return false;
109}
110
111
112// ************************************************************************************************
113
114
115
116bool TrigEgammaMonitorBaseAlgorithm::isIsolated(const xAOD::Electron *eg, const std::string& isolation) const {
117 ATH_MSG_DEBUG("Apply Isolation " << isolation);
118 float ptcone20=0;
119 bool isoStat=eg->isolationValue(ptcone20, xAOD::Iso::ptcone20);
120 if (!isoStat) {
121 ATH_MSG_DEBUG("Electron doesn't provide isolation for ptcone20");
122 return false;
123 }
124 if (!(fabs(eg->pt()) > 0)) {
125 ATH_MSG_DEBUG("Electron pt is zero, can't calculate relative isolation");
126 return false;
127 }
128 ATH_MSG_DEBUG("ptcone20 " << ptcone20);
129 float ptcone20_rel = ptcone20/eg->pt();
130 ATH_MSG_DEBUG("Relative isolation value " << ptcone20_rel);
131 if (isolation == "loose"){
132 if (ptcone20_rel > 0.1) {
133 ATH_MSG_DEBUG("Probe failing isolation");
134 return false;
135 } else {
136 ATH_MSG_DEBUG("Probe passing isolation");
137 return true;
138 }
139 }
140 else {
141 ATH_MSG_DEBUG("No valid working point defined for " << isolation << " continue without isolation");
142 }
143 return false;
144}
145
146
147
148bool TrigEgammaMonitorBaseAlgorithm::isPrescaled(const std::string& trigger) const {
149
150 bool efprescale=false;
151 bool l1prescale=false;
152 bool prescale=false;
153 bool rerun=true; //assume rerun for l1
154 std::string l1item="";
155
156 if(trigger.starts_with( "L1" ))
157 l1item=trigger;
158 if(trigger.starts_with("HLT")){
159 l1item = getL1Item(trigger);
160 const unsigned int bit=tdt()->isPassedBits(trigger);
161 efprescale=bit & TrigDefs::EF_prescaled;
162 rerun=bit&TrigDefs::EF_resurrected; //Rerun, only check for HLT
163 }
164
165
166 ATH_MSG_DEBUG("Checking prescale for " << trigger << " " << l1item);
167 const unsigned int l1bit=tdt()->isPassedBits(l1item);
168 bool l1_afterpre=l1bit&TrigDefs::L1_isPassedAfterPrescale;
169 bool l1_beforepre=l1bit&TrigDefs::L1_isPassedBeforePrescale;
170 l1prescale=l1_beforepre && !l1_afterpre;
171 prescale=efprescale || l1prescale;
172 ATH_MSG_DEBUG("L1 prescale " << l1item << " " << l1prescale << " before " << l1_beforepre << " after " << l1_afterpre);
173 ATH_MSG_DEBUG("EF prescale " << trigger << " " << efprescale << " Prescale " << prescale);
174 if(rerun) return false; // Rerun use the event
175 if(prescale) return true; // Prescaled, reject event
176 return false; // Not prescaled, use event
177}
178
179
180
182
183 ATH_MSG_DEBUG("setAccept");
184
185 unsigned int condition=TrigDefs::includeFailedDecisions;
186
187 asg::AcceptData acceptData (&m_accept);
188
189 bool passedL1Calo=false;
190 bool passedL2Calo=false;
191 bool passedEFCalo=false;
192 bool passedL2=false;
193 bool passedEFTrk=false;
194 bool passedEF=false;
195
196 if (dec) {
197 auto trigger = info.trigger;
198 if (!onlyHLT){
199 // Step 1
200 passedL1Calo = match()->ancestorPassed<TrigRoiDescriptorCollection>( dec , trigger , "initialRois", condition);
201
202 if( passedL1Calo ){ // HLT item get full decision
203 // Step 2
204 passedL2Calo = match()->ancestorPassed<xAOD::TrigEMClusterContainer>(dec, trigger, match()->key("FastCalo"), condition);
205
206 if(passedL2Calo){
207
208 // Step 3
209 if(info.signature == "Electron" or info.signature == "e"){
210 std::string key = match()->key("FastElectrons");
211 if(info.lrt) key = match()->key("FastElectrons_LRT");
212 passedL2 = match()->ancestorPassed<xAOD::TrigElectronContainer>(dec, trigger, key, condition);
213 }else if(info.signature == "Photon" or info.signature == "g"){
214 passedL2 = match()->ancestorPassed<xAOD::TrigPhotonContainer>(dec, trigger, match()->key("FastPhotons"), condition);
215 }
216
217 if(passedL2){
218
219 // Step 4
220 std::string key = match()->key("PrecisionCalo_Electron");
221 if(info.signature == "Photon" or info.signature == "g") key = match()->key("PrecisionCalo_Photon");
222 if(info.lrt) key = match()->key("PrecisionCalo_LRT");
223 if(info.ion) key = match()->key("PrecisionCalo_HI");
224
225 passedEFCalo = match()->ancestorPassed<xAOD::CaloClusterContainer>(dec, trigger, key, condition);
226
227 if(passedEFCalo){
228
229 // Step 5
230 passedEFTrk=true;// Assume true for photons
231
232 // Step 6
233 if(info.signature == "Electron" or info.signature == "e"){
234 if( info.etcut || info.idperf){// etcut or idperf
235 passedEF = true; // since we dont run the preciseElectron step
236 }else{
237 std::string key = match()->key("Electrons_GSF");
238 if(info.lrt) key = match()->key("Electrons_LRT");
239 if(info.nogsf) key = match()->key("Electrons");
240 passedEF = match()->ancestorPassed<xAOD::ElectronContainer>(dec, trigger, key, condition);
241 }
242
243 }else if(info.signature == "Photon" or info.signature == "g"){
244 if (info.etcut){
245 passedEF = true; // since we dont run the precisePhoton step
246 }else{
247 passedEF = match()->ancestorPassed<xAOD::PhotonContainer>(dec, trigger, match()->key("Photons"), condition);
248 }
249 }
250 } // EFCalo
251 }// L2
252 }// L2Calo
253 }// L2Calo
254
255 }
256 else{
257 if(info.signature == "Electron" or info.signature == "e"){
258 if( info.etcut || info.idperf){// etcut or idperf
259 passedEF = true; // since we dont run the preciseElectron step
260 }else{
261 std::string key = match()->key("Electrons_GSF");
262 if(info.lrt) key = match()->key("Electrons_LRT");
263 if(info.nogsf) key = match()->key("Electrons");
264 passedEF = match()->ancestorPassed<xAOD::ElectronContainer>(dec, trigger, key, condition);
265 }
266
267 }else if(info.signature == "Photon" or info.signature == "g"){
268 if (info.etcut){
269 passedEF = true; // since we dont run the precisePhoton step
270 }else{
271 passedEF = match()->ancestorPassed<xAOD::PhotonContainer>(dec, trigger, match()->key("Photons"), condition);
272 }
273 }
274 }
275 }
276
277 acceptData.setCutResult("L1Calo",passedL1Calo);
278 acceptData.setCutResult("L2Calo",passedL2Calo);
279 acceptData.setCutResult("L2",passedL2);
280 acceptData.setCutResult("EFCalo",passedEFCalo);
281 acceptData.setCutResult("EFTrack",passedEFTrk);
282 acceptData.setCutResult("HLT",passedEF);
283 ATH_MSG_DEBUG("Accept results:");
284 ATH_MSG_DEBUG("L1: "<< passedL1Calo);
285 ATH_MSG_DEBUG("L2Calo: " << passedL2Calo);
286 ATH_MSG_DEBUG("L2: "<< passedL2);
287 ATH_MSG_DEBUG("EFCalo: "<< passedEFCalo);
288 ATH_MSG_DEBUG("HLT: "<<passedEF);
289
290 return acceptData;
291}
292
293
294
295
296float TrigEgammaMonitorBaseAlgorithm::dR(const float eta1, const float phi1, const float eta2, const float phi2) const {
297 float deta = fabs(eta1 - eta2);
298 float dphi = fabs(phi1 - phi2) < TMath::Pi() ? fabs(phi1 - phi2) : 2*TMath:: \
299 Pi() - fabs(phi1 - phi2);
300 return sqrt(deta*deta + dphi*dphi);
301}
302
303
304
305
307 if(eg && (eg->caloCluster())){
308 const xAOD::CaloCluster* cluster = eg->caloCluster();
309 return fabs(cluster->etaBE(2));
310 }
311 else return -99.;
312}
313
314
316 if(eg && (eg->caloCluster()) && (eg->trackParticle())){
317 const xAOD::TrackParticle *trk=eg->trackParticle();
318 const xAOD::CaloCluster *clus=eg->caloCluster();
319 float eta = fabs(trk->eta());
320 return clus->e()/cosh(eta);
321 }
322 else return -99.;
323}
324
325
327 if(eg && (eg->caloCluster())){
328 const xAOD::CaloCluster* cluster = eg->caloCluster();
329 float eta2 = fabs(cluster->etaBE(2));
330 return cluster->e()/cosh(eta2);
331 }
332 else return -99.;
333}
334
335
337 if(eg){
338 float emax2=0.;
340 float emax=0.;
342 float den = emax+emax2;
343
344 if (fabs(den) < 1e-6) return -99.;
345
346 float val = (emax-emax2)/(den);
347 return val;
348 }
349 else return -99.;
350}
351
352
354 if(eg && eg->trackParticle()){
355 uint8_t trtHits = 0;
357 uint8_t trtHTHits = 0;
359 if (fabs(trtHits) < 1e-6) {
360 return -99.;
361 }
362 else{
363 return ( (double)trtHTHits / (double)trtHits );
364 }
365 }
366 else return -99.;
367}
368
369
371 const xAOD::TrackParticle* t = eg->trackParticle();
372 float d0sigma=0.;
373 if (t)
374 {
375 float vard0 = t->definingParametersCovMatrix()(0,0);
376 if (vard0 > 0) {
377 d0sigma=sqrtf(vard0);
378 }
379 else return -99.;
380 return d0sigma;
381 }
382 else return -99.;
383}
384
385
387 const xAOD::TrackParticle* t = eg->trackParticle();
388 float d0sigma=0.;
389 if (t)
390 {
391 float vard0 = t->definingParametersCovMatrix()(0,0);
392 if (vard0 > 0) {
393 d0sigma=sqrtf(vard0);
394 }
395 else return -99.;
396
397 if (fabs(d0sigma) < 1e-6) return -99.;
398 return t->d0()/d0sigma;
399 }
400 else return -99.;
401}
402
403
405 if(eg && (eg->caloCluster())){
406 const xAOD::CaloCluster* cluster = eg->caloCluster();
407 return cluster->energyBE(0);
408 }
409 else return 0;
410}
411
412
414 if(eg && (eg->caloCluster())){
415 const xAOD::CaloCluster* cluster = eg->caloCluster();
416 return cluster->energyBE(1);
417 }
418 else return 0.;
419}
420
421
423 if(eg && (eg->caloCluster())){
424 const xAOD::CaloCluster* cluster = eg->caloCluster();
425 return cluster->energyBE(2);
426 }
427 else return 0.;
428}
429
430
432 if(eg && (eg->caloCluster())){
433 const xAOD::CaloCluster* cluster = eg->caloCluster();
434 return cluster->energyBE(3);
435 }
436 else return 0.;
437}
438
439
441 if(eg && (eg->caloCluster())){
442 const xAOD::CaloCluster* cluster = eg->caloCluster();
443 float ebe1 = cluster->energyBE(1);
444 float ebe2 = cluster->energyBE(2);
445 float ebe3 = cluster->energyBE(3);
446 return (ebe1+ebe2+ebe3);
447 }
448 else return 0.;
449}
450
451
453 if(eg && (eg->caloCluster())){
454 const xAOD::CaloCluster* cluster = eg->caloCluster();
455 float ebe0 = cluster->energyBE(0);
456 float ebe1 = cluster->energyBE(1);
457 float ebe2 = cluster->energyBE(2);
458 float ebe3 = cluster->energyBE(3);
459 float eacc = ebe1+ebe2+ebe3;
460 if(eacc==0.) return 0.;
461 return (ebe0/eacc);
462 }
463 else return 0.;
464}
465
466
468#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getShowerShape_##_name_(const xAOD::Egamma* eg) const \
469{ float val{-99}; \
470 eg->showerShapeValue(val,xAOD::EgammaParameters::_name_); \
471 return val; }
472 GETTER(e011)
473 GETTER(e132)
474 GETTER(e237)
475 GETTER(e277)
476 GETTER(ethad)
477 GETTER(ethad1)
478 GETTER(weta1)
479 GETTER(weta2)
480 GETTER(f1)
481 GETTER(e2tsts1)
482 GETTER(emins1)
483 GETTER(emaxs1)
484 GETTER(wtots1)
485 GETTER(fracs1)
486 GETTER(Reta)
487 GETTER(Rphi)
488 GETTER(f3)
489 GETTER(f3core)
490 GETTER(Eratio)
491 GETTER(Rhad)
492 GETTER(Rhad1)
493 GETTER(DeltaE)
494#undef GETTER
495
496
497// GETTER for Isolation monitoring
498#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getIsolation_##_name_(const xAOD::Electron* eg) const\
499{ float val{-99}; \
500 eg->isolationValue(val,xAOD::Iso::_name_); \
501 return val; }
502 GETTER(ptcone20)
503 GETTER(ptcone30)
504 GETTER(ptcone40)
505 GETTER(ptvarcone20)
506 GETTER(ptvarcone30)
507 GETTER(ptvarcone40)
508#undef GETTER
509
510
511#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getIsolation_##_name_(const xAOD::Egamma* eg) const\
512{ float val{-99}; \
513 eg->isolationValue(val,xAOD::Iso::_name_); \
514 return val; }
515 GETTER(ptcone20)
516 GETTER(etcone20)
517 GETTER(etcone30)
518 GETTER(etcone40)
519 GETTER(topoetcone20)
520 GETTER(topoetcone30)
521 GETTER(topoetcone40)
522#undef GETTER
523
524
525// GETTERs for CaloCluster monitoring
526#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getCluster_##_name_(const xAOD::Egamma* eg) const\
527{ if(eg && eg->caloCluster()) \
528 return eg->caloCluster()->_name_(); \
529 else return -99.;}
530 GETTER(et)
531 GETTER(phi)
532 GETTER(eta)
533#undef GETTER
534
535
536// GETTERs for Track monitoring
537#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrack_##_name_(const xAOD::Electron* eg) const\
538{ if(eg && eg->trackParticle()) \
539 return eg->trackParticle()->_name_(); \
540 else return -99.;}
541 GETTER(pt)
542 GETTER(phi)
543 GETTER(eta)
544 GETTER(d0)
545 GETTER(z0)
546#undef GETTER
547
548
549// GETTERs for Track details monitoring
550#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrackSummary_##_name_(const xAOD::Electron* eg) const \
551{ uint8_t val_uint8{0}; \
552 if(eg){ \
553 eg->trackParticleSummaryValue(val_uint8,xAOD::_name_); \
554 return val_uint8; } \
555 else return -99; }
556 GETTER(numberOfInnermostPixelLayerHits)
557 GETTER(numberOfInnermostPixelLayerOutliers)
558 GETTER(numberOfPixelHits)
559 GETTER(numberOfPixelOutliers)
560 GETTER(numberOfSCTHits)
561 GETTER(numberOfSCTOutliers)
562 GETTER(numberOfTRTHits)
563 GETTER(numberOfTRTHighThresholdHits)
564 GETTER(numberOfTRTHighThresholdOutliers)
565 GETTER(numberOfTRTOutliers)
566 GETTER(expectInnermostPixelLayerHit)
567 GETTER(numberOfPixelDeadSensors)
568 GETTER(numberOfSCTDeadSensors)
569 GETTER(numberOfTRTXenonHits)
570#undef GETTER
571
572
573#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrackSummaryFloat_##_name_(const xAOD::Electron* eg) const\
574{ float val_float{0}; \
575 if(eg){ \
576 eg->trackParticleSummaryValue(val_float,xAOD::_name_); \
577 return val_float; } \
578 else return -99; }
579 GETTER(eProbabilityComb)
580 GETTER(eProbabilityHT)
581 GETTER(pixeldEdx)
582#undef GETTER
583
584
585// GETTERs for Calo-Track monitoring
586#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getCaloTrackMatch_##_name_(const xAOD::Electron* eg) const\
587{ float val={-99.}; \
588 if(eg){ \
589 eg->trackCaloMatchValue(val,xAOD::EgammaParameters::_name_);} \
590 return val; }
591 GETTER(deltaEta0)
592 GETTER(deltaPhi0)
593 GETTER(deltaPhiRescaled0)
594 GETTER(deltaEta1)
595 GETTER(deltaPhi1)
596 GETTER(deltaPhiRescaled1)
597 GETTER(deltaEta2)
598 GETTER(deltaPhi2)
599 GETTER(deltaPhiRescaled2)
600 GETTER(deltaEta3)
601 GETTER(deltaPhi3)
602 GETTER(deltaPhiRescaled3)
603#undef GETTER
604
605
606
607TrigInfo TrigEgammaMonitorBaseAlgorithm::getTrigInfo(const std::string& trigger) const{
608 return m_trigInfo.at(trigger);
609}
610
612 return m_trigInfoR3.at(trigger);
613}
614
615
616
617// This is not const function and can not be used in execute mode (not thread safe)
618// adds entry in TrigInfo map to retrieve later via trigger name
619void TrigEgammaMonitorBaseAlgorithm::setTrigInfo(const std::string& trigger){
620
621 /********************************************
622 // Trigger Information struct
623 typedef struct _triginfo
624 {
625 // L1 information
626 bool L1Legacy;
627 std::string L1Threshold; //EM22VHI
628 // HLT information
629 std::string trigger; //Trigger Name
630 std::string signature; //Electron or Photon
631 float etthr; // HLT Et threshold
632 // if trigger is etcut OR idperf, pidname should be default (usually lhloose)
633 std::string pidname; // Offline loose, medium, tight, etc...
634 // extra HLT information
635 bool idperf; // Performance chain
636 bool etcut; // Et cut only chain
637 bool nogsf; // chain without gsf reconstruction
638 bool lrt; // LRT chain
639 bool ion; // Heavy Ion chain
640 std::string isolation;
641 bool isolated;
642 } TrigInfo;
643 *******************************************/
644
645 std::map<std::string, std::string> pidMap = { {"vloose" , "loose" },
646 {"loose" , "loose" },
647 {"medium" , "medium" },
648 {"tight" , "tight" },
649 {"loose1" , "loose" },
650 {"medium1" , "medium" },
651 {"tight1" , "tight" },
652 {"lhvloose" , "lhvloose" },
653 {"lhloose" , "lhloose" },
654 {"lhmedium" , "lhmedium" },
655 {"lhtight" , "lhtight" },
656 {"dnnloose" , "dnnloose" },
657 {"dnnmedium", "dnnmedium"},
658 {"dnntight" , "dnntight" },
659 {"nopid" , "nopid" } };
660
661 std::vector<std::string> isoNames = {"ivarloose","ivarmedium","ivartight","icaloloose","icalomedium","icalotight"};
662
663 bool nogsf = false;
664 bool lrt = false;
665 bool ion = false;
666 bool etcut = false;
667 bool idperf = false;
668 bool isolated = false;
669
670 std::string isolation="";
671 bool l1legacy=true;
672
673 std::string hltinfo=trigger;
674 std::string signature = "";
675 float threshold = 0;
676 // HLT_e/gXX_(pidname/etcut/idperf)_*_L1EMXX to e/gXX_(pidname/etcut/idperf)_*_L1EMXX
677 if(boost::contains(hltinfo,"HLT")) hltinfo.erase(0,4);
678
679
680 std::vector<std::string> parts;
681 boost::split(parts,hltinfo,boost::is_any_of("_"));
682 std::string pidname;
683
684 // e/gXX_(pidname/etcut/idperf)_*_L1EMXX
685 if(boost::contains(parts.at(0),"e")) {
686 signature = "Electron";
688 }else if(boost::contains(parts.at(0),"g")) {
689 signature = "Photon";
690 pidname = m_defaultProbePidPhoton;
691 }else {
692 ATH_MSG_ERROR("Cannot set trigger type from name");
693 }
694
695 ATH_MSG_DEBUG(parts.at(1));
696 if(parts.at(1) == "idperf"){
697 ATH_MSG_DEBUG("This is idperf");
698 idperf=true;
699 }
700 else if( parts.at(1)== "etcut"){
701 ATH_MSG_DEBUG("This is etcut");
702 etcut=true;
703 }
704 else { // remap online pidname to offline pidname
705 ATH_MSG_DEBUG("This is nominal");
706 if (pidMap.count(parts.at(1)) != 1) {
707 ATH_MSG_ERROR("Unknown trigger type: " << parts.at(1) << " (" << trigger << ")");
708 }
709 pidname = pidMap.at(parts.at(1));
710 }
711
712
713 // extra information
714 nogsf = boost::contains(trigger,"nogsf");
715 lrt = boost::contains(trigger,"lrt");
716 ion = boost::contains(trigger,"ion");
717
718 for(auto& iso : isoNames){
719 if(boost::contains(trigger, iso)){
720 isolation=iso; isolated=true; break;
721 }
722 }
723
724 // Get the threshold
725 std::string str_thr = parts.at(0);
726 str_thr.erase( 0, 1);
727 threshold = atof(str_thr.c_str());
728
729 // L1EMXX
730 std::string l1seed = getL1Item(trigger);
731 l1legacy = !boost::contains(l1seed, "eEM");
732
733
734 ATH_MSG_DEBUG("=================== Chain Parser =======================");
735 ATH_MSG_DEBUG( "trigger : " << trigger );
736 ATH_MSG_DEBUG( "threshold : " << threshold);
737 ATH_MSG_DEBUG( "Pidname : " << pidname );
738 ATH_MSG_DEBUG( "signature : " << signature);
739 ATH_MSG_DEBUG( "etcut : " << (etcut?"Yes":"No"));
740 ATH_MSG_DEBUG( "idperf : " << (idperf?"Yes":"No"));
741 ATH_MSG_DEBUG( "nogsf : " << (nogsf?"Yes":"No"));
742 ATH_MSG_DEBUG( "lrt : " << (lrt?"Yes":"No"));
743 ATH_MSG_DEBUG( "HeavyIon : " << (ion?"Yes":"No"));
744 ATH_MSG_DEBUG( "Isolation : " << isolation);
745 ATH_MSG_DEBUG( "Isolated : " << (isolated?"Yes":"No"));
746 ATH_MSG_DEBUG( "L1Seed : " << l1seed << " (Is Legacy? " << (l1legacy?"Yes":"No") << ")");
747 ATH_MSG_DEBUG("========================================================");
748
749 TrigInfo info{l1legacy,l1seed,trigger,signature,threshold,pidname,idperf,etcut,nogsf,lrt,ion,isolation,isolated};
750 m_trigInfo[trigger] = info;
751
752}
753
754std::vector<ChainNameParser::LegInfo>
755TrigEgammaMonitorBaseAlgorithm::getProbeTriggerLeg(const std::string& triggerName) const
756{
757 std::vector<ChainNameParser::LegInfo> result;
758
759 for (const ChainNameParser::LegInfo& legInfo : ChainNameParser::HLTChainInfo(triggerName))
760 {
761 ATH_MSG_DEBUG("Full trigger name = " << triggerName
762 << ", multiplicity = " << legInfo.multiplicity
763 << ", signature = " << legInfo.signature
764 << ", threshold = " << legInfo.threshold
765 << ", leg parts = "<< legInfo.legParts); //Gives the pidname
766
767 result.push_back(legInfo);
768 }
769
770 return result;
771}
772
773
774// This is not const function and can not be used in execute mode (not thread safe)
775// adds entry in TrigInfo map to retrieve later via trigger name
776void TrigEgammaMonitorBaseAlgorithm::setTrigInfoR3(const std::string& trigger){
777
778 ATH_MSG_DEBUG("Entering function");
779 /********************************************
780 // Trigger Information struct
781 typedef struct _triginfo
782 {
783 // L1 information
784 bool L1Legacy; (done)
785 std::string L1Threshold; //EM22VHI
786 // HLT information
787 std::string trigger; //Trigger Name (done)
788 std::string signature; //Electron or Photon (done)
789 float etthr; // HLT Et threshold (done)
790 // if trigger is etcut OR idperf, pidname should be default (usually lhloose)
791 std::string pidname; // Offline loose, medium, tight, etc...(done)
792 // extra HLT information
793 bool idperf; // Performance chain
794 bool etcut; // Et cut only chain
795 bool nogsf; // chain without gsf reconstruction
796 bool lrt; // LRT chain
797 bool ion; // Heavy Ion chain
798 std::string isolation;
799 bool isolated;
800 } TrigInfo;
801 *******************************************/
802
803 std::map<std::string, std::string> pidMap = { {"vloose" , "loose" },
804 {"loose" , "loose" },
805 {"medium" , "medium" },
806 {"tight" , "tight" },
807 {"loose1" , "loose" },
808 {"medium1" , "medium" },
809 {"tight1" , "tight" },
810 {"lhvloose" , "lhvloose" },
811 {"lhloose" , "lhloose" },
812 {"lhmedium" , "lhmedium" },
813 {"lhtight" , "lhtight" },
814 {"dnnloose" , "dnnloose" },
815 {"dnnmedium", "dnnmedium"},
816 {"dnntight" , "dnntight" },
817 {"nopid" , "nopid" } };
818
819 //Get information about each signature of the trigger
820 //Each signature counts as a leg
821 //HLT_2e17_medium_g22_medium_probe_L12eEM24H
822 //Leg 1 : 2e17_medium
823 //Leg2: g22_medium_probe
824
825 float threshold = 0;
826 std::string signature = "";
827 std::string etthr = "";
828 std::string pidname = "";
829
830
831 auto LegParts = getProbeTriggerLeg(trigger);
832
833 //Get the probe leg
834 if(!LegParts.empty())
835 {
836 //Looping over signatures
837 for( const auto& leg: LegParts)
838 {
839 //Grab the requested signature
840 if (leg.signature != "g") continue;
841
842 //Building the probe trigger name
843 signature = leg.signature;
844 if (signature == "g"){
845 signature = "Photon";
846 }
847 threshold = leg.threshold;
848 //threshold = std::to_string(leg.threshold);
849 pidname = leg.legParts[0];
850 }
851 }
852
853
854 bool l1legacy=true;
855 // L1EMXX
856 std::string l1seed = getL1Item(trigger);
857 l1legacy = !boost::contains(l1seed, "eEM");
858
859
860 std::vector<std::string> isoNames = {"ivarloose","ivarmedium","ivartight","icaloloose","icalomedium","icalotight"};
861
862 bool nogsf = false;
863 bool lrt = false;
864 bool ion = false;
865 bool etcut = false;
866 bool idperf = false;
867 bool isolated = false;
868
869 std::string isolation="";
870
871 // extra information
872 nogsf = boost::contains(trigger,"nogsf");
873 lrt = boost::contains(trigger,"lrt");
874 ion = boost::contains(trigger,"ion");
875
876 for(auto& iso : isoNames){
877 if(boost::contains(trigger, iso)){
878 isolation=iso; isolated=true; break;
879 }
880 }
881
882 std::vector<std::string> parts;
883 boost::split(parts, trigger, boost::is_any_of("_"));
884
885 if(boost::contains(trigger, "idperf")){
886 ATH_MSG_DEBUG("This is idperf");
887 idperf=true;
888 }
889 else if(boost::contains(trigger, "etcut")){
890 ATH_MSG_DEBUG("This is etcut");
891 etcut=true;
892 }
893 else { // remap online pidname to offline pidname
894 //ATH_MSG_DEBUG("Problem: 3");
895 // ATH_MSG_DEBUG("This is nominal");
896 // if (pidMap.count(parts.at(4)) != 4) {
897 // ATH_MSG_DEBUG("Unknown trigger type: " << parts.at(4) << " (" << trigger << ")");
898 // }
899 // pidname = pidMap.at(parts.at(4));
900 }
901
902
903 ATH_MSG_DEBUG("Problem: 5");
904 ATH_MSG_DEBUG("=================== R3 Chain Parser R3 =======================");
905 ATH_MSG_DEBUG( "trigger : " << trigger );
906 ATH_MSG_DEBUG( "threshold : " << threshold);
907 ATH_MSG_DEBUG( "Pidname : " << pidname );
908 ATH_MSG_DEBUG( "signature : " << signature);
909 ATH_MSG_DEBUG( "etcut : " << (etcut?"Yes":"No"));
910 ATH_MSG_DEBUG( "idperf : " << (idperf?"Yes":"No"));
911 ATH_MSG_DEBUG( "nogsf : " << (nogsf?"Yes":"No"));
912 ATH_MSG_DEBUG( "lrt : " << (lrt?"Yes":"No"));
913 ATH_MSG_DEBUG( "HeavyIon : " << (ion?"Yes":"No"));
914 ATH_MSG_DEBUG( "Isolation : " << isolation);
915 ATH_MSG_DEBUG( "Isolated : " << (isolated?"Yes":"No"));
916 ATH_MSG_DEBUG( "L1Seed : " << l1seed << " (Is Legacy? " << (l1legacy?"Yes":"No") << ")");
917 ATH_MSG_DEBUG("========================================================");
918
919 TrigInfo info{l1legacy,l1seed,trigger,signature,threshold,pidname,idperf,etcut,nogsf,lrt,ion,isolation,isolated};
920 m_trigInfoR3[trigger] = info;
921
922}
923
924
925
926
927
928
929
930
931
932
933
934// For Run-3, all triggers must have the L1 seed in name (last part)
935std::string TrigEgammaMonitorBaseAlgorithm::getL1Item(const std::string& trigger) const{
936 std::vector<std::string> parts;
937 boost::split(parts,trigger,boost::is_any_of("_"));
938 // L1EMXX
939 std::string l1seed = parts.back();
940 return l1seed;
941}
942
943
945 return m_trigdec->ExperimentalAndExpertMethods().isHLTTruncated();
946}
947
948
949
950
952
953// Define the parser
954#include "Gaudi/Parsers/Factory.h"
955
956namespace Gaudi
957{
958 namespace Parsers
959 {
960 // Parse function... nothing special, but it must be done explicitely.
961 StatusCode parse( VecDict_t& result, const std::string& input ) { return parse_( result, input ); }
962 }
963}
964
965// We also need to be able to print an object of our type as a string that both
966// Python and our parser can understand,
967#include "GaudiKernel/ToStream.h"
968namespace std
969{
970 // This is an example valid for any mapping type.
971 ostream& operator<<( ostream& s, const Gaudi::Parsers::VecDict_t& vecDict )
972 {
973 s << '{';
974 for ( const auto& dict : vecDict ) {
975 Gaudi::Utils::toStream( dict, s );
976 }
977 s << '}';
978 return s;
979 }
980}
981
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define GETTER(_name_)
Macros for plotting.
struct _triginfo TrigInfo
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Helper class that provides access to information about individual legs.
bool ApplyElectronPid(const EventContext &ctx, const xAOD::Electron *eg, const std::string &) const
Get offline electron decision.
float getEnergyBE2(const xAOD::Egamma *eg) const
ToolHandleArray< IAsgElectronLikelihoodTool > m_electronLHTool
Offline LH Selectors.
float getEnergyBE3(const xAOD::Egamma *eg) const
float getSigmaD0(const xAOD::Electron *eg) const
std::map< std::string, TrigInfo > m_trigInfo
creates map of trigger name and TrigInfo struct
float getEtCluster37(const xAOD::Egamma *eg) const
TrigEgammaMonitorBaseAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
const ToolHandle< TrigEgammaMatchingToolMT > & match() const
Get the e/g match tool.
Gaudi::Property< std::string > m_defaultProbePidPhoton
default probe pid for photon trigitems that don't have pid in their name
float dR(const float, const float, const float, const float) const
Get delta R.
float getEnergyBE1(const xAOD::Egamma *eg) const
float getDEmaxs1(const xAOD::Egamma *eg) const
float rTRT(const xAOD::Electron *eg) const
ToolHandle< TrigEgammaMatchingToolMT > m_matchTool
const ToolHandle< Trig::TrigDecisionTool > & tdt() const
Get the TDT.
float getE0Eaccordion(const xAOD::Egamma *eg) const
Gaudi::Property< std::string > m_defaultProbePidElectron
default probe pid for electron trigitems that don't have pid in their name
ToolHandleArray< IAsgPhotonIsEMSelector > m_photonIsEMTool
Offline isEM Photon Selectors.
ToolHandle< Trig::TrigDecisionTool > m_trigdec
Trigger decision tool.
float getEt(const xAOD::Electron *eg) const
ToolHandleArray< IAsgElectronIsEMSelector > m_electronIsEMTool
Offline isEM Selectors.
asg::AcceptData setAccept(const TrigCompositeUtils::Decision *, const TrigInfo &, const bool) const
Set the accept object for all trigger levels.
bool isPrescaled(const std::string &) const
Check if the event is prescaled.
std::map< std::string, TrigInfo > m_trigInfoR3
virtual StatusCode initialize() override
initialize
TrigInfo getTrigInfo(const std::string &) const
Get the trigger info parsed from the chain name (only single lepton triggers).
bool isIsolated(const xAOD::Electron *, const std::string &) const
Check if electron fulfils isolation criteria.
void setTrigInfo(const std::string &)
Set the trigger info parsed from the chain name.
float getD0sig(const xAOD::Electron *eg) const
float getEta2(const xAOD::Egamma *eg) const
Features helper.
bool ApplyPhotonPid(const EventContext &ctx, const xAOD::Photon *eg, const std::string &) const
Get offline electron decision.
float getEaccordion(const xAOD::Egamma *eg) const
std::string getL1Item(const std::string &trigger) const
Creates static map to return L1 item from trigger name.
ToolHandle< Trig::TrigEgammaEmulationToolMT > m_emulatorTool
TrigInfo getTrigInfoR3(const std::string &) const
float getEnergyBE0(const xAOD::Egamma *eg) const
std::vector< ChainNameParser::LegInfo > getProbeTriggerLeg(const std::string &triggerName) const
ToolHandleArray< IAsgElectronLikelihoodTool > m_electronDNNTool
Offline DNN Selectors.
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer).
Definition AcceptData.h:135
virtual double e() const
The total energy of the particle.
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition Egamma_v1.cxx:66
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
bool isolationValue(float &value, const Iso::IsolationType information) const
old Accessor for Isolation values.
Definition Egamma_v1.h:251
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
bool trackParticleSummaryValue(uint8_t &value, const SummaryType information, int index=0) const
Accessor to the matching track(s) float information (index = 0 is the best match) If 'information' is...
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
std::vector< Dict_t > VecDict_t
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
std::ostream & toStream(const SG::VarHandleKeyArray &v, std::ostream &o)
Gaudi function used to convert a property to a string.
=============================================================================
static const unsigned int includeFailedDecisions
Run3 synonym of alsoDeactivateTEs.
STL namespace.
ostream & operator<<(ostream &s, const SG::VarHandleKey &m)
@ emaxs1
energy of strip with maximal energy deposit
@ e2tsts1
energy of the cell corresponding to second energy maximum in the first sampling
@ ptcone20
Track isolation.
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".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrigEMClusterContainer_v1 TrigEMClusterContainer
Define the latest version of the trigger EM cluster container.
TrigPhotonContainer_v1 TrigPhotonContainer
Declare the latest version of the container.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
Photon_v1 Photon
Definition of the current "egamma version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
@ numberOfTRTHits
number of TRT hits [unit8_t].
@ numberOfTRTHighThresholdHits
number of TRT hits which pass the high threshold (only xenon counted) [unit8_t].
Electron_v1 Electron
Definition of the current "egamma version".
Struct containing information on each leg of a chain.
Extra patterns decribing particle interation process.