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  : 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  , NumberOfTracksVsLS(NULL)
53  // , NumberOfGoodTracksVsLS(NULL)
54  , GoodTracksFractionVsLS(NULL)
55  // , GoodTracksNumberOfRecHitsPerTrackVsLS(NULL)
56  // ADD by Mia for PU monitoring
57  // vertex plots to be moved in ad hoc class
58  , NumberOfTracksVsGoodPVtx(NULL)
59  , NumberOfTracksVsPUPVtx(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(), *this))
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");
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  // get flag from the configuration
108  doPlotsVsBXlumi_ = conf_.getParameter<bool>("doPlotsVsBXlumi");
109  if ( doPlotsVsBXlumi_ )
110  theLumiDetails_ = new GetLumi( iConfig.getParameter<edm::ParameterSet>("BXlumiSetup"), c );
111  doPlotsVsGoodPVtx_ = conf_.getParameter<bool>("doPlotsVsGoodPVtx");
112 
113 
114  if ( doPUmonitoring_ ) {
115 
116  std::vector<edm::InputTag> primaryVertexInputTags = conf_.getParameter<std::vector<edm::InputTag> >("primaryVertexInputTags");
117  std::vector<edm::InputTag> selPrimaryVertexInputTags = conf_.getParameter<std::vector<edm::InputTag> >("selPrimaryVertexInputTags");
118  std::vector<std::string> pvLabels = conf_.getParameter<std::vector<std::string> > ("pvLabels");
119 
120  if (primaryVertexInputTags.size()==pvLabels.size() and primaryVertexInputTags.size()==selPrimaryVertexInputTags.size()) {
121  // for (auto const& tag : primaryVertexInputTags) {
122  for (size_t i=0; i<primaryVertexInputTags.size(); i++) {
123  edm::InputTag iPVinputTag = primaryVertexInputTags[i];
124  edm::InputTag iSelPVinputTag = selPrimaryVertexInputTags[i];
125  std::string iPVlabel = pvLabels[i];
126 
127  theVertexMonitor.push_back(new VertexMonitor(conf_,iPVinputTag,iSelPVinputTag,iPVlabel,c) );
128  }
129  }
130  }
131 
132 }
133 
134 
136 {
139  if ( doPUmonitoring_ )
140  for (size_t i=0; i<theVertexMonitor.size(); i++)
141  if (theVertexMonitor[i]) delete theVertexMonitor[i];
143 }
144 
145 
147 {
148 
149 
150 }
151 
153  edm::Run const & iRun,
154  edm::EventSetup const & iSetup)
155 {
156  // parameters from the configuration
159  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
160 
161  // test for the Quality veriable validity
162  if( Quality_ != "") {
163  if( Quality_ != "highPurity" && Quality_ != "tight" && Quality_ != "loose") {
164  edm::LogWarning("TrackingMonitor") << "Qualty Name is invalid, using no quality criterea by default";
165  Quality_ = "";
166  }
167  }
168 
169  // use the AlgoName and Quality Name
170  std::string CategoryName = Quality_ != "" ? AlgoName_ + "_" + Quality_ : AlgoName_;
171 
172  // get binning from the configuration
173  int TKNoBin = conf_.getParameter<int>( "TkSizeBin");
174  double TKNoMin = conf_.getParameter<double>("TkSizeMin");
175  double TKNoMax = conf_.getParameter<double>("TkSizeMax");
176 
177  int TCNoBin = conf_.getParameter<int>( "TCSizeBin");
178  double TCNoMin = conf_.getParameter<double>("TCSizeMin");
179  double TCNoMax = conf_.getParameter<double>("TCSizeMax");
180 
181  int TKNoSeedBin = conf_.getParameter<int>( "TkSeedSizeBin");
182  double TKNoSeedMin = conf_.getParameter<double>("TkSeedSizeMin");
183  double TKNoSeedMax = conf_.getParameter<double>("TkSeedSizeMax");
184 
185  int MeanHitBin = conf_.getParameter<int>( "MeanHitBin");
186  double MeanHitMin = conf_.getParameter<double>("MeanHitMin");
187  double MeanHitMax = conf_.getParameter<double>("MeanHitMax");
188 
189  int MeanLayBin = conf_.getParameter<int>( "MeanLayBin");
190  double MeanLayMin = conf_.getParameter<double>("MeanLayMin");
191  double MeanLayMax = conf_.getParameter<double>("MeanLayMax");
192 
193  int LSBin = conf_.getParameter<int>( "LSBin");
194  int LSMin = conf_.getParameter<double>("LSMin");
195  int LSMax = conf_.getParameter<double>("LSMax");
196 
197  std::string StateName = conf_.getParameter<std::string>("MeasurementState");
198  if (
199  StateName != "OuterSurface" &&
200  StateName != "InnerSurface" &&
201  StateName != "ImpactPoint" &&
202  StateName != "default" &&
203  StateName != "All"
204  ) {
205  // print warning
206  edm::LogWarning("TrackingMonitor") << "State Name is invalid, using 'ImpactPoint' by default";
207  }
208 
209  ibooker.setCurrentFolder(MEFolderName);
210 
211  // book the General Property histograms
212  // ---------------------------------------------------------------------------------//
213 
215 
216  ibooker.setCurrentFolder(MEFolderName+"/GeneralProperties");
217 
218  histname = "NumberOfTracks_" + CategoryName;
219  // MODIFY by Mia in order to cope w/ high multiplicity
220  NumberOfTracks = ibooker.book1D(histname, histname, 3*TKNoBin, TKNoMin, (TKNoMax+0.5)*3.-0.5);
221  NumberOfTracks->setAxisTitle("Number of Tracks per Event", 1);
222  NumberOfTracks->setAxisTitle("Number of Events", 2);
223 
224  histname = "NumberOfMeanRecHitsPerTrack_" + CategoryName;
225  NumberOfMeanRecHitsPerTrack = ibooker.book1D(histname, histname, MeanHitBin, MeanHitMin, MeanHitMax);
226  NumberOfMeanRecHitsPerTrack->setAxisTitle("Mean number of valid RecHits per Track", 1);
228 
229  histname = "NumberOfMeanLayersPerTrack_" + CategoryName;
230  NumberOfMeanLayersPerTrack = ibooker.book1D(histname, histname, MeanLayBin, MeanLayMin, MeanLayMax);
231  NumberOfMeanLayersPerTrack->setAxisTitle("Mean number of Layers per Track", 1);
233 
234  if (doFractionPlot_) {
235  histname = "FractionOfGoodTracks_" + CategoryName;
236  FractionOfGoodTracks = ibooker.book1D(histname, histname, 101, -0.005, 1.005);
237  FractionOfGoodTracks->setAxisTitle("Fraction of Tracks (w.r.t. generalTracks)", 1);
238  FractionOfGoodTracks->setAxisTitle("Entries", 2);
239  }
240  }
241 
242  if ( doLumiAnalysis ) {
243  // add by Mia in order to deal with LS transitions
244  ibooker.setCurrentFolder(MEFolderName+"/LSanalysis");
245 
246  histname = "NumberOfTracks_lumiFlag_" + CategoryName;
247  NumberOfTracks_lumiFlag = ibooker.book1D(histname, histname, 3*TKNoBin, TKNoMin, (TKNoMax+0.5)*3.-0.5);
248  NumberOfTracks_lumiFlag->setAxisTitle("Number of Tracks per Event", 1);
249  NumberOfTracks_lumiFlag->setAxisTitle("Number of Events", 2);
250 
251  }
252 
253  // book profile plots vs LS :
254  //---------------------------
255 
256 
257  if ( doProfilesVsLS_ || doAllPlots) {
258 
259  ibooker.setCurrentFolder(MEFolderName+"/GeneralProperties");
260 
261  histname = "NumberOfTracksVsLS_"+ CategoryName;
262  NumberOfTracksVsLS = ibooker.bookProfile(histname,histname, LSBin,LSMin,LSMax, TKNoMin, (TKNoMax+0.5)*3.-0.5,"");
263  NumberOfTracksVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
264  NumberOfTracksVsLS->setAxisTitle("#Lumi section",1);
265  NumberOfTracksVsLS->setAxisTitle("Number of Tracks",2);
266 
267  histname = "NumberOfRecHitsPerTrackVsLS_" + CategoryName;
268  NumberOfRecHitsPerTrackVsLS = ibooker.bookProfile(histname,histname, LSBin,LSMin,LSMax,0.,40.,"");
269  NumberOfRecHitsPerTrackVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
270  NumberOfRecHitsPerTrackVsLS->setAxisTitle("#Lumi section",1);
271  NumberOfRecHitsPerTrackVsLS->setAxisTitle("Mean number of Valid RecHits per track",2);
272 
273  if (doFractionPlot_) {
274  histname = "GoodTracksFractionVsLS_"+ CategoryName;
275  GoodTracksFractionVsLS = ibooker.bookProfile(histname,histname, LSBin,LSMin,LSMax,0,1.1,"");
276  GoodTracksFractionVsLS->getTH1()->SetCanExtend(TH1::kAllAxes);
277  GoodTracksFractionVsLS->setAxisTitle("#Lumi section",1);
278  GoodTracksFractionVsLS->setAxisTitle("Fraction of Good Tracks",2);
279  }
280  }
281 
282  // book PU monitoring plots :
283  //---------------------------
284 
285  if ( doPUmonitoring_ ) {
286 
287  for (size_t i=0; i<theVertexMonitor.size(); i++)
288  theVertexMonitor[i]->initHisto(ibooker);
289  }
290 
291  if ( doPlotsVsGoodPVtx_ ) {
292  ibooker.setCurrentFolder(MEFolderName+"/PUmonitoring");
293  // get binning from the configuration
294  int GoodPVtxBin = conf_.getParameter<int>("GoodPVtxBin");
295  double GoodPVtxMin = conf_.getParameter<double>("GoodPVtxMin");
296  double GoodPVtxMax = conf_.getParameter<double>("GoodPVtxMax");
297 
298  histname = "NumberOfTracksVsGoodPVtx";
299  NumberOfTracksVsGoodPVtx = ibooker.bookProfile(histname,histname,GoodPVtxBin,GoodPVtxMin,GoodPVtxMax,TKNoMin, (TKNoMax+0.5)*3.-0.5,"");
300  NumberOfTracksVsGoodPVtx->getTH1()->SetCanExtend(TH1::kAllAxes);
301  NumberOfTracksVsGoodPVtx->setAxisTitle("Number of PV",1);
302  NumberOfTracksVsGoodPVtx->setAxisTitle("Mean number of Tracks per Event",2);
303 
304  histname = "NumberOfTracksVsPUPVtx";
305  NumberOfTracksVsPUPVtx = ibooker.bookProfile(histname,histname,GoodPVtxBin,GoodPVtxMin,GoodPVtxMax,0., 100.,"");
306  NumberOfTracksVsPUPVtx->getTH1()->SetCanExtend(TH1::kAllAxes);
307  NumberOfTracksVsPUPVtx->setAxisTitle("Number of PU",1);
308  NumberOfTracksVsPUPVtx->setAxisTitle("Mean number of Tracks per PUvtx",2);
309 
310  }
311 
312  if ( doPlotsVsBXlumi_ ) {
313  ibooker.setCurrentFolder(MEFolderName+"/PUmonitoring");
314  // get binning from the configuration
315  edm::ParameterSet BXlumiParameters = conf_.getParameter<edm::ParameterSet>("BXlumiSetup");
316  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
317  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
318  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
319 
320  histname = "NumberOfTracksVsBXlumi_"+ CategoryName;
321  NumberOfTracksVsBXlumi = ibooker.bookProfile(histname,histname, BXlumiBin,BXlumiMin,BXlumiMax, TKNoMin, TKNoMax,"");
322  NumberOfTracksVsBXlumi->getTH1()->SetCanExtend(TH1::kAllAxes);
323  NumberOfTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]",1);
324  NumberOfTracksVsBXlumi->setAxisTitle("Mean number of Tracks",2);
325 
326  }
327 
328 
329  theTrackAnalyzer->initHisto(ibooker, iSetup);
330 
331  // book the Seed Property histograms
332  // ---------------------------------------------------------------------------------//
333 
334  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
335 
336  doAllSeedPlots = conf_.getParameter<bool>("doSeedParameterHistos");
337  doSeedNumberPlot = conf_.getParameter<bool>("doSeedNumberHisto");
338  doSeedLumiAnalysis_ = conf_.getParameter<bool>("doSeedLumiAnalysis");
339  doSeedVsClusterPlot = conf_.getParameter<bool>("doSeedVsClusterHisto");
340  // if (doAllPlots) doAllSeedPlots=true;
341 
342  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"));
343 
344  edm::InputTag seedProducer = conf_.getParameter<edm::InputTag>("SeedProducer");
345 
346  if (doAllSeedPlots || doSeedNumberPlot){
347  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
348  histname = "NumberOfSeeds_"+ seedProducer.label() + "_"+ CategoryName;
349  NumberOfSeeds = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
350  NumberOfSeeds->setAxisTitle("Number of Seeds per Event", 1);
351  NumberOfSeeds->setAxisTitle("Number of Events", 2);
352 
353  if ( doSeedLumiAnalysis_ ) {
354  ibooker.setCurrentFolder(MEFolderName+"/LSanalysis");
355  histname = "NumberOfSeeds_lumiFlag_"+ seedProducer.label() + "_"+ CategoryName;
356  NumberOfSeeds_lumiFlag = ibooker.book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
357  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Seeds per Event", 1);
358  NumberOfSeeds_lumiFlag->setAxisTitle("Number of Events", 2);
359  }
360 
361  }
362 
363  if (doAllSeedPlots || doSeedVsClusterPlot){
364  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
365 
366  ClusterLabels= conf_.getParameter<std::vector<std::string> >("ClusterLabels");
367 
368  std::vector<double> histoMin,histoMax;
369  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
370 
371  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
372  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
373  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
374 
375  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
376  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
377  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
378 
379  setMaxMinBin(histoMin,histoMax,histoBin,NClusStrMin,NClusStrMax,NClusStrBin,NClusPxMin,NClusPxMax,NClusPxBin);
380 
381  for (uint i=0; i<ClusterLabels.size(); i++){
382  histname = "SeedsVsClusters_" + seedProducer.label() + "_Vs_" + ClusterLabels[i] + "_" + CategoryName;
383  SeedsVsClusters.push_back(dynamic_cast<MonitorElement*>(ibooker.book2D(histname, histname, histoBin[i], histoMin[i], histoMax[i],
384  TKNoSeedBin, TKNoSeedMin, TKNoSeedMax)));
385  SeedsVsClusters[i]->setAxisTitle("Number of Clusters", 1);
386  SeedsVsClusters[i]->setAxisTitle("Number of Seeds", 2);
387  }
388  }
389 
390  doTkCandPlots=conf_.getParameter<bool>("doTrackCandHistos");
391  // if (doAllPlots) doTkCandPlots=true;
392 
393  if (doTkCandPlots){
394  ibooker.setCurrentFolder(MEFolderName+"/TrackBuilding");
395 
396  edm::InputTag tcProducer = conf_.getParameter<edm::InputTag>("TCProducer");
397 
398  histname = "NumberOfTrackCandidates_"+ tcProducer.label() + "_"+ CategoryName;
399  NumberOfTrackCandidates = ibooker.book1D(histname, histname, TCNoBin, TCNoMin, TCNoMax);
400  NumberOfTrackCandidates->setAxisTitle("Number of Track Candidates per Event", 1);
401  NumberOfTrackCandidates->setAxisTitle("Number of Event", 2);
402  }
403 
405 
406 
407  if (doLumiAnalysis) {
408  if ( NumberOfTracks_lumiFlag ) NumberOfTracks_lumiFlag -> setLumiFlag();
410  }
411 
412  if(doAllSeedPlots || doSeedNumberPlot){
413  if ( doSeedLumiAnalysis_ )
415  }
416 
418 
419  ClusterLabels= conf_.getParameter<std::vector<std::string> >("ClusterLabels");
420 
421  std::vector<double> histoMin,histoMax;
422  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
423 
424  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
425  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
426  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
427 
428  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
429  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
430  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
431 
432  int NTrk2DBin = conf_.getParameter<int>( "NTrk2DBin");
433  double NTrk2DMin = conf_.getParameter<double>("NTrk2DMin");
434  double NTrk2DMax = conf_.getParameter<double>("NTrk2DMax");
435 
436  setMaxMinBin(histoMin,histoMax,histoBin,
437  NClusStrMin,NClusStrMax,NClusStrBin,
438  NClusPxMin, NClusPxMax, NClusPxBin);
439 
440  ibooker.setCurrentFolder(MEFolderName+"/HitProperties");
441 
442  for (uint i=0; i<ClusterLabels.size(); i++){
443 
444  ibooker.setCurrentFolder(MEFolderName+"/HitProperties");
445  histname = "TracksVs" + ClusterLabels[i] + "Cluster_" + CategoryName;
446  NumberOfTrkVsClusters.push_back(dynamic_cast<MonitorElement*>(ibooker.book2D(histname, histname,
447  histoBin[i], histoMin[i], histoMax[i],
448  NTrk2DBin,NTrk2DMin,NTrk2DMax
449  )));
450  std::string title = "Number of " + ClusterLabels[i] + " Clusters";
451  if(ClusterLabels[i].compare("Tot")==0)
452  title = "# of Clusters in (Pixel+Strip) Detectors";
453  NumberOfTrkVsClusters[i]->setAxisTitle(title, 1);
454  NumberOfTrkVsClusters[i]->setAxisTitle("Number of Tracks", 2);
455  }
456  }
457 
458  // Initialize the GenericTriggerEventFlag
459  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
460 
461 }
462 
463 /*
464 // -- BeginRun
465 //---------------------------------------------------------------------------------//
466 void TrackingMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
467 {
468 
469 }
470 */
471 
472 // - BeginLumi
473 // ---------------------------------------------------------------------------------//
475 
476  if (doLumiAnalysis) {
479  }
481  if ( doSeedLumiAnalysis_ )
483  }
484 }
485 
486 // -- Analyse
487 // ---------------------------------------------------------------------------------//
489 {
490 
491  // Filter out events if Trigger Filtering is requested
492  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
493 
494  // Analyse the tracks
495  // if the collection is empty, do not fill anything
496  // ---------------------------------------------------------------------------------//
497 
498  // get the track collection
500  iEvent.getByToken(trackToken_, trackHandle);
501 
502  // int numberOfAllTracks = 0;
503  int numberOfTracks_den = 0;
504  edm::Handle<reco::TrackCollection> allTrackHandle;
505  iEvent.getByToken(allTrackToken_,allTrackHandle);
506  if (allTrackHandle.isValid()) {
507  // numberOfAllTracks = allTrackHandle->size();
508  for (reco::TrackCollection::const_iterator track = allTrackHandle->begin();
509  track!=allTrackHandle->end(); ++track) {
510  if ( denSelection_(*track) )
511  numberOfTracks_den++;
512  }
513  }
514 
516  iEvent.getByToken(pvSrcToken_, pvHandle );
517  reco::Vertex const * pv0 = nullptr;
518  if (pvHandle.isValid()) {
519  pv0 = &pvHandle->front();
520  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
521  if ( pv0->isFake() || pv0->tracksSize()==0
522  // definition of goodOfflinePrimaryVertex
523  || pv0->ndof() < 4. || pv0->z() > 24.) pv0 = nullptr;
524  }
525 
526 
527  if (trackHandle.isValid()) {
528 
529  int numberOfTracks = trackHandle->size();
530  int numberOfTracks_num = 0;
531  int numberOfTracks_pv0 = 0;
532 
533  reco::TrackCollection trackCollection = *trackHandle;
534  // calculate the mean # rechits and layers
535  int totalRecHits = 0, totalLayers = 0;
536 
538  for (reco::TrackCollection::const_iterator track = trackCollection.begin();
539  track!=trackCollection.end(); ++track) {
540 
541  if ( numSelection_(*track) ) {
542  numberOfTracks_num++;
543  if (pv0 && std::abs(track->dz(pv0->position()))<0.15) ++numberOfTracks_pv0;
544  }
545 
546  if ( doProfilesVsLS_ || doAllPlots)
547  NumberOfRecHitsPerTrackVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),track->numberOfValidHits());
548 
549  totalRecHits += track->numberOfValidHits();
550  totalLayers += track->hitPattern().trackerLayersWithMeasurement();
551 
552  // do analysis per track
553  theTrackAnalyzer->analyze(iEvent, iSetup, *track);
554  }
555 
556  double frac = -1.;
557  // if (numberOfAllTracks > 0) frac = static_cast<double>(numberOfTracks)/static_cast<double>(numberOfAllTracks);
558  if (numberOfTracks_den > 0) frac = static_cast<double>(numberOfTracks_num)/static_cast<double>(numberOfTracks_den);
559 
561  NumberOfTracks -> Fill(numberOfTracks);
562  if (doFractionPlot_)
563  FractionOfGoodTracks -> Fill(frac);
564 
565  if( numberOfTracks > 0 ) {
566  double meanRecHits = static_cast<double>(totalRecHits) / static_cast<double>(numberOfTracks);
567  double meanLayers = static_cast<double>(totalLayers) / static_cast<double>(numberOfTracks);
568  NumberOfMeanRecHitsPerTrack -> Fill(meanRecHits);
569  NumberOfMeanLayersPerTrack -> Fill(meanLayers);
570  }
571  }
572 
573  if ( doProfilesVsLS_ || doAllPlots) {
574  NumberOfTracksVsLS ->Fill(static_cast<double>(iEvent.id().luminosityBlock()),numberOfTracks);
575  if (doFractionPlot_)
576  GoodTracksFractionVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),frac);
577  }
578 
579  if ( doLumiAnalysis ) {
580  NumberOfTracks_lumiFlag -> Fill(numberOfTracks);
581  }
582 
583 
584  // Analyse the Track Building variables
585  // if the collection is empty, do not fill anything
586  // ---------------------------------------------------------------------------------//
587 
588 
589  // fill the TrackCandidate info
590  if (doTkCandPlots) {
591  // magnetic field
593  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
594 
595  // get the candidate collection
597  iEvent.getByToken( trackCandidateToken_, theTCHandle );
598  const TrackCandidateCollection& theTCCollection = *theTCHandle;
599 
600  if (theTCHandle.isValid()) {
601 
602  // get the beam spot
603  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
604  iEvent.getByToken(bsSrcToken_, recoBeamSpotHandle );
605  const reco::BeamSpot& bs = *recoBeamSpotHandle;
606 
607  NumberOfTrackCandidates->Fill(theTCCollection.size());
609  for( TrackCandidateCollection::const_iterator cand = theTCCollection.begin(); cand != theTCCollection.end(); ++cand) {
610 
611  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *cand, bs, theMF, theTTRHBuilder);
612  }
613  } else {
614  edm::LogWarning("TrackingMonitor") << "No Track Candidates in the event. Not filling associated histograms";
615  }
616  }
617 
618  //plots for trajectory seeds
619 
621 
622  // get the seed collection
624  iEvent.getByToken(seedToken_, seedHandle );
625  const edm::View<TrajectorySeed>& seedCollection = *seedHandle;
626 
627  // fill the seed info
628  if (seedHandle.isValid()) {
629 
631  NumberOfSeeds->Fill(seedCollection.size());
632  if ( doSeedLumiAnalysis_ )
633  NumberOfSeeds_lumiFlag->Fill(seedCollection.size());
634  }
635 
637 
638  std::vector<int> NClus;
639  setNclus(iEvent,NClus);
640  for (uint i=0; i< ClusterLabels.size(); i++){
641  SeedsVsClusters[i]->Fill(NClus[i],seedCollection.size());
642  }
643  }
644 
646 
647  //here duplication of mag field and be informations is needed to allow seed and track cand histos to be independent
648  // magnetic field
650  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
651 
652  // get the beam spot
653  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
654  iEvent.getByToken(bsSrcToken_, recoBeamSpotHandle );
655  const reco::BeamSpot& bs = *recoBeamSpotHandle;
656 
658  for(size_t i=0; i < seedHandle->size(); ++i) {
659 
661  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *seed, bs, theMF, theTTRHBuilder);
662  }
663  }
664 
665  } else {
666  edm::LogWarning("TrackingMonitor") << "No Trajectory seeds in the event. Not filling associated histograms";
667  }
668  }
669 
670 
672 
673  std::vector<int> NClus;
674  setNclus(iEvent,NClus);
675  for (uint i=0; i< ClusterLabels.size(); i++) {
676  NumberOfTrkVsClusters[i]->Fill(NClus[i],numberOfTracks);
677  }
678  }
679 
680  if ( doPUmonitoring_ ) {
681 
682  // do vertex monitoring
683  for (size_t i=0; i<theVertexMonitor.size(); i++)
684  theVertexMonitor[i]->analyze(iEvent, iSetup);
685  }
686  if ( doPlotsVsGoodPVtx_ ) {
687 
688  size_t totalNumGoodPV = 0;
689  if (pvHandle.isValid()) {
690 
691  for (reco::VertexCollection::const_iterator pv = pvHandle->begin();
692  pv != pvHandle->end(); ++pv) {
693 
694  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
695  if (pv->isFake() || pv->tracksSize()==0) continue;
696 
697  // definition of goodOfflinePrimaryVertex
698  if (pv->ndof() < 4. || pv->z() > 24.) continue;
699  totalNumGoodPV++;
700  }
701 
702  NumberOfTracksVsGoodPVtx -> Fill( totalNumGoodPV, numberOfTracks );
703  if (totalNumGoodPV>1) NumberOfTracksVsPUPVtx-> Fill( totalNumGoodPV-1, double(numberOfTracks-numberOfTracks_pv0)/double(totalNumGoodPV-1) );
704  }
705 
706 
707  if ( doPlotsVsBXlumi_ ) {
708  double bxlumi = theLumiDetails_->getValue(iEvent);
709  NumberOfTracksVsBXlumi -> Fill( bxlumi, numberOfTracks );
710  }
711 
712  } // PU monitoring
713 
714  } // trackHandle is valid
715 
716 }
717 
718 
720 {
721 }
722 
723 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)
724 {
725  arrayMin.resize(ClusterLabels.size());
726  arrayMax.resize(ClusterLabels.size());
727  arrayBin.resize(ClusterLabels.size());
728 
729  for (uint i=0; i<ClusterLabels.size(); ++i) {
730 
731  if (ClusterLabels[i].compare("Pix")==0 ) {arrayMin[i]=pmin; arrayMax[i]=pmax; arrayBin[i]=pbin;}
732  else if(ClusterLabels[i].compare("Strip")==0) {arrayMin[i]=smin; arrayMax[i]=smax; arrayBin[i]=sbin;}
733  else if(ClusterLabels[i].compare("Tot")==0 ) {arrayMin[i]=smin; arrayMax[i]=smax+pmax; arrayBin[i]=sbin;}
734  else {edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i] << " not defined, using strip parameters ";
735  arrayMin[i]=smin; arrayMax[i]=smax; arrayBin[i]=sbin;}
736 
737  }
738 
739 }
740 
741 void TrackingMonitor::setNclus(const edm::Event& iEvent,std::vector<int> &arrayNclus)
742 {
743 
744  int ncluster_pix=-1;
745  int ncluster_strip=-1;
746 
748  iEvent.getByToken(stripClustersToken_, strip_clusters );
750  iEvent.getByToken(pixelClustersToken_, pixel_clusters );
751 
752  if (strip_clusters.isValid() && pixel_clusters.isValid()) {
753  ncluster_pix = (*pixel_clusters).dataSize();
754  ncluster_strip = (*strip_clusters).dataSize();
755  }
756 
757  arrayNclus.resize(ClusterLabels.size());
758  for (uint i=0; i<ClusterLabels.size(); ++i){
759 
760  if (ClusterLabels[i].compare("Pix")==0 ) arrayNclus[i]=ncluster_pix ;
761  else if(ClusterLabels[i].compare("Strip")==0) arrayNclus[i]=ncluster_strip;
762  else if(ClusterLabels[i].compare("Tot")==0 ) arrayNclus[i]=ncluster_pix+ncluster_strip;
763  else {edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i] << " not defined using stri parametrs ";
764  arrayNclus[i]=ncluster_strip ;}
765  }
766 
767 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken_
int i
Definition: DBlmapReader.cc:9
std::vector< MonitorElement * > NumberOfTrkVsClusters
MonitorElement * FractionOfGoodTracks
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:157
GetLumi * theLumiDetails_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#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:14
edm::InputTag pvSrc_
size_type size() const
#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:40
const Point & position() const
position
Definition: Vertex.h:99
MonitorElement * GoodTracksFractionVsLS
MonitorElement * NumberOfTracksVsPUPVtx
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.
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:115
MonitorElement * NumberOfTracksVsLS
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
y coordinate
Definition: Vertex.h:105
TH1 * getTH1(void) const
void compare(std::vector< std::string > const &old_files, std::string const &old_process, std::vector< std::string > const &new_files, std::string const &new_process, unsigned int max_events, bool ignore_prescales, int verbose, int quiet)
Definition: hltDiff.cc:497
bool runTrackBuildingAnalyzerForSeed
bool isValid() const
Definition: HandleBase.h:75
std::vector< MonitorElement * > SeedsVsClusters
MonitorElement * NumberOfRecHitsPerTrackVsLS
virtual void endRun(const edm::Run &, const edm::EventSetup &)
double ndof() const
Definition: Vertex.h:95
std::string histname
std::vector< VertexMonitor * > theVertexMonitor
MonitorElement * NumberOfTracksVsBXlumi
edm::InputTag stripClusterInputTag_
bool doGeneralPropertiesPlots_
tuple trackCollection
TrackBuildingAnalyzer * theTrackBuildingAnalyzer
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
bool isFake() const
Definition: Vertex.h:64
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< reco::TrackCollection > trackToken_
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_
edm::InputTag pixelClusterInputTag_
std::string const & label() const
Definition: InputTag.h:36
MonitorElement * NumberOfSeeds_lumiFlag
edm::EventID id() const
Definition: EventBase.h:59
TrackingMonitor(const edm::ParameterSet &)
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
virtual void beginJob(void)
MonitorElement * NumberOfTrackCandidates
virtual void initHisto(DQMStore::IBooker &ibooker, const edm::EventSetup &)
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.
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
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:34
edm::EDGetTokenT< reco::VertexCollection > pvSrcToken_
Definition: Run.h:43
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &eSetup)
std::vector< std::string > ClusterLabels
std::string builderName