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