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>(std::move(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::ConstAccessor<float> pqcd_accessor("GN2XTrig_pqcd");
281 static const SG::ConstAccessor<float> ptop_accessor("GN2XTrig_ptop");
282 static const SG::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::ConstAccessor<float> pqcd_accessor0("GN2Xv01_pqcd");
343 static const SG::ConstAccessor<float> ptop_accessor0("GN2Xv01_ptop");
344 static const SG::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>(std::move(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 GN2_mv(0.);
397 bool 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::ConstAccessor<float> GN2pu_accessor("GN220240122_pu");
482 static const SG::ConstAccessor<float> GN2pc_accessor("GN220240122_pc");
483 static const SG::ConstAccessor<float> GN2pb_accessor("GN220240122_pb");
484
485 // checking just pu is enough
486 if (GN2pu_accessor.isAvailable(*obj_storing_btag)) {
487 double GN2_pu(-1.), GN2_pc(-1.), GN2_pb(-1.);
488 GN2_pu = GN2pu_accessor(*obj_storing_btag);
489 ATH_MSG_DEBUG(" GN2_pu: " << GN2_pu);
490 GN2_pc = GN2pc_accessor(*obj_storing_btag);
491 ATH_MSG_DEBUG(" GN2_pc: " << GN2_pc);
492 GN2_pb = GN2pb_accessor(*obj_storing_btag);
493 ATH_MSG_DEBUG(" GN2_pb: " << GN2_pb);
494 theLLR_GN2 = LLR (GN2_pu, GN2_pc, GN2_pb, GN2_mv);
495 ATH_MSG_DEBUG(" GN2_mv: " << GN2_mv << " LLR: " << theLLR_GN2);
496 }
497 }// if ijet==0
498
499 ijet++;
500
501 }// for onlinejets
502
503 imuon++;
504
505 }// for onlinemuons
506
507 // muon vs jet histograms
508
509 // Delta R(muon,jet)
510 std::string DeltaRH = "DeltaR_"+trigName;
511 ATH_MSG_DEBUG( " DeltaRH: " << DeltaRH );
512 auto DeltaR = Monitored::Scalar<float>(std::move(DeltaRH),0.0);
513 float DeltaEta = muonEta1 - jetEta1;
514 float DeltaPhi = phiCorr( phiCorr(muonPhi1) - phiCorr(jetPhi1) );
515 DeltaR = sqrt( DeltaEta*DeltaEta + DeltaPhi*DeltaPhi );
516 ATH_MSG_DEBUG(" Delta R : " << DeltaR);
517 fill("TrigBjetMonitor",DeltaR);
518
519 // Delta Z(muon,jet)
520 std::string DeltaZH = "DeltaZ_"+trigName;
521 ATH_MSG_DEBUG( " DeltaZH: " << DeltaZH );
522 auto DeltaZ = Monitored::Scalar<float>(std::move(DeltaZH),0.0);
523 DeltaZ = std::abs(muonZ1-jetZ1);
524 ATH_MSG_DEBUG(" Delta Z : " << DeltaZ);
525 if (plotDeltaZ) fill("TrigBjetMonitor",DeltaZ);
526
527 // muonPt/jetPt
528 std::string RatioPtH = "RatioPt_"+trigName;
529 ATH_MSG_DEBUG( " RatioPtH: " << RatioPtH );
530 auto RatioPt = Monitored::Scalar<float>(std::move(RatioPtH),0.0);
531 RatioPt = -100.;
532 if (jetPt1 > 0.) RatioPt = muonPt1/jetPt1;
533 ATH_MSG_DEBUG(" RatioPt : " << RatioPt);
534 if (RatioPt > 0.) fill("TrigBjetMonitor",RatioPt);
535
536 // muonPt relative to jet direction
537 std::string RelPtH = "RelPt_"+trigName;
538 ATH_MSG_DEBUG( " RelPtH: " << RelPtH );
539 auto RelPt = Monitored::Scalar<float>(std::move(RelPtH),0.0);
540 RelPt = 1.e10;
541 bool calc_relpt = CalcRelPt (muonPt1, muonEta1, muonPhi1, jetPt1, jetEta1, jetPhi1, RelPt);
542 ATH_MSG_DEBUG(" RelPt : " << RelPt);
543
544 // wGN2
545 std::string wGN2H = "wGN2_"+trigName;
546 ATH_MSG_DEBUG( " NameH: " << wGN2H );
547 auto wGN2 = Monitored::Scalar<float>(std::move(wGN2H),0.0);
548 wGN2 = float(GN2_mv);
549 ATH_MSG_DEBUG(" wGN2: " << wGN2 << " RelPt : " << RelPt);
550 if (calc_relpt && theLLR_GN2) fill("TrigBjetMonitor",wGN2,RelPt);
551
552 } // if (nMuon*nJet > 0)
553
554 }// if mujetChain
555
556 // bjet chains
557 if (bjetChain) {
558
559 // Jets and PV and tracks through jet link
560
561 std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDecTool->features<xAOD::JetContainer>(trigName, TrigDefs::Physics); // TM 2021-10-30
562
563 int ijet = 0;
564 int itrack = 0;
565 std::string nJetH = "nJet_"+trigName;
566 auto nJet = Monitored::Scalar<int>(std::move(nJetH),0.0);
567 nJet = onlinejets.size();
568 fill("TrigBjetMonitor",nJet);
569
570 if (nJet > 0) {
571
572 for(const auto& jetLinkInfo : onlinejets) {
573 const xAOD::Jet* jet = *(jetLinkInfo.link);
574 // jetPt
575 std::string NameH = "jetPt_"+trigName;
576 ATH_MSG_DEBUG( " NameH: " << NameH );
577 auto jetPt = Monitored::Scalar<float>(NameH,0.0);
578 jetPt = (jet->pt())*1.e-3;
579 ATH_MSG_DEBUG(" jetPt: " << jetPt);
580 fill("TrigBjetMonitor",jetPt);
581 // jetEta
582 NameH = "jetEta_"+trigName;
583 ATH_MSG_DEBUG( " NameH: " << NameH );
584 auto jetEta = Monitored::Scalar<float>(NameH,0.0);
585 jetEta = jet->eta();
586 // jetPhi
587 NameH = "jetPhi_"+trigName;
588 ATH_MSG_DEBUG( " NameH: " << NameH );
589 auto jetPhi = Monitored::Scalar<float>(NameH,0.0);
590 jetPhi = jet->phi();
591 ATH_MSG_DEBUG(" jetEta: " << jetEta << " jetPhi : " << jetPhi);
592 fill("TrigBjetMonitor",jetEta,jetPhi);
593
594 // 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
595 if (ijet == 0) {
596
597 // Fetch and plot PV
598
599 std::string vtxname = m_onlineVertexContainerKey.key();
600 if ( vtxname.compare(0, 4, "HLT_")==0 ) vtxname.erase(0,4);
601 auto vertexLinkInfo = TrigCompositeUtils::findLink<xAOD::VertexContainer>(ctx, jetLinkInfo.source, vtxname ); // CV 200120 & MS 290620
602 ATH_CHECK( vertexLinkInfo.isValid() ) ; // TM 200120
603 const xAOD::Vertex* vtx = *(vertexLinkInfo.link);
604 NameH = "PVz_jet_"+trigName;
605 ATH_MSG_DEBUG( " NameH: " << NameH );
606 auto PVz_jet = Monitored::Scalar<float>(NameH,0.0);
607 PVz_jet = vtx->z();
608 ATH_MSG_DEBUG(" PVz_jet: " << PVz_jet);
609 fill("TrigBjetMonitor",PVz_jet);
610 NameH = "PVx_jet_"+trigName;
611 ATH_MSG_DEBUG( " NameH: " << NameH );
612 auto PVx_jet = Monitored::Scalar<float>(NameH,0.0);
613 PVx_jet = vtx->x();
614 ATH_MSG_DEBUG(" PVx_jet: " << PVx_jet);
615 fill("TrigBjetMonitor",PVx_jet);
616 NameH = "PVy_jet_"+trigName;
617 ATH_MSG_DEBUG( " NameH: " << NameH );
618 auto PVy_jet = Monitored::Scalar<float>(NameH,0.0);
619 PVy_jet = vtx->y();
620 ATH_MSG_DEBUG(" PVy_jet: " << PVy_jet);
621 fill("TrigBjetMonitor",PVy_jet);
622
623
624 } // if (ijet == 0)
625
626 ijet++;
627
628 // Fetch and plot BTagging information
629 const SG::AuxElement* obj_storing_btag = nullptr;
630 auto btaggingLinkInfo = TrigCompositeUtils::findLink<xAOD::BTaggingContainer>(ctx, jetLinkInfo.source, m_btaggingLinkName); // TM 2021-10-30
631 if ( btaggingLinkInfo.isValid() ) {
632 obj_storing_btag = *(btaggingLinkInfo.link);
633 }
634 else {
635 obj_storing_btag = *(jetLinkInfo.link);
636 }
637
638 bool theLLR(false);
639 static const SG::ConstAccessor<float> GN2pu_accessor("GN220240122_pu");
640 static const SG::ConstAccessor<float> GN2pc_accessor("GN220240122_pc");
641 static const SG::ConstAccessor<float> GN2pb_accessor("GN220240122_pb");
642 // checking only pu should be sufficient
643 bool GN2_available = GN2pu_accessor.isAvailable(*obj_storing_btag);
644
645 NameH = "GN2_pu_tr_"+trigName;
646 ATH_MSG_DEBUG( " NameH: " << NameH );
647 auto GN2_pu = Monitored::Scalar<double>(NameH,0.0);
648 GN2_pu = GN2_available ? GN2pu_accessor(*obj_storing_btag) : -1.0;
649 ATH_MSG_DEBUG(" GN2_pu: " << GN2_pu);
650 fill("TrigBjetMonitor",GN2_pu);
651
652 NameH = "GN2_pc_tr_"+trigName;
653 ATH_MSG_DEBUG( " NameH: " << NameH );
654 auto GN2_pc = Monitored::Scalar<double>(NameH,0.0);
655 GN2_pc = GN2_available ? GN2pc_accessor(*obj_storing_btag) : -1.0;
656 ATH_MSG_DEBUG(" GN2_pc: " << GN2_pc);
657 fill("TrigBjetMonitor",GN2_pc);
658
659 NameH = "GN2_pb_tr_"+trigName;
660 ATH_MSG_DEBUG( " NameH: " << NameH );
661 auto GN2_pb = Monitored::Scalar<double>(NameH,0.0);
662 GN2_pb = GN2_available ? GN2pb_accessor(*obj_storing_btag) : -1.0;
663 ATH_MSG_DEBUG(" GN2_pb: " << GN2_pb);
664 fill("TrigBjetMonitor",GN2_pb);
665
666 NameH = "GN2_mv_tr_"+trigName;
667 ATH_MSG_DEBUG( " NameH: " << NameH );
668 auto GN2_mv = Monitored::Scalar<double>(std::move(NameH),0.0);
669 theLLR = LLR (GN2_pu, GN2_pc, GN2_pb, GN2_mv);
670 if ( theLLR ) fill("TrigBjetMonitor",GN2_mv);
671 ATH_MSG_DEBUG(" GN2_mv: " << GN2_mv << " LLR: " << theLLR);
672
673
674 // Tracks associated to triggered jets ( featurs = onlinejets ) courtesy of Tim Martin on 12/05/2020
675 const auto track_it_pair = m_trigDecTool->associateToEventView(theTracks, jetLinkInfo.source, "roi");
676 const xAOD::TrackParticleContainer::const_iterator start_it = track_it_pair.first;
677 const xAOD::TrackParticleContainer::const_iterator end_it = track_it_pair.second;
678
679 int count = 0;
680 for ( xAOD::TrackParticleContainer::const_iterator it = start_it; it != end_it; ++it) {
681 count++;
682 ATH_MSG_DEBUG( " Track " << count << " with pT " << (*it)->pt() <<" from BJet with pT " << (*jetLinkInfo.link)->pt() );
683 ATH_MSG_DEBUG( " Track " << count << " with pT/eta/phi " << (*it)->pt() << "/" << (*it)->eta() << "/" << (*it)->phi() );
684 ATH_MSG_DEBUG( " Track " << count << " with d0/sigd0 " << (*it)->d0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 0) );
685 ATH_MSG_DEBUG( " Track " << count << " with z0/sigz0 " << (*it)->z0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 1) );
686 std::string NameH = "trkPt_"+trigName;
687 ATH_MSG_DEBUG( " NameH: " << NameH );
688 auto trkPt = Monitored::Scalar<float>(NameH,0.0);
689 trkPt = ((*it)->pt())*1.e-3;
690 ATH_MSG_DEBUG(" trkPt: " << trkPt);
691 fill("TrigBjetMonitor",trkPt);
692 NameH = "trkEta_"+trigName;
693 ATH_MSG_DEBUG( " NameH: " << NameH );
694 auto trkEta = Monitored::Scalar<float>(NameH,0.0);
695 trkEta = (*it)->eta();
696 NameH = "trkPhi_"+trigName;
697 ATH_MSG_DEBUG( " NameH: " << NameH );
698 auto trkPhi = Monitored::Scalar<float>(NameH,0.0);
699 trkPhi = (*it)->phi();
700 ATH_MSG_DEBUG(" trkEta: " << trkEta << " trkPhi : " << trkPhi);
701 fill("TrigBjetMonitor",trkEta,trkPhi);
702 NameH = "d0_"+trigName;
703 ATH_MSG_DEBUG( " NameH: " << NameH );
704 auto d0 = Monitored::Scalar<float>(NameH,0.0);
705 d0 = (*it)->d0();
706 ATH_MSG_DEBUG(" d0: " << d0);
707 fill("TrigBjetMonitor",d0);
708 NameH = "z0_"+trigName;
709 ATH_MSG_DEBUG( " NameH: " << NameH );
710 auto z0 = Monitored::Scalar<float>(NameH,0.0);
711 z0 = (*it)->z0();
712 ATH_MSG_DEBUG(" z0: " << z0);
713 fill("TrigBjetMonitor",z0);
714 NameH = "ed0_"+trigName;
715 ATH_MSG_DEBUG( " NameH: " << NameH );
716 auto ed0 = Monitored::Scalar<float>(NameH,0.0);
717 ed0 = Amg::error((*it)->definingParametersCovMatrix(), 0);
718 ATH_MSG_DEBUG(" ed0: " << ed0);
719 fill("TrigBjetMonitor",ed0);
720 NameH = "sd0_"+trigName;
721 ATH_MSG_DEBUG( " NameH: " << NameH );
722 auto sd0 = Monitored::Scalar<float>(NameH,0.0);
723 sd0 = -10.;
724 if (ed0 > 0.) sd0 = std::abs(d0)/ed0;
725 ATH_MSG_DEBUG(" sd0: " << sd0);
726 fill("TrigBjetMonitor",sd0);
727 NameH = "ez0_"+trigName;
728 ATH_MSG_DEBUG( " NameH: " << NameH );
729 auto ez0 = Monitored::Scalar<float>(std::move(NameH),0.0);
730 ez0 = Amg::error((*it)->definingParametersCovMatrix(), 1);
731 ATH_MSG_DEBUG(" ez0: " << ez0);
732 fill("TrigBjetMonitor",ez0);
733 } // it on tracks
734 ATH_MSG_DEBUG( " Number of tracks: " << count );
735 itrack += count;
736
737 } // jetLinkInfo from onlinejets
738
739 ATH_MSG_DEBUG(" Total number of triggered b-jets: " << ijet << " nJet : " << nJet);
740 ATH_MSG_DEBUG(" Total number of triggered tracks associated to the b-jets: " << itrack);
741 std::string nTrackH = "nTrack_"+trigName;
742 auto nTrack = Monitored::Scalar<int>(std::move(nTrackH),0.0);
743 nTrack = itrack;
744 fill("TrigBjetMonitor",nTrack);
745
746 } // if (nJet > 0)
747
748 } //if bjetChain
749
750 } else {
751 ATH_MSG_DEBUG(" Chain " << trigName << " is declared for the Express Stream but it is NOT in the Express Stream in an Express Job");
752 } // if m_expressStreamFlag
753
754 } else {
755 ATH_MSG_DEBUG( " Trigger chain from AllChains list: " << trigName << " has not fired " );
756 } // trigger not fired
757
758
759 } // for AllChains
760
761 return StatusCode::SUCCESS;
762}
#define M_PI
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(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:861
Declare a monitored scalar variable.
Helper class to provide constant type-safe access to aux data.
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: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:
Definition Muon.h:13
JetContainer_v1 JetContainer
Definition of the current "jet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".