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