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  * $Date: 2012/10/16 10:07:41 $
5  * $Revision: 1.16 $
6  * \author Suchandra Dutta , Giorgia Mila
7  */
8 
18 
26 
29 
39 
42 
44 
45 #include <string>
46 
47 // TrackingMonitor
48 // ----------------------------------------------------------------------------------//
49 
51  : dqmStore_( edm::Service<DQMStore>().operator->() )
52  , conf_ ( iConfig )
53  , theTrackAnalyzer( new TrackAnalyzer(conf_) )
54  , theTrackBuildingAnalyzer( new TrackBuildingAnalyzer(conf_) )
55  , NumberOfTracks(NULL)
56  , NumberOfMeanRecHitsPerTrack(NULL)
57  , NumberOfMeanLayersPerTrack(NULL)
58  , NumberOfGoodTracks(NULL)
59  , FractionOfGoodTracks(NULL)
60  , NumberOfSeeds(NULL)
61  , NumberOfTrackCandidates(NULL)
62  // ADD by Mia
63  /*
64  , NumberOfPixelClus(NULL)
65  , NumberOfStripClus(NULL)
66  , RatioOfPixelAndStripClus(NULL)
67  , NumberOfTrkVsClus(NULL)
68  , NumberOfTrkVsStripClus(NULL)
69  , NumberOfTrkVsPixelClus(NULL)
70  */
71  , NumberOfGoodTrkVsClus(NULL)
72  , NumberOfTracksVsLS(NULL)
73  , NumberOfGoodTracksVsLS(NULL)
74  , GoodTracksFractionVsLS(NULL)
75  , GoodTracksNumberOfRecHitsPerTrackVsLS(NULL)
76  // ADD by Mia for PU monitoring
77  // vertex plots to be moved in ad hoc class
78  , NumberOfTracksVsGoodPVtx(NULL)
79  , NumberOfTracksVsBXlumi(NULL)
80  , NumberOfGoodTracksVsGoodPVtx(NULL)
81  , NumberOfGoodTracksVsBXlumi(NULL)
82  , FractionOfGoodTracksVsGoodPVtx(NULL)
83  , FractionOfGoodTracksVsBXlumi(NULL)
84  // ADD by Mia in order to deal with LS transitions
85  , NumberOfTracks_lumiFlag(NULL)
86  , NumberOfGoodTracks_lumiFlag(NULL)
87 
88  , builderName ( conf_.getParameter<std::string>("TTRHBuilder"))
89  , doTrackerSpecific_ ( conf_.getParameter<bool>("doTrackerSpecific") )
90  , doLumiAnalysis ( conf_.getParameter<bool>("doLumiAnalysis"))
91  , doProfilesVsLS_ ( conf_.getParameter<bool>("doProfilesVsLS"))
92  , doAllPlots ( conf_.getParameter<bool>("doAllPlots"))
93  , doGeneralPropertiesPlots_( conf_.getParameter<bool>("doGeneralPropertiesPlots"))
94  , doHitPropertiesPlots_ ( conf_.getParameter<bool>("doHitPropertiesPlots"))
95  , doGoodTrackPlots_ ( conf_.getParameter<bool>("doGoodTrackPlots") )
96  , doPUmonitoring_ ( conf_.getParameter<bool>("doPUmonitoring") )
97  , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig))
98 {
99 
100  if ( doPUmonitoring_ ) {
101 
102  // get flag from the configuration
103  doPlotsVsBXlumi_ = conf_.getParameter<bool>("doPlotsVsBXlumi");
104  doPlotsVsGoodPVtx_ = conf_.getParameter<bool>("doPlotsVsGoodPVtx");
105 
106  if ( doPlotsVsBXlumi_ )
107  theLumiDetails_ = new GetLumi( iConfig.getParameter<edm::ParameterSet>("BXlumiSetup") );
108 
109  std::vector<edm::InputTag> primaryVertexInputTags = conf_.getParameter<std::vector<edm::InputTag> >("primaryVertexInputTags");
110  std::vector<edm::InputTag> selPrimaryVertexInputTags = conf_.getParameter<std::vector<edm::InputTag> >("selPrimaryVertexInputTags");
111  std::vector<std::string> pvLabels = conf_.getParameter<std::vector<std::string> > ("pvLabels");
112 
113  if (primaryVertexInputTags.size()==pvLabels.size() and primaryVertexInputTags.size()==selPrimaryVertexInputTags.size()) {
114  for (size_t i=0; i<primaryVertexInputTags.size(); i++) {
115  edm::InputTag iPVinputTag = primaryVertexInputTags[i];
116  edm::InputTag iSelPVinputTag = selPrimaryVertexInputTags[i];
117  std::string iPVlabel = pvLabels[i];
118 
119  theVertexMonitor.push_back(new VertexMonitor(conf_,iPVinputTag,iSelPVinputTag,iPVlabel));
120  }
121  }
122  }
123 
124 }
125 
126 
128 {
131  if ( doPUmonitoring_ )
132  for (size_t i=0; i<theVertexMonitor.size(); i++)
133  if (theVertexMonitor[i]) delete theVertexMonitor[i];
135 }
136 
137 
139 {
140 
141  // parameters from the configuration
142  std::string Quality = conf_.getParameter<std::string>("Quality");
143  std::string AlgoName = conf_.getParameter<std::string>("AlgoName");
144  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
145 
146  // test for the Quality veriable validity
147  if( Quality != "")
148  {
149  if( Quality != "highPurity" && Quality != "tight" && Quality != "loose")
150  {
151  edm::LogWarning("TrackingMonitor") << "Qualty Name is invalid, using no quality criterea by default";
152  Quality = "";
153  }
154  }
155 
156  // use the AlgoName and Quality Name
157  std::string CategoryName = Quality != "" ? AlgoName + "_" + Quality : AlgoName;
158 
159  // get binning from the configuration
160  int TKNoBin = conf_.getParameter<int>( "TkSizeBin");
161  double TKNoMin = conf_.getParameter<double>("TkSizeMin");
162  double TKNoMax = conf_.getParameter<double>("TkSizeMax");
163 
164  int TCNoBin = conf_.getParameter<int>( "TCSizeBin");
165  double TCNoMin = conf_.getParameter<double>("TCSizeMin");
166  double TCNoMax = conf_.getParameter<double>("TCSizeMax");
167 
168  int TKNoSeedBin = conf_.getParameter<int>( "TkSeedSizeBin");
169  double TKNoSeedMin = conf_.getParameter<double>("TkSeedSizeMin");
170  double TKNoSeedMax = conf_.getParameter<double>("TkSeedSizeMax");
171 
172  int MeanHitBin = conf_.getParameter<int>( "MeanHitBin");
173  double MeanHitMin = conf_.getParameter<double>("MeanHitMin");
174  double MeanHitMax = conf_.getParameter<double>("MeanHitMax");
175 
176  int MeanLayBin = conf_.getParameter<int>( "MeanLayBin");
177  double MeanLayMin = conf_.getParameter<double>("MeanLayMin");
178  double MeanLayMax = conf_.getParameter<double>("MeanLayMax");
179 
180  int LSBin = conf_.getParameter<int>( "LSBin");
181  int LSMin = conf_.getParameter<double>("LSMin");
182  int LSMax = conf_.getParameter<double>("LSMax");
183 
184  std::string StateName = conf_.getParameter<std::string>("MeasurementState");
185  if
186  (
187  StateName != "OuterSurface" &&
188  StateName != "InnerSurface" &&
189  StateName != "ImpactPoint" &&
190  StateName != "default" &&
191  StateName != "All"
192  )
193  {
194  // print warning
195  edm::LogWarning("TrackingMonitor") << "State Name is invalid, using 'ImpactPoint' by default";
196  }
197 
198  dqmStore_->setCurrentFolder(MEFolderName);
199 
200  // book the General Property histograms
201  // ---------------------------------------------------------------------------------//
202 
204 
205  dqmStore_->setCurrentFolder(MEFolderName+"/GeneralProperties");
206 
207  histname = "NumberOfTracks_" + CategoryName;
208  // MODIFY by Mia in order to cope w/ high multiplicity
209  // NumberOfTracks = dqmStore_->book1D(histname, histname, TKNoBin, TKNoMin, TKNoMax);
210  NumberOfTracks = dqmStore_->book1D(histname, histname, 3*TKNoBin, TKNoMin, (TKNoMax+0.5)*3.-0.5);
211  NumberOfTracks->setAxisTitle("Number of Tracks per Event", 1);
212  NumberOfTracks->setAxisTitle("Number of Events", 2);
213 
214  histname = "NumberOfMeanRecHitsPerTrack_" + CategoryName;
215  NumberOfMeanRecHitsPerTrack = dqmStore_->book1D(histname, histname, MeanHitBin, MeanHitMin, MeanHitMax);
216  NumberOfMeanRecHitsPerTrack->setAxisTitle("Mean number of found RecHits per Track", 1);
218 
219  histname = "NumberOfMeanLayersPerTrack_" + CategoryName;
220  NumberOfMeanLayersPerTrack = dqmStore_->book1D(histname, histname, MeanLayBin, MeanLayMin, MeanLayMax);
221  NumberOfMeanLayersPerTrack->setAxisTitle("Mean number of Layers per Track", 1);
223 
224  dqmStore_->setCurrentFolder(MEFolderName+"/GeneralProperties/GoodTracks");
225 
226  histname = "NumberOfGoodTracks_" + CategoryName;
227  NumberOfGoodTracks = dqmStore_->book1D(histname, histname, TKNoBin, TKNoMin, TKNoMax);
228  NumberOfGoodTracks->setAxisTitle("Number of Good Tracks per Event", 1);
229  NumberOfGoodTracks->setAxisTitle("Number of Events", 2);
230 
231  histname = "FractionOfGoodTracks_" + CategoryName;
232  FractionOfGoodTracks = dqmStore_->book1D(histname, histname, 101, -0.005, 1.005);
233  FractionOfGoodTracks->setAxisTitle("Fraction of High Purity Tracks (Tracks with Pt>1GeV)", 1);
234  FractionOfGoodTracks->setAxisTitle("Entries", 2);
235  }
236 
237  if ( doLumiAnalysis ) {
238  // add by Mia in order to deal with LS transitions
239  dqmStore_->setCurrentFolder(MEFolderName+"/LSanalysis");
240 
241  histname = "NumberOfTracks_lumiFlag_" + CategoryName;
242  NumberOfTracks_lumiFlag = dqmStore_->book1D(histname, histname, 3*TKNoBin, TKNoMin, (TKNoMax+0.5)*3.-0.5);
243  NumberOfTracks_lumiFlag->setAxisTitle("Number of Tracks per Event", 1);
244  NumberOfTracks_lumiFlag->setAxisTitle("Number of Events", 2);
245 
246  if ( doGoodTrackPlots_ ) {
247  histname = "NumberOfGoodTracks_lumiFlag_" + CategoryName;
248  NumberOfGoodTracks_lumiFlag = dqmStore_->book1D(histname, histname, TKNoBin, TKNoMin, TKNoMax);
249  NumberOfGoodTracks_lumiFlag->setAxisTitle("Number of Good Tracks per Event", 1);
250  NumberOfGoodTracks_lumiFlag->setAxisTitle("Number of Events", 2);
251  }
252 
253  }
254 
255  // book profile plots vs LS :
256  //---------------------------
257 
258 
259  if ( doProfilesVsLS_ || doAllPlots) {
260 
261  dqmStore_->setCurrentFolder(MEFolderName+"/GeneralProperties");
262 
263  histname = "NumberOfTracksVsLS_"+ CategoryName;
264  NumberOfTracksVsLS = dqmStore_->bookProfile(histname,histname, LSBin,LSMin,LSMax, TKNoMin, (TKNoMax+0.5)*3.-0.5,"");
265  NumberOfTracksVsLS->getTH1()->SetBit(TH1::kCanRebin);
266  NumberOfTracksVsLS->setAxisTitle("#Lumi section",1);
267  NumberOfTracksVsLS->setAxisTitle("Number of Tracks",2);
268 
269  if (doGoodTrackPlots_ || doAllPlots ){
270  dqmStore_->setCurrentFolder(MEFolderName+"/GeneralProperties/GoodTracks");
271 
272  histname = "NumberOfGoodTracksVsLS_"+ CategoryName;
273  NumberOfGoodTracksVsLS = dqmStore_->bookProfile(histname,histname, LSBin,LSMin,LSMax, TKNoMin, TKNoMax,"");
274  NumberOfGoodTracksVsLS->getTH1()->SetBit(TH1::kCanRebin);
275  NumberOfGoodTracksVsLS->setAxisTitle("#Lumi section",1);
276  NumberOfGoodTracksVsLS->setAxisTitle("Number of Good Tracks",2);
277 
278  histname = "GoodTracksFractionVsLS_"+ CategoryName;
279  GoodTracksFractionVsLS = dqmStore_->bookProfile(histname,histname, LSBin,LSMin,LSMax,0,1.1,"");
280  GoodTracksFractionVsLS->getTH1()->SetBit(TH1::kCanRebin);
281  GoodTracksFractionVsLS->setAxisTitle("#Lumi section",1);
282  GoodTracksFractionVsLS->setAxisTitle("Fraction of Good Tracks",2);
283 
284  histname = "GoodTracksNumberOfRecHitsPerTrackVsLS_" + CategoryName;
286  GoodTracksNumberOfRecHitsPerTrackVsLS->getTH1()->SetBit(TH1::kCanRebin);
288  GoodTracksNumberOfRecHitsPerTrackVsLS->setAxisTitle("Mean number of RecHits per Good track",2);
289  }
290  }
291 
292  // book PU monitoring plots :
293  //---------------------------
294 
295  if ( doPUmonitoring_ ) {
296 
297  for (size_t i=0; i<theVertexMonitor.size(); i++)
299 
300  dqmStore_->setCurrentFolder(MEFolderName+"/PUmonitoring");
301 
302  if ( doPlotsVsGoodPVtx_ ) {
303  // get binning from the configuration
304  int GoodPVtxBin = conf_.getParameter<int>("GoodPVtxBin");
305  double GoodPVtxMin = conf_.getParameter<double>("GoodPVtxMin");
306  double GoodPVtxMax = conf_.getParameter<double>("GoodPVtxMax");
307 
308  histname = "NumberOfTracksVsGoodPVtx";
309  NumberOfTracksVsGoodPVtx = dqmStore_->bookProfile(histname,histname,GoodPVtxBin,GoodPVtxMin,GoodPVtxMax,TKNoMin, (TKNoMax+0.5)*3.-0.5,"");
310  NumberOfTracksVsGoodPVtx->getTH1()->SetBit(TH1::kCanRebin);
311  NumberOfTracksVsGoodPVtx->setAxisTitle("Number of PV",1);
312  NumberOfTracksVsGoodPVtx->setAxisTitle("Mean number of Tracks per Event",2);
313 
314  histname = "NumberOfGoodTracksVsGoodPVtx";
315  NumberOfGoodTracksVsGoodPVtx = dqmStore_->bookProfile(histname,histname,GoodPVtxBin,GoodPVtxMin,GoodPVtxMax, TKNoMin, TKNoMax,"");
316  NumberOfGoodTracksVsGoodPVtx->getTH1()->SetBit(TH1::kCanRebin);
317  NumberOfGoodTracksVsGoodPVtx->setAxisTitle("Number of PV",1);
318  NumberOfGoodTracksVsGoodPVtx->setAxisTitle("Mean number of Good Tracks per Event",2);
319 
320  histname = "FractionOfGoodTracksVsGoodPVtx";
321  FractionOfGoodTracksVsGoodPVtx = dqmStore_->bookProfile(histname,histname,GoodPVtxBin,GoodPVtxMin,GoodPVtxMax, TKNoMin, TKNoMax,"");
322  FractionOfGoodTracksVsGoodPVtx->getTH1()->SetBit(TH1::kCanRebin);
323  FractionOfGoodTracksVsGoodPVtx->setAxisTitle("Number of PV",1);
324  FractionOfGoodTracksVsGoodPVtx->setAxisTitle("Mean fraction of Good Tracks per Event",2);
325  }
326 
327  if ( doPlotsVsBXlumi_ ) {
328  // get binning from the configuration
329  edm::ParameterSet BXlumiParameters = conf_.getParameter<edm::ParameterSet>("BXlumiSetup");
330  int BXlumiBin = BXlumiParameters.getParameter<int>("BXlumiBin");
331  double BXlumiMin = BXlumiParameters.getParameter<double>("BXlumiMin");
332  double BXlumiMax = BXlumiParameters.getParameter<double>("BXlumiMax");
333 
334  histname = "NumberOfTracksVsBXlumi_"+ CategoryName;
335  NumberOfTracksVsBXlumi = dqmStore_->bookProfile(histname,histname, BXlumiBin,BXlumiMin,BXlumiMax, TKNoMin, TKNoMax,"");
336  NumberOfTracksVsBXlumi->getTH1()->SetBit(TH1::kCanRebin);
337  NumberOfTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]",1);
338  NumberOfTracksVsBXlumi->setAxisTitle("Mean number of Good Tracks",2);
339 
340  histname = "NumberOfGoodTracksVsBXlumi_"+ CategoryName;
341  NumberOfGoodTracksVsBXlumi = dqmStore_->bookProfile(histname,histname, BXlumiBin,BXlumiMin,BXlumiMax, TKNoMin, TKNoMax,"");
342  NumberOfGoodTracksVsBXlumi->getTH1()->SetBit(TH1::kCanRebin);
343  NumberOfGoodTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]",1);
344  NumberOfGoodTracksVsBXlumi->setAxisTitle("Mean number of Good Tracks",2);
345 
346  histname = "FractionOfGoodTracksVsBXlumi_"+ CategoryName;
347  FractionOfGoodTracksVsBXlumi = dqmStore_->bookProfile(histname,histname, BXlumiBin,BXlumiMin,BXlumiMax, TKNoMin, TKNoMax,"");
348  FractionOfGoodTracksVsBXlumi->getTH1()->SetBit(TH1::kCanRebin);
349  FractionOfGoodTracksVsBXlumi->setAxisTitle("lumi BX [10^{30}Hzcm^{-2}]",1);
350  FractionOfGoodTracksVsBXlumi->setAxisTitle("Mean fraction of Good Tracks",2);
351 
352  }
353  }
354 
356 
357  // book the Seed Property histograms
358  // ---------------------------------------------------------------------------------//
359 
360  dqmStore_->setCurrentFolder(MEFolderName+"/TrackBuilding");
361 
362  doAllSeedPlots=conf_.getParameter<bool>("doSeedParameterHistos");
363  doSeedNumberPlot=conf_.getParameter<bool>("doSeedNumberHisto");
364  doSeedVsClusterPlot=conf_.getParameter<bool>("doSeedVsClusterHisto");
365  // if (doAllPlots) doAllSeedPlots=true;
366 
367  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"));
368 
369  edm::InputTag seedProducer = conf_.getParameter<edm::InputTag>("SeedProducer");
370 
371  if (doAllSeedPlots || doSeedNumberPlot){
372  histname = "NumberOfSeeds_"+ seedProducer.label() + "_"+ CategoryName;
373  NumberOfSeeds = dqmStore_->book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
374  NumberOfSeeds->setAxisTitle("Number of Seeds per Event", 1);
375  NumberOfSeeds->setAxisTitle("Number of Events", 2);
376  }
377 
378  if (doAllSeedPlots || doSeedVsClusterPlot){
379 
380  ClusterLabels= conf_.getParameter<std::vector<std::string> >("ClusterLabels");
381 
382  std::vector<double> histoMin,histoMax;
383  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
384 
385  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
386  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
387  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
388 
389  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
390  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
391  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
392 
393  setMaxMinBin(histoMin,histoMax,histoBin,NClusStrMin,NClusStrMax,NClusStrBin,NClusPxMin,NClusPxMax,NClusPxBin);
394 
395  for (uint i=0; i<ClusterLabels.size(); i++){
396  histname = "SeedsVsClusters_" + seedProducer.label() + "_Vs_" + ClusterLabels[i] + "_" + CategoryName;
397  SeedsVsClusters.push_back(dynamic_cast<MonitorElement*>(dqmStore_->book2D(histname, histname, histoBin[i], histoMin[i], histoMax[i],
398  TKNoSeedBin, TKNoSeedMin, TKNoSeedMax)));
399  SeedsVsClusters[i]->setAxisTitle("Number of Clusters", 1);
400  SeedsVsClusters[i]->setAxisTitle("Number of Seeds", 2);
401  }
402  }
403 
404 
405  doTkCandPlots=conf_.getParameter<bool>("doTrackCandHistos");
406  // if (doAllPlots) doTkCandPlots=true;
407 
408  if (doTkCandPlots){
409 
410  edm::InputTag tcProducer = conf_.getParameter<edm::InputTag>("TCProducer");
411 
412  histname = "NumberOfTrackCandidates_"+ tcProducer.label() + "_"+ CategoryName;
413  NumberOfTrackCandidates = dqmStore_->book1D(histname, histname, TCNoBin, TCNoMin, TCNoMax);
414  NumberOfTrackCandidates->setAxisTitle("Number of Track Candidates per Event", 1);
415  NumberOfTrackCandidates->setAxisTitle("Number of Event", 2);
416  }
417 
418 
420 
421 
422  if (doLumiAnalysis) {
423 // if (NumberOfTracks) NumberOfTracks->setLumiFlag();
424 // if (NumberOfGoodTracks) NumberOfGoodTracks->setLumiFlag();
425 // if (FractionOfGoodTracks) FractionOfGoodTracks->setLumiFlag();
426  if ( NumberOfTracks_lumiFlag ) NumberOfTracks_lumiFlag -> setLumiFlag();
429  }
430 
432 
433  ClusterLabels= conf_.getParameter<std::vector<std::string> >("ClusterLabels");
434 
435  std::vector<double> histoMin,histoMax;
436  std::vector<int> histoBin; //these vectors are for max min and nbins in histograms
437 
438  /*
439  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
440  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
441  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
442 
443  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
444  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
445  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
446  */
447 
448  /*
449  int NClus2DTotBin = conf_.getParameter<int>( "NClus2DTotBin");
450  double NClus2DTotMin = conf_.getParameter<double>("NClus2DTotMin");
451  double NClus2DTotMax = conf_.getParameter<double>("NClus2DTotMax");
452  */
453 
454  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
455  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
456  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
457 
458  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
459  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
460  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
461 
462  int NTrk2DBin = conf_.getParameter<int>( "NTrk2DBin");
463  double NTrk2DMin = conf_.getParameter<double>("NTrk2DMin");
464  double NTrk2DMax = conf_.getParameter<double>("NTrk2DMax");
465 
466  // setMaxMinBin(histoMin,histoMax,histoBin,NClusStrMin,NClusStrMax,NClusStrBin,NClusPxMin,NClusPxMax,NClusPxBin);
467  setMaxMinBin(histoMin,histoMax,histoBin,
468  NClusStrMin,NClusStrMax,NClusStrBin,
469  NClusPxMin, NClusPxMax, NClusPxBin);
470 
471  /*
472  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
473  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
474  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
475 
476  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
477  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
478  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
479  */
480 
481  dqmStore_->setCurrentFolder(MEFolderName+"/HitProperties");
482 
483  for (uint i=0; i<ClusterLabels.size(); i++){
484 
485  dqmStore_->setCurrentFolder(MEFolderName+"/HitProperties");
486  histname = "TracksVs" + ClusterLabels[i] + "Cluster_" + CategoryName;
487  NumberOfTrkVsClusters.push_back(dynamic_cast<MonitorElement*>(dqmStore_->book2D(histname, histname,
488  histoBin[i], histoMin[i], histoMax[i],
489  NTrk2DBin,NTrk2DMin,NTrk2DMax
490  )));
491  std::string title = "Number of " + ClusterLabels[i] + " Clusters";
492  NumberOfTrkVsClusters[i]->setAxisTitle(title, 1);
493  NumberOfTrkVsClusters[i]->setAxisTitle("Number of Seeds", 2);
494 
495  if (doGoodTrackPlots_ || doAllPlots ) {
496 
497  dqmStore_->setCurrentFolder(MEFolderName+"/HitProperties/GoodTracks");
498 
499  if(ClusterLabels[i].compare("Tot")==0){
500  histname = "GoodTracksVs" + ClusterLabels[i] + "Cluster_" + CategoryName;
502  histoBin[i], histoMin[i], histoMax[i],
503  TKNoBin,TKNoMin,TKNoMax
504  );
505  NumberOfGoodTrkVsClus->setAxisTitle("# of Clusters in (Pixel+Strip) Detectors", 1);
506  NumberOfGoodTrkVsClus->setAxisTitle("Number of Good Tracks", 2);
507  }
508  }
509  }
510 
511  /*
512  histname = "TracksVsClusters_" + CategoryName;
513  NumberOfTrkVsClus = dqmStore_->book2D(histname,histname,
514  NClus2DTotBin,NClus2DTotMin,NClus2DTotMax,
515  NTrk2DBin,NTrk2DMin,NTrk2DMax
516  );
517  NumberOfTrkVsClus->setAxisTitle("# of Clusters in (Pixel+Strip) Detectors", 1);
518  NumberOfTrkVsClus->setAxisTitle("Number of Tracks", 2);
519  */
520  }
521 
522 
523 }
524 
525 // -- BeginRun
526 //---------------------------------------------------------------------------------//
527 void TrackingMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
528 {
529 
530  // Initialize the GenericTriggerEventFlag
531  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
532 }
533 
534 // - BeginLumi
535 // ---------------------------------------------------------------------------------//
537 
538  if (doLumiAnalysis) {
539 // dqmStore_->softReset(NumberOfTracks);
540 // dqmStore_->softReset(NumberOfGoodTracks);
541 // dqmStore_->softReset(FractionOfGoodTracks);
542 // theTrackAnalyzer->doSoftReset(dqmStore_);
544  if ( doGoodTrackPlots_ )
547  }
548 }
549 
550 // -- Analyse
551 // ---------------------------------------------------------------------------------//
553 {
554  // Filter out events if Trigger Filtering is requested
555  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
556 
557  // input tags for collections from the configuration
558  edm::InputTag trackProducer = conf_.getParameter<edm::InputTag>("TrackProducer");
559  edm::InputTag seedProducer = conf_.getParameter<edm::InputTag>("SeedProducer");
560  edm::InputTag tcProducer = conf_.getParameter<edm::InputTag>("TCProducer");
562  edm::InputTag pvSrc_ = conf_.getParameter<edm::InputTag>("primaryVertex");
563  std::string Quality = conf_.getParameter<std::string>("Quality");
564  std::string Algo = conf_.getParameter<std::string>("AlgoName");
565 
566  // Analyse the tracks
567  // if the collection is empty, do not fill anything
568  // ---------------------------------------------------------------------------------//
569 
570  // get the track collection
572  iEvent.getByLabel(trackProducer, trackHandle);
573 
574  if (trackHandle.isValid())
575  {
576 
577  reco::TrackCollection trackCollection = *trackHandle;
578  // calculate the mean # rechits and layers
579  int totalNumTracks = 0, totalRecHits = 0, totalLayers = 0;
580  int totalNumHPTracks = 0, totalNumPt1Tracks = 0, totalNumHPPt1Tracks = 0;
581  double frac = 0.;
582  for (reco::TrackCollection::const_iterator track = trackCollection.begin(); track!=trackCollection.end(); ++track)
583  {
584 
585  if( track->quality(reco::TrackBase::highPurity) ) {
586  ++totalNumHPTracks;
587  if ( track->pt() >= 1. ) {
588  ++totalNumHPPt1Tracks;
589  if ( doProfilesVsLS_ || doAllPlots)
590  if ( doGoodTrackPlots_ || doAllPlots ) {
591  GoodTracksNumberOfRecHitsPerTrackVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),track->recHitsSize());
592  }
593  }
594  }
595 
596  if ( track->pt() >= 1. ) ++totalNumPt1Tracks;
597 
598 
599  if( Quality == "highPurity")
600  {
601  if( !track->quality(reco::TrackBase::highPurity) ) continue;
602  }
603  else if( Quality == "tight")
604  {
605  if( !track->quality(reco::TrackBase::tight) ) continue;
606  }
607  else if( Quality == "loose")
608  {
609  if( !track->quality(reco::TrackBase::loose) ) continue;
610  }
611 
612  totalNumTracks++;
613  totalRecHits += track->numberOfValidHits();
614  totalLayers += track->hitPattern().trackerLayersWithMeasurement();
615 
616  // do analysis per track
617  theTrackAnalyzer->analyze(iEvent, iSetup, *track);
618  }
619 
620  if (totalNumPt1Tracks > 0) frac = static_cast<double>(totalNumHPPt1Tracks)/static_cast<double>(totalNumPt1Tracks);
621 
623  NumberOfTracks -> Fill(totalNumTracks);
624  NumberOfGoodTracks -> Fill(totalNumHPPt1Tracks);
625  FractionOfGoodTracks -> Fill(frac);
626  }
627 
628  if ( doProfilesVsLS_ || doAllPlots) {
629  NumberOfTracksVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),totalNumTracks);
630  if ( doGoodTrackPlots_ || doAllPlots ) {
631  NumberOfGoodTracksVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),totalNumHPPt1Tracks);
632  GoodTracksFractionVsLS->Fill(static_cast<double>(iEvent.id().luminosityBlock()),frac);
633  }
634  }
635 
636  if ( doLumiAnalysis ) {
637  NumberOfTracks_lumiFlag -> Fill(totalNumTracks);
638  if ( doGoodTrackPlots_ )
639  NumberOfGoodTracks_lumiFlag -> Fill(totalNumHPPt1Tracks);
640  }
641 
643  if( totalNumTracks > 0 )
644  {
645  double meanRecHits = static_cast<double>(totalRecHits) / static_cast<double>(totalNumTracks);
646  double meanLayers = static_cast<double>(totalLayers) / static_cast<double>(totalNumTracks);
647  NumberOfMeanRecHitsPerTrack -> Fill(meanRecHits);
648  NumberOfMeanLayersPerTrack -> Fill(meanLayers);
649  }
650  }
651 
652  // Analyse the Track Building variables
653  // if the collection is empty, do not fill anything
654  // ---------------------------------------------------------------------------------//
655 
656 
657  // fill the TrackCandidate info
658  if (doTkCandPlots)
659  {
660 
661  // magnetic field
663  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
664 
665  // get the beam spot
666  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
667  iEvent.getByLabel(bsSrc,recoBeamSpotHandle);
668  const reco::BeamSpot& bs = *recoBeamSpotHandle;
669 
670  // get the candidate collection
672  iEvent.getByLabel(tcProducer, theTCHandle );
673  const TrackCandidateCollection& theTCCollection = *theTCHandle;
674 
675  if (theTCHandle.isValid())
676  {
677  NumberOfTrackCandidates->Fill(theTCCollection.size());
679  for( TrackCandidateCollection::const_iterator cand = theTCCollection.begin(); cand != theTCCollection.end(); ++cand)
680  {
681  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *cand, bs, theMF, theTTRHBuilder);
682  }
683  }
684  else
685  {
686  edm::LogWarning("TrackingMonitor") << "No Track Candidates in the event. Not filling associated histograms";
687  }
688  }
689 
690  //plots for trajectory seeds
691 
693 
694  // get the seed collection
696  iEvent.getByLabel(seedProducer, seedHandle);
697  const edm::View<TrajectorySeed>& seedCollection = *seedHandle;
698 
699  // fill the seed info
700  if (seedHandle.isValid())
701  {
702  if(doAllSeedPlots || doSeedNumberPlot) NumberOfSeeds->Fill(seedCollection.size());
703 
705 
706  std::vector<int> NClus;
707  setNclus(iEvent,NClus);
708  for (uint i=0; i< ClusterLabels.size(); i++){
709  SeedsVsClusters[i]->Fill(NClus[i],seedCollection.size());
710  }
711  }
712 
714 
715  //here duplication of mag field and be informations is needed to allow seed and track cand histos to be independent
716  // magnetic field
718  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
719 
720  // get the beam spot
721  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
722  iEvent.getByLabel(bsSrc,recoBeamSpotHandle);
723  const reco::BeamSpot& bs = *recoBeamSpotHandle;
724 
726  for(size_t i=0; i < seedHandle->size(); ++i)
727  {
728  edm::RefToBase<TrajectorySeed> seed(seedHandle, i);
729  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *seed, bs, theMF, theTTRHBuilder);
730  }
731  }
732 
733  }
734  else
735  {
736  edm::LogWarning("TrackingMonitor") << "No Trajectory seeds in the event. Not filling associated histograms";
737  }
738  }
739 
740 
742  {
743  std::vector<int> NClus;
744  setNclus(iEvent,NClus);
745  for (uint i=0; i< ClusterLabels.size(); i++){
746  NumberOfTrkVsClusters[i]->Fill(NClus[i],totalNumTracks);
747  }
748  if ( doGoodTrackPlots_ || doAllPlots ) {
749  for (uint i=0; i< ClusterLabels.size(); i++){
750  if(ClusterLabels[i].compare("Tot")==0){
751  NumberOfGoodTrkVsClus->Fill( NClus[i],totalNumHPPt1Tracks);
752  }
753  }
754  }
755 
756  /*
757  edm::Handle< edmNew::DetSetVector<SiStripCluster> > strip_clusters;
758  iEvent.getByLabel("siStripClusters", strip_clusters);
759  edm::Handle< edmNew::DetSetVector<SiPixelCluster> > pixel_clusters;
760  iEvent.getByLabel("siPixelClusters", pixel_clusters);
761  if (strip_clusters.isValid() && pixel_clusters.isValid())
762  {
763  unsigned int ncluster_pix = (*pixel_clusters).dataSize();
764  unsigned int ncluster_strip = (*strip_clusters).dataSize();
765  double ratio = 0.0;
766  if ( ncluster_pix > 0) ratio = atan(ncluster_pix*1.0/ncluster_strip);
767 
768  NumberOfStripClus->Fill(ncluster_strip);
769  NumberOfPixelClus->Fill(ncluster_pix);
770  RatioOfPixelAndStripClus->Fill(ratio);
771 
772  NumberOfTrkVsClus->Fill( ncluster_strip+ncluster_pix,totalNumTracks);
773 
774  if (doGoodTrackPlots_) {
775  NumberOfGoodTrkVsClus->Fill( ncluster_strip+ncluster_pix,totalNumHPPt1Tracks);
776  }
777  }
778  */
779  }
780 
781  if ( doPUmonitoring_ ) {
782 
783  // do vertex monitoring
784  for (size_t i=0; i<theVertexMonitor.size(); i++)
785  theVertexMonitor[i]->analyze(iEvent, iSetup);
786 
787  if ( doPlotsVsGoodPVtx_ ) {
788 
789  edm::InputTag primaryVertexInputTag = conf_.getParameter<edm::InputTag>("primaryVertex");
790 
791  size_t totalNumGoodPV = 0;
793  iEvent.getByLabel(primaryVertexInputTag, pvHandle );
794  if (pvHandle.isValid())
795  {
796 
797  for (reco::VertexCollection::const_iterator pv = pvHandle->begin();
798  pv != pvHandle->end(); ++pv) {
799 
800  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
801  if (pv->isFake() || pv->tracksSize()==0) continue;
802 
803  // definition of goodOfflinePrimaryVertex
804  if (pv->ndof() < 4. || pv->z() > 24.) continue;
805  totalNumGoodPV++;
806  }
807 
808  NumberOfTracksVsGoodPVtx -> Fill( totalNumGoodPV, totalNumTracks );
809  NumberOfGoodTracksVsGoodPVtx -> Fill( totalNumGoodPV, totalNumHPPt1Tracks );
810  FractionOfGoodTracksVsGoodPVtx -> Fill( totalNumGoodPV, frac );
811  }
812  }
813 
814  if ( doPlotsVsBXlumi_ ) {
815 
816  double bxlumi = theLumiDetails_->getValue(iEvent);
817 
818  NumberOfTracksVsBXlumi -> Fill( bxlumi, totalNumTracks );
819  NumberOfGoodTracksVsBXlumi -> Fill( bxlumi, totalNumHPPt1Tracks );
820  FractionOfGoodTracksVsBXlumi -> Fill( bxlumi, frac );
821  }
822 
823  }
824 
825  }
826 
827 }
828 
829 
831 {
832  if (doLumiAnalysis) {
833  /*
834  dqmStore_->disableSoftReset(NumberOfTracks);
835  dqmStore_->disableSoftReset(NumberOfGoodTracks);
836  dqmStore_->disableSoftReset(FractionOfGoodTracks);
837  theTrackAnalyzer->undoSoftReset(dqmStore_);
838  */
839  }
840 
841 }
842 
844 {
845  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
846  std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
847  if(outputMEsInRootFile)
848  {
850  dqmStore_->save(outputFileName);
851  }
852 }
853 
854 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)
855 {
856  arrayMin.resize(ClusterLabels.size());
857  arrayMax.resize(ClusterLabels.size());
858  arrayBin.resize(ClusterLabels.size());
859 
860  for (uint i=0; i<ClusterLabels.size(); ++i){
861 
862  if (ClusterLabels[i].compare("Pix")==0) {arrayMin[i]=pmin; arrayMax[i]=pmax; arrayBin[i]=pbin;}
863  else if(ClusterLabels[i].compare("Strip")==0){arrayMin[i]=smin; arrayMax[i]=smax; arrayBin[i]=sbin;}
864  else if(ClusterLabels[i].compare("Tot")==0){arrayMin[i]=smin; arrayMax[i]=smax+pmax; arrayBin[i]=sbin;}
865  else {edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i] << " not defined, using strip parameters ";
866  arrayMin[i]=smin; arrayMax[i]=smax; arrayBin[i]=sbin;}
867 
868  }
869 
870 }
871 
872 void TrackingMonitor::setNclus(const edm::Event& iEvent,std::vector<int> &arrayNclus)
873 {
874 
875  int ncluster_pix=-1;
876  int ncluster_strip=-1;
877 
879  iEvent.getByLabel("siStripClusters", strip_clusters);
881  iEvent.getByLabel("siPixelClusters", pixel_clusters);
882 
883  if (strip_clusters.isValid() && pixel_clusters.isValid())
884  {
885  ncluster_pix = (*pixel_clusters).dataSize();
886  ncluster_strip = (*strip_clusters).dataSize();
887  }
888 
889  arrayNclus.resize(ClusterLabels.size());
890  for (uint i=0; i<ClusterLabels.size(); ++i){
891 
892  if (ClusterLabels[i].compare("Pix")==0) arrayNclus[i]=ncluster_pix ;
893  else if(ClusterLabels[i].compare("Strip")==0) arrayNclus[i]=ncluster_strip;
894  else if(ClusterLabels[i].compare("Tot")==0)arrayNclus[i]=ncluster_pix+ncluster_strip;
895  else {edm::LogWarning("TrackingMonitor") << "Cluster Label " << ClusterLabels[i] << " not defined using stri parametrs ";
896  arrayNclus[i]=ncluster_strip ;}
897  }
898 
899 }
T getParameter(std::string const &) const
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
MonitorElement * NumberOfGoodTracksVsLS
MonitorElement * FractionOfGoodTracksVsGoodPVtx
edm::ParameterSet conf_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
virtual void setNclus(const edm::Event &, std::vector< int > &)
GetLumi * theLumiDetails_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:35
MonitorElement * NumberOfGoodTracks
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
std::vector< TrackCandidate > TrackCandidateCollection
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
void doReset(DQMStore *dqmStore_)
#define NULL
Definition: scimark2.h:8
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * NumberOfGoodTrkVsClus
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
MonitorElement * NumberOfMeanRecHitsPerTrack
MonitorElement * FractionOfGoodTracksVsBXlumi
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:52
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)
virtual void beginJob(DQMStore *dqmStore_)
MonitorElement * NumberOfSeeds
int iEvent
Definition: GenABIO.cc:243
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual void endJob(void)
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
MonitorElement * NumberOfGoodTracksVsBXlumi
MonitorElement * NumberOfTracksVsLS
TH1 * getTH1(void) const
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1031
bool runTrackBuildingAnalyzerForSeed
bool isValid() const
Definition: HandleBase.h:76
std::vector< MonitorElement * > SeedsVsClusters
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void endRun(const edm::Run &, const edm::EventSetup &)
MonitorElement * NumberOfGoodTracksVsGoodPVtx
std::string histname
edm::InputTag bsSrc
std::vector< VertexMonitor * > theVertexMonitor
virtual void beginJob(DQMStore *dqmStore_)
MonitorElement * NumberOfTracksVsBXlumi
bool doGeneralPropertiesPlots_
TrackBuildingAnalyzer * theTrackBuildingAnalyzer
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Track &track)
MonitorElement * NumberOfMeanLayersPerTrack
const T & get() const
Definition: EventSetup.h:55
size_type size() const
GenericTriggerEventFlag * genTriggerEventFlag_
std::string const & label() const
Definition: InputTag.h:25
edm::EventID id() const
Definition: EventBase.h:56
TrackingMonitor(const edm::ParameterSet &)
MonitorElement * GoodTracksNumberOfRecHitsPerTrackVsLS
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
MonitorElement * NumberOfGoodTracks_lumiFlag
virtual void beginJob(void)
MonitorElement * NumberOfTrackCandidates
void Reset(std::vector< TH2F > &depth)
void showDirStructure(void) const
Definition: DQMStore.cc:2761
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
MonitorElement * NumberOfTracks_lumiFlag
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: fakeMenu.h:4
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * NumberOfTracks
Definition: Run.h:33
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &eSetup)
std::vector< std::string > ClusterLabels
std::string builderName