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