CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DMRChecker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Alignment/OfflineValidation
4 // Class: DMRChecker
5 //
9 //
10 // Original Author: Marco Musich
11 // Created: Mon, 10 Aug 2020 15:45:00 GMT
12 //
13 //
14 
15 // ROOT includes
16 
17 #include <RtypesCore.h>
18 #include <TAxis.h>
19 #include <TCanvas.h>
20 #include <TColor.h>
21 #include <TH1.h>
22 #include <TH2.h>
23 #include <TLatex.h>
24 #include <TMath.h>
25 #include <TProfile.h>
26 #include <TString.h>
27 #include <TStyle.h>
28 #include <TVirtualPad.h>
29 
30 // STL includes
31 
32 #include <algorithm>
33 #include <array>
34 #include <cmath>
35 #include <cstdint>
36 #include <cstdlib>
37 #include <ctime>
38 #include <ext/alloc_traits.h>
39 #include <fmt/printf.h>
40 #include <iomanip>
41 #include <iostream>
42 #include <map>
43 #include <memory>
44 #include <string>
45 #include <type_traits>
46 #include <utility>
47 #include <vector>
48 #include <boost/range/adaptor/indexed.hpp>
49 
50 // user system includes
51 
119 
120 #define DEBUG 0
121 
122 using namespace std;
123 using namespace edm;
124 
127 constexpr float cmToUm = 10000.;
128 
134 namespace running {
135  struct Estimators {
139  int hitCount;
144  };
145 
146  using estimatorMap = std::map<uint32_t, running::Estimators>;
147 
148 } // namespace running
149 
150 class DMRChecker : public edm::one::EDAnalyzer<edm::one::SharedResources> {
151 public:
153  : geomToken_(esConsumes()),
154  runInfoToken_(esConsumes()),
155  magFieldToken_(esConsumes()),
156  topoToken_(esConsumes()),
157  latencyToken_(esConsumes()),
158  isCosmics_(pset.getParameter<bool>("isCosmics")) {
159  usesResource(TFileService::kSharedResource);
160 
161  TkTag_ = pset.getParameter<edm::InputTag>("TkTag");
162  theTrackCollectionToken_ = consumes<reco::TrackCollection>(TkTag_);
163 
164  TriggerResultsTag_ = pset.getParameter<edm::InputTag>("TriggerResultsTag");
165  hltresultsToken_ = consumes<edm::TriggerResults>(TriggerResultsTag_);
166 
167  BeamSpotTag_ = pset.getParameter<edm::InputTag>("BeamSpotTag");
168  beamspotToken_ = consumes<reco::BeamSpot>(BeamSpotTag_);
169 
170  VerticesTag_ = pset.getParameter<edm::InputTag>("VerticesTag");
171  vertexToken_ = consumes<reco::VertexCollection>(VerticesTag_);
172 
173  // initialize conventional Tracker maps
174 
175  pmap = std::make_unique<TrackerMap>("Pixel");
176  pmap->onlyPixel(true);
177  pmap->setTitle("Pixel Hit entries");
178  pmap->setPalette(1);
179 
180  tmap = std::make_unique<TrackerMap>("Strip");
181  tmap->setTitle("Strip Hit entries");
182  tmap->setPalette(1);
183 
184  // initialize Phase1 Pixel Maps
185 
186  pixelmap = std::make_unique<Phase1PixelMaps>("COLZ0 L");
187  pixelmap->bookBarrelHistograms("DMRsX", "Median Residuals x-direction", "Median Residuals");
188  pixelmap->bookForwardHistograms("DMRsX", "Median Residuals x-direction", "Median Residuals");
189 
190  pixelmap->bookBarrelHistograms("DMRsY", "Median Residuals y-direction", "Median Residuals");
191  pixelmap->bookForwardHistograms("DMRsY", "Median Residuals y-direction", "Median Residuals");
192 
193  // set no rescale
194  pixelmap->setNoRescale();
195 
196  // initialize Full Pixel Map
197  fullPixelmapXDMR = std::make_unique<Phase1PixelSummaryMap>("", "DMR-x", "median of residuals [#mum]");
198  fullPixelmapYDMR = std::make_unique<Phase1PixelSummaryMap>("", "DMR-y", "median of residuals [#mum]");
199  }
200 
202 
203  ~DMRChecker() override = default;
204 
205  /*_______________________________________________________
206  //
207  // auxilliary method to retrieve certain histogram types
208  //_______________________________________________________
209  */
210  template <class OBJECT_TYPE>
211  int GetIndex(const std::vector<OBJECT_TYPE *> &vec, const std::string &name) {
212  for (const auto &iter : vec | boost::adaptors::indexed(0)) {
213  if (iter.value() && iter.value()->GetName() == name) {
214  return iter.index();
215  }
216  }
217  edm::LogError("Alignment") << "@SUB=DMRChecker::GetIndex"
218  << " could not find " << name;
219  return -1;
220  }
221 
222 private:
223  // tokens for the event setup
229 
231 
232  std::unique_ptr<Phase1PixelMaps> pixelmap;
233  std::unique_ptr<Phase1PixelSummaryMap> fullPixelmapXDMR;
234  std::unique_ptr<Phase1PixelSummaryMap> fullPixelmapYDMR;
235 
236  std::unique_ptr<PixelRegions::PixelRegionContainers> PixelDMRS_x_ByLayer;
237  std::unique_ptr<PixelRegions::PixelRegionContainers> PixelDMRS_y_ByLayer;
238 
239  std::unique_ptr<TrackerMap> tmap;
240  std::unique_ptr<TrackerMap> pmap;
241 
242  TH1D *hchi2ndof;
243  TH1D *hNtrk;
244  TH1D *hNtrkZoom;
245  TH1I *htrkQuality;
246  TH1I *htrkAlgo;
248  TH1D *hP;
249  TH1D *hPPlus;
250  TH1D *hPMinus;
251  TH1D *hPt;
252  TH1D *hMinPt;
253  TH1D *hPtPlus;
254  TH1D *hPtMinus;
255  TH1D *hHit;
256  TH1D *hHit2D;
257 
262 
267 
272 
277 
282 
287 
294 
297 
300 
307 
310 
313 
314  TH1D *hHitPlus;
315  TH1D *hHitMinus;
316 
317  TH1D *hPhp;
318  TH1D *hPthp;
319  TH1D *hHithp;
320  TH1D *hEtahp;
321  TH1D *hPhihp;
322  TH1D *hchi2ndofhp;
323  TH1D *hchi2Probhp;
324 
325  TH1D *hCharge;
326  TH1D *hQoverP;
327  TH1D *hQoverPZoom;
328  TH1D *hEta;
329  TH1D *hEtaPlus;
330  TH1D *hEtaMinus;
331  TH1D *hPhi;
332  TH1D *hPhiBarrel;
337  TH1D *hPhiPlus;
338  TH1D *hPhiMinus;
339 
340  TH1D *hDeltaPhi;
341  TH1D *hDeltaEta;
342  TH1D *hDeltaR;
343 
344  TH1D *hvx;
345  TH1D *hvy;
346  TH1D *hvz;
347  TH1D *hd0;
348  TH1D *hdz;
349  TH1D *hdxy;
350 
351  TH2D *hd0PVvsphi;
352  TH2D *hd0PVvseta;
353  TH2D *hd0PVvspt;
354 
355  TH2D *hd0vsphi;
356  TH2D *hd0vseta;
357  TH2D *hd0vspt;
358 
359  TH1D *hnhpxb;
360  TH1D *hnhpxe;
361  TH1D *hnhTIB;
362  TH1D *hnhTID;
363  TH1D *hnhTOB;
364  TH1D *hnhTEC;
365 
367 
368  TProfile *pNBpixHitsVsVx;
369  TProfile *pNBpixHitsVsVy;
370  TProfile *pNBpixHitsVsVz;
371 
372  TH1D *hMultCand;
373 
374  TH1D *hdxyBS;
375  TH1D *hd0BS;
376  TH1D *hdzBS;
377  TH1D *hdxyPV;
378  TH1D *hd0PV;
379  TH1D *hdzPV;
380  TH1D *hrun;
381  TH1D *hlumi;
382 
383  std::vector<TH1 *> vTrackHistos_;
384  std::vector<TH1 *> vTrackProfiles_;
385  std::vector<TH1 *> vTrack2DHistos_;
386 
389 
390  TH1D *modeByRun_;
391  TH1D *fieldByRun_;
392 
394  TH1D *hitsByRun_;
395 
398 
401 
402  // Pixel
403 
404  TH1D *DMRBPixX_;
405  TH1D *DMRBPixY_;
406 
407  TH1D *DMRFPixX_;
408  TH1D *DMRFPixY_;
409 
410  TH1D *DRnRBPixX_;
411  TH1D *DRnRBPixY_;
412 
413  TH1D *DRnRFPixX_;
414  TH1D *DRnRFPixY_;
415 
416  // Strips
417 
418  TH1D *DMRTIB_;
419  TH1D *DMRTOB_;
420 
421  TH1D *DMRTID_;
422  TH1D *DMRTEC_;
423 
424  TH1D *DRnRTIB_;
425  TH1D *DRnRTOB_;
426 
427  TH1D *DRnRTID_;
428  TH1D *DRnRTEC_;
429 
430  // Split DMRs
431 
432  std::array<TH1D *, 2> DMRBPixXSplit_;
433  std::array<TH1D *, 2> DMRBPixYSplit_;
434 
435  std::array<TH1D *, 2> DMRFPixXSplit_;
436  std::array<TH1D *, 2> DMRFPixYSplit_;
437 
438  std::array<TH1D *, 2> DMRTIBSplit_;
439  std::array<TH1D *, 2> DMRTOBSplit_;
440 
441  // residuals
442 
443  std::map<unsigned int, TH1D *> barrelLayersResidualsX;
444  std::map<unsigned int, TH1D *> barrelLayersPullsX;
445  std::map<unsigned int, TH1D *> barrelLayersResidualsY;
446  std::map<unsigned int, TH1D *> barrelLayersPullsY;
447 
448  std::map<unsigned int, TH1D *> endcapDisksResidualsX;
449  std::map<unsigned int, TH1D *> endcapDisksPullsX;
450  std::map<unsigned int, TH1D *> endcapDisksResidualsY;
451  std::map<unsigned int, TH1D *> endcapDisksPullsY;
452 
453  int ievt;
454  int itrks;
455  int mode;
457 
459  const bool isCosmics_;
460 
465 
470 
471  std::map<std::string, std::pair<int, int> > triggerMap_;
472  std::map<int, std::pair<int, float> > conditionsMap_;
473  std::map<int, std::pair<int, int> > runInfoMap_;
474  std::map<int, std::array<int, 6> > runHitsMap_;
475 
476  std::map<int, float> timeMap_;
477 
478  // Pixel
479 
484 
485  // Strips
486 
491 
492  void analyze(const edm::Event &event, const edm::EventSetup &setup) override {
493  ievt++;
494 
495  edm::Handle<reco::TrackCollection> trackCollection = event.getHandle(theTrackCollectionToken_);
496 
497  // magnetic field setup
498  const MagneticField *magneticField_ = &setup.getData(magFieldToken_);
499  float B_ = magneticField_->inTesla(GlobalPoint(0, 0, 0)).mag();
500 
501  const RunInfo *summary = &setup.getData(runInfoToken_);
502  time_t start_time = summary->m_start_time_ll;
503  ctime(&start_time);
504  time_t end_time = summary->m_stop_time_ll;
505  ctime(&end_time);
506 
507  /*
508  float average_current = runInfo.product()->m_avg_current;
509  float uptimeInSeconds = runInfo.product()->m_run_intervall_micros;
510  edm::LogVerbatim("DMRChecker")<< " start_time " << start_time << "( " << summary->m_start_time_str <<" )"
511  << " end_time " << end_time << "( " << summary->m_stop_time_str <<" )" << std::endl;
512  */
513 
514  double seconds = difftime(end_time, start_time) / 1.0e+6; // convert from micros-seconds
515  //edm::LogVerbatim("DMRChecker")<<" diff: "<< seconds << "s" << std::endl;
516  timeMap_[event.run()] = seconds;
517 
518  // topology setup
519  const TrackerTopology *const tTopo = &setup.getData(topoToken_);
520 
521  const SiStripLatency *apvlat = &setup.getData(latencyToken_);
522  if (apvlat->singleReadOutMode() == 1) {
523  mode = 1; // peak mode
524  } else if (apvlat->singleReadOutMode() == 0) {
525  mode = -1; // deco mode
526  }
527 
528  conditionsMap_[event.run()].first = mode;
529  conditionsMap_[event.run()].second = B_;
530 
531  // geometry setup
532  const TrackerGeometry *theGeometry = &setup.getData(geomToken_);
533 
534  if (firstEvent_) {
535  if (theGeometry->isThere(GeomDetEnumerators::P2PXB) || theGeometry->isThere(GeomDetEnumerators::P2PXEC)) {
536  phase_ = SiPixelPI::phase::two;
537  } else if (theGeometry->isThere(GeomDetEnumerators::P1PXB) || theGeometry->isThere(GeomDetEnumerators::P1PXEC)) {
538  phase_ = SiPixelPI::phase::one;
539  } else {
540  phase_ = SiPixelPI::phase::zero;
541  }
542  firstEvent_ = false;
543  }
544 
545  GlobalPoint zeroPoint(0, 0, 0);
546  //edm::LogVerbatim("DMRChecker") << "event#" << ievt << " Event ID = "<< event.id()
548 
549  const reco::TrackCollection tC = *(trackCollection.product());
550  itrks += tC.size();
551 
552  runInfoMap_[event.run()].first += 1;
553  runInfoMap_[event.run()].second += tC.size();
554 
555  //edm::LogVerbatim("DMRChecker") << "Reconstructed "<< tC.size() << " tracks" << std::endl ;
556 
557  edm::Handle<edm::TriggerResults> hltresults = event.getHandle(hltresultsToken_);
558  if (hltresults.isValid()) {
559  const edm::TriggerNames &triggerNames_ = event.triggerNames(*hltresults);
560  int ntrigs = hltresults->size();
561 
562  for (int itrig = 0; itrig != ntrigs; ++itrig) {
563  const string &trigName = triggerNames_.triggerName(itrig);
564  bool accept = hltresults->accept(itrig);
565  if (accept == 1) {
566  // emd::LogVerbatim("DMRChecker") << trigName << " " << accept << " ,track size: " << tC.size() << endl;
567  triggerMap_[trigName].first += 1;
568  triggerMap_[trigName].second += tC.size();
569  }
570  }
571  }
572 
573  hrun->Fill(event.run());
574  hlumi->Fill(event.luminosityBlock());
575 
576  int nHighPurityTracks = 0;
577 
578  for (const auto &track : tC) {
579  auto const &residuals = track.extra()->residuals();
580 
581  unsigned int nHit2D = 0;
582  int h_index = 0;
583  for (trackingRecHit_iterator iHit = track.recHitsBegin(); iHit != track.recHitsEnd(); ++iHit, ++h_index) {
584  if (this->isHit2D(**iHit))
585  ++nHit2D;
586 
587  double resX = residuals.residualX(h_index);
588  double resY = residuals.residualY(h_index);
589  double pullX = residuals.pullX(h_index);
590  double pullY = residuals.pullY(h_index);
591 
592  const DetId &detId = (*iHit)->geographicalId();
593 
594  unsigned int subid = detId.subdetId();
595  uint32_t detid_db = detId.rawId();
596 
597  const GeomDet *geomDet(theGeometry->idToDet(detId));
598 
599  float uOrientation(-999.F), vOrientation(-999.F);
600  LocalPoint lPModule(0., 0., 0.), lUDirection(1., 0., 0.), lVDirection(0., 1., 0.), lWDirection(0., 0., 1.);
601 
602  // do all the transformations here
603  GlobalPoint gUDirection = geomDet->surface().toGlobal(lUDirection);
604  GlobalPoint gVDirection = geomDet->surface().toGlobal(lVDirection);
605  GlobalPoint gWDirection = geomDet->surface().toGlobal(lWDirection);
606  GlobalPoint gPModule = geomDet->surface().toGlobal(lPModule);
607 
608  if (!(*iHit)->detUnit())
609  continue; // is it a single physical module?
610 
611  if ((*iHit)->isValid() && (subid > PixelSubdetector::PixelEndcap)) {
612  tmap->fill(detid_db, 1);
613 
614  //LocalPoint lp = (*iHit)->localPosition();
615  //LocalError le = (*iHit)->localPositionError();
616 
617  // fill DMRs and DrNRs
618  if (subid == StripSubdetector::TIB) {
619  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
620  //vOrientation = gVDirection.z() - gPModule.z() >= 0 ? +1.F : -1.F; // not used for Strips
621 
622  // if the detid has never occcurred yet, set the local orientations
623  if (resDetailsTIB_.find(detid_db) == resDetailsTIB_.end()) {
624  resDetailsTIB_[detid_db].rDirection = gWDirection.perp() - gPModule.perp() >= 0 ? +1 : -1;
625  resDetailsTIB_[detid_db].zDirection = gVDirection.z() - gPModule.z() >= 0 ? +1 : -1;
626  resDetailsTIB_[detid_db].rOrZDirection = resDetailsTIB_[detid_db].rDirection; // barrel (split in r)
627  }
628 
629  hTIBResXPrime->Fill(uOrientation * resX * cmToUm);
630  hTIBResXPull->Fill(pullX);
631 
632  // update residuals
633  this->updateOnlineMomenta(resDetailsTIB_, detid_db, uOrientation * resX * cmToUm, pullX);
634 
635  } else if (subid == StripSubdetector::TOB) {
636  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
637  //vOrientation = gVDirection.z() - gPModule.z() >= 0 ? +1.F : -1.F; // not used for Strips
638 
639  hTOBResXPrime->Fill(uOrientation * resX * cmToUm);
640  hTOBResXPull->Fill(pullX);
641 
642  // if the detid has never occcurred yet, set the local orientations
643  if (resDetailsTOB_.find(detid_db) == resDetailsTOB_.end()) {
644  resDetailsTOB_[detid_db].rDirection = gWDirection.perp() - gPModule.perp() >= 0 ? +1 : -1;
645  resDetailsTOB_[detid_db].zDirection = gVDirection.z() - gPModule.z() >= 0 ? +1 : -1;
646  resDetailsTOB_[detid_db].rOrZDirection = resDetailsTOB_[detid_db].rDirection; // barrel (split in r)
647  }
648 
649  // update residuals
650  this->updateOnlineMomenta(resDetailsTOB_, detid_db, uOrientation * resX * cmToUm, pullX);
651 
652  } else if (subid == StripSubdetector::TID) {
653  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
654  //vOrientation = gVDirection.perp() - gPModule.perp() >= 0. ? +1.F : -1.F; // not used for Strips
655 
656  hTIDResXPrime->Fill(uOrientation * resX * cmToUm);
657  hTIDResXPull->Fill(pullX);
658 
659  // update residuals
660  this->updateOnlineMomenta(resDetailsTID_, detid_db, uOrientation * resX * cmToUm, pullX);
661 
662  } else if (subid == StripSubdetector::TEC) {
663  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
664  //vOrientation = gVDirection.perp() - gPModule.perp() >= 0. ? +1.F : -1.F; // not used for Strips
665 
666  hTECResXPrime->Fill(uOrientation * resX * cmToUm);
667  hTECResXPull->Fill(pullX);
668 
669  // update residuals
670  this->updateOnlineMomenta(resDetailsTEC_, detid_db, uOrientation * resX * cmToUm, pullX);
671  }
672  }
673 
674  const SiPixelRecHit *pixhit = dynamic_cast<const SiPixelRecHit *>(*iHit);
675 
676  if (pixhit) {
677  if (pixhit->isValid()) {
678  if (phase_ == SiPixelPI::phase::zero) {
679  pmap->fill(detid_db, 1);
680  }
681 
682  LocalPoint lp = (*iHit)->localPosition();
683  //LocalError le = (*iHit)->localPositionError();
684  GlobalPoint GP = geomDet->surface().toGlobal(lp);
685 
686  if ((subid == PixelSubdetector::PixelBarrel) || (subid == PixelSubdetector::PixelEndcap)) {
687  // 1 = PXB, 2 = PXF
688  if (subid == PixelSubdetector::PixelBarrel) {
689  int layer_num = tTopo->pxbLayer(detid_db);
690 
691  uOrientation = deltaPhi(gUDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
692  vOrientation = gVDirection.z() - gPModule.z() >= 0 ? +1.F : -1.F;
693 
694  // if the detid has never occcurred yet, set the local orientations
695  if (resDetailsBPixX_.find(detid_db) == resDetailsBPixX_.end()) {
696  resDetailsBPixX_[detid_db].rDirection = gWDirection.perp() - gPModule.perp() >= 0 ? +1 : -1;
697  resDetailsBPixX_[detid_db].zDirection = gVDirection.z() - gPModule.z() >= 0 ? +1 : -1;
698  resDetailsBPixX_[detid_db].rOrZDirection =
699  resDetailsBPixX_[detid_db].rDirection; // barrel (split in r)
700  }
701 
702  // if the detid has never occcurred yet, set the local orientations
703  if (resDetailsBPixY_.find(detid_db) == resDetailsBPixY_.end()) {
704  resDetailsBPixY_[detid_db].rDirection = gWDirection.perp() - gPModule.perp() >= 0 ? +1 : -1;
705  resDetailsBPixY_[detid_db].zDirection = gVDirection.z() - gPModule.z() >= 0 ? +1 : -1;
706  resDetailsBPixY_[detid_db].rOrZDirection =
707  resDetailsBPixY_[detid_db].rDirection; // barrel (split in r)
708  }
709 
710  hHitCountVsThetaBPix->Fill(GP.theta());
711  hHitCountVsPhiBPix->Fill(GP.phi());
712 
713  hHitCountVsZBPix->Fill(GP.z());
714  hHitCountVsXBPix->Fill(GP.x());
715  hHitCountVsYBPix->Fill(GP.y());
716 
717  hBPixResXPrime->Fill(uOrientation * resX * cmToUm);
718  hBPixResYPrime->Fill(vOrientation * resY * cmToUm);
719  hBPixResXPull->Fill(pullX);
720  hBPixResYPull->Fill(pullY);
721 
722  //edm::LogVerbatim("DMRChecker")<<"layer: "<<layer_num<<std::endl;
723 
724  // update residuals X
725  this->updateOnlineMomenta(resDetailsBPixX_, detid_db, uOrientation * resX * cmToUm, pullX);
726 
727  // update residuals Y
728  this->updateOnlineMomenta(resDetailsBPixY_, detid_db, vOrientation * resY * cmToUm, pullY);
729 
730  fillByIndex(barrelLayersResidualsX, layer_num, uOrientation * resX * cmToUm);
731  fillByIndex(barrelLayersPullsX, layer_num, pullX);
732  fillByIndex(barrelLayersResidualsY, layer_num, vOrientation * resY * cmToUm);
733  fillByIndex(barrelLayersPullsY, layer_num, pullY);
734 
735  } else if (subid == PixelSubdetector::PixelEndcap) {
736  uOrientation = gUDirection.perp() - gPModule.perp() >= 0 ? +1.F : -1.F;
737  vOrientation = deltaPhi(gVDirection.barePhi(), gPModule.barePhi()) >= 0. ? +1.F : -1.F;
738 
739  int side_num = tTopo->pxfSide(detid_db);
740  int disk_num = tTopo->pxfDisk(detid_db);
741 
742  int packedTopo = disk_num + 3 * (side_num - 1);
743 
744  //edm::LogVerbatim("DMRChecker")<<"side: "<< side_num <<" disk: " << disk_num << " packedTopo: " << packedTopo <<" GP.z(): "<<GP.z()<<std::endl;
745 
746  hHitCountVsThetaFPix->Fill(GP.theta());
747  hHitCountVsPhiFPix->Fill(GP.phi());
748 
749  hHitCountVsZFPix->Fill(GP.z());
750  hHitCountVsXFPix->Fill(GP.x());
751  hHitCountVsYFPix->Fill(GP.y());
752 
753  hFPixResXPrime->Fill(uOrientation * resX * cmToUm);
754  hFPixResYPrime->Fill(vOrientation * resY * cmToUm);
755  hFPixResXPull->Fill(pullX);
756  hFPixResYPull->Fill(pullY);
757 
758  fillByIndex(endcapDisksResidualsX, packedTopo, uOrientation * resX * cmToUm);
759  fillByIndex(endcapDisksPullsX, packedTopo, pullX);
760  fillByIndex(endcapDisksResidualsY, packedTopo, vOrientation * resY * cmToUm);
761  fillByIndex(endcapDisksPullsY, packedTopo, pullY);
762 
763  // if the detid has never occcurred yet, set the local orientations
764  if (resDetailsFPixX_.find(detid_db) == resDetailsFPixX_.end()) {
765  resDetailsFPixX_[detid_db].rDirection = gUDirection.perp() - gPModule.perp() >= 0 ? +1 : -1;
766  resDetailsFPixX_[detid_db].zDirection = gWDirection.z() - gPModule.z() >= 0 ? +1 : -1;
767  resDetailsFPixX_[detid_db].rOrZDirection =
768  resDetailsFPixX_[detid_db].zDirection; // endcaps (split in z)
769  }
770 
771  // if the detid has never occcurred yet, set the local orientations
772  if (resDetailsFPixY_.find(detid_db) == resDetailsFPixY_.end()) {
773  resDetailsFPixY_[detid_db].rDirection = gUDirection.perp() - gPModule.perp() >= 0 ? +1 : -1;
774  resDetailsFPixY_[detid_db].zDirection = gWDirection.z() - gPModule.z() >= 0 ? +1 : -1;
775  resDetailsFPixY_[detid_db].rOrZDirection =
776  resDetailsFPixY_[detid_db].zDirection; // endcaps (split in z)
777  }
778 
779  // update residuals X
780  this->updateOnlineMomenta(resDetailsFPixX_, detid_db, uOrientation * resX * cmToUm, pullX);
781 
782  // update residuals Y
783  this->updateOnlineMomenta(resDetailsFPixY_, detid_db, vOrientation * resY * cmToUm, pullY);
784 
785  if (side_num == 1) {
786  hHitCountVsXFPixMinus->Fill(GP.x());
787  hHitCountVsYFPixMinus->Fill(GP.y());
788  hHitCountVsZFPixMinus->Fill(GP.z());
789  hHitCountVsThetaFPixMinus->Fill(GP.theta());
790  hHitCountVsPhiFPixMinus->Fill(GP.phi());
791 
792  hFPixZMinusResXPrime->Fill(uOrientation * resX * cmToUm);
793  hFPixZMinusResYPrime->Fill(vOrientation * resY * cmToUm);
794  hFPixZMinusResXPull->Fill(pullX);
795  hFPixZMinusResYPull->Fill(pullY);
796 
797  } else {
798  hHitCountVsXFPixPlus->Fill(GP.x());
799  hHitCountVsYFPixPlus->Fill(GP.y());
800  hHitCountVsZFPixPlus->Fill(GP.z());
801  hHitCountVsThetaFPixPlus->Fill(GP.theta());
802  hHitCountVsPhiFPixPlus->Fill(GP.phi());
803 
804  hFPixZPlusResXPrime->Fill(uOrientation * resX * cmToUm);
805  hFPixZPlusResYPrime->Fill(vOrientation * resY * cmToUm);
806  hFPixZPlusResXPull->Fill(pullX);
807  hFPixZPlusResYPull->Fill(pullY);
808  }
809  }
810  }
811  }
812  }
813  }
814 
815  hHit2D->Fill(nHit2D);
816  hHit->Fill(track.numberOfValidHits());
817  hnhpxb->Fill(track.hitPattern().numberOfValidPixelBarrelHits());
818  hnhpxe->Fill(track.hitPattern().numberOfValidPixelEndcapHits());
819  hnhTIB->Fill(track.hitPattern().numberOfValidStripTIBHits());
820  hnhTID->Fill(track.hitPattern().numberOfValidStripTIDHits());
821  hnhTOB->Fill(track.hitPattern().numberOfValidStripTOBHits());
822  hnhTEC->Fill(track.hitPattern().numberOfValidStripTECHits());
823 
824  runHitsMap_[event.run()][0] += track.hitPattern().numberOfValidPixelBarrelHits();
825  runHitsMap_[event.run()][1] += track.hitPattern().numberOfValidPixelEndcapHits();
826  runHitsMap_[event.run()][2] += track.hitPattern().numberOfValidStripTIBHits();
827  runHitsMap_[event.run()][3] += track.hitPattern().numberOfValidStripTIDHits();
828  runHitsMap_[event.run()][4] += track.hitPattern().numberOfValidStripTOBHits();
829  runHitsMap_[event.run()][5] += track.hitPattern().numberOfValidStripTECHits();
830 
831  // fill hit composition histogram
832  if (track.hitPattern().numberOfValidPixelBarrelHits() != 0) {
833  hHitComposition->Fill(0., track.hitPattern().numberOfValidPixelBarrelHits());
834 
835  pNBpixHitsVsVx->Fill(track.vx(), track.hitPattern().numberOfValidPixelBarrelHits());
836  pNBpixHitsVsVy->Fill(track.vy(), track.hitPattern().numberOfValidPixelBarrelHits());
837  pNBpixHitsVsVz->Fill(track.vz(), track.hitPattern().numberOfValidPixelBarrelHits());
838  }
839  if (track.hitPattern().numberOfValidPixelEndcapHits() != 0) {
840  hHitComposition->Fill(1., track.hitPattern().numberOfValidPixelEndcapHits());
841  }
842  if (track.hitPattern().numberOfValidStripTIBHits() != 0) {
843  hHitComposition->Fill(2., track.hitPattern().numberOfValidStripTIBHits());
844  }
845  if (track.hitPattern().numberOfValidStripTIDHits() != 0) {
846  hHitComposition->Fill(3., track.hitPattern().numberOfValidStripTIDHits());
847  }
848  if (track.hitPattern().numberOfValidStripTOBHits() != 0) {
849  hHitComposition->Fill(4., track.hitPattern().numberOfValidStripTOBHits());
850  }
851  if (track.hitPattern().numberOfValidStripTECHits() != 0) {
852  hHitComposition->Fill(5., track.hitPattern().numberOfValidStripTECHits());
853  }
854 
855  hCharge->Fill(track.charge());
856  hQoverP->Fill(track.qoverp());
857  hQoverPZoom->Fill(track.qoverp());
858  hPt->Fill(track.pt());
859  hP->Fill(track.p());
860  hchi2ndof->Fill(track.normalizedChi2());
861  hEta->Fill(track.eta());
862  hPhi->Fill(track.phi());
863 
864  if (fabs(track.eta()) < 0.8)
865  hPhiBarrel->Fill(track.phi());
866  if (track.eta() > 0.8 && track.eta() < 1.4)
867  hPhiOverlapPlus->Fill(track.phi());
868  if (track.eta() < -0.8 && track.eta() > -1.4)
869  hPhiOverlapMinus->Fill(track.phi());
870  if (track.eta() > 1.4)
871  hPhiEndcapPlus->Fill(track.phi());
872  if (track.eta() < -1.4)
873  hPhiEndcapMinus->Fill(track.phi());
874 
875  hd0->Fill(track.d0());
876  hdz->Fill(track.dz());
877  hdxy->Fill(track.dxy());
878  hvx->Fill(track.vx());
879  hvy->Fill(track.vy());
880  hvz->Fill(track.vz());
881 
882  htrkAlgo->Fill(track.algo());
883 
884  int myquality = -99;
885  if (track.quality(reco::TrackBase::undefQuality)) {
886  myquality = -1;
887  htrkQuality->Fill(myquality);
888  }
889  if (track.quality(reco::TrackBase::loose)) {
890  myquality = 0;
891  htrkQuality->Fill(myquality);
892  }
893  if (track.quality(reco::TrackBase::tight)) {
894  myquality = 1;
895  htrkQuality->Fill(myquality);
896  }
897  if (track.quality(reco::TrackBase::highPurity) && (!isCosmics_)) {
898  myquality = 2;
899  htrkQuality->Fill(myquality);
900  hPhp->Fill(track.p());
901  hPthp->Fill(track.pt());
902  hHithp->Fill(track.numberOfValidHits());
903  hEtahp->Fill(track.eta());
904  hPhihp->Fill(track.phi());
905  hchi2ndofhp->Fill(track.normalizedChi2());
906  hchi2Probhp->Fill(TMath::Prob(track.chi2(), track.ndof()));
907  nHighPurityTracks++;
908  }
909  if (track.quality(reco::TrackBase::confirmed)) {
910  myquality = 3;
911  htrkQuality->Fill(myquality);
912  }
913  if (track.quality(reco::TrackBase::goodIterative)) {
914  myquality = 4;
915  htrkQuality->Fill(myquality);
916  }
917 
918  // Fill 1D track histos
919  static const int etaindex = this->GetIndex(vTrackHistos_, "h_tracketa");
920  vTrackHistos_[etaindex]->Fill(track.eta());
921  static const int phiindex = this->GetIndex(vTrackHistos_, "h_trackphi");
922  vTrackHistos_[phiindex]->Fill(track.phi());
923  static const int numOfValidHitsindex = this->GetIndex(vTrackHistos_, "h_trackNumberOfValidHits");
924  vTrackHistos_[numOfValidHitsindex]->Fill(track.numberOfValidHits());
925  static const int numOfLostHitsindex = this->GetIndex(vTrackHistos_, "h_trackNumberOfLostHits");
926  vTrackHistos_[numOfLostHitsindex]->Fill(track.numberOfLostHits());
927 
928  GlobalPoint gPoint(track.vx(), track.vy(), track.vz());
929  double theLocalMagFieldInInverseGeV = magneticField_->inInverseGeV(gPoint).z();
930  double kappa = -track.charge() * theLocalMagFieldInInverseGeV / track.pt();
931 
932  static const int kappaindex = this->GetIndex(vTrackHistos_, "h_curvature");
933  vTrackHistos_[kappaindex]->Fill(kappa);
934  static const int kappaposindex = this->GetIndex(vTrackHistos_, "h_curvature_pos");
935  if (track.charge() > 0)
936  vTrackHistos_[kappaposindex]->Fill(fabs(kappa));
937  static const int kappanegindex = this->GetIndex(vTrackHistos_, "h_curvature_neg");
938  if (track.charge() < 0)
939  vTrackHistos_[kappanegindex]->Fill(fabs(kappa));
940 
941  double chi2Prob = TMath::Prob(track.chi2(), track.ndof());
942  double normchi2 = track.normalizedChi2();
943 
944  static const int normchi2index = this->GetIndex(vTrackHistos_, "h_normchi2");
945  vTrackHistos_[normchi2index]->Fill(normchi2);
946  static const int chi2index = this->GetIndex(vTrackHistos_, "h_chi2");
947  vTrackHistos_[chi2index]->Fill(track.chi2());
948  static const int chi2Probindex = this->GetIndex(vTrackHistos_, "h_chi2Prob");
949  vTrackHistos_[chi2Probindex]->Fill(chi2Prob);
950  static const int ptindex = this->GetIndex(vTrackHistos_, "h_pt");
951  static const int pt2index = this->GetIndex(vTrackHistos_, "h_ptrebin");
952  vTrackHistos_[ptindex]->Fill(track.pt());
953  vTrackHistos_[pt2index]->Fill(track.pt());
954  if (track.ptError() != 0.) {
955  static const int ptResolutionindex = this->GetIndex(vTrackHistos_, "h_ptResolution");
956  vTrackHistos_[ptResolutionindex]->Fill(track.ptError() / track.pt());
957  }
958  // Fill track profiles
959  static const int d0phiindex = this->GetIndex(vTrackProfiles_, "p_d0_vs_phi");
960  vTrackProfiles_[d0phiindex]->Fill(track.phi(), track.d0());
961  static const int dzphiindex = this->GetIndex(vTrackProfiles_, "p_dz_vs_phi");
962  vTrackProfiles_[dzphiindex]->Fill(track.phi(), track.dz());
963  static const int d0etaindex = this->GetIndex(vTrackProfiles_, "p_d0_vs_eta");
964  vTrackProfiles_[d0etaindex]->Fill(track.eta(), track.d0());
965  static const int dzetaindex = this->GetIndex(vTrackProfiles_, "p_dz_vs_eta");
966  vTrackProfiles_[dzetaindex]->Fill(track.eta(), track.dz());
967  static const int chiProbphiindex = this->GetIndex(vTrackProfiles_, "p_chi2Prob_vs_phi");
968  vTrackProfiles_[chiProbphiindex]->Fill(track.phi(), chi2Prob);
969  static const int chiProbabsd0index = this->GetIndex(vTrackProfiles_, "p_chi2Prob_vs_d0");
970  vTrackProfiles_[chiProbabsd0index]->Fill(fabs(track.d0()), chi2Prob);
971  static const int chiProbabsdzindex = this->GetIndex(vTrackProfiles_, "p_chi2Prob_vs_dz");
972  vTrackProfiles_[chiProbabsdzindex]->Fill(track.dz(), chi2Prob);
973  static const int chiphiindex = this->GetIndex(vTrackProfiles_, "p_chi2_vs_phi");
974  vTrackProfiles_[chiphiindex]->Fill(track.phi(), track.chi2());
975  static const int normchiphiindex = this->GetIndex(vTrackProfiles_, "p_normchi2_vs_phi");
976  vTrackProfiles_[normchiphiindex]->Fill(track.phi(), normchi2);
977  static const int chietaindex = this->GetIndex(vTrackProfiles_, "p_chi2_vs_eta");
978  vTrackProfiles_[chietaindex]->Fill(track.eta(), track.chi2());
979  static const int normchiptindex = this->GetIndex(vTrackProfiles_, "p_normchi2_vs_pt");
980  vTrackProfiles_[normchiptindex]->Fill(track.pt(), normchi2);
981  static const int normchipindex = this->GetIndex(vTrackProfiles_, "p_normchi2_vs_p");
982  vTrackProfiles_[normchipindex]->Fill(track.p(), normchi2);
983  static const int chiProbetaindex = this->GetIndex(vTrackProfiles_, "p_chi2Prob_vs_eta");
984  vTrackProfiles_[chiProbetaindex]->Fill(track.eta(), chi2Prob);
985  static const int normchietaindex = this->GetIndex(vTrackProfiles_, "p_normchi2_vs_eta");
986  vTrackProfiles_[normchietaindex]->Fill(track.eta(), normchi2);
987  static const int kappaphiindex = this->GetIndex(vTrackProfiles_, "p_kappa_vs_phi");
988  vTrackProfiles_[kappaphiindex]->Fill(track.phi(), kappa);
989  static const int kappaetaindex = this->GetIndex(vTrackProfiles_, "p_kappa_vs_eta");
990  vTrackProfiles_[kappaetaindex]->Fill(track.eta(), kappa);
991  static const int ptResphiindex = this->GetIndex(vTrackProfiles_, "p_ptResolution_vs_phi");
992  vTrackProfiles_[ptResphiindex]->Fill(track.phi(), track.ptError() / track.pt());
993  static const int ptResetaindex = this->GetIndex(vTrackProfiles_, "p_ptResolution_vs_eta");
994  vTrackProfiles_[ptResetaindex]->Fill(track.eta(), track.ptError() / track.pt());
995 
996  // Fill 2D track histos
997  static const int d0phiindex_2d = this->GetIndex(vTrack2DHistos_, "h2_d0_vs_phi");
998  vTrack2DHistos_[d0phiindex_2d]->Fill(track.phi(), track.d0());
999  static const int dzphiindex_2d = this->GetIndex(vTrack2DHistos_, "h2_dz_vs_phi");
1000  vTrack2DHistos_[dzphiindex_2d]->Fill(track.phi(), track.dz());
1001  static const int d0etaindex_2d = this->GetIndex(vTrack2DHistos_, "h2_d0_vs_eta");
1002  vTrack2DHistos_[d0etaindex_2d]->Fill(track.eta(), track.d0());
1003  static const int dzetaindex_2d = this->GetIndex(vTrack2DHistos_, "h2_dz_vs_eta");
1004  vTrack2DHistos_[dzetaindex_2d]->Fill(track.eta(), track.dz());
1005  static const int chiphiindex_2d = this->GetIndex(vTrack2DHistos_, "h2_chi2_vs_phi");
1006  vTrack2DHistos_[chiphiindex_2d]->Fill(track.phi(), track.chi2());
1007  static const int chiProbphiindex_2d = this->GetIndex(vTrack2DHistos_, "h2_chi2Prob_vs_phi");
1008  vTrack2DHistos_[chiProbphiindex_2d]->Fill(track.phi(), chi2Prob);
1009  static const int chiProbabsd0index_2d = this->GetIndex(vTrack2DHistos_, "h2_chi2Prob_vs_d0");
1010  vTrack2DHistos_[chiProbabsd0index_2d]->Fill(fabs(track.d0()), chi2Prob);
1011  static const int normchiphiindex_2d = this->GetIndex(vTrack2DHistos_, "h2_normchi2_vs_phi");
1012  vTrack2DHistos_[normchiphiindex_2d]->Fill(track.phi(), normchi2);
1013  static const int chietaindex_2d = this->GetIndex(vTrack2DHistos_, "h2_chi2_vs_eta");
1014  vTrack2DHistos_[chietaindex_2d]->Fill(track.eta(), track.chi2());
1015  static const int chiProbetaindex_2d = this->GetIndex(vTrack2DHistos_, "h2_chi2Prob_vs_eta");
1016  vTrack2DHistos_[chiProbetaindex_2d]->Fill(track.eta(), chi2Prob);
1017  static const int normchietaindex_2d = this->GetIndex(vTrack2DHistos_, "h2_normchi2_vs_eta");
1018  vTrack2DHistos_[normchietaindex_2d]->Fill(track.eta(), normchi2);
1019  static const int kappaphiindex_2d = this->GetIndex(vTrack2DHistos_, "h2_kappa_vs_phi");
1020  vTrack2DHistos_[kappaphiindex_2d]->Fill(track.phi(), kappa);
1021  static const int kappaetaindex_2d = this->GetIndex(vTrack2DHistos_, "h2_kappa_vs_eta");
1022  vTrack2DHistos_[kappaetaindex_2d]->Fill(track.eta(), kappa);
1023  static const int normchi2kappa_2d = this->GetIndex(vTrack2DHistos_, "h2_normchi2_vs_kappa");
1024  vTrack2DHistos_[normchi2kappa_2d]->Fill(normchi2, kappa);
1025 
1026  //edm::LogVerbatim("DMRChecker") << "filling histos"<<std::endl;
1027 
1028  //dxy with respect to the beamspot
1030  edm::Handle<reco::BeamSpot> beamSpotHandle = event.getHandle(beamspotToken_);
1031  if (beamSpotHandle.isValid()) {
1032  beamSpot = *beamSpotHandle;
1033  math::XYZPoint point(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
1034  double dxy = track.dxy(point);
1035  double dz = track.dz(point);
1036  hdxyBS->Fill(dxy);
1037  hd0BS->Fill(-dxy);
1038  hdzBS->Fill(dz);
1039  }
1040 
1041  //dxy with respect to the primary vertex
1042  reco::Vertex pvtx;
1043  edm::Handle<reco::VertexCollection> vertexHandle = event.getHandle(vertexToken_);
1044  double mindxy = 100.;
1045  double dz = 100;
1046  if (vertexHandle.isValid()) {
1047  for (reco::VertexCollection::const_iterator pvtx = vertexHandle->begin(); pvtx != vertexHandle->end(); ++pvtx) {
1048  math::XYZPoint mypoint(pvtx->x(), pvtx->y(), pvtx->z());
1049  if (abs(mindxy) > abs(track.dxy(mypoint))) {
1050  mindxy = track.dxy(mypoint);
1051  dz = track.dz(mypoint);
1052  //edm::LogVerbatim("DMRChecker")<<"dxy: "<<mindxy<<"dz: "<<dz<<std::endl;
1053  }
1054  }
1055 
1056  hdxyPV->Fill(mindxy);
1057  hd0PV->Fill(-mindxy);
1058  hdzPV->Fill(dz);
1059 
1060  hd0PVvsphi->Fill(track.phi(), -mindxy);
1061  hd0PVvseta->Fill(track.eta(), -mindxy);
1062  hd0PVvspt->Fill(track.pt(), -mindxy);
1063 
1064  } else {
1065  hdxyPV->Fill(100);
1066  hd0PV->Fill(100);
1067  hdzPV->Fill(100);
1068  }
1069 
1070  // edm::LogVerbatim("DMRChecker")<<"end of track loop"<<std::endl;
1071  }
1072 
1073  // edm::LogVerbatim("DMRChecker")<<"end of analysis"<<std::endl;
1074 
1075  hNtrk->Fill(tC.size());
1076  hNtrkZoom->Fill(tC.size());
1077  hNhighPurity->Fill(nHighPurityTracks);
1078 
1079  // edm::LogVerbatim("DMRChecker")<<"end of analysis"<<std::endl;
1080  }
1081 
1082  void beginJob() override {
1083  if (DEBUG)
1084  edm::LogVerbatim("DMRChecker") << __LINE__ << endl;
1085 
1086  TH1D::SetDefaultSumw2(kTRUE);
1087 
1088  ievt = 0;
1089  itrks = 0;
1090 
1091  hrun = fs->make<TH1D>("h_run", "run", 100000, 230000, 240000);
1092  hlumi = fs->make<TH1D>("h_lumi", "lumi", 1000, 0, 1000);
1093 
1094  // clang-format off
1095 
1096  hchi2ndof = fs->make<TH1D>("h_chi2ndof", "chi2/ndf;#chi^{2}/ndf;tracks", 100, 0, 5.);
1097  hCharge = fs->make<TH1D>("h_charge", "charge;Charge of the track;tracks", 5, -2.5, 2.5);
1098  hNtrk = fs->make<TH1D>("h_Ntrk", "ntracks;Number of Tracks;events", 200, 0., 200.);
1099  hNtrkZoom = fs->make<TH1D>("h_NtrkZoom", "Number of tracks; number of tracks;events", 10, 0., 10.);
1100  hNhighPurity = fs->make<TH1D>("h_NhighPurity", "n. high purity tracks;Number of high purity tracks;events", 200, 0., 200.);
1101 
1102  int nAlgos = reco::TrackBase::algoSize;
1103  htrkAlgo = fs->make<TH1I>("h_trkAlgo", "tracking step;iterative tracking step;tracks", nAlgos, -0.5, nAlgos - 0.5);
1104  for (int nbin = 1; nbin <= htrkAlgo->GetNbinsX(); nbin++) {
1105  htrkAlgo->GetXaxis()->SetBinLabel(nbin, reco::TrackBase::algoNames[nbin - 1].c_str());
1106  }
1107 
1108  htrkQuality = fs->make<TH1I>("h_trkQuality", "track quality;track quality;tracks", 6, -1, 5);
1109  std::string qualities[7] = {"undef", "loose", "tight", "highPurity", "confirmed", "goodIterative"};
1110  for (int nbin = 1; nbin <= htrkQuality->GetNbinsX(); nbin++) {
1111  htrkQuality->GetXaxis()->SetBinLabel(nbin, qualities[nbin - 1].c_str());
1112  }
1113 
1114  hP = fs->make<TH1D>("h_P", "Momentum;track momentum [GeV];tracks", 100, 0., 100.);
1115  hQoverP = fs->make<TH1D>("h_qoverp", "Track q/p; track q/p [GeV^{-1}];tracks", 100, -1., 1.);
1116  hQoverPZoom = fs->make<TH1D>("h_qoverpZoom", "Track q/p; track q/p [GeV^{-1}];tracks", 100, -0.1, 0.1);
1117  hPt = fs->make<TH1D>("h_Pt", "Transverse Momentum;track p_{T} [GeV];tracks", 100, 0., 100.);
1118  hHit = fs->make<TH1D>("h_nHits", "Number of hits;track n. hits;tracks", 50, -0.5, 49.5);
1119  hHit2D = fs->make<TH1D>("h_nHit2D", "Number of 2D hits; number of 2D hits;tracks", 20, 0, 20);
1120 
1121  // Pixel
1122 
1123  hBPixResXPrime = fs->make<TH1D>("h_BPixResXPrime", "BPix track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1124  hFPixResXPrime = fs->make<TH1D>("h_FPixResXPrime", "FPix track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1125  hFPixZPlusResXPrime = fs->make<TH1D>("h_FPixZPlusResXPrime", "FPix (Z+) track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1126  hFPixZMinusResXPrime = fs->make<TH1D>("h_FPixZMinusResXPrime", "FPix (Z-) track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1127 
1128  hBPixResYPrime = fs->make<TH1D>("h_BPixResYPrime", "BPix track Y-residuals;res_{Y'} [#mum];hits", 100, -1000., 1000.);
1129  hFPixResYPrime = fs->make<TH1D>("h_FPixResYPrime", "FPix track Y-residuals;res_{Y'} [#mum];hits", 100, -1000., 1000.);
1130  hFPixZPlusResYPrime = fs->make<TH1D>("h_FPixZPlusResYPrime", "FPix (Z+) track Y-residuals;res_{Y'} [#mum];hits", 100, -1000., 1000.);
1131  hFPixZMinusResYPrime = fs->make<TH1D>("h_FPixZMinusResYPrime", "FPix (Z-) track Y-residuals;res_{Y'} [#mum];hits", 100, -1000., 1000.);
1132 
1133  hBPixResXPull = fs->make<TH1D>("h_BPixResXPull", "BPix track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1134  hFPixResXPull = fs->make<TH1D>("h_FPixResXPull", "FPix track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1135  hFPixZPlusResXPull = fs->make<TH1D>("h_FPixZPlusResXPull", "FPix (Z+) track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1136  hFPixZMinusResXPull = fs->make<TH1D>("h_FPixZMinusResXPull", "FPix (Z-) track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1137 
1138  hBPixResYPull = fs->make<TH1D>("h_BPixResYPull", "BPix track Y-pulls;res_{Y'}/#sigma_{res_{Y'}};hits", 100, -5., 5.);
1139  hFPixResYPull = fs->make<TH1D>("h_FPixResYPull", "FPix track Y-pulls;res_{Y'}/#sigma_{res_{Y'}};hits", 100, -5., 5.);
1140  hFPixZPlusResYPull = fs->make<TH1D>("h_FPixZPlusResYPull", "FPix (Z+) track Y-pulls;res_{Y'}/#sigma_{res_{Y'}};hits", 100, -5., 5.);
1141  hFPixZMinusResYPull = fs->make<TH1D>("h_FPixZMinusResYPull", "FPix (Z-) track Y-pulls;res_{Y'}/#sigma_{res_{Y'}};hits", 100, -5., 5.);
1142 
1143  // Strips
1144 
1145  hTIBResXPrime = fs->make<TH1D>("h_TIBResXPrime", "TIB track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1146  hTOBResXPrime = fs->make<TH1D>("h_TOBResXPrime", "TOB track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1147  hTIDResXPrime = fs->make<TH1D>("h_TIDResXPrime", "TID track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1148  hTECResXPrime = fs->make<TH1D>("h_TECResXPrime", "TEC track X-residuals;res_{X'} [#mum];hits", 100, -1000., 1000.);
1149 
1150  hTIBResXPull = fs->make<TH1D>("h_TIBResXPull", "TIB track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1151  hTOBResXPull = fs->make<TH1D>("h_TOBResXPull", "TOB track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1152  hTIDResXPull = fs->make<TH1D>("h_TIDResXPull", "TID track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1153  hTECResXPull = fs->make<TH1D>("h_TECResXPull", "TEC track X-pulls;res_{X'}/#sigma_{res_{X'}};hits", 100, -5., 5.);
1154 
1155  // hit counts
1156 
1157  hHitCountVsZBPix = fs->make<TH1D>("h_HitCountVsZBpix", "Number of BPix hits vs z;hit global z;hits", 60, -30, 30);
1158  hHitCountVsZFPix = fs->make<TH1D>("h_HitCountVsZFpix", "Number of FPix hits vs z;hit global z;hits", 100, -100, 100);
1159 
1160  hHitCountVsXBPix = fs->make<TH1D>("h_HitCountVsXBpix", "Number of BPix hits vs x;hit global x;hits", 20, -20, 20);
1161  hHitCountVsXFPix = fs->make<TH1D>("h_HitCountVsXFpix", "Number of FPix hits vs x;hit global x;hits", 20, -20, 20);
1162 
1163  hHitCountVsYBPix = fs->make<TH1D>("h_HitCountVsYBpix", "Number of BPix hits vs y;hit global y;hits", 20, -20, 20);
1164  hHitCountVsYFPix = fs->make<TH1D>("h_HitCountVsYFpix", "Number of FPix hits vs y;hit global y;hits", 20, -20, 20);
1165 
1166  hHitCountVsThetaBPix = fs->make<TH1D>("h_HitCountVsThetaBpix", "Number of BPix hits vs #theta;hit global #theta;hits", 20, 0., M_PI);
1167  hHitCountVsPhiBPix = fs->make<TH1D>("h_HitCountVsPhiBpix", "Number of BPix hits vs #phi;hit global #phi;hits", 20, -M_PI, M_PI);
1168 
1169  hHitCountVsThetaFPix = fs->make<TH1D>("h_HitCountVsThetaFpix", "Number of FPix hits vs #theta;hit global #theta;hits", 40, 0., M_PI);
1170  hHitCountVsPhiFPix = fs->make<TH1D>("h_HitCountVsPhiFpix", "Number of FPix hits vs #phi;hit global #phi;hits", 20, -M_PI, M_PI);
1171 
1172  // two sides of FPix
1173 
1174  hHitCountVsZFPixPlus = fs->make<TH1D>("h_HitCountVsZFPixPlus", "Number of FPix(Z+) hits vs z;hit global z;hits", 60, 15., 60);
1175  hHitCountVsZFPixMinus = fs->make<TH1D>("h_HitCountVsZFPixMinus", "Number of FPix(Z-) hits vs z;hit global z;hits", 100, -60., -15.);
1176 
1177  hHitCountVsXFPixPlus = fs->make<TH1D>("h_HitCountVsXFPixPlus", "Number of FPix(Z+) hits vs x;hit global x;hits", 20, -20, 20);
1178  hHitCountVsXFPixMinus = fs->make<TH1D>("h_HitCountVsXFPixMinus", "Number of FPix(Z-) hits vs x;hit global x;hits", 20, -20, 20);
1179 
1180  hHitCountVsYFPixPlus = fs->make<TH1D>("h_HitCountVsYFPixPlus", "Number of FPix(Z+) hits vs y;hit global y;hits", 20, -20, 20);
1181  hHitCountVsYFPixMinus = fs->make<TH1D>("h_HitCountVsYFPixMinus", "Number of FPix(Z-) hits vs y;hit global y;hits", 20, -20, 20);
1182 
1183  hHitCountVsThetaFPixPlus = fs->make<TH1D>("h_HitCountVsThetaFPixPlus", "Number of FPix(Z+) hits vs #theta;hit global #theta;hits", 20, 0., M_PI);
1184  hHitCountVsPhiFPixPlus = fs->make<TH1D>("h_HitCountVsPhiFPixPlus","Number of FPix(Z+) hits vs #phi;hit global #phi;hits",20,-M_PI,M_PI);
1185 
1186  hHitCountVsThetaFPixMinus = fs->make<TH1D>("h_HitCountVsThetaFPixMinus", "Number of FPix(Z+) hits vs #theta;hit global #theta;hits", 40, 0., M_PI);
1187  hHitCountVsPhiFPixMinus = fs->make<TH1D>("h_HitCountVsPhiFPixMinus","Number of FPix(Z+) hits vs #phi;hit global #phi;hits",20,-M_PI,M_PI);
1188 
1189  TFileDirectory ByLayerResiduals = fs->mkdir("ByLayerResiduals");
1190  barrelLayersResidualsX = bookResidualsHistogram(ByLayerResiduals, 4, "X", "Res", "BPix");
1191  endcapDisksResidualsX = bookResidualsHistogram(ByLayerResiduals, 6, "X", "Res", "FPix");
1192  barrelLayersResidualsY = bookResidualsHistogram(ByLayerResiduals, 4, "Y", "Res", "BPix");
1193  endcapDisksResidualsY = bookResidualsHistogram(ByLayerResiduals, 6, "Y", "Res", "FPix");
1194 
1195  TFileDirectory ByLayerPulls = fs->mkdir("ByLayerPulls");
1196  barrelLayersPullsX = bookResidualsHistogram(ByLayerPulls, 4, "X", "Pull", "BPix");
1197  endcapDisksPullsX = bookResidualsHistogram(ByLayerPulls, 6, "X", "Pull", "FPix");
1198  barrelLayersPullsY = bookResidualsHistogram(ByLayerPulls, 4, "Y", "Pull", "BPix");
1199  endcapDisksPullsY = bookResidualsHistogram(ByLayerPulls, 6, "Y", "Pull", "FPix");
1200 
1201  hEta = fs->make<TH1D>("h_Eta", "Track pseudorapidity; track #eta;tracks", 100, -M_PI, M_PI);
1202  hPhi = fs->make<TH1D>("h_Phi", "Track azimuth; track #phi;tracks", 100, -M_PI, M_PI);
1203 
1204  hPhiBarrel = fs->make<TH1D>("h_PhiBarrel", "hPhiBarrel (0<|#eta|<0.8);track #Phi;tracks", 100, -M_PI, M_PI);
1205  hPhiOverlapPlus = fs->make<TH1D>("h_PhiOverlapPlus", "hPhiOverlapPlus (0.8<#eta<1.4);track #phi;tracks", 100, -M_PI, M_PI);
1206  hPhiOverlapMinus = fs->make<TH1D>("h_PhiOverlapMinus", "hPhiOverlapMinus (-1.4<#eta<-0.8);track #phi;tracks", 100, -M_PI, M_PI);
1207  hPhiEndcapPlus = fs->make<TH1D>("h_PhiEndcapPlus", "hPhiEndcapPlus (#eta>1.4);track #phi;track", 100, -M_PI, M_PI);
1208  hPhiEndcapMinus = fs->make<TH1D>("h_PhiEndcapMinus", "hPhiEndcapMinus (#eta<1.4);track #phi;tracks", 100, -M_PI, M_PI);
1209 
1210  if (!isCosmics_) {
1211  hPhp = fs->make<TH1D>("h_P_hp", "Momentum (high purity);track momentum [GeV];tracks", 100, 0., 100.);
1212  hPthp = fs->make<TH1D>("h_Pt_hp", "Transverse Momentum (high purity);track p_{T} [GeV];tracks", 100, 0., 100.);
1213  hHithp = fs->make<TH1D>("h_nHit_hp", "Number of hits (high purity);track n. hits;tracks", 30, 0, 30);
1214  hEtahp = fs->make<TH1D>("h_Eta_hp", "Track pseudorapidity (high purity); track #eta;tracks", 100, -M_PI, M_PI);
1215  hPhihp = fs->make<TH1D>("h_Phi_hp", "Track azimuth (high purity); track #phi;tracks", 100, -M_PI, M_PI);
1216  hchi2ndofhp = fs->make<TH1D>("h_chi2ndof_hp", "chi2/ndf (high purity);#chi^{2}/ndf;tracks", 100, 0, 5.);
1217  hchi2Probhp = fs->make<TH1D>("hchi2_Prob_hp", "#chi^{2} probability (high purity);#chi^{2}prob_{Track};Number of Tracks", 100, 0.0, 1.);
1218 
1219  hvx = fs->make<TH1D>("h_vx", "Track v_{x} ; track v_{x} [cm];tracks", 100, -1.5, 1.5);
1220  hvy = fs->make<TH1D>("h_vy", "Track v_{y} ; track v_{y} [cm];tracks", 100, -1.5, 1.5);
1221  hvz = fs->make<TH1D>("h_vz", "Track v_{z} ; track v_{z} [cm];tracks", 100, -20., 20.);
1222  hd0 = fs->make<TH1D>("h_d0", "Track d_{0} ; track d_{0} [cm];tracks", 100, -1., 1.);
1223  hdxy = fs->make<TH1D>("h_dxy", "Track d_{xy}; track d_{xy} [cm]; tracks", 100, -0.5, 0.5);
1224  hdz = fs->make<TH1D>("h_dz", "Track d_{z} ; track d_{z} [cm]; tracks", 100, -20, 20);
1225 
1226  hd0PVvsphi = fs->make<TH2D>("h2_d0PVvsphi", "hd0PVvsphi;track #phi;track d_{0}(PV) [cm]", 160, -M_PI, M_PI, 100, -1., 1.);
1227  hd0PVvseta = fs->make<TH2D>("h2_d0PVvseta", "hdPV0vseta;track #eta;track d_{0}(PV) [cm]", 160, -2.5, 2.5, 100, -1., 1.);
1228  hd0PVvspt = fs->make<TH2D>("h2_d0PVvspt", "hdPV0vspt;track p_{T};d_{0}(PV) [cm]", 50, 0., 100., 100, -1, 1.);
1229 
1230  hdxyBS = fs->make<TH1D>("h_dxyBS", "hdxyBS; track d_{xy}(BS) [cm];tracks", 100, -0.1, 0.1);
1231  hd0BS = fs->make<TH1D>("h_d0BS", "hd0BS ; track d_{0}(BS) [cm];tracks", 100, -0.1, 0.1);
1232  hdzBS = fs->make<TH1D>("h_dzBS", "hdzBS ; track d_{z}(BS) [cm];tracks", 100, -12, 12);
1233  hdxyPV = fs->make<TH1D>("h_dxyPV", "hdxyPV; track d_{xy}(PV) [cm];tracks", 100, -0.1, 0.1);
1234  hd0PV = fs->make<TH1D>("h_d0PV", "hd0PV ; track d_{0}(PV) [cm];tracks", 100, -0.15, 0.15);
1235  hdzPV = fs->make<TH1D>("h_dzPV", "hdzPV ; track d_{z}(PV) [cm];tracks", 100, -0.1, 0.1);
1236 
1237  hnhTIB = fs->make<TH1D>("h_nHitTIB", "nhTIB;# hits in TIB; tracks", 20, 0., 20.);
1238  hnhTID = fs->make<TH1D>("h_nHitTID", "nhTID;# hits in TID; tracks", 20, 0., 20.);
1239  hnhTOB = fs->make<TH1D>("h_nHitTOB", "nhTOB;# hits in TOB; tracks", 20, 0., 20.);
1240  hnhTEC = fs->make<TH1D>("h_nHitTEC", "nhTEC;# hits in TEC; tracks", 20, 0., 20.);
1241 
1242  } else {
1243  hvx = fs->make<TH1D>("h_vx", "Track v_{x};track v_{x} [cm];tracks", 100, -100., 100.);
1244  hvy = fs->make<TH1D>("h_vy", "Track v_{y};track v_{y} [cm];tracks", 100, -100., 100.);
1245  hvz = fs->make<TH1D>("h_vz", "Track v_{z};track v_{z} [cm];track", 100, -100., 100.);
1246  hd0 = fs->make<TH1D>("h_d0", "Track d_{0};track d_{0} [cm];track", 100, -100., 100.);
1247  hdxy = fs->make<TH1D>("h_dxy", "Track d_{xy};track d_{xy} [cm];tracks", 100, -100, 100);
1248  hdz = fs->make<TH1D>("h_dz", "Track d_{z};track d_{z} [cm];tracks", 100, -200, 200);
1249 
1250  hd0vsphi = fs->make<TH2D>("h2_d0vsphi", "Track d_{0} vs #phi; track #phi;track d_{0} [cm]", 160, -3.20, 3.20, 100, -100., 100.);
1251  hd0vseta = fs->make<TH2D>("h2_d0vseta", "Track d_{0} vs #eta; track #eta;track d_{0} [cm]", 160, -3.20, 3.20, 100, -100., 100.);
1252  hd0vspt = fs->make<TH2D>("h2_d0vspt", "Track d_{0} vs p_{T};track p_{T};track d_{0} [cm]", 50, 0., 100., 100, -100, 100);
1253 
1254  hdxyBS = fs->make<TH1D>("h_dxyBS", "Track d_{xy}(BS);d_{xy}(BS) [cm];tracks", 100, -100., 100.);
1255  hd0BS = fs->make<TH1D>("h_d0BS", "Track d_{0}(BS);d_{0}(BS) [cm];tracks", 100, -100., 100.);
1256  hdzBS = fs->make<TH1D>("h_dzBS", "Track d_{z}(BS);d_{z}(BS) [cm];tracks", 100, -100., 100.);
1257  hdxyPV = fs->make<TH1D>("h_dxyPV", "Track d_{xy}(PV); d_{xy}(PV) [cm];tracks", 100, -100., 100.);
1258  hd0PV = fs->make<TH1D>("h_d0PV", "Track d_{0}(PV); d_{0}(PV) [cm];tracks", 100, -100., 100.);
1259  hdzPV = fs->make<TH1D>("h_dzPV", "Track d_{z}(PV); d_{z}(PV) [cm];tracks", 100, -100., 100.);
1260 
1261  hnhTIB = fs->make<TH1D>("h_nHitTIB", "nhTIB;# hits in TIB; tracks", 30, 0., 30.);
1262  hnhTID = fs->make<TH1D>("h_nHitTID", "nhTID;# hits in TID; tracks", 30, 0., 30.);
1263  hnhTOB = fs->make<TH1D>("h_nHitTOB", "nhTOB;# hits in TOB; tracks", 30, 0., 30.);
1264  hnhTEC = fs->make<TH1D>("h_nHitTEC", "nhTEC;# hits in TEC; tracks", 30, 0., 30.);
1265  }
1266 
1267  hnhpxb = fs->make<TH1D>("h_nHitPXB", "nhpxb;# hits in Pixel Barrel; tracks", 10, 0., 10.);
1268  hnhpxe = fs->make<TH1D>("h_nHitPXE", "nhpxe;# hits in Pixel Endcap; tracks", 10, 0., 10.);
1269 
1270  hHitComposition = fs->make<TH1D>("h_hitcomposition", "track hit composition;;# hits", 6, -0.5, 5.5);
1271  pNBpixHitsVsVx = fs->make<TProfile>("p_NpixHits_vs_Vx", "n. Barrel Pixel hits vs. v_{x};v_{x} (cm);n. BPix hits", 20, -20, 20);
1272  pNBpixHitsVsVy = fs->make<TProfile>("p_NpixHits_vs_Vy", "n. Barrel Pixel hits vs. v_{y};v_{y} (cm);n. BPix hits", 20, -20, 20);
1273  pNBpixHitsVsVz = fs->make<TProfile>("p_NpixHits_vs_Vz", "n. Barrel Pixel hits vs. v_{z};v_{z} (cm);n. BPix hits", 20, -100, 100);
1274 
1275  std::string dets[6] = {"PXB", "PXF", "TIB", "TID", "TOB", "TEC"};
1276  for (int i = 1; i <= hHitComposition->GetNbinsX(); i++) {
1277  hHitComposition->GetXaxis()->SetBinLabel(i, dets[i - 1].c_str());
1278  }
1279 
1280  vTrackHistos_.push_back(fs->make<TH1F>("h_tracketa", "Track #eta;#eta_{Track};Number of Tracks", 90, -3., 3.));
1281  vTrackHistos_.push_back(fs->make<TH1F>("h_trackphi", "Track #phi;#phi_{Track};Number of Tracks", 90, -M_PI, M_PI));
1282  vTrackHistos_.push_back(fs->make<TH1F>("h_trackNumberOfValidHits", "Track # of valid hits;# of valid hits _{Track};Number of Tracks", 40, 0., 40.));
1283  vTrackHistos_.push_back(fs->make<TH1F>("h_trackNumberOfLostHits", "Track # of lost hits;# of lost hits _{Track};Number of Tracks", 10, 0., 10.));
1284  vTrackHistos_.push_back(fs->make<TH1F>("h_curvature", "Curvature #kappa;#kappa_{Track};Number of Tracks", 100, -.05, .05));
1285  vTrackHistos_.push_back(fs->make<TH1F>("h_curvature_pos", "Curvature |#kappa| Positive Tracks;|#kappa_{pos Track}|;Number of Tracks", 100, .0, .05));
1286  vTrackHistos_.push_back(fs->make<TH1F>("h_curvature_neg", "Curvature |#kappa| Negative Tracks;|#kappa_{neg Track}|;Number of Tracks", 100, .0, .05));
1287  vTrackHistos_.push_back(fs->make<TH1F>("h_diff_curvature", "Curvature |#kappa| Tracks Difference;|#kappa_{Track}|;# Pos Tracks - # Neg Tracks", 100,.0,.05));
1288 
1289  vTrackHistos_.push_back(fs->make<TH1F>("h_chi2", "Track #chi^{2};#chi^{2}_{Track};Number of Tracks", 500, -0.01, 500.));
1290  vTrackHistos_.push_back(fs->make<TH1F>("h_chi2Prob", "#chi^{2} probability;Track Prob(#chi^{2},ndof);Number of Tracks", 100, 0.0, 1.));
1291  vTrackHistos_.push_back(fs->make<TH1F>("h_normchi2", "#chi^{2}/ndof;#chi^{2}/ndof;Number of Tracks", 100, -0.01, 10.));
1292 
1293  //variable binning for chi2/ndof vs. pT
1294  double xBins[19] = {0., 0.15, 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 7., 10., 15., 25., 40., 100., 200.};
1295  vTrackHistos_.push_back(fs->make<TH1F>("h_pt", "Track p_{T};p_{T}^{track} [GeV];Number of Tracks", 250, 0., 250));
1296  vTrackHistos_.push_back(fs->make<TH1F>("h_ptrebin", "Track p_{T};p_{T}^{track} [GeV];Number of Tracks", 18, xBins));
1297 
1298  vTrackHistos_.push_back(fs->make<TH1F>("h_ptResolution", "#delta_{p_{T}}/p_{T}^{track};#delta_{p_{T}}/p_{T}^{track};Number of Tracks", 100, 0., 0.5));
1299  vTrackProfiles_.push_back(fs->make<TProfile>("p_d0_vs_phi", "Transverse Impact Parameter vs. #phi;#phi_{Track};#LT d_{0} #GT [cm]", 100, -M_PI, M_PI));
1300  vTrackProfiles_.push_back(fs->make<TProfile>("p_dz_vs_phi", "Longitudinal Impact Parameter vs. #phi;#phi_{Track};#LT d_{z} #GT [cm]", 100, -M_PI, M_PI));
1301  vTrackProfiles_.push_back(fs->make<TProfile>("p_d0_vs_eta", "Transverse Impact Parameter vs. #eta;#eta_{Track};#LT d_{0} #GT [cm]", 100, -M_PI, M_PI));
1302  vTrackProfiles_.push_back(fs->make<TProfile>("p_dz_vs_eta", "Longitudinal Impact Parameter vs. #eta;#eta_{Track};#LT d_{z} #GT [cm]", 100, -M_PI, M_PI));
1303  vTrackProfiles_.push_back(fs->make<TProfile>("p_chi2_vs_phi", "#chi^{2} vs. #phi;#phi_{Track};#LT #chi^{2} #GT", 100, -M_PI, M_PI));
1304  vTrackProfiles_.push_back(fs->make<TProfile>("p_chi2Prob_vs_phi","#chi^{2} probablility vs. #phi;#phi_{Track};#LT #chi^{2} probability#GT",100,-M_PI,M_PI));
1305  vTrackProfiles_.push_back(fs->make<TProfile>("p_chi2Prob_vs_d0", "#chi^{2} probablility vs. |d_{0}|;|d_{0}|[cm];#LT #chi^{2} probability#GT", 100, 0, 80));
1306  vTrackProfiles_.push_back(fs->make<TProfile>("p_chi2Prob_vs_dz", "#chi^{2} probablility vs. dz;d_{z} [cm];#LT #chi^{2} probability#GT", 100, -30, 30));
1307  vTrackProfiles_.push_back(fs->make<TProfile>("p_normchi2_vs_phi", "#chi^{2}/ndof vs. #phi;#phi_{Track};#LT #chi^{2}/ndof #GT", 100, -M_PI, M_PI));
1308  vTrackProfiles_.push_back(fs->make<TProfile>("p_chi2_vs_eta", "#chi^{2} vs. #eta;#eta_{Track};#LT #chi^{2} #GT", 100, -M_PI, M_PI));
1309  vTrackProfiles_.push_back(fs->make<TProfile>("p_normchi2_vs_pt", "norm #chi^{2} vs. p_{T}_{Track}; p_{T}_{Track};#LT #chi^{2}/ndof #GT", 18, xBins));
1310  vTrackProfiles_.push_back(fs->make<TProfile>("p_normchi2_vs_p", "#chi^{2}/ndof vs. p_{Track};p_{Track};#LT #chi^{2}/ndof #GT", 18, xBins));
1311  vTrackProfiles_.push_back(fs->make<TProfile>("p_chi2Prob_vs_eta","#chi^{2} probability vs. #eta;#eta_{Track};#LT #chi^{2} probability #GT",100,-M_PI,M_PI));
1312  vTrackProfiles_.push_back(fs->make<TProfile>("p_normchi2_vs_eta", "#chi^{2}/ndof vs. #eta;#eta_{Track};#LT #chi^{2}/ndof #GT", 100, -M_PI, M_PI));
1313  vTrackProfiles_.push_back(fs->make<TProfile>("p_kappa_vs_phi", "#kappa vs. #phi;#phi_{Track};#kappa", 100, -M_PI, M_PI));
1314  vTrackProfiles_.push_back(fs->make<TProfile>("p_kappa_vs_eta", "#kappa vs. #eta;#eta_{Track};#kappa", 100, -M_PI, M_PI));
1315  vTrackProfiles_.push_back(fs->make<TProfile>("p_ptResolution_vs_phi","#delta_{p_{T}}/p_{T}^{track};#phi^{track};#delta_{p_{T}}/p_{T}^{track}",100,-M_PI,M_PI));
1316  vTrackProfiles_.push_back(fs->make<TProfile>("p_ptResolution_vs_eta","#delta_{p_{T}}/p_{T}^{track};#eta^{track};#delta_{p_{T}}/p_{T}^{track}",100,-M_PI,M_PI));
1317  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_d0_vs_phi","Transverse Impact Parameter vs. #phi;#phi_{Track};d_{0} [cm]", 100, -M_PI, M_PI, 100, -1., 1.));
1318  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_dz_vs_phi","Longitudinal Impact Parameter vs. #phi;#phi_{Track};d_{z} [cm]",100,-M_PI,M_PI,100,-100.,100.));
1319  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_d0_vs_eta","Transverse Impact Parameter vs. #eta;#eta_{Track};d_{0} [cm]", 100, -M_PI, M_PI, 100, -1., 1.));
1320  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_dz_vs_eta","Longitudinal Impact Parameter vs. #eta;#eta_{Track};d_{z} [cm]",100,-M_PI,M_PI, 100,-100.,100.));
1321  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_chi2_vs_phi", "#chi^{2} vs. #phi;#phi_{Track};#chi^{2}", 100, -M_PI, M_PI, 500, 0., 500.));
1322  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_chi2Prob_vs_phi","#chi^{2} probability vs. #phi;#phi_{Track};#chi^{2} probability",100,-M_PI,M_PI,100,0.,1.));
1323  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_chi2Prob_vs_d0","#chi^{2} probability vs. |d_{0}|;|d_{0}| [cm];#chi^{2} probability",100,0,80,100,0.,1.));
1324  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_normchi2_vs_phi", "#chi^{2}/ndof vs. #phi;#phi_{Track};#chi^{2}/ndof", 100, -M_PI, M_PI, 100, 0., 10.));
1325  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_chi2_vs_eta", "#chi^{2} vs. #eta;#eta_{Track};#chi^{2}", 100, -M_PI, M_PI, 500, 0., 500.));
1326  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_chi2Prob_vs_eta","#chi^{2} probaility vs. #eta;#eta_{Track};#chi^{2} probability",100,-M_PI,M_PI,100,0.,1.));
1327  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_normchi2_vs_eta", "#chi^{2}/ndof vs. #eta;#eta_{Track};#chi^{2}/ndof", 100, -M_PI, M_PI, 100, 0., 10.));
1328  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_kappa_vs_phi", "#kappa vs. #phi;#phi_{Track};#kappa", 100, -M_PI, M_PI, 100, .0, .05));
1329  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_kappa_vs_eta", "#kappa vs. #eta;#eta_{Track};#kappa", 100, -M_PI, M_PI, 100, .0, .05));
1330  vTrack2DHistos_.push_back(fs->make<TH2F>("h2_normchi2_vs_kappa", "#kappa vs. #chi^{2}/ndof;#chi^{2}/ndof;#kappa", 100, 0., 10, 100, -.03, .03));
1331 
1332  // clang-format on
1333 
1334  firstEvent_ = true;
1335 
1336  // create the full maps
1337  fullPixelmapXDMR->createTrackerBaseMap();
1338  fullPixelmapYDMR->createTrackerBaseMap();
1339 
1340  } //beginJob
1341 
1342  void endJob() override {
1343  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1344  edm::LogPrint("DMRChecker") << "Events run in total: " << ievt << std::endl;
1345  edm::LogPrint("DMRChecker") << "n. tracks: " << itrks << std::endl;
1346  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1347 
1348  int nFiringTriggers = triggerMap_.size();
1349  edm::LogPrint("DMRChecker") << "firing triggers: " << nFiringTriggers << std::endl;
1350  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1351 
1352  tksByTrigger_ = fs->make<TH1D>(
1353  "tksByTrigger", "tracks by HLT path;;% of # traks", nFiringTriggers, -0.5, nFiringTriggers - 0.5);
1354  evtsByTrigger_ = fs->make<TH1D>(
1355  "evtsByTrigger", "events by HLT path;;% of # events", nFiringTriggers, -0.5, nFiringTriggers - 0.5);
1356 
1357  int i = 0;
1358 
1359  for (std::map<std::string, std::pair<int, int> >::iterator it = triggerMap_.begin(); it != triggerMap_.end();
1360  ++it) {
1361  i++;
1362 
1363  double trkpercent = ((it->second).second) * 100. / double(itrks);
1364  double evtpercent = ((it->second).first) * 100. / double(ievt);
1365 
1366  std::cout.precision(4);
1367 
1368  edm::LogPrint("DMRChecker") << "HLT path: " << std::setw(60) << left << it->first << " | events firing: " << right
1369  << std::setw(8) << (it->second).first << " (" << setw(8) << fixed << evtpercent
1370  << "%)"
1371  << " | tracks collected: " << std::setw(10) << (it->second).second << " (" << setw(8)
1372  << fixed << trkpercent << "%)";
1373 
1374  tksByTrigger_->SetBinContent(i, trkpercent);
1375  tksByTrigger_->GetXaxis()->SetBinLabel(i, (it->first).c_str());
1376 
1377  evtsByTrigger_->SetBinContent(i, evtpercent);
1378  evtsByTrigger_->GetXaxis()->SetBinLabel(i, (it->first).c_str());
1379  }
1380 
1381  int nRuns = conditionsMap_.size();
1382 
1383  vector<int> theRuns_;
1384  for (map<int, std::pair<int, float> >::iterator it = conditionsMap_.begin(); it != conditionsMap_.end(); ++it) {
1385  theRuns_.push_back(it->first);
1386  }
1387 
1388  sort(theRuns_.begin(), theRuns_.end());
1389  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1390  edm::LogPrint("DMRChecker") << "first run: " << theRuns_[0] << std::endl;
1391  edm::LogPrint("DMRChecker") << "last run: " << theRuns_[theRuns_.size() - 1] << std::endl;
1392  edm::LogPrint("DMRChecker") << "considered runs: " << nRuns << std::endl;
1393  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1394 
1395  modeByRun_ = fs->make<TH1D>(
1396  "modeByRun", "Strip APV mode by run number;;APV mode (-1=deco,+1=peak)", nRuns, -0.5, nRuns - 0.5);
1397  fieldByRun_ = fs->make<TH1D>(
1398  "fieldByRun", "CMS B-field intensity by run number;;B-field intensity [T]", nRuns, -0.5, nRuns - 0.5);
1399 
1400  tracksByRun_ =
1401  fs->make<TH1D>("tracksByRun", "n. AlCaReco Tracks by run number;;n. of tracks", nRuns, -0.5, nRuns - 0.5);
1402  hitsByRun_ = fs->make<TH1D>("histByRun", "n. of hits by run number;;n. of hits", nRuns, -0.5, nRuns - 0.5);
1403 
1404  trackRatesByRun_ = fs->make<TH1D>(
1405  "trackRatesByRun", "rate of AlCaReco Tracks by run number;;n. of tracks/s", nRuns, -0.5, nRuns - 0.5);
1406  eventRatesByRun_ = fs->make<TH1D>(
1407  "eventRatesByRun", "rate of AlCaReco Events by run number;;n. of events/s", nRuns, -0.5, nRuns - 0.5);
1408 
1409  hitsinBPixByRun_ = fs->make<TH1D>(
1410  "histinBPixByRun", "n. of hits in BPix by run number;;n. of BPix hits", nRuns, -0.5, nRuns - 0.5);
1411  hitsinFPixByRun_ = fs->make<TH1D>(
1412  "histinFPixByRun", "n. of hits in FPix by run number;;n. of FPix hits", nRuns, -0.5, nRuns - 0.5);
1413 
1414  int indexing(0);
1415  for (int the_r = theRuns_[0]; the_r <= theRuns_[theRuns_.size() - 1]; the_r++) {
1416  if (conditionsMap_.find(the_r)->second.first != 0) {
1417  indexing++;
1418  double runTime = timeMap_.find(the_r)->second;
1419 
1420  edm::LogPrint("DMRChecker") << "run:" << the_r << " | isPeak: " << std::setw(4)
1421  << conditionsMap_.find(the_r)->second.first
1422  << "| B-field: " << conditionsMap_.find(the_r)->second.second << " [T]"
1423  << "| events: " << setw(10) << runInfoMap_.find(the_r)->second.first
1424  << "(rate: " << setw(10) << (runInfoMap_.find(the_r)->second.first) / runTime
1425  << " ev/s)"
1426  << ", tracks " << setw(10) << runInfoMap_.find(the_r)->second.second
1427  << "(rate: " << setw(10) << (runInfoMap_.find(the_r)->second.second) / runTime
1428  << " trk/s)" << std::endl;
1429 
1430  // int the_bin = modeByRun_->GetXaxis()->FindBin(the_r);
1431  modeByRun_->SetBinContent(indexing, conditionsMap_.find(the_r)->second.first);
1432  modeByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1433  fieldByRun_->SetBinContent(indexing, conditionsMap_.find(the_r)->second.second);
1434  fieldByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1435 
1436  tracksByRun_->SetBinContent(indexing, runInfoMap_.find(the_r)->second.first);
1437  tracksByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1438  hitsByRun_->SetBinContent(indexing, runInfoMap_.find(the_r)->second.second);
1439  hitsByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1440 
1441  hitsinBPixByRun_->SetBinContent(indexing, (runHitsMap_.find(the_r)->second)[0]);
1442  hitsinBPixByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1443  hitsinFPixByRun_->SetBinContent(indexing, (runHitsMap_.find(the_r)->second)[1]);
1444  hitsinFPixByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1445 
1446  trackRatesByRun_->SetBinContent(indexing, (runInfoMap_.find(the_r)->second.second) / runTime);
1447  trackRatesByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1448  eventRatesByRun_->SetBinContent(indexing, (runInfoMap_.find(the_r)->second.first) / runTime);
1449  eventRatesByRun_->GetXaxis()->SetBinLabel(indexing, Form("%d", the_r));
1450 
1451  constexpr const char *subdets[]{"BPix", "FPix", "TIB", "TID", "TOB", "TEC"};
1452 
1453  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1454  edm::LogPrint("DMRChecker") << "Hits by Sub-det" << std::endl;
1455  int si = 0;
1456  for (const auto &entry : runHitsMap_.find(the_r)->second) {
1457  edm::LogPrint("DMRChecker") << subdets[si] << " " << entry << std::endl;
1458  si++;
1459  }
1460  edm::LogPrint("DMRChecker") << "*******************************" << std::endl;
1461  }
1462 
1463  // modeByRun_->GetXaxis()->SetBinLabel(the_r-theRuns_[0]+1,(const char*)the_r);
1464  }
1465 
1466  // DMRs
1467 
1468  TFileDirectory DMeanR = fs->mkdir("DMRs");
1469 
1470  DMRBPixX_ = DMeanR.make<TH1D>("DMRBPix-X", "DMR of BPix-X;mean of X-residuals;modules", 100., -200, 200);
1471  DMRBPixY_ = DMeanR.make<TH1D>("DMRBPix-Y", "DMR of BPix-Y;mean of Y-residuals;modules", 100., -200, 200);
1472 
1473  DMRFPixX_ = DMeanR.make<TH1D>("DMRFPix-X", "DMR of FPix-X;mean of X-residuals;modules", 100., -200, 200);
1474  DMRFPixY_ = DMeanR.make<TH1D>("DMRFPix-Y", "DMR of FPix-Y;mean of Y-residuals;modules", 100., -200, 200);
1475 
1476  DMRTIB_ = DMeanR.make<TH1D>("DMRTIB", "DMR of TIB;mean of X-residuals;modules", 100., -200, 200);
1477  DMRTOB_ = DMeanR.make<TH1D>("DMRTOB", "DMR of TOB;mean of X-residuals;modules", 100., -200, 200);
1478 
1479  DMRTID_ = DMeanR.make<TH1D>("DMRTID", "DMR of TID;mean of X-residuals;modules", 100., -200, 200);
1480  DMRTEC_ = DMeanR.make<TH1D>("DMRTEC", "DMR of TEC;mean of X-residuals;modules", 100., -200, 200);
1481 
1482  TFileDirectory DMeanRSplit = fs->mkdir("SplitDMRs");
1483 
1484  DMRBPixXSplit_ = bookSplitDMRHistograms(DMeanRSplit, "BPix", "X", true);
1485  DMRBPixYSplit_ = bookSplitDMRHistograms(DMeanRSplit, "BPix", "Y", true);
1486 
1487  DMRFPixXSplit_ = bookSplitDMRHistograms(DMeanRSplit, "FPix", "X", false);
1488  DMRFPixYSplit_ = bookSplitDMRHistograms(DMeanRSplit, "FPix", "Y", false);
1489 
1490  DMRTIBSplit_ = bookSplitDMRHistograms(DMeanRSplit, "TIB", "X", true);
1491  DMRTOBSplit_ = bookSplitDMRHistograms(DMeanRSplit, "TOB", "X", true);
1492 
1493  // DRnRs
1494  TFileDirectory DRnRs = fs->mkdir("DRnRs");
1495 
1496  DRnRBPixX_ = DRnRs.make<TH1D>("DRnRBPix-X", "DRnR of BPix-X;rms of normalized X-residuals;modules", 100., 0., 3.);
1497  DRnRBPixY_ = DRnRs.make<TH1D>("DRnRBPix-Y", "DRnR of BPix-Y;rms of normalized Y-residuals;modules", 100., 0., 3.);
1498 
1499  DRnRFPixX_ = DRnRs.make<TH1D>("DRnRFPix-X", "DRnR of FPix-X;rms of normalized X-residuals;modules", 100., 0., 3.);
1500  DRnRFPixY_ = DRnRs.make<TH1D>("DRnRFPix-Y", "DRnR of FPix-Y;rms of normalized Y-residuals;modules", 100., 0., 3.);
1501 
1502  DRnRTIB_ = DRnRs.make<TH1D>("DRnRTIB", "DRnR of TIB;rms of normalized X-residuals;modules", 100., 0., 3.);
1503  DRnRTOB_ = DRnRs.make<TH1D>("DRnRTOB", "DRnR of TOB;rms of normalized Y-residuals;modules", 100., 0., 3.);
1504 
1505  DRnRTID_ = DRnRs.make<TH1D>("DRnRTID", "DRnR of TID;rms of normalized X-residuals;modules", 100., 0., 3.);
1506  DRnRTEC_ = DRnRs.make<TH1D>("DRnRTEC", "DRnR of TEC;rms of normalized Y-residuals;modules", 100., 0., 3.);
1507 
1508  // initialize the topology first
1509 
1510  SiPixelPI::PhaseInfo ph_info(phase_);
1511  const char *path_toTopologyXML = ph_info.pathToTopoXML();
1512  const TrackerTopology standaloneTopo =
1514 
1515  // initialize PixelRegionContainers
1516  PixelDMRS_x_ByLayer = std::make_unique<PixelRegions::PixelRegionContainers>(&standaloneTopo, ph_info.phase());
1517  PixelDMRS_y_ByLayer = std::make_unique<PixelRegions::PixelRegionContainers>(&standaloneTopo, ph_info.phase());
1518 
1519  // book PixelRegionContainers
1520  PixelDMRS_x_ByLayer->bookAll("Barrel Pixel DMRs", "median(x'_{pred}-x'_{hit}) [#mum]", "# modules", 100, -50, 50);
1521  PixelDMRS_y_ByLayer->bookAll("Barrel Pixel DMRs", "median(y'_{pred}-y'_{hit}) [#mum]", "# modules", 100, -50, 50);
1522 
1523  /*
1524  auto dets = PixelRegions::attachedDets(PixelRegions::PixelId::L1,&m_standaloneTopo,isPhase1_);
1525  for(const auto& det : dets){
1526  auto myLocalTopo = PixelDMRS_x_ByLayer->getTheTTopo();
1527  edm::LogVerbatim("DMRChecker") << myLocalTopo->print(det) << std::endl;
1528  }
1529  */
1530 
1531  // pixel
1532 
1533  for (auto &bpixid : resDetailsBPixX_) {
1534  DMRBPixX_->Fill(bpixid.second.runningMeanOfRes_);
1535  if (phase_ == SiPixelPI::phase::one) {
1536  pixelmap->fillBarrelBin("DMRsX", bpixid.first, bpixid.second.runningMeanOfRes_);
1537  fullPixelmapXDMR->fillTrackerMap(bpixid.first, bpixid.second.runningMeanOfRes_);
1538  }
1539 
1540  //auto myLocalTopo = PixelDMRS_x_ByLayer->getTheTopo();
1541  //edm::LogPrint("DMRChecker") << myLocalTopo->print(bpixid.first) << std::endl;
1542 
1543  PixelDMRS_x_ByLayer->fill(bpixid.first, bpixid.second.runningMeanOfRes_);
1544 
1545  // split DMR
1546  if (bpixid.second.rDirection > 0) {
1547  DMRBPixXSplit_[0]->Fill(bpixid.second.runningMeanOfRes_);
1548  } else {
1549  DMRBPixXSplit_[1]->Fill(bpixid.second.runningMeanOfRes_);
1550  }
1551 
1552  if (bpixid.second.hitCount < 2)
1553  DRnRBPixX_->Fill(-1);
1554  else
1555  DRnRBPixX_->Fill(sqrt(bpixid.second.runningNormVarOfRes_ / (bpixid.second.hitCount - 1)));
1556  }
1557 
1558  for (auto &bpixid : resDetailsBPixY_) {
1559  DMRBPixY_->Fill(bpixid.second.runningMeanOfRes_);
1560  if (phase_ == SiPixelPI::phase::one) {
1561  pixelmap->fillBarrelBin("DMRsY", bpixid.first, bpixid.second.runningMeanOfRes_);
1562  fullPixelmapYDMR->fillTrackerMap(bpixid.first, bpixid.second.runningMeanOfRes_);
1563  }
1564 
1565  PixelDMRS_y_ByLayer->fill(bpixid.first, bpixid.second.runningMeanOfRes_);
1566 
1567  // split DMR
1568  if (bpixid.second.rDirection > 0) {
1569  DMRBPixYSplit_[0]->Fill(bpixid.second.runningMeanOfRes_);
1570  } else {
1571  DMRBPixYSplit_[1]->Fill(bpixid.second.runningMeanOfRes_);
1572  }
1573 
1574  if (bpixid.second.hitCount < 2)
1575  DRnRBPixY_->Fill(-1);
1576  else
1577  DRnRBPixY_->Fill(sqrt(bpixid.second.runningNormVarOfRes_ / (bpixid.second.hitCount - 1)));
1578  }
1579 
1580  for (auto &fpixid : resDetailsFPixX_) {
1581  DMRFPixX_->Fill(fpixid.second.runningMeanOfRes_);
1582  if (phase_ == SiPixelPI::phase::one) {
1583  pixelmap->fillForwardBin("DMRsX", fpixid.first, fpixid.second.runningMeanOfRes_);
1584  fullPixelmapXDMR->fillTrackerMap(fpixid.first, fpixid.second.runningMeanOfRes_);
1585  }
1586  PixelDMRS_x_ByLayer->fill(fpixid.first, fpixid.second.runningMeanOfRes_);
1587 
1588  // split DMR
1589  if (fpixid.second.zDirection > 0) {
1590  DMRFPixXSplit_[0]->Fill(fpixid.second.runningMeanOfRes_);
1591  } else {
1592  DMRFPixXSplit_[1]->Fill(fpixid.second.runningMeanOfRes_);
1593  }
1594 
1595  if (fpixid.second.hitCount < 2)
1596  DRnRFPixX_->Fill(-1);
1597  else
1598  DRnRFPixX_->Fill(sqrt(fpixid.second.runningNormVarOfRes_ / (fpixid.second.hitCount - 1)));
1599  }
1600 
1601  for (auto &fpixid : resDetailsFPixY_) {
1602  DMRFPixY_->Fill(fpixid.second.runningMeanOfRes_);
1603  if (phase_ == SiPixelPI::phase::one) {
1604  pixelmap->fillForwardBin("DMRsY", fpixid.first, fpixid.second.runningMeanOfRes_);
1605  fullPixelmapXDMR->fillTrackerMap(fpixid.first, fpixid.second.runningMeanOfRes_);
1606  }
1607  PixelDMRS_y_ByLayer->fill(fpixid.first, fpixid.second.runningMeanOfRes_);
1608 
1609  // split DMR
1610  if (fpixid.second.zDirection > 0) {
1611  DMRFPixYSplit_[0]->Fill(fpixid.second.runningMeanOfRes_);
1612  } else {
1613  DMRFPixYSplit_[1]->Fill(fpixid.second.runningMeanOfRes_);
1614  }
1615 
1616  if (fpixid.second.hitCount < 2)
1617  DRnRFPixY_->Fill(-1);
1618  else
1619  DRnRFPixY_->Fill(sqrt(fpixid.second.runningNormVarOfRes_ / (fpixid.second.hitCount - 1)));
1620  }
1621 
1622  // strips
1623 
1624  for (auto &tibid : resDetailsTIB_) {
1625  DMRTIB_->Fill(tibid.second.runningMeanOfRes_);
1626 
1627  // split DMR
1628  if (tibid.second.rDirection > 0) {
1629  DMRTIBSplit_[0]->Fill(tibid.second.runningMeanOfRes_);
1630  } else {
1631  DMRTIBSplit_[1]->Fill(tibid.second.runningMeanOfRes_);
1632  }
1633 
1634  if (tibid.second.hitCount < 2)
1635  DRnRTIB_->Fill(-1);
1636  else
1637  DRnRTIB_->Fill(sqrt(tibid.second.runningNormVarOfRes_ / (tibid.second.hitCount - 1)));
1638  }
1639 
1640  for (auto &tobid : resDetailsTOB_) {
1641  DMRTOB_->Fill(tobid.second.runningMeanOfRes_);
1642 
1643  // split DMR
1644  if (tobid.second.rDirection > 0) {
1645  DMRTOBSplit_[0]->Fill(tobid.second.runningMeanOfRes_);
1646  } else {
1647  DMRTOBSplit_[1]->Fill(tobid.second.runningMeanOfRes_);
1648  }
1649 
1650  if (tobid.second.hitCount < 2)
1651  DRnRTOB_->Fill(-1);
1652  else
1653  DRnRTOB_->Fill(sqrt(tobid.second.runningNormVarOfRes_ / (tobid.second.hitCount - 1)));
1654  }
1655 
1656  for (auto &tidid : resDetailsTID_) {
1657  DMRTID_->Fill(tidid.second.runningMeanOfRes_);
1658 
1659  if (tidid.second.hitCount < 2)
1660  DRnRTID_->Fill(-1);
1661  else
1662  DRnRTID_->Fill(sqrt(tidid.second.runningNormVarOfRes_ / (tidid.second.hitCount - 1)));
1663  }
1664 
1665  for (auto &tecid : resDetailsTEC_) {
1666  DMRTEC_->Fill(tecid.second.runningMeanOfRes_);
1667 
1668  if (tecid.second.hitCount < 2)
1669  DRnRTEC_->Fill(-1);
1670  else
1671  DRnRTEC_->Fill(sqrt(tecid.second.runningNormVarOfRes_ / (tecid.second.hitCount - 1)));
1672  }
1673 
1674  edm::LogPrint("DMRChecker") << "n. of bpix modules " << resDetailsBPixX_.size() << std::endl;
1675  edm::LogPrint("DMRChecker") << "n. of fpix modules " << resDetailsFPixX_.size() << std::endl;
1676 
1677  if (phase_ == SiPixelPI::phase::zero) {
1678  pmap->save(true, 0, 0, "PixelHitMap.pdf", 600, 800);
1679  pmap->save(true, 0, 0, "PixelHitMap.png", 500, 750);
1680  }
1681 
1682  tmap->save(true, 0, 0, "StripHitMap.pdf");
1683  tmap->save(true, 0, 0, "StripHitMap.png");
1684 
1685  if (phase_ == SiPixelPI::phase::one) {
1686  gStyle->SetPalette(kRainBow);
1687  pixelmap->beautifyAllHistograms();
1688 
1689  TCanvas cBX("CanvXBarrel", "CanvXBarrel", 1200, 1000);
1690  pixelmap->drawBarrelMaps("DMRsX", cBX);
1691  cBX.SaveAs("pixelBarrelDMR_x.png");
1692 
1693  TCanvas cFX("CanvXForward", "CanvXForward", 1600, 1000);
1694  pixelmap->drawForwardMaps("DMRsX", cFX);
1695  cFX.SaveAs("pixelForwardDMR_x.png");
1696 
1697  TCanvas cBY("CanvYBarrel", "CanvYBarrel", 1200, 1000);
1698  pixelmap->drawBarrelMaps("DMRsY", cBY);
1699  cBY.SaveAs("pixelBarrelDMR_y.png");
1700 
1701  TCanvas cFY("CanvXForward", "CanvXForward", 1600, 1000);
1702  pixelmap->drawForwardMaps("DMRsY", cFY);
1703  cFY.SaveAs("pixelForwardDMR_y.png");
1704 
1705  TCanvas cFullPixelxDMR("CanvFullPixelX", "CanvFullPixelX", 3000, 2000);
1706  fullPixelmapXDMR->printTrackerMap(cFullPixelxDMR);
1707  cFullPixelxDMR.SaveAs("fullPixelDMR_x.png");
1708 
1709  TCanvas cFullPixelyDMR("CanvFullPixelX", "CanvFullPixelY", 3000, 2000);
1710  fullPixelmapXDMR->printTrackerMap(cFullPixelyDMR);
1711  cFullPixelyDMR.SaveAs("fullPixelDMR_y.png");
1712  }
1713 
1714  // take care now of the 1D histograms
1715  gStyle->SetOptStat("emr");
1716  PixelDMRS_x_ByLayer->beautify(2, 0);
1717  PixelDMRS_y_ByLayer->beautify(2, 0);
1718 
1719  TCanvas DMRxBarrel("DMRxBarrelCanv", "x-coordinate", 1400, 1200);
1720  DMRxBarrel.Divide(2, 2);
1721  PixelDMRS_x_ByLayer->draw(DMRxBarrel, true, "HISTS");
1722  adjustCanvases(DMRxBarrel, true);
1723  for (unsigned int c = 1; c <= 4; c++) {
1724  DMRxBarrel.cd(c)->Update();
1725  }
1726  PixelDMRS_x_ByLayer->stats();
1727 
1728  TCanvas DMRxForward("DMRxForwardCanv", "x-coordinate", 1400, 1200);
1729  DMRxForward.Divide(4, 3);
1730  PixelDMRS_x_ByLayer->draw(DMRxForward, false, "HISTS");
1731  adjustCanvases(DMRxForward, false);
1732  for (unsigned int c = 1; c <= 12; c++) {
1733  DMRxForward.cd(c)->Update();
1734  }
1735  PixelDMRS_x_ByLayer->stats();
1736 
1737  DMRxBarrel.SaveAs("DMR_x_Barrel_ByLayer.png");
1738  DMRxForward.SaveAs("DMR_x_Forward_ByRing.png");
1739 
1740  TCanvas DMRyBarrel("DMRyBarrelCanv", "y-coordinate", 1400, 1200);
1741  DMRyBarrel.Divide(2, 2);
1742  PixelDMRS_y_ByLayer->draw(DMRyBarrel, true, "HISTS");
1743  adjustCanvases(DMRyBarrel, true);
1744  for (unsigned int c = 1; c <= 4; c++) {
1745  DMRyBarrel.cd(c)->Update();
1746  }
1747  PixelDMRS_y_ByLayer->stats();
1748 
1749  TCanvas DMRyForward("DMRyForwardCanv", "y-coordinate", 1400, 1200);
1750  DMRyForward.Divide(4, 3);
1751  PixelDMRS_y_ByLayer->draw(DMRyForward, false, "HISTS");
1752  adjustCanvases(DMRyForward, false);
1753  for (unsigned int c = 1; c <= 12; c++) {
1754  DMRyForward.cd(c)->Update();
1755  }
1756  PixelDMRS_y_ByLayer->stats();
1757 
1758  DMRyBarrel.SaveAs("DMR_y_Barrel_ByLayer.png");
1759  DMRyForward.SaveAs("DMR_y_Forward_ByRing.png");
1760  }
1761 
1762  //*************************************************************
1763  // Adjust canvas for DMRs
1764  //*************************************************************
1765  void adjustCanvases(TCanvas &canvas, bool isBarrel) {
1766  unsigned int maxPads = isBarrel ? 4 : 12;
1767  for (unsigned int c = 1; c <= maxPads; c++) {
1768  canvas.cd(c);
1769  SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
1770  }
1771 
1772  auto ltx = TLatex();
1773  ltx.SetTextFont(62);
1774  ltx.SetTextSize(0.05);
1775  ltx.SetTextAlign(11);
1776 
1777  std::string toAppend = canvas.GetTitle();
1778 
1779  for (unsigned int c = 1; c <= maxPads; c++) {
1780  auto index = isBarrel ? c - 1 : c + 3;
1781  canvas.cd(c);
1782  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1783  1 - gPad->GetTopMargin() + 0.01,
1784  (PixelRegions::IDlabels.at(index) + " " + toAppend).c_str());
1785  }
1786  }
1787 
1788  //*************************************************************
1789  // check if the hit is 2D
1790  //*************************************************************
1791  bool isHit2D(const TrackingRecHit &hit) {
1792  bool countStereoHitAs2D_ = true;
1793  // we count SiStrip stereo modules as 2D if selected via countStereoHitAs2D_
1794  // (since they provide theta information)
1795  if (!hit.isValid() ||
1796  (hit.dimension() < 2 && !countStereoHitAs2D_ && !dynamic_cast<const SiStripRecHit1D *>(&hit))) {
1797  return false; // real RecHit1D - but SiStripRecHit1D depends on countStereoHitAs2D_
1798  } else {
1799  const DetId detId(hit.geographicalId());
1800  if (detId.det() == DetId::Tracker) {
1801  if (detId.subdetId() == kBPIX || detId.subdetId() == kFPIX) {
1802  return true; // pixel is always 2D
1803  } else { // should be SiStrip now
1804  const SiStripDetId stripId(detId);
1805  if (stripId.stereo())
1806  return countStereoHitAs2D_; // stereo modules
1807  else if (dynamic_cast<const SiStripRecHit1D *>(&hit) || dynamic_cast<const SiStripRecHit2D *>(&hit))
1808  return false; // rphi modules hit
1809  //the following two are not used any more since ages...
1810  else if (dynamic_cast<const SiStripMatchedRecHit2D *>(&hit))
1811  return true; // matched is 2D
1812  else if (dynamic_cast<const ProjectedSiStripRecHit2D *>(&hit)) {
1813  const ProjectedSiStripRecHit2D *pH = static_cast<const ProjectedSiStripRecHit2D *>(&hit);
1814  return (countStereoHitAs2D_ && this->isHit2D(pH->originalHit())); // depends on original...
1815  } else {
1816  edm::LogError("UnknownType") << "@SUB=DMRChecker::isHit2D"
1817  << "Tracker hit not in pixel, neither SiStripRecHit[12]D nor "
1818  << "SiStripMatchedRecHit2D nor ProjectedSiStripRecHit2D.";
1819  return false;
1820  }
1821  }
1822  } else { // not tracker??
1823  edm::LogWarning("DetectorMismatch") << "@SUB=DMRChecker::isHit2D"
1824  << "Hit not in tracker with 'official' dimension >=2.";
1825  return true; // dimension() >= 2 so accept that...
1826  }
1827  }
1828  // never reached...
1829  }
1830 
1831  //*************************************************************
1832  // Generic booker of split DMRs
1833  //*************************************************************
1835  std::string subdet,
1836  std::string vartype,
1837  bool isBarrel) {
1838  TH1F::SetDefaultSumw2(kTRUE);
1839 
1840  std::array<TH1D *, 2> out;
1841  std::array<std::string, 2> sign_name = {{"plus", "minus"}};
1842  std::array<std::string, 2> sign = {{">0", "<0"}};
1843  for (unsigned int i = 0; i < 2; i++) {
1844  const char *name_;
1845  const char *title_;
1846  const char *axisTitle_;
1847 
1848  if (isBarrel) {
1849  name_ = Form("DMR%s_%s_rDir%s", subdet.c_str(), vartype.c_str(), sign_name[i].c_str());
1850  title_ = Form("Split DMR of %s-%s (rDir%s)", subdet.c_str(), vartype.c_str(), sign[i].c_str());
1851  axisTitle_ = Form("mean of %s-residuals (rDir%s);modules", vartype.c_str(), sign[i].c_str());
1852  } else {
1853  name_ = Form("DMR%s_%s_zDir%s", subdet.c_str(), vartype.c_str(), sign_name[i].c_str());
1854  title_ = Form("Split DMR of %s-%s (zDir%s)", subdet.c_str(), vartype.c_str(), sign[i].c_str());
1855  axisTitle_ = Form("mean of %s-residuals (zDir%s);modules", vartype.c_str(), sign[i].c_str());
1856  }
1857 
1858  out[i] = dir.make<TH1D>(name_, fmt::sprintf("%s;%s", title_, axisTitle_).c_str(), 100., -200, 200);
1859  }
1860  return out;
1861  }
1862 
1863  //*************************************************************
1864  // Generic booker function
1865  //*************************************************************
1866  std::map<unsigned int, TH1D *> bookResidualsHistogram(
1867  TFileDirectory dir, unsigned int theNLayers, std::string resType, std::string varType, std::string detType) {
1868  TH1F::SetDefaultSumw2(kTRUE);
1869 
1870  std::pair<double, double> limits;
1871 
1872  if (varType.find("Res") != std::string::npos) {
1873  limits = std::make_pair(-1000., 1000);
1874  } else {
1875  limits = std::make_pair(-3., 3.);
1876  }
1877 
1878  std::map<unsigned int, TH1D *> h;
1879 
1880  for (unsigned int i = 1; i <= theNLayers; i++) {
1881  const char *name_;
1882  const char *title_;
1883  const char *xAxisTitle_;
1884 
1885  if (varType.find("Res") != std::string::npos) {
1886  xAxisTitle_ = ("res_{" + resType + "'} [#mum]").c_str();
1887  } else {
1888  xAxisTitle_ = ("res_{" + resType + "'}/#sigma_{res_{" + resType + "`}}").c_str();
1889  }
1890 
1891  unsigned int side = -1;
1892  if (detType.find("FPix") != std::string::npos) {
1893  side = (i - 1) / 3 + 1;
1894  unsigned int plane = (i - 1) % 3 + 1;
1895 
1896  std::string theSide = "";
1897  if (side == 1) {
1898  theSide = "Z-";
1899  } else {
1900  theSide = "Z+";
1901  }
1902 
1903  name_ = Form("h_%s%s%s_side%i_disk%i", detType.c_str(), varType.c_str(), resType.c_str(), side, plane);
1904  title_ = Form("%s (%s, disk %i) track %s-%s;%s;hits",
1905  detType.c_str(),
1906  theSide.c_str(),
1907  plane,
1908  resType.c_str(),
1909  varType.c_str(),
1910  xAxisTitle_);
1911 
1912  } else {
1913  name_ = Form("h_%s%s%s_layer%i", detType.c_str(), varType.c_str(), resType.c_str(), i);
1914  title_ = Form(
1915  "%s (layer %i) track %s-%s;%s;hits", detType.c_str(), i, resType.c_str(), varType.c_str(), xAxisTitle_);
1916 
1917  //edm::LogPrint("DMRChecker")<<"bookResidualsHistogram(): "<<i<<" layer:"<<i<<std::endl;
1918  }
1919 
1920  h[i] = dir.make<TH1D>(name_, title_, 100, limits.first, limits.second);
1921  }
1922 
1923  return h;
1924  }
1925 
1926  //*************************************************************
1927  // Generic filler function
1928  //*************************************************************
1929  void fillByIndex(std::map<unsigned int, TH1D *> &h, unsigned int index, double x) {
1930  if (h.count(index) != 0) {
1931  //if(TString(h[index]->GetName()).Contains("BPix"))
1932  //edm::LogPrint("DMRChecker")<<"fillByIndex() index: "<< index << " filling histogram: "<< h[index]->GetName() << std::endl;
1933 
1934  double min = h[index]->GetXaxis()->GetXmin();
1935  double max = h[index]->GetXaxis()->GetXmax();
1936  if (x < min)
1937  h[index]->Fill(min);
1938  else if (x >= max)
1939  h[index]->Fill(0.99999 * max);
1940  else
1941  h[index]->Fill(x);
1942  }
1943  }
1944 
1945  //*************************************************************
1946  // Implementation of the online variance algorithm
1947  // as in https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
1948  //*************************************************************
1949  void updateOnlineMomenta(running::estimatorMap &myDetails, uint32_t theID, float the_data, float the_pull) {
1950  myDetails[theID].hitCount += 1;
1951 
1952  float delta = 0;
1953  float n_delta = 0;
1954 
1955  if (myDetails[theID].hitCount != 1) {
1956  delta = the_data - myDetails[theID].runningMeanOfRes_;
1957  n_delta = the_pull - myDetails[theID].runningNormMeanOfRes_;
1958  myDetails[theID].runningMeanOfRes_ += (delta / myDetails[theID].hitCount);
1959  myDetails[theID].runningNormMeanOfRes_ += (n_delta / myDetails[theID].hitCount);
1960  } else {
1961  myDetails[theID].runningMeanOfRes_ = the_data;
1962  myDetails[theID].runningNormMeanOfRes_ = the_pull;
1963  }
1964 
1965  float delta2 = the_data - myDetails[theID].runningMeanOfRes_;
1966  float n_delta2 = the_pull - myDetails[theID].runningNormMeanOfRes_;
1967 
1968  myDetails[theID].runningVarOfRes_ += delta * delta2;
1969  myDetails[theID].runningNormVarOfRes_ += n_delta * n_delta2;
1970  }
1971 
1972  //*************************************************************
1973  // Fill the histograms using the running::estimatorMap
1974  //**************************************************************
1975  void fillDMRs(const running::estimatorMap &myDetails,
1976  TH1D *DMR,
1977  TH1D *DRnR,
1978  std::array<TH1D *, 2> DMRSplit,
1979  std::unique_ptr<PixelRegions::PixelRegionContainers> regionalDMR) {
1980  for (const auto &element : myDetails) {
1981  // DMR
1982  DMR->Fill(element.second.runningMeanOfRes_);
1983 
1984  // DMR by layer
1985  if (regionalDMR.get()) {
1986  regionalDMR->fill(element.first, element.second.runningMeanOfRes_);
1987  }
1988 
1989  // split DMR
1990  if (element.second.rOrZDirection > 0) {
1991  DMRSplit[0]->Fill(element.second.runningMeanOfRes_);
1992  } else {
1993  DMRSplit[1]->Fill(element.second.runningMeanOfRes_);
1994  }
1995 
1996  // DRnR
1997  if (element.second.hitCount < 2) {
1998  DRnR->Fill(-1);
1999  } else {
2000  DRnR->Fill(sqrt(element.second.runningNormVarOfRes_ / (element.second.hitCount - 1)));
2001  }
2002  }
2003  }
2004 };
2005 
2006 //*************************************************************
2008 //*************************************************************
2009 {
2011  desc.setComment("Generic track analyzer to check ALCARECO sample quantities / compute fast DMRs");
2012  desc.add<edm::InputTag>("TkTag", edm::InputTag("generalTracks"));
2013  desc.add<edm::InputTag>("TriggerResultsTag", edm::InputTag("TriggerResults", "", "HLT"));
2014  desc.add<edm::InputTag>("BeamSpotTag", edm::InputTag("offlineBeamSpot"));
2015  desc.add<edm::InputTag>("VerticesTag", edm::InputTag("offlinePrimaryVertices"));
2016  desc.add<bool>("isCosmics", false);
2017  descriptions.add("DMRChecker", desc);
2018 }
2019 
TH1D * hHitMinus
Definition: DMRChecker.cc:315
static const std::string kSharedResource
Definition: TFileService.h:76
TH1D * hTECResXPrime
Definition: DMRChecker.cc:281
std::array< TH1D *, 2 > bookSplitDMRHistograms(TFileDirectory dir, std::string subdet, std::string vartype, bool isBarrel)
Definition: DMRChecker.cc:1834
TH1D * hPhihp
Definition: DMRChecker.cc:321
running::estimatorMap resDetailsTEC_
Definition: DMRChecker.cc:490
Log< level::Info, true > LogVerbatim
static constexpr auto TEC
TH1D * hPhiOverlapMinus
Definition: DMRChecker.cc:334
TH1D * hFPixZMinusResYPull
Definition: DMRChecker.cc:276
double z0() const
z coordinate
Definition: BeamSpot.h:65
virtual int dimension() const =0
TH1D * hHitCountVsXFPix
Definition: DMRChecker.cc:289
TH1D * hHitCountVsYFPixPlus
Definition: DMRChecker.cc:303
void fillByIndex(std::map< unsigned int, TH1D * > &h, unsigned int index, double x)
Definition: DMRChecker.cc:1929
TH1D * hFPixZPlusResXPrime
Definition: DMRChecker.cc:260
TH1D * hHitCountVsXFPixPlus
Definition: DMRChecker.cc:301
const edm::EventSetup & c
TH1D * hHitCountVsYFPixMinus
Definition: DMRChecker.cc:304
TH1D * eventRatesByRun_
Definition: DMRChecker.cc:397
TH1D * hFPixZMinusResXPrime
Definition: DMRChecker.cc:261
TH1D * hDeltaPhi
Definition: DMRChecker.cc:340
TH1D * modeByRun_
Definition: DMRChecker.cc:390
void fillByIndex(std::vector< TH1F * > &h, unsigned int index, double x, std::string tag="")
double seconds()
TH1D * tracksByRun_
Definition: DMRChecker.cc:393
TH1D * hitsinFPixByRun_
Definition: DMRChecker.cc:400
std::unique_ptr< Phase1PixelSummaryMap > fullPixelmapXDMR
Definition: DMRChecker.cc:233
std::vector< TH1 * > vTrackProfiles_
Definition: DMRChecker.cc:384
TH1D * hHitCountVsZFPixMinus
Definition: DMRChecker.cc:306
TH1D * hPtPlus
Definition: DMRChecker.cc:253
T perp() const
Definition: PV3DBase.h:69
TH1D * hnhpxe
Definition: DMRChecker.cc:360
running::estimatorMap resDetailsBPixX_
Definition: DMRChecker.cc:480
std::map< std::string, std::pair< int, int > > triggerMap_
Definition: DMRChecker.cc:471
TH1D * hPhiEndcapMinus
Definition: DMRChecker.cc:336
uint32_t stereo() const
Definition: SiStripDetId.h:168
TH1D * hEta
Definition: DMRChecker.cc:328
const SiPixelPI::phase phase() const
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: DMRChecker.cc:2007
const std::vector< std::string > IDlabels
std::map< int, std::array< int, 6 > > runHitsMap_
Definition: DMRChecker.cc:474
TH1D * hdxyBS
Definition: DMRChecker.cc:374
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
int16_t singleReadOutMode() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TH1D * hd0
Definition: DMRChecker.cc:347
unsigned int pxfDisk(const DetId &id) const
std::map< unsigned int, TH1D * > endcapDisksPullsX
Definition: DMRChecker.cc:449
running::estimatorMap resDetailsTOB_
Definition: DMRChecker.cc:488
double y() const
y coordinate
Definition: Vertex.h:131
TH1D * hvz
Definition: DMRChecker.cc:346
running::estimatorMap resDetailsBPixY_
Definition: DMRChecker.cc:481
double sign(double x)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TH1D * hTOBResXPrime
Definition: DMRChecker.cc:279
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
T y() const
Definition: PV3DBase.h:60
TH1I * htrkQuality
Definition: DMRChecker.cc:245
TH1D * hFPixZPlusResYPull
Definition: DMRChecker.cc:275
TH1D * hHit
Definition: DMRChecker.cc:255
bool firstEvent_
Definition: DMRChecker.cc:456
TH1D * hPtMinus
Definition: DMRChecker.cc:254
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
running::estimatorMap resDetailsFPixY_
Definition: DMRChecker.cc:483
TH1D * hFPixResYPull
Definition: DMRChecker.cc:274
TH1D * hd0BS
Definition: DMRChecker.cc:375
TH1D * hCharge
Definition: DMRChecker.cc:325
TH1D * hTECResXPull
Definition: DMRChecker.cc:286
TH1D * hDeltaEta
Definition: DMRChecker.cc:341
TProfile * pNBpixHitsVsVx
Definition: DMRChecker.cc:368
TProfile * pNBpixHitsVsVz
Definition: DMRChecker.cc:370
TH1D * hHitCountVsThetaFPix
Definition: DMRChecker.cc:298
TH1D * DRnRFPixY_
Definition: DMRChecker.cc:414
edm::InputTag TriggerResultsTag_
Definition: DMRChecker.cc:462
TH1D * hMultCand
Definition: DMRChecker.cc:372
TH1D * hNtrkZoom
Definition: DMRChecker.cc:244
Log< level::Error, false > LogError
std::map< int, std::pair< int, int > > runInfoMap_
Definition: DMRChecker.cc:473
std::map< unsigned int, TH1D * > endcapDisksResidualsX
Definition: DMRChecker.cc:448
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
TH1D * hHitComposition
Definition: DMRChecker.cc:366
std::map< unsigned int, TH1D * > bookResidualsHistogram(TFileDirectory dir, unsigned int theNLayers, std::string resType, std::string varType, std::string detType)
Definition: DMRChecker.cc:1866
edm::InputTag BeamSpotTag_
Definition: DMRChecker.cc:463
TH1D * hPhiBarrel
Definition: DMRChecker.cc:332
TH1D * hHithp
Definition: DMRChecker.cc:319
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
TH1D * hHitCountVsZFPixPlus
Definition: DMRChecker.cc:305
TH1D * hEtaPlus
Definition: DMRChecker.cc:329
edm::InputTag TkTag_
Definition: DMRChecker.cc:461
TH1D * hvx
Definition: DMRChecker.cc:344
TH1D * hHitCountVsZBPix
Definition: DMRChecker.cc:292
running::estimatorMap resDetailsTID_
Definition: DMRChecker.cc:489
TH1D * hHitCountVsYFPix
Definition: DMRChecker.cc:291
TH1D * trackRatesByRun_
Definition: DMRChecker.cc:396
TH1D * hchi2ndofhp
Definition: DMRChecker.cc:322
TH1D * DMRTID_
Definition: DMRChecker.cc:421
std::map< int, float > timeMap_
Definition: DMRChecker.cc:476
TH1D * DRnRFPixX_
Definition: DMRChecker.cc:413
def canvas
Definition: svgfig.py:482
TH1D * hFPixZPlusResYPrime
Definition: DMRChecker.cc:265
TH2D * hd0vspt
Definition: DMRChecker.cc:357
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
TH1D * hFPixZPlusResXPull
Definition: DMRChecker.cc:270
TH1D * hTOBResXPull
Definition: DMRChecker.cc:284
bool isThere(GeomDetEnumerators::SubDetector subdet) const
std::array< TH1D *, 2 > DMRTIBSplit_
Definition: DMRChecker.cc:438
TH1D * hPthp
Definition: DMRChecker.cc:318
TH1D * hHitCountVsPhiFPix
Definition: DMRChecker.cc:299
const int kFPIX
bool getData(T &iHolder) const
Definition: EventSetup.h:128
U second(std::pair< T, U > const &p)
void beginJob() override
Definition: DMRChecker.cc:1082
TH1D * hEtaMinus
Definition: DMRChecker.cc:330
T barePhi() const
Definition: PV3DBase.h:65
TH1D * hchi2Probhp
Definition: DMRChecker.cc:323
TH1D * hPPlus
Definition: DMRChecker.cc:249
TH1D * hFPixResYPrime
Definition: DMRChecker.cc:264
std::map< uint32_t, running::Estimators > estimatorMap
Definition: DMRChecker.cc:146
void setComment(std::string const &value)
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:36
std::unique_ptr< Phase1PixelSummaryMap > fullPixelmapYDMR
Definition: DMRChecker.cc:234
int GetIndex(const std::vector< OBJECT_TYPE * > &vec, const std::string &name)
Definition: DMRChecker.cc:211
TH1D * hHitCountVsPhiBPix
Definition: DMRChecker.cc:296
TH1D * DRnRBPixX_
Definition: DMRChecker.cc:410
DMRChecker(const edm::ParameterSet &pset)
Definition: DMRChecker.cc:152
TH1D * hBPixResYPull
Definition: DMRChecker.cc:273
TH1D * hHitCountVsXFPixMinus
Definition: DMRChecker.cc:302
TH1D * hHitCountVsPhiFPixPlus
Definition: DMRChecker.cc:309
TH1D * hQoverPZoom
Definition: DMRChecker.cc:327
TH1D * hPhiEndcapPlus
Definition: DMRChecker.cc:335
T mag() const
Definition: PV3DBase.h:64
std::unique_ptr< PixelRegions::PixelRegionContainers > PixelDMRS_x_ByLayer
Definition: DMRChecker.cc:236
edm::EDGetTokenT< reco::TrackCollection > theTrackCollectionToken_
Definition: DMRChecker.cc:466
TH1D * DMRBPixY_
Definition: DMRChecker.cc:405
TH1D * hHitCountVsThetaFPixPlus
Definition: DMRChecker.cc:308
TH1D * hFPixZMinusResXPull
Definition: DMRChecker.cc:271
TH1D * hHitCountVsZFPix
Definition: DMRChecker.cc:293
TH1D * hdzBS
Definition: DMRChecker.cc:376
TH1D * DMRTIB_
Definition: DMRChecker.cc:418
TH1D * hP
Definition: DMRChecker.cc:248
TH1D * hNtrk
Definition: DMRChecker.cc:243
TH1D * hnhTOB
Definition: DMRChecker.cc:363
std::map< unsigned int, TH1D * > barrelLayersPullsX
Definition: DMRChecker.cc:444
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
constexpr float cmToUm
Definition: DMRChecker.cc:127
std::unique_ptr< TrackerMap > pmap
Definition: DMRChecker.cc:240
std::array< TH1D *, 2 > DMRBPixXSplit_
Definition: DMRChecker.cc:432
T sqrt(T t)
Definition: SSEVec.h:19
void endJob() override
Definition: DMRChecker.cc:1342
TH1D * DRnRTEC_
Definition: DMRChecker.cc:428
T z() const
Definition: PV3DBase.h:61
TH1D * hHitCountVsYBPix
Definition: DMRChecker.cc:290
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: DMRChecker.cc:469
std::vector< TH1 * > vTrackHistos_
Definition: DMRChecker.cc:383
edm::EDGetTokenT< reco::BeamSpot > beamspotToken_
Definition: DMRChecker.cc:468
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
TH1D * fieldByRun_
Definition: DMRChecker.cc:391
RunNumber_t run() const
Definition: Event.h:109
TH1D * hvy
Definition: DMRChecker.cc:345
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TH1D * hdzPV
Definition: DMRChecker.cc:379
double z() const
z coordinate
Definition: Vertex.h:133
TH1D * DMRTOB_
Definition: DMRChecker.cc:419
TH1D * hPMinus
Definition: DMRChecker.cc:250
TH1D * hPhiOverlapPlus
Definition: DMRChecker.cc:333
std::map< int, std::pair< int, float > > conditionsMap_
Definition: DMRChecker.cc:472
void updateOnlineMomenta(running::estimatorMap &myDetails, uint32_t theID, float the_data, float the_pull)
Definition: DMRChecker.cc:1949
std::array< TH1D *, 2 > DMRFPixXSplit_
Definition: DMRChecker.cc:435
T * make(const Args &...args) const
make new ROOT object
std::unique_ptr< TrackerMap > tmap
Definition: DMRChecker.cc:239
std::map< unsigned int, TH1D * > endcapDisksResidualsY
Definition: DMRChecker.cc:450
T min(T a, T b)
Definition: MathUtil.h:58
TH1D * DRnRTIB_
Definition: DMRChecker.cc:424
TH1D * DMRBPixX_
Definition: DMRChecker.cc:404
static constexpr auto TOB
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
TH1D * hEtahp
Definition: DMRChecker.cc:320
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
running::estimatorMap resDetailsFPixX_
Definition: DMRChecker.cc:482
running::estimatorMap resDetailsTIB_
Definition: DMRChecker.cc:487
Log< level::Warning, true > LogPrint
TH1D * hPt
Definition: DMRChecker.cc:251
const TrackerGeomDet * idToDet(DetId) const override
TH1D * hlumi
Definition: DMRChecker.cc:381
TH1D * hrun
Definition: DMRChecker.cc:380
TH1D * hFPixResXPrime
Definition: DMRChecker.cc:259
TH1D * hchi2ndof
Definition: DMRChecker.cc:242
#define M_PI
TH1D * DMRFPixY_
Definition: DMRChecker.cc:408
std::map< unsigned int, TH1D * > barrelLayersResidualsX
Definition: DMRChecker.cc:443
unsigned int pxbLayer(const DetId &id) const
TH1D * hnhTID
Definition: DMRChecker.cc:362
TH1D * hPhi
Definition: DMRChecker.cc:331
TH1D * hHitCountVsPhiFPixMinus
Definition: DMRChecker.cc:312
TH1D * hFPixZMinusResYPrime
Definition: DMRChecker.cc:266
SiStripRecHit2D originalHit() const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
TH1D * hd0PV
Definition: DMRChecker.cc:378
TH1D * hnhTEC
Definition: DMRChecker.cc:364
const edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
Definition: DMRChecker.cc:225
TH2D * hd0PVvseta
Definition: DMRChecker.cc:352
Definition: DetId.h:17
TH1D * hHitCountVsThetaFPixMinus
Definition: DMRChecker.cc:311
double x() const
x coordinate
Definition: Vertex.h:129
TH1D * hHitPlus
Definition: DMRChecker.cc:314
tuple trackCollection
static constexpr auto TIB
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_
Definition: DMRChecker.cc:228
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< unsigned int, TH1D * > barrelLayersResidualsY
Definition: DMRChecker.cc:445
TH1D * tksByTrigger_
Definition: DMRChecker.cc:387
T const * product() const
Definition: Handle.h:70
std::map< unsigned int, TH1D * > barrelLayersPullsY
Definition: DMRChecker.cc:446
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Definition: DMRChecker.cc:227
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
TH1D * hBPixResYPrime
Definition: DMRChecker.cc:263
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:50
std::unique_ptr< Phase1PixelMaps > pixelmap
Definition: DMRChecker.cc:232
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
SiPixelPI::phase phase_
Definition: DMRChecker.cc:458
TH1D * hTIBResXPrime
Definition: DMRChecker.cc:278
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
Definition: DMRChecker.cc:226
edm::EDGetTokenT< edm::TriggerResults > hltresultsToken_
Definition: DMRChecker.cc:467
TH1D * hTIDResXPull
Definition: DMRChecker.cc:285
TProfile * pNBpixHitsVsVy
Definition: DMRChecker.cc:369
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TH1D * hPhiMinus
Definition: DMRChecker.cc:338
bool isValid() const
TH1D * hPhp
Definition: DMRChecker.cc:317
void add(std::string const &label, ParameterSetDescription const &psetDescription)
long long m_stop_time_ll
Definition: RunInfo.h:23
TH1D * DRnRTID_
Definition: DMRChecker.cc:427
TH1D * DRnRTOB_
Definition: DMRChecker.cc:425
TH1D * hnhTIB
Definition: DMRChecker.cc:361
TH1D * hFPixResXPull
Definition: DMRChecker.cc:269
TH1D * hPhiPlus
Definition: DMRChecker.cc:337
static const std::string algoNames[]
Definition: TrackBase.h:147
TH1D * hdz
Definition: DMRChecker.cc:348
const bool isCosmics_
Definition: DMRChecker.cc:459
std::array< TH1D *, 2 > DMRFPixYSplit_
Definition: DMRChecker.cc:436
TH1D * hQoverP
Definition: DMRChecker.cc:326
edm::InputTag VerticesTag_
Definition: DMRChecker.cc:464
TH2D * hd0vseta
Definition: DMRChecker.cc:356
TH1D * hdxyPV
Definition: DMRChecker.cc:377
TH1D * DMRFPixX_
Definition: DMRChecker.cc:407
edm::Service< TFileService > fs
Definition: DMRChecker.cc:230
#define DEBUG
Definition: DMRChecker.cc:120
TH1D * hBPixResXPrime
Definition: DMRChecker.cc:258
void adjustCanvases(TCanvas &canvas, bool isBarrel)
Definition: DMRChecker.cc:1765
std::array< TH1D *, 2 > DMRTOBSplit_
Definition: DMRChecker.cc:439
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
TH1D * hdxy
Definition: DMRChecker.cc:349
TH1I * htrkAlgo
Definition: DMRChecker.cc:246
double y0() const
y coordinate
Definition: BeamSpot.h:63
std::unique_ptr< PixelRegions::PixelRegionContainers > PixelDMRS_y_ByLayer
Definition: DMRChecker.cc:237
TH1D * hHit2D
Definition: DMRChecker.cc:256
list entry
Definition: mps_splice.py:68
unsigned int pxfSide(const DetId &id) const
TH1D * hHitCountVsThetaBPix
Definition: DMRChecker.cc:295
TH1D * hBPixResXPull
Definition: DMRChecker.cc:268
void fillDMRs(const running::estimatorMap &myDetails, TH1D *DMR, TH1D *DRnR, std::array< TH1D *, 2 > DMRSplit, std::unique_ptr< PixelRegions::PixelRegionContainers > regionalDMR)
Definition: DMRChecker.cc:1975
TH1D * DMRTEC_
Definition: DMRChecker.cc:422
TH1D * hHitCountVsXBPix
Definition: DMRChecker.cc:288
tuple cout
Definition: gather_cfg.py:144
TH1D * hnhpxb
Definition: DMRChecker.cc:359
TH1D * hTIDResXPrime
Definition: DMRChecker.cc:280
TH2D * hd0PVvspt
Definition: DMRChecker.cc:353
std::map< unsigned int, TH1D * > endcapDisksPullsY
Definition: DMRChecker.cc:451
DetId geographicalId() const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
Definition: DMRChecker.cc:224
TH2D * hd0vsphi
Definition: DMRChecker.cc:355
TH1D * DRnRBPixY_
Definition: DMRChecker.cc:411
TH1D * evtsByTrigger_
Definition: DMRChecker.cc:388
Log< level::Warning, false > LogWarning
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
TH1D * hMinPt
Definition: DMRChecker.cc:252
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
T x() const
Definition: PV3DBase.h:59
TH1D * hDeltaR
Definition: DMRChecker.cc:342
TH1D * hitsinBPixByRun_
Definition: DMRChecker.cc:399
static const std::string subdets[7]
Definition: TrackUtils.cc:60
static constexpr auto TID
long long m_start_time_ll
Definition: RunInfo.h:21
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
TH1D * hTIBResXPull
Definition: DMRChecker.cc:283
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition: DMRChecker.cc:492
TH2D * hd0PVvsphi
Definition: DMRChecker.cc:351
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
std::array< TH1D *, 2 > DMRBPixYSplit_
Definition: DMRChecker.cc:433
bool isHit2D(const TrackingRecHit &hit)
Definition: DMRChecker.cc:1791
Our base class.
Definition: SiPixelRecHit.h:23
std::vector< TH1 * > vTrack2DHistos_
Definition: DMRChecker.cc:385
double x0() const
x coordinate
Definition: BeamSpot.h:61
TH1D * hNhighPurity
Definition: DMRChecker.cc:247
const int kBPIX
TH1D * hitsByRun_
Definition: DMRChecker.cc:394