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: 2010/11/23 19:20:30 $
5  * $Revision: 1.19 $
6  * \author Suchandra Dutta , Giorgia Mila
7  */
8 
18 
25 
28 
38 #include <string>
39 
40 // TrackingMonitor
41 // ----------------------------------------------------------------------------------//
42 
44  : dqmStore_( edm::Service<DQMStore>().operator->() )
45  , conf_ ( iConfig )
46  , theTrackAnalyzer( new TrackAnalyzer(conf_) )
47  , theTrackBuildingAnalyzer( new TrackBuildingAnalyzer(conf_) )
48  , NumberOfTracks(NULL)
49  , NumberOfMeanRecHitsPerTrack(NULL)
50  , NumberOfMeanLayersPerTrack(NULL)
51  , NumberOfGoodTracks(NULL)
52  , FractionOfGoodTracks(NULL)
53  , NumberOfSeeds(NULL)
54  , NumberOfTrackCandidates(NULL)
55  , builderName( conf_.getParameter<std::string>("TTRHBuilder"))
56  , doTrackerSpecific_( conf_.getParameter<bool>("doTrackerSpecific") )
57  , doLumiAnalysis( conf_.getParameter<bool>("doLumiAnalysis"))
58  , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig))
59 {
60 }
61 
62 
64 {
68 }
69 
70 
72 {
73 
74  // parameters from the configuration
75  std::string Quality = conf_.getParameter<std::string>("Quality");
76  std::string AlgoName = conf_.getParameter<std::string>("AlgoName");
77  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
78 
79  // test for the Quality veriable validity
80  if( Quality != "")
81  {
82  if( Quality != "highPurity" && Quality != "tight" && Quality != "loose")
83  {
84  edm::LogWarning("TrackingMonitor") << "Qualty Name is invalid, using no quality criterea by default";
85  Quality = "";
86  }
87  }
88 
89  // use the AlgoName and Quality Name
90  std::string CatagoryName = Quality != "" ? AlgoName + "_" + Quality : AlgoName;
91 
92  // get binning from the configuration
93  int TKNoBin = conf_.getParameter<int>( "TkSizeBin");
94  double TKNoMin = conf_.getParameter<double>("TkSizeMin");
95  double TKNoMax = conf_.getParameter<double>("TkSizeMax");
96 
97  int TCNoBin = conf_.getParameter<int>( "TCSizeBin");
98  double TCNoMin = conf_.getParameter<double>("TCSizeMin");
99  double TCNoMax = conf_.getParameter<double>("TCSizeMax");
100 
101  int TKNoSeedBin = conf_.getParameter<int>( "TkSeedSizeBin");
102  double TKNoSeedMin = conf_.getParameter<double>("TkSeedSizeMin");
103  double TKNoSeedMax = conf_.getParameter<double>("TkSeedSizeMax");
104 
105  int MeanHitBin = conf_.getParameter<int>( "MeanHitBin");
106  double MeanHitMin = conf_.getParameter<double>("MeanHitMin");
107  double MeanHitMax = conf_.getParameter<double>("MeanHitMax");
108 
109  int MeanLayBin = conf_.getParameter<int>( "MeanLayBin");
110  double MeanLayMin = conf_.getParameter<double>("MeanLayMin");
111  double MeanLayMax = conf_.getParameter<double>("MeanLayMax");
112 
113  std::string StateName = conf_.getParameter<std::string>("MeasurementState");
114  if
115  (
116  StateName != "OuterSurface" &&
117  StateName != "InnerSurface" &&
118  StateName != "ImpactPoint" &&
119  StateName != "default" &&
120  StateName != "All"
121  )
122  {
123  // print warning
124  edm::LogWarning("TrackingMonitor") << "State Name is invalid, using 'ImpactPoint' by default";
125  }
126 
127  dqmStore_->setCurrentFolder(MEFolderName);
128 
129  // book the General Property histograms
130  // ---------------------------------------------------------------------------------//
131  dqmStore_->setCurrentFolder(MEFolderName+"/GeneralProperties");
132 
133  histname = "NumberOfTracks_" + CatagoryName;
134  NumberOfTracks = dqmStore_->book1D(histname, histname, TKNoBin, TKNoMin, TKNoMax);
135  NumberOfTracks->setAxisTitle("Number of Tracks per Event", 1);
136  NumberOfTracks->setAxisTitle("Number of Events", 2);
137 
138  histname = "NumberOfMeanRecHitsPerTrack_" + CatagoryName;
139  NumberOfMeanRecHitsPerTrack = dqmStore_->book1D(histname, histname, MeanHitBin, MeanHitMin, MeanHitMax);
140  NumberOfMeanRecHitsPerTrack->setAxisTitle("Mean number of RecHits per Track", 1);
142 
143  histname = "NumberOfMeanLayersPerTrack_" + CatagoryName;
144  NumberOfMeanLayersPerTrack = dqmStore_->book1D(histname, histname, MeanLayBin, MeanLayMin, MeanLayMax);
145  NumberOfMeanLayersPerTrack->setAxisTitle("Mean number of Layers per Track", 1);
147 
148  histname = "NumberOfGoodTracks_" + CatagoryName;
149  NumberOfGoodTracks = dqmStore_->book1D(histname, histname, TKNoBin, TKNoMin, TKNoMax);
150  NumberOfGoodTracks->setAxisTitle("Number of Good Tracks per Event", 1);
151  NumberOfGoodTracks->setAxisTitle("Number of Events", 2);
152 
153  histname = "FractionOfGoodTracks_" + CatagoryName;
154  FractionOfGoodTracks = dqmStore_->book1D(histname, histname, 101, -0.005, 1.005);
155  FractionOfGoodTracks->setAxisTitle("Fraction of High Purity Tracks (Tracks with Pt>1GeV)", 1);
156  FractionOfGoodTracks->setAxisTitle("Entries", 2);
157 
159 
160  // book the Seed Property histograms
161  // ---------------------------------------------------------------------------------//
162  if (conf_.getParameter<bool>("doSeedParameterHistos"))
163  {
164  dqmStore_->setCurrentFolder(MEFolderName+"/TrackBuilding");
165 
166  histname = "NumberOfSeeds_" + CatagoryName;
167  NumberOfSeeds = dqmStore_->book1D(histname, histname, TKNoSeedBin, TKNoSeedMin, TKNoSeedMax);
168  NumberOfSeeds->setAxisTitle("Number of Seeds per Event", 1);
169  NumberOfSeeds->setAxisTitle("Number of Events", 2);
170 
171  histname = "NumberOfTrackCandidates_" + CatagoryName;
172  NumberOfTrackCandidates = dqmStore_->book1D(histname, histname, TCNoBin, TCNoMin, TCNoMax);
173  NumberOfTrackCandidates->setAxisTitle("Number of Track Candidates per Event", 1);
174  NumberOfTrackCandidates->setAxisTitle("Number of Event", 2);
175 
177  }
178  if (doLumiAnalysis) {
183  }
184  if (doTrackerSpecific_) {
185  int NClusPxBin = conf_.getParameter<int>( "NClusPxBin");
186  double NClusPxMin = conf_.getParameter<double>("NClusPxMin");
187  double NClusPxMax = conf_.getParameter<double>("NClusPxMax");
188 
189 
190  int NClusStrBin = conf_.getParameter<int>( "NClusStrBin");
191  double NClusStrMin = conf_.getParameter<double>("NClusStrMin");
192  double NClusStrMax = conf_.getParameter<double>("NClusStrMax");
193 
194  int NClus2DStrBin = conf_.getParameter<int>( "NClus2DStrBin");
195  double NClus2DStrMin = conf_.getParameter<double>("NClus2DStrMin");
196  double NClus2DStrMax = conf_.getParameter<double>("NClus2DStrMax");
197  int NClus2DPxBin = conf_.getParameter<int>( "NClus2DPxBin");
198  double NClus2DPxMin = conf_.getParameter<double>("NClus2DPxMin");
199  double NClus2DPxMax = conf_.getParameter<double>("NClus2DPxMax");
200 
201  int NClus2DTotBin = conf_.getParameter<int>( "NClus2DTotBin");
202  double NClus2DTotMin = conf_.getParameter<double>("NClus2DTotMin");
203  double NClus2DTotMax = conf_.getParameter<double>("NClus2DTotMax");
204  int NTrk2DBin = conf_.getParameter<int>( "NTrk2DBin");
205  double NTrk2DMin = conf_.getParameter<double>("NTrk2DMin");
206  double NTrk2DMax = conf_.getParameter<double>("NTrk2DMax");
207 
208  dqmStore_->setCurrentFolder(MEFolderName+"/HitProperties");
209  histname = "NumberOfClustersInPixel_" + CatagoryName;
210  NumberOfPixelClus = dqmStore_->book1D(histname, histname, NClusPxBin, NClusPxMin, NClusPxMax);
211  NumberOfPixelClus->setAxisTitle("# of Clusters in Pixel", 1);
212  NumberOfPixelClus->setAxisTitle("Number of Events", 2);
213 
214  histname = "NumberOfClustersInStrip_" + CatagoryName;
215  NumberOfStripClus = dqmStore_->book1D(histname, histname, NClusStrBin, NClusStrMin, NClusStrMax);
216  NumberOfStripClus->setAxisTitle("# of Clusters in Strip Detectors", 1);
217  NumberOfStripClus->setAxisTitle("Number of Events", 2);
218 
219  histname = "PixelClustersVsStripClusters_" + CatagoryName;
220  NumberOfStripVsStripClus = dqmStore_->book2D(histname, histname, NClus2DStrBin, NClus2DStrMin, NClus2DStrMax,
221  NClus2DPxBin, NClus2DPxMin, NClus2DPxMax);
222  NumberOfStripVsStripClus->setAxisTitle("# of Clusters in Strip Detectors", 1);
223  NumberOfStripVsStripClus->setAxisTitle("# of Clusters in Pixel Detectors", 2);
224 
225  histname = "RatioOfPixelAndStripClusters_" + CatagoryName;
227  RatioOfPixelAndStripClus->setAxisTitle("ArcTan(PixelCluster/StripClusters)", 1);
228  RatioOfPixelAndStripClus->setAxisTitle("Number of Events", 2);
229 
230  histname = "TracksVsClusters_" + CatagoryName;
231  NumberOfTrkVsClus = dqmStore_->book2D(histname,histname,NTrk2DBin,NTrk2DMin,NTrk2DMax,
232  NClus2DTotBin,NClus2DTotMin,NClus2DTotMax);
233  NumberOfTrkVsClus->setAxisTitle("Number of Tracks", 1);
234  NumberOfTrkVsClus->setAxisTitle("# of Clusters in (Pixel+Strip) Detectors", 2);
235 
236  }
237 
238 
239 }
240 
241 // -- BeginRun
242 //---------------------------------------------------------------------------------//
243 void TrackingMonitor::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
244 {
245  // Initialize the GenericTriggerEventFlag
246  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
247 }
248 
249 // - BeginLumi
250 // ---------------------------------------------------------------------------------//
252  if (doLumiAnalysis) {
257  }
258 }
259 
260 // -- Analyse
261 // ---------------------------------------------------------------------------------//
263 {
264  // Filter out events if Trigger Filtering is requested
265  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
266 
267  // input tags for collections from the configuration
269  edm::InputTag seedProducer = conf_.getParameter<edm::InputTag>("SeedProducer");
270  edm::InputTag tcProducer = conf_.getParameter<edm::InputTag>("TCProducer");
272  std::string Quality = conf_.getParameter<std::string>("Quality");
273  std::string Algo = conf_.getParameter<std::string>("AlgoName");
274 
275  // Analyse the tracks
276  // if the collection is empty, do not fill anything
277  // ---------------------------------------------------------------------------------//
278 
279  // get the track collection
281  iEvent.getByLabel(trackProducer, trackHandle);
282 
283  if (trackHandle.isValid())
284  {
285 
286  reco::TrackCollection trackCollection = *trackHandle;
287  // calculate the mean # rechits and layers
288  int totalNumTracks = 0, totalRecHits = 0, totalLayers = 0;
289  int totalNumHPTracks = 0, totalNumPt1Tracks = 0, totalNumHPPt1Tracks = 0;
290 
291  for (reco::TrackCollection::const_iterator track = trackCollection.begin(); track!=trackCollection.end(); ++track)
292  {
293 
294  if( track->quality(reco::TrackBase::highPurity) ) {
295  ++totalNumHPTracks;
296  if ( track->pt() >= 1. ) ++totalNumHPPt1Tracks;
297  }
298 
299  if ( track->pt() >= 1. ) ++totalNumPt1Tracks;
300 
301 
302  if( Quality == "highPurity")
303  {
304  if( !track->quality(reco::TrackBase::highPurity) ) continue;
305  }
306  else if( Quality == "tight")
307  {
308  if( !track->quality(reco::TrackBase::tight) ) continue;
309  }
310  else if( Quality == "loose")
311  {
312  if( !track->quality(reco::TrackBase::loose) ) continue;
313  }
314 
315  totalNumTracks++;
316  totalRecHits += track->found();
317  totalLayers += track->hitPattern().trackerLayersWithMeasurement();
318 
319  // do analysis per track
320  theTrackAnalyzer->analyze(iEvent, iSetup, *track);
321  }
322 
323  NumberOfTracks->Fill(totalNumTracks);
324  NumberOfGoodTracks->Fill(totalNumHPPt1Tracks);
325 
326  double frac = 0.;
327  if (totalNumPt1Tracks > 0) frac = static_cast<double>(totalNumHPPt1Tracks)/static_cast<double>(totalNumPt1Tracks);
328  FractionOfGoodTracks->Fill(frac);
329 
330  if( totalNumTracks > 0 )
331  {
332  double meanRecHits = static_cast<double>(totalRecHits) / static_cast<double>(totalNumTracks);
333  double meanLayers = static_cast<double>(totalLayers) / static_cast<double>(totalNumTracks);
334  NumberOfMeanRecHitsPerTrack->Fill(meanRecHits);
335  NumberOfMeanLayersPerTrack->Fill(meanLayers);
336  }
337 
338 
339  // Analyse the Track Building variables
340  // if the collection is empty, do not fill anything
341  // ---------------------------------------------------------------------------------//
342 
343  if (conf_.getParameter<bool>("doSeedParameterHistos"))
344  {
345 
346  // magnetic field
348  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
349 
350  // get the beam spot
351  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
352  iEvent.getByLabel(bsSrc,recoBeamSpotHandle);
353  const reco::BeamSpot& bs = *recoBeamSpotHandle;
354 
355  // get the candidate collection
357  iEvent.getByLabel(tcProducer, theTCHandle );
358  const TrackCandidateCollection& theTCCollection = *theTCHandle;
359 
360  // fill the TrackCandidate info
361  if (theTCHandle.isValid())
362  {
363  NumberOfTrackCandidates->Fill(theTCCollection.size());
365  for( TrackCandidateCollection::const_iterator cand = theTCCollection.begin(); cand != theTCCollection.end(); ++cand)
366  {
367  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *cand, bs, theMF, theTTRHBuilder);
368  }
369  }
370  else
371  {
372  edm::LogWarning("TrackingMonitor") << "No Track Candidates in the event. Not filling associated histograms";
373  }
374 
375  // get the seed collection
377  iEvent.getByLabel(seedProducer, seedHandle);
378  const edm::View<TrajectorySeed>& seedCollection = *seedHandle;
379 
380  // fill the seed info
381  if (seedHandle.isValid())
382  {
383  NumberOfSeeds->Fill(seedCollection.size());
384 
386  for(size_t i=0; i < seedHandle->size(); ++i)
387  {
388  edm::RefToBase<TrajectorySeed> seed(seedHandle, i);
389  theTrackBuildingAnalyzer->analyze(iEvent, iSetup, *seed, bs, theMF, theTTRHBuilder);
390  }
391  }
392  else
393  {
394  edm::LogWarning("TrackingMonitor") << "No Trajectory seeds in the event. Not filling associated histograms";
395  }
396  }
397  if ( doTrackerSpecific_)
398  {
400  iEvent.getByLabel("siStripClusters", strip_clusters);
402  iEvent.getByLabel("siPixelClusters", pixel_clusters);
403  if (strip_clusters.isValid() && pixel_clusters.isValid())
404  {
405  unsigned int ncluster_pix = (*pixel_clusters).dataSize();
406  unsigned int ncluster_strip = (*strip_clusters).dataSize();
407  double ratio = 0.0;
408  if ( ncluster_pix > 0) ratio = atan(ncluster_pix*1.0/ncluster_strip);
409 
410  NumberOfStripClus->Fill(ncluster_strip);
411  NumberOfPixelClus->Fill(ncluster_pix);
412  NumberOfStripVsStripClus->Fill(ncluster_strip,ncluster_pix);
414  NumberOfTrkVsClus->Fill(totalNumTracks, ncluster_strip+ncluster_pix);
415  }
416  }
417 
418  }
419  else
420  {
421  return;
422  }
423 }
425 {
426  if (doLumiAnalysis) {
431  }
432 
433 }
434 
436 {
437  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
438  std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
439  if(outputMEsInRootFile)
440  {
442  dqmStore_->save(outputFileName);
443  }
444 }
445 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * FractionOfGoodTracks
DQMStore * dqmStore_
TrackAnalyzer * theTrackAnalyzer
edm::ParameterSet conf_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:41
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:1883
std::vector< TrackCandidate > TrackCandidateCollection
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
#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 * NumberOfStripVsStripClus
void Fill(long long x)
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:2520
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)
MonitorElement * NumberOfPixelClus
virtual void beginJob(DQMStore *dqmStore_)
MonitorElement * NumberOfSeeds
int iEvent
Definition: GenABIO.cc:243
virtual void endJob(void)
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
void softReset(MonitorElement *me)
Definition: DQMStore.cc:2512
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
virtual void endRun(const edm::Run &, const edm::EventSetup &)
std::string histname
edm::InputTag bsSrc
virtual void beginJob(DQMStore *dqmStore_)
TrackBuildingAnalyzer * theTrackBuildingAnalyzer
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::Track &track)
MonitorElement * NumberOfMeanLayersPerTrack
MonitorElement * NumberOfStripClus
const T & get() const
Definition: EventSetup.h:55
MonitorElement * RatioOfPixelAndStripClus
size_type size() const
GenericTriggerEventFlag * genTriggerEventFlag_
TrackingMonitor(const edm::ParameterSet &)
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
void doSoftReset(DQMStore *dqmStore_)
virtual void beginJob(void)
MonitorElement * NumberOfTrackCandidates
void showDirStructure(void) const
Definition: DQMStore.cc:2539
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginedm::Run() methods.
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
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:647
MonitorElement * NumberOfTrkVsClus
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:237
MonitorElement * NumberOfTracks
Definition: Run.h:31
void undoSoftReset(DQMStore *dqmStore_)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &eSetup)
std::string builderName