TrigBjetMonitorAlgorithm.cxx 21.6 KB
Newer Older
Elemer Nagy's avatar
Elemer Nagy committed
1
/*
Elemer Nagy's avatar
Elemer Nagy committed
2
  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Elemer Nagy's avatar
Elemer Nagy committed
3
4
5
6
*/

#include "TrigBjetMonitorAlgorithm.h"

7
8
9
10
#include "AthenaMonitoring/AthenaMonManager.h"
#include "AthenaMonitoring/ManagedMonitorToolTest.h"
#include "AthenaMonitoring/ManagedMonitorToolBase.h"   //EN

11
#include "xAODTracking/TrackParticle.h"
12
#include "xAODTracking/VertexContainer.h"
13

14
15
16
17
#include "xAODBTagging/BTaggingAuxContainer.h"
#include "xAODBTagging/BTaggingContainer.h"
#include "xAODBTagging/BTagging.h"

18
19
#include "EventPrimitives/EventPrimitivesHelpers.h"

20
21
22
23
24
25
#include "Particle/TrackParticleContainer.h"
#include "GeoPrimitives/GeoPrimitives.h"

#include "TrigParticle/TrigEFBjet.h"
#include "TrigParticle/TrigEFBjetContainer.h"

26
27
28
#include "JetEvent/JetCollection.h"
#include "muonEvent/Muon.h"
#include "muonEvent/MuonContainer.h"
29

30
31
32
33
34
// Calculates the track errors
#include "EventPrimitives/EventPrimitivesHelpers.h"



Elemer Nagy's avatar
Elemer Nagy committed
35
36
TrigBjetMonitorAlgorithm::TrigBjetMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
  : AthMonitorAlgorithm(name,pSvcLocator)
37
  ,m_doRandom(true)
38
39
  ,m_allChains{}
  ,m_muonContainerKey("Muons")
40
  ,m_trigDec("Trig::TrigDecisionTool/TrigDecisionTool")
Elemer Nagy's avatar
Elemer Nagy committed
41
  ,m_doRun2(false)
42
{
43
44
  declareProperty ("AllChains", m_allChains);
  declareProperty("MuonContainerName",m_muonContainerKey);
Elemer Nagy's avatar
Elemer Nagy committed
45
  declareProperty("doRun2",m_doRun2);
46
}
Elemer Nagy's avatar
Elemer Nagy committed
47
48
49
50
51
52


TrigBjetMonitorAlgorithm::~TrigBjetMonitorAlgorithm() {}


StatusCode TrigBjetMonitorAlgorithm::initialize() {
53
  ATH_CHECK( m_muonContainerKey.initialize() );
54
55
56

  ATH_CHECK( m_offlineVertexContainerKey.initialize() );
  ATH_CHECK( m_onlineVertexContainerKey.initialize() );
57
  ATH_CHECK( m_onlineTrackContainerKey.initialize() );
58
  ATH_CHECK( m_onlineBTaggingContainerKey.initialize() );
59

60
  return AthMonitorAlgorithm::initialize();
Elemer Nagy's avatar
Elemer Nagy committed
61
62
63
64
}


StatusCode TrigBjetMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
65
  using namespace Monitored;
Elemer Nagy's avatar
Elemer Nagy committed
66

67

68
  // Read off-line PV's  and fill histograms 
69
70
71
72
73
74

  auto OffNVtx = Monitored::Scalar<int>("Off_NVtx",0);
  auto OffxVtx = Monitored::Scalar<float>("Off_xVtx",0.0);
  auto OffyVtx = Monitored::Scalar<float>("Off_yVtx",0.0);
  auto OffzVtx = Monitored::Scalar<float>("Off_zVtx",0.0);

75
  SG::ReadHandle<xAOD::VertexContainer> offlinepv = SG::makeHandle( m_offlineVertexContainerKey, ctx );
76
  if (! offlinepv.isValid() ) {
77
    ATH_MSG_ERROR("evtStore() does not contain VertexContainer Collection with name "<< m_offlineVertexContainerKey);
78
79
    return StatusCode::FAILURE;
  }
80
  ATH_MSG_DEBUG(" Size of the Off-line PV container: " << offlinepv->size() );
81
82
83
84
85
  OffNVtx = offlinepv->size() ;
  for (unsigned int j = 0; j<offlinepv->size(); j++){
    OffxVtx = (*(offlinepv))[j]->x();
    OffyVtx = (*(offlinepv))[j]->y();
    OffzVtx = (*(offlinepv))[j]->z();
86
    fill("TrigBjetMonitor",OffxVtx,OffyVtx,OffzVtx);
87
  }
88
  fill("TrigBjetMonitor",OffNVtx);
89
  
90

91
  // print the trigger chain names 
92
93

  std::string chainName;
94

95
  int size_AllChains = m_allChains.size();
96
  ATH_MSG_DEBUG(" Size of the AllChains trigger container: " << size_AllChains );
97
  for (int i =0; i<size_AllChains; i++){
98
    chainName = m_allChains.at(i);
99
    ATH_MSG_DEBUG("  Chain number: " << i << " AllChains Chain Name: " << chainName );
100
101
  }

102
  
103
  // Verifiy if the trigger chain was fired and if yes, fill the corresponding histogram
104

105
  // Define keys of retrival
106
107
108
109
110
111
112
113

  std::string trackKey  = "";
  std::string jetKey  = "";
  std::string priVtxKey  = "EFHistoPrmVtx";
  bool FTKChain = false;
  bool mujetChain = false;
  bool bjetChain = true;
  bool splitChain = false;
114
  
115

116

117
  for ( auto& trigName : m_allChains ) {
118

Elemer Nagy's avatar
Elemer Nagy committed
119
    
120
    // Access to TrigFeature
Elemer Nagy's avatar
Elemer Nagy committed
121
    //    bool Run2_Access = true;
Elemer Nagy's avatar
Elemer Nagy committed
122
    //    bool Run2_Access = false;
123

124
    
125
    if ( m_trigDecTool->isPassed(trigName) ) {
126
      ATH_MSG_DEBUG(" Trigger chain from AllChains list: " << trigName << " has fired !!! " );
127

128

129
      // Trigger type
130

131
132
133
134
135
136
137
138
      // split vs unsplit
      std::size_t found = trigName.find("split");
      if (found!=std::string::npos) {
	splitChain = true;
	jetKey = "SplitJet";
	priVtxKey = "xPrimVx";
	trackKey  = "InDetTrigTrackingxAODCnv_Bjet_IDTrig";
      }// found
139

140
141
142
143
144
145
146
147
148
149
150
151
152
153
      // FTK vs non FTK
      std::size_t found1 = trigName.find("FTK");
      if (found1!=std::string::npos) {
	priVtxKey = "PrimVertexFTK";
	trackKey  = "InDetTrigTrackingxAODCnv_Bjet_FTK_IDTrig";
	std::size_t found2 = trigName.find("FTKRefit");
	if (found2!=std::string::npos) {
	  trackKey  = "InDetTrigTrackingxAODCnv_Bjet_FTKRefit_IDTrig";
	}// found2
	std::size_t found3 = trigName.find("FTKVtx");
	if (found3!=std::string::npos) {
	  trackKey  = "InDetTrigTrackingxAODCnv_Bjet_IDTrig";
	}// found3
      }// found1
154

155
156
157
158
159
      // gsc vs non-gsc chain
      std::size_t found4 = trigName.find("gsc");
      if (found4!=std::string::npos) {
	jetKey = "GSCJet";
      }// found4
160

161
162
163
164
165
166
167
      // bjet vs mujet
      found = trigName.find("HLT_mu");
      if (found!=std::string::npos) {
	mujetChain = true;
	bjetChain = false;
      }// found

168
169
      ATH_MSG_DEBUG( " Trigger type: bjetChain " << bjetChain << " mujetChain " << mujetChain << " FTKChain " << FTKChain << " splitChain " << splitChain );
      ATH_MSG_DEBUG( " Keys -- priVtxKey:  " << priVtxKey << " jetKey: " << jetKey << " trackKey: " << trackKey );
170

171
      // Read the TrigFeature contener
172

173
      if (m_doRun2) { // Run 2 trigger
174

175
	ATH_MSG_DEBUG("  ===> Run 2 access to Trigger feature: " );
176
177
	Trig::FeatureContainer fc = m_trigDec->features(trigName);
	const std::vector< Trig::Combination >& triggerCombs = fc.getCombinations();
178
179
	ATH_MSG_DEBUG("RETRIEVED " << triggerCombs.size() << " COMBINATIONS FOR "  << trigName);
	ATH_MSG_DEBUG( " Size of triggerCombs : " << triggerCombs.size() );
180
181
182
183
184
185
186
187
188
189
	// Take all combinations for this b-jet trigger
	std::vector< Trig::Combination >::const_iterator triggerComb;
	for( triggerComb = triggerCombs.begin(); triggerComb != triggerCombs.end(); ++triggerComb ) {
	  const Trig::Combination& comb = *triggerComb;

	  // bjet chains
	  if (bjetChain) {

	    // online PV 
	    const std::vector< Trig::Feature<xAOD::VertexContainer> > onlinepvs = comb.get<xAOD::VertexContainer>(priVtxKey);
190
	    ATH_MSG_DEBUG("RETRIEVED PV  -   size: " << onlinepvs.size());
191
192
	    if ( not onlinepvs.empty() ) {
	      const xAOD::VertexContainer* onlinepv = onlinepvs[0].cptr();
193
	      ATH_MSG_DEBUG("   for VertexContainer: " << priVtxKey << " nVert: " << onlinepv->size());
194
195
196
	      if( not onlinepv->empty()) {
		// PVz_tr 
		std::string NameH = "PVz_tr_"+trigName;
197
		ATH_MSG_DEBUG( " NameH: " << NameH );
198
199
		auto PVz_tr = Monitored::Scalar<float>(NameH,0.0);
		PVz_tr = (*(onlinepv))[0]->z();
200
		ATH_MSG_DEBUG("        PVz_tr: " << PVz_tr);
201
202
203
204
205
206
		fill("TrigBjetMonitor",PVz_tr);
	      }// onlinepv
	    }// onlinepvs

	    // Tracks 
	    const std::vector< Trig::Feature<xAOD::TrackParticleContainer> > onlinetracks = comb.get<xAOD::TrackParticleContainer>(trackKey);
207
	    ATH_MSG_DEBUG("RETRIEVED TRACKS -   size: " << onlinetracks.size());
208
209
	    if ( not onlinetracks.empty() ) { 
	      const xAOD::TrackParticleContainer*  onlinetrack = onlinetracks[0].cptr();
210
	      ATH_MSG_DEBUG("                 -   nTrack: " << onlinetrack->size());
211
212
213
	      for(const auto* trk : *onlinetrack) {
		// d0 
		std::string NameH = "d0_"+trigName;
214
		ATH_MSG_DEBUG( " NameH: " << NameH  );
215
216
		auto d0 = Monitored::Scalar<float>(NameH,0.0);
		d0 = trk->d0();
217
		ATH_MSG_DEBUG("        d0: " << d0);
218
219
220
221
222
223
		fill("TrigBjetMonitor",d0);
	      }// onlinetrack
	    }// onlinetracks
	    
	    // b-tagged jets 
	    const std::vector< Trig::Feature<xAOD::BTaggingContainer> > onlinebjets = comb.get<xAOD::BTaggingContainer>();
224
	    ATH_MSG_DEBUG("RETRIEVED BJETS  from xAOD BTaggingContainer -   size: " << onlinebjets.size());
225
226
	    if(not onlinebjets.empty()) { 
	      const xAOD::BTaggingContainer* onlinebjet = onlinebjets[0].cptr();
227
	      ATH_MSG_DEBUG("                 -   nBjet: " << onlinebjet->size());
228
229
230
	      for(const auto* bjet : *onlinebjet) {
		// wMV2c20 
		std::string NameH = "wMV2c20_"+trigName;
231
		ATH_MSG_DEBUG( " NameH: " << NameH  );
232
233
		auto wMV2c20 = Monitored::Scalar<double>(NameH,0.0);
		wMV2c20 = bjet->auxdata<double>("MV2c20_discriminant");
234
		ATH_MSG_DEBUG("        wMV2c20: " << wMV2c20);
235
236
237
238
239
		fill("TrigBjetMonitor",wMV2c20);
	      }// onlinebjet
	    }// onlinebjets

	  }//bjetChain
240
	  
241
242
243
244
245
	  //bjet or mujet chains
	  if (bjetChain || mujetChain) {

	    // Jets 
	    const std::vector< Trig::Feature<xAOD::JetContainer> > onlinejets = comb.get<xAOD::JetContainer>(jetKey);
246
	    ATH_MSG_DEBUG("RETRIEVED JETS   -   size: " << onlinejets.size());
247
248
	    if( not onlinejets.empty()) { 
	      const xAOD::JetContainer* onlinejet = onlinejets[0].cptr();
249
	      ATH_MSG_DEBUG("                 -   nJet: " << onlinejet->size());
250
251
252
	      for(const auto* jet : *onlinejet) {
		// jetPt 
		std::string NameH = "jetPt_"+trigName;
253
		ATH_MSG_DEBUG( " NameH: " << NameH  );
254
255
		auto jetPt = Monitored::Scalar<float>(NameH,0.0);
		jetPt = (jet->pt())*1.e-3;
256
		ATH_MSG_DEBUG("        jetPt: " << jetPt);
257
258
259
260
261
262
263
264
265
266
267
268
		fill("TrigBjetMonitor",jetPt);
	      }// onlinejet
	    }// onlinejets
	    
	  }//bjet or mujet

	  // mujet chains

	  if (mujetChain) {

	    // muons  and jets  
	    const std::vector< Trig::Feature<xAOD::JetContainer> > onlinejets = comb.get<xAOD::JetContainer>(jetKey);
269
	    ATH_MSG_DEBUG("RETRIEVED JETS   -   size: " << onlinejets.size());
270
	    const std::vector< Trig::Feature<xAOD::MuonContainer> > onlinemuons = comb.get<xAOD::MuonContainer>();
271
	    ATH_MSG_DEBUG("RETRIEVED MUONS   -   size: " << onlinemuons.size());
272
273
	    if( not onlinemuons.empty()) { 
	      const xAOD::MuonContainer* onlinemuon = onlinemuons[0].cptr();
274
	      ATH_MSG_DEBUG("                 -   nMuon: " << onlinemuon->size());
275
276
277
278
279
	      for(const auto* muon : *onlinemuon) {
		// plot muon attributes: pT, eta, phi, etc .... independently of the muon type
		const xAOD::Muon::MuonType muontype = muon->muonType();
		if( muontype != xAOD::Muon::MuonType::Combined ) continue;
		// if muon type is "Combined" and jet container is not empty loop on jets and plot muon-jet combined quantitites
280
		//   see Run2 code: https://gitlab.cern.ch/atlas/athena/blob/21.3/Trigger/TrigMonitoring/TrigBjetMonitoring/src/HLTBjetMonTool.cxx 
281
282
283
284
285
		if( not onlinejets.empty()) { 
		  const xAOD::JetContainer* onlinejet = onlinejets[0].cptr();
		  for(const auto* jet : *onlinejet) {
		    // jetPt 
		    std::string NameH = "jetPt_"+trigName;
286
		    ATH_MSG_DEBUG( " NameH: " << NameH  );
287
288
		    auto jetPt = Monitored::Scalar<float>(NameH,0.0);
		    jetPt = (jet->pt())*1.e-3;
289
		    ATH_MSG_DEBUG("        jetPt: " << jetPt);
290
291
292
293
294
295
296
297
298
299
300
		    fill("TrigBjetMonitor",jetPt);
		  }// onlinejet
		}// onlinejets
	      }// onlinemuon
	    }// onlinemuons
	    
	  }//mujetChain
	  
	}// trigger combinations
	
      } else { // Run 3 trigger
301
302
303
304
305
306
307
308
309

	ATH_MSG_DEBUG("  ===> Run 3 access to Trigger Item: " << trigName);

	// online track container 
	SG::ReadHandle<xAOD::TrackParticleContainer> theTracks(m_onlineTrackContainerKey, ctx);
	// verify the content 
	for ( const xAOD::TrackParticle* track : *theTracks ) {
	  ATH_MSG_DEBUG( " Pt of track in TrackParticleContainer: " << track->pt() );
	}
310

Elemer Nagy's avatar
Elemer Nagy committed
311
	// bjet chains
312
	if (bjetChain) {
313
	  // online PV 
314
	  SG::ReadHandle<xAOD::VertexContainer> vtxContainer = SG::makeHandle( m_onlineVertexContainerKey, ctx );
315
	  int nPV = 0;
316
317
	  for (const xAOD::Vertex* vtx : *vtxContainer) {
	    if (vtx->vertexType() == xAOD::VxType::PriVtx) {
318
	      nPV++;
319
	      std::string NameH = "PVz_tr_"+trigName;
320
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
321
322
	      auto PVz_tr = Monitored::Scalar<float>(NameH,0.0);
	      PVz_tr = vtx->z();
323
	      ATH_MSG_DEBUG("        PVz_tr: " << PVz_tr);
324
	      fill("TrigBjetMonitor",PVz_tr);
325
326
327
328
329
330
331
332
333
334
335
336
	      NameH = "PVx_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto PVx_tr = Monitored::Scalar<float>(NameH,0.0);
	      PVx_tr = vtx->x();
	      ATH_MSG_DEBUG("        PVx_tr: " << PVx_tr);
	      fill("TrigBjetMonitor",PVx_tr);
	      NameH = "PVy_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto PVy_tr = Monitored::Scalar<float>(NameH,0.0);
	      PVy_tr = vtx->y();
	      ATH_MSG_DEBUG("        PVy_tr: " << PVy_tr);
	      fill("TrigBjetMonitor",PVy_tr);
337
338
	    } // if vtx type
	  } // loop on vtxContainer
339
340
341
342
343
	  std::string NpvH = "nPV_tr_"+trigName;
	  ATH_MSG_DEBUG( " NpvH: " << NpvH  );
	  auto nPV_tr = Monitored::Scalar<int>(NpvH,0.0);
	  nPV_tr = nPV;
	  fill("TrigBjetMonitor",nPV_tr);
344
345
	} // if bjetChain

346
347
348
	//bjet or mujet chains 
	if (bjetChain || mujetChain) {

349
350
	  // Jets and PV and tracks through jet link

351
	  std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDec->features<xAOD::JetContainer>(trigName, TrigDefs::Physics, m_onlineBjetContainerKey);
352

353
	  int ijet = 0;
354
	  int itrack = 0;
355
356
357
358
	  std::string nJetH = "nJet_"+trigName;
	  auto nJet = Monitored::Scalar<int>(nJetH,0.0);
	  nJet = onlinejets.size();
	  fill("TrigBjetMonitor",nJet);
359
	  for(const auto& jetLinkInfo : onlinejets) {
360
	    // jetPt
361
362
	    const xAOD::Jet* jet = *(jetLinkInfo.link);
	    std::string NameH = "jetPt_"+trigName;
363
	    ATH_MSG_DEBUG( " NameH: " << NameH  );
364
365
	    auto jetPt = Monitored::Scalar<float>(NameH,0.0);
	    jetPt = (jet->pt())*1.e-3;
366
	    ATH_MSG_DEBUG("        jetPt: " << jetPt);
367
	    fill("TrigBjetMonitor",jetPt);
368
369
370
371
372
373
374
375
376
377
	    NameH = "jetEta_"+trigName;
	    ATH_MSG_DEBUG( " NameH: " << NameH  );
	    auto jetEta = Monitored::Scalar<float>(NameH,0.0);
	    jetEta = jet->eta();
	    NameH = "jetPhi_"+trigName;
	    ATH_MSG_DEBUG( " NameH: " << NameH  );
	    auto jetPhi = Monitored::Scalar<float>(NameH,0.0);
	    jetPhi = jet->phi();
	    ATH_MSG_DEBUG("        jetEta: " << jetEta << " jetPhi : " << jetPhi);
	    fill("TrigBjetMonitor",jetEta,jetPhi);
378
379
	    // 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
	    if (ijet == 0) {
380

381
382
	      // Fetch and plot PV

383
384
	      std::string vtxname = m_onlineVertexContainerKey.key();
	      if ( vtxname.find("HLT_")==0 ) vtxname.erase(0,4);
385
	      auto vertexLinkInfo = TrigCompositeUtils::findLink<xAOD::VertexContainer>(jetLinkInfo.source, vtxname ); // CV 200120 & MS 290620
386
	      ATH_CHECK( vertexLinkInfo.isValid() ) ; // TM 200120
387
388
	      const xAOD::Vertex* vtx = *(vertexLinkInfo.link);
	      NameH = "PVz_jet_"+trigName;
389
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
390
391
	      auto PVz_jet = Monitored::Scalar<float>(NameH,0.0);
	      PVz_jet = vtx->z();
392
	      ATH_MSG_DEBUG("        PVz_jet: " << PVz_jet);
393
	      fill("TrigBjetMonitor",PVz_jet);
394
395
396
397
398
399
400
401
402
403
404
405
	      NameH = "PVx_jet_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto PVx_jet = Monitored::Scalar<float>(NameH,0.0);
	      PVx_jet = vtx->x();
	      ATH_MSG_DEBUG("        PVx_jet: " << PVx_jet);
	      fill("TrigBjetMonitor",PVx_jet);
	      NameH = "PVy_jet_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto PVy_jet = Monitored::Scalar<float>(NameH,0.0);
	      PVy_jet = vtx->y();
	      ATH_MSG_DEBUG("        PVy_jet: " << PVy_jet);
	      fill("TrigBjetMonitor",PVy_jet);
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492

	      // Fetch and plot BTagging information

	      std::string btagname = m_onlineBTaggingContainerKey.key();
	      if ( btagname.find("HLT_")==0 ) btagname.erase(0,4);
	      auto btaggingLinkInfo = TrigCompositeUtils::findLink<xAOD::BTaggingContainer>(jetLinkInfo.source, btagname );
	      ATH_CHECK( btaggingLinkInfo.isValid() ) ;
	      const xAOD::BTagging* btag = *(btaggingLinkInfo.link);

	      // IP3D variables
	      NameH = "IP3D_pu_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto IP3D_pu = Monitored::Scalar<float>(NameH,0.0);
	      IP3D_pu = btag->IP3D_pu();
	      ATH_MSG_DEBUG("        IP3D_pu: " << IP3D_pu);
	      fill("TrigBjetMonitor",IP3D_pu);

	      NameH = "IP3D_pb_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto IP3D_pb = Monitored::Scalar<float>(NameH,0.0);
	      IP3D_pb = btag->IP3D_pb();
	      ATH_MSG_DEBUG("        IP3D_pb: " << IP3D_pb);
	      fill("TrigBjetMonitor",IP3D_pb);

	      NameH = "IP3D_pc_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto IP3D_pc = Monitored::Scalar<float>(NameH,0.0);
	      IP3D_pc = btag->IP3D_pc();
	      ATH_MSG_DEBUG("        IP3D_pc: " << IP3D_pc);
	      fill("TrigBjetMonitor",IP3D_pc);

	      // LogLH variables
	      NameH = "wIP3D_Rbu_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto wIP3D = Monitored::Scalar<double>(NameH,0.0);
	      btag->loglikelihoodratio("IP3D", wIP3D);
	      ATH_MSG_DEBUG("        wIP3D: " << wIP3D);
	      fill("TrigBjetMonitor",wIP3D);

	      NameH = "wSV1_Rbu_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto wSV1 = Monitored::Scalar<double>(NameH,0.0);
	      btag->loglikelihoodratio("SV1", wSV1);
	      ATH_MSG_DEBUG("        wSV1: " << wSV1);
	      fill("TrigBjetMonitor",wSV1);

	      NameH = "wCOMB_Rbu_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto wCOMB = Monitored::Scalar<double>(NameH,0.0);
	      wCOMB = wIP3D+wSV1;
	      ATH_MSG_DEBUG("        wCOMB: " << wCOMB);
	      fill("TrigBjetMonitor",wCOMB);

	      // Discriminants
	      NameH = "wMV2c10_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto wMV2c10 = Monitored::Scalar<double>(NameH,0.0);
	      wMV2c10 = btag->auxdata<double>("MV2c10_discriminant");
	      ATH_MSG_DEBUG("        wMV2c10: " << wMV2c10);
	      fill("TrigBjetMonitor",wMV2c10);

	      // SV1 variables (credit LZ)
	      NameH = "xNVtx_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto svp_n2t = Monitored::Scalar<int>(NameH,0.0);
	      btag->variable<int>("SV1", "N2Tpair", svp_n2t);
	      ATH_MSG_DEBUG("        svp_n2t: " << svp_n2t);
	      fill("TrigBjetMonitor",svp_n2t);

	      NameH = "xMVtx_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto svp_mass = Monitored::Scalar<float>(NameH,0.0);
	      btag->variable<float>("SV1", "masssvx", svp_mass);
	      ATH_MSG_DEBUG("        svp_mass: " << svp_mass );
	      svp_mass *= 1.e-3;
	      ATH_MSG_DEBUG("        svp_mass: " << svp_mass );
	      fill("TrigBjetMonitor",svp_mass);

	      NameH = "xEVtx_tr_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto svp_efrc = Monitored::Scalar<float>(NameH,0.0);
	      btag->variable<float>("SV1", "efracsvx", svp_efrc);
	      ATH_MSG_DEBUG("        svp_efrc: " << svp_efrc);
	      fill("TrigBjetMonitor",svp_efrc);

	    } // if (ijet == 0)

493
	    ijet++;
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559

	    // Tracks associated to triggered jets ( featurs = onlinejets ) courtesy of Tim Martin on 12/05/2020 
	    const auto track_it_pair = m_trigDec->associateToEventView(theTracks, jetLinkInfo.source, "roi");
	    const xAOD::TrackParticleContainer::const_iterator start_it = track_it_pair.first;
	    const xAOD::TrackParticleContainer::const_iterator end_it = track_it_pair.second;

	    int count = 0;
	    for ( xAOD::TrackParticleContainer::const_iterator it = start_it; it != end_it; ++it) {
	      count++;
	      ATH_MSG_DEBUG( " Track " << count << " with pT " << (*it)->pt() <<" from BJet with pT " << (*jetLinkInfo.link)->pt() );
	      ATH_MSG_DEBUG( " Track " << count << " with pT/eta/phi " << (*it)->pt() << "/" << (*it)->eta() << "/" << (*it)->phi() );
	      ATH_MSG_DEBUG( " Track " << count << " with d0/sigd0 " << (*it)->d0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 0) );
	      ATH_MSG_DEBUG( " Track " << count << " with z0/sigz0 " << (*it)->z0() << "/" << Amg::error((*it)->definingParametersCovMatrix(), 1) );
	      std::string NameH = "trkPt_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto trkPt = Monitored::Scalar<float>(NameH,0.0);
	      trkPt = ((*it)->pt())*1.e-3;
	      ATH_MSG_DEBUG("        trkPt: " << trkPt);
	      fill("TrigBjetMonitor",trkPt);
	      NameH = "trkEta_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto trkEta = Monitored::Scalar<float>(NameH,0.0);
	      trkEta = (*it)->eta();
	      NameH = "trkPhi_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto trkPhi = Monitored::Scalar<float>(NameH,0.0);
	      trkPhi = (*it)->phi();
	      ATH_MSG_DEBUG("        trkEta: " << trkEta << " trkPhi : " << trkPhi);
	      fill("TrigBjetMonitor",trkEta,trkPhi);
	      NameH = "d0_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto d0 = Monitored::Scalar<float>(NameH,0.0);
	      d0 = (*it)->d0();
	      ATH_MSG_DEBUG("        d0: " << d0);
	      fill("TrigBjetMonitor",d0);
	      NameH = "z0_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto z0 = Monitored::Scalar<float>(NameH,0.0);
	      z0 = (*it)->z0();
	      ATH_MSG_DEBUG("        z0: " << z0);
	      fill("TrigBjetMonitor",z0);
	      NameH = "ed0_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto ed0 = Monitored::Scalar<float>(NameH,0.0);
	      ed0 = Amg::error((*it)->definingParametersCovMatrix(), 0);
	      ATH_MSG_DEBUG("        ed0: " << ed0);
	      fill("TrigBjetMonitor",ed0);
	      NameH = "ez0_"+trigName;
	      ATH_MSG_DEBUG( " NameH: " << NameH  );
	      auto ez0 = Monitored::Scalar<float>(NameH,0.0);
	      ez0 = Amg::error((*it)->definingParametersCovMatrix(), 1);
	      ATH_MSG_DEBUG("        ez0: " << ez0);
	      fill("TrigBjetMonitor",ez0);
	    } // it on tracks
	    ATH_MSG_DEBUG( "  Number of tracks: " << count );
	    itrack += count;

	  } // jetLinkInfo from onlinejets

	  ATH_MSG_DEBUG("  Total number of triggered b-jets: " << ijet << " nJet : " << nJet);
	  ATH_MSG_DEBUG(" Total number of triggered tracks associated to the b-jets: " << itrack);
	  std::string nTrackH = "nTrack_"+trigName;
	  auto nTrack = Monitored::Scalar<int>(nTrackH,0.0);
	  nTrack = itrack;
	  fill("TrigBjetMonitor",nTrack);

560
	} //bjet or mujet
561

562
      } // else Run3  
563

564
    } else {
565
      ATH_MSG_DEBUG( " Trigger chain from AllChains list: " << trigName << " has not fired "  );
566
    } // trigger not fired
567
    
568

569
  } // for AllChains
Elemer Nagy's avatar
Elemer Nagy committed
570
571
572

    return StatusCode::SUCCESS;
}