ATLAS Offline Software
Loading...
Searching...
No Matches
TrigBjetMonitorAlgorithm.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
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 track = muon->trackParticle(xAOD::Muon::TrackParticleType::CombinedTrackParticle); // TM and DG 18/06/22
424 if (track) {
425 plotDeltaZ = true;
426 muonZ = track->z0() + track->vz();
427 } else {
428 plotDeltaZ = false;
429 muonZ = 0.;
430 }
431
432 if (imuon == 0) {
433 //store the parameter for the 1st muon
434 muonPt1 = muonPt;
435 muonEta1 = muonEta;
436 muonPhi1 = muonPhi;
437 muonZ1 = muonZ;
438 }// if imuon==0
439
440 // The associated jet loop
441 for(const auto& jetLinkInfo : onlinejets) {
442 const xAOD::Jet* jet = *(jetLinkInfo.link);
443 // jetPt
444 NameH = "jetPt_"+trigName;
445 ATH_MSG_DEBUG( " NameH: " << NameH );
446 auto jetPt = Monitored::Scalar<float>(NameH,0.0);
447 jetPt = (jet->pt())*1.e-3;
448 ATH_MSG_DEBUG(" jetPt: " << jetPt);
449 fill("TrigBjetMonitor",jetPt);
450 // jetEta
451 NameH = "jetEta_"+trigName;
452 ATH_MSG_DEBUG( " NameH: " << NameH );
453 auto jetEta = Monitored::Scalar<float>(NameH,0.0);
454 jetEta = jet->eta();
455 ATH_MSG_DEBUG(" jetEta : " << jetEta);
456 fill("TrigBjetMonitor",jetEta);
457 // jetPhi
458 NameH = "jetPhi_"+trigName;
459 ATH_MSG_DEBUG( " NameH: " << NameH );
460 auto jetPhi = Monitored::Scalar<float>(NameH,0.0);
461 jetPhi = jet->phi();
462 ATH_MSG_DEBUG(" jetPhi : " << jetPhi);
463
464 // Take the b-tagging info from the first jet
465 if (ijet == 0) {
466 //store the parameter for the 1st jet
467 jetPt1 = jetPt;
468 jetEta1 = jetEta;
469 jetPhi1 = jetPhi;
470 jetZ1 = zPrmVtx;
471
472 auto btaggingLinkInfo = TrigCompositeUtils::findLink<xAOD::BTaggingContainer>(ctx, jetLinkInfo.source, m_btaggingLinkName); // TM 2021-10-30
473 const SG::AuxElement* obj_storing_btag = nullptr;
474 if ( btaggingLinkInfo.isValid() ) {
475 obj_storing_btag = *(btaggingLinkInfo.link);
476 }
477 else {
478 obj_storing_btag = *(jetLinkInfo.link);
479 }
480
481 static const SG::AuxElement::ConstAccessor<float> GN1pu_accessor("GN120220813_pu");
482 static const SG::AuxElement::ConstAccessor<float> GN1pc_accessor("GN120220813_pc");
483 static const SG::AuxElement::ConstAccessor<float> GN1pb_accessor("GN120220813_pb");
484
485 static const SG::AuxElement::ConstAccessor<float> GN2pu_accessor("GN220240122_pu");
486 static const SG::AuxElement::ConstAccessor<float> GN2pc_accessor("GN220240122_pc");
487 static const SG::AuxElement::ConstAccessor<float> GN2pb_accessor("GN220240122_pb");
488
489 // checking just pu is enough
490 if (GN1pu_accessor.isAvailable(*obj_storing_btag)) {
491 double GN1_pu(-1.), GN1_pc(-1.), GN1_pb(-1.);
492 GN1_pu = GN1pu_accessor(*obj_storing_btag);
493 ATH_MSG_DEBUG(" GN1_pu: " << GN1_pu);
494 GN1_pc = GN1pc_accessor(*obj_storing_btag);
495 ATH_MSG_DEBUG(" GN1_pc: " << GN1_pc);
496 GN1_pb = GN1pb_accessor(*obj_storing_btag);
497 ATH_MSG_DEBUG(" GN1_pb: " << GN1_pb);
498 theLLR_GN1 = LLR (GN1_pu, GN1_pc, GN1_pb, GN1_mv);
499 ATH_MSG_DEBUG(" GN1_mv: " << GN1_mv << " LLR: " << theLLR_GN1);
500 }
501 if (GN2pu_accessor.isAvailable(*obj_storing_btag)) {
502 double GN2_pu(-1.), GN2_pc(-1.), GN2_pb(-1.);
503 GN2_pu = GN2pu_accessor(*obj_storing_btag);
504 ATH_MSG_DEBUG(" GN2_pu: " << GN2_pu);
505 GN2_pc = GN2pc_accessor(*obj_storing_btag);
506 ATH_MSG_DEBUG(" GN2_pc: " << GN2_pc);
507 GN2_pb = GN2pb_accessor(*obj_storing_btag);
508 ATH_MSG_DEBUG(" GN2_pb: " << GN2_pb);
509 theLLR_GN2 = LLR (GN2_pu, GN2_pc, GN2_pb, GN2_mv);
510 ATH_MSG_DEBUG(" GN2_mv: " << GN2_mv << " LLR: " << theLLR_GN2);
511 }
512 }// if ijet==0
513
514 ijet++;
515
516 }// for onlinejets
517
518 imuon++;
519
520 }// for onlinemuons
521
522 // muon vs jet histograms
523
524 // Delta R(muon,jet)
525 std::string DeltaRH = "DeltaR_"+trigName;
526 ATH_MSG_DEBUG( " DeltaRH: " << DeltaRH );
527 auto DeltaR = Monitored::Scalar<float>(DeltaRH,0.0);
528 float DeltaEta = muonEta1 - jetEta1;
529 float DeltaPhi = phiCorr( phiCorr(muonPhi1) - phiCorr(jetPhi1) );
530 DeltaR = sqrt( DeltaEta*DeltaEta + DeltaPhi*DeltaPhi );
531 ATH_MSG_DEBUG(" Delta R : " << DeltaR);
532 fill("TrigBjetMonitor",DeltaR);
533
534 // Delta Z(muon,jet)
535 std::string DeltaZH = "DeltaZ_"+trigName;
536 ATH_MSG_DEBUG( " DeltaZH: " << DeltaZH );
537 auto DeltaZ = Monitored::Scalar<float>(DeltaZH,0.0);
538 DeltaZ = std::abs(muonZ1-jetZ1);
539 ATH_MSG_DEBUG(" Delta Z : " << DeltaZ);
540 if (plotDeltaZ) fill("TrigBjetMonitor",DeltaZ);
541
542 // muonPt/jetPt
543 std::string RatioPtH = "RatioPt_"+trigName;
544 ATH_MSG_DEBUG( " RatioPtH: " << RatioPtH );
545 auto RatioPt = Monitored::Scalar<float>(RatioPtH,0.0);
546 RatioPt = -100.;
547 if (jetPt1 > 0.) RatioPt = muonPt1/jetPt1;
548 ATH_MSG_DEBUG(" RatioPt : " << RatioPt);
549 if (RatioPt > 0.) fill("TrigBjetMonitor",RatioPt);
550
551 // muonPt relative to jet direction
552 std::string RelPtH = "RelPt_"+trigName;
553 ATH_MSG_DEBUG( " RelPtH: " << RelPtH );
554 auto RelPt = Monitored::Scalar<float>(RelPtH,0.0);
555 RelPt = 1.e10;
556 bool calc_relpt = CalcRelPt (muonPt1, muonEta1, muonPhi1, jetPt1, jetEta1, jetPhi1, RelPt);
557 ATH_MSG_DEBUG(" RelPt : " << RelPt);
558
559 // wGN1
560 std::string wGN1H = "wGN1_"+trigName;
561 ATH_MSG_DEBUG( " NameH: " << wGN1H );
562 auto wGN1 = Monitored::Scalar<float>(wGN1H,0.0);
563 wGN1 = float(GN1_mv);
564 ATH_MSG_DEBUG(" wGN1: " << wGN1 << " RelPt : " << RelPt);
565 if (calc_relpt && theLLR_GN1) fill("TrigBjetMonitor",wGN1,RelPt);
566
567 // wGN2
568 std::string wGN2H = "wGN2_"+trigName;
569 ATH_MSG_DEBUG( " NameH: " << wGN2H );
570 auto wGN2 = Monitored::Scalar<float>(wGN2H,0.0);
571 wGN2 = float(GN2_mv);
572 ATH_MSG_DEBUG(" wGN2: " << wGN2 << " RelPt : " << RelPt);
573 if (calc_relpt && theLLR_GN2) fill("TrigBjetMonitor",wGN2,RelPt);
574
575 } // if (nMuon*nJet > 0)
576
577 }// if mujetChain
578
579 // bjet chains
580 if (bjetChain) {
581
582 // Jets and PV and tracks through jet link
583
584 std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDecTool->features<xAOD::JetContainer>(trigName, TrigDefs::Physics); // TM 2021-10-30
585
586 int ijet = 0;
587 int itrack = 0;
588 std::string nJetH = "nJet_"+trigName;
589 auto nJet = Monitored::Scalar<int>(nJetH,0.0);
590 nJet = onlinejets.size();
591 fill("TrigBjetMonitor",nJet);
592
593 if (nJet > 0) {
594
595 for(const auto& jetLinkInfo : onlinejets) {
596 const xAOD::Jet* jet = *(jetLinkInfo.link);
597 // jetPt
598 std::string NameH = "jetPt_"+trigName;
599 ATH_MSG_DEBUG( " NameH: " << NameH );
600 auto jetPt = Monitored::Scalar<float>(NameH,0.0);
601 jetPt = (jet->pt())*1.e-3;
602 ATH_MSG_DEBUG(" jetPt: " << jetPt);
603 fill("TrigBjetMonitor",jetPt);
604 // jetEta
605 NameH = "jetEta_"+trigName;
606 ATH_MSG_DEBUG( " NameH: " << NameH );
607 auto jetEta = Monitored::Scalar<float>(NameH,0.0);
608 jetEta = jet->eta();
609 // jetPhi
610 NameH = "jetPhi_"+trigName;
611 ATH_MSG_DEBUG( " NameH: " << NameH );
612 auto jetPhi = Monitored::Scalar<float>(NameH,0.0);
613 jetPhi = jet->phi();
614 ATH_MSG_DEBUG(" jetEta: " << jetEta << " jetPhi : " << jetPhi);
615 fill("TrigBjetMonitor",jetEta,jetPhi);
616
617 // 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
618 if (ijet == 0) {
619
620 // Fetch and plot PV
621
622 std::string vtxname = m_onlineVertexContainerKey.key();
623 if ( vtxname.compare(0, 4, "HLT_")==0 ) vtxname.erase(0,4);
624 auto vertexLinkInfo = TrigCompositeUtils::findLink<xAOD::VertexContainer>(ctx, jetLinkInfo.source, vtxname ); // CV 200120 & MS 290620
625 ATH_CHECK( vertexLinkInfo.isValid() ) ; // TM 200120
626 const xAOD::Vertex* vtx = *(vertexLinkInfo.link);
627 NameH = "PVz_jet_"+trigName;
628 ATH_MSG_DEBUG( " NameH: " << NameH );
629 auto PVz_jet = Monitored::Scalar<float>(NameH,0.0);
630 PVz_jet = vtx->z();
631 ATH_MSG_DEBUG(" PVz_jet: " << PVz_jet);
632 fill("TrigBjetMonitor",PVz_jet);
633 NameH = "PVx_jet_"+trigName;
634 ATH_MSG_DEBUG( " NameH: " << NameH );
635 auto PVx_jet = Monitored::Scalar<float>(NameH,0.0);
636 PVx_jet = vtx->x();
637 ATH_MSG_DEBUG(" PVx_jet: " << PVx_jet);
638 fill("TrigBjetMonitor",PVx_jet);
639 NameH = "PVy_jet_"+trigName;
640 ATH_MSG_DEBUG( " NameH: " << NameH );
641 auto PVy_jet = Monitored::Scalar<float>(NameH,0.0);
642 PVy_jet = vtx->y();
643 ATH_MSG_DEBUG(" PVy_jet: " << PVy_jet);
644 fill("TrigBjetMonitor",PVy_jet);
645
646
647 } // if (ijet == 0)
648
649 ijet++;
650
651 // Fetch and plot BTagging information
652 const SG::AuxElement* obj_storing_btag = nullptr;
653 auto btaggingLinkInfo = TrigCompositeUtils::findLink<xAOD::BTaggingContainer>(ctx, jetLinkInfo.source, m_btaggingLinkName); // TM 2021-10-30
654 if ( btaggingLinkInfo.isValid() ) {
655 obj_storing_btag = *(btaggingLinkInfo.link);
656 }
657 else {
658 obj_storing_btag = *(jetLinkInfo.link);
659 }
660
661 bool theLLR(false);
662 static const SG::AuxElement::ConstAccessor<float> GN1pu_accessor("GN120220813_pu");
663 static const SG::AuxElement::ConstAccessor<float> GN1pc_accessor("GN120220813_pc");
664 static const SG::AuxElement::ConstAccessor<float> GN1pb_accessor("GN120220813_pb");
665 static const SG::AuxElement::ConstAccessor<float> GN2pu_accessor("GN220240122_pu");
666 static const SG::AuxElement::ConstAccessor<float> GN2pc_accessor("GN220240122_pc");
667 static const SG::AuxElement::ConstAccessor<float> GN2pb_accessor("GN220240122_pb");
668 // checking only pu should be sufficient
669 bool GN1_available = GN1pu_accessor.isAvailable(*obj_storing_btag);
670 bool GN2_available = GN2pu_accessor.isAvailable(*obj_storing_btag);
671 NameH = "GN1_pu_tr_"+trigName;
672 ATH_MSG_DEBUG( " NameH: " << NameH );
673 auto GN1_pu = Monitored::Scalar<double>(NameH,0.0);
674 GN1_pu = GN1_available ? GN1pu_accessor(*obj_storing_btag) : -1.0;
675 ATH_MSG_DEBUG(" GN1_pu: " << GN1_pu);
676 fill("TrigBjetMonitor",GN1_pu);
677
678 NameH = "GN1_pc_tr_"+trigName;
679 ATH_MSG_DEBUG( " NameH: " << NameH );
680 auto GN1_pc = Monitored::Scalar<double>(NameH,0.0);
681 GN1_pc = GN1_available ? GN1pc_accessor(*obj_storing_btag) : -1.0;
682 ATH_MSG_DEBUG(" GN1_pc: " << GN1_pc);
683 fill("TrigBjetMonitor",GN1_pc);
684
685 NameH = "GN1_pb_tr_"+trigName;
686 ATH_MSG_DEBUG( " NameH: " << NameH );
687 auto GN1_pb = Monitored::Scalar<double>(NameH,0.0);
688 GN1_pb = GN1_available ? GN1pb_accessor(*obj_storing_btag) : -1.0;
689 ATH_MSG_DEBUG(" GN1_pb: " << GN1_pb);
690 fill("TrigBjetMonitor",GN1_pb);
691
692 NameH = "GN1_mv_tr_"+trigName;
693 ATH_MSG_DEBUG( " NameH: " << NameH );
694 auto GN1_mv = Monitored::Scalar<double>(NameH,0.0);
695 theLLR = LLR (GN1_pu, GN1_pc, GN1_pb, GN1_mv);
696 if ( theLLR ) fill("TrigBjetMonitor",GN1_mv);
697 ATH_MSG_DEBUG(" GN1_mv: " << GN1_mv << " LLR: " << theLLR);
698
699
700 NameH = "GN2_pu_tr_"+trigName;
701 ATH_MSG_DEBUG( " NameH: " << NameH );
702 auto GN2_pu = Monitored::Scalar<double>(NameH,0.0);
703 GN2_pu = GN2_available ? GN2pu_accessor(*obj_storing_btag) : -1.0;
704 ATH_MSG_DEBUG(" GN2_pu: " << GN2_pu);
705 fill("TrigBjetMonitor",GN2_pu);
706
707 NameH = "GN2_pc_tr_"+trigName;
708 ATH_MSG_DEBUG( " NameH: " << NameH );
709 auto GN2_pc = Monitored::Scalar<double>(NameH,0.0);
710 GN2_pc = GN2_available ? GN2pc_accessor(*obj_storing_btag) : -1.0;
711 ATH_MSG_DEBUG(" GN2_pc: " << GN2_pc);
712 fill("TrigBjetMonitor",GN2_pc);
713
714 NameH = "GN2_pb_tr_"+trigName;
715 ATH_MSG_DEBUG( " NameH: " << NameH );
716 auto GN2_pb = Monitored::Scalar<double>(NameH,0.0);
717 GN2_pb = GN2_available ? GN2pb_accessor(*obj_storing_btag) : -1.0;
718 ATH_MSG_DEBUG(" GN2_pb: " << GN2_pb);
719 fill("TrigBjetMonitor",GN2_pb);
720
721 NameH = "GN2_mv_tr_"+trigName;
722 ATH_MSG_DEBUG( " NameH: " << NameH );
723 auto GN2_mv = Monitored::Scalar<double>(NameH,0.0);
724 theLLR = LLR (GN2_pu, GN2_pc, GN2_pb, GN2_mv);
725 if ( theLLR ) fill("TrigBjetMonitor",GN2_mv);
726 ATH_MSG_DEBUG(" GN2_mv: " << GN2_mv << " LLR: " << theLLR);
727
728
729 // Tracks associated to triggered jets ( featurs = onlinejets ) courtesy of Tim Martin on 12/05/2020
730 const auto track_it_pair = m_trigDecTool->associateToEventView(theTracks, jetLinkInfo.source, "roi");
731 const xAOD::TrackParticleContainer::const_iterator start_it = track_it_pair.first;
732 const xAOD::TrackParticleContainer::const_iterator end_it = track_it_pair.second;
733
734 int count = 0;
735 for ( xAOD::TrackParticleContainer::const_iterator it = start_it; it != end_it; ++it) {
736 count++;
737 ATH_MSG_DEBUG( " Track " << count << " with pT " << (*it)->pt() <<" from BJet with pT " << (*jetLinkInfo.link)->pt() );
738 ATH_MSG_DEBUG( " Track " << count << " with pT/eta/phi " << (*it)->pt() << "/" << (*it)->eta() << "/" << (*it)->phi() );
739 ATH_MSG_DEBUG( " Track " << count << " with d0/sigd0 " << (*it)->d0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 0) );
740 ATH_MSG_DEBUG( " Track " << count << " with z0/sigz0 " << (*it)->z0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 1) );
741 std::string NameH = "trkPt_"+trigName;
742 ATH_MSG_DEBUG( " NameH: " << NameH );
743 auto trkPt = Monitored::Scalar<float>(NameH,0.0);
744 trkPt = ((*it)->pt())*1.e-3;
745 ATH_MSG_DEBUG(" trkPt: " << trkPt);
746 fill("TrigBjetMonitor",trkPt);
747 NameH = "trkEta_"+trigName;
748 ATH_MSG_DEBUG( " NameH: " << NameH );
749 auto trkEta = Monitored::Scalar<float>(NameH,0.0);
750 trkEta = (*it)->eta();
751 NameH = "trkPhi_"+trigName;
752 ATH_MSG_DEBUG( " NameH: " << NameH );
753 auto trkPhi = Monitored::Scalar<float>(NameH,0.0);
754 trkPhi = (*it)->phi();
755 ATH_MSG_DEBUG(" trkEta: " << trkEta << " trkPhi : " << trkPhi);
756 fill("TrigBjetMonitor",trkEta,trkPhi);
757 NameH = "d0_"+trigName;
758 ATH_MSG_DEBUG( " NameH: " << NameH );
759 auto d0 = Monitored::Scalar<float>(NameH,0.0);
760 d0 = (*it)->d0();
761 ATH_MSG_DEBUG(" d0: " << d0);
762 fill("TrigBjetMonitor",d0);
763 NameH = "z0_"+trigName;
764 ATH_MSG_DEBUG( " NameH: " << NameH );
765 auto z0 = Monitored::Scalar<float>(NameH,0.0);
766 z0 = (*it)->z0();
767 ATH_MSG_DEBUG(" z0: " << z0);
768 fill("TrigBjetMonitor",z0);
769 NameH = "ed0_"+trigName;
770 ATH_MSG_DEBUG( " NameH: " << NameH );
771 auto ed0 = Monitored::Scalar<float>(NameH,0.0);
772 ed0 = Amg::error((*it)->definingParametersCovMatrix(), 0);
773 ATH_MSG_DEBUG(" ed0: " << ed0);
774 fill("TrigBjetMonitor",ed0);
775 NameH = "sd0_"+trigName;
776 ATH_MSG_DEBUG( " NameH: " << NameH );
777 auto sd0 = Monitored::Scalar<float>(NameH,0.0);
778 sd0 = -10.;
779 if (ed0 > 0.) sd0 = std::abs(d0)/ed0;
780 ATH_MSG_DEBUG(" sd0: " << sd0);
781 fill("TrigBjetMonitor",sd0);
782 NameH = "ez0_"+trigName;
783 ATH_MSG_DEBUG( " NameH: " << NameH );
784 auto ez0 = Monitored::Scalar<float>(NameH,0.0);
785 ez0 = Amg::error((*it)->definingParametersCovMatrix(), 1);
786 ATH_MSG_DEBUG(" ez0: " << ez0);
787 fill("TrigBjetMonitor",ez0);
788 } // it on tracks
789 ATH_MSG_DEBUG( " Number of tracks: " << count );
790 itrack += count;
791
792 } // jetLinkInfo from onlinejets
793
794 ATH_MSG_DEBUG(" Total number of triggered b-jets: " << ijet << " nJet : " << nJet);
795 ATH_MSG_DEBUG(" Total number of triggered tracks associated to the b-jets: " << itrack);
796 std::string nTrackH = "nTrack_"+trigName;
797 auto nTrack = Monitored::Scalar<int>(nTrackH,0.0);
798 nTrack = itrack;
799 fill("TrigBjetMonitor",nTrack);
800
801 } // if (nJet > 0)
802
803 } //if bjetChain
804
805 } else {
806 ATH_MSG_DEBUG(" Chain " << trigName << " is declared for the Express Stream but it is NOT in the Express Stream in an Express Job");
807 } // if m_expressStreamFlag
808
809 } else {
810 ATH_MSG_DEBUG( " Trigger chain from AllChains list: " << trigName << " has not fired " );
811 } // trigger not fired
812
813
814 } // for AllChains
815
816 return StatusCode::SUCCESS;
817}
#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.
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:148
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.
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
LinkInfo< T > findLink(const EventContext &ctx, 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".