CMS 3D CMS Logo

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