HLTBjetMonTool.cxx 66.5 KB
Newer Older
1
/*
Elemer Nagy's avatar
Elemer Nagy committed
2
  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
4
5
6
7
8
9
10
11
*/

// ***************************************************
//
// NAME:     HLTBjetMonTool.cxx
// PACKAGE:  Trigger/TrigMonitoring/TrigBjetMonitoring
//
// AUTHOR:   Andrea Coccaro
// EMAIL:    Andrea.Coccaro@cern.ch
12
//
13
14
15
// REVISED for RUN2: Elemer Nagy
// EMAIL:            Elemer.Nagy@cern.ch
//
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ***************************************************

#include "GaudiKernel/IJobOptionsSvc.h"
#include "AthenaMonitoring/AthenaMonManager.h"
#include "AthenaMonitoring/ManagedMonitorToolTest.h"
#include "AthenaMonitoring/ManagedMonitorToolBase.h"   //EN

#include "JetEvent/JetCollection.h"
#include "FourMomUtils/P4DescendingSorters.h"

#include "JetUtils/JetCaloQualityUtils.h"

#include "muonEvent/Muon.h"
#include "muonEvent/MuonContainer.h"
#include "Particle/TrackParticleContainer.h"

#include "GeoPrimitives/GeoPrimitives.h"

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


#include "TH1F.h"
#include "TH2F.h"
#include "TGraph.h"
#include "TMath.h"
#include "TLorentzVector.h"

#include <vector>
45
#include <map>
46
/* Shaun Roe says it is alread included elsewhere so no need to be here
47
48
49
50
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
51
52
53
*/
// #include <math.h> // Shaun Roe says the use of all '.h' headers of the C++ standard library is deprecated
#include <cmath>
54

55
56
57
58
#include "xAODBTagging/BTaggingAuxContainer.h"
#include "xAODBTagging/BTaggingContainer.h"
#include "xAODBTagging/BTagging.h"

59
60
#include "xAODTracking/VertexContainer.h"

61
62
#include "xAODTracking/TrackParticle.h"

63
64
#include "xAODEventInfo/EventInfo.h"

65
#include "EventPrimitives/EventPrimitivesHelpers.h"
66
67


68

69
#include "HLTBjetMonTool.h"
70

71
#include "TrigInDetToolInterfaces/ITrigTrackJetFinderTool.h"
72
73
74
75
76
77
78
79
80
81
82
83

#include "GaudiKernel/ListItem.h"

namespace Analysis { class MuonContainer; }



//** ----------------------------------------------------------------------------------------------------------------- **//


HLTBjetMonTool::HLTBjetMonTool(const std::string & type, const std::string & name, const IInterface* parent) :
  IHLTMonTool(type, name, parent),
84
  m_trackJetFinderTool("TrigTrackJetFinderTool"),
85
  m_TriggerChainBjet{}, m_TriggerChainMujet{},
86
  m_TriggerChainBjet_x{}, m_TriggerChainMujet_x{},
87
88
  m_Chain2Dir{},
  m_Shifter_jSplit{}, m_Expert_jSplit{}, m_Shifter_jUnSplit{},  m_Expert_jUnSplit{}, m_Shifter_mujet{},m_Expert_mujet{},
89
90
  m_trigDec("Trig::TrigDecisionTool/TrigDecisionTool"),
  m_etCut(10.), m_sv1_infosource("SV1")
91
{
92
93
  declareProperty ("monitoring_bjet",       m_TriggerChainBjet_x);
  declareProperty ("monitoring_mujet",      m_TriggerChainMujet_x);
94
95
96
97
98
99
100
101
}


//** ----------------------------------------------------------------------------------------------------------------- **//


HLTBjetMonTool::~HLTBjetMonTool() {

102

103
104
}

105
106
107
108
109
110
111
//** ----------------------------------------------------------------------------------------------------------------- **//

float HLTBjetMonTool::phiCorr(float phi) {
  if (phi < -M_PI) phi += 2*M_PI;
  if (phi >  M_PI) phi -= 2*M_PI;
  return phi;
}
112
113
114
115
116
117

//** ----------------------------------------------------------------------------------------------------------------- **//


StatusCode HLTBjetMonTool::init() {

118
  ATH_CHECK(m_trackJetFinderTool.retrieve());
119

120
  ATH_MSG_INFO("in HLTBjetMonTool::init - retrieved tool: " << m_trackJetFinderTool);
121
122

  m_etCut = 10.;
123
  ATH_MSG_INFO(" ===> in HLTBjetMonTool::init - Muon-jet parameters: m_etCut = " << m_etCut);
124
125

  m_sv1_infosource = "SV1";
126
  ATH_MSG_INFO(" ===> in HLTBjetMonTool::init - SV1  parameters: inputSV1SourceName = "  <<  m_sv1_infosource);
127

128
129
  ATH_CHECK( m_offlineVertexContainerKey.initialize() );
  ATH_CHECK( m_onlineVertexContainerKey.initialize() );
130
  ATH_CHECK( m_onlineTrackContainerKey.initialize() );
131
  ATH_CHECK( m_onlineBTaggingContainerKey.initialize() );
132

133
134
135
136
137
138
139
140
141
142
143
  return StatusCode::SUCCESS;
}


//** ----------------------------------------------------------------------------------------------------------------- **//



#ifdef ManagedMonitorToolBase_Uses_API_201401
StatusCode HLTBjetMonTool::proc(){
#else
144
  StatusCode HLTBjetMonTool::proc(bool endOfEventsBlock, bool endOfLumiBlock, bool endOfRun){
145
#endif
146

147
    ATH_MSG_INFO("in HLTBjetMonTool::proc");
148
149
150
151
152
153
154
155
156

  return StatusCode::SUCCESS;

  }


#ifdef ManagedMonitorToolBase_Uses_API_201401
StatusCode HLTBjetMonTool::book(){
#else
157
  StatusCode HLTBjetMonTool::book(bool newEventsBlock, bool newLumiBlock, bool newRun){
158
159
#endif

160

161
162
    ATH_MSG_INFO("HLTBjetMonTool::book");
    ATH_MSG_INFO(" entered HLTBjetMonTool::book");
163

164
    addMonGroup(new MonGroup(this,"HLT/BjetMon", run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
165

166
    ATH_MSG_INFO("in HLTBjetMonTool::book added directory HLT/BjetMon, run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED);
167

168
    ATH_MSG_INFO("in HLTBjetMonTool::book newRun: " << newRunFlag() );
169
170


171

172
    if(newRunFlag()){
173

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
      //#define TestOnTrigConf

      // Decode extended TriggerChain vectors from the python config file
      // Create conventional TriggerChain vectors
      // Verify if a chain is not configured, in that case discard it

      int size_TriggerChainBjet = m_TriggerChainBjet_x.size();
      int size_TriggerChainMujet = m_TriggerChainMujet_x.size();
      std::string chainName, folderName;

      ATH_MSG_INFO("         Extended Chain Name sizes - Bjet: " << size_TriggerChainBjet << " MuJet: " << size_TriggerChainMujet );
      for (int i =0; i<size_TriggerChainBjet; i++){
	chainName = m_TriggerChainBjet_x.at(i);
	ATH_MSG_INFO("         Chain number: " << i << " Bjet Chain Name: " << chainName );
	// Investigate by the 1st character which folder should be assigned
	if (chainName.substr(0,1) == "E") {
	  chainName = chainName.substr (2);
#ifdef TestOnTrigConf
	  if ( (m_trigDec->getListOfTriggers( chainName)).empty() ) continue;
#endif
	  m_TriggerChainBjet.push_back(chainName);
	  m_Chain2Dir[chainName] = "Expert";
	} else if (chainName.substr(0,1) == "S") {
	  chainName = chainName.substr (2);
#ifdef TestOnTrigConf
	  if ( (m_trigDec->getListOfTriggers( chainName)).empty() ) continue;
#endif
	  m_TriggerChainBjet.push_back(chainName);
	  m_Chain2Dir[chainName] = "Shifter";
	} else {
	  ATH_MSG_INFO("         Chain number: " << i << " Bjet Chain Name: " << chainName << " is not assigned to Expert or Shifter folders !!" );
	  return StatusCode::FAILURE;
	} // else
	ATH_MSG_DEBUG("         Chain number: " << i << " Bjet Chain Name: " << chainName );
      }
      for (int i =0; i<size_TriggerChainMujet; i++){
	chainName = m_TriggerChainMujet_x.at(i);
	ATH_MSG_INFO("         Chain number: " << i << " Mujet Chain Name: " << chainName );
	// Investigate by the 1st character which folder should be assigned
	if (chainName.substr(0,1) == "E") {
	  chainName = chainName.substr (2);
#ifdef TestOnTrigConf
	  if ( (m_trigDec->getListOfTriggers( chainName)).empty() ) continue;
#endif
	  m_TriggerChainMujet.push_back(chainName);
	  m_Chain2Dir[chainName] = "Expert";
	} else if (chainName.substr(0,1) == "S") {
	  chainName = chainName.substr (2);
#ifdef TestOnTrigConf
	  if ( (m_trigDec->getListOfTriggers( chainName)).empty() ) continue;
#endif
	  m_TriggerChainMujet.push_back(chainName);
	  m_Chain2Dir[chainName] = "Shifter";
	} else {
	  ATH_MSG_INFO("         Chain number: " << i << " Mujet Chain Name: " << chainName << " is not assigned to Expert or Shifter folders !!" );
	  return StatusCode::FAILURE;
	} // else
	ATH_MSG_DEBUG("         Chain number: " << i << " Mujet Chain Name: " << chainName );
      }


  // Look for the created TriggerChain vector - if it is empty and if the triggers are configured

      size_TriggerChainBjet = m_TriggerChainBjet.size();
      size_TriggerChainMujet = m_TriggerChainMujet.size();
      ATH_MSG_INFO("         Chain Name sizes - Bjet: " << size_TriggerChainBjet << " MuJet: " << size_TriggerChainMujet );
      if ( (size_TriggerChainBjet+size_TriggerChainMujet) <= 0) {
	ATH_MSG_INFO( " No trigger chain is configured for this run ==> Stop monitoring " );
	return StatusCode::FAILURE;
      }
      for (int i =0; i<size_TriggerChainBjet; i++){
	chainName = m_TriggerChainBjet.at(i);
	ATH_MSG_INFO("         Chain number: " << i << " Bjet Chain Name: " << chainName );
	std::vector<std::string> selectChains  = m_trigDec->getListOfTriggers( chainName );
	ATH_MSG_DEBUG( " In HLTBjetMonTool::book(): Trigger chain " << chainName << " Size of selectChains " << selectChains.size());
      }
      for (int i =0; i<size_TriggerChainMujet; i++){
	chainName = m_TriggerChainMujet.at(i);
	ATH_MSG_INFO("         Chain number: " << i << " Mujet Chain Name: " << chainName );
	std::vector<std::string> selectChains  = m_trigDec->getListOfTriggers( chainName );
	ATH_MSG_DEBUG( " In HLTBjetMonTool::book(): Trigger chain " << chainName << " Size of selectChains " << selectChains.size());
      }

      // Check if folder assignment is made for all chains - if not stop the program
      // Regroup chain names with identical histograms

      std::map<std::string,std::string>::iterator it = m_Chain2Dir.begin();
      while (it != m_Chain2Dir.end()) {
	ATH_MSG_DEBUG(it->first << " :: " << it->second );
	it++;
      }
      std::map<std::string,std::string>::iterator p;
      for (const auto & chainName:m_TriggerChainBjet){     // Shaun Roe 21/9/16
	p = m_Chain2Dir.find(chainName);
	if ( p != m_Chain2Dir.end() ) {
	  folderName = p->second;
	} else {
	  ATH_MSG_INFO(" Chain Name " << chainName << " has no folder name - verify HLTBjetMonTool::book() !!!" );
	  return StatusCode::FAILURE;
	}
	ATH_MSG_INFO( " Chain name " << chainName << " is in folder " << folderName);
	if ( (folderName != "Expert") && (folderName != "Shifter") ){
	  ATH_MSG_INFO( " Chain name " << chainName << " is neither in Expert nor in Shifter folder - verify HLTBjetMonTool::book() !!!");
	  return StatusCode::FAILURE;
	} //if
	std::size_t found = chainName.find("split");
	if (found!=std::string::npos) {
	  if (folderName == "Shifter") m_Shifter_jSplit.push_back(chainName);
	  if (folderName == "Expert") m_Expert_jSplit.push_back(chainName);
	} else {
	  if (folderName == "Shifter") m_Shifter_jUnSplit.push_back(chainName);
	  if (folderName == "Expert") m_Expert_jUnSplit.push_back(chainName);
	}
      } //i Bjet
      for (const auto & chainName:m_TriggerChainMujet){    // Shaun Roe 21/9/16
	p = m_Chain2Dir.find(chainName);
	if ( p != m_Chain2Dir.end() ) {
	  folderName = p->second;
	} else {
	  ATH_MSG_INFO(" Chain Name " << chainName << " has no folder name - verify HLTBjetMonTool::book() !!!" );
	  return StatusCode::FAILURE;
	}
	ATH_MSG_INFO( " Chain name " << chainName << " is in folder " << folderName);
	if (folderName == "Shifter") m_Shifter_mujet.push_back(chainName);
	else if (folderName == "Expert") m_Expert_mujet.push_back(chainName);
	else {
	  ATH_MSG_INFO( " Chain name " << chainName << " is neither in Expert nor in Shifter folder - verify HLTBjetMonTool::book() !!!");
	  return StatusCode::FAILURE;
	} //if
      } //i Mujet

      for (unsigned int i = 0; i< m_Shifter_mujet.size(); i++) {
	ATH_MSG_DEBUG(" m_Shifter_mujet: " << m_Shifter_mujet.at(i) );
      }
      for (unsigned int i = 0; i< m_Expert_mujet.size(); i++) {
	ATH_MSG_DEBUG(" m_Expert_mujet: " << m_Expert_mujet.at(i) );
      }
      for (unsigned int i = 0; i< m_Shifter_jUnSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Shifter_jUnSplit: " << m_Shifter_jUnSplit.at(i) );
      }
      for (unsigned int i = 0; i< m_Expert_jUnSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Expert_jUnSplit: " << m_Expert_jUnSplit.at(i) );
      }
      for (unsigned int i = 0; i< m_Shifter_jSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Shifter_jSplit: " << m_Shifter_jSplit.at(i) );
      }
      for (unsigned int i = 0; i< m_Expert_jSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Expert_jSplit: " << m_Expert_jSplit.at(i) );
      }

Elemer Nagy's avatar
Elemer Nagy committed
324
      float PVx_low(-1.5), PVx_high(+1.5), PVy_low(-1.5), PVy_high(+1.5), PVz_low(-250.), PVz_high(+250.);
325

326
      // Shifter Folders
327

328
      addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter", run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
329
      ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter, run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
330
331

      //    Off-line
332
333
334
335
      addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter/Offline", run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
      ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter/Offline, run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
      // PV
      addHistogram(new TH1F("nPV","Number of offline PV per event", 100, 0., 100.));
336
337
      addHistogram(new TH1F("PVx","offline xPV", 200, PVx_low, PVx_high));
      addHistogram(new TH1F("PVy","offline yPV", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
338
      addHistogram(new TH1F("PVz","offline zPV", 500, PVz_low, PVz_high));
339
340

      //    On-line SplitChains
341
342
343
344
345
346
347
348
      //      addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter/Online_SplitChains", run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
      //      ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter/Online_SplitChains, run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
      for (unsigned int i = 0; i< m_Shifter_jSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Shifter_jSplit: " << m_Shifter_jSplit.at(i) );
	addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter/"+m_Shifter_jSplit.at(i), run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
	ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter/" << m_Shifter_jSplit.at(i) << " run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
	// PV
	addHistogram(new TH1F(("nPV_tr_"+m_Shifter_jSplit.at(i)).c_str(),"Number of online PV per event for xPrimVtx", 101, -1., 100.));
349
350
	addHistogram(new TH1F(("PVx_tr_"+m_Shifter_jSplit.at(i)).c_str(),"online (1st) xPV for xPrimVtx", 200, PVx_low, PVx_high));
	addHistogram(new TH1F(("PVy_tr_"+m_Shifter_jSplit.at(i)).c_str(),"online (1st) yPV for xPrimVtx", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
351
	addHistogram(new TH1F(("PVz_tr_"+m_Shifter_jSplit.at(i)).c_str(),"online (1st) zPV for xPrimVtx", 500, PVz_low, PVz_high));
352
	addHistogram(new TH1F(("nPV_tr_Hist_"+m_Shifter_jSplit.at(i)).c_str(),"Number of online PV per event for EFHistoPrmVtx", 101, -1., 100.));
353
354
	addHistogram(new TH1F(("PVx_tr_Hist_"+m_Shifter_jSplit.at(i)).c_str(),"online (1st) xPV for EFHistoPrmVtx", 200, PVx_low, PVx_high));
	addHistogram(new TH1F(("PVy_tr_Hist_"+m_Shifter_jSplit.at(i)).c_str(),"online (1st) yPV for EFHistoPrmVtx", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
355
	addHistogram(new TH1F(("PVz_tr_Hist_"+m_Shifter_jSplit.at(i)).c_str(),"online (1st) zPV for EFHistoPrmVtx", 500, PVz_low, PVz_high));
356
	addHistogram(new TH1F(("diffzPV0offPVon_"+m_Shifter_jSplit.at(i)).c_str(),"z difference of the 1st offline and (1st) online PV", 200, -1., 1.));
357
	// Tracks
358
359
	addHistogram(new TH1F(("nTrack_"+m_Shifter_jSplit.at(i)).c_str(),"Number of tracks", 40, 0., 40.));
	addHistogram(new TH1F(("d0_"+m_Shifter_jSplit.at(i)).c_str(),"d0 of tracks", 200, -2., 2.));
Elemer Nagy's avatar
Elemer Nagy committed
360
	addHistogram(new TH1F(("z0_"+m_Shifter_jSplit.at(i)).c_str(),"z0 of tracks", 500, PVz_low, PVz_high));
361
362
363
364
365
366
367
368
	addHistogram(new TH1F(("ed0_"+m_Shifter_jSplit.at(i)).c_str(),"err_d0 of tracks", 200, 0., 1.));
	addHistogram(new TH1F(("ez0_"+m_Shifter_jSplit.at(i)).c_str(),"err_z0 of tracks", 200, 0., 5.));
	addHistogram(new TH1F(("diffz0PV0_"+m_Shifter_jSplit.at(i)).c_str(),"z0 of tracks wrt 1st offline PV", 200, -10., 10.));
	addHistogram(new TH1F(("sigz0PV_"+m_Shifter_jSplit.at(i)).c_str(),"z0-PV/errz0", 200, -20., 20.));
	addHistogram(new TH1F(("trkPt_"+m_Shifter_jSplit.at(i)).c_str(),"Pt of tracks", 100, 0., 50.));
	addHistogram(new TH2F(("trkEtaPhi_"+m_Shifter_jSplit.at(i)).c_str(),"Phi vs Eta of tracks", 20, -5., 5., 20, -3.1416, 3.1416));
	//   Jets
	addHistogram(new TH1F(("nJet_"+m_Shifter_jSplit.at(i)).c_str(),"Number of jets", 40, 0., 40.));
369
	addHistogram(new TH1F(("jetPt_"+m_Shifter_jSplit.at(i)).c_str(),"Pt of jets", 100, 0., 750.));
370
	addHistogram(new TH2F(("jetEtaPhi_"+m_Shifter_jSplit.at(i)).c_str(),"Phi vs Eta of jets", 20, -5., 5., 20, -3.1416, 3.1416));
371
	//   B-jets
372
373
374
375
376
377
	addHistogram(new TH1F(("IP3D_pu_tr_"+m_Shifter_jSplit.at(i)).c_str(),"IP3D_pu probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pb_tr_"+m_Shifter_jSplit.at(i)).c_str(),"IP3D_pb probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pc_tr_"+m_Shifter_jSplit.at(i)).c_str(),"IP3D_pc probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("wIP3D_Rbu_tr_"+m_Shifter_jSplit.at(i)).c_str(),"LogLH IP3D_pb/IP3D_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wSV1_Rbu_tr_"+m_Shifter_jSplit.at(i)).c_str(),"LogLH SV1_pb/SV1_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wCOMB_Rbu_tr_"+m_Shifter_jSplit.at(i)).c_str(),"LogLH IP3D+SV1 probability ratio distribution", 200, -4., 6.));
378
	addHistogram(new TH1F(("wMV2c00_tr_"+m_Shifter_jSplit.at(i)).c_str(),"MV2hybrid discriminant", 200, -1., 1.));
379
380
381
382
383
384
	addHistogram(new TH1F(("wMV2c10_tr_"+m_Shifter_jSplit.at(i)).c_str(),"MV2c10 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("wMV2c20_tr_"+m_Shifter_jSplit.at(i)).c_str(),"MV2c20 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("xMVtx_tr_"+m_Shifter_jSplit.at(i)).c_str(),"SV1 mass - all SV1", 50, 0., 10.));
	addHistogram(new TH1F(("xEVtx_tr_"+m_Shifter_jSplit.at(i)).c_str(),"SV1 E-fraction - all SV1", 50, 0., 1.));
	addHistogram(new TH1F(("xNVtx_tr_"+m_Shifter_jSplit.at(i)).c_str(),"Number of 2-track SV1 - all SV1", 40, 0., 40.));
      }
385

386
387
388
389
390
391
392
393
394
      //    On-line UnSplitChains
      //      addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter/Online_UnSplitChains", run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
      //      ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter/Online_UnSplitChains, run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
      for (unsigned int i = 0; i< m_Shifter_jUnSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Shifter_jUnSplit: " << m_Shifter_jUnSplit.at(i) );
	addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter/"+m_Shifter_jUnSplit.at(i), run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
	ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter/" << m_Shifter_jUnSplit.at(i) << " run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
	// PV
	addHistogram(new TH1F(("nPV_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"Number of online PV per event", 101, -1., 100.));
395
396
	addHistogram(new TH1F(("PVx_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"online (1st) xPV", 200, PVx_low, PVx_high));
	addHistogram(new TH1F(("PVy_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"online (1st) yPV", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
397
	addHistogram(new TH1F(("PVz_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"online (1st) zPV", 500, PVz_low, PVz_high));
398
	addHistogram(new TH1F(("diffzPV0offPVon_"+m_Shifter_jUnSplit.at(i)).c_str(),"z difference of the 1st offline and (1st) online PV", 200, -1., 1.));
399
	// Tracks
400
401
	addHistogram(new TH1F(("nTrack_"+m_Shifter_jUnSplit.at(i)).c_str(),"Number of tracks", 40, 0., 40.));
	addHistogram(new TH1F(("d0_"+m_Shifter_jUnSplit.at(i)).c_str(),"d0 of tracks", 200, -2., 2.));
Elemer Nagy's avatar
Elemer Nagy committed
402
	addHistogram(new TH1F(("z0_"+m_Shifter_jUnSplit.at(i)).c_str(),"z0 of tracks", 500, PVz_low, PVz_high));
403
404
405
406
407
408
409
410
	addHistogram(new TH1F(("ed0_"+m_Shifter_jUnSplit.at(i)).c_str(),"err_d0 of tracks", 200, 0., 1.));
	addHistogram(new TH1F(("ez0_"+m_Shifter_jUnSplit.at(i)).c_str(),"err_z0 of tracks", 200, 0., 5.));
	addHistogram(new TH1F(("diffz0PV0_"+m_Shifter_jUnSplit.at(i)).c_str(),"z0 of tracks wrt 1st offline PV", 200, -10., 10.));
	addHistogram(new TH1F(("sigz0PV_"+m_Shifter_jUnSplit.at(i)).c_str(),"z0-PV/errz0", 200, -20., 20.));
	addHistogram(new TH1F(("trkPt_"+m_Shifter_jUnSplit.at(i)).c_str(),"Pt of tracks", 100, 0., 50.));
	addHistogram(new TH2F(("trkEtaPhi_"+m_Shifter_jUnSplit.at(i)).c_str(),"Phi vs Eta of tracks", 20, -5., 5., 20, -3.1416, 3.1416));
	//   Jets
	addHistogram(new TH1F(("nJet_"+m_Shifter_jUnSplit.at(i)).c_str(),"Number of jets", 40, 0., 40.));
411
	addHistogram(new TH1F(("jetPt_"+m_Shifter_jUnSplit.at(i)).c_str(),"Pt of jets", 100, 0., 750.));
412
	addHistogram(new TH2F(("jetEtaPhi_"+m_Shifter_jUnSplit.at(i)).c_str(),"Phi vs Eta of jets", 20, -5., 5., 20, -3.1416, 3.1416));
413
	//   B-jets
414
415
416
417
418
419
	addHistogram(new TH1F(("IP3D_pu_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"IP3D_pu probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pb_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"IP3D_pb probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pc_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"IP3D_pc probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("wIP3D_Rbu_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"LogLH IP3D_pb/IP3D_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wSV1_Rbu_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"LogLH SV1_pb/SV1_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wCOMB_Rbu_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"LogLH IP3D+SV1 probability ratio distribution", 200, -4., 6.));
420
	addHistogram(new TH1F(("wMV2c00_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"MV2hybrid discriminant", 200, -1., 1.));
421
422
423
424
425
	addHistogram(new TH1F(("wMV2c10_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"MV2c10 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("wMV2c20_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"MV2c20 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("xMVtx_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"SV1 mass - all SV1", 50, 0., 10.));
	addHistogram(new TH1F(("xEVtx_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"SV1 E-fraction - all SV1", 50, 0., 1.));
	addHistogram(new TH1F(("xNVtx_tr_"+m_Shifter_jUnSplit.at(i)).c_str(),"Number of 2-track SV1 - all SV1", 40, 0., 40.));
426
      }
427
428
429
430
431
432
433
      //    On-line MuChains
      for (unsigned int i = 0; i< m_Shifter_mujet.size(); i++) {
	ATH_MSG_DEBUG(" m_Shifter_mujet: " << m_Shifter_mujet.at(i) );
	addMonGroup(new MonGroup(this,"HLT/BjetMon/Shifter/"+m_Shifter_mujet.at(i), run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
	ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Shifter/" << m_Shifter_mujet.at(i) << " run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
	//   Jets
	addHistogram(new TH1F(("nJet_"+m_Shifter_mujet.at(i)).c_str(),"Number of jets", 40, 0., 40.));
434
	addHistogram(new TH1F(("jetPt_"+m_Shifter_mujet.at(i)).c_str(),"Pt of jets", 100, 0., 750.));
435
436
437
438
439
440
441
442
	addHistogram(new TH2F(("jetEtaPhi_"+m_Shifter_mujet.at(i)).c_str(),"Phi vs Eta of jets", 20, -5., 5., 20, -3.1416, 3.1416));
	// Muons
	addHistogram(new TH1F(("nMuon_"+m_Shifter_mujet.at(i)).c_str(),"Number of muons", 20, 0., 20.));
	addHistogram(new TH1F(("muonPt_"+m_Shifter_mujet.at(i)).c_str(),"Pt of muons", 100, 0., 250.));
	addHistogram(new TH2F(("muonEtaPhi_"+m_Shifter_mujet.at(i)).c_str(),"Phi vs Eta of muons", 20, -5., 5., 20, -3.1416, 3.1416));
	addHistogram(new TH1F(("DeltaRAll_"+m_Shifter_mujet.at(i)).c_str(),"DeltaR between muon and any jet", 100, 0., 6.));
	addHistogram(new TH1F(("DeltaZAll_"+m_Shifter_mujet.at(i)).c_str(),"DeltaZ between muon and any jet", 100, 0., 10.));
      }
443

444
      // Expert Folders
445

446
447
      addMonGroup(new MonGroup(this,"HLT/BjetMon/Expert", run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
      ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Expert, run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
448

449

450
451
452
453
454
455
456
      //    On-line SplitChains
      for (unsigned int i = 0; i< m_Expert_jSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Expert_jSplit: " << m_Expert_jSplit.at(i) );
	addMonGroup(new MonGroup(this,"HLT/BjetMon/Expert/"+m_Expert_jSplit.at(i), run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
	ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Expert/" << m_Expert_jSplit.at(i) << " run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
	// PV
	addHistogram(new TH1F(("nPV_tr_"+m_Expert_jSplit.at(i)).c_str(),"Number of online PV per event for xPrimVtx", 101, -1., 100.));
457
458
	addHistogram(new TH1F(("PVx_tr_"+m_Expert_jSplit.at(i)).c_str(),"online (1st) xPV for xPrimVtx", 200, PVx_low, PVx_high));
	addHistogram(new TH1F(("PVy_tr_"+m_Expert_jSplit.at(i)).c_str(),"online (1st) yPV for xPrimVtx", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
459
	addHistogram(new TH1F(("PVz_tr_"+m_Expert_jSplit.at(i)).c_str(),"online (1st) zPV for xPrimVtx", 500, PVz_low, PVz_high));
460
	addHistogram(new TH1F(("nPV_tr_Hist_"+m_Expert_jSplit.at(i)).c_str(),"Number of online PV per event for EFHistoPrmVtx", 101, -1., 100.));
461
462
	addHistogram(new TH1F(("PVx_tr_Hist_"+m_Expert_jSplit.at(i)).c_str(),"online (1st) xPV for EFHistoPrmVtx", 200, PVx_low, PVx_high));
	addHistogram(new TH1F(("PVy_tr_Hist_"+m_Expert_jSplit.at(i)).c_str(),"online (1st) yPV for EFHistoPrmVtx", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
463
	addHistogram(new TH1F(("PVz_tr_Hist_"+m_Expert_jSplit.at(i)).c_str(),"online (1st) zPV for EFHistoPrmVtx", 500, PVz_low, PVz_high));
464
	addHistogram(new TH1F(("diffzPV0offPVon_"+m_Expert_jSplit.at(i)).c_str(),"z difference of the 1st offline and (1st) online PV", 200, -1., 1.));
465
	// Tracks
466
467
	addHistogram(new TH1F(("nTrack_"+m_Expert_jSplit.at(i)).c_str(),"Number of tracks", 40, 0., 40.));
	addHistogram(new TH1F(("d0_"+m_Expert_jSplit.at(i)).c_str(),"d0 of tracks", 200, -2., 2.));
Elemer Nagy's avatar
Elemer Nagy committed
468
	addHistogram(new TH1F(("z0_"+m_Expert_jSplit.at(i)).c_str(),"z0 of tracks", 500, PVz_low, PVz_high));
469
470
471
472
473
474
475
476
	addHistogram(new TH1F(("ed0_"+m_Expert_jSplit.at(i)).c_str(),"err_d0 of tracks", 200, 0., 1.));
	addHistogram(new TH1F(("ez0_"+m_Expert_jSplit.at(i)).c_str(),"err_z0 of tracks", 200, 0., 5.));
	addHistogram(new TH1F(("diffz0PV0_"+m_Expert_jSplit.at(i)).c_str(),"z0 of tracks wrt 1st offline PV", 200, -10., 10.));
	addHistogram(new TH1F(("sigz0PV_"+m_Expert_jSplit.at(i)).c_str(),"z0-PV/errz0", 200, -20., 20.));
	addHistogram(new TH1F(("trkPt_"+m_Expert_jSplit.at(i)).c_str(),"Pt of tracks", 100, 0., 50.));
	addHistogram(new TH2F(("trkEtaPhi_"+m_Expert_jSplit.at(i)).c_str(),"Phi vs Eta of tracks", 20, -5., 5., 20, -3.1416, 3.1416));
	//   Jets
	addHistogram(new TH1F(("nJet_"+m_Expert_jSplit.at(i)).c_str(),"Number of jets", 40, 0., 40.));
477
	addHistogram(new TH1F(("jetPt_"+m_Expert_jSplit.at(i)).c_str(),"Pt of jets", 100, 0., 750.));
478
	addHistogram(new TH2F(("jetEtaPhi_"+m_Expert_jSplit.at(i)).c_str(),"Phi vs Eta of jets", 20, -5., 5., 20, -3.1416, 3.1416));
479
	//   B-jets
480
481
482
483
484
485
	addHistogram(new TH1F(("IP3D_pu_tr_"+m_Expert_jSplit.at(i)).c_str(),"IP3D_pu probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pb_tr_"+m_Expert_jSplit.at(i)).c_str(),"IP3D_pb probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pc_tr_"+m_Expert_jSplit.at(i)).c_str(),"IP3D_pc probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("wIP3D_Rbu_tr_"+m_Expert_jSplit.at(i)).c_str(),"LogLH IP3D_pb/IP3D_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wSV1_Rbu_tr_"+m_Expert_jSplit.at(i)).c_str(),"LogLH SV1_pb/SV1_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wCOMB_Rbu_tr_"+m_Expert_jSplit.at(i)).c_str(),"LogLH IP3D+SV1 probability ratio distribution", 200, -4., 6.));
486
	addHistogram(new TH1F(("wMV2c00_tr_"+m_Expert_jSplit.at(i)).c_str(),"MV2hybrid discriminant", 200, -1., 1.));
487
488
489
490
491
492
493
494
495
496
497
498
499
500
	addHistogram(new TH1F(("wMV2c10_tr_"+m_Expert_jSplit.at(i)).c_str(),"MV2c10 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("wMV2c20_tr_"+m_Expert_jSplit.at(i)).c_str(),"MV2c20 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("xMVtx_tr_"+m_Expert_jSplit.at(i)).c_str(),"SV1 mass - all SV1", 50, 0., 10.));
	addHistogram(new TH1F(("xEVtx_tr_"+m_Expert_jSplit.at(i)).c_str(),"SV1 E-fraction - all SV1", 50, 0., 1.));
	addHistogram(new TH1F(("xNVtx_tr_"+m_Expert_jSplit.at(i)).c_str(),"Number of 2-track SV1 - all SV1", 40, 0., 40.));
      }

      //    On-line UnSplitChains
      for (unsigned int i = 0; i< m_Expert_jUnSplit.size(); i++) {
	ATH_MSG_DEBUG(" m_Expert_jUnSplit: " << m_Expert_jUnSplit.at(i) );
	addMonGroup(new MonGroup(this,"HLT/BjetMon/Expert/"+m_Expert_jUnSplit.at(i), run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
	ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Expert/" << m_Expert_jUnSplit.at(i) << " run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
	// PV
	addHistogram(new TH1F(("nPV_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"Number of online PV per event", 101, -1., 100.));
501
502
	addHistogram(new TH1F(("PVx_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"online (1st) xPV", 200, PVx_low, PVx_high));
	addHistogram(new TH1F(("PVy_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"online (1st) yPV", 200, PVy_low, PVy_high));
Elemer Nagy's avatar
Elemer Nagy committed
503
	addHistogram(new TH1F(("PVz_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"online (1st) zPV", 500, PVz_low, PVz_high));
504
	addHistogram(new TH1F(("diffzPV0offPVon_"+m_Expert_jUnSplit.at(i)).c_str(),"z difference of the 1st offline and (1st) online PV", 200, -1., 1.));
505
	// Tracks
506
507
	addHistogram(new TH1F(("nTrack_"+m_Expert_jUnSplit.at(i)).c_str(),"Number of tracks", 40, 0., 40.));
	addHistogram(new TH1F(("d0_"+m_Expert_jUnSplit.at(i)).c_str(),"d0 of tracks", 200, -2., 2.));
Elemer Nagy's avatar
Elemer Nagy committed
508
	addHistogram(new TH1F(("z0_"+m_Expert_jUnSplit.at(i)).c_str(),"z0 of tracks", 500, PVz_low, PVz_high));
509
510
511
512
513
514
515
516
	addHistogram(new TH1F(("ed0_"+m_Expert_jUnSplit.at(i)).c_str(),"err_d0 of tracks", 200, 0., 1.));
	addHistogram(new TH1F(("ez0_"+m_Expert_jUnSplit.at(i)).c_str(),"err_z0 of tracks", 200, 0., 5.));
	addHistogram(new TH1F(("diffz0PV0_"+m_Expert_jUnSplit.at(i)).c_str(),"z0 of tracks wrt 1st offline PV", 200, -10., 10.));
	addHistogram(new TH1F(("sigz0PV_"+m_Expert_jUnSplit.at(i)).c_str(),"z0-PV/errz0", 200, -20., 20.));
	addHistogram(new TH1F(("trkPt_"+m_Expert_jUnSplit.at(i)).c_str(),"Pt of tracks", 100, 0., 50.));
	addHistogram(new TH2F(("trkEtaPhi_"+m_Expert_jUnSplit.at(i)).c_str(),"Phi vs Eta of tracks", 20, -5., 5., 20, -3.1416, 3.1416));
	//   Jets
	addHistogram(new TH1F(("nJet_"+m_Expert_jUnSplit.at(i)).c_str(),"Number of jets", 40, 0., 40.));
517
	addHistogram(new TH1F(("jetPt_"+m_Expert_jUnSplit.at(i)).c_str(),"Pt of jets", 100, 0., 750.));
518
	addHistogram(new TH2F(("jetEtaPhi_"+m_Expert_jUnSplit.at(i)).c_str(),"Phi vs Eta of jets", 20, -5., 5., 20, -3.1416, 3.1416));
519
	//   B-jets
520
521
522
523
524
525
	addHistogram(new TH1F(("IP3D_pu_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"IP3D_pu probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pb_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"IP3D_pb probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("IP3D_pc_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"IP3D_pc probability distribution", 200, 0., 1.));
	addHistogram(new TH1F(("wIP3D_Rbu_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"LogLH IP3D_pb/IP3D_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wSV1_Rbu_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"LogLH SV1_pb/SV1_pu probability ratio distribution", 200, -4., 6.));
	addHistogram(new TH1F(("wCOMB_Rbu_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"LogLH IP3D+SV1 probability ratio distribution", 200, -4., 6.));
526
	addHistogram(new TH1F(("wMV2c00_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"MV2hybrid discriminant", 200, -1., 1.));
527
528
529
530
531
532
	addHistogram(new TH1F(("wMV2c10_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"MV2c10 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("wMV2c20_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"MV2c20 discriminant", 200, -1., 1.));
	addHistogram(new TH1F(("xMVtx_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"SV1 mass - all SV1", 50, 0., 10.));
	addHistogram(new TH1F(("xEVtx_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"SV1 E-fraction - all SV1", 50, 0., 1.));
	addHistogram(new TH1F(("xNVtx_tr_"+m_Expert_jUnSplit.at(i)).c_str(),"Number of 2-track SV1 - all SV1", 40, 0., 40.));
      }
533

534
535
536
537
538
539
540
      //    On-line MuChains
      for (unsigned int i = 0; i< m_Expert_mujet.size(); i++) {
	ATH_MSG_DEBUG(" m_Expert_mujet: " << m_Expert_mujet.at(i) );
	addMonGroup(new MonGroup(this,"HLT/BjetMon/Expert/"+m_Expert_mujet.at(i), run, ManagedMonitorToolBase::ATTRIB_MANAGED)); //EN
	ATH_MSG_INFO("  in HLTBjetMonTool::book added directory HLT/BjetMon/Expert/" << m_Expert_mujet.at(i) << " run: " << run << " " << ManagedMonitorToolBase::ATTRIB_MANAGED );
	//   Jets
	addHistogram(new TH1F(("nJet_"+m_Expert_mujet.at(i)).c_str(),"Number of jets", 40, 0., 40.));
541
	addHistogram(new TH1F(("jetPt_"+m_Expert_mujet.at(i)).c_str(),"Pt of jets", 100, 0., 750.));
542
543
544
545
546
547
548
549
	addHistogram(new TH2F(("jetEtaPhi_"+m_Expert_mujet.at(i)).c_str(),"Phi vs Eta of jets", 20, -5., 5., 20, -3.1416, 3.1416));
	// Muons
	addHistogram(new TH1F(("nMuon_"+m_Expert_mujet.at(i)).c_str(),"Number of muons", 20, 0., 20.));
	addHistogram(new TH1F(("muonPt_"+m_Expert_mujet.at(i)).c_str(),"Pt of muons", 100, 0., 250.));
	addHistogram(new TH2F(("muonEtaPhi_"+m_Expert_mujet.at(i)).c_str(),"Phi vs Eta of muons", 20, -5., 5., 20, -3.1416, 3.1416));
	addHistogram(new TH1F(("DeltaRAll_"+m_Expert_mujet.at(i)).c_str(),"DeltaR between muon and any jet", 100, 0., 6.));
	addHistogram(new TH1F(("DeltaZAll_"+m_Expert_mujet.at(i)).c_str(),"DeltaZ between muon and any jet", 100, 0., 10.));
      }
550

551
    } // if newRunFlag
552
553
554
555



    return StatusCode::SUCCESS;
556
557
558
559
560
561
  }


//** ----------------------------------------------------------------------------------------------------------------- **//


562
  StatusCode HLTBjetMonTool::fill() {
563

564
    ATH_MSG_DEBUG("====> Entering HLTBjetMonTool::fill()" );
565

566

567
568
569
570
  ////////////////////////////////////
  //setCurrentMonGroup("HLT/BjetMon/Shifter");
  ////////////////////////////////////

571

572
  // Trigger (chain) name definition
573
574

  int size_TriggerChainBjet =m_TriggerChainBjet.size();
575
  int size_TriggerChainMujet =m_TriggerChainMujet.size();
576
577
  ATH_MSG_DEBUG( " Size of Bjet Trigger chain " << size_TriggerChainBjet );
  ATH_MSG_DEBUG( " Size of Mujet Trigger chain " << size_TriggerChainMujet );
578
  if ( (size_TriggerChainBjet <= 0) && (size_TriggerChainMujet <= 0) ) {
579
580
581
    return StatusCode::SUCCESS;
  }
  std::string chainName = "Not fired";
582
  std::vector<std::string> FiredChainNames;
583
584
585

  for (int i =0; i<size_TriggerChainBjet; i++){
    if (!getTDT()->isPassed(m_TriggerChainBjet.at(i))){
586
      ATH_MSG_DEBUG( " Trigger chain " << i << " " << m_TriggerChainBjet.at(i) << " has not fired." );
587
    } else {
588
      chainName = m_TriggerChainBjet.at(i);
589
      ATH_MSG_DEBUG( " Trigger chain " << i << " " << chainName << " has fired." );
590
      std::vector<std::string> selectChains  = m_trigDec->getListOfTriggers( chainName );
591
592
      ATH_MSG_DEBUG( " In HLTBjetMonTool::fill(): Trigger chain " << chainName << " fired. Size of selectChains " << selectChains.size());
      if ( not selectChains.empty() ) FiredChainNames.push_back(chainName); // test if chain is configured
593
    } // else
594
  } //i Bjet
595
596
597

  for (int i =0; i<size_TriggerChainMujet; i++){
    if (!getTDT()->isPassed(m_TriggerChainMujet.at(i))){
598
      ATH_MSG_DEBUG( " Trigger chain " << i << " " << m_TriggerChainMujet.at(i) << " has not fired." );
599
600
    } else {
      chainName = m_TriggerChainMujet.at(i);
601
      ATH_MSG_DEBUG( " Trigger chain " << i << " " << chainName << " has fired." );
602
      std::vector<std::string> selectChains  = m_trigDec->getListOfTriggers( chainName );
603
604
      ATH_MSG_DEBUG( " In HLTBjetMonTool::fill(): Trigger chain " << chainName << " fired. Size of selectChains " << selectChains.size());
      if ( not selectChains.empty() ) FiredChainNames.push_back(chainName); // test if chain is configured
605
    } // else
606
  } // i Mujet
607

608
  if ( not  FiredChainNames.empty() ) ATH_MSG_DEBUG( " " << FiredChainNames.size() << " trigger chains have fired: " );
609
  for (unsigned int i = 0; i< FiredChainNames.size(); i++) {
610
    ATH_MSG_DEBUG( FiredChainNames.at(i) );
611
  }
612

613
  if ( FiredChainNames.empty() ) {
614

615
    ATH_MSG_INFO(" ===> No trigger has fired neither for TriggerChainBjet of size: " << size_TriggerChainBjet
616
617
618
619
		 << " nor for TriggerChainMujet of size: " << size_TriggerChainMujet << " RETURN from HLTBjetMonTool::fill() ! " );
    return StatusCode::SUCCESS;
  } else {

620
    //    return StatusCode::SUCCESS;
621
622
623
624
625
626
627

    const xAOD::EventInfo* eventInfo = 0;
    CHECK( evtStore()->retrieve( eventInfo, "EventInfo") );
    bool MCflag = true;
    if ( !eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION) ) MCflag = false;
    ATH_MSG_DEBUG( " MCflag: " << MCflag );

628
629
630
    /* This sequence contains a now obsolate jetcontainer, namely "AntiKt4TruthJets" so it has to be taken out
    // Since truthjets may be used later, we leave here the sequence commented out, waiting for another
    //      container name which will replace "AntiKt4TruthJets" for truthjets
631
632
633
634
635
636
    // Get truth jets
    if (MCflag) {
      const xAOD::JetContainer* truthjets = 0;
      ATH_CHECK( evtStore()->retrieve(truthjets,"AntiKt4TruthJets") );
      ATH_MSG_DEBUG("RETRIEVED TRUTH JETS  - size: " << truthjets->size());
    } // MCflag
637
    */
638

639
640
    ATH_MSG_DEBUG("  ========= Start retrival of Offline histograms  ========== ");

641

642
643
644
645
    std::string HistDir = "/Offline";
    std::string HistExt = "";
    float offlinepvz(-1.e6);
    bool Eofflinepv(false);
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
    float offlinepvzFTK(-1.e6);
    bool EofflinepvFTK(false);

    if (getTDT()->getNavigationFormat() == "TriggerElement") { // Run 2 access a la Tim Martin

      // Get offline PV - non FTK
      const xAOD::VertexContainer* offlinepv = 0;
      if ( evtStore()->contains<xAOD::VertexContainer>("PrimaryVertices") ) {
	ATH_CHECK( evtStore()->retrieve(offlinepv, "PrimaryVertices") );
	ATH_MSG_DEBUG("RETRIEVED OFFLINE standard PV  - size: " << offlinepv->size());
	if ( offlinepv->size() ) {
	  Eofflinepv = true;
	  offlinepvz = offlinepv->front()->z();
	  ATH_MSG_DEBUG(" 1st zPV a la Carlo: " << offlinepvz);
	  hist("nPV"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill(offlinepv->size());
	  for (unsigned int j = 0; j<offlinepv->size(); j++){
	    hist("PVx"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill((*(offlinepv))[j]->x());
	    hist("PVy"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill((*(offlinepv))[j]->y());
	    hist("PVz"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill((*(offlinepv))[j]->z());
	  } // j
	} // if size
      } // evtStore
      //
      
      // Get offline PV - FTK
      const xAOD::VertexContainer* offlinepvFTK = 0;
      if ( evtStore()->contains<xAOD::VertexContainer>("FTK_VertexContainer") ) {
	ATH_CHECK( evtStore()->retrieve(offlinepvFTK, "FTK_VertexContainer") );
	ATH_MSG_DEBUG("RETRIEVED OFFLINE FTK PV  - size: " << offlinepvFTK->size());
	if ( offlinepvFTK->size() ) {
	  EofflinepvFTK = true;
	  offlinepvzFTK = offlinepvFTK->front()->z();
	  if (EofflinepvFTK) ATH_MSG_DEBUG(" 1st zPV FTK a la Carlo: " << offlinepvzFTK);
	} // if size
      } // evtStore
      //
      
    } else { // Run3 access a la Tim Martin

      SG::ReadHandle<xAOD::VertexContainer> offlinepv = SG::makeHandle( m_offlineVertexContainerKey);
      if (! offlinepv.isValid() ) {
	ATH_MSG_ERROR("evtStore() does not contain VertexContainer Collection with name "<< m_offlineVertexContainerKey);
	return StatusCode::FAILURE;
      } // valid
      ATH_MSG_DEBUG(" Size of the Off-line PV container: " << offlinepv->size() );
691
692
693
694
695
696
697
698
699
700
701
      if ( offlinepv->size() ) {
	Eofflinepv = true;
	offlinepvz = offlinepv->front()->z();
	ATH_MSG_DEBUG(" 1st zPV a la Carlo: " << offlinepvz);
	hist("nPV"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill(offlinepv->size());
	for (unsigned int j = 0; j<offlinepv->size(); j++){
	  hist("PVx"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill((*(offlinepv))[j]->x());
	  hist("PVy"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill((*(offlinepv))[j]->y());
	  hist("PVz"+HistExt,"HLT/BjetMon/Shifter"+HistDir)->Fill((*(offlinepv))[j]->z());
	} // j
      } // if size
702
703
704

    } // else Run3

705

706
    ATH_MSG_DEBUG(" ======== Offline histograms are retrieved successfully ! ==== Start online histograms to retrieve ====== ");
707

708
    // Get online triggers
709

710
    bool SplitKey;
711
    bool FTKchain;
712

713
    //  unsigned int ichain = 0;
714
    // Loop on trigger items
715
716
717
718
719
720
721
722
    for (const auto & trigItem:FiredChainNames){        // Shaun Roe 21/9/16
      // Set directory name (Expert or Shifter)
      std::map<std::string,std::string>::iterator p;
      p = m_Chain2Dir.find(trigItem);
      if ( p != m_Chain2Dir.end() ) {
	HistDir = p->second+"/"+trigItem;
      } else {
	ATH_MSG_INFO(" Fired Trigger " << trigItem << " has no folder name - verify HLTBjetMonTool::init() !!!" );
723
	continue;
724
725
726
727
728
      }
      ATH_MSG_DEBUG(" Fired Trigger " << trigItem << " will be placed in folder " << p->second );
      HistExt = "_"+trigItem;
      ATH_MSG_DEBUG(" HistDir " << HistDir << " HistExt " << HistExt );
      // Set container names (2016/03/03) see TrigBtagEmulation.cxx
729
730
      // Set keys
      // HLT non split input chaines
731
      SplitKey = false;
732
733
734
      std::string jetKey = "";
      std::string priVtxKey = "EFHistoPrmVtx";
      std::string trackKey  = "";
735
      // HLT split input chaines
736
737
      std::size_t found = trigItem.find("split");
      if (found!=std::string::npos) {
738
	SplitKey =true;
739
740
741
	jetKey = "SplitJet";
	priVtxKey = "xPrimVx";
	trackKey  = "InDetTrigTrackingxAODCnv_Bjet_IDTrig";
742
      }
743
      // FTK input chains: John Baines and Julie Hart 
744
      FTKchain = false;
745
746
      std::size_t found1 = trigItem.find("FTK");
      if (found1!=std::string::npos) {
747
	FTKchain = true;
748
749
750
	//	priVtxKey = "HLT_PrimVertexFTK";
	priVtxKey = "PrimVertexFTK";  // Mark Sutton 17.09.17 
	trackKey  = "InDetTrigTrackingxAODCnv_Bjet_FTK_IDTrig";
751
	std::size_t found2 = trigItem.find("FTKRefit");
752
        if (found2!=std::string::npos) {
753
          trackKey  = "InDetTrigTrackingxAODCnv_Bjet_FTKRefit_IDTrig";
754
        }//found2
755
756
	std::size_t found3 = trigItem.find("FTKVtx");
        if (found3!=std::string::npos) {
757
          trackKey  = "InDetTrigTrackingxAODCnv_Bjet_IDTrig";
758
        }//found3
759
      }//found1
760
761
762
      // gsc input chains: Ruch Gupta 2017/08/02 
      std::size_t found4 = trigItem.find("gsc");
      if (found4!=std::string::npos) {
763
	jetKey = "GSCJet";
764
      } // if found4
765
766
      ATH_MSG_DEBUG( " Trigger chain name: " << trigItem << " m_jetKey: " << jetKey << " m_priVtxKey: " << priVtxKey 
		    << " m_trackKey: " << trackKey << " SplitKey: " << SplitKey << " FTKchain: " << FTKchain);
767
      ATH_MSG_DEBUG("PROCESSING TRIGITEM  -  " << trigItem);
768
769
770
771
772
773
774
775
776
777
      // Set flag MuJet
      bool MuJet = false;
      found = trigItem.find("HLT_mu");
      if (found!=std::string::npos) MuJet = true;
      // Set flags for histograms
      bool HistPV = !MuJet;
      bool HistJet = true;
      bool HistMuJet = MuJet;
      bool HistTrack = !MuJet;
      bool HistBjet = !MuJet;
778

779
      float zPrmVtx = 0.; // used for muon-jets
780
781
782
783

      // Temporary work-around to retrieve online PV for FTK chains suggested by John Baines 2017/09/12
      // Dummy vertices not treated here for the moment

784
      /*
785
786
787
788
789
790
791
792
793
794
795
796
797
798
      if (FTKchain) {
        const xAOD::VertexContainer * onlinepvFTK = 0;
        if ( evtStore()->contains<xAOD::VertexContainer>("HLT_xAOD__VertexContainer_PrimVertexFTK") ) {
          ATH_CHECK( evtStore()->retrieve(onlinepvFTK, "HLT_xAOD__VertexContainer_PrimVertexFTK") );
          ATH_MSG_DEBUG("RETRIEVED FTK PV from evtStore -   size: " << onlinepvFTK->size());
          if( not onlinepvFTK->empty()) {
	    int iVsize = onlinepvFTK->size();
	    for (int iV = 0; iV < iVsize; iV++){
	      ATH_MSG_DEBUG("    FTK evtStore Online PV -  iV: " << iV << " z[iV]: " << (*(onlinepvFTK))[iV]->z() << " type: " << (*(onlinepvFTK))[iV]->vertexType() );
	    } // for iV
	    if(HistPV) hist("PVx_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepvFTK))[0]->x());
	    if(HistPV) hist("PVy_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepvFTK))[0]->y());
	    if(HistPV) hist("PVz_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepvFTK))[0]->z());
	    if(HistPV) hist("nPV_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(onlinepvFTK->size());
799
	    zPrmVtx = (*(onlinepvFTK))[0]->z();
800
801
802
803
	    if (EofflinepvFTK && HistPV) hist("diffzPV0offPVon"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepvFTK))[0]->z()-offlinepvzFTK);
          } // not onlinepvFTK->empty()
	} // if contains
      } // FTK chain
804
805
      */  

806
807
    // Access to Trigger elements

808
      if (getTDT()->getNavigationFormat() == "TriggerElement") { // Run 2 access a la Tim Martin
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830


	Trig::FeatureContainer fc = m_trigDec->features(trigItem);
	const std::vector< Trig::Combination >& bjetCombs = fc.getCombinations();
	ATH_MSG_DEBUG("RETRIEVED " << bjetCombs.size() << " COMBINATIONS FOR "  << trigItem);
	
	// Loop on combinations
	std::vector< Trig::Combination >::const_iterator bjetComb;
	for( bjetComb = bjetCombs.begin(); bjetComb != bjetCombs.end(); ++bjetComb ) {
	  const Trig::Combination& comb = *bjetComb;
	  ATH_MSG_DEBUG("------------ NEW COMBINATION ------------");
	  zPrmVtx = 0.; // used for muon-jets
	  
	  if (!FTKchain) {
	    
	    // Get online PV
	    bool DummyVtx = false;
	    const std::vector< Trig::Feature<xAOD::VertexContainer> > onlinepvs = comb.get<xAOD::VertexContainer>(priVtxKey);
	    ATH_MSG_DEBUG("RETRIEVED PV  -   size: " << onlinepvs.size());
	    if ( not onlinepvs.empty() ) {
	      const xAOD::VertexContainer* onlinepv = onlinepvs[0].cptr();
	      ATH_MSG_DEBUG("   for VertexContainer: " << priVtxKey << " nVert: " << onlinepv->size());
831
832
	      if( not onlinepv->empty()) {
		if ( (*(onlinepv))[0]->vertexType() == xAOD::VxType::VertexType:: PriVtx ) { // test that PriVtx is not dummy (JA)
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
		  if(HistPV) hist("PVx_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->x());
		  if(HistPV) hist("PVy_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->y());
		  if(HistPV) hist("PVz_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->z());
		  zPrmVtx = (*(onlinepv))[0]->z();
		  if (Eofflinepv && HistPV) hist("diffzPV0offPVon"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->z()-offlinepvz);
		  ATH_MSG_DEBUG("         Online PV -   z[0]: " << (*(onlinepv))[0]->z());
		} // if PV not dummy
		else {
		  DummyVtx = true;
		  ATH_MSG_DEBUG("  Dummy Vertex found: DummyVtx = " << DummyVtx << " m_jetKey = " << jetKey << " HistExt = " << HistExt << " m_priVtxKey " << priVtxKey );
		  ATH_MSG_DEBUG(" Online dummy PV - type: " << (*(onlinepv))[0]->vertexType() << " x[0]: " << (*(onlinepv))[0]->x()
				<< " y[0]: " << (*(onlinepv))[0]->y() <<  " z[0]: " << (*(onlinepv))[0]->z() );
		  int dummyflag = -1;
		  if(HistPV) hist("nPV_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(dummyflag);
		  //	      continue; // if vertex is dummy skip reading out the other quntities for this trigger combination (EN)
		} // else
		if (!DummyVtx && HistPV) hist("nPV_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(onlinepv->size());
	      }  // if onlinepv not empty
	    } // if onlinepvs not empty
	    if ( SplitKey && DummyVtx ) {
	      // for SplitJets and DummyVtx monitor Vtx with Histogram algorithm
	      const std::vector< Trig::Feature<xAOD::VertexContainer> >onlinepvsd = comb.get<xAOD::VertexContainer>("EFHistoPrmVtx");
	      ATH_MSG_DEBUG("RETRIEVED PV with Histo algo for Split chains when Dummy vtx found with xPrimVx algo-   size: " << onlinepvsd.size());
	      if ( not onlinepvsd.empty() ) {
		const xAOD::VertexContainer* onlinepv = onlinepvsd[0].cptr();
		ATH_MSG_DEBUG(" for VertexContainer EFHistoPrmVtx  - nVert: " << onlinepv->size());
		if( not onlinepv->empty()) {
		  if ( (*(onlinepv))[0]->vertexType() == xAOD::VxType::VertexType:: PriVtx ) { // test that PriVtx is not dummy (JA)
		    if(HistPV) hist("PVx_tr_Hist"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->x());
		    if(HistPV) hist("PVy_tr_Hist"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->y());
		    if(HistPV) hist("PVz_tr_Hist"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((*(onlinepv))[0]->z());
		    if(HistPV) hist("nPV_tr_Hist"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(onlinepv->size());
		    ATH_MSG_DEBUG(" Dummy PV using Histogram algorithm - type: " << (*(onlinepv))[0]->vertexType() << " x[0]: " << (*(onlinepv))[0]->x()
				  << " y[0]: " << (*(onlinepv))[0]->y() <<  " z[0]: " << (*(onlinepv))[0]->z() );
		  } // if VertexType
		} // if not onlinepv
	      } // if not onlinepvs
	      continue; // if vertex is dummy skip reading out the other quntities for this trigger combination (EN)
	    } // if DummyVtx
	    
	  } // if (!FTKchain)
	  
	  ATH_MSG_DEBUG(" ======== End of retrival of PV histograms  ==============  ");
	  
	  // Get online jet
	  const std::vector< Trig::Feature<xAOD::JetContainer> > onlinejets = comb.get<xAOD::JetContainer>(jetKey);
	  ATH_MSG_DEBUG("RETRIEVED JETS   -   size: " << onlinejets.size());
	  if( not onlinejets.empty()) {  // SR
	    const xAOD::JetContainer* onlinejet = onlinejets[0].cptr();
	    ATH_MSG_DEBUG("                 -   nJet: " << onlinejet->size());
	    int nJet = onlinejet->size();
	    if(HistJet) hist("nJet"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(nJet);
	    for(const auto* jet : *onlinejet) {
	      ATH_MSG_DEBUG("                 -   pt/eta/phi: " << (jet->pt())*1.e-3 << " / " << jet->eta() << " / " << jet->phi());
	      if(HistJet) hist("jetPt"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((jet->pt())*1.e-3);
	      if(HistJet) hist2("jetEtaPhi"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(jet->eta(),jet->phi());
	    } // for online jet
	  }//onlinejets.size
	  
	  ATH_MSG_DEBUG(" Jets histograms are stored successfully !");
	  
	  // Get online muon
	  const std::vector< Trig::Feature<xAOD::MuonContainer> > onlinemuons = comb.get<xAOD::MuonContainer>();
	  ATH_MSG_DEBUG("RETRIEVED MUONS   -   size: " << onlinemuons.size());
	  if( not onlinemuons.empty()) {  // SR
	    const xAOD::MuonContainer* onlinemuon = onlinemuons[0].cptr();
	    ATH_MSG_DEBUG("                 -   nMuon: " << onlinemuon->size());
	    int nMuon = onlinemuon->size();
	    if(HistMuJet) hist("nMuon"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(nMuon);
	    for(const auto* muon : *onlinemuon) {
	      ATH_MSG_DEBUG("                 -   pt/eta/phi: " << (muon->pt())*1.e-3 << " / " << muon->eta() << " / " << muon->phi());
	      if(HistMuJet) hist("muonPt"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((muon->pt())*1.e-3);
	      if(HistMuJet) hist2("muonEtaPhi"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(muon->eta(),muon->phi());
	    } // for online muon
	  }//onlinemuons.size
	  
	  // Loop over muons and jets to monitor muon-jets m_deltaZ and m_dR
	  float muonEta=0, muonPhi=0, muonZ=0;
	  float jetEta=0,  jetPhi=0, jetZ=0;
	  float deltaEta=0, deltaPhi=0, deltaZ=0;
	  double dR = 0.;
	  if( not onlinemuons.empty()) { // SR
	    const xAOD::MuonContainer* onlinemuon = onlinemuons[0].cptr();
	    for(const auto* muon : *onlinemuon) {
	      //	  if(onlinejets.size()) {
	      if( not onlinejets.empty()) { // SR
		const xAOD::Muon::MuonType muontype = muon->muonType();
		if( muontype != xAOD::Muon::MuonType::Combined ) continue; // to correct coverity issue - see next commented line
		//	    if(!(muontype == xAOD::Muon::MuonType::Combined) ) continue;
		muonEta = muon->eta();
		muonPhi = muon->phi();
		muonZ=0;
		//	    muonZ= (*(muon->combinedTrackParticleLink()))->z0();
		muonZ = (*(muon->combinedTrackParticleLink()))->z0()  + (*(muon->combinedTrackParticleLink()))->vz(); //LZ 131115
		const xAOD::JetContainer* onlinejet = onlinejets[0].cptr();
		for(const auto* jet : *onlinejet) {
		  if((jet)->p4().Et() < m_etCut) continue;
		  jetEta = (jet)->eta();
		  jetPhi = (jet)->phi();
		  jetZ=zPrmVtx;
		  deltaEta = muonEta - jetEta;
		  deltaPhi = phiCorr(phiCorr(muonPhi) - phiCorr(jetPhi));
		  deltaZ   = fabs(muonZ-jetZ);
		  dR = sqrt(deltaEta*deltaEta + deltaPhi*deltaPhi);
		  if(HistMuJet) hist("DeltaZAll"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(deltaZ);
		  if(HistMuJet) hist("DeltaRAll"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(dR);
		} // for online jet
	      }//onlinejets.size
	    } // for online muon
	  }//onlinemuons.size
	  
	  ATH_MSG_DEBUG(" Muon histograms are stored successfully !");
945
	  
946
947
948
949
950
951
952
953
954
955
956
957
	  // Get online track particles
	  const std::vector< Trig::Feature<xAOD::TrackParticleContainer> > onlinetracks = comb.get<xAOD::TrackParticleContainer>(trackKey);
	  ATH_MSG_DEBUG("RETRIEVED TRACKS -   size: " << onlinetracks.size());
	  if ( not onlinetracks.empty() ) { // SR
	    const xAOD::TrackParticleContainer*  onlinetrack = onlinetracks[0].cptr();
	    ATH_MSG_DEBUG("                 -   nTrack: " << onlinetrack->size());
	    int nTrack = onlinetrack->size();
	    if (HistTrack) hist("nTrack"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(nTrack);
	    for(const auto* trk : *onlinetrack) {
	      ATH_MSG_DEBUG("     pT: " << (trk->pt())*1.e-3 << " Eta: " << trk->eta() << " Phi: " << trk->phi() << " d0: " << trk->d0() );
	      if (HistTrack) hist("d0"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(trk->d0());
	      if (HistTrack) hist("z0"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(trk->z0());
958
	      if (HistTrack) hist("ed0"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(Amg::error(trk->definingParametersCovMatrix(), 0) );
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
	      if (HistTrack) hist("ez0"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(Amg::error(trk->definingParametersCovMatrix(), 1));
	      if (HistTrack) hist("trkPt"+HistExt,"HLT/BjetMon/"+HistDir)->Fill( (trk->pt())*1.e-3 );
	      if (HistTrack) hist2("trkEtaPhi"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(trk->eta(),trk->phi());
	      float errz0 = Amg::error(trk->definingParametersCovMatrix(), 1);
	      if (FTKchain) {
		if (EofflinepvFTK) ATH_MSG_DEBUG(" z0 - zPVoffl: " << trk->z0()+trk->vz()-offlinepvzFTK ); // John A
		if (EofflinepvFTK && HistTrack) hist("diffz0PV0"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(trk->z0()+trk->vz()-offlinepvzFTK); // John Alison
		if ( errz0 >0. && EofflinepvFTK && HistTrack) hist("sigz0PV"+HistExt,"HLT/BjetMon/"+HistDir)->Fill( (trk->z0()+trk->vz()-offlinepvzFTK)/errz0 ); // John Alison
	      } else { // if FTKchain
		if (Eofflinepv) ATH_MSG_DEBUG(" z0 - zPVoffl: " << trk->z0()+trk->vz()-offlinepvz ); // John A
		if (Eofflinepv && HistTrack) hist("diffz0PV0"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(trk->z0()+trk->vz()-offlinepvz); // John Alison
		if ( errz0 >0. && Eofflinepv && HistTrack) hist("sigz0PV"+HistExt,"HLT/BjetMon/"+HistDir)->Fill( (trk->z0()+trk->vz()-offlinepvz)/errz0 ); // John Alison
	      } // else
	    } // for online track particles
	  } // onlinetracks.size
	  
	  ATH_MSG_DEBUG(" Track histograms are stored successfully !");
	  
	  // Get online bjet from xAOD BTaggingContainer
	  const std::vector< Trig::Feature<xAOD::BTaggingContainer> > onlinebjets = comb.get<xAOD::BTaggingContainer>();
	  ATH_MSG_DEBUG("RETRIEVED BJETS  from xAOD BTaggingContainer -   size: " << onlinebjets.size());
	  if(not onlinebjets.empty()) { // SR
	    const xAOD::BTaggingContainer* onlinebjet = onlinebjets[0].cptr();
	    ATH_MSG_DEBUG("                 -   nBjet: " << onlinebjet->size());
	    for(const auto* bjet : *onlinebjet) {
	      double wIP3D, wSV1, wCOMB, wMV2c00, wMV2c10, wMV2c20  = 0.; // discriminant variables
	      //	  double wMV1  = 0.;
	      float svp_efrc, svp_mass = -1.; int svp_n2t = -1; // SV1 variables
	      bjet->loglikelihoodratio("IP3D", wIP3D);
	      bjet->loglikelihoodratio("SV1", wSV1);
	      double SV1_loglikelihoodratioLZ = bjet->SV1_loglikelihoodratio();
	      wCOMB = wIP3D+wSV1;
	      wMV2c00 = bjet->auxdata<double>("MV2c00_discriminant");
	      wMV2c10 = bjet->auxdata<double>("MV2c10_discriminant");
	      wMV2c20 = bjet->auxdata<double>("MV2c20_discriminant");
	      //	  wMV1 = bjet->MV1_discriminant();
	      // Suggestion of LZ
	      bjet->variable<float>("SV1", "masssvx", svp_mass);
	      bjet->variable<float>("SV1", "efracsvx", svp_efrc);
	      bjet->variable<int>("SV1", "N2Tpair", svp_n2t);
	      ATH_MSG_DEBUG("                 -   Before SV1 check - MVTX / EVTX / NVTX: " << svp_mass << " / " << svp_efrc << " / " << svp_n2t ) ;
	      if (HistBjet) hist("xNVtx_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(svp_n2t);
1001
	      if ( svp_n2t > 0 ) {
1002
1003
		if (HistBjet) hist("xMVtx_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill( svp_mass * 1.e-3 );
		if (HistBjet) hist("xEVtx_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill( svp_efrc );
1004
	      } // if svp_n2t
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
	      // end of suggestion of LZ
	      ATH_MSG_DEBUG("                 -   IP3Dpu / IP3Dpb / IP3Dpc: " << bjet->IP3D_pu() << " / " << bjet->IP3D_pb() << " / " << bjet->IP3D_pc() );
	      if (HistBjet) hist("IP3D_pu_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(bjet->IP3D_pu());
	      if (HistBjet) hist("IP3D_pb_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(bjet->IP3D_pb());
	      if (HistBjet) hist("IP3D_pc_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(bjet->IP3D_pc());
	      ATH_MSG_DEBUG("                 -   IP3D / SV1 / IP3D+SV1: " << wIP3D << " / " << wSV1 << " / " << wCOMB );
	      ATH_MSG_DEBUG("                 -   SV1 LZ: " << SV1_loglikelihoodratioLZ );
	      ATH_MSG_DEBUG("                 -   MV2c00 / MV2c10 / MV2c20: " << wMV2c00 << " / " << wMV2c10 << " / " << wMV2c20);
	      if (HistBjet) hist("wIP3D_Rbu_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(wIP3D);
	      if (HistBjet) hist("wSV1_Rbu_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(wSV1);
	      if (HistBjet) hist("wCOMB_Rbu_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(wCOMB);
	      if (HistBjet) hist("wMV2c00_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(wMV2c00);
	      if (HistBjet) hist("wMV2c10_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(wMV2c10);
	      if (HistBjet) hist("wMV2c20_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(wMV2c20);
	      
	      // Get SV1 secondary vtx information, see:
	      // /PhysicsAnalysis/JetTagging/JetTagTools/src/MV2Tag.cxx#0486 and
	      // /PhysicsAnalysis/JetTagging/JetTagTools/src/GaiaNNTool.cxx#0349
	      std::vector< ElementLink< xAOD::VertexContainer > > myVertices;
	      ATH_MSG_DEBUG("    SV1 info source name before calling VertexContainer: " << m_sv1_infosource ) ;
	      bjet->variable<std::vector<ElementLink<xAOD::VertexContainer> > >(m_sv1_infosource, "vertices", myVertices);
	      ATH_MSG_DEBUG("    SV1 info source name after calling VertexContainer: " << m_sv1_infosource ) ;
	      if ( myVertices.size() > 0 && myVertices[0].isValid() ) {
		ATH_MSG_DEBUG("    SV1 vertex size: " << myVertices.size() << " is it valid? " << myVertices[0].isValid() ) ;
		bjet->variable<float>(m_sv1_infosource, "masssvx", svp_mass);
		bjet->variable<float>(m_sv1_infosource, "efracsvx", svp_efrc);
		bjet->variable<int>(m_sv1_infosource, "N2Tpair", svp_n2t);
		ATH_MSG_DEBUG("                 -   MVTX / EVTX / NVTX: " << svp_mass << " / " << svp_efrc << " / " << svp_n2t ) ;
		if ( svp_n2t > 0 ) {
		} // if svp_n2t
	      } else {
		ATH_MSG_DEBUG("  No valid SV1 vertex found --  SV1 vertex size: " << myVertices.size() );
		if ( myVertices.size() > 0 ) ATH_MSG_DEBUG("  No valid SV1 vertex found -- myVertices[0].isValid(): " << myVertices[0].isValid() ) ;
	      } // if vertex valid
	    } // for online bjet
	  } // onlinebjets.size
	  
	  ATH_MSG_DEBUG(" Bjet histograms are stored successfully !");
	  
	} // for bjetComb
	
      } // Run2 access 
      else { // Run3 access
1048

Elemer Nagy's avatar
Elemer Nagy committed
1049
	ATH_MSG_DEBUG("  ===> Run 3 access for Trigger Item: " << trigItem);
1050

1051
1052
1053
1054
1055
1056
1057
	// online track container
	SG::ReadHandle<xAOD::TrackParticleContainer> theTracks(m_onlineTrackContainerKey);
	// verify the content
	for ( const xAOD::TrackParticle* track : *theTracks ) {
	  ATH_MSG_DEBUG( " Pt of track in TrackParticleContainer: " << track->pt() );
	}
	
1058

1059
	// online PV from SG
1060
	int iPV = 0;
1061
	SG::ReadHandle<xAOD::VertexContainer> vtxContainer(m_onlineVertexContainerKey);
1062
1063
	for (const xAOD::Vertex* vtx : *vtxContainer) {
	  if (vtx->vertexType() == xAOD::VxType::PriVtx) {
1064
1065
1066
	    ATH_MSG_DEBUG("        PVx,PVy,PVz from SG: " << vtx->x() << " " << vtx->y() << " " << vtx->z() );
	    if(HistPV) hist("PVx_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(vtx->x());
	    if(HistPV) hist("PVy_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(vtx->y());
1067
	    if(HistPV) hist("PVz_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(vtx->z());
1068
	    iPV++;
1069
	    if ( Eofflinepv && HistPV && (iPV == 1) ) hist("diffzPV0offPVon"+HistExt,"HLT/BjetMon/"+HistDir)->Fill( vtx->z()-offlinepvz );
1070
1071
	  } // if vtx type
	} // loop on vtxContainer
1072
1073
	ATH_MSG_DEBUG("        Number of vertices from SG: " << iPV );
	if(HistPV) hist("nPV_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(iPV);
1074

1075
	// Jets and PV and tracks through jet link
1076
	std::vector< TrigCompositeUtils::LinkInfo<xAOD::JetContainer> > onlinejets = m_trigDec->features<xAOD::JetContainer>(trigItem, TrigDefs::Physics, m_onlineBjetContainerKey); // TM 240320
1077
	int ijet = 0;
1078
	int itrack = 0;
1079
	for(const auto& jetLinkInfo : onlinejets) {
1080
1081
1082
1083
	  // jetPt
	  const xAOD::Jet* jet = *(jetLinkInfo.link);
	  ATH_MSG_DEBUG("                 -   pt/eta/phi: " << (jet->pt())*1.e-3 << " / " << jet->eta() << " / " << jet->phi());
	  if(HistJet) hist("jetPt"+HistExt,"HLT/BjetMon/"+HistDir)->Fill((jet->pt())*1.e-3);
1084
	  if(HistJet) hist2("jetEtaPhi"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(jet->eta(),jet->phi());
1085
1086
	  // 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) {
1087
1088

	    // Fetch and plot PV
1089
1090
	    std::string vtxname = m_onlineVertexContainerKey.key();
	    if ( vtxname.find("HLT_")==0 ) vtxname.erase(0,4);
1091
	    auto vertexLinkInfo = TrigCompositeUtils::findLink<xAOD::VertexContainer>(jetLinkInfo.source, vtxname ); // CV 200120 & MS 290620
1092
	    ATH_CHECK( vertexLinkInfo.isValid() ) ; // TM 200120
1093
	    const xAOD::Vertex* vtx = *(vertexLinkInfo.link);
Elemer Nagy's avatar
Elemer Nagy committed
1094
	    ATH_MSG_DEBUG("        PVz_jet from jet link info: " << vtx->z());
1095
	    // if(HistPV) hist("PVz_tr"+HistExt,"HLT/BjetMon/"+HistDir)->Fill(vtx->z());
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137