CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  : dqmStore_( edm::Service<DQMStore>().operator->() )
42  , conf_ ( iConfig )
43  , theTrackBuildingAnalyzer( new TrackBuildingAnalyzer(conf_) )
44  , NumberOfTracks(NULL)
45  , NumberOfMeanRecHitsPerTrack(NULL)
46  , NumberOfMeanLayersPerTrack(NULL)
47  // , NumberOfGoodTracks(NULL)
48  , FractionOfGoodTracks(NULL)
49  , NumberOfSeeds(NULL)
50  , NumberOfSeeds_lumiFlag(NULL)
51  , NumberOfTrackCandidates(NULL)
52  // , NumberOfGoodTrkVsClus(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  , NumberOfTracksVsGoodPVtx(NULL)
60  , NumberOfTracksVsBXlumi(NULL)
61 
62  , NumberOfTracks_lumiFlag(NULL)
63  // , NumberOfGoodTracks_lumiFlag(NULL)
64 
65  , builderName ( conf_.getParameter<std::string>("TTRHBuilder"))
66  , doTrackerSpecific_ ( conf_.getParameter<bool>("doTrackerSpecific") )
67  , doLumiAnalysis ( conf_.getParameter<bool>("doLumiAnalysis"))
68  , doProfilesVsLS_ ( conf_.getParameter<bool>("doProfilesVsLS"))
69  , doAllPlots ( conf_.getParameter<bool>("doAllPlots"))
70  , doGeneralPropertiesPlots_( conf_.getParameter<bool>("doGeneralPropertiesPlots"))
71  , doHitPropertiesPlots_ ( conf_.getParameter<bool>("doHitPropertiesPlots"))
72  , doPUmonitoring_ ( conf_.getParameter<bool>("doPUmonitoring") )
73  , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig,consumesCollector()))
74  , numSelection_ (conf_.getParameter<std::string>("numCut"))
75  , denSelection_ (conf_.getParameter<std::string>("denCut"))
76 {
77 
80 
81  // input tags for collections from the configuration
82  bsSrc_ = conf_.getParameter<edm::InputTag>("beamSpot");
83  pvSrc_ = conf_.getParameter<edm::InputTag>("primaryVertex");
84  bsSrcToken_ = consumes<reco::BeamSpot>(bsSrc_);
85  pvSrcToken_ = mayConsume<reco::VertexCollection>(pvSrc_);
86 
87  edm::InputTag alltrackProducer = conf_.getParameter<edm::InputTag>("allTrackProducer");
88  edm::InputTag trackProducer = conf_.getParameter<edm::InputTag>("TrackProducer");
89  edm::InputTag tcProducer = conf_.getParameter<edm::InputTag>("TCProducer");
90  edm::InputTag seedProducer = conf_.getParameter<edm::InputTag>("SeedProducer");
91  allTrackToken_ = consumes<reco::TrackCollection>(alltrackProducer);
92  trackToken_ = consumes<reco::TrackCollection>(trackProducer);
93  trackCandidateToken_ = consumes<TrackCandidateCollection>(tcProducer);
94  seedToken_ = consumes<edm::View<TrajectorySeed> >(seedProducer);
95 
98  stripClustersToken_ = mayConsume<edmNew::DetSetVector<SiStripCluster> > (stripClusterInputTag_);
99  pixelClustersToken_ = mayConsume<edmNew::DetSetVector<SiPixelCluster> > (pixelClusterInputTag_);
100 
101  doFractionPlot_ = true;
102  if (alltrackProducer.label()==trackProducer.label()) doFractionPlot_ = false;
103 
104  Quality_ = conf_.getParameter<std::string>("Quality");
105  AlgoName_ = conf_.getParameter<std::string>("AlgoName");
106 
107 
108  if ( doPUmonitoring_ ) {
109 
110  // get flag from the configuration
111  doPlotsVsBXlumi_ = conf_.getParameter<bool>("doPlotsVsBXlumi");
112  doPlotsVsGoodPVtx_ = conf_.getParameter<bool>("doPlotsVsGoodPVtx");
113 
114  if ( doPlotsVsBXlumi_ )
115  theLumiDetails_ = new GetLumi( iConfig.getParameter<edm::ParameterSet>("BXlumiSetup"), c );
116 
117  std::vector<edm::InputTag> primaryVertexInputTags = conf_.getParameter<std::vector<edm::InputTag> >("primaryVertexInputTags");
118  std::vector<edm::InputTag> selPrimaryVertexInputTags = conf_.getParameter<std::vector<edm::InputTag> >("selPrimaryVertexInputTags");
119  std::vector<std::string> pvLabels = conf_.getParameter<std::vector<std::string> > ("pvLabels");
120 
121  if (primaryVertexInputTags.size()==pvLabels.size() and primaryVertexInputTags.size()==selPrimaryVertexInputTags.size()) {
122  // for (auto const& tag : primaryVertexInputTags) {
123  for (size_t i=0; i<primaryVertexInputTags.size(); i++) {
124  edm::InputTag iPVinputTag = primaryVertexInputTags[i];
125  edm::InputTag iSelPVinputTag = selPrimaryVertexInputTags[i];
126  std::string iPVlabel = pvLabels[i];
127 
128  theVertexMonitor.push_back(new VertexMonitor(conf_,iPVinputTag,iSelPVinputTag,iPVlabel,c) );
129  }
130  }
131  }
132 
133 }
134 
135 
137 {
140  if ( doPUmonitoring_ )
141  for (size_t i=0; i<theVertexMonitor.size(); i++)
142  if (theVertexMonitor[i]) delete theVertexMonitor[i];
144 }
145 
146 
148 {
149 
150 
151 }
152 
154  edm::Run const & iRun,
155  edm::EventSetup const & iSetup)
156 {
157  // parameters from the configuration
159  std::string AlgoName = conf_.getParameter<std::string>("AlgoName");
160  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
161 
162  // test for the Quality veriable validity
163  if( Quality_ != "") {
164  if( Quality_ != "highPurity" && Quality_ != "tight" && Quality_ != "loose") {
165  edm::LogWarning("TrackingMonitor") << "Qualty Name is invalid, using no quality criterea by default";
166  Quality_ = "";
167  }
168  }
169 
170  // use the AlgoName and Quality Name
171  std::string CategoryName = Quality_ != "" ? AlgoName_ + "_" + Quality_ : AlgoName_;
172 
173  // get binning from the configuration
174  int TKNoBin = conf_.getParameter<int>( "TkSizeBin");
175  double TKNoMin = conf_.getParameter<double>("TkSizeMin");
176  double TKNoMax = conf_.getParameter<double>("TkSizeMax");
177 
178  int TCNoBin = conf_.getParameter<int>( "TCSizeBin");
179  double TCNoMin = conf_.getParameter<double>("TCSizeMin");
180  double TCNoMax = conf_.getParameter<double>("TCSizeMax");
181 
182  int TKNoSeedBin = conf_.getParameter<int>( "TkSeedSizeBin");
183  double TKNoSeedMin = conf_.getParameter<double>("TkSeedSizeMin");
184  double TKNoSeedMax = conf_.getParameter<double>("TkSeedSizeMax");
185 
186  int MeanHitBin = conf_.getParameter<int>( "MeanHitBin");
187  double MeanHitMin = conf_.getParameter<double>("MeanHitMin");
188  double MeanHitMax = conf_.getParameter<double>("MeanHitMax");
189 
190  int MeanLayBin = conf_.getParameter<int>( "MeanLayBin");
191  double MeanLayMin = conf_.getParameter<double>("MeanLayMin");
192  double MeanLayMax = conf_.getParameter<double>("MeanLayMax");
193 
194  int LSBin = conf_.getParameter<int>( "LSBin");
195  int LSMin = conf_.getParameter<double>("LSMin");
196  int LSMax = conf_.getParameter<double>("LSMax");
197 
198  std::string StateName = conf_.getParameter<std::string>("MeasurementState");
199  if (
200  StateName != "OuterSurface" &&
201  StateName != "InnerSurface" &&
202  StateName != "ImpactPoint" &&
203  StateName != "default" &&
204  StateName != "All"
205  ) {
206  // print warning
207  edm::LogWarning("TrackingMonitor") << "State Name is invalid, using 'ImpactPoint' by default";
208  }
209 
210  ibooker.setCurrentFolder(MEFolderName);
211 
212  // book the General Property histograms
213  // ---------------------------------------------------------------------------------//
214 
216 
217  ibooker.setCurrentFolder(MEFolderName+"/GeneralProperties");
218 
219  histname = "NumberOfTracks_" + CategoryName;
220  // MODIFY by Mia in order to cope w/ high multiplicity
221  NumberOfTracks = ibooker.book1D(histname, histname, 3*TKNoBin, TKNoMin, (TKNoMax+0.5)*3.-0.5);
222  NumberOfTracks->setAxisTitle("Number of Tracks per Event", 1);
223  NumberOfTracks->setAxisTitle("Number of Events", 2);
224 
225  histname = "NumberOfMeanRecHitsPerTrack_" + CategoryName;
226  NumberOfMeanRecHitsPerTrack = ibooker.book1D(histname, histname, MeanHitBin, MeanHitMin, MeanHitMax);
227  NumberOfMeanRecHitsPerTrack->setAxisTitle("Mean number of valid RecHits per Track", 1);
229 
230  histname = "NumberOfMeanLayersPerTrack_" + CategoryName;
231  NumberOfMeanLayersPerTrack = ibooker.book1D(histname, histname, MeanLayBin, MeanLayMin, MeanLayMax);
232  NumberOfMeanLayersPerTrack->setAxisTitle("Mean number of Layers per Track", 1);
234 
235  if (doFractionPlot_) {
236  histname = "FractionOfGoodTracks_" + CategoryName;
237  FractionOfGoodTracks = ibooker.book1D(histname, histname, 101, -0.005, 1.005);
238  FractionOfGoodTracks->setAxisTitle("Fraction of Tracks (w.r.t. generalTracks)", 1);
239  FractionOfGoodTracks->setAxisTitle("Entries", 2);
240  }
241  }
242 
243  if ( doLumiAnalysis ) {
244  // add by Mia in order to deal with LS transitions
245  ibooker.setCurrentFolder(MEFolderName+"/LSanalysis");
246 
247  histname = "NumberOfTracks_lumiFlag_" + CategoryName;
248  NumberOfTracks_lumiFlag = ibooker.book1D(histname, histname, 3*TKNoBin, TKNoMin, (TKNoMax+0.5)*3.-0.5);
249  NumberOfTracks_lumiFlag->setAxisTitle("Number of Tracks per Event", 1);
250  NumberOfTracks_lumiFlag->setAxisTitle("Number of Events", 2);
251 
252  }
253 
254  // book profile plots vs LS :
255  //---------------------------
256 
257 
258  if ( doProfilesVsLS_ || doAllPlots) {
259 
260  ibooker.setCurrentFolder(MEFolderName+"/GeneralProperties");
261 
262  histname = "NumberOfTracksVsLS_"+ CategoryName;
263  NumberOfTracksVsLS = ibooker.bookProfile(histname,histname, LSBin,LSMin,LSMax, TKNoMin, (TKNoMax+0.5)*3.-0.5,"");
264  NumberOfTracksVsLS->getTH1()->SetBit(TH1::kCanRebin);
265  NumberOfTracksVsLS->setAxisTitle("#Lumi section",1);
266  NumberOfTracksVsLS->setAxisTitle("Number of Tracks",2);
267 
268  histname = "NumberOfRecHitsPerTrackVsLS_" + CategoryName;
269  NumberOfRecHitsPerTrackVsLS = ibooker.bookProfile(histname,histname, LSBin,LSMin,LSMax,0.,40.,"");
270  NumberOfRecHitsPerTrackVsLS->getTH1()->SetBit(TH1::kCanRebin);
271  NumberOfRecHitsPerTrackVsLS->setAxisTitle("#Lumi section",1);
272  NumberOfRecHitsPerTrackVsLS->setAxisTitle("Mean number of RecHits per track",2);
273 
274  if (doFractionPlot_) {
275  histname = "GoodTracksFractionVsLS_"+ CategoryName;
276  GoodTracksFractionVsLS = ibooker.bookProfile(histname,histname, LSBin,LSMin,LSMax,0,1.1,"");
277  GoodTracksFractionVsLS->getTH1()->SetBit(TH1::kCanRebin);
278  GoodTracksFractionVsLS->setAxisTitle("#Lumi section",1);
279  GoodTracksFractionVsLS->setAxisTitle("Fraction of Good Tracks",2);
280  }
281  }
282 
283  // book PU monitoring plots :
284  //---------------------------
285 
286  if ( doPUmonitoring_ ) {
287 
288  for (size_t i=0; i<theVertexMonitor.size(); i++)
289  theVertexMonitor[i]->initHisto(ibooker);
290 
291  ibooker.setCurrentFolder(MEFolderName+"/PUmonitoring");
292 
293  if ( doPlotsVsGoodPVtx_ ) {
294  // get binning from the configuration
295  int GoodPVtxBin = conf_.getParameter<int>("GoodPVtxBin");
296  double GoodPVtxMin = conf_.getParameter<double>("GoodPVtxMin");
297  double GoodPVtxMax = conf_.getParameter<double>("GoodPVtxMax");
298 
299  histname = "NumberOfTracksVsGoodPVtx";
300  NumberOfTracksVsGoodPVtx = ibooker.bookProfile(histname,histname,GoodPVtxBin,GoodPVtxMin,GoodPVtxMax,TKNoMin, (TKNoMax+0.5)*3.-0.5,"");
301  NumberOfTracksVsGoodPVtx->getTH1()->SetBit(TH1::kCanRebin);
302  NumberOfTracksVsGoodPVtx->setAxisTitle("Number of PV",1);
303  NumberOfTracksVsGoodPVtx->setAxisTitle("Mean number of Tracks per Event",2);
304 
305  }
306 
307  if ( doPlotsVsBXlumi_ ) {
308  // get binning from the configuration
309  edm::ParameterSet BXlumiParameters = conf_.getParameter<edm::ParameterSet>("BXlumiSetup");
310  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
311  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
312  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
313 
314  histname = "NumberOfTracksVsBXlumi_"+ CategoryName;
315  NumberOfTracksVsBXlumi = ibooker.bookProfile(histname,histname, BXlumiBin,BXlumiMin,BXlumiMax, TKNoMin, TKNoMax,"");
316  NumberOfTracksVsBXlumi->getTH1()->SetBit(TH1::kCanRebin);
317  NumberOfTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]",1);
318  NumberOfTracksVsBXlumi->setAxisTitle("Mean number of Tracks",2);
319 
320  }
321  }
322 
323  theTrackAnalyzer->initHisto(ibooker);
324 
325  // book the Seed Property histograms
326  // ---------------------------------------------------------------------------------//
327 
328  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
329 
330  doAllSeedPlots = conf_.getParameter<bool>("doSeedParameterHistos");
331  doSeedNumberPlot = conf_.getParameter<bool>("doSeedNumberHisto");
332  doSeedLumiAnalysis_ = conf_.getParameter<bool>("doSeedLumiAnalysis");
333  doSeedVsClusterPlot = conf_.getParameter<bool>("doSeedVsClusterHisto");
334  // if (doAllPlots) doAllSeedPlots=true;
335 
336  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"));
337 
338  edm::InputTag seedProducer = conf_.getParameter<edm::InputTag>("SeedProducer");
339 
340  if (doAllSeedPlots || doSeedNumberPlot){
341  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
342  histname = "NumberOfSeeds_"+ seedProducer.label() + "_"+ CategoryName;
343  NumberOfSeeds = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
344  NumberOfSeeds->setAxisTitle("Number of Seeds per Event", 1);
345  NumberOfSeeds->setAxisTitle("Number of Events", 2);
346 
347  if ( doSeedLumiAnalysis_ ) {
348  ibooker.setCurrentFolder(MEFolderName+"/LSanalysis");
349  histname = "NumberOfSeeds_lumiFlag_"+ seedProducer.label() + "_"+ CategoryName;
350  NumberOfSeeds_lumiFlag = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
351  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Seeds per Event", 1);
352  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Events", 2);
353  }
354 
355  }
356 
357  if (doAllSeedPlots || doSeedVsClusterPlot){
358  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
359 
360  ClusterLabels= conf_.getParameter<std::vector<std::string> >("ClusterLabels");
361 
362  std::vector<double> histoMin,histoMax;
363  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
364 
365  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
366  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
367  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
368 
369  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
370  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
371  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
372 
373  setMaxMinBin(histoMin,histoMax,histoBin,NClusStrMin,NClusStrMax,NClusStrBin,NClusPxMin,NClusPxMax,NClusPxBin);
374 
375  for (uint i=0; i<ClusterLabels.size(); i++){
376  histname = "SeedsVsClusters_" + seedProducer.label() + "_Vs_" + ClusterLabels[i] + "_" + CategoryName;
377  SeedsVsClusters.push_back(dynamic_cast<MonitorElement*>(ibooker.book2D(histname, histname, histoBin[i], histoMin[i], histoMax[i],
378  TKNoSeedBin, TKNoSeedMin, TKNoSeedMax)));
379  SeedsVsClusters[i]->setAxisTitle("Number of Clusters", 1);
380  SeedsVsClusters[i]->setAxisTitle("Number of Seeds", 2);
381  }
382  }
383 
384  doTkCandPlots=conf_.getParameter<bool>("doTrackCandHistos");
385  // if (doAllPlots) doTkCandPlots=true;
386 
387  if (doTkCandPlots){
388  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
389 
390  edm::InputTag tcProducer = conf_.getParameter<edm::InputTag>("TCProducer");
391 
392  histname = "NumberOfTrackCandidates_"+ tcProducer.label() + "_"+ CategoryName;
393  NumberOfTrackCandidates = ibooker.book1D(histname, histname, TCNoBin, TCNoMin, TCNoMax);
394  NumberOfTrackCandidates->setAxisTitle("Number of Track Candidates per Event", 1);
395  NumberOfTrackCandidates->setAxisTitle("Number of Event", 2);
396  }
397 
399 
400 
401  if (doLumiAnalysis) {
402  if ( NumberOfTracks_lumiFlag ) NumberOfTracks_lumiFlag -> setLumiFlag();
404  }
405 
406  if(doAllSeedPlots || doSeedNumberPlot){
407  if ( doSeedLumiAnalysis_ )
409  }
410 
412 
413  ClusterLabels= conf_.getParameter<std::vector<std::string> >("ClusterLabels");
414 
415  std::vector<double> histoMin,histoMax;
416  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
417 
418  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
419  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
420  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
421 
422  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
423  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
424  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
425 
426  int NTrk2DBin = conf_.getParameter<int>( "NTrk2DBin");
427  double NTrk2DMin = conf_.getParameter<double>("NTrk2DMin");
428  double NTrk2DMax = conf_.getParameter<double>("NTrk2DMax");
429 
430  setMaxMinBin(histoMin,histoMax,histoBin,
431  NClusStrMin,NClusStrMax,NClusStrBin,
432  NClusPxMin, NClusPxMax, NClusPxBin);
433 
434  ibooker.setCurrentFolder(MEFolderName+"/HitProperties");
435 
436  for (uint i=0; i<ClusterLabels.size(); i++){
437 
438  ibooker.setCurrentFolder(MEFolderName+"/HitProperties");
439  histname = "TracksVs" + ClusterLabels[i] + "Cluster_" + CategoryName;
440  NumberOfTrkVsClusters.push_back(dynamic_cast<MonitorElement*>(ibooker.book2D(histname, histname,
441  histoBin[i], histoMin[i], histoMax[i],
442  NTrk2DBin,NTrk2DMin,NTrk2DMax
443  )));
444  std::string title = "Number of " + ClusterLabels[i] + " Clusters";
445  if(ClusterLabels[i].compare("Tot")==0)
446  title = "# of Clusters in (Pixel+Strip) Detectors";
447  NumberOfTrkVsClusters[i]->setAxisTitle(title, 1);
448  NumberOfTrkVsClusters[i]->setAxisTitle("Number of Tracks", 2);
449  }
450  }
451 
452  // Initialize the GenericTriggerEventFlag
453  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
454 
455 }
456 
457 /*
458 // -- BeginRun
459 //---------------------------------------------------------------------------------//
460 void TrackingMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
461 {
462 
463 }
464 */
465 
466 // - BeginLumi
467 // ---------------------------------------------------------------------------------//
469 
470  if (doLumiAnalysis) {
473  }
475  if ( doSeedLumiAnalysis_ )
477  }
478 }
479 
480 // -- Analyse
481 // ---------------------------------------------------------------------------------//
483 {
484  // Filter out events if Trigger Filtering is requested
485  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
486 
487  // Analyse the tracks
488  // if the collection is empty, do not fill anything
489  // ---------------------------------------------------------------------------------//
490 
491  // get the track collection
493  iEvent.getByToken(trackToken_, trackHandle);
494 
495  // int numberOfAllTracks = 0;
496  int numberOfTracks_den = 0;
497  edm::Handle<reco::TrackCollection> allTrackHandle;
498  iEvent.getByToken(allTrackToken_,allTrackHandle);
499  if (allTrackHandle.isValid()) {
500  // numberOfAllTracks = allTrackHandle->size();
501  for (reco::TrackCollection::const_iterator track = allTrackHandle->begin();
502  track!=allTrackHandle->end(); ++track) {
503  if ( denSelection_(*track) )
504  numberOfTracks_den++;
505  }
506  }
507 
508  if (trackHandle.isValid()) {
509 
510  int numberOfTracks = trackHandle->size();
511  int numberOfTracks_num = 0;
512 
513  reco::TrackCollection trackCollection = *trackHandle;
514  // calculate the mean # rechits and layers
515  int totalRecHits = 0, totalLayers = 0;
516 
517  for (reco::TrackCollection::const_iterator track = trackCollection.begin();
518  track!=trackCollection.end(); ++track) {
519 
520  if ( numSelection_(*track) )
521  numberOfTracks_num++;
522 
523  if ( doProfilesVsLS_ || doAllPlots)
524  NumberOfRecHitsPerTrackVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),track->recHitsSize());
525 
526  totalRecHits += track->numberOfValidHits();
527  totalLayers += track->hitPattern().trackerLayersWithMeasurement();
528 
529  // do analysis per track
530  theTrackAnalyzer->analyze(iEvent, iSetup, *track);
531  }
532 
533  double frac = -1.;
534  // if (numberOfAllTracks > 0) frac = static_cast<double>(numberOfTracks)/static_cast<double>(numberOfAllTracks);
535  if (numberOfTracks_den > 0) frac = static_cast<double>(numberOfTracks_num)/static_cast<double>(numberOfTracks_den);
536 
538  NumberOfTracks -> Fill(numberOfTracks);
539  if (doFractionPlot_)
540  FractionOfGoodTracks -> Fill(frac);
541 
542  if( numberOfTracks > 0 ) {
543  double meanRecHits = static_cast<double>(totalRecHits) / static_cast<double>(numberOfTracks);
544  double meanLayers = static_cast<double>(totalLayers) / static_cast<double>(numberOfTracks);
545  NumberOfMeanRecHitsPerTrack -> Fill(meanRecHits);
546  NumberOfMeanLayersPerTrack -> Fill(meanLayers);
547  }
548  }
549 
550  if ( doProfilesVsLS_ || doAllPlots) {
551  NumberOfTracksVsLS ->Fill(static_cast<double>(iEvent.id().luminosityBlock()),numberOfTracks);
552  if (doFractionPlot_)
553  GoodTracksFractionVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),frac);
554  }
555 
556  if ( doLumiAnalysis ) {
557  NumberOfTracks_lumiFlag -> Fill(numberOfTracks);
558  }
559 
560 
561  // Analyse the Track Building variables
562  // if the collection is empty, do not fill anything
563  // ---------------------------------------------------------------------------------//
564 
565 
566  // fill the TrackCandidate info
567  if (doTkCandPlots) {
568  // magnetic field
570  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
571 
572  // get the candidate collection
574  iEvent.getByToken( trackCandidateToken_, theTCHandle );
575  const TrackCandidateCollection& theTCCollection = *theTCHandle;
576 
577  if (theTCHandle.isValid()) {
578 
579  // get the beam spot
580  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
581  iEvent.getByToken(bsSrcToken_, recoBeamSpotHandle );
582  const reco::BeamSpot& bs = *recoBeamSpotHandle;
583 
584  NumberOfTrackCandidates->Fill(theTCCollection.size());
586  for( TrackCandidateCollection::const_iterator cand = theTCCollection.begin(); cand != theTCCollection.end(); ++cand) {
587 
588  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *cand, bs, theMF, theTTRHBuilder);
589  }
590  } else {
591  edm::LogWarning("TrackingMonitor") << "No Track Candidates in the event. Not filling associated histograms";
592  }
593  }
594 
595  //plots for trajectory seeds
596 
598 
599  // get the seed collection
601  iEvent.getByToken(seedToken_, seedHandle );
602  const edm::View<TrajectorySeed>& seedCollection = *seedHandle;
603 
604  // fill the seed info
605  if (seedHandle.isValid()) {
606 
608  NumberOfSeeds->Fill(seedCollection.size());
609  if ( doSeedLumiAnalysis_ )
610  NumberOfSeeds_lumiFlag->Fill(seedCollection.size());
611  }
612 
614 
615  std::vector<int> NClus;
616  setNclus(iEvent,NClus);
617  for (uint i=0; i< ClusterLabels.size(); i++){
618  SeedsVsClusters[i]->Fill(NClus[i],seedCollection.size());
619  }
620  }
621 
623 
624  //here duplication of mag field and be informations is needed to allow seed and track cand histos to be independent
625  // magnetic field
627  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
628 
629  // get the beam spot
630  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
631  iEvent.getByToken(bsSrcToken_, recoBeamSpotHandle );
632  const reco::BeamSpot& bs = *recoBeamSpotHandle;
633 
635  for(size_t i=0; i < seedHandle->size(); ++i) {
636 
638  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *seed, bs, theMF, theTTRHBuilder);
639  }
640  }
641 
642  } else {
643  edm::LogWarning("TrackingMonitor") << "No Trajectory seeds in the event. Not filling associated histograms";
644  }
645  }
646 
647 
649 
650  std::vector<int> NClus;
651  setNclus(iEvent,NClus);
652  for (uint i=0; i< ClusterLabels.size(); i++) {
653  NumberOfTrkVsClusters[i]->Fill(NClus[i],numberOfTracks);
654  }
655  }
656 
657  if ( doPUmonitoring_ ) {
658 
659  // do vertex monitoring
660  for (size_t i=0; i<theVertexMonitor.size(); i++)
661  theVertexMonitor[i]->analyze(iEvent, iSetup);
662 
663  if ( doPlotsVsGoodPVtx_ ) {
664 
665  size_t totalNumGoodPV = 0;
667  iEvent.getByToken(pvSrcToken_, pvHandle );
668  if (pvHandle.isValid()) {
669 
670  for (reco::VertexCollection::const_iterator pv = pvHandle->begin();
671  pv != pvHandle->end(); ++pv) {
672 
673  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
674  if (pv->isFake() || pv->tracksSize()==0) continue;
675 
676  // definition of goodOfflinePrimaryVertex
677  if (pv->ndof() < 4. || pv->z() > 24.) continue;
678  totalNumGoodPV++;
679  }
680 
681  NumberOfTracksVsGoodPVtx -> Fill( totalNumGoodPV, numberOfTracks );
682  }
683  }
684 
685  if ( doPlotsVsBXlumi_ ) {
686  double bxlumi = theLumiDetails_->getValue(iEvent);
687  NumberOfTracksVsBXlumi -> Fill( bxlumi, numberOfTracks );
688  }
689 
690  } // PU monitoring
691 
692  } // trackHandle is valid
693 
694 }
695 
696 
698 {
699 }
700 
702 {
703  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
705  if(outputMEsInRootFile)
706  {
708  dqmStore_->save(outputFileName);
709  }
710 }
711 
712 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)
713 {
714  arrayMin.resize(ClusterLabels.size());
715  arrayMax.resize(ClusterLabels.size());
716  arrayBin.resize(ClusterLabels.size());
717 
718  for (uint i=0; i<ClusterLabels.size(); ++i) {
719 
720  if (ClusterLabels[i].compare("Pix")==0 ) {arrayMin[i]=pmin; arrayMax[i]=pmax; arrayBin[i]=pbin;}
721  else if(ClusterLabels[i].compare("Strip")==0) {arrayMin[i]=smin; arrayMax[i]=smax; arrayBin[i]=sbin;}
722  else if(ClusterLabels[i].compare("Tot")==0 ) {arrayMin[i]=smin; arrayMax[i]=smax+pmax; arrayBin[i]=sbin;}
723  else {edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i] << " not defined, using strip parameters ";
724  arrayMin[i]=smin; arrayMax[i]=smax; arrayBin[i]=sbin;}
725 
726  }
727 
728 }
729 
730 void TrackingMonitor::setNclus(const edm::Event& iEvent,std::vector<int> &arrayNclus)
731 {
732 
733  int ncluster_pix=-1;
734  int ncluster_strip=-1;
735 
737  iEvent.getByToken(stripClustersToken_, strip_clusters );
739  iEvent.getByToken(pixelClustersToken_, pixel_clusters );
740 
741  if (strip_clusters.isValid() && pixel_clusters.isValid()) {
742  ncluster_pix = (*pixel_clusters).dataSize();
743  ncluster_strip = (*strip_clusters).dataSize();
744  }
745 
746  arrayNclus.resize(ClusterLabels.size());
747  for (uint i=0; i<ClusterLabels.size(); ++i){
748 
749  if (ClusterLabels[i].compare("Pix")==0 ) arrayNclus[i]=ncluster_pix ;
750  else if(ClusterLabels[i].compare("Strip")==0) arrayNclus[i]=ncluster_strip;
751  else if(ClusterLabels[i].compare("Tot")==0 ) arrayNclus[i]=ncluster_pix+ncluster_strip;
752  else {edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i] << " not defined using stri parametrs ";
753  arrayNclus[i]=ncluster_strip ;}
754  }
755 
756 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken_
int i
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > NumberOfTrkVsClusters
MonitorElement * FractionOfGoodTracks
DQMStore * dqmStore_
virtual void setMaxMinBin(std::vector< double > &, std::vector< double > &, std::vector< int > &, double, double, int, double, double, int)
TrackAnalyzer * theTrackAnalyzer
edm::ParameterSet conf_
virtual void setNclus(const edm::Event &, std::vector< int > &)
edm::EDGetTokenT< reco::TrackCollection > allTrackToken_
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:155
GetLumi * theLumiDetails_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:35
std::vector< TrackCandidate > TrackCandidateCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
edm::InputTag pvSrc_
#define NULL
Definition: scimark2.h:8
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
MonitorElement * NumberOfMeanRecHitsPerTrack
MonitorElement * NumberOfTracksVsGoodPVtx
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:43
MonitorElement * GoodTracksFractionVsLS
void Fill(long long x)
double getValue(const edm::Event &)
Definition: GetLumi.cc:64
std::string Quality_
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
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
virtual void endJob(void)
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.
virtual void initHisto(DQMStore::IBooker &ibooker)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
MonitorElement * NumberOfTracksVsLS
TH1 * getTH1(void) const
bool runTrackBuildingAnalyzerForSeed
bool isValid() const
Definition: HandleBase.h:76
std::vector< MonitorElement * > SeedsVsClusters
MonitorElement * NumberOfRecHitsPerTrackVsLS
virtual void endRun(const edm::Run &, const edm::EventSetup &)
std::string histname
std::vector< VertexMonitor * > theVertexMonitor
MonitorElement * NumberOfTracksVsBXlumi
edm::InputTag stripClusterInputTag_
bool doGeneralPropertiesPlots_
TrackBuildingAnalyzer * theTrackBuildingAnalyzer
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:131
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Track &track)
std::string AlgoName_
edm::EDGetTokenT< reco::TrackCollection > trackToken_
edm::EDGetTokenT< TrackCandidateCollection > trackCandidateToken_
MonitorElement * NumberOfMeanLayersPerTrack
StringCutObjectSelector< reco::Track, true > denSelection_
const T & get() const
Definition: EventSetup.h:55
StringCutObjectSelector< reco::Track, true > numSelection_
size_type size() const
virtual void initHisto(DQMStore::IBooker &ibooker)
GenericTriggerEventFlag * genTriggerEventFlag_
edm::InputTag pixelClusterInputTag_
std::string const & label() const
Definition: InputTag.h:42
MonitorElement * NumberOfSeeds_lumiFlag
edm::EventID id() const
Definition: EventBase.h:56
TrackingMonitor(const edm::ParameterSet &)
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2540
virtual void beginJob(void)
MonitorElement * NumberOfTrackCandidates
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
void Reset(std::vector< TH2F > &depth)
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersToken_
void showDirStructure(void) const
Definition: DQMStore.cc:3332
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
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
edm::EDGetTokenT< reco::VertexCollection > pvSrcToken_
Definition: Run.h:41
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &eSetup)
std::vector< std::string > ClusterLabels
std::string builderName