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