CMS 3D CMS Logo

TrackingMonitor.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  **
4  * \author Suchandra Dutta , Giorgia Mila
5  */
6 
13 
22 
26 
34 
37 
39 
40 #include <string>
41 
42 #ifdef VI_DEBUG
43 #define COUT(x) std::cout << x << ' '
44 #else
45 #define COUT(x) LogDebug(x)
46 #endif
47 
48 // TrackingMonitor
49 // ----------------------------------------------------------------------------------//
50 
52  : confID_(iConfig.id()),
53  theTrackBuildingAnalyzer(new TrackBuildingAnalyzer(iConfig)),
54  NumberOfTracks(nullptr),
55  NumberOfMeanRecHitsPerTrack(nullptr),
56  NumberOfMeanLayersPerTrack(nullptr)
57  // , NumberOfGoodTracks(NULL)
58  ,
59  FractionOfGoodTracks(nullptr),
60  NumberOfTrackingRegions(nullptr),
61  NumberOfSeeds(nullptr),
62  NumberOfSeeds_lumiFlag(nullptr),
63  NumberOfTrackCandidates(nullptr),
64  FractionCandidatesOverSeeds(nullptr)
65  // , NumberOfGoodTrkVsClus(NULL)
66  ,
67  NumberEventsOfVsLS(nullptr),
68  NumberOfTracksVsLS(nullptr)
69  // , NumberOfGoodTracksVsLS(NULL)
70  ,
71  GoodTracksFractionVsLS(nullptr)
72  // , GoodTracksNumberOfRecHitsPerTrackVsLS(NULL)
73  // ADD by Mia for PU monitoring
74  // vertex plots to be moved in ad hoc class
75  ,
76  NumberOfGoodPVtxVsLS(nullptr),
77  NumberOfGoodPVtxWO0VsLS(nullptr),
78  NumberEventsOfVsBX(nullptr),
79  NumberOfTracksVsBX(nullptr),
80  GoodTracksFractionVsBX(nullptr),
81  NumberOfRecHitsPerTrackVsBX(nullptr),
82  NumberOfGoodPVtxVsBX(nullptr),
83  NumberOfGoodPVtxWO0VsBX(nullptr),
84  NumberOfTracksVsBXlumi(nullptr),
85  NumberOfTracksVsGoodPVtx(nullptr),
86  NumberOfTracksVsPUPVtx(nullptr),
87  NumberEventsOfVsGoodPVtx(nullptr),
88  GoodTracksFractionVsGoodPVtx(nullptr),
89  NumberOfRecHitsPerTrackVsGoodPVtx(nullptr),
90  NumberOfPVtxVsGoodPVtx(nullptr),
91  NumberOfPixelClustersVsGoodPVtx(nullptr),
92  NumberOfStripClustersVsGoodPVtx(nullptr),
93  NumberEventsOfVsLUMI(nullptr),
94  NumberOfTracksVsLUMI(nullptr),
95  GoodTracksFractionVsLUMI(nullptr),
96  NumberOfRecHitsPerTrackVsLUMI(nullptr),
97  NumberOfGoodPVtxVsLUMI(nullptr),
98  NumberOfGoodPVtxWO0VsLUMI(nullptr),
99  NumberOfPixelClustersVsLUMI(nullptr),
100  NumberOfStripClustersVsLUMI(nullptr),
101  NumberOfTracks_lumiFlag(nullptr)
102  // , NumberOfGoodTracks_lumiFlag(NULL)
103 
104  ,
105  builderName(iConfig.getParameter<std::string>("TTRHBuilder")),
106  doTrackerSpecific_(iConfig.getParameter<bool>("doTrackerSpecific")),
107  doLumiAnalysis(iConfig.getParameter<bool>("doLumiAnalysis")),
108  doProfilesVsLS_(iConfig.getParameter<bool>("doProfilesVsLS")),
109  doAllPlots(iConfig.getParameter<bool>("doAllPlots")),
110  doGeneralPropertiesPlots_(iConfig.getParameter<bool>("doGeneralPropertiesPlots")),
111  doHitPropertiesPlots_(iConfig.getParameter<bool>("doHitPropertiesPlots")),
112  doPUmonitoring_(iConfig.getParameter<bool>("doPUmonitoring")),
113  genTriggerEventFlag_(new GenericTriggerEventFlag(
114  iConfig.getParameter<edm::ParameterSet>("genericTriggerEventPSet"), consumesCollector(), *this)),
115  numSelection_(iConfig.getParameter<std::string>("numCut")),
116  denSelection_(iConfig.getParameter<std::string>("denCut")),
117  pvNDOF_(iConfig.getParameter<int>("pvNDOF")) {
118  edm::ConsumesCollector c{consumesCollector()};
119  theTrackAnalyzer = new dqm::TrackAnalyzer(iConfig, c);
120 
121  // input tags for collections from the configuration
122  bsSrc_ = iConfig.getParameter<edm::InputTag>("beamSpot");
123  pvSrc_ = iConfig.getParameter<edm::InputTag>("primaryVertex");
124  bsSrcToken_ = consumes<reco::BeamSpot>(bsSrc_);
125  pvSrcToken_ = mayConsume<reco::VertexCollection>(pvSrc_);
126 
127  lumiscalersToken_ = consumes<LumiScalersCollection>(iConfig.getParameter<edm::InputTag>("scal"));
128 
129  edm::InputTag alltrackProducer = iConfig.getParameter<edm::InputTag>("allTrackProducer");
130  edm::InputTag trackProducer = iConfig.getParameter<edm::InputTag>("TrackProducer");
131  edm::InputTag tcProducer = iConfig.getParameter<edm::InputTag>("TCProducer");
132  edm::InputTag seedProducer = iConfig.getParameter<edm::InputTag>("SeedProducer");
133  allTrackToken_ = consumes<edm::View<reco::Track> >(alltrackProducer);
134  trackToken_ = consumes<edm::View<reco::Track> >(trackProducer);
135  trackCandidateToken_ = consumes<TrackCandidateCollection>(tcProducer);
136  seedToken_ = consumes<edm::View<TrajectorySeed> >(seedProducer);
137  seedStopInfoToken_ = consumes<std::vector<SeedStopInfo> >(tcProducer);
138 
139  doMVAPlots = iConfig.getParameter<bool>("doMVAPlots");
140  if (doMVAPlots) {
142  iConfig.getParameter<std::vector<std::string> >("MVAProducers"), [&](const std::string& tag) {
143  return std::make_tuple(consumes<MVACollection>(edm::InputTag(tag, "MVAValues")),
144  consumes<QualityMaskCollection>(edm::InputTag(tag, "QualityMasks")));
145  });
146  mvaTrackToken_ = consumes<edm::View<reco::Track> >(iConfig.getParameter<edm::InputTag>("TrackProducerForMVA"));
147  }
148 
149  doRegionPlots = iConfig.getParameter<bool>("doRegionPlots");
150  doRegionCandidatePlots = iConfig.getParameter<bool>("doRegionCandidatePlots");
151  if (doRegionPlots) {
152  const auto& regionTag = iConfig.getParameter<edm::InputTag>("RegionProducer");
153  if (!regionTag.label().empty()) {
154  regionToken_ = consumes<edm::OwnVector<TrackingRegion> >(regionTag);
155  }
156  const auto& regionLayersTag = iConfig.getParameter<edm::InputTag>("RegionSeedingLayersProducer");
157  if (!regionLayersTag.label().empty()) {
158  if (!regionToken_.isUninitialized()) {
159  throw cms::Exception("Configuration")
160  << "Only one of 'RegionProducer' and 'RegionSeedingLayersProducer' can be non-empty, now both are.";
161  }
162  regionLayerSetsToken_ = consumes<TrackingRegionsSeedingLayerSets>(regionLayersTag);
163  } else if (regionToken_.isUninitialized()) {
164  throw cms::Exception("Configuration") << "With doRegionPlots=True either 'RegionProducer' or "
165  "'RegionSeedingLayersProducer' must be non-empty, now both are empty.";
166  }
167 
168  if (doRegionCandidatePlots) {
169  regionCandidateToken_ = consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("RegionCandidates"));
170  }
171  }
172 
175  stripClustersToken_ = mayConsume<edmNew::DetSetVector<SiStripCluster> >(stripClusterInputTag_);
176  pixelClustersToken_ = mayConsume<edmNew::DetSetVector<SiPixelCluster> >(pixelClusterInputTag_);
177 
178  doFractionPlot_ = true;
179  if (alltrackProducer.label() == trackProducer.label())
180  doFractionPlot_ = false;
181 
182  Quality_ = iConfig.getParameter<std::string>("Quality");
183  AlgoName_ = iConfig.getParameter<std::string>("AlgoName");
184 
185  // get flag from the configuration
186  doPlotsVsBXlumi_ = iConfig.getParameter<bool>("doPlotsVsBXlumi");
187  if (doPlotsVsBXlumi_)
188  theLumiDetails_ = new GetLumi(iConfig.getParameter<edm::ParameterSet>("BXlumiSetup"), c);
189  doPlotsVsGoodPVtx_ = iConfig.getParameter<bool>("doPlotsVsGoodPVtx");
190  doPlotsVsLUMI_ = iConfig.getParameter<bool>("doPlotsVsLUMI");
191  doPlotsVsBX_ = iConfig.getParameter<bool>("doPlotsVsBX");
192 
193  if (doPUmonitoring_) {
194  std::vector<edm::InputTag> primaryVertexInputTags =
195  iConfig.getParameter<std::vector<edm::InputTag> >("primaryVertexInputTags");
196  std::vector<edm::InputTag> selPrimaryVertexInputTags =
197  iConfig.getParameter<std::vector<edm::InputTag> >("selPrimaryVertexInputTags");
198  std::vector<std::string> pvLabels = iConfig.getParameter<std::vector<std::string> >("pvLabels");
199 
200  if (primaryVertexInputTags.size() == pvLabels.size() and
201  primaryVertexInputTags.size() == selPrimaryVertexInputTags.size()) {
202  for (size_t i = 0; i < primaryVertexInputTags.size(); i++) {
203  edm::InputTag iPVinputTag = primaryVertexInputTags[i];
204  edm::InputTag iSelPVinputTag = selPrimaryVertexInputTags[i];
205  std::string iPVlabel = pvLabels[i];
206 
207  theVertexMonitor.push_back(new VertexMonitor(iConfig, iPVinputTag, iSelPVinputTag, iPVlabel, c));
208  }
209  }
210  }
211 }
212 
214  if (theTrackAnalyzer)
215  delete theTrackAnalyzer;
218  if (doPUmonitoring_)
219  for (size_t i = 0; i < theVertexMonitor.size(); i++)
220  if (theVertexMonitor[i])
221  delete theVertexMonitor[i];
223  delete genTriggerEventFlag_;
224 }
225 
226 void TrackingMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
227  // parameters from the configuration
228  auto const* conf = edm::pset::Registry::instance()->getMapped(confID_);
229  assert(conf != nullptr);
230  std::string Quality = conf->getParameter<std::string>("Quality");
231  std::string AlgoName = conf->getParameter<std::string>("AlgoName");
232  MEFolderName = conf->getParameter<std::string>("FolderName");
233  std::string Folder = MEFolderName.substr(0, 2);
234 
235  // test for the Quality veriable validity
236  if (!Quality_.empty()) {
237  if (Quality_ != "highPurity" && Quality_ != "tight" && Quality_ != "loose") {
238  edm::LogWarning("TrackingMonitor") << "Qualty Name is invalid, using no quality criterea by default";
239  Quality_ = "";
240  }
241  }
242 
243  // use the AlgoName and Quality Name
244  std::string CategoryName = !Quality_.empty() ? AlgoName_ + "_" + Quality_ : AlgoName_;
245 
246  // get binning from the configuration
247  int TKNoBin = conf->getParameter<int>("TkSizeBin");
248  double TKNoMin = conf->getParameter<double>("TkSizeMin");
249  double TKNoMax = conf->getParameter<double>("TkSizeMax");
250 
251  int TCNoBin = conf->getParameter<int>("TCSizeBin");
252  double TCNoMin = conf->getParameter<double>("TCSizeMin");
253  double TCNoMax = conf->getParameter<double>("TCSizeMax");
254 
255  int TKNoSeedBin = conf->getParameter<int>("TkSeedSizeBin");
256  double TKNoSeedMin = conf->getParameter<double>("TkSeedSizeMin");
257  double TKNoSeedMax = conf->getParameter<double>("TkSeedSizeMax");
258 
259  int MeanHitBin = conf->getParameter<int>("MeanHitBin");
260  double MeanHitMin = conf->getParameter<double>("MeanHitMin");
261  double MeanHitMax = conf->getParameter<double>("MeanHitMax");
262 
263  int MeanLayBin = conf->getParameter<int>("MeanLayBin");
264  double MeanLayMin = conf->getParameter<double>("MeanLayMin");
265  double MeanLayMax = conf->getParameter<double>("MeanLayMax");
266 
267  int LSBin = conf->getParameter<int>("LSBin");
268  int LSMin = conf->getParameter<double>("LSMin");
269  int LSMax = conf->getParameter<double>("LSMax");
270 
271  std::string StateName = conf->getParameter<std::string>("MeasurementState");
272  if (StateName != "OuterSurface" && StateName != "InnerSurface" && StateName != "ImpactPoint" &&
273  StateName != "default" && StateName != "All") {
274  // print warning
275  edm::LogWarning("TrackingMonitor") << "State Name is invalid, using 'ImpactPoint' by default";
276  }
277 
278  ibooker.setCurrentFolder(MEFolderName);
279 
280  // book the General Property histograms
281  // ---------------------------------------------------------------------------------//
282 
284  ibooker.setCurrentFolder(MEFolderName + "/GeneralProperties");
285 
286  histname = "NumberOfTracks_" + CategoryName;
287  // MODIFY by Mia in order to cope w/ high multiplicity
288  NumberOfTracks = ibooker.book1D(histname, histname, 3 * TKNoBin, TKNoMin, (TKNoMax + 0.5) * 3. - 0.5);
289  NumberOfTracks->setAxisTitle("Number of Tracks per Event", 1);
290  NumberOfTracks->setAxisTitle("Number of Events", 2);
291 
292  if (Folder == "Tr") {
293  histname = "NumberOfTracks_PUvtx_" + CategoryName;
294  NumberOfTracks_PUvtx = ibooker.book1D(histname, histname, 3 * TKNoBin, TKNoMin, (TKNoMax + 0.5) * 3. - 0.5);
295  NumberOfTracks_PUvtx->setAxisTitle("Number of Tracks per Event (matched a PU vertex)", 1);
296  NumberOfTracks_PUvtx->setAxisTitle("Number of Events", 2);
297 
298  histname = "NumberofTracks_Hardvtx_" + CategoryName;
300  ibooker.book1D(histname, histname, TKNoBin / 10, TKNoMin, (TKNoMax / 10 + 0.5) * 3. - 0.5);
301  NumberofTracks_Hardvtx->setAxisTitle("Number of Tracks per Event (matched main vertex)", 1);
302  NumberofTracks_Hardvtx->setAxisTitle("Number of Events", 2);
303 
304  histname = "NumberofTracks_Hardvtx_PUvtx_" + CategoryName;
305  NumberofTracks_Hardvtx_PUvtx = ibooker.book1D(histname, histname, 2, 0., 2.);
306  NumberofTracks_Hardvtx_PUvtx->setAxisTitle("Number of Tracks per PU/Hard vertex", 1);
307  NumberofTracks_Hardvtx_PUvtx->setAxisTitle("Number of Tracks", 2);
308  NumberofTracks_Hardvtx_PUvtx->setBinLabel(1, "PU_Vertex");
309  NumberofTracks_Hardvtx_PUvtx->setBinLabel(2, "Hard_Vertex");
310  }
311 
312  histname = "NumberOfMeanRecHitsPerTrack_" + CategoryName;
313  NumberOfMeanRecHitsPerTrack = ibooker.book1D(histname, histname, MeanHitBin, MeanHitMin, MeanHitMax);
314  NumberOfMeanRecHitsPerTrack->setAxisTitle("Mean number of valid RecHits per Track", 1);
316 
317  histname = "NumberOfMeanLayersPerTrack_" + CategoryName;
318  NumberOfMeanLayersPerTrack = ibooker.book1D(histname, histname, MeanLayBin, MeanLayMin, MeanLayMax);
319  NumberOfMeanLayersPerTrack->setAxisTitle("Mean number of Layers per Track", 1);
321 
322  if (doFractionPlot_) {
323  histname = "FractionOfGoodTracks_" + CategoryName;
324  FractionOfGoodTracks = ibooker.book1D(histname, histname, 101, -0.005, 1.005);
325  FractionOfGoodTracks->setAxisTitle("Fraction of Tracks (w.r.t. generalTracks)", 1);
326  FractionOfGoodTracks->setAxisTitle("Entries", 2);
327  }
328  }
329 
330  if (doLumiAnalysis) {
331  // add by Mia in order to deal with LS transitions
332  ibooker.setCurrentFolder(MEFolderName + "/LSanalysis");
333 
334  histname = "NumberOfTracks_lumiFlag_" + CategoryName;
335  NumberOfTracks_lumiFlag = ibooker.book1D(histname, histname, 3 * TKNoBin, TKNoMin, (TKNoMax + 0.5) * 3. - 0.5);
336  NumberOfTracks_lumiFlag->setAxisTitle("Number of Tracks per Event", 1);
337  NumberOfTracks_lumiFlag->setAxisTitle("Number of Events", 2);
338  }
339 
340  // book profile plots vs LS :
341  //---------------------------
342 
343  if (doProfilesVsLS_ || doAllPlots) {
344  ibooker.setCurrentFolder(MEFolderName + "/GeneralProperties");
345 
346  histname = "NumberOfTracksVsLS_" + CategoryName;
347  NumberOfTracksVsLS = ibooker.bookProfile(histname, histname, LSBin, LSMin, LSMax, TKNoMin, TKNoMax * 3., "");
348  NumberOfTracksVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
349  NumberOfTracksVsLS->setAxisTitle("#Lumi section", 1);
350  NumberOfTracksVsLS->setAxisTitle("Number of Tracks", 2);
351 
352  histname = "NumberOfRecHitsPerTrackVsLS_" + CategoryName;
353  NumberOfRecHitsPerTrackVsLS = ibooker.bookProfile(histname, histname, LSBin, LSMin, LSMax, 0., 200., "");
354  NumberOfRecHitsPerTrackVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
355  NumberOfRecHitsPerTrackVsLS->setAxisTitle("#Lumi section", 1);
356  NumberOfRecHitsPerTrackVsLS->setAxisTitle("Mean number of Valid RecHits per track", 2);
357 
358  histname = "NumberEventsVsLS_" + CategoryName;
359  NumberEventsOfVsLS = ibooker.book1D(histname, histname, LSBin, LSMin, LSMax);
360  NumberEventsOfVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
361  NumberEventsOfVsLS->setAxisTitle("#Lumi section", 1);
362  NumberEventsOfVsLS->setAxisTitle("Number of events", 2);
363 
364  double GoodPVtxMin = conf->getParameter<double>("GoodPVtxMin");
365  double GoodPVtxMax = conf->getParameter<double>("GoodPVtxMax");
366 
367  histname = "NumberOfGoodPVtxVsLS_" + CategoryName;
369  ibooker.bookProfile(histname, histname, LSBin, LSMin, LSMax, GoodPVtxMin, 3. * GoodPVtxMax, "");
370  NumberOfGoodPVtxVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
371  NumberOfGoodPVtxVsLS->setAxisTitle("#Lumi section", 1);
372  NumberOfGoodPVtxVsLS->setAxisTitle("Mean number of good PV", 2);
373 
374  histname = "NumberOfGoodPVtxWO0VsLS_" + CategoryName;
376  ibooker.bookProfile(histname, histname, LSBin, LSMin, LSMax, GoodPVtxMin, 3. * GoodPVtxMax, "");
377  NumberOfGoodPVtxWO0VsLS->setAxisTitle("#Lumi section", 1);
378  NumberOfGoodPVtxWO0VsLS->setAxisTitle("Mean number of good PV", 2);
379 
380  if (doFractionPlot_) {
381  histname = "GoodTracksFractionVsLS_" + CategoryName;
382  GoodTracksFractionVsLS = ibooker.bookProfile(histname, histname, LSBin, LSMin, LSMax, 0, 1.1, "");
383  GoodTracksFractionVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
384  GoodTracksFractionVsLS->setAxisTitle("#Lumi section", 1);
385  GoodTracksFractionVsLS->setAxisTitle("Fraction of Good Tracks", 2);
386  }
387 
388  if (doPlotsVsBX_ || doAllPlots) {
389  ibooker.setCurrentFolder(MEFolderName + "/BXanalysis");
390  int BXBin = 3564;
391  double BXMin = 0.5;
392  double BXMax = 3564.5;
393 
394  histname = "NumberEventsVsBX_" + CategoryName;
395  NumberEventsOfVsBX = ibooker.book1D(histname, histname, BXBin, BXMin, BXMax);
397  NumberEventsOfVsBX->setAxisTitle("Number of events", 2);
398 
399  histname = "NumberOfTracksVsBX_" + CategoryName;
400  NumberOfTracksVsBX = ibooker.bookProfile(histname, histname, BXBin, BXMin, BXMax, TKNoMin, TKNoMax * 3., "");
402  NumberOfTracksVsBX->setAxisTitle("Number of Tracks", 2);
403 
404  histname = "NumberOfRecHitsPerTrackVsBX_" + CategoryName;
405  NumberOfRecHitsPerTrackVsBX = ibooker.bookProfile(histname, histname, BXBin, BXMin, BXMax, 0., 200., "");
407  NumberOfRecHitsPerTrackVsBX->setAxisTitle("Mean number of Valid RecHits per track", 2);
408 
409  histname = "NumberOfGoodPVtxVsBX_" + CategoryName;
411  ibooker.bookProfile(histname, histname, BXBin, BXMin, BXMax, GoodPVtxMin, 3. * GoodPVtxMax, "");
413  NumberOfGoodPVtxVsBX->setAxisTitle("Mean number of good PV", 2);
414 
415  histname = "NumberOfGoodPVtxWO0VsBX_" + CategoryName;
417  ibooker.bookProfile(histname, histname, BXBin, BXMin, BXMax, GoodPVtxMin, 3. * GoodPVtxMax, "");
419  NumberOfGoodPVtxWO0VsBX->setAxisTitle("Mean number of good PV", 2);
420 
421  if (doFractionPlot_) {
422  histname = "GoodTracksFractionVsBX_" + CategoryName;
423  GoodTracksFractionVsBX = ibooker.bookProfile(histname, histname, BXBin, BXMin, BXMax, 0, 1.1, "");
425  GoodTracksFractionVsBX->setAxisTitle("Fraction of Good Tracks", 2);
426  }
427  }
428  }
429 
430  // book PU monitoring plots :
431  //---------------------------
432 
433  if (doPUmonitoring_) {
434  for (size_t i = 0; i < theVertexMonitor.size(); i++)
435  theVertexMonitor[i]->initHisto(ibooker);
436  }
437 
438  if (doPlotsVsGoodPVtx_) {
439  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring");
440  // get binning from the configuration
441  int PVBin = conf->getParameter<int>("PVBin");
442  float PVMin = conf->getParameter<double>("PVMin");
443  float PVMax = conf->getParameter<double>("PVMax");
444 
445  histname = "NumberOfTracksVsGoodPVtx";
446  NumberOfTracksVsGoodPVtx = ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, TKNoMin, TKNoMax * 5., "");
447  NumberOfTracksVsGoodPVtx->setAxisTitle("Number of PV", 1);
448  NumberOfTracksVsGoodPVtx->setAxisTitle("Mean number of Tracks per Event", 2);
449 
450  histname = "NumberOfTracksVsPUPVtx";
451  NumberOfTracksVsPUPVtx = ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, 0., TKNoMax * 5., "");
452  NumberOfTracksVsPUPVtx->setAxisTitle("Number of PU", 1);
453  NumberOfTracksVsPUPVtx->setAxisTitle("Mean number of Tracks per PUvtx", 2);
454 
455  histname = "NumberEventsVsGoodPVtx";
456  NumberEventsOfVsGoodPVtx = ibooker.book1D(histname, histname, PVBin, PVMin, PVMax);
457  NumberEventsOfVsGoodPVtx->setAxisTitle("Number of good PV (PU)", 1);
458  NumberEventsOfVsGoodPVtx->setAxisTitle("Number of events", 2);
459 
460  if (doFractionPlot_) {
461  histname = "GoodTracksFractionVsGoodPVtx";
462  GoodTracksFractionVsGoodPVtx = ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, 0., 1.1, "");
463  GoodTracksFractionVsGoodPVtx->setAxisTitle("Number of good PV (PU)", 1);
464  GoodTracksFractionVsGoodPVtx->setAxisTitle("Mean fraction of good tracks", 2);
465  }
466 
467  histname = "NumberOfRecHitsPerTrackVsGoodPVtx";
468  NumberOfRecHitsPerTrackVsGoodPVtx = ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, 0., 200., "");
469  NumberOfRecHitsPerTrackVsGoodPVtx->setAxisTitle("Number of good PV (PU)", 1);
470  NumberOfRecHitsPerTrackVsGoodPVtx->setAxisTitle("Mean number of valid rechits per Tracks", 2);
471 
472  histname = "NumberOfPVtxVsGoodPVtx";
473  NumberOfPVtxVsGoodPVtx = ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, 0., 3. * PVMax, "");
474  NumberOfPVtxVsGoodPVtx->setAxisTitle("Number of good PV (PU)", 1);
475  NumberOfPVtxVsGoodPVtx->setAxisTitle("Mean number of vertices", 2);
476 
477  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
478  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
479  histname = "NumberOfPixelClustersVsGoodPVtx";
481  ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, NClusPxMin, 3. * NClusPxMax, "");
482  NumberOfPixelClustersVsGoodPVtx->setAxisTitle("Number of good PV (PU)", 1);
483  NumberOfPixelClustersVsGoodPVtx->setAxisTitle("Mean number of pixel clusters", 2);
484 
485  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
486  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
487  histname = "NumberOfStripClustersVsGoodPVtx";
489  ibooker.bookProfile(histname, histname, PVBin, PVMin, PVMax, NClusStrMin, 3. * NClusStrMax, "");
490  NumberOfStripClustersVsGoodPVtx->setAxisTitle("Number of good PV (PU)", 1);
491  NumberOfStripClustersVsGoodPVtx->setAxisTitle("Mean number of strip clusters", 2);
492  }
493 
494  if (doPlotsVsLUMI_ || doAllPlots) {
495  ibooker.setCurrentFolder(MEFolderName + "/LUMIanalysis");
496  int LUMIBin = conf->getParameter<int>("LUMIBin");
497  float LUMIMin = conf->getParameter<double>("LUMIMin");
498  float LUMIMax = conf->getParameter<double>("LUMIMax");
499 
500  histname = "NumberEventsVsLUMI";
501  NumberEventsOfVsLUMI = ibooker.book1D(histname, histname, LUMIBin, LUMIMin, LUMIMax);
502  NumberEventsOfVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
503  NumberEventsOfVsLUMI->setAxisTitle("Number of events", 2);
504 
505  histname = "NumberOfTracksVsLUMI";
506  NumberOfTracksVsLUMI = ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, 0., 2000., "");
507  NumberOfTracksVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
508  NumberOfTracksVsLUMI->setAxisTitle("Mean number of vertices", 2);
509 
510  if (doFractionPlot_) {
511  histname = "GoodTracksFractionVsLUMI";
512  GoodTracksFractionVsLUMI = ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, 0., 1.1, "");
513  GoodTracksFractionVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
514  GoodTracksFractionVsLUMI->setAxisTitle("Mean number of vertices", 2);
515  }
516 
517  histname = "NumberOfRecHitsPerTrackVsLUMI";
518  NumberOfRecHitsPerTrackVsLUMI = ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, 0., 200., "");
519  NumberOfRecHitsPerTrackVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
520  NumberOfRecHitsPerTrackVsLUMI->setAxisTitle("Mean number of vertices", 2);
521 
522  double PVMin = conf->getParameter<double>("PVMin");
523  double PVMax = conf->getParameter<double>("PVMax");
524 
525  histname = "NumberOfGoodPVtxVsLUMI";
526  NumberOfGoodPVtxVsLUMI = ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, PVMin, 3. * PVMax, "");
527  NumberOfGoodPVtxVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
528  NumberOfGoodPVtxVsLUMI->setAxisTitle("Mean number of vertices", 2);
529 
530  histname = "NumberOfGoodPVtxWO0VsLUMI";
532  ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, PVMin, 3. * PVMax, "");
533  NumberOfGoodPVtxWO0VsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
534  NumberOfGoodPVtxWO0VsLUMI->setAxisTitle("Mean number of vertices", 2);
535 
536  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
537  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
538  histname = "NumberOfPixelClustersVsGoodPVtx";
540  ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, NClusPxMin, 3. * NClusPxMax, "");
541  NumberOfPixelClustersVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
542  NumberOfPixelClustersVsLUMI->setAxisTitle("Mean number of pixel clusters", 2);
543 
544  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
545  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
546  histname = "NumberOfStripClustersVsLUMI";
548  ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, NClusStrMin, 3. * NClusStrMax, "");
549  NumberOfStripClustersVsLUMI->setAxisTitle("scal lumi [10e30 Hz cm^{-2}]", 1);
550  NumberOfStripClustersVsLUMI->setAxisTitle("Mean number of strip clusters", 2);
551  }
552 
553  if (doPlotsVsBXlumi_) {
554  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring");
555  // get binning from the configuration
556  edm::ParameterSet BXlumiParameters = conf->getParameter<edm::ParameterSet>("BXlumiSetup");
557  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
558  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
559  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
560 
561  histname = "NumberOfTracksVsBXlumi_" + CategoryName;
563  ibooker.bookProfile(histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, TKNoMin, 3. * TKNoMax, "");
564  NumberOfTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]", 1);
565  NumberOfTracksVsBXlumi->setAxisTitle("Mean number of Tracks", 2);
566  }
567 
568  theTrackAnalyzer->initHisto(ibooker, iSetup, *conf);
569 
570  // book the Seed Property histograms
571  // ---------------------------------------------------------------------------------//
572 
573  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
574 
575  doAllSeedPlots = conf->getParameter<bool>("doSeedParameterHistos");
576  doSeedNumberPlot = conf->getParameter<bool>("doSeedNumberHisto");
577  doSeedLumiAnalysis_ = conf->getParameter<bool>("doSeedLumiAnalysis");
578  doSeedVsClusterPlot = conf->getParameter<bool>("doSeedVsClusterHisto");
579  // if (doAllPlots) doAllSeedPlots=true;
580 
582  (doAllSeedPlots || conf->getParameter<bool>("doSeedPTHisto") || conf->getParameter<bool>("doSeedETAHisto") ||
583  conf->getParameter<bool>("doSeedPHIHisto") || conf->getParameter<bool>("doSeedPHIVsETAHisto") ||
584  conf->getParameter<bool>("doSeedThetaHisto") || conf->getParameter<bool>("doSeedQHisto") ||
585  conf->getParameter<bool>("doSeedDxyHisto") || conf->getParameter<bool>("doSeedDzHisto") ||
586  conf->getParameter<bool>("doSeedNRecHitsHisto") || conf->getParameter<bool>("doSeedNVsPhiProf") ||
587  conf->getParameter<bool>("doSeedNVsEtaProf"));
588 
589  edm::InputTag seedProducer = conf->getParameter<edm::InputTag>("SeedProducer");
590 
591  if (doAllSeedPlots || doSeedNumberPlot) {
592  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
593  histname = "NumberOfSeeds_" + seedProducer.label() + "_" + CategoryName;
594  NumberOfSeeds = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
595  NumberOfSeeds->setAxisTitle("Number of Seeds per Event", 1);
596  NumberOfSeeds->setAxisTitle("Number of Events", 2);
597 
598  if (doSeedLumiAnalysis_) {
599  ibooker.setCurrentFolder(MEFolderName + "/LSanalysis");
600  histname = "NumberOfSeeds_lumiFlag_" + seedProducer.label() + "_" + CategoryName;
601  NumberOfSeeds_lumiFlag = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
602  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Seeds per Event", 1);
603  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Events", 2);
604  }
605  }
606 
607  if (doAllSeedPlots || doSeedVsClusterPlot) {
608  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
609 
610  ClusterLabels = conf->getParameter<std::vector<std::string> >("ClusterLabels");
611 
612  std::vector<double> histoMin, histoMax;
613  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
614 
615  int NClusPxBin = conf->getParameter<int>("NClusPxBin");
616  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
617  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
618 
619  int NClusStrBin = conf->getParameter<int>("NClusStrBin");
620  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
621  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
622 
623  setMaxMinBin(
624  histoMin, histoMax, histoBin, NClusStrMin, NClusStrMax, NClusStrBin, NClusPxMin, NClusPxMax, NClusPxBin);
625 
626  for (uint i = 0; i < ClusterLabels.size(); i++) {
627  histname = "SeedsVsClusters_" + seedProducer.label() + "_Vs_" + ClusterLabels[i] + "_" + CategoryName;
628  SeedsVsClusters.push_back(dynamic_cast<MonitorElement*>(ibooker.book2D(
629  histname, histname, histoBin[i], histoMin[i], histoMax[i], TKNoSeedBin, TKNoSeedMin, TKNoSeedMax)));
630  SeedsVsClusters[i]->setAxisTitle("Number of Clusters", 1);
631  SeedsVsClusters[i]->setAxisTitle("Number of Seeds", 2);
632  SeedsVsClusters[i]->getTH2F()->SetCanExtend(TH1::kAllAxes);
633  }
634  }
635 
636  if (doRegionPlots) {
637  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
638 
639  int regionBin = conf->getParameter<int>("RegionSizeBin");
640  double regionMin = conf->getParameter<double>("RegionSizeMin");
641  double regionMax = conf->getParameter<double>("RegionSizeMax");
642 
643  histname = "TrackingRegionsNumberOf_" + seedProducer.label() + "_" + CategoryName;
644  NumberOfTrackingRegions = ibooker.book1D(histname, histname, regionBin, regionMin, regionMax);
645  NumberOfTrackingRegions->setAxisTitle("Number of TrackingRegions per Event", 1);
646  NumberOfTrackingRegions->setAxisTitle("Number of Events", 2);
647  }
648 
649  doTkCandPlots = conf->getParameter<bool>("doTrackCandHistos");
650  // if (doAllPlots) doTkCandPlots=true;
651 
652  if (doTkCandPlots) {
653  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
654 
655  edm::InputTag tcProducer = conf->getParameter<edm::InputTag>("TCProducer");
656 
657  histname = "NumberOfTrackCandidates_" + tcProducer.label() + "_" + CategoryName;
658  NumberOfTrackCandidates = ibooker.book1D(histname, histname, TCNoBin, TCNoMin, TCNoMax);
659  NumberOfTrackCandidates->setAxisTitle("Number of Track Candidates per Event", 1);
660  NumberOfTrackCandidates->setAxisTitle("Number of Event", 2);
661 
662  histname = "FractionOfCandOverSeeds_" + tcProducer.label() + "_" + CategoryName;
663  FractionCandidatesOverSeeds = ibooker.book1D(histname, histname, 101, 0., 1.01);
664  FractionCandidatesOverSeeds->setAxisTitle("Number of Track Candidates / Number of Seeds per Event", 1);
665  FractionCandidatesOverSeeds->setAxisTitle("Number of Event", 2);
666  }
667 
668  theTrackBuildingAnalyzer->initHisto(ibooker, *conf);
669 
670  if (doLumiAnalysis) {
674  }
675 
676  if (doAllSeedPlots || doSeedNumberPlot) {
677  if (doSeedLumiAnalysis_)
679  }
680 
682  ClusterLabels = conf->getParameter<std::vector<std::string> >("ClusterLabels");
683 
684  std::vector<double> histoMin, histoMax;
685  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
686 
687  int NClusStrBin = conf->getParameter<int>("NClusStrBin");
688  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
689  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
690 
691  int NClusPxBin = conf->getParameter<int>("NClusPxBin");
692  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
693  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
694 
695  int NTrk2DBin = conf->getParameter<int>("NTrk2DBin");
696  double NTrk2DMin = conf->getParameter<double>("NTrk2DMin");
697  double NTrk2DMax = conf->getParameter<double>("NTrk2DMax");
698 
699  setMaxMinBin(
700  histoMin, histoMax, histoBin, NClusStrMin, NClusStrMax, NClusStrBin, NClusPxMin, NClusPxMax, NClusPxBin);
701 
702  ibooker.setCurrentFolder(MEFolderName + "/HitProperties");
703 
704  for (uint i = 0; i < ClusterLabels.size(); i++) {
705  ibooker.setCurrentFolder(MEFolderName + "/HitProperties");
706  histname = "TracksVs" + ClusterLabels[i] + "Cluster_" + CategoryName;
707  NumberOfTrkVsClusters.push_back(dynamic_cast<MonitorElement*>(
708  ibooker.book2D(histname, histname, histoBin[i], histoMin[i], histoMax[i], NTrk2DBin, NTrk2DMin, NTrk2DMax)));
709  std::string title = "Number of " + ClusterLabels[i] + " Clusters";
710  if (ClusterLabels[i] == "Tot")
711  title = "# of Clusters in (Pixel+Strip) Detectors";
712  NumberOfTrkVsClusters[i]->setAxisTitle(title, 1);
713  NumberOfTrkVsClusters[i]->setAxisTitle("Number of Tracks", 2);
714  NumberOfTrkVsClusters[i]->getTH1()->SetCanExtend(TH1::kXaxis);
715  }
716  }
717 
718  // Initialize the GenericTriggerEventFlag
719  if (genTriggerEventFlag_->on())
720  genTriggerEventFlag_->initRun(iRun, iSetup);
721 }
722 
723 /*
724 // -- BeginRun
725 //---------------------------------------------------------------------------------//
726 void TrackingMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
727 {
728 
729 }
730 */
731 
732 // - BeginLumi
733 // ---------------------------------------------------------------------------------//
735  if (doLumiAnalysis) {
739  }
743  }
744 }
745 
746 // -- Analyse
747 // ---------------------------------------------------------------------------------//
749  // Filter out events if Trigger Filtering is requested
750  if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(iEvent, iSetup))
751  return;
752  auto const* conf = edm::pset::Registry::instance()->getMapped(confID_);
753  MEFolderName = conf->getParameter<std::string>("FolderName");
754  std::string Folder = MEFolderName.substr(0, 2);
755  float lumi = -1.;
757  iEvent.getByToken(lumiscalersToken_, lumiScalers);
758  if (lumiScalers.isValid() && !lumiScalers->empty()) {
759  LumiScalersCollection::const_iterator scalit = lumiScalers->begin();
760  lumi = scalit->instantLumi();
761  } else
762  lumi = -1.;
763 
764  if (doPlotsVsLUMI_ || doAllPlots)
765  NumberEventsOfVsLUMI->Fill(lumi);
766 
767  // Analyse the tracks
768  // if the collection is empty, do not fill anything
769  // ---------------------------------------------------------------------------------//
770 
771  size_t bx = iEvent.bunchCrossing();
772  if (doPlotsVsBX_ || doAllPlots)
774 
775  // get the track collection
777  iEvent.getByToken(trackToken_, trackHandle);
778 
779  int numberOfTracks_den = 0;
780  edm::Handle<edm::View<reco::Track> > allTrackHandle;
781  iEvent.getByToken(allTrackToken_, allTrackHandle);
782  if (allTrackHandle.isValid()) {
783  for (edm::View<reco::Track>::const_iterator track = allTrackHandle->begin(); track != allTrackHandle->end();
784  ++track) {
785  if (denSelection_(*track))
786  numberOfTracks_den++;
787  }
788  }
789 
791  iEvent.getByToken(pvSrcToken_, pvHandle);
792  reco::Vertex const* pv0 = nullptr;
793  if (pvHandle.isValid()) {
794  pv0 = &pvHandle->front();
795  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
796  if (pv0->isFake() ||
797  pv0->tracksSize() == 0
798  // definition of goodOfflinePrimaryVertex
799  || pv0->ndof() < pvNDOF_ || pv0->z() > 24.)
800  pv0 = nullptr;
801  }
802 
803  if (trackHandle.isValid()) {
804  int numberOfTracks = trackHandle->size();
805  int numberOfTracks_num = 0;
806  int numberOfTracks_pv0 = 0;
807 
808  const edm::View<reco::Track>& trackCollection = *trackHandle;
809  // calculate the mean # rechits and layers
810  int totalRecHits = 0, totalLayers = 0;
811 
813  theTrackAnalyzer->setBX(iEvent);
814  theTrackAnalyzer->setLumi(iEvent, iSetup);
815  for (edm::View<reco::Track>::const_iterator track = trackCollection.begin(); track != trackCollection.end();
816  ++track) {
817  if (doPlotsVsBX_ || doAllPlots)
818  NumberOfRecHitsPerTrackVsBX->Fill(bx, track->numberOfValidHits());
819  if (numSelection_(*track)) {
820  numberOfTracks_num++;
821  if (pv0 && std::abs(track->dz(pv0->position())) < 0.15)
822  ++numberOfTracks_pv0;
823  }
824 
826  NumberOfRecHitsPerTrackVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),
827  track->numberOfValidHits());
828 
829  if (doPlotsVsLUMI_ || doAllPlots)
830  NumberOfRecHitsPerTrackVsLUMI->Fill(lumi, track->numberOfValidHits());
831 
832  totalRecHits += track->numberOfValidHits();
833  totalLayers += track->hitPattern().trackerLayersWithMeasurement();
834 
835  // do analysis per track
836  theTrackAnalyzer->analyze(iEvent, iSetup, *track);
837  }
838 
839  double frac = -1.;
840  // if (numberOfAllTracks > 0) frac = static_cast<double>(numberOfTracks)/static_cast<double>(numberOfAllTracks);
841  if (numberOfTracks_den > 0)
842  frac = static_cast<double>(numberOfTracks_num) / static_cast<double>(numberOfTracks_den);
843 
845  NumberOfTracks->Fill(double(numberOfTracks));
846 
847  if (Folder == "Tr") {
848  NumberofTracks_Hardvtx->Fill(double(numberOfTracks_pv0));
849  NumberOfTracks_PUvtx->Fill(double(numberOfTracks - numberOfTracks_pv0));
850  NumberofTracks_Hardvtx_PUvtx->Fill(0.5, double(numberOfTracks_pv0));
851  NumberofTracks_Hardvtx_PUvtx->Fill(1.5, double(numberOfTracks - numberOfTracks_pv0));
852  }
853 
854  if (doPlotsVsBX_ || doAllPlots)
855  NumberOfTracksVsBX->Fill(bx, numberOfTracks);
856  if (doPlotsVsLUMI_ || doAllPlots)
857  NumberOfTracksVsLUMI->Fill(lumi, numberOfTracks);
858  if (doFractionPlot_) {
859  FractionOfGoodTracks->Fill(frac);
860 
861  if (doFractionPlot_) {
862  if (doPlotsVsBX_ || doAllPlots)
863  GoodTracksFractionVsBX->Fill(bx, frac);
864  if (doPlotsVsLUMI_ || doAllPlots)
865  GoodTracksFractionVsLUMI->Fill(lumi, frac);
866  }
867  }
868  if (numberOfTracks > 0) {
869  double meanRecHits = static_cast<double>(totalRecHits) / static_cast<double>(numberOfTracks);
870  double meanLayers = static_cast<double>(totalLayers) / static_cast<double>(numberOfTracks);
871  NumberOfMeanRecHitsPerTrack->Fill(meanRecHits);
872  NumberOfMeanLayersPerTrack->Fill(meanLayers);
873  }
874  }
875 
876  if (doProfilesVsLS_ || doAllPlots) {
877  float nLS = static_cast<double>(iEvent.id().luminosityBlock());
878  NumberEventsOfVsLS->Fill(nLS);
879  NumberOfTracksVsLS->Fill(nLS, numberOfTracks);
880  if (doFractionPlot_)
881  GoodTracksFractionVsLS->Fill(nLS, frac);
882  }
883 
884  if (doLumiAnalysis) {
885  NumberOfTracks_lumiFlag->Fill(numberOfTracks);
886  }
887 
888  // Analyse the Track Building variables
889  // if the collection is empty, do not fill anything
890  // ---------------------------------------------------------------------------------//
891 
892  // fill the TrackCandidate info
893  if (doTkCandPlots) {
894  // magnetic field
896  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
897 
898  // get the candidate collection
900  iEvent.getByToken(trackCandidateToken_, theTCHandle);
901  const TrackCandidateCollection& theTCCollection = *theTCHandle;
902 
903  if (theTCHandle.isValid()) {
904  // get the beam spot
905  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
906  iEvent.getByToken(bsSrcToken_, recoBeamSpotHandle);
907  const reco::BeamSpot& bs = *recoBeamSpotHandle;
908 
909  NumberOfTrackCandidates->Fill(theTCCollection.size());
910 
911  // get the seed collection
913  iEvent.getByToken(seedToken_, seedHandle);
914  const edm::View<TrajectorySeed>& seedCollection = *seedHandle;
915  if (seedHandle.isValid() && !seedCollection.empty())
916  FractionCandidatesOverSeeds->Fill(double(theTCCollection.size()) / double(seedCollection.size()));
917 
919  for (TrackCandidateCollection::const_iterator cand = theTCCollection.begin(); cand != theTCCollection.end();
920  ++cand) {
921  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *cand, bs, theMF, theTTRHBuilder);
922  }
923  } else {
924  edm::LogWarning("TrackingMonitor") << "No Track Candidates in the event. Not filling associated histograms";
925  }
926 
927  if (doMVAPlots) {
928  // Get MVA and quality mask collections
929  std::vector<const MVACollection*> mvaCollections;
930  std::vector<const QualityMaskCollection*> qualityMaskCollections;
931 
933  iEvent.getByToken(mvaTrackToken_, htracks);
934 
937  for (const auto& tokenTpl : mvaQualityTokens_) {
938  iEvent.getByToken(std::get<0>(tokenTpl), hmva);
939  iEvent.getByToken(std::get<1>(tokenTpl), hqual);
940 
941  mvaCollections.push_back(hmva.product());
942  qualityMaskCollections.push_back(hqual.product());
943  }
944  theTrackBuildingAnalyzer->analyze(*htracks, mvaCollections, qualityMaskCollections);
945  }
946  }
947 
948  //plots for trajectory seeds
949 
951  // get the seed collection
953  iEvent.getByToken(seedToken_, seedHandle);
954 
955  // fill the seed info
956  if (seedHandle.isValid()) {
957  const auto& seedCollection = *seedHandle;
958 
963  }
964 
966  std::vector<int> NClus;
967  setNclus(iEvent, NClus);
968  for (uint i = 0; i < ClusterLabels.size(); i++) {
969  SeedsVsClusters[i]->Fill(NClus[i], seedCollection.size());
970  }
971  }
972 
975  iEvent.getByToken(seedStopInfoToken_, stopHandle);
976  const auto& seedStopInfo = *stopHandle;
977 
978  if (seedStopInfo.size() == seedCollection.size()) {
979  //here duplication of mag field and be informations is needed to allow seed and track cand histos to be independent
980  // magnetic field
982  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
983 
984  // get the beam spot
985  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
986  iEvent.getByToken(bsSrcToken_, recoBeamSpotHandle);
987  const reco::BeamSpot& bs = *recoBeamSpotHandle;
988 
990  for (size_t i = 0; i < seedCollection.size(); ++i) {
992  iEvent, iSetup, seedCollection[i], seedStopInfo[i], bs, theMF, theTTRHBuilder);
993  }
994  } else {
995  edm::LogWarning("TrackingMonitor")
996  << "Seed collection size (" << seedCollection.size()
997  << ") differs from seed stop info collection size (" << seedStopInfo.size()
998  << "). This is a sign of inconsistency in the configuration. Not filling associated histograms.";
999  }
1000  }
1001 
1002  } else {
1003  edm::LogWarning("TrackingMonitor") << "No Trajectory seeds in the event. Not filling associated histograms";
1004  }
1005  }
1006 
1007  // plots for tracking regions
1008  if (doRegionPlots) {
1009  if (!regionToken_.isUninitialized()) {
1011  iEvent.getByToken(regionToken_, hregions);
1012  const auto& regions = *hregions;
1014 
1016  } else if (!regionLayerSetsToken_.isUninitialized()) {
1018  iEvent.getByToken(regionLayerSetsToken_, hregions);
1019  const auto& regions = *hregions;
1020  NumberOfTrackingRegions->Fill(regions.regionsSize());
1021 
1023  }
1024 
1025  if (doRegionCandidatePlots) {
1027  iEvent.getByToken(regionCandidateToken_, hcandidates);
1028  theTrackBuildingAnalyzer->analyze(*hcandidates);
1029  }
1030  }
1031 
1032  if (doTrackerSpecific_ || doAllPlots) {
1033  std::vector<int> NClus;
1034  setNclus(iEvent, NClus);
1035  for (uint i = 0; i < ClusterLabels.size(); i++) {
1036  NumberOfTrkVsClusters[i]->Fill(NClus[i], numberOfTracks);
1037  }
1038  }
1039 
1040  if (doPUmonitoring_) {
1041  // do vertex monitoring
1042  for (size_t i = 0; i < theVertexMonitor.size(); i++)
1043  theVertexMonitor[i]->analyze(iEvent, iSetup);
1044  }
1045  if (doPlotsVsGoodPVtx_) {
1046  size_t totalNumGoodPV = 0;
1047  if (pvHandle.isValid()) {
1048  for (reco::VertexCollection::const_iterator pv = pvHandle->begin(); pv != pvHandle->end(); ++pv) {
1049  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
1050  if (pv->isFake() || pv->tracksSize() == 0)
1051  continue;
1052 
1053  // definition of goodOfflinePrimaryVertex
1054  if (pv->ndof() < pvNDOF_ || pv->z() > 24.)
1055  continue;
1056  totalNumGoodPV++;
1057  }
1058 
1059  NumberEventsOfVsGoodPVtx->Fill(float(totalNumGoodPV));
1060  NumberOfTracksVsGoodPVtx->Fill(float(totalNumGoodPV), numberOfTracks);
1061  if (totalNumGoodPV > 1)
1062  NumberOfTracksVsPUPVtx->Fill(totalNumGoodPV - 1,
1063  double(numberOfTracks - numberOfTracks_pv0) / double(totalNumGoodPV - 1));
1064  NumberOfPVtxVsGoodPVtx->Fill(float(totalNumGoodPV), pvHandle->size());
1065 
1066  for (edm::View<reco::Track>::const_iterator track = trackCollection.begin(); track != trackCollection.end();
1067  ++track) {
1068  NumberOfRecHitsPerTrackVsGoodPVtx->Fill(float(totalNumGoodPV), track->numberOfValidHits());
1069  }
1070 
1071  if (doProfilesVsLS_ || doAllPlots)
1072  NumberOfGoodPVtxVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()), totalNumGoodPV);
1073  if (doPlotsVsBX_ || doAllPlots)
1074  NumberOfGoodPVtxVsBX->Fill(bx, float(totalNumGoodPV));
1075 
1076  if (doFractionPlot_)
1077  GoodTracksFractionVsGoodPVtx->Fill(float(totalNumGoodPV), frac);
1078 
1079  if (doPlotsVsLUMI_ || doAllPlots)
1080  NumberOfGoodPVtxVsLUMI->Fill(lumi, float(totalNumGoodPV));
1081  }
1082 
1083  std::vector<int> NClus;
1084  setNclus(iEvent, NClus);
1085  std::ostringstream ss;
1086  ss << "VI stat " << totalNumGoodPV << ' ' << numberOfTracks;
1087  for (uint i = 0; i < ClusterLabels.size(); i++) {
1088  ss << ' ' << NClus[i];
1089  if (doPlotsVsLUMI_ || doAllPlots) {
1090  if (ClusterLabels[i] == "Pix")
1091  NumberOfPixelClustersVsLUMI->Fill(lumi, NClus[i]);
1092  if (ClusterLabels[i] == "Strip")
1093  NumberOfStripClustersVsLUMI->Fill(lumi, NClus[i]);
1094  }
1095  if (ClusterLabels[i] == "Pix")
1096  NumberOfPixelClustersVsGoodPVtx->Fill(float(totalNumGoodPV), NClus[i]);
1097  if (ClusterLabels[i] == "Strip")
1098  NumberOfStripClustersVsGoodPVtx->Fill(float(totalNumGoodPV), NClus[i]);
1099  }
1100  COUT(MEFolderName) << ss.str() << std::endl;
1101  if (doPlotsVsBXlumi_) {
1102  double bxlumi = theLumiDetails_->getValue(iEvent);
1103  NumberOfTracksVsBXlumi->Fill(bxlumi, numberOfTracks);
1104  }
1105 
1106  if (doProfilesVsLS_ || doAllPlots)
1107  if (totalNumGoodPV != 0)
1108  NumberOfGoodPVtxWO0VsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()), float(totalNumGoodPV));
1109  if (doPlotsVsBX_ || doAllPlots)
1110  if (totalNumGoodPV != 0)
1111  NumberOfGoodPVtxWO0VsBX->Fill(bx, float(totalNumGoodPV));
1112  if (doPlotsVsLUMI_ || doAllPlots)
1113  if (totalNumGoodPV != 0)
1114  NumberOfGoodPVtxWO0VsLUMI->Fill(lumi, float(totalNumGoodPV));
1115 
1116  } // PU monitoring
1117 
1118  } // trackHandle is valid
1119 }
1120 
1122 
1123 void TrackingMonitor::setMaxMinBin(std::vector<double>& arrayMin,
1124  std::vector<double>& arrayMax,
1125  std::vector<int>& arrayBin,
1126  double smin,
1127  double smax,
1128  int sbin,
1129  double pmin,
1130  double pmax,
1131  int pbin) {
1132  arrayMin.resize(ClusterLabels.size());
1133  arrayMax.resize(ClusterLabels.size());
1134  arrayBin.resize(ClusterLabels.size());
1135 
1136  for (uint i = 0; i < ClusterLabels.size(); ++i) {
1137  if (ClusterLabels[i] == "Pix") {
1138  arrayMin[i] = pmin;
1139  arrayMax[i] = pmax;
1140  arrayBin[i] = pbin;
1141  } else if (ClusterLabels[i] == "Strip") {
1142  arrayMin[i] = smin;
1143  arrayMax[i] = smax;
1144  arrayBin[i] = sbin;
1145  } else if (ClusterLabels[i] == "Tot") {
1146  arrayMin[i] = smin;
1147  arrayMax[i] = smax + pmax;
1148  arrayBin[i] = sbin;
1149  } else {
1150  edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i]
1151  << " not defined, using strip parameters ";
1152  arrayMin[i] = smin;
1153  arrayMax[i] = smax;
1154  arrayBin[i] = sbin;
1155  }
1156  }
1157 }
1158 
1159 void TrackingMonitor::setNclus(const edm::Event& iEvent, std::vector<int>& arrayNclus) {
1160  int ncluster_pix = -1;
1161  int ncluster_strip = -1;
1162 
1164  iEvent.getByToken(stripClustersToken_, strip_clusters);
1166  iEvent.getByToken(pixelClustersToken_, pixel_clusters);
1167 
1168  if (strip_clusters.isValid() && pixel_clusters.isValid()) {
1169  ncluster_pix = (*pixel_clusters).dataSize();
1170  ncluster_strip = (*strip_clusters).dataSize();
1171  }
1172 
1173  arrayNclus.resize(ClusterLabels.size());
1174  for (uint i = 0; i < ClusterLabels.size(); ++i) {
1175  if (ClusterLabels[i] == "Pix")
1176  arrayNclus[i] = ncluster_pix;
1177  else if (ClusterLabels[i] == "Strip")
1178  arrayNclus[i] = ncluster_strip;
1179  else if (ClusterLabels[i] == "Tot")
1180  arrayNclus[i] = ncluster_pix + ncluster_strip;
1181  else {
1182  edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i]
1183  << " not defined using stri parametrs ";
1184  arrayNclus[i] = ncluster_strip;
1185  }
1186  }
1187 }
edm::EDGetTokenT< std::vector< SeedStopInfo > > seedStopInfoToken_
edm::EDGetTokenT< edm::View< reco::Track > > trackToken_
StringCutObjectSelector< reco::Track, true > denSelection_
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::OwnVector< TrackingRegion > > regionToken_
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken_
std::vector< MonitorElement * > NumberOfTrkVsClusters
MonitorElement * FractionOfGoodTracks
virtual void setMaxMinBin(std::vector< double > &, std::vector< double > &, std::vector< int > &, double, double, int, double, double, int)
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const TrajectorySeed &seed, const SeedStopInfo &stopInfo, const reco::BeamSpot &bs, const edm::ESHandle< MagneticField > &theMF, const edm::ESHandle< TransientTrackingRecHitBuilder > &theTTRHBuilder)
MonitorElement * NumberOfTracksVsBX
MonitorElement * NumberOfRecHitsPerTrackVsBX
MonitorElement * NumberOfRecHitsPerTrackVsLUMI
virtual void setNclus(const edm::Event &, std::vector< int > &)
~TrackingMonitor() override
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
MonitorElement * NumberEventsOfVsGoodPVtx
GetLumi * theLumiDetails_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void initHisto(DQMStore::IBooker &ibooker, const edm::EventSetup &, const edm::ParameterSet &)
std::vector< TrackCandidate > TrackCandidateCollection
#define nullptr
TH1 * getTH1() const
MonitorElement * FractionCandidatesOverSeeds
std::string MEFolderName
int bunchCrossing() const
Definition: EventBase.h:64
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::InputTag pvSrc_
size_type size() const
MonitorElement * GoodTracksFractionVsLUMI
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
MonitorElement * NumberOfPVtxVsGoodPVtx
MonitorElement * NumberOfMeanRecHitsPerTrack
MonitorElement * NumberOfTracksVsGoodPVtx
void initHisto(DQMStore::IBooker &ibooker, const edm::ParameterSet &)
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
const Point & position() const
position
Definition: Vertex.h:109
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * NumberOfStripClustersVsLUMI
MonitorElement * GoodTracksFractionVsLS
void Fill(long long x)
MonitorElement * NumberofTracks_Hardvtx_PUvtx
edm::EDGetTokenT< edm::View< reco::Track > > mvaTrackToken_
double getValue(const edm::Event &)
Definition: GetLumi.cc:64
std::string Quality_
MonitorElement * NumberOfGoodPVtxWO0VsLUMI
edm::InputTag bsSrc_
MonitorElement * NumberOfSeeds
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const_iterator begin() const
MonitorElement * NumberOfTrackingRegions
void setLumiFlag()
this ME is meant to be stored for each luminosity section
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void setBX(const edm::Event &)
MonitorElement * NumberOfGoodPVtxVsLS
edm::EDGetTokenT< edm::View< reco::Track > > allTrackToken_
MonitorElement * NumberOfGoodPVtxVsLUMI
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
#define COUT(x)
bool empty() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * NumberOfTracks_PUvtx
void endRun(const edm::Run &, const edm::EventSetup &) override
MonitorElement * NumberOfTracksVsLS
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * NumberOfGoodPVtxWO0VsLS
double z() const
z coordinate
Definition: Vertex.h:115
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
MonitorElement * NumberOfTracksVsPUPVtx
edm::EDGetTokenT< LumiScalersCollection > lumiscalersToken_
MonitorElement * NumberEventsOfVsBX
bool runTrackBuildingAnalyzerForSeed
void Reset()
reset ME (ie. contents, errors, etc)
MonitorElement * NumberOfStripClustersVsGoodPVtx
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * NumberOfPixelClustersVsGoodPVtx
dqm::TrackAnalyzer * theTrackAnalyzer
MonitorElement * NumberOfRecHitsPerTrackVsLS
MonitorElement * GoodTracksFractionVsGoodPVtx
double ndof() const
Definition: Vertex.h:105
MonitorElement * NumberOfRecHitsPerTrackVsGoodPVtx
edm::EDGetTokenT< TrackingRegionsSeedingLayerSets > regionLayerSetsToken_
std::string histname
edm::ParameterSetID confID_
MonitorElement * NumberOfPixelClustersVsLUMI
void setNumberOfGoodVertices(const edm::Event &)
std::vector< VertexMonitor * > theVertexMonitor
MonitorElement * NumberOfTracksVsBXlumi
edm::InputTag stripClusterInputTag_
bool doGeneralPropertiesPlots_
TrackBuildingAnalyzer * theTrackBuildingAnalyzer
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
bool isFake() const
Definition: Vertex.h:72
T const * product() const
Definition: Handle.h:74
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::string AlgoName_
edm::EDGetTokenT< TrackCandidateCollection > trackCandidateToken_
MonitorElement * NumberOfMeanLayersPerTrack
def uint(string)
GenericTriggerEventFlag * genTriggerEventFlag_
edm::EDGetTokenT< reco::CandidateView > regionCandidateToken_
MonitorElement * GoodTracksFractionVsBX
edm::InputTag pixelClusterInputTag_
std::string const & label() const
Definition: InputTag.h:36
MonitorElement * NumberOfSeeds_lumiFlag
void beginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &eSetup) override
edm::EventID id() const
Definition: EventBase.h:59
TrackingMonitor(const edm::ParameterSet &)
HLT enums.
MonitorElement * NumberofTracks_Hardvtx
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
T get() const
Definition: EventSetup.h:71
MonitorElement * NumberOfTrackCandidates
bool isUninitialized() const
Definition: EDGetToken.h:70
const_iterator end() const
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
MonitorElement * NumberOfGoodPVtxVsBX
MonitorElement * NumberEventsOfVsLUMI
std::vector< MonitorElement * > SeedsVsClusters
std::vector< std::tuple< edm::EDGetTokenT< MVACollection >, edm::EDGetTokenT< QualityMaskCollection > > > mvaQualityTokens_
MonitorElement * NumberOfTracks_lumiFlag
void setLumi(const edm::Event &, const edm::EventSetup &iSetup)
StringCutObjectSelector< reco::Track, true > numSelection_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
edm::EDGetTokenT< reco::BeamSpot > bsSrcToken_
MonitorElement * NumberOfTracks
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71
static Registry * instance()
Definition: Registry.cc:12
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Track &track)
edm::EDGetTokenT< reco::VertexCollection > pvSrcToken_
Definition: Run.h:45
MonitorElement * NumberEventsOfVsLS
MonitorElement * NumberOfTracksVsLUMI
std::vector< std::string > ClusterLabels
MonitorElement * NumberOfGoodPVtxWO0VsBX
std::string builderName