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  bool isMC = ((iRun.runAuxiliary().run() == 1) && (iRun.runAuxiliary().beginTime().value() == 1));
518 
519  if ((doPlotsVsLUMI_ || doAllPlots) && !isMC) {
520  ibooker.setCurrentFolder(MEFolderName + "/LUMIanalysis");
521  int LUMIBin = conf->getParameter<int>("LUMIBin");
522  float LUMIMin = conf->getParameter<double>("LUMIMin");
523  float LUMIMax = conf->getParameter<double>("LUMIMax");
524 
525  histname = "NumberEventsVsLUMI";
527  NumberEventsOfVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
528  NumberEventsOfVsLUMI->setAxisTitle("Number of events", 2);
529 
530  histname = "NumberOfTracksVsLUMI";
531  NumberOfTracksVsLUMI = ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, TKNoMin, TKNoMax * 3, "");
532  NumberOfTracksVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
533  NumberOfTracksVsLUMI->setAxisTitle("Mean number of vertices", 2);
534 
535  if (doFractionPlot_) {
536  histname = "GoodTracksFractionVsLUMI";
538  GoodTracksFractionVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
539  GoodTracksFractionVsLUMI->setAxisTitle("Mean number of vertices", 2);
540  }
541 
542  histname = "NumberOfRecHitsPerTrackVsLUMI";
545  NumberOfRecHitsPerTrackVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
546  NumberOfRecHitsPerTrackVsLUMI->setAxisTitle("Mean number of vertices", 2);
547 
548  double PVMin = conf->getParameter<double>("PVMin");
549  double PVMax = conf->getParameter<double>("PVMax");
550 
551  histname = "NumberOfGoodPVtxVsLUMI";
553  NumberOfGoodPVtxVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
554  NumberOfGoodPVtxVsLUMI->setAxisTitle("Mean number of vertices", 2);
555 
556  histname = "NumberOfGoodPVtxWO0VsLUMI";
558  ibooker.bookProfile(histname, histname, LUMIBin, LUMIMin, LUMIMax, PVMin, 3. * PVMax, "");
559  NumberOfGoodPVtxWO0VsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
560  NumberOfGoodPVtxWO0VsLUMI->setAxisTitle("Mean number of vertices", 2);
561 
562  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
563  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
564  histname = "NumberOfPixelClustersVsGoodPVtx";
567  NumberOfPixelClustersVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
568  NumberOfPixelClustersVsLUMI->setAxisTitle("Mean number of pixel clusters", 2);
569 
570  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
571  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
572  histname = "NumberOfStripClustersVsLUMI";
575  NumberOfStripClustersVsLUMI->setAxisTitle("online lumi [1e30 Hz cm^{-2}]", 1);
576  NumberOfStripClustersVsLUMI->setAxisTitle("Mean number of strip clusters", 2);
577  }
578 
579  if (doPlotsVsBXlumi_) {
580  ibooker.setCurrentFolder(MEFolderName + "/PUmonitoring");
581  // get binning from the configuration
582  edm::ParameterSet BXlumiParameters = conf->getParameter<edm::ParameterSet>("BXlumiSetup");
583  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
584  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
585  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
586 
587  histname = "NumberOfTracksVsBXlumi_" + CategoryName;
589  ibooker.bookProfile(histname, histname, BXlumiBin, BXlumiMin, BXlumiMax, TKNoMin, 3. * TKNoMax, "");
590  NumberOfTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]", 1);
591  NumberOfTracksVsBXlumi->setAxisTitle("Mean number of Tracks", 2);
592  }
593 
594  if (doLumiAnalysis) {
595  auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
596  theTrackAnalyzer->initHisto(ibooker, iSetup, *conf);
597  } else {
598  theTrackAnalyzer->initHisto(ibooker, iSetup, *conf);
599  }
600 
601  // book the Seed Property histograms
602  // ---------------------------------------------------------------------------------//
603 
604  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
605 
606  doSeedNumberPlot = conf->getParameter<bool>("doSeedNumberHisto");
607  doSeedLumiAnalysis_ = conf->getParameter<bool>("doSeedLumiAnalysis");
608  doSeedVsClusterPlot = conf->getParameter<bool>("doSeedVsClusterHisto");
609 
610  edm::InputTag seedProducer = conf->getParameter<edm::InputTag>("SeedProducer");
611 
613  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
614  histname = "NumberOfSeeds_" + seedProducer.label() + "_" + CategoryName;
615  NumberOfSeeds = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
616  NumberOfSeeds->setAxisTitle("Number of Seeds per Event", 1);
617  NumberOfSeeds->setAxisTitle("Number of Events", 2);
618 
619  if (doSeedLumiAnalysis_) {
620  ibooker.setCurrentFolder(MEFolderName + "/LSanalysis");
621  auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
622  histname = "NumberOfSeeds_lumiFlag_" + seedProducer.label() + "_" + CategoryName;
623  NumberOfSeeds_lumiFlag = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
624  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Seeds per Event", 1);
625  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Events", 2);
626  }
627  }
628 
630  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
631 
632  ClusterLabels = conf->getParameter<std::vector<std::string> >("ClusterLabels");
633 
634  std::vector<double> histoMin, histoMax;
635  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
636 
637  int NClusPxBin = conf->getParameter<int>("NClusPxBin");
638  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
639  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
640 
641  int NClusStrBin = conf->getParameter<int>("NClusStrBin");
642  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
643  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
644 
645  setMaxMinBin(
646  histoMin, histoMax, histoBin, NClusStrMin, NClusStrMax, NClusStrBin, NClusPxMin, NClusPxMax, NClusPxBin);
647 
648  for (uint i = 0; i < ClusterLabels.size(); i++) {
649  histname = "SeedsVsClusters_" + seedProducer.label() + "_Vs_" + ClusterLabels[i] + "_" + CategoryName;
650  SeedsVsClusters.push_back(dynamic_cast<MonitorElement*>(ibooker.book2D(
651  histname, histname, histoBin[i], histoMin[i], histoMax[i], TKNoSeedBin, TKNoSeedMin, TKNoSeedMax)));
652  SeedsVsClusters[i]->setAxisTitle("Number of Clusters", 1);
653  SeedsVsClusters[i]->setAxisTitle("Number of Seeds", 2);
654  SeedsVsClusters[i]->getTH2F()->SetCanExtend(TH1::kAllAxes);
655  }
656  }
657 
658  if (doRegionPlots) {
659  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
660 
661  int regionBin = conf->getParameter<int>("RegionSizeBin");
662  double regionMin = conf->getParameter<double>("RegionSizeMin");
663  double regionMax = conf->getParameter<double>("RegionSizeMax");
664 
665  histname = "TrackingRegionsNumberOf_" + seedProducer.label() + "_" + CategoryName;
666  NumberOfTrackingRegions = ibooker.book1D(histname, histname, regionBin, regionMin, regionMax);
667  NumberOfTrackingRegions->setAxisTitle("Number of TrackingRegions per Event", 1);
668  NumberOfTrackingRegions->setAxisTitle("Number of Events", 2);
669  }
670 
671  if (doTkCandPlots) {
672  ibooker.setCurrentFolder(MEFolderName + "/TrackBuilding");
673 
674  edm::InputTag tcProducer = conf->getParameter<edm::InputTag>("TCProducer");
675 
676  histname = "NumberOfTrackCandidates_" + tcProducer.label() + "_" + CategoryName;
677  NumberOfTrackCandidates = ibooker.book1D(histname, histname, TCNoBin, TCNoMin, TCNoMax);
678  NumberOfTrackCandidates->setAxisTitle("Number of Track Candidates per Event", 1);
679  NumberOfTrackCandidates->setAxisTitle("Number of Event", 2);
680 
681  histname = "FractionOfCandOverSeeds_" + tcProducer.label() + "_" + CategoryName;
682  FractionCandidatesOverSeeds = ibooker.book1D(histname, histname, 101, 0., 1.01);
683  FractionCandidatesOverSeeds->setAxisTitle("Number of Track Candidates / Number of Seeds per Event", 1);
684  FractionCandidatesOverSeeds->setAxisTitle("Number of Event", 2);
685  }
686 
687  theTrackBuildingAnalyzer->initHisto(ibooker, *conf);
688 
690  ClusterLabels = conf->getParameter<std::vector<std::string> >("ClusterLabels");
691 
692  std::vector<double> histoMin, histoMax;
693  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
694 
695  int NClusStrBin = conf->getParameter<int>("NClusStrBin");
696  double NClusStrMin = conf->getParameter<double>("NClusStrMin");
697  double NClusStrMax = conf->getParameter<double>("NClusStrMax");
698 
699  int NClusPxBin = conf->getParameter<int>("NClusPxBin");
700  double NClusPxMin = conf->getParameter<double>("NClusPxMin");
701  double NClusPxMax = conf->getParameter<double>("NClusPxMax");
702 
703  edm::ParameterSet ParametersNTrk2D = conf->getParameter<edm::ParameterSet>("NTrk2D");
704  int NTrk2DBin = ParametersNTrk2D.getParameter<int>("NTrk2DBin");
705  double NTrk2DMin = ParametersNTrk2D.getParameter<double>("NTrk2DMin");
706  double NTrk2DMax = ParametersNTrk2D.getParameter<double>("NTrk2DMax");
707 
708  setMaxMinBin(
709  histoMin, histoMax, histoBin, NClusStrMin, NClusStrMax, NClusStrBin, NClusPxMin, NClusPxMax, NClusPxBin);
710 
711  ibooker.setCurrentFolder(MEFolderName + "/HitProperties");
712 
713  for (uint i = 0; i < ClusterLabels.size(); i++) {
714  ibooker.setCurrentFolder(MEFolderName + "/HitProperties");
715  histname = "TracksVs" + ClusterLabels[i] + "Cluster_" + CategoryName;
716  NumberOfTrkVsClusters.push_back(dynamic_cast<MonitorElement*>(
717  ibooker.book2D(histname, histname, histoBin[i], histoMin[i], histoMax[i], NTrk2DBin, NTrk2DMin, NTrk2DMax)));
718  std::string title = "Number of " + ClusterLabels[i] + " Clusters";
719  if (ClusterLabels[i] == "Tot")
720  title = "# of Clusters in (Pixel+Strip) Detectors";
721  NumberOfTrkVsClusters[i]->setAxisTitle(title, 1);
722  NumberOfTrkVsClusters[i]->setAxisTitle("Number of Tracks", 2);
723  NumberOfTrkVsClusters[i]->getTH1()->SetCanExtend(TH1::kXaxis);
724  }
725  }
726 
727  // Initialize the GenericTriggerEventFlag
728  if (genTriggerEventFlag_->on())
729  genTriggerEventFlag_->initRun(iRun, iSetup);
730 }
731 
732 /*
733 // -- BeginRun
734 //---------------------------------------------------------------------------------//
735 void TrackingMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
736 {
737 
738 }
739 */
740 
741 // -- Analyse
742 // ---------------------------------------------------------------------------------//
744  // Filter out events if Trigger Filtering is requested
746  return;
747  auto const* conf = edm::pset::Registry::instance()->getMapped(confID_);
748  MEFolderName = conf->getParameter<std::string>("FolderName");
749  std::string Folder = MEFolderName.substr(0, 2);
750  float lumi = -1.;
751  if (forceSCAL_) {
753  if (lumiScalers.isValid() && !lumiScalers->empty()) {
754  LumiScalersCollection::const_iterator scalit = lumiScalers->begin();
755  lumi = scalit->instantLumi();
756  }
757  } else {
759  if (metaData.isValid())
760  lumi = metaData->instLumi();
761  }
762 
763  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData())
765 
766  // Analyse the tracks
767  // if the collection is empty, do not fill anything
768  // ---------------------------------------------------------------------------------//
769 
770  size_t bx = iEvent.bunchCrossing();
771  if (doPlotsVsBX_ || doAllPlots)
773 
774  // get the track collection
775  edm::Handle<edm::View<reco::Track> > trackHandle = iEvent.getHandle(trackToken_);
776 
777  int numberOfTracks_den = 0;
778  edm::Handle<edm::View<reco::Track> > allTrackHandle = iEvent.getHandle(allTrackToken_);
779  if (allTrackHandle.isValid()) {
780  for (edm::View<reco::Track>::const_iterator track = allTrackHandle->begin(); track != allTrackHandle->end();
781  ++track) {
782  if (denSelection_(*track))
783  numberOfTracks_den++;
784  }
785  }
786 
788  reco::Vertex const* pv0 = nullptr;
789  if (pvHandle.isValid()) {
790  pv0 = &pvHandle->front();
791  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
792  if (pv0->isFake() ||
793  pv0->tracksSize() == 0
794  // definition of goodOfflinePrimaryVertex
795  || pv0->ndof() < pvNDOF_ || pv0->z() > 24.)
796  pv0 = nullptr;
797  }
798 
799  if (trackHandle.isValid()) {
800  int numberOfTracks = trackHandle->size();
801  int numberOfTracks_num = 0;
802  int numberOfTracks_pv0 = 0;
803 
804  const edm::View<reco::Track>& trackCollection = *trackHandle;
805  // calculate the mean # rechits and layers
806  int totalRecHits = 0, totalLayers = 0;
807 
810  theTrackAnalyzer->setLumi(iEvent, iSetup);
812  ++track) {
813  if (doPlotsVsBX_ || doAllPlots)
814  NumberOfRecHitsPerTrackVsBX->Fill(bx, track->numberOfValidHits());
815  if (numSelection_(*track)) {
816  numberOfTracks_num++;
817  if (pv0 && std::abs(track->dz(pv0->position())) < 0.15)
818  ++numberOfTracks_pv0;
819  }
820 
822  NumberOfRecHitsPerTrackVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),
823  track->numberOfValidHits());
824 
825  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData())
826  NumberOfRecHitsPerTrackVsLUMI->Fill(lumi, track->numberOfValidHits());
827 
828  totalRecHits += track->numberOfValidHits();
829  totalLayers += track->hitPattern().trackerLayersWithMeasurement();
830 
831  // do analysis per track
832  theTrackAnalyzer->analyze(iEvent, iSetup, *track);
833  }
834 
835  double frac = -1.;
836  // if (numberOfAllTracks > 0) frac = static_cast<double>(numberOfTracks)/static_cast<double>(numberOfAllTracks);
837  if (numberOfTracks_den > 0)
838  frac = static_cast<double>(numberOfTracks_num) / static_cast<double>(numberOfTracks_den);
839 
841  NumberOfTracks->Fill(double(numberOfTracks));
842 
843  if (Folder == "Tr") {
844  NumberofTracks_Hardvtx->Fill(double(numberOfTracks_pv0));
845  NumberOfTracks_PUvtx->Fill(double(numberOfTracks - numberOfTracks_pv0));
846  NumberofTracks_Hardvtx_PUvtx->Fill(0.5, double(numberOfTracks_pv0));
847  NumberofTracks_Hardvtx_PUvtx->Fill(1.5, double(numberOfTracks - numberOfTracks_pv0));
848  }
849 
850  if (doPlotsVsBX_ || doAllPlots)
851  NumberOfTracksVsBX->Fill(bx, numberOfTracks);
852  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData())
853  NumberOfTracksVsLUMI->Fill(lumi, numberOfTracks);
854  if (doFractionPlot_) {
856 
857  if (doFractionPlot_) {
858  if (doPlotsVsBX_ || doAllPlots)
860  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData())
862  }
863  }
864  if (numberOfTracks > 0) {
865  double meanRecHits = static_cast<double>(totalRecHits) / static_cast<double>(numberOfTracks);
866  double meanLayers = static_cast<double>(totalLayers) / static_cast<double>(numberOfTracks);
867  NumberOfMeanRecHitsPerTrack->Fill(meanRecHits);
868  NumberOfMeanLayersPerTrack->Fill(meanLayers);
869  }
870  }
871 
872  if (doProfilesVsLS_ || doAllPlots) {
873  float nLS = static_cast<double>(iEvent.id().luminosityBlock());
874  NumberEventsOfVsLS->Fill(nLS);
875  NumberOfTracksVsLS->Fill(nLS, numberOfTracks);
876  if (doFractionPlot_)
878  }
879 
880  if (doLumiAnalysis) {
881  NumberOfTracks_lumiFlag->Fill(numberOfTracks);
882  }
883 
884  // Analyse the Track Building variables
885  // if the collection is empty, do not fill anything
886  // ---------------------------------------------------------------------------------//
887 
888  // fill the TrackCandidate info
889  if (doTkCandPlots) {
890  // magnetic field
891  MagneticField const& theMF = iSetup.getData(magneticFieldToken_);
892 
893  // get the candidate collection
895  const TrackCandidateCollection& theTCCollection = *theTCHandle;
896 
897  if (theTCHandle.isValid()) {
898  // get the beam spot
899  edm::Handle<reco::BeamSpot> recoBeamSpotHandle = iEvent.getHandle(bsSrcToken_);
900  const reco::BeamSpot& bs = *recoBeamSpotHandle;
901 
902  NumberOfTrackCandidates->Fill(theTCCollection.size());
903 
904  // get the seed collection
905  edm::Handle<edm::View<TrajectorySeed> > seedHandle = iEvent.getHandle(seedToken_);
906  const edm::View<TrajectorySeed>& seedCollection = *seedHandle;
907  if (seedHandle.isValid() && !seedCollection.empty())
908  FractionCandidatesOverSeeds->Fill(double(theTCCollection.size()) / double(seedCollection.size()));
909 
911  for (TrackCandidateCollection::const_iterator cand = theTCCollection.begin(); cand != theTCCollection.end();
912  ++cand) {
913  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *cand, bs, theMF, theTTRHBuilder);
914  }
915  } else {
916  edm::LogWarning("TrackingMonitor") << "No Track Candidates in the event. Not filling associated histograms";
917  }
918 
919  if (doMVAPlots) {
920  // Get MVA and quality mask collections
921  std::vector<const MVACollection*> mvaCollections;
922  std::vector<const QualityMaskCollection*> qualityMaskCollections;
923 
925 
928  for (const auto& tokenTpl : mvaQualityTokens_) {
929  hmva = iEvent.getHandle(std::get<0>(tokenTpl));
930  hqual = iEvent.getHandle(std::get<1>(tokenTpl));
931  mvaCollections.push_back(hmva.product());
932  qualityMaskCollections.push_back(hqual.product());
933  }
934  theTrackBuildingAnalyzer->analyze(*htracks, mvaCollections, qualityMaskCollections);
935  }
936  }
937 
938  //plots for trajectory seeds
939 
941  // get the seed collection
942  edm::Handle<edm::View<TrajectorySeed> > seedHandle = iEvent.getHandle(seedToken_);
943 
944  // fill the seed info
945  if (seedHandle.isValid()) {
946  const auto& seedCollection = *seedHandle;
947 
952  }
953 
955  std::vector<int> NClus;
956  setNclus(iEvent, NClus);
957  for (uint i = 0; i < ClusterLabels.size(); i++) {
958  SeedsVsClusters[i]->Fill(NClus[i], seedCollection.size());
959  }
960  }
961 
964  const auto& seedStopInfo = *stopHandle;
965 
966  if (seedStopInfo.size() == seedCollection.size()) {
967  //here duplication of mag field and be informations is needed to allow seed and track cand histos to be independent
968  // magnetic field
969  MagneticField const& theMF = iSetup.getData(magneticFieldToken_);
970 
971  // get the beam spot
972  edm::Handle<reco::BeamSpot> recoBeamSpotHandle = iEvent.getHandle(bsSrcToken_);
973  const reco::BeamSpot& bs = *recoBeamSpotHandle;
974 
976  for (size_t i = 0; i < seedCollection.size(); ++i) {
978  iEvent, iSetup, seedCollection[i], seedStopInfo[i], bs, theMF, theTTRHBuilder);
979  }
980  } else {
981  edm::LogWarning("TrackingMonitor")
982  << "Seed collection size (" << seedCollection.size()
983  << ") differs from seed stop info collection size (" << seedStopInfo.size()
984  << "). This is a sign of inconsistency in the configuration. Not filling associated histograms.";
985  }
986  }
987 
988  } else {
989  edm::LogWarning("TrackingMonitor") << "No Trajectory seeds in the event. Not filling associated histograms";
990  }
991  }
992 
993  // plots for tracking regions
994  if (doRegionPlots) {
995  if (!regionToken_.isUninitialized()) {
997  const auto& regions = *hregions;
999 
1001  } else if (!regionLayerSetsToken_.isUninitialized()) {
1003  const auto& regions = *hregions;
1004  NumberOfTrackingRegions->Fill(regions.regionsSize());
1005 
1007  }
1008 
1009  if (doRegionCandidatePlots) {
1011  theTrackBuildingAnalyzer->analyze(*hcandidates);
1012  }
1013  }
1014 
1015  if (doTrackerSpecific_ || doAllPlots) {
1016  std::vector<int> NClus;
1017  setNclus(iEvent, NClus);
1018  for (uint i = 0; i < ClusterLabels.size(); i++) {
1019  NumberOfTrkVsClusters[i]->Fill(NClus[i], numberOfTracks);
1020  }
1021  }
1022 
1023  if (doPUmonitoring_) {
1024  // do vertex monitoring
1025  for (size_t i = 0; i < theVertexMonitor.size(); i++)
1026  theVertexMonitor[i]->analyze(iEvent, iSetup);
1027  }
1028  if (doPlotsVsGoodPVtx_) {
1029  size_t totalNumGoodPV = 0;
1030  if (pvHandle.isValid()) {
1031  for (reco::VertexCollection::const_iterator pv = pvHandle->begin(); pv != pvHandle->end(); ++pv) {
1032  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
1033  if (pv->isFake() || pv->tracksSize() == 0)
1034  continue;
1035 
1036  // definition of goodOfflinePrimaryVertex
1037  if (pv->ndof() < pvNDOF_ || pv->z() > 24.)
1038  continue;
1039  totalNumGoodPV++;
1040  }
1041 
1042  NumberEventsOfVsGoodPVtx->Fill(float(totalNumGoodPV));
1043  NumberOfTracksVsGoodPVtx->Fill(float(totalNumGoodPV), numberOfTracks);
1044  if (totalNumGoodPV > 1)
1045  NumberOfTracksVsPUPVtx->Fill(totalNumGoodPV - 1,
1046  double(numberOfTracks - numberOfTracks_pv0) / double(totalNumGoodPV - 1));
1047  NumberOfPVtxVsGoodPVtx->Fill(float(totalNumGoodPV), pvHandle->size());
1048 
1050  ++track) {
1051  NumberOfRecHitsPerTrackVsGoodPVtx->Fill(float(totalNumGoodPV), track->numberOfValidHits());
1052  }
1053 
1054  if (doProfilesVsLS_ || doAllPlots)
1055  NumberOfGoodPVtxVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()), totalNumGoodPV);
1056  if (doPlotsVsBX_ || doAllPlots)
1057  NumberOfGoodPVtxVsBX->Fill(bx, float(totalNumGoodPV));
1058 
1059  if (doFractionPlot_)
1060  GoodTracksFractionVsGoodPVtx->Fill(float(totalNumGoodPV), frac);
1061 
1062  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData())
1063  NumberOfGoodPVtxVsLUMI->Fill(lumi, float(totalNumGoodPV));
1064  }
1065 
1066  std::vector<int> NClus;
1067  setNclus(iEvent, NClus);
1068  std::ostringstream ss;
1069  ss << "VI stat " << totalNumGoodPV << ' ' << numberOfTracks;
1070  for (uint i = 0; i < ClusterLabels.size(); i++) {
1071  ss << ' ' << NClus[i];
1072  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData()) {
1073  if (ClusterLabels[i] == "Pix")
1075  if (ClusterLabels[i] == "Strip")
1077  }
1078  if (ClusterLabels[i] == "Pix")
1079  NumberOfPixelClustersVsGoodPVtx->Fill(float(totalNumGoodPV), NClus[i]);
1080  if (ClusterLabels[i] == "Strip")
1081  NumberOfStripClustersVsGoodPVtx->Fill(float(totalNumGoodPV), NClus[i]);
1082  }
1083  COUT(MEFolderName) << ss.str() << std::endl;
1084  if (doPlotsVsBXlumi_) {
1085  double bxlumi = theLumiDetails_->getValue(iEvent);
1086  NumberOfTracksVsBXlumi->Fill(bxlumi, numberOfTracks);
1087  }
1088 
1089  if (doProfilesVsLS_ || doAllPlots)
1090  if (totalNumGoodPV != 0)
1091  NumberOfGoodPVtxWO0VsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()), float(totalNumGoodPV));
1092  if (doPlotsVsBX_ || doAllPlots)
1093  if (totalNumGoodPV != 0)
1094  NumberOfGoodPVtxWO0VsBX->Fill(bx, float(totalNumGoodPV));
1095  if ((doPlotsVsLUMI_ || doAllPlots) && iEvent.isRealData())
1096  if (totalNumGoodPV != 0)
1097  NumberOfGoodPVtxWO0VsLUMI->Fill(lumi, float(totalNumGoodPV));
1098 
1099  } // PU monitoring
1100 
1101  } // trackHandle is valid
1102 }
1103 
1104 void TrackingMonitor::setMaxMinBin(std::vector<double>& arrayMin,
1105  std::vector<double>& arrayMax,
1106  std::vector<int>& arrayBin,
1107  double smin,
1108  double smax,
1109  int sbin,
1110  double pmin,
1111  double pmax,
1112  int pbin) {
1113  arrayMin.resize(ClusterLabels.size());
1114  arrayMax.resize(ClusterLabels.size());
1115  arrayBin.resize(ClusterLabels.size());
1116 
1117  for (uint i = 0; i < ClusterLabels.size(); ++i) {
1118  if (ClusterLabels[i] == "Pix") {
1119  arrayMin[i] = pmin;
1120  arrayMax[i] = pmax;
1121  arrayBin[i] = pbin;
1122  } else if (ClusterLabels[i] == "Strip") {
1123  arrayMin[i] = smin;
1124  arrayMax[i] = smax;
1125  arrayBin[i] = sbin;
1126  } else if (ClusterLabels[i] == "Tot") {
1127  arrayMin[i] = smin;
1128  arrayMax[i] = smax + pmax;
1129  arrayBin[i] = sbin;
1130  } else {
1131  edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i]
1132  << " not defined, using strip parameters ";
1133  arrayMin[i] = smin;
1134  arrayMax[i] = smax;
1135  arrayBin[i] = sbin;
1136  }
1137  }
1138 }
1139 
1140 void TrackingMonitor::setNclus(const edm::Event& iEvent, std::vector<int>& arrayNclus) {
1141  int ncluster_pix = -1;
1142  int ncluster_strip = -1;
1143 
1146 
1147  if (strip_clusters.isValid() && pixel_clusters.isValid()) {
1148  ncluster_pix = (*pixel_clusters).dataSize();
1149  ncluster_strip = (*strip_clusters).dataSize();
1150  }
1151 
1152  arrayNclus.resize(ClusterLabels.size());
1153  for (uint i = 0; i < ClusterLabels.size(); ++i) {
1154  if (ClusterLabels[i] == "Pix")
1155  arrayNclus[i] = ncluster_pix;
1156  else if (ClusterLabels[i] == "Strip")
1157  arrayNclus[i] = ncluster_strip;
1158  else if (ClusterLabels[i] == "Tot")
1159  arrayNclus[i] = ncluster_pix + ncluster_strip;
1160  else {
1161  edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i]
1162  << " not defined using stri parametrs ";
1163  arrayNclus[i] = ncluster_strip;
1164  }
1165  }
1166 }
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:307
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_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
MonitorElement * NumberOfRecHitsPerTrackVsBX
MonitorElement * NumberOfRecHitsPerTrackVsLUMI
double z() const
z coordinate
Definition: Vertex.h:134
bool isFake() const
Definition: Vertex.h:77
virtual void setNclus(const edm::Event &, std::vector< int > &)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
~TrackingMonitor() override
MonitorElement * NumberEventsOfVsGoodPVtx
GetLumi * theLumiDetails_
const Point & position() const
position
Definition: Vertex.h:128
RunAuxiliary const & runAuxiliary() const final
Definition: Run.cc:24
std::vector< TrackCandidate > TrackCandidateCollection
T const * product() const
Definition: Handle.h:70
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
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:124
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
RunNumber_t run() const
Definition: RunAuxiliary.h:30
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Track &track)
size_t tracksSize() const
number of tracks
Definition: Vertex.h:113
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * NumberOfTracksVsPUPVtx
edm::EDGetTokenT< LumiScalersCollection > lumiscalersToken_
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)
trackCollection
Definition: JetHT_cfg.py:51
MonitorElement * NumberOfPixelClustersVsGoodPVtx
MonitorElement * NumberOfRecHitsPerTrackVsLS
Timestamp const & beginTime() const
Definition: RunAuxiliary.h:28
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_
TimeValue_t value() const
Definition: Timestamp.h:38
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_
dictionary isMC
Definition: DiMuonV_cfg.py:35
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:88
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)