CMS 3D CMS Logo

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