CMS 3D CMS Logo

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