CMS 3D CMS Logo

StandaloneTrackMonitor.cc
Go to the documentation of this file.
32 
33 #include "TFile.h"
34 #include "TH1.h"
35 #include "TMath.h"
36 #include "TPRegexp.h"
37 
38 #include <string>
39 #include <vector>
40 #include <map>
41 #include <set>
42 
44 public:
46 
47 protected:
48  void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
49  void processHit(const TrackingRecHit& recHit, edm::EventSetup const& iSetup, double wfac = 1);
50  void processClusters(edm::Event const& iEvent, edm::EventSetup const& iSetup, double wfac = 1);
51  void addClusterToMap(uint32_t detid, const SiStripCluster* cluster);
52  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
53  void dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) override;
54 
55 private:
57 
70 
73  const bool doPUCorrection_;
74  const bool isMC_;
75  const bool haveAllHistograms_;
77  const bool verbose_;
78 
97 
105 
110 
115 
123 
124  // MC only
128 
129  // Exclusive Quantities
139 
144 
149 
150  unsigned long long m_cacheID_;
151 
152  std::vector<float> vpu_;
153  std::map<uint32_t, std::set<const SiStripCluster*> > clusterMap_;
155  const TrackerGeometry* tkGeom_ = nullptr;
156 };
157 
158 // -----------------------------
159 // constructors and destructor
160 // -----------------------------
162  : parameters_(ps),
163  moduleName_(parameters_.getUntrackedParameter<std::string>("moduleName", "StandaloneTrackMonitor")),
164  folderName_(parameters_.getUntrackedParameter<std::string>("folderName", "highPurityTracks")),
165  trackTag_(parameters_.getUntrackedParameter<edm::InputTag>("trackInputTag", edm::InputTag("generalTracks"))),
166  bsTag_(parameters_.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
167  vertexTag_(
168  parameters_.getUntrackedParameter<edm::InputTag>("vertexTag", edm::InputTag("offlinePrimaryVertices"))),
169  puSummaryTag_(parameters_.getUntrackedParameter<edm::InputTag>("puTag", edm::InputTag("addPileupInfo"))),
170  clusterTag_(parameters_.getUntrackedParameter<edm::InputTag>("clusterTag", edm::InputTag("siStripClusters"))),
171  trackToken_(consumes<reco::TrackCollection>(trackTag_)),
172  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
173  vertexToken_(consumes<reco::VertexCollection>(vertexTag_)),
174  puSummaryToken_(consumes<std::vector<PileupSummaryInfo> >(puSummaryTag_)),
175  clusterToken_(consumes<edmNew::DetSetVector<SiStripCluster> >(clusterTag_)),
176  trackQuality_(parameters_.getUntrackedParameter<std::string>("trackQuality", "highPurity")),
177  siStripClusterInfo_(consumesCollector()),
178  doPUCorrection_(parameters_.getUntrackedParameter<bool>("doPUCorrection", false)),
179  isMC_(parameters_.getUntrackedParameter<bool>("isMC", false)),
180  haveAllHistograms_(parameters_.getUntrackedParameter<bool>("haveAllHistograms", false)),
181  puScaleFactorFile_(
182  parameters_.getUntrackedParameter<std::string>("puScaleFactorFile", "PileupScaleFactor_run203002.root")),
183  verbose_(parameters_.getUntrackedParameter<bool>("verbose", false)),
185  trackEtaH_ = nullptr;
186  trackEtaerrH_ = nullptr;
187  trackCosThetaH_ = nullptr;
188  trackThetaerrH_ = nullptr;
189  trackPhiH_ = nullptr;
190  trackPhierrH_ = nullptr;
191  trackPH_ = nullptr;
192  trackPtH_ = nullptr;
193  trackPtUpto2GeVH_ = nullptr;
194  trackPtOver10GeVH_ = nullptr;
195  trackPterrH_ = nullptr;
196  trackqOverpH_ = nullptr;
197  trackqOverperrH_ = nullptr;
198  trackChargeH_ = nullptr;
199  nlostHitsH_ = nullptr;
200  nvalidTrackerHitsH_ = nullptr;
201  nvalidPixelHitsH_ = nullptr;
202  nvalidStripHitsH_ = nullptr;
203  trkLayerwithMeasurementH_ = nullptr;
204  pixelLayerwithMeasurementH_ = nullptr;
205  stripLayerwithMeasurementH_ = nullptr;
206  beamSpotXYposH_ = nullptr;
207  beamSpotXYposerrH_ = nullptr;
208  beamSpotZposH_ = nullptr;
209  beamSpotZposerrH_ = nullptr;
210  trackChi2H_ = nullptr;
211  tracknDOFH_ = nullptr;
212  trackd0H_ = nullptr;
213  trackChi2bynDOFH_ = nullptr;
214  vertexXposH_ = nullptr;
215  vertexYposH_ = nullptr;
216  vertexZposH_ = nullptr;
217 
218  nPixBarrelH_ = nullptr;
219  nPixEndcapH_ = nullptr;
220  nStripTIBH_ = nullptr;
221  nStripTOBH_ = nullptr;
222  nStripTECH_ = nullptr;
223  nStripTIDH_ = nullptr;
224  nTracksH_ = nullptr;
225 
226  // for MC only
227  nVertexH_ = nullptr;
228  bunchCrossingH_ = nullptr;
229  nPUH_ = nullptr;
230  trueNIntH_ = nullptr;
231 
232  nHitsVspTH_ = nullptr;
233  nHitsVsEtaH_ = nullptr;
234  nHitsVsCosThetaH_ = nullptr;
235  nHitsVsPhiH_ = nullptr;
236  nHitsVsnVtxH_ = nullptr;
237  nLostHitsVspTH_ = nullptr;
238  nLostHitsVsEtaH_ = nullptr;
239  nLostHitsVsCosThetaH_ = nullptr;
240  nLostHitsVsPhiH_ = nullptr;
241 
242  hOnTrkClusChargeThinH_ = nullptr;
243  hOnTrkClusWidthThinH_ = nullptr;
244  hOnTrkClusChargeThickH_ = nullptr;
245  hOnTrkClusWidthThickH_ = nullptr;
246 
247  hOffTrkClusChargeThinH_ = nullptr;
248  hOffTrkClusWidthThinH_ = nullptr;
249  hOffTrkClusChargeThickH_ = nullptr;
250  hOffTrkClusWidthThickH_ = nullptr;
251 
252  // Read pileup weight factors
253  if (isMC_ && doPUCorrection_) {
254  vpu_.clear();
255  TFile* f1 = TFile::Open(puScaleFactorFile_.c_str());
256  TH1F* h1 = dynamic_cast<TH1F*>(f1->Get("pileupweight"));
257  for (int i = 1; i <= h1->GetNbinsX(); ++i)
258  vpu_.push_back(h1->GetBinContent(i));
259  f1->Close();
260  }
261 }
262 
264  tkGeom_ = &(iSetup.getData(geomToken_));
265 }
266 
268  edm::Run const& iRun,
269  edm::EventSetup const& iSetup) {
270  edm::ParameterSet TrackEtaHistoPar = parameters_.getParameter<edm::ParameterSet>("trackEtaH");
271  edm::ParameterSet TrackPtHistoPar = parameters_.getParameter<edm::ParameterSet>("trackPtH");
272 
273  std::string currentFolder = moduleName_ + "/" + folderName_;
274  iBook.setCurrentFolder(currentFolder);
275 
276  // The following are common with the official tool
277  if (haveAllHistograms_) {
278  if (!trackEtaH_)
279  trackEtaH_ = iBook.book1D("trackEta",
280  "Track Eta",
281  TrackEtaHistoPar.getParameter<int32_t>("Xbins"),
282  TrackEtaHistoPar.getParameter<double>("Xmin"),
283  TrackEtaHistoPar.getParameter<double>("Xmax"));
284  if (!trackEtaerrH_)
285  trackEtaerrH_ = iBook.book1D("trackEtaerr", "Track Eta Error", 50, 0.0, 1.0);
286  if (!trackCosThetaH_)
287  trackCosThetaH_ = iBook.book1D("trackCosTheta", "Track Cos(Theta)", 50, -1.0, 1.0);
288  if (!trackThetaerrH_)
289  trackThetaerrH_ = iBook.book1D("trackThetaerr", "Track Theta Error", 50, 0.0, 1.0);
290  if (!trackPhiH_)
291  trackPhiH_ = iBook.book1D("trackPhi", "Track Phi", 70, -3.5, 3.5);
292  if (!trackPhierrH_)
293  trackPhierrH_ = iBook.book1D("trackPhierr", "Track Phi Error", 50, 0.0, 1.0);
294 
295  if (!trackPH_)
296  trackPH_ = iBook.book1D("trackP", "Track 4-momentum", 50, 0.0, 10.0);
297  if (!trackPtH_)
298  trackPtH_ = iBook.book1D("trackPt",
299  "Track Pt",
300  TrackPtHistoPar.getParameter<int32_t>("Xbins"),
301  TrackPtHistoPar.getParameter<double>("Xmin"),
302  TrackPtHistoPar.getParameter<double>("Xmax"));
303  if (!trackPtUpto2GeVH_)
304  trackPtUpto2GeVH_ = iBook.book1D("trackPtUpto2GeV", "Track Pt upto 2GeV", 100, 0, 2.0);
305  if (!trackPtOver10GeVH_)
306  trackPtOver10GeVH_ = iBook.book1D("trackPtOver10GeV", "Track Pt greater than 10 GeV", 100, 0, 100.0);
307  if (!trackPterrH_)
308  trackPterrH_ = iBook.book1D("trackPterr", "Track Pt Error", 100, 0.0, 100.0);
309  if (!trackqOverpH_)
310  trackqOverpH_ = iBook.book1D("trackqOverp", "q Over p", 40, -10.0, 10.0);
311  if (!trackqOverperrH_)
312  trackqOverperrH_ = iBook.book1D("trackqOverperr", "q Over p Error", 50, 0.0, 25.0);
313  if (!trackChargeH_)
314  trackChargeH_ = iBook.book1D("trackCharge", "Track Charge", 50, -5, 5);
315  if (!trackChi2H_)
316  trackChi2H_ = iBook.book1D("trackChi2", "Chi2", 100, 0.0, 100.0);
317  if (!tracknDOFH_)
318  tracknDOFH_ = iBook.book1D("tracknDOF", "nDOF", 100, 0.0, 100.0);
319  if (!trackd0H_)
320  trackd0H_ = iBook.book1D("trackd0", "Track d0", 100, -1, 1);
321  if (!trackChi2bynDOFH_)
322  trackChi2bynDOFH_ = iBook.book1D("trackChi2bynDOF", "Chi2 Over nDOF", 100, 0.0, 10.0);
323 
324  if (!nlostHitsH_)
325  nlostHitsH_ = iBook.book1D("nlostHits", "No. of Lost Hits", 10, 0.0, 10.0);
326  if (!nvalidTrackerHitsH_)
327  nvalidTrackerHitsH_ = iBook.book1D("nvalidTrackerhits", "No. of Valid Tracker Hits", 35, 0.0, 35.0);
328  if (!nvalidPixelHitsH_)
329  nvalidPixelHitsH_ = iBook.book1D("nvalidPixelHits", "No. of Valid Hits in Pixel", 10, 0.0, 10.0);
330  if (!nvalidStripHitsH_)
331  nvalidStripHitsH_ = iBook.book1D("nvalidStripHits", "No.of Valid Hits in Strip", 25, 0.0, 25.0);
332 
334  trkLayerwithMeasurementH_ = iBook.book1D("trkLayerwithMeasurement", "No. of Layers per Track", 25, 0.0, 25.0);
337  iBook.book1D("pixelLayerwithMeasurement", "No. of Pixel Layers per Track", 10, 0.0, 10.0);
340  iBook.book1D("stripLayerwithMeasurement", "No. of Strip Layers per Track", 20, 0.0, 20.0);
341 
342  if (!beamSpotXYposH_)
343  beamSpotXYposH_ = iBook.book1D("beamSpotXYpos", "XY position of beam spot", 40, -4.0, 4.0);
344  if (!beamSpotXYposerrH_)
345  beamSpotXYposerrH_ = iBook.book1D("beamSpotXYposerr", "Error in XY position of beam spot", 20, 0.0, 4.0);
346  if (!beamSpotZposH_)
347  beamSpotZposH_ = iBook.book1D("beamSpotZpos", "Z position of beam spot", 100, -20.0, 20.0);
348  if (!beamSpotZposerrH_)
349  beamSpotZposerrH_ = iBook.book1D("beamSpotZposerr", "Error in Z position of beam spot", 50, 0.0, 5.0);
350 
351  if (!vertexXposH_)
352  vertexXposH_ = iBook.book1D("vertexXpos", "Vertex X position", 50, -1.0, 1.0);
353  if (!vertexYposH_)
354  vertexYposH_ = iBook.book1D("vertexYpos", "Vertex Y position", 50, -1.0, 1.0);
355  if (!vertexZposH_)
356  vertexZposH_ = iBook.book1D("vertexZpos", "Vertex Z position", 100, -20.0, 20.0);
357  if (!nVertexH_)
358  nVertexH_ = iBook.book1D("nVertex", "# of vertices", 60, -0.5, 59.5);
359 
360  if (!nPixBarrelH_)
361  nPixBarrelH_ = iBook.book1D("nHitPixelBarrel", "No. of hits in Pixel Barrel per Track", 20, 0, 20.0);
362  if (!nPixEndcapH_)
363  nPixEndcapH_ = iBook.book1D("nHitPixelEndcap", "No. of hits in Pixel Endcap per Track", 20, 0, 20.0);
364  if (!nStripTIBH_)
365  nStripTIBH_ = iBook.book1D("nHitStripTIB", "No. of hits in Strip TIB per Track", 30, 0, 30.0);
366  if (!nStripTOBH_)
367  nStripTOBH_ = iBook.book1D("nHitStripTOB", "No. of hits in Strip TOB per Track", 30, 0, 30.0);
368  if (!nStripTECH_)
369  nStripTECH_ = iBook.book1D("nHitStripTEC", "No. of hits in Strip TEC per Track", 30, 0, 30.0);
370  if (!nStripTIDH_)
371  nStripTIDH_ = iBook.book1D("nHitStripTID", "No. of hits in Strip TID per Tracks", 30, 0, 30.0);
372 
373  if (!nTracksH_)
374  nTracksH_ = iBook.book1D("nTracks", "No. of Tracks", 100, -0.5, 999.5);
375  }
376  if (isMC_) {
377  if (!bunchCrossingH_)
378  bunchCrossingH_ = iBook.book1D("bunchCrossing", "Bunch Crosssing", 60, 0, 60.0);
379  if (!nPUH_)
380  nPUH_ = iBook.book1D("nPU", "No of Pileup", 60, 0, 60.0);
381  if (!trueNIntH_)
382  trueNIntH_ = iBook.book1D("trueNInt", "True no of Interactions", 60, 0, 60.0);
383  }
384  // Exclusive histograms
385  if (!nHitsVspTH_)
386  nHitsVspTH_ = iBook.bookProfile("nHitsVspT",
387  "Number of Hits Vs pT",
388  TrackPtHistoPar.getParameter<int32_t>("Xbins"),
389  TrackPtHistoPar.getParameter<double>("Xmin"),
390  TrackPtHistoPar.getParameter<double>("Xmax"),
391  0.0,
392  0.0,
393  "g");
394  if (!nHitsVsnVtxH_)
395  nHitsVsnVtxH_ = iBook.bookProfile("nHitsVsnVtx", "Number of Hits Vs Number of Vertex", 100, 0.0, 50, 0.0, 0.0, "g");
396  if (!nHitsVsEtaH_)
397  nHitsVsEtaH_ = iBook.bookProfile("nHitsVsEta",
398  "Number of Hits Vs Eta",
399  TrackEtaHistoPar.getParameter<int32_t>("Xbins"),
400  TrackEtaHistoPar.getParameter<double>("Xmin"),
401  TrackEtaHistoPar.getParameter<double>("Xmax"),
402  0.0,
403  0.0,
404  "g");
405  if (!nHitsVsCosThetaH_)
407  iBook.bookProfile("nHitsVsCosTheta", "Number of Hits Vs Cos(Theta)", 50, -1.0, 1.0, 0.0, 0.0, "g");
408  if (!nHitsVsPhiH_)
409  nHitsVsPhiH_ = iBook.bookProfile("nHitsVsPhi", "Number of Hits Vs Phi", 100, -3.5, 3.5, 0.0, 0.0, "g");
410 
411  if (!nLostHitsVspTH_)
412  nLostHitsVspTH_ = iBook.bookProfile("nLostHitsVspT",
413  "Number of Lost Hits Vs pT",
414  TrackPtHistoPar.getParameter<int32_t>("Xbins"),
415  TrackPtHistoPar.getParameter<double>("Xmin"),
416  TrackPtHistoPar.getParameter<double>("Xmax"),
417  0.0,
418  0.0,
419  "g");
420  if (!nLostHitsVsEtaH_)
421  nLostHitsVsEtaH_ = iBook.bookProfile("nLostHitsVsEta",
422  "Number of Lost Hits Vs Eta",
423  TrackEtaHistoPar.getParameter<int32_t>("Xbins"),
424  TrackEtaHistoPar.getParameter<double>("Xmin"),
425  TrackEtaHistoPar.getParameter<double>("Xmax"),
426  0.0,
427  0.0,
428  "g");
431  iBook.bookProfile("nLostHitsVsCosTheta", "Number of Lost Hits Vs Cos(Theta)", 50, -1.0, 1.0, 0.0, 0.0, "g");
432  if (!nLostHitsVsPhiH_)
433  nLostHitsVsPhiH_ = iBook.bookProfile("nLostHitsVsPhi", "Number of Lost Hits Vs Phi", 100, -3.5, 3.5, 0.0, 0.0, "g");
434 
435  // On and off-track cluster properties
438  iBook.book1D("hOnTrkClusChargeThin", "On-track Cluster Charge (Thin Sensor)", 100, 0, 1000);
440  hOnTrkClusWidthThinH_ = iBook.book1D("hOnTrkClusWidthThin", "On-track Cluster Width (Thin Sensor)", 20, -0.5, 19.5);
443  iBook.book1D("hOnTrkClusChargeThick", "On-track Cluster Charge (Thick Sensor)", 100, 0, 1000);
446  iBook.book1D("hOnTrkClusWidthThick", "On-track Cluster Width (Thick Sensor)", 20, -0.5, 19.5);
447 
450  iBook.book1D("hOffTrkClusChargeThin", "Off-track Cluster Charge (Thin Sensor)", 100, 0, 1000);
453  iBook.book1D("hOffTrkClusWidthThin", "Off-track Cluster Width (Thin Sensor)", 20, -0.5, 19.5);
456  iBook.book1D("hOffTrkClusChargeThick", "Off-track Cluster Charge (Thick Sensor)", 100, 0, 1000);
459  iBook.book1D("hOffTrkClusWidthThick", "Off-track Cluster Width (Thick Sensor)", 20, -0.5, 19.5);
460 }
462  // Get event setup (to get global transformation)
463 
465 
466  // Primary vertex collection
468  iEvent.getByToken(vertexToken_, vertexColl);
469 
470  // Beam spot
472  iEvent.getByToken(bsToken_, beamSpot);
473 
474  // Track collection
476  iEvent.getByToken(trackToken_, tracks);
477 
478  // Access PU information
479  double wfac = 1.0; // for data
480  if (!iEvent.isRealData()) {
482  iEvent.getByToken(puSummaryToken_, PupInfo);
483 
484  if (verbose_)
485  edm::LogInfo("StandaloneTrackMonitor") << "nPUColl = " << PupInfo->size();
486  for (auto const& v : *PupInfo) {
487  int bx = v.getBunchCrossing();
488  if (bunchCrossingH_)
490  if (bx == 0) {
491  if (nPUH_)
492  nPUH_->Fill(v.getPU_NumInteractions());
493  int ntrueInt = v.getTrueNumInteractions();
494  if (trueNIntH_)
495  trueNIntH_->Fill(ntrueInt);
496  if (doPUCorrection_)
497  if (ntrueInt > -1 && ntrueInt < int(vpu_.size()))
498  wfac = vpu_.at(ntrueInt);
499  }
500  }
501  }
502  if (verbose_)
503  edm::LogInfo("StandaloneTrackMonitor") << "PU reweight factor = " << wfac;
504 
505  if (!vertexColl.isValid())
506  edm::LogError("DqmTrackStudy") << "Error! Failed to get reco::Vertex Collection, " << vertexTag_;
507  if (haveAllHistograms_) {
508  int nvtx = (vertexColl.isValid() ? vertexColl->size() : 0);
509  nVertexH_->Fill(nvtx);
510  }
511 
512  int ntracks = 0;
513  if (tracks.isValid()) {
514  edm::LogInfo("StandaloneTrackMonitor") << "Total # of Tracks: " << tracks->size();
515  if (verbose_)
516  edm::LogInfo("StandaloneTrackMonitor") << "Total # of Tracks: " << tracks->size();
518  for (auto const& track : *tracks) {
519  if (!track.quality(quality))
520  continue;
521 
522  ++ntracks;
523 
524  double eta = track.eta();
525  double theta = track.theta();
526  double phi = track.phi();
527  double pt = track.pt();
528 
529  const reco::HitPattern& hitp = track.hitPattern();
530  double nValidTrackerHits = hitp.numberOfValidTrackerHits();
531  nHitsVsEtaH_->Fill(eta, nValidTrackerHits);
532  nHitsVsCosThetaH_->Fill(std::cos(theta), nValidTrackerHits);
533  nHitsVsPhiH_->Fill(phi, nValidTrackerHits);
534  nHitsVspTH_->Fill(pt, nValidTrackerHits);
535  nHitsVsnVtxH_->Fill(vertexColl->size(), nValidTrackerHits);
536 
537  int nLostHits = track.numberOfLostHits();
538  nLostHitsVspTH_->Fill(pt, nLostHits);
539  nLostHitsVsEtaH_->Fill(eta, nLostHits);
541  nLostHitsVsPhiH_->Fill(phi, nLostHits);
542 
543  double nValidPixelHits = hitp.numberOfValidPixelHits();
544  double nValidStripHits = hitp.numberOfValidStripHits();
545  double pixelLayersWithMeasurement = hitp.pixelLayersWithMeasurement();
546  double stripLayersWithMeasurement = hitp.stripLayersWithMeasurement();
547 
548  if (haveAllHistograms_) {
549  double etaError = track.etaError();
550  double thetaError = track.thetaError();
551  double phiError = track.phiError();
552  double p = track.p();
553  double ptError = track.ptError();
554  double qoverp = track.qoverp();
555  double qoverpError = track.qoverpError();
556  double charge = track.charge();
557 
558  double trackerLayersWithMeasurement = hitp.trackerLayersWithMeasurement();
559 
560  double dxy = track.dxy(beamSpot->position());
561  double dxyError = track.dxyError();
562  double dz = track.dz(beamSpot->position());
563  double dzError = track.dzError();
564 
565  double trkd0 = track.d0();
566  double chi2 = track.chi2();
567  double ndof = track.ndof();
568  double vx = track.vx();
569  double vy = track.vy();
570  double vz = track.vz();
571 
572  // Fill the histograms
573  trackEtaH_->Fill(eta, wfac);
574  trackEtaerrH_->Fill(etaError, wfac);
576  trackThetaerrH_->Fill(thetaError, wfac);
577  trackPhiH_->Fill(phi, wfac);
578  trackPhierrH_->Fill(phiError, wfac);
579  trackPH_->Fill(p, wfac);
580  trackPtH_->Fill(pt, wfac);
581  if (pt <= 2)
582  trackPtUpto2GeVH_->Fill(pt, wfac);
583  if (pt >= 10)
584  trackPtOver10GeVH_->Fill(pt, wfac);
585  trackPterrH_->Fill(ptError, wfac);
586  trackqOverpH_->Fill(qoverp, wfac);
587  trackqOverperrH_->Fill(qoverpError, wfac);
588  trackChargeH_->Fill(charge, wfac);
589  trackChi2H_->Fill(chi2, wfac);
590  trackd0H_->Fill(trkd0, wfac);
591  tracknDOFH_->Fill(ndof, wfac);
592  trackChi2bynDOFH_->Fill(chi2 / ndof, wfac);
593 
594  nlostHitsH_->Fill(nLostHits, wfac);
595  nvalidTrackerHitsH_->Fill(nValidTrackerHits, wfac);
596  nvalidPixelHitsH_->Fill(nValidPixelHits, wfac);
597  nvalidStripHitsH_->Fill(nValidStripHits, wfac);
598 
599  trkLayerwithMeasurementH_->Fill(trackerLayersWithMeasurement, wfac);
600  pixelLayerwithMeasurementH_->Fill(pixelLayersWithMeasurement, wfac);
601  stripLayerwithMeasurementH_->Fill(stripLayersWithMeasurement, wfac);
602 
603  beamSpotXYposH_->Fill(dxy, wfac);
604  beamSpotXYposerrH_->Fill(dxyError, wfac);
605  beamSpotZposH_->Fill(dz, wfac);
606  beamSpotZposerrH_->Fill(dzError, wfac);
607 
608  vertexXposH_->Fill(vx, wfac);
609  vertexYposH_->Fill(vy, wfac);
610  vertexZposH_->Fill(vz, wfac);
611  }
612  int nPixBarrel = 0, nPixEndcap = 0, nStripTIB = 0, nStripTOB = 0, nStripTEC = 0, nStripTID = 0;
613  for (auto it = track.recHitsBegin(); it != track.recHitsEnd(); ++it) {
614  const TrackingRecHit& hit = (**it);
615  if (hit.isValid()) {
616  if (hit.geographicalId().det() == DetId::Tracker) {
617  int subdetId = hit.geographicalId().subdetId();
618  if (subdetId == PixelSubdetector::PixelBarrel)
619  ++nPixBarrel;
620  else if (subdetId == PixelSubdetector::PixelEndcap)
621  ++nPixEndcap;
622  else if (subdetId == StripSubdetector::TIB)
623  ++nStripTIB;
624  else if (subdetId == StripSubdetector::TOB)
625  ++nStripTOB;
626  else if (subdetId == StripSubdetector::TEC)
627  ++nStripTEC;
628  else if (subdetId == StripSubdetector::TID)
629  ++nStripTID;
630 
631  // Find on-track clusters
632  processHit(hit, iSetup, wfac);
633  }
634  }
635  }
636  if (verbose_)
637  edm::LogInfo("StandaloneTrackMonitor")
638  << " >>> HITs: nPixBarrel: " << nPixBarrel << " nPixEndcap: " << nPixEndcap << " nStripTIB: " << nStripTIB
639  << " nStripTOB: " << nStripTOB << " nStripTEC: " << nStripTEC << " nStripTID: " << nStripTID;
640  if (haveAllHistograms_) {
641  nPixBarrelH_->Fill(nPixBarrel, wfac);
642  nPixEndcapH_->Fill(nPixEndcap, wfac);
643  nStripTIBH_->Fill(nStripTIB, wfac);
644  nStripTOBH_->Fill(nStripTOB, wfac);
645  nStripTECH_->Fill(nStripTEC, wfac);
646  nStripTIDH_->Fill(nStripTID, wfac);
647  }
648  }
649  } else {
650  edm::LogError("DqmTrackStudy") << "Error! Failed to get reco::Track collection, " << trackTag_;
651  }
652  if (haveAllHistograms_)
654 
655  // off track cluster properties
656  processClusters(iEvent, iSetup, wfac);
657 }
659  // SiStripClusters
661  iEvent.getByToken(clusterToken_, clusterHandle);
662 
663  if (clusterHandle.isValid()) {
664  // Loop on Dets
665  for (edmNew::DetSetVector<SiStripCluster>::const_iterator dsvit = clusterHandle->begin();
666  dsvit != clusterHandle->end();
667  ++dsvit) {
668  uint32_t detId = dsvit->id();
669  std::map<uint32_t, std::set<const SiStripCluster*> >::iterator jt = clusterMap_.find(detId);
670  bool detid_found = (jt != clusterMap_.end()) ? true : false;
671 
672  // Loop on Clusters
673  for (edmNew::DetSet<SiStripCluster>::const_iterator clusit = dsvit->begin(); clusit != dsvit->end(); ++clusit) {
674  if (detid_found) {
675  std::set<const SiStripCluster*>& s = jt->second;
676  if (s.find(&*clusit) != s.end())
677  continue;
678  }
679 
680  siStripClusterInfo_.setCluster(*clusit, detId);
682  float width = siStripClusterInfo_.width();
683 
684  const GeomDetUnit* detUnit = tkGeom_->idToDetUnit(detId);
685  float thickness = detUnit->surface().bounds().thickness(); // unit cm
686  if (thickness > 0.035) {
689  } else {
692  }
693  }
694  }
695  } else {
696  edm::LogError("StandaloneTrackMonitor") << "ClusterCollection " << clusterTag_ << " not valid!!" << std::endl;
697  }
698 }
700  uint32_t detid = recHit.geographicalId();
701  const GeomDetUnit* detUnit = tkGeom_->idToDetUnit(detid);
702  float thickness = detUnit->surface().bounds().thickness(); // unit cm
703 
704  auto const& thit = static_cast<BaseTrackerRecHit const&>(recHit);
705  if (!thit.isValid())
706  return;
707 
708  auto const& clus = thit.firstClusterRef();
709  if (!clus.isValid())
710  return;
711  if (!clus.isStrip())
712  return;
713 
714  if (thit.isMatched()) {
715  const SiStripMatchedRecHit2D& matchedHit = dynamic_cast<const SiStripMatchedRecHit2D&>(recHit);
716 
717  auto& clusterM = matchedHit.monoCluster();
718  siStripClusterInfo_.setCluster(clusterM, detid);
719  if (thickness > 0.035) {
722  } else {
725  }
726  addClusterToMap(detid, &clusterM);
727 
728  auto& clusterS = matchedHit.stereoCluster();
729  siStripClusterInfo_.setCluster(clusterS, detid);
730  if (thickness > 0.035) {
733  } else {
736  }
737  addClusterToMap(detid, &clusterS);
738  } else {
739  auto& cluster = clus.stripCluster();
740  siStripClusterInfo_.setCluster(cluster, detid);
741  if (thickness > 0.035) {
744  } else {
747  }
748  addClusterToMap(detid, &cluster);
749  }
750 }
751 void StandaloneTrackMonitor::addClusterToMap(uint32_t detid, const SiStripCluster* cluster) {
752  std::map<uint32_t, std::set<const SiStripCluster*> >::iterator it = clusterMap_.find(detid);
753  if (it == clusterMap_.end()) {
754  std::set<const SiStripCluster*> s;
755  s.insert(cluster);
756  clusterMap_.insert(std::pair<uint32_t, std::set<const SiStripCluster*> >(detid, s));
757  } else {
758  std::set<const SiStripCluster*>& s = it->second;
759  s.insert(cluster);
760  }
761 }
762 // Define this as a plug-in
MonitorElement * pixelLayerwithMeasurementH_
const TrackerGeometry * tkGeom_
int numberOfValidPixelHits() const
Definition: HitPattern.h:831
MonitorElement * hOnTrkClusChargeThickH_
const edm::InputTag trackTag_
static constexpr auto TEC
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement * hOnTrkClusChargeThinH_
MonitorElement * trackPtOver10GeVH_
void setCluster(const SiStripCluster &cluster, int detId)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusterToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
StandaloneTrackMonitor(const edm::ParameterSet &)
MonitorElement * trackChi2bynDOFH_
TrackQuality
track quality
Definition: TrackBase.h:150
MonitorElement * hOffTrkClusWidthThickH_
const edm::EDGetTokenT< reco::TrackCollection > trackToken_
void processClusters(edm::Event const &iEvent, edm::EventSetup const &iSetup, double wfac=1)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:534
const edm::EDGetTokenT< std::vector< PileupSummaryInfo > > puSummaryToken_
int stripLayersWithMeasurement() const
Definition: HitPattern.h:1005
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
MonitorElement * stripLayerwithMeasurementH_
data_type const * const_iterator
Definition: DetSetNew.h:31
void processHit(const TrackingRecHit &recHit, edm::EventSetup const &iSetup, double wfac=1)
Log< level::Error, false > LogError
std::vector< Vertex > VertexCollection
Definition: Vertex.h:31
MonitorElement * hOnTrkClusWidthThinH_
MonitorElement * hOffTrkClusWidthThinH_
const std::string puScaleFactorFile_
MonitorElement * hOffTrkClusChargeThinH_
SiStripClusterInfo siStripClusterInfo_
int numberOfValidStripHits() const
Definition: HitPattern.h:843
const edm::InputTag vertexTag_
void Fill(long long x)
virtual float thickness() const =0
int iEvent
Definition: GenABIO.cc:224
MonitorElement * hOnTrkClusWidthThickH_
SiStripCluster const & monoCluster() const
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const edm::InputTag puSummaryTag_
Transition
Definition: Transition.h:12
bool getData(T &iHolder) const
Definition: EventSetup.h:122
static constexpr auto TOB
MonitorElement * nLostHitsVsCosThetaH_
MonitorElement * hOffTrkClusChargeThickH_
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const edm::InputTag clusterTag_
MonitorElement * nvalidTrackerHitsH_
void addClusterToMap(uint32_t detid, const SiStripCluster *cluster)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
static constexpr auto TIB
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
auto const & tracks
cannot be loose
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
MonitorElement * trkLayerwithMeasurementH_
std::map< uint32_t, std::set< const SiStripCluster * > > clusterMap_
uint16_t width() const
SiStripCluster const & stereoCluster() const
bool isValid() const
Definition: HandleBase.h:70
fixed size matrix
void dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
HLT enums.
const edm::EDGetTokenT< reco::VertexCollection > vertexToken_
int pixelLayersWithMeasurement() const
Definition: HitPattern.cc:513
MonitorElement * trackPtUpto2GeVH_
uint16_t charge() const
string quality
void initEvent(const edm::EventSetup &iSetup)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static constexpr auto TID
Geom::Theta< T > theta() const
int numberOfValidTrackerHits() const
Definition: HitPattern.h:819
Definition: Run.h:45
const Bounds & bounds() const
Definition: Surface.h:87