ATLAS Offline Software
Loading...
Searching...
No Matches
TrigBjetMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
12
13
14TrigBjetMonitorAlgorithm::TrigBjetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
15 : AthMonitorAlgorithm(name,pSvcLocator)
16{}
17
19
20
33
34bool LLR(double pu, double pc, double pb, double &w) {
35 w = -100.;
36 bool ll = false;
37 float cfrac(0.018); // DG 2022/07/28
38 if (pb > 0.) {
39 double denom = pu*(1.-cfrac)+pc*cfrac;
40 if (denom > 0.) {
41 w = log(pb/denom);
42 ll = true;
43 }
44 }
45 return ll;
46}
47
48bool LLRW(float pqcd, float ptop, float phbb, float &w) { // RJ 17/02/2025
49 w = -100.;
50 bool ll = false;
51 float topfrac(0.25);
52 if (phbb > 0.) {
53 double denom = pqcd*(1.-topfrac)+ptop*topfrac;
54 if (denom > 0.) {
55 w = log(phbb/denom);
56 ll = true;
57 }
58 }
59 return ll;
60}
61
62
63bool CalcRelPt (float muonPt, float muonEta, float muonPhi, float jetPt, float jetEta, float jetPhi, float &RelPt) {
64
65 bool r = false;
66 RelPt = -20.;
67
68 float muonT, muonX, muonY, muonZ, muon, jetT, jetX, jetY, jetZ, jet, scprod;
69
70 muonT = 2.*atan( exp(-muonEta) );
71 jetT = 2.*atan( exp(-jetEta) );
72 if ( (std::abs(muonT) > 0.) && (std::abs(jetT) > 0.) ) {
73 muon = muonPt/std::abs( sin(muonT) );
74 muonX = muonPt*cos(muonPhi);
75 muonY = muonPt*sin(muonPhi);
76 muonZ = muon*cos(muonT);
77 jet = jetPt/std::abs( sin(jetT) );
78 jetX = jetPt*cos(jetPhi);
79 jetY = jetPt*sin(jetPhi);
80 jetZ = jet*cos(jetT);
81 scprod = (muonX*jetX + muonY*jetY + muonZ*jetZ)/(muon*jet);
82 scprod *= scprod;
83 if ( (1. - scprod) > 0. ) {
84 RelPt = muon * sqrt(1. - scprod);
85 r = true;
86 }
87 }
88
89 return r;
90
91}
92
93float phiCorr(float phi) {
94 if (phi < -M_PI) phi += 2*M_PI;
95 if (phi > M_PI) phi -= 2*M_PI;
96 return phi;
97}
98
99
100StatusCode TrigBjetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
101 using namespace Monitored;
102
103 if(m_trigDecTool->ExperimentalAndExpertMethods().isHLTTruncated()) {
104 ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis");
105 return StatusCode::SUCCESS;
106 } // ATR-31454
107
108
109 // Read off-line PV's and fill histograms
110
111 bool Eofflinepv(false);
112 float offlinepvz(-1.e6);
113 float offlinepvx(-1.e6);
114 float offlinepvy(-1.e6);
115
116 if (m_collisionRun) {
117 auto OffNVtx = Monitored::Scalar<int>("Off_NVtx",0);
118 auto OffxVtx = Monitored::Scalar<float>("Off_xVtx",0.0);
119 auto OffyVtx = Monitored::Scalar<float>("Off_yVtx",0.0);
120 auto OffzVtx = Monitored::Scalar<float>("Off_zVtx",0.0);
121
123 if (! offlinepv.isValid() ) {
124 ATH_MSG_ERROR("evtStore() does not contain VertexContainer Collection with name "<< m_offlineVertexContainerKey);
125 return StatusCode::FAILURE;
126 }
127 ATH_MSG_DEBUG(" Size of the Off-line PV container: " << offlinepv->size() );
128 if ( offlinepv->size() ) {
129 Eofflinepv = true;
130 offlinepvz = offlinepv->front()->z();
131 offlinepvx = offlinepv->front()->x();
132 offlinepvy = offlinepv->front()->y();
133 OffNVtx = offlinepv->size() ;
134 for (unsigned int j = 0; j<offlinepv->size(); j++) {
135 if ( (*(offlinepv))[j]->nTrackParticles()==0 ) continue; // MS 9/7/2025
136 if ( (*(offlinepv))[j]->vertexType()==0 ) continue; // MS 9/7/2025
137 OffxVtx = (*(offlinepv))[j]->x();
138 OffyVtx = (*(offlinepv))[j]->y();
139 OffzVtx = (*(offlinepv))[j]->z();
140 fill("TrigBjetMonitor",OffxVtx,OffyVtx,OffzVtx);
141 }
142 fill("TrigBjetMonitor",OffNVtx);
143 } // if size
144 } // if m_collisionRun
145
146 // print the trigger chain names
147
148 std::string chainName;
149
150 int size_AllChains = m_allChains.size();
151 ATH_MSG_DEBUG(" Size of the AllChains trigger container: " << size_AllChains );
152 for (int i =0; i<size_AllChains; i++) {
153 chainName = m_allChains[i];
154 ATH_MSG_DEBUG(" Chain number: " << i << " AllChains Chain Name: " << chainName );
155 }
156
157 // Verifiy if the trigger chain was fired and if yes, fill the corresponding histogram
158
159 bool mujetChain(false);
160 bool bjetChain(true);
161 bool L2bjetChain(false);
162
163
164 for ( auto& trigName : m_allChains ) {
165
166
167 if ( m_trigDecTool->isPassed(trigName) ) {
168 ATH_MSG_DEBUG(" Trigger chain from AllChains list: " << trigName << " has fired !!! " );
169
170 // Verify if the chain was in the Express Stream if the job was an express job
171
172 const unsigned int passBits = m_trigDecTool->isPassedBits(trigName);
173 const bool expressPass = passBits & TrigDefs::Express_passed;
174
175 ATH_MSG_DEBUG( " Express Stream Test: Chain: " << trigName<< " m_expressStreamFlag: " << m_expressStreamFlag << " expressPass: " << expressPass );
176
177 if ( !m_expressStreamFlag || (m_expressStreamFlag && expressPass) ) {
178
179
180 // bjet vs mujet vs L2bjetChain
181 mujetChain = false;
182 L2bjetChain = false;
183 bjetChain = false;
184 std::size_t found = trigName.find("HLT_mu");
185 if (found!=std::string::npos) mujetChain = true;
186 else {
187 found = trigName.find("a10sd_cssk");
188 if (found!=std::string::npos) L2bjetChain = true;
189 else bjetChain = true;
190 }
191
192 ATH_MSG_DEBUG(" ===> Run 3 access to Trigger Item: " << trigName );
193 ATH_MSG_DEBUG(" bjetChain: " << bjetChain << " mujetChain: " << mujetChain << " L2bjetChain: " << L2bjetChain );
194
195
196 // online track container
198 // verify the content
199 for ( const xAOD::TrackParticle* track : *theTracks ) {
200 ATH_MSG_DEBUG( " Pt of track in TrackParticleContainer: " << track->pt() );
201 }
202
203 float zPrmVtx = 0.; // used for muon-jets
204
205 // Online Primary Vertex from SG
206
207 if (m_collisionRun) {
209 int nPV = 0;
210 for (const xAOD::Vertex* vtx : *vtxContainer) {
211 if (vtx->vertexType() == xAOD::VxType::PriVtx) {
212 nPV++;
213 std::string NameH = "PVz_tr_"+trigName;
214 ATH_MSG_DEBUG( " NameH: " << NameH );
215 auto PVz_tr = Monitored::Scalar<float>(NameH,0.0);
216 PVz_tr = vtx->z();
217 zPrmVtx = PVz_tr;
218 ATH_MSG_DEBUG(" PVz_tr: " << PVz_tr);
219 fill("TrigBjetMonitor",PVz_tr);
220 if (Eofflinepv) {
221 NameH = "DiffOnOffPVz_tr_"+trigName;
222 ATH_MSG_DEBUG( " NameH: " << NameH );
223 auto DiffOnOffPVz_tr = Monitored::Scalar<float>(NameH,0.0);
224 DiffOnOffPVz_tr = vtx->z()-offlinepvz;
225 ATH_MSG_DEBUG(" DiffOnOffPVz_tr: " << DiffOnOffPVz_tr);
226 fill("TrigBjetMonitor",DiffOnOffPVz_tr);
227 } // if Eofflinepv
228 NameH = "PVx_tr_"+trigName;
229 ATH_MSG_DEBUG( " NameH: " << NameH );
230 auto PVx_tr = Monitored::Scalar<float>(NameH,0.0);
231 PVx_tr = vtx->x();
232 ATH_MSG_DEBUG(" PVx_tr: " << PVx_tr);
233 fill("TrigBjetMonitor",PVx_tr);
234 if (Eofflinepv) {
235 NameH = "DiffOnOffPVx_tr_"+trigName;
236 ATH_MSG_DEBUG( " NameH: " << NameH );
237 auto DiffOnOffPVx_tr = Monitored::Scalar<float>(NameH,0.0);
238 DiffOnOffPVx_tr = vtx->x()-offlinepvx;
239 ATH_MSG_DEBUG(" DiffOnOffPVx_tr: " << DiffOnOffPVx_tr);
240 fill("TrigBjetMonitor",DiffOnOffPVx_tr);
241 } // if Eofflinepv
242 NameH = "PVy_tr_"+trigName;
243 ATH_MSG_DEBUG( " NameH: " << NameH );
244 auto PVy_tr = Monitored::Scalar<float>(NameH,0.0);
245 PVy_tr = vtx->y();
246 ATH_MSG_DEBUG(" PVy_tr: " << PVy_tr);
247 fill("TrigBjetMonitor",PVy_tr);
248 if (Eofflinepv) {
249 NameH = "DiffOnOffPVy_tr_"+trigName;
250 ATH_MSG_DEBUG( " NameH: " << NameH );
251 auto DiffOnOffPVy_tr = Monitored::Scalar<float>(NameH,0.0);
252 DiffOnOffPVy_tr = vtx->y()-offlinepvy;
253 ATH_MSG_DEBUG(" DiffOnOffPVy_tr: " << DiffOnOffPVy_tr);
254 fill("TrigBjetMonitor",DiffOnOffPVy_tr);
255 } // if Eofflinepv
256 } // if vtx type
257 } // loop on vtxContainer
258 std::string NpvH = "nPV_tr_"+trigName;
259 ATH_MSG_DEBUG( " NpvH: " << NpvH );
260 auto nPV_tr = Monitored::Scalar<int>(NpvH,0.0);
261 nPV_tr = nPV;
262 fill("TrigBjetMonitor",nPV_tr);
263 } // if m_collisionRun
264
265 // L2bjetChain
266
267
268 if (L2bjetChain) {
269 std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDecTool->features<xAOD::JetContainer>(trigName, TrigDefs::Physics);
270
271 std::string nJetH = "LargeR_nJet_"+trigName;
272 auto nJet = Monitored::Scalar<int>(nJetH,0.0);
273 nJet = onlinejets.size();
274 ATH_MSG_DEBUG(" nJet: " << nJet);
275 fill("TrigBjetMonitor",nJet);
276 for(const auto& jetLinkInfo : onlinejets) {
277 const xAOD::Jet* jet = *(jetLinkInfo.link);
278
279 // GN2XTrig
280 static const SG::AuxElement::ConstAccessor<float> pqcd_accessor("GN2XTrig_pqcd");
281 static const SG::AuxElement::ConstAccessor<float> ptop_accessor("GN2XTrig_ptop");
282 static const SG::AuxElement::ConstAccessor<float> phbb_accessor("GN2XTrig_phbb");
283 bool isGN2XTrigAvailable = pqcd_accessor.isAvailable(*jet);
284
285 std::string NameH = "GN2XTrig_pqcd_tr_"+trigName;
286 ATH_MSG_DEBUG( " NameH: " << NameH );
287 auto GN2XTrig_pqcd = Monitored::Scalar<float>(NameH,0.0);
288 GN2XTrig_pqcd = isGN2XTrigAvailable ? pqcd_accessor(*jet) : -1.;
289 fill("TrigBjetMonitor",GN2XTrig_pqcd);
290
291 NameH = "GN2XTrig_ptop_tr_"+trigName;
292 ATH_MSG_DEBUG( " NameH: " << NameH );
293 auto GN2XTrig_ptop = Monitored::Scalar<float>(NameH,0.0);
294 GN2XTrig_ptop = isGN2XTrigAvailable ? ptop_accessor(*jet) : -1.;
295 fill("TrigBjetMonitor",GN2XTrig_ptop);
296
297 NameH = "GN2XTrig_phbb_tr_"+trigName;
298 ATH_MSG_DEBUG( " NameH: " << NameH );
299 auto GN2XTrig_phbb = Monitored::Scalar<float>(NameH,0.0);
300 GN2XTrig_phbb = isGN2XTrigAvailable ? phbb_accessor(*jet) : -1.;
301 fill("TrigBjetMonitor",GN2XTrig_phbb);
302
303 NameH = "GN2XTrig_mv_tr_"+trigName;
304 ATH_MSG_DEBUG( " NameH: " << NameH );
305 auto GN2XTrig_mv = Monitored::Scalar<float>(NameH,0.0);
306 ATH_MSG_DEBUG(" GN2XTrig_pqcd: " << GN2XTrig_pqcd << " GN2XTrig_ptop: " << GN2XTrig_ptop << " GN2XTrig_phbb: " << GN2XTrig_phbb );
307 bool theLLRW = LLRW (GN2XTrig_pqcd, GN2XTrig_ptop, GN2XTrig_phbb, GN2XTrig_mv);
308 ATH_MSG_DEBUG(" GN2XTrig_mv: " << GN2XTrig_mv << " LLRW: " << theLLRW);
309 if ( theLLRW ) fill("TrigBjetMonitor",GN2XTrig_mv);
310
311 // jetPt
312 NameH = "LargeR_jetPt_"+trigName;
313 ATH_MSG_DEBUG( " NameH: " << NameH );
314 auto LargeR_jetPt = Monitored::Scalar<float>(NameH,0.0);
315 LargeR_jetPt = (jet->pt())*1.e-3;
316 ATH_MSG_DEBUG(" LargeR_jetPt: " << LargeR_jetPt);
317 fill("TrigBjetMonitor",LargeR_jetPt);
318
319 // jetEta
320 NameH = "LargeR_jetEta_"+trigName;
321 ATH_MSG_DEBUG( " NameH: " << NameH );
322 auto LargeR_jetEta = Monitored::Scalar<float>(NameH,0.0);
323 LargeR_jetEta = jet->eta();
324
325 // jetPhi
326 NameH = "LargeR_jetPhi_"+trigName;
327 ATH_MSG_DEBUG( " NameH: " << NameH );
328 auto LargeR_jetPhi = Monitored::Scalar<float>(NameH,0.0);
329 LargeR_jetPhi = jet->phi();
330 ATH_MSG_DEBUG(" LargeR_jetEta: " << LargeR_jetEta << " LargeR_jetPhi : " << LargeR_jetPhi);
331 fill("TrigBjetMonitor",LargeR_jetEta,LargeR_jetPhi);
332
333 // jetMass
334 NameH = "LargeR_jetMass_"+trigName;
335 ATH_MSG_DEBUG( " NameH: " << NameH );
336 auto LargeR_jetMass = Monitored::Scalar<float>(NameH,0.0);
337 LargeR_jetMass = (jet->m())*1.e-3;
338 ATH_MSG_DEBUG(" LargeR_jetMass: " << LargeR_jetMass);
339 fill("TrigBjetMonitor",LargeR_jetMass);
340
341 // GN2Xv01
342 static const SG::AuxElement::ConstAccessor<float> pqcd_accessor0("GN2Xv01_pqcd");
343 static const SG::AuxElement::ConstAccessor<float> ptop_accessor0("GN2Xv01_ptop");
344 static const SG::AuxElement::ConstAccessor<float> phbb_accessor0("GN2Xv01_phbb");
345 bool isGN2Xv01Available = pqcd_accessor0.isAvailable(*jet);
346
347 NameH = "GN2Xv01_pqcd_tr_"+trigName;
348 ATH_MSG_DEBUG( " NameH: " << NameH );
349 auto GN2Xv01_pqcd = Monitored::Scalar<float>(NameH,0.0);
350 GN2Xv01_pqcd = isGN2Xv01Available ? pqcd_accessor0(*jet) : -1.;
351 fill("TrigBjetMonitor",GN2Xv01_pqcd);
352
353 NameH = "GN2Xv01_ptop_tr_"+trigName;
354 ATH_MSG_DEBUG( " NameH: " << NameH );
355 auto GN2Xv01_ptop = Monitored::Scalar<float>(NameH,0.0);
356 GN2Xv01_ptop = isGN2Xv01Available ? ptop_accessor0(*jet) : -1.;
357 fill("TrigBjetMonitor",GN2Xv01_ptop);
358
359 NameH = "GN2Xv01_phbb_tr_"+trigName;
360 ATH_MSG_DEBUG( " NameH: " << NameH );
361 auto GN2Xv01_phbb = Monitored::Scalar<float>(NameH,0.0);
362 GN2Xv01_phbb = isGN2Xv01Available ? phbb_accessor0(*jet) : -1.;
363 fill("TrigBjetMonitor",GN2Xv01_phbb);
364
365 NameH = "GN2Xv01_mv_tr_"+trigName;
366 ATH_MSG_DEBUG( " NameH: " << NameH );
367 auto GN2Xv01_mv = Monitored::Scalar<float>(NameH,0.0);
368 ATH_MSG_DEBUG(" GN2Xv01_pqcd: " << GN2Xv01_pqcd << " GN2Xv01_ptop: " << GN2Xv01_ptop << " GN2Xv01_phbb: " << GN2Xv01_phbb );
369 theLLRW = LLRW (GN2Xv01_pqcd, GN2Xv01_ptop, GN2Xv01_phbb, GN2Xv01_mv);
370 ATH_MSG_DEBUG(" GN2Xv01_mv: " << GN2Xv01_mv << " LLRW: " << theLLRW);
371 if ( theLLRW ) fill("TrigBjetMonitor",GN2Xv01_mv);
372
373 } // for jetLinkInfo
374
375 } // if (L2bjetChain)
376
377
378 if (mujetChain) {
379 std::vector< TrigCompositeUtils::LinkInfo<xAOD::MuonContainer> > onlinemuons = m_trigDecTool->features<xAOD::MuonContainer>(trigName, TrigDefs::Physics); // TM 2022-05-16
380 int imuon = 0;
381 std::string nMuonH = "nMuon_"+trigName;
382 auto nMuon = Monitored::Scalar<int>(nMuonH,0.0);
383 nMuon = onlinemuons.size();
384 fill("TrigBjetMonitor",nMuon);
385
386 std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDecTool->features<xAOD::JetContainer>(trigName, TrigDefs::Physics); // TM 2021-10-30
387 int ijet = 0;
388 std::string nJetH = "nJet_"+trigName;
389 auto nJet = Monitored::Scalar<int>(nJetH,0.0);
390 nJet = onlinejets.size();
391 fill("TrigBjetMonitor",nJet);
392
393 if (nMuon*nJet > 0) {
394
395 float muonPt1(0.), muonEta1(0.), muonPhi1(0.), muonZ1(0.), jetPt1(0.), jetEta1(0.), jetPhi1(0.), jetZ1(0.), muonZ(0.);
396 double GN1_mv(0.), GN2_mv(0.);
397 bool theLLR_GN1(false), theLLR_GN2(false);
398 bool plotDeltaZ(false);
399
400 for(const auto& muonLinkInfo : onlinemuons) {
401 const xAOD::Muon* muon = *(muonLinkInfo.link);
402 // muonPt
403 std::string NameH = "muonPt_"+trigName;
404 ATH_MSG_DEBUG( " NameH: " << NameH );
405 auto muonPt = Monitored::Scalar<float>(NameH,0.0);
406 muonPt = (muon->pt())*1.e-3;
407 ATH_MSG_DEBUG(" muonPt: " << muonPt);
408 fill("TrigBjetMonitor",muonPt);
409 // muonEta
410 NameH = "muonEta_"+trigName;
411 ATH_MSG_DEBUG( " NameH: " << NameH );
412 auto muonEta = Monitored::Scalar<float>(NameH,0.0);
413 muonEta = muon->eta();
414 ATH_MSG_DEBUG(" muonEta: " << muonEta);
415 fill("TrigBjetMonitor",muonEta);
416 // muonPhi
417 NameH = "muonPhi_"+trigName;
418 ATH_MSG_DEBUG( " NameH: " << NameH );
419 auto muonPhi = Monitored::Scalar<float>(NameH,0.0);
420 muonPhi = muon->phi();
421 ATH_MSG_DEBUG(" muonPhi : " << muonPhi);
422 // muonZ
423 auto link = muon->combinedTrackParticleLink(); // TM and DG 18/06/22
424 if (link.isValid()) {
425 plotDeltaZ = true;
426 const xAOD::TrackParticle* track = *link;
427 muonZ = track->z0() + track->vz();
428 } else {
429 plotDeltaZ = false;
430 muonZ = 0.;
431 }
432
433 if (imuon == 0) {
434 //store the parameter for the 1st muon
435 muonPt1 = muonPt;
436 muonEta1 = muonEta;
437 muonPhi1 = muonPhi;
438 muonZ1 = muonZ;
439 }// if imuon==0
440
441 // The associated jet loop
442 for(const auto& jetLinkInfo : onlinejets) {
443 const xAOD::Jet* jet = *(jetLinkInfo.link);
444 // jetPt
445 NameH = "jetPt_"+trigName;
446 ATH_MSG_DEBUG( " NameH: " << NameH );
447 auto jetPt = Monitored::Scalar<float>(NameH,0.0);
448 jetPt = (jet->pt())*1.e-3;
449 ATH_MSG_DEBUG(" jetPt: " << jetPt);
450 fill("TrigBjetMonitor",jetPt);
451 // jetEta
452 NameH = "jetEta_"+trigName;
453 ATH_MSG_DEBUG( " NameH: " << NameH );
454 auto jetEta = Monitored::Scalar<float>(NameH,0.0);
455 jetEta = jet->eta();
456 ATH_MSG_DEBUG(" jetEta : " << jetEta);
457 fill("TrigBjetMonitor",jetEta);
458 // jetPhi
459 NameH = "jetPhi_"+trigName;
460 ATH_MSG_DEBUG( " NameH: " << NameH );
461 auto jetPhi = Monitored::Scalar<float>(NameH,0.0);
462 jetPhi = jet->phi();
463 ATH_MSG_DEBUG(" jetPhi : " << jetPhi);
464
465 // Take the b-tagging info from the first jet
466 if (ijet == 0) {
467 //store the parameter for the 1st jet
468 jetPt1 = jetPt;
469 jetEta1 = jetEta;
470 jetPhi1 = jetPhi;
471 jetZ1 = zPrmVtx;
472
473 auto btaggingLinkInfo = TrigCompositeUtils::findLink<xAOD::BTaggingContainer>(jetLinkInfo.source, m_btaggingLinkName); // TM 2021-10-30
474 const SG::AuxElement* obj_storing_btag = nullptr;
475 if ( btaggingLinkInfo.isValid() ) {
476 obj_storing_btag = *(btaggingLinkInfo.link);
477 }
478 else {
479 obj_storing_btag = *(jetLinkInfo.link);
480 }
481
482 static const SG::AuxElement::ConstAccessor<float> GN1pu_accessor("GN120220813_pu");
483 static const SG::AuxElement::ConstAccessor<float> GN1pc_accessor("GN120220813_pc");
484 static const SG::AuxElement::ConstAccessor<float> GN1pb_accessor("GN120220813_pb");
485
486 static const SG::AuxElement::ConstAccessor<float> GN2pu_accessor("GN220240122_pu");
487 static const SG::AuxElement::ConstAccessor<float> GN2pc_accessor("GN220240122_pc");
488 static const SG::AuxElement::ConstAccessor<float> GN2pb_accessor("GN220240122_pb");
489
490 // checking just pu is enough
491 if (GN1pu_accessor.isAvailable(*obj_storing_btag)) {
492 double GN1_pu(-1.), GN1_pc(-1.), GN1_pb(-1.);
493 GN1_pu = GN1pu_accessor(*obj_storing_btag);
494 ATH_MSG_DEBUG(" GN1_pu: " << GN1_pu);
495 GN1_pc = GN1pc_accessor(*obj_storing_btag);
496 ATH_MSG_DEBUG(" GN1_pc: " << GN1_pc);
497 GN1_pb = GN1pb_accessor(*obj_storing_btag);
498 ATH_MSG_DEBUG(" GN1_pb: " << GN1_pb);
499 theLLR_GN1 = LLR (GN1_pu, GN1_pc, GN1_pb, GN1_mv);
500 ATH_MSG_DEBUG(" GN1_mv: " << GN1_mv << " LLR: " << theLLR_GN1);
501 }
502 if (GN2pu_accessor.isAvailable(*obj_storing_btag)) {
503 double GN2_pu(-1.), GN2_pc(-1.), GN2_pb(-1.);
504 GN2_pu = GN2pu_accessor(*obj_storing_btag);
505 ATH_MSG_DEBUG(" GN2_pu: " << GN2_pu);
506 GN2_pc = GN2pc_accessor(*obj_storing_btag);
507 ATH_MSG_DEBUG(" GN2_pc: " << GN2_pc);
508 GN2_pb = GN2pb_accessor(*obj_storing_btag);
509 ATH_MSG_DEBUG(" GN2_pb: " << GN2_pb);
510 theLLR_GN2 = LLR (GN2_pu, GN2_pc, GN2_pb, GN2_mv);
511 ATH_MSG_DEBUG(" GN2_mv: " << GN2_mv << " LLR: " << theLLR_GN2);
512 }
513 }// if ijet==0
514
515 ijet++;
516
517 }// for onlinejets
518
519 imuon++;
520
521 }// for onlinemuons
522
523 // muon vs jet histograms
524
525 // Delta R(muon,jet)
526 std::string DeltaRH = "DeltaR_"+trigName;
527 ATH_MSG_DEBUG( " DeltaRH: " << DeltaRH );
528 auto DeltaR = Monitored::Scalar<float>(DeltaRH,0.0);
529 float DeltaEta = muonEta1 - jetEta1;
530 float DeltaPhi = phiCorr( phiCorr(muonPhi1) - phiCorr(jetPhi1) );
531 DeltaR = sqrt( DeltaEta*DeltaEta + DeltaPhi*DeltaPhi );
532 ATH_MSG_DEBUG(" Delta R : " << DeltaR);
533 fill("TrigBjetMonitor",DeltaR);
534
535 // Delta Z(muon,jet)
536 std::string DeltaZH = "DeltaZ_"+trigName;
537 ATH_MSG_DEBUG( " DeltaZH: " << DeltaZH );
538 auto DeltaZ = Monitored::Scalar<float>(DeltaZH,0.0);
539 DeltaZ = std::abs(muonZ1-jetZ1);
540 ATH_MSG_DEBUG(" Delta Z : " << DeltaZ);
541 if (plotDeltaZ) fill("TrigBjetMonitor",DeltaZ);
542
543 // muonPt/jetPt
544 std::string RatioPtH = "RatioPt_"+trigName;
545 ATH_MSG_DEBUG( " RatioPtH: " << RatioPtH );
546 auto RatioPt = Monitored::Scalar<float>(RatioPtH,0.0);
547 RatioPt = -100.;
548 if (jetPt1 > 0.) RatioPt = muonPt1/jetPt1;
549 ATH_MSG_DEBUG(" RatioPt : " << RatioPt);
550 if (RatioPt > 0.) fill("TrigBjetMonitor",RatioPt);
551
552 // muonPt relative to jet direction
553 std::string RelPtH = "RelPt_"+trigName;
554 ATH_MSG_DEBUG( " RelPtH: " << RelPtH );
555 auto RelPt = Monitored::Scalar<float>(RelPtH,0.0);
556 RelPt = 1.e10;
557 bool calc_relpt = CalcRelPt (muonPt1, muonEta1, muonPhi1, jetPt1, jetEta1, jetPhi1, RelPt);
558 ATH_MSG_DEBUG(" RelPt : " << RelPt);
559
560 // wGN1
561 std::string wGN1H = "wGN1_"+trigName;
562 ATH_MSG_DEBUG( " NameH: " << wGN1H );
563 auto wGN1 = Monitored::Scalar<float>(wGN1H,0.0);
564 wGN1 = float(GN1_mv);
565 ATH_MSG_DEBUG(" wGN1: " << wGN1 << " RelPt : " << RelPt);
566 if (calc_relpt && theLLR_GN1) fill("TrigBjetMonitor",wGN1,RelPt);
567
568 // wGN2
569 std::string wGN2H = "wGN2_"+trigName;
570 ATH_MSG_DEBUG( " NameH: " << wGN2H );
571 auto wGN2 = Monitored::Scalar<float>(wGN2H,0.0);
572 wGN2 = float(GN2_mv);
573 ATH_MSG_DEBUG(" wGN2: " << wGN2 << " RelPt : " << RelPt);
574 if (calc_relpt && theLLR_GN2) fill("TrigBjetMonitor",wGN2,RelPt);
575
576 } // if (nMuon*nJet > 0)
577
578 }// if mujetChain
579
580 // bjet chains
581 if (bjetChain) {
582
583 // Jets and PV and tracks through jet link
584
585 std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDecTool->features<xAOD::JetContainer>(trigName, TrigDefs::Physics); // TM 2021-10-30
586
587 int ijet = 0;
588 int itrack = 0;
589 std::string nJetH = "nJet_"+trigName;
590 auto nJet = Monitored::Scalar<int>(nJetH,0.0);
591 nJet = onlinejets.size();
592 fill("TrigBjetMonitor",nJet);
593
594 if (nJet > 0) {
595
596 for(const auto& jetLinkInfo : onlinejets) {
597 const xAOD::Jet* jet = *(jetLinkInfo.link);
598 // jetPt
599 std::string NameH = "jetPt_"+trigName;
600 ATH_MSG_DEBUG( " NameH: " << NameH );
601 auto jetPt = Monitored::Scalar<float>(NameH,0.0);
602 jetPt = (jet->pt())*1.e-3;
603 ATH_MSG_DEBUG(" jetPt: " << jetPt);
604 fill("TrigBjetMonitor",jetPt);
605 // jetEta
606 NameH = "jetEta_"+trigName;
607 ATH_MSG_DEBUG( " NameH: " << NameH );
608 auto jetEta = Monitored::Scalar<float>(NameH,0.0);
609 jetEta = jet->eta();
610 // jetPhi
611 NameH = "jetPhi_"+trigName;
612 ATH_MSG_DEBUG( " NameH: " << NameH );
613 auto jetPhi = Monitored::Scalar<float>(NameH,0.0);
614 jetPhi = jet->phi();
615 ATH_MSG_DEBUG(" jetEta: " << jetEta << " jetPhi : " << jetPhi);
616 fill("TrigBjetMonitor",jetEta,jetPhi);
617
618 // zPV associated to the jets in the same event: they are the same for every jet in the same event so only the first zPV should be plotted
619 if (ijet == 0) {
620
621 // Fetch and plot PV
622
623 std::string vtxname = m_onlineVertexContainerKey.key();
624 if ( vtxname.compare(0, 4, "HLT_")==0 ) vtxname.erase(0,4);
625 auto vertexLinkInfo = TrigCompositeUtils::findLink<xAOD::VertexContainer>(jetLinkInfo.source, vtxname ); // CV 200120 & MS 290620
626 ATH_CHECK( vertexLinkInfo.isValid() ) ; // TM 200120
627 const xAOD::Vertex* vtx = *(vertexLinkInfo.link);
628 NameH = "PVz_jet_"+trigName;
629 ATH_MSG_DEBUG( " NameH: " << NameH );
630 auto PVz_jet = Monitored::Scalar<float>(NameH,0.0);
631 PVz_jet = vtx->z();
632 ATH_MSG_DEBUG(" PVz_jet: " << PVz_jet);
633 fill("TrigBjetMonitor",PVz_jet);
634 NameH = "PVx_jet_"+trigName;
635 ATH_MSG_DEBUG( " NameH: " << NameH );
636 auto PVx_jet = Monitored::Scalar<float>(NameH,0.0);
637 PVx_jet = vtx->x();
638 ATH_MSG_DEBUG(" PVx_jet: " << PVx_jet);
639 fill("TrigBjetMonitor",PVx_jet);
640 NameH = "PVy_jet_"+trigName;
641 ATH_MSG_DEBUG( " NameH: " << NameH );
642 auto PVy_jet = Monitored::Scalar<float>(NameH,0.0);
643 PVy_jet = vtx->y();
644 ATH_MSG_DEBUG(" PVy_jet: " << PVy_jet);
645 fill("TrigBjetMonitor",PVy_jet);
646
647
648 } // if (ijet == 0)
649
650 ijet++;
651
652 // Fetch and plot BTagging information
653 const SG::AuxElement* obj_storing_btag = nullptr;
654 auto btaggingLinkInfo = TrigCompositeUtils::findLink<xAOD::BTaggingContainer>(jetLinkInfo.source, m_btaggingLinkName); // TM 2021-10-30
655 if ( btaggingLinkInfo.isValid() ) {
656 obj_storing_btag = *(btaggingLinkInfo.link);
657 }
658 else {
659 obj_storing_btag = *(jetLinkInfo.link);
660 }
661
662 bool theLLR(false);
663 static const SG::AuxElement::ConstAccessor<float> GN1pu_accessor("GN120220813_pu");
664 static const SG::AuxElement::ConstAccessor<float> GN1pc_accessor("GN120220813_pc");
665 static const SG::AuxElement::ConstAccessor<float> GN1pb_accessor("GN120220813_pb");
666 static const SG::AuxElement::ConstAccessor<float> GN2pu_accessor("GN220240122_pu");
667 static const SG::AuxElement::ConstAccessor<float> GN2pc_accessor("GN220240122_pc");
668 static const SG::AuxElement::ConstAccessor<float> GN2pb_accessor("GN220240122_pb");
669 // checking only pu should be sufficient
670 bool GN1_available = GN1pu_accessor.isAvailable(*obj_storing_btag);
671 bool GN2_available = GN2pu_accessor.isAvailable(*obj_storing_btag);
672 NameH = "GN1_pu_tr_"+trigName;
673 ATH_MSG_DEBUG( " NameH: " << NameH );
674 auto GN1_pu = Monitored::Scalar<double>(NameH,0.0);
675 GN1_pu = GN1_available ? GN1pu_accessor(*obj_storing_btag) : -1.0;
676 ATH_MSG_DEBUG(" GN1_pu: " << GN1_pu);
677 fill("TrigBjetMonitor",GN1_pu);
678
679 NameH = "GN1_pc_tr_"+trigName;
680 ATH_MSG_DEBUG( " NameH: " << NameH );
681 auto GN1_pc = Monitored::Scalar<double>(NameH,0.0);
682 GN1_pc = GN1_available ? GN1pc_accessor(*obj_storing_btag) : -1.0;
683 ATH_MSG_DEBUG(" GN1_pc: " << GN1_pc);
684 fill("TrigBjetMonitor",GN1_pc);
685
686 NameH = "GN1_pb_tr_"+trigName;
687 ATH_MSG_DEBUG( " NameH: " << NameH );
688 auto GN1_pb = Monitored::Scalar<double>(NameH,0.0);
689 GN1_pb = GN1_available ? GN1pb_accessor(*obj_storing_btag) : -1.0;
690 ATH_MSG_DEBUG(" GN1_pb: " << GN1_pb);
691 fill("TrigBjetMonitor",GN1_pb);
692
693 NameH = "GN1_mv_tr_"+trigName;
694 ATH_MSG_DEBUG( " NameH: " << NameH );
695 auto GN1_mv = Monitored::Scalar<double>(NameH,0.0);
696 theLLR = LLR (GN1_pu, GN1_pc, GN1_pb, GN1_mv);
697 if ( theLLR ) fill("TrigBjetMonitor",GN1_mv);
698 ATH_MSG_DEBUG(" GN1_mv: " << GN1_mv << " LLR: " << theLLR);
699
700
701 NameH = "GN2_pu_tr_"+trigName;
702 ATH_MSG_DEBUG( " NameH: " << NameH );
703 auto GN2_pu = Monitored::Scalar<double>(NameH,0.0);
704 GN2_pu = GN2_available ? GN2pu_accessor(*obj_storing_btag) : -1.0;
705 ATH_MSG_DEBUG(" GN2_pu: " << GN2_pu);
706 fill("TrigBjetMonitor",GN2_pu);
707
708 NameH = "GN2_pc_tr_"+trigName;
709 ATH_MSG_DEBUG( " NameH: " << NameH );
710 auto GN2_pc = Monitored::Scalar<double>(NameH,0.0);
711 GN2_pc = GN2_available ? GN2pc_accessor(*obj_storing_btag) : -1.0;
712 ATH_MSG_DEBUG(" GN2_pc: " << GN2_pc);
713 fill("TrigBjetMonitor",GN2_pc);
714
715 NameH = "GN2_pb_tr_"+trigName;
716 ATH_MSG_DEBUG( " NameH: " << NameH );
717 auto GN2_pb = Monitored::Scalar<double>(NameH,0.0);
718 GN2_pb = GN2_available ? GN2pb_accessor(*obj_storing_btag) : -1.0;
719 ATH_MSG_DEBUG(" GN2_pb: " << GN2_pb);
720 fill("TrigBjetMonitor",GN2_pb);
721
722 NameH = "GN2_mv_tr_"+trigName;
723 ATH_MSG_DEBUG( " NameH: " << NameH );
724 auto GN2_mv = Monitored::Scalar<double>(NameH,0.0);
725 theLLR = LLR (GN2_pu, GN2_pc, GN2_pb, GN2_mv);
726 if ( theLLR ) fill("TrigBjetMonitor",GN2_mv);
727 ATH_MSG_DEBUG(" GN2_mv: " << GN2_mv << " LLR: " << theLLR);
728
729
730 // Tracks associated to triggered jets ( featurs = onlinejets ) courtesy of Tim Martin on 12/05/2020
731 const auto track_it_pair = m_trigDecTool->associateToEventView(theTracks, jetLinkInfo.source, "roi");
732 const xAOD::TrackParticleContainer::const_iterator start_it = track_it_pair.first;
733 const xAOD::TrackParticleContainer::const_iterator end_it = track_it_pair.second;
734
735 int count = 0;
736 for ( xAOD::TrackParticleContainer::const_iterator it = start_it; it != end_it; ++it) {
737 count++;
738 ATH_MSG_DEBUG( " Track " << count << " with pT " << (*it)->pt() <<" from BJet with pT " << (*jetLinkInfo.link)->pt() );
739 ATH_MSG_DEBUG( " Track " << count << " with pT/eta/phi " << (*it)->pt() << "/" << (*it)->eta() << "/" << (*it)->phi() );
740 ATH_MSG_DEBUG( " Track " << count << " with d0/sigd0 " << (*it)->d0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 0) );
741 ATH_MSG_DEBUG( " Track " << count << " with z0/sigz0 " << (*it)->z0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 1) );
742 std::string NameH = "trkPt_"+trigName;
743 ATH_MSG_DEBUG( " NameH: " << NameH );
744 auto trkPt = Monitored::Scalar<float>(NameH,0.0);
745 trkPt = ((*it)->pt())*1.e-3;
746 ATH_MSG_DEBUG(" trkPt: " << trkPt);
747 fill("TrigBjetMonitor",trkPt);
748 NameH = "trkEta_"+trigName;
749 ATH_MSG_DEBUG( " NameH: " << NameH );
750 auto trkEta = Monitored::Scalar<float>(NameH,0.0);
751 trkEta = (*it)->eta();
752 NameH = "trkPhi_"+trigName;
753 ATH_MSG_DEBUG( " NameH: " << NameH );
754 auto trkPhi = Monitored::Scalar<float>(NameH,0.0);
755 trkPhi = (*it)->phi();
756 ATH_MSG_DEBUG(" trkEta: " << trkEta << " trkPhi : " << trkPhi);
757 fill("TrigBjetMonitor",trkEta,trkPhi);
758 NameH = "d0_"+trigName;
759 ATH_MSG_DEBUG( " NameH: " << NameH );
760 auto d0 = Monitored::Scalar<float>(NameH,0.0);
761 d0 = (*it)->d0();
762 ATH_MSG_DEBUG(" d0: " << d0);
763 fill("TrigBjetMonitor",d0);
764 NameH = "z0_"+trigName;
765 ATH_MSG_DEBUG( " NameH: " << NameH );
766 auto z0 = Monitored::Scalar<float>(NameH,0.0);
767 z0 = (*it)->z0();
768 ATH_MSG_DEBUG(" z0: " << z0);
769 fill("TrigBjetMonitor",z0);
770 NameH = "ed0_"+trigName;
771 ATH_MSG_DEBUG( " NameH: " << NameH );
772 auto ed0 = Monitored::Scalar<float>(NameH,0.0);
773 ed0 = Amg::error((*it)->definingParametersCovMatrix(), 0);
774 ATH_MSG_DEBUG(" ed0: " << ed0);
775 fill("TrigBjetMonitor",ed0);
776 NameH = "sd0_"+trigName;
777 ATH_MSG_DEBUG( " NameH: " << NameH );
778 auto sd0 = Monitored::Scalar<float>(NameH,0.0);
779 sd0 = -10.;
780 if (ed0 > 0.) sd0 = std::abs(d0)/ed0;
781 ATH_MSG_DEBUG(" sd0: " << sd0);
782 fill("TrigBjetMonitor",sd0);
783 NameH = "ez0_"+trigName;
784 ATH_MSG_DEBUG( " NameH: " << NameH );
785 auto ez0 = Monitored::Scalar<float>(NameH,0.0);
786 ez0 = Amg::error((*it)->definingParametersCovMatrix(), 1);
787 ATH_MSG_DEBUG(" ez0: " << ez0);
788 fill("TrigBjetMonitor",ez0);
789 } // it on tracks
790 ATH_MSG_DEBUG( " Number of tracks: " << count );
791 itrack += count;
792
793 } // jetLinkInfo from onlinejets
794
795 ATH_MSG_DEBUG(" Total number of triggered b-jets: " << ijet << " nJet : " << nJet);
796 ATH_MSG_DEBUG(" Total number of triggered tracks associated to the b-jets: " << itrack);
797 std::string nTrackH = "nTrack_"+trigName;
798 auto nTrack = Monitored::Scalar<int>(nTrackH,0.0);
799 nTrack = itrack;
800 fill("TrigBjetMonitor",nTrack);
801
802 } // if (nJet > 0)
803
804 } //if bjetChain
805
806 } else {
807 ATH_MSG_DEBUG(" Chain " << trigName << " is declared for the Express Stream but it is NOT in the Express Stream in an Express Job");
808 } // if m_expressStreamFlag
809
810 } else {
811 ATH_MSG_DEBUG( " Trigger chain from AllChains list: " << trigName << " has not fired " );
812 } // trigger not fired
813
814
815 } // for AllChains
816
817 return StatusCode::SUCCESS;
818}
#define M_PI
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool LLRW(float pqcd, float ptop, float phbb, float &w)
bool LLR(double pu, double pc, double pb, double &w)
float phiCorr(float phi)
bool CalcRelPt(float muonPt, float muonEta, float muonPhi, float jetPt, float jetEta, float jetPhi, float &RelPt)
#define y
#define x
#define z
virtual StatusCode initialize() override
initialize
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecTool
Tool to tell whether a specific trigger is passed.
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
Declare a monitored scalar variable.
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandleKey< xAOD::VertexContainer > m_offlineVertexContainerKey
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< xAOD::JetContainer > m_onlineEMTopoBJetContainerKey
Gaudi::Property< bool > m_expressStreamFlag
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_onlineTrackContainerKey
Gaudi::Property< std::vector< std::string > > m_allChains
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
TrigBjetMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::JetContainer > m_onlineEMPFlowBJetContainerKey
Gaudi::Property< std::string > m_btaggingLinkName
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_onlineVertexContainerKey
Gaudi::Property< bool > m_collisionRun
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
int r
Definition globals.cxx:22
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Generic monitoring tool for athena components.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
LinkInfo< T > findLink(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...
@ PriVtx
Primary vertex.
Jet_v1 Jet
Definition of the current "jet version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
Muon_v1 Muon
Reference the current persistent version:
JetContainer_v1 JetContainer
Definition of the current "jet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".