CMS 3D CMS Logo

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