Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-18 23:26:54

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author Suchandra Dutta , Giorgia Mila
0005  */
0006 
0007 #include "DataFormats/TrackReco/interface/Track.h"
0008 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0009 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0010 #include "TrackingTools/IPTools/interface/IPTools.h"
0011 #include "MagneticField/Engine/interface/MagneticField.h"
0012 
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include "FWCore/Utilities/interface/ESInputTag.h"
0015 #include "FWCore/Utilities/interface/InputTag.h"
0016 #include "FWCore/Utilities/interface/Transition.h"
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 #include "DQM/TrackingMonitor/interface/TrackAnalyzer.h"
0019 #include <string>
0020 #include "TMath.h"
0021 #include "DQM/TrackingMonitor/interface/GetLumi.h"
0022 
0023 namespace {
0024   template <typename T, size_t N>
0025   std::array<T, N + 1> makeLogBins(const double min, const double max) {
0026     const double minLog10 = std::log10(min);
0027     const double maxLog10 = std::log10(max);
0028     const double width = (maxLog10 - minLog10) / N;
0029     std::array<T, N + 1> ret;
0030     ret[0] = std::pow(10, minLog10);
0031     const double mult = std::pow(10, width);
0032     for (size_t i = 1; i <= N; ++i) {
0033       ret[i] = ret[i - 1] * mult;
0034     }
0035     return ret;
0036   }
0037 }  // namespace
0038 
0039 using namespace tadqm;
0040 TrackAnalyzer::TrackAnalyzer(const edm::ParameterSet& iConfig)
0041     : conf_(nullptr),
0042       stateName_(iConfig.getParameter<std::string>("MeasurementState")),
0043       doTrackerSpecific_(iConfig.getParameter<bool>("doTrackerSpecific")),
0044       doAllPlots_(iConfig.getParameter<bool>("doAllPlots")),
0045       doBSPlots_(iConfig.getParameter<bool>("doBeamSpotPlots")),
0046       doPVPlots_(iConfig.getParameter<bool>("doPrimaryVertexPlots")),
0047       doDCAPlots_(iConfig.getParameter<bool>("doDCAPlots")),
0048       doGeneralPropertiesPlots_(iConfig.getParameter<bool>("doGeneralPropertiesPlots")),
0049       doMeasurementStatePlots_(iConfig.getParameter<bool>("doMeasurementStatePlots")),
0050       doHitPropertiesPlots_(iConfig.getParameter<bool>("doHitPropertiesPlots")),
0051       doRecHitVsPhiVsEtaPerTrack_(iConfig.getParameter<bool>("doRecHitVsPhiVsEtaPerTrack")),
0052       doRecHitVsPtVsEtaPerTrack_(iConfig.getParameter<bool>("doRecHitVsPtVsEtaPerTrack")),
0053       doLayersVsPhiVsEtaPerTrack_(iConfig.getParameter<bool>("doLayersVsPhiVsEtaPerTrack")),
0054       doRecHitsPerTrackProfile_(iConfig.getParameter<bool>("doRecHitsPerTrackProfile")),
0055       doThetaPlots_(iConfig.getParameter<bool>("doThetaPlots")),
0056       doTrackPxPyPlots_(iConfig.getParameter<bool>("doTrackPxPyPlots")),
0057       doDCAwrtPVPlots_(iConfig.getParameter<bool>("doDCAwrtPVPlots")),
0058       doDCAwrt000Plots_(iConfig.getParameter<bool>("doDCAwrt000Plots")),
0059       doLumiAnalysis_(iConfig.getParameter<bool>("doLumiAnalysis")),
0060       doTestPlots_(iConfig.getParameter<bool>("doTestPlots")),
0061       doHIPlots_(iConfig.getParameter<bool>("doHIPlots")),
0062       doSIPPlots_(iConfig.getParameter<bool>("doSIPPlots")),
0063       doEffFromHitPatternVsPU_(iConfig.getParameter<bool>("doEffFromHitPatternVsPU")),
0064       doEffFromHitPatternVsBX_(iConfig.getParameter<bool>("doEffFromHitPatternVsBX")),
0065       doEffFromHitPatternVsLUMI_(iConfig.getParameter<bool>("doEffFromHitPatternVsLUMI")),
0066       pvNDOF_(iConfig.getParameter<int>("pvNDOF")),
0067       forceSCAL_(iConfig.getParameter<bool>("forceSCAL")),
0068       useBPixLayer1_(iConfig.getParameter<bool>("useBPixLayer1")),
0069       minNumberOfPixelsPerCluster_(iConfig.getParameter<int>("minNumberOfPixelsPerCluster")),
0070       minPixelClusterCharge_(iConfig.getParameter<double>("minPixelClusterCharge")),
0071       qualityString_(iConfig.getParameter<std::string>("qualityString")),
0072       good_vertices_(0),
0073       bx_(0),
0074       pixel_lumi_(0.),
0075       scal_lumi_(0.) {
0076   initHistos();
0077   TopFolder_ = iConfig.getParameter<std::string>("FolderName");
0078 }
0079 
0080 TrackAnalyzer::TrackAnalyzer(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC) : TrackAnalyzer(iConfig) {
0081   edm::InputTag bsSrc = iConfig.getParameter<edm::InputTag>("beamSpot");
0082   edm::InputTag primaryVertexInputTag = iConfig.getParameter<edm::InputTag>("primaryVertex");
0083   edm::InputTag pixelClusterInputTag = iConfig.getParameter<edm::InputTag>("pixelCluster4lumi");
0084   edm::InputTag scalInputTag = iConfig.getParameter<edm::InputTag>("scal");
0085   edm::InputTag metaDataInputTag = iConfig.getParameter<edm::InputTag>("metadata");
0086   beamSpotToken_ = iC.consumes<reco::BeamSpot>(bsSrc);
0087   pvToken_ = iC.consumes<reco::VertexCollection>(primaryVertexInputTag);
0088   pixelClustersToken_ = iC.mayConsume<edmNew::DetSetVector<SiPixelCluster> >(pixelClusterInputTag);
0089   lumiscalersToken_ = iC.mayConsume<LumiScalersCollection>(scalInputTag);
0090   metaDataToken_ = iC.mayConsume<OnlineLuminosityRecord>(metaDataInputTag);
0091 
0092   if (doAllPlots_ || doEffFromHitPatternVsPU_ || doEffFromHitPatternVsBX_ || doEffFromHitPatternVsLUMI_) {
0093     trackerGeometryToken_ = iC.esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>();
0094   }
0095   trackerTopologyToken_ = iC.esConsumes<TrackerTopology, TrackerTopologyRcd>();
0096   if (doSIPPlots_ ||
0097       ((doMeasurementStatePlots_ || doAllPlots_) && (stateName_ == "All" || stateName_ == "OuterSurface" ||
0098                                                      stateName_ == "InnerSurface" || stateName_ == "ImpactPoint"))) {
0099     transientTrackBuilderToken_ =
0100         iC.esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"));
0101   }
0102 
0103   if (useBPixLayer1_)
0104     lumi_factor_per_bx_ = GetLumi::FREQ_ORBIT * GetLumi::SECONDS_PER_LS / GetLumi::XSEC_PIXEL_CLUSTER;
0105   else
0106     lumi_factor_per_bx_ = GetLumi::FREQ_ORBIT * GetLumi::SECONDS_PER_LS / GetLumi::rXSEC_PIXEL_CLUSTER;
0107 }
0108 
0109 void TrackAnalyzer::initHistos() {
0110   Chi2 = nullptr;
0111   Chi2Prob = nullptr;
0112   Chi2ProbVsPhi = nullptr;
0113   Chi2ProbVsEta = nullptr;
0114   Chi2oNDF = nullptr;
0115   Chi2oNDFVsEta = nullptr;
0116   Chi2oNDFVsPhi = nullptr;
0117   Chi2oNDFVsTheta = nullptr;
0118 
0119   NumberOfRecHitsPerTrack = nullptr;
0120   NumberOfValidRecHitsPerTrack = nullptr;
0121   NumberOfLostRecHitsPerTrack = nullptr;
0122 
0123   NumberOfRecHitsPerTrackVsPhi = nullptr;
0124   NumberOfRecHitsPerTrackVsTheta = nullptr;
0125   NumberOfRecHitsPerTrackVsEta = nullptr;
0126 
0127   NumberOfRecHitVsPhiVsEtaPerTrack = nullptr;
0128 
0129   NumberOfValidRecHitsPerTrackVsPhi = nullptr;
0130   NumberOfValidRecHitsPerTrackVsEta = nullptr;
0131 
0132   DistanceOfClosestApproach = nullptr;
0133   DistanceOfClosestApproachError = nullptr;
0134   DistanceOfClosestApproachErrorVsPt = nullptr;
0135   DistanceOfClosestApproachErrorVsEta = nullptr;
0136   DistanceOfClosestApproachErrorVsPhi = nullptr;
0137   DistanceOfClosestApproachErrorVsDxy = nullptr;
0138   DistanceOfClosestApproachToBS = nullptr;
0139   DistanceOfClosestApproachToBSdz = nullptr;
0140   AbsDistanceOfClosestApproachToBS = nullptr;
0141   DistanceOfClosestApproachToPV = nullptr;
0142   DistanceOfClosestApproachToPVZoom = nullptr;
0143   DeltaZToPV = nullptr;
0144   DeltaZToPVZoom = nullptr;
0145   DistanceOfClosestApproachVsTheta = nullptr;
0146   DistanceOfClosestApproachVsPhi = nullptr;
0147   DistanceOfClosestApproachToBSVsPhi = nullptr;
0148   DistanceOfClosestApproachToBSVsEta = nullptr;
0149   DistanceOfClosestApproachToPVVsPhi = nullptr;
0150   DistanceOfClosestApproachVsEta = nullptr;
0151   xPointOfClosestApproach = nullptr;
0152   xPointOfClosestApproachVsZ0wrt000 = nullptr;
0153   xPointOfClosestApproachVsZ0wrtBS = nullptr;
0154   yPointOfClosestApproach = nullptr;
0155   yPointOfClosestApproachVsZ0wrt000 = nullptr;
0156   yPointOfClosestApproachVsZ0wrtBS = nullptr;
0157   zPointOfClosestApproach = nullptr;
0158   zPointOfClosestApproachVsPhi = nullptr;
0159   algorithm = nullptr;
0160   oriAlgo = nullptr;
0161   stoppingSource = nullptr;
0162   stoppingSourceVSeta = nullptr;
0163   stoppingSourceVSphi = nullptr;
0164   // TESTING
0165   TESTDistanceOfClosestApproachToBS = nullptr;
0166   TESTDistanceOfClosestApproachToBSVsPhi = nullptr;
0167 
0168   // by Mia in order to deal w/ LS transitions
0169   Chi2oNDF_lumiFlag = nullptr;
0170   NumberOfRecHitsPerTrack_lumiFlag = nullptr;
0171 
0172   ////////////////////////////////////////////////////////////
0173   //special Plots for HI DQM  //SHOULD I ADD THE BOOL HERE??
0174   ////////////////////////////////////////////////////////////
0175   LongDCASig = nullptr;
0176   TransDCASig = nullptr;
0177   dNdPhi_HighPurity = nullptr;
0178   dNdEta_HighPurity = nullptr;
0179   dNdPt_HighPurity = nullptr;
0180   NhitVsEta_HighPurity = nullptr;
0181   NhitVsPhi_HighPurity = nullptr;
0182 
0183   // IP significance
0184   sipDxyToBS = nullptr;
0185   sipDzToBS = nullptr;
0186   sip3dToPV = nullptr;
0187   sip2dToPV = nullptr;
0188   sipDxyToPV = nullptr;
0189   sipDzToPV = nullptr;
0190 }
0191 
0192 TrackAnalyzer::~TrackAnalyzer() {}
0193 
0194 void TrackAnalyzer::initHisto(DQMStore::IBooker& ibooker,
0195                               const edm::EventSetup& iSetup,
0196                               const edm::ParameterSet& iConfig) {
0197   conf_ = &iConfig;
0198   bookHistosForHitProperties(ibooker);
0199   bookHistosForBeamSpot(ibooker);
0200   bookHistosForLScertification(ibooker);
0201   if (doEffFromHitPatternVsPU_ || doAllPlots_)
0202     bookHistosForEfficiencyFromHitPatter(ibooker, iSetup, "", false);
0203   if (doEffFromHitPatternVsBX_ || doAllPlots_)
0204     bookHistosForEfficiencyFromHitPatter(ibooker, iSetup, "VsBX", false);
0205   if (doEffFromHitPatternVsLUMI_ || doAllPlots_)
0206     bookHistosForEfficiencyFromHitPatter(ibooker, iSetup, "VsSCALLUMI", false);
0207   //  if (doEffFromHitPatternVsLUMI_ || doAllPlots_) bookHistosForEfficiencyFromHitPatter(ibooker, iSetup, "VsPIXELLUMI");
0208   if (doEffFromHitPatternVsPU_ || doAllPlots_)
0209     bookHistosForEfficiencyFromHitPatter(ibooker, iSetup, "", true);
0210   if (doEffFromHitPatternVsLUMI_ || doAllPlots_)
0211     bookHistosForEfficiencyFromHitPatter(ibooker, iSetup, "VsSCALLUMI", true);
0212 
0213   // book tracker specific related histograms
0214   // ---------------------------------------------------------------------------------//
0215   if (doTrackerSpecific_ || doAllPlots_)
0216     bookHistosForTrackerSpecific(ibooker);
0217 
0218   // book state related histograms
0219   // ---------------------------------------------------------------------------------//
0220   if (doMeasurementStatePlots_ || doAllPlots_) {
0221     if (stateName_ == "All") {
0222       bookHistosForState("OuterSurface", ibooker);
0223       bookHistosForState("InnerSurface", ibooker);
0224       bookHistosForState("ImpactPoint", ibooker);
0225     } else if (stateName_ != "OuterSurface" && stateName_ != "InnerSurface" && stateName_ != "ImpactPoint" &&
0226                stateName_ != "default") {
0227       bookHistosForState("default", ibooker);
0228 
0229     } else {
0230       bookHistosForState(stateName_, ibooker);
0231     }
0232     conf_ = nullptr;
0233   }
0234 }
0235 
0236 void TrackAnalyzer::bookHistosForEfficiencyFromHitPatter(DQMStore::IBooker& ibooker,
0237                                                          const edm::EventSetup& iSetup,
0238                                                          const std::string suffix,
0239                                                          bool useInac) {
0240   ibooker.setCurrentFolder(TopFolder_ + "/HitEffFromHitPattern" + (useInac ? "All" : "") + suffix);
0241 
0242   constexpr int LUMIBin = 300;  // conf_->getParameter<int>("LUMIBin");
0243   float LUMIMin = conf_->getParameter<double>("LUMIMin");
0244   float LUMIMax = conf_->getParameter<double>("LUMIMax");
0245 
0246   int PVBin = conf_->getParameter<int>("PVBin");
0247   float PVMin = conf_->getParameter<double>("PVMin");
0248   float PVMax = conf_->getParameter<double>("PVMax");
0249 
0250   int NBINS[] = {PVBin, int(GetLumi::lastBunchCrossing), LUMIBin, LUMIBin};
0251   float MIN[] = {PVMin, 0.5, LUMIMin, LUMIMin};
0252   float MAX[] = {PVMax, float(GetLumi::lastBunchCrossing) + 0.5, LUMIMax, LUMIMax};
0253   std::string NAME[] = {"", "VsBX", "VsLUMI", "VsLUMI"};
0254 
0255   auto logBins = makeLogBins<float, LUMIBin>(LUMIMin, LUMIMax);
0256 
0257   int mon = -1;
0258   int nbins = -1;
0259   float min = -1.;
0260   float max = -1.;
0261   bool logQ = false;
0262   std::string name = "";
0263   for (int i = 0; i < monQuantity::END; i++) {
0264     if (monName[i] == suffix) {
0265       logQ = (i > 1);  // VsLUMI
0266       mon = i;
0267       if (useInac)
0268         mon += monQuantity::END;
0269       nbins = NBINS[i];
0270       min = MIN[i];
0271       max = MAX[i];
0272       name = NAME[i];
0273     }
0274   }
0275 
0276   TrackerGeometry const& trackerGeometry = iSetup.getData(trackerGeometryToken_);
0277 
0278   // Values are not ordered randomly, but the order is taken from
0279   // http://cmslxr.fnal.gov/dxr/CMSSW/source/Geometry/CommonDetUnit/interface/GeomDetEnumerators.h#15
0280   const char* dets[] = {"None", "PXB", "PXF", "TIB", "TID", "TOB", "TEC"};
0281 
0282   // Also in this case, ordering is not random but extracted from
0283   // http://cmslxr.fnal.gov/dxr/CMSSW/source/DataFormats/TrackReco/interface/HitPattern.h
0284   // The category "total" is an addition to ease the computation of
0285   // the efficiencies and is not part of the original HitPattern.
0286   const char* hit_category[] = {"valid", "missing", "inactive", "bad", "total"};
0287 
0288   // We set sub_det to be a 1-based index since to it is the sub-sub-structure in the HitPattern
0289   char title[50];
0290   for (unsigned int det = 1; det < sizeof(dets) / sizeof(char*); ++det) {
0291     for (unsigned int sub_det = 1; sub_det <= trackerGeometry.numberOfLayers(det); ++sub_det) {
0292       for (unsigned int cat = 0; cat < sizeof(hit_category) / sizeof(char*); ++cat) {
0293         memset(title, 0, sizeof(title));
0294         snprintf(title, sizeof(title), "Hits%s_%s_%s_Subdet%d", name.c_str(), hit_category[cat], dets[det], sub_det);
0295         switch (cat) {
0296           case 0:
0297             hits_valid_.insert(std::make_pair(Key(det, sub_det, mon),
0298                                               logQ ? ibooker.book1D(title, title, nbins, &logBins[0])
0299                                                    : ibooker.book1D(title, title, nbins, min, max)));
0300             break;
0301           case 4:
0302             hits_total_.insert(std::make_pair(Key(det, sub_det, mon),
0303                                               logQ ? ibooker.book1D(title, title, nbins, &logBins[0])
0304                                                    : ibooker.book1D(title, title, nbins, min, max)));
0305             break;
0306           default:
0307             LogDebug("TrackAnalyzer") << "Invalid hit category used " << cat << " ignored\n";
0308         }
0309       }
0310     }
0311   }
0312 }
0313 
0314 #include "DataFormats/TrackCandidate/interface/TrajectoryStopReasons.h"
0315 void TrackAnalyzer::bookHistosForHitProperties(DQMStore::IBooker& ibooker) {
0316   // parameters from the configuration
0317   std::string QualName = conf_->getParameter<std::string>("Quality");
0318   std::string AlgoName = conf_->getParameter<std::string>("AlgoName");
0319   std::string MEBSFolderName = conf_->getParameter<std::string>("BSFolderName");
0320 
0321   // use the AlgoName and Quality Name
0322   std::string CategoryName = !QualName.empty() ? AlgoName + "_" + QualName : AlgoName;
0323 
0324   // get binning from the configuration
0325   int TKHitBin = conf_->getParameter<int>("RecHitBin");
0326   double TKHitMin = conf_->getParameter<double>("RecHitMin");
0327   double TKHitMax = conf_->getParameter<double>("RecHitMax");
0328 
0329   int TKLostBin = conf_->getParameter<int>("RecLostBin");
0330   double TKLostMin = conf_->getParameter<double>("RecLostMin");
0331   double TKLostMax = conf_->getParameter<double>("RecLostMax");
0332 
0333   int TKLayBin = conf_->getParameter<int>("RecLayBin");
0334   double TKLayMin = conf_->getParameter<double>("RecLayMin");
0335   double TKLayMax = conf_->getParameter<double>("RecLayMax");
0336 
0337   int PhiBin = conf_->getParameter<int>("PhiBin");
0338   double PhiMin = conf_->getParameter<double>("PhiMin");
0339   double PhiMax = conf_->getParameter<double>("PhiMax");
0340 
0341   int EtaBin = conf_->getParameter<int>("EtaBin");
0342   double EtaMin = conf_->getParameter<double>("EtaMin");
0343   double EtaMax = conf_->getParameter<double>("EtaMax");
0344 
0345   int PtBin = conf_->getParameter<int>("TrackPtBin");
0346   double PtMin = conf_->getParameter<double>("TrackPtMin");
0347   double PtMax = conf_->getParameter<double>("TrackPtMax");
0348 
0349   int Phi2DBin = conf_->getParameter<int>("Phi2DBin");
0350   int Eta2DBin = conf_->getParameter<int>("Eta2DBin");
0351   int Pt2DBin = conf_->getParameter<int>("TrackPt2DBin");
0352 
0353   int VXBin = conf_->getParameter<int>("VXBin");
0354   double VXMin = conf_->getParameter<double>("VXMin");
0355   double VXMax = conf_->getParameter<double>("VXMax");
0356 
0357   int VYBin = conf_->getParameter<int>("VYBin");
0358   double VYMin = conf_->getParameter<double>("VYMin");
0359   double VYMax = conf_->getParameter<double>("VYMax");
0360 
0361   int VZBin = conf_->getParameter<int>("VZBin");
0362   double VZMin = conf_->getParameter<double>("VZMin");
0363   double VZMax = conf_->getParameter<double>("VZMax");
0364 
0365   ibooker.setCurrentFolder(TopFolder_);
0366 
0367   // book the Hit Property histograms
0368   // ---------------------------------------------------------------------------------//
0369 
0370   TkParameterMEs tkmes;
0371   if (doHitPropertiesPlots_ || doAllPlots_) {
0372     ibooker.setCurrentFolder(TopFolder_ + "/HitProperties");
0373 
0374     histname = "NumberOfRecHitsPerTrack_";
0375     NumberOfRecHitsPerTrack =
0376         ibooker.book1D(histname + CategoryName, histname + CategoryName, TKHitBin, TKHitMin, TKHitMax);
0377     NumberOfRecHitsPerTrack->setAxisTitle("Number of all RecHits of each Track");
0378     NumberOfRecHitsPerTrack->setAxisTitle("Number of Tracks", 2);
0379 
0380     histname = "NumberOfValidRecHitsPerTrack_";
0381     NumberOfValidRecHitsPerTrack =
0382         ibooker.book1D(histname + CategoryName, histname + CategoryName, TKHitBin, TKHitMin, TKHitMax);
0383     NumberOfValidRecHitsPerTrack->setAxisTitle("Number of valid RecHits for each Track");
0384 
0385     NumberOfValidRecHitsPerTrack->setAxisTitle("Number of Tracks", 2);
0386 
0387     histname = "NumberOfLostRecHitsPerTrack_";
0388     NumberOfLostRecHitsPerTrack =
0389         ibooker.book1D(histname + CategoryName, histname + CategoryName, TKLostBin, TKLostMin, TKLostMax);
0390     NumberOfLostRecHitsPerTrack->setAxisTitle("Number of lost RecHits for each Track");
0391     NumberOfLostRecHitsPerTrack->setAxisTitle("Number of Tracks", 2);
0392 
0393     histname = "NumberOfMissingInnerRecHitsPerTrack_";
0394     NumberOfMIRecHitsPerTrack = ibooker.book1D(histname + CategoryName, histname + CategoryName, 10, -0.5, 9.5);
0395     NumberOfMIRecHitsPerTrack->setAxisTitle("Number of missing-inner RecHits for each Track");
0396     NumberOfMIRecHitsPerTrack->setAxisTitle("Number of Tracks", 2);
0397 
0398     histname = "NumberOfMissingOuterRecHitsPerTrack_";
0399     NumberOfMORecHitsPerTrack = ibooker.book1D(histname + CategoryName, histname + CategoryName, 10, -0.5, 9.5);
0400     NumberOfMORecHitsPerTrack->setAxisTitle("Number of missing-outer RecHits for each Track");
0401     NumberOfMORecHitsPerTrack->setAxisTitle("Number of Tracks", 2);
0402 
0403     histname = "ValidFractionPerTrack_";
0404     ValidFractionPerTrack = ibooker.book1D(histname + CategoryName, histname + CategoryName, 101, 0., 1.01);
0405     ValidFractionPerTrack->setAxisTitle("ValidFraction of RecHits for each Track");
0406     ValidFractionPerTrack->setAxisTitle("Number of Tracks", 2);
0407 
0408     if (doRecHitVsPhiVsEtaPerTrack_ || doAllPlots_) {
0409       histname = "NumberOfValidRecHitVsPhiVsEtaPerTrack_";
0410       NumberOfValidRecHitVsPhiVsEtaPerTrack = ibooker.bookProfile2D(histname + CategoryName,
0411                                                                     histname + CategoryName,
0412                                                                     Eta2DBin,
0413                                                                     EtaMin,
0414                                                                     EtaMax,
0415                                                                     Phi2DBin,
0416                                                                     PhiMin,
0417                                                                     PhiMax,
0418                                                                     0,
0419                                                                     40.,
0420                                                                     "");
0421       NumberOfValidRecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0422       NumberOfValidRecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #phi ", 2);
0423 
0424       histname = "NumberOfLostRecHitVsPhiVsEtaPerTrack_";
0425       NumberOfLostRecHitVsPhiVsEtaPerTrack = ibooker.bookProfile2D(histname + CategoryName,
0426                                                                    histname + CategoryName,
0427                                                                    Eta2DBin,
0428                                                                    EtaMin,
0429                                                                    EtaMax,
0430                                                                    Phi2DBin,
0431                                                                    PhiMin,
0432                                                                    PhiMax,
0433                                                                    0,
0434                                                                    5.,
0435                                                                    "");
0436       NumberOfLostRecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0437       NumberOfLostRecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #phi ", 2);
0438 
0439       histname = "NumberMIRecHitVsPhiVsEtaPerTrack_";
0440       NumberOfMIRecHitVsPhiVsEtaPerTrack = ibooker.bookProfile2D(histname + CategoryName,
0441                                                                  histname + CategoryName,
0442                                                                  Eta2DBin,
0443                                                                  EtaMin,
0444                                                                  EtaMax,
0445                                                                  Phi2DBin,
0446                                                                  PhiMin,
0447                                                                  PhiMax,
0448                                                                  0,
0449                                                                  15.,
0450                                                                  "");
0451       NumberOfMIRecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0452       NumberOfMIRecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #phi ", 2);
0453 
0454       histname = "NumberMORecHitVsPhiVsEtaPerTrack_";
0455       NumberOfMORecHitVsPhiVsEtaPerTrack = ibooker.bookProfile2D(histname + CategoryName,
0456                                                                  histname + CategoryName,
0457                                                                  Eta2DBin,
0458                                                                  EtaMin,
0459                                                                  EtaMax,
0460                                                                  Phi2DBin,
0461                                                                  PhiMin,
0462                                                                  PhiMax,
0463                                                                  0,
0464                                                                  15.,
0465                                                                  "");
0466       NumberOfMORecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0467       NumberOfMORecHitVsPhiVsEtaPerTrack->setAxisTitle("Track #phi ", 2);
0468 
0469       histname = "ValidFractionVsPhiVsEtaPerTrack_";
0470       ValidFractionVsPhiVsEtaPerTrack = ibooker.bookProfile2D(histname + CategoryName,
0471                                                               histname + CategoryName,
0472                                                               Eta2DBin,
0473                                                               EtaMin,
0474                                                               EtaMax,
0475                                                               Phi2DBin,
0476                                                               PhiMin,
0477                                                               PhiMax,
0478                                                               0,
0479                                                               2.,
0480                                                               "");
0481       ValidFractionVsPhiVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0482       ValidFractionVsPhiVsEtaPerTrack->setAxisTitle("Track #phi ", 2);
0483     }
0484 
0485     if (doRecHitVsPtVsEtaPerTrack_ || doAllPlots_) {
0486       histname = "NumberOfValidRecHitVsPtVsEtaPerTrack_";
0487       NumberOfValidRecHitVsPtVsEtaPerTrack = ibooker.bookProfile2D(
0488           histname + CategoryName, histname + CategoryName, Eta2DBin, EtaMin, EtaMax, Pt2DBin, PtMin, PtMax, 0, 40., "");
0489       NumberOfValidRecHitVsPtVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0490       NumberOfValidRecHitVsPtVsEtaPerTrack->setAxisTitle("Track p_{T} [GeV] ", 2);
0491 
0492       histname = "NumberOfLostRecHitVsPtVsEtaPerTrack_";
0493       NumberOfLostRecHitVsPtVsEtaPerTrack = ibooker.bookProfile2D(
0494           histname + CategoryName, histname + CategoryName, Eta2DBin, EtaMin, EtaMax, Pt2DBin, PtMin, PtMax, 0, 5., "");
0495       NumberOfLostRecHitVsPtVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0496       NumberOfLostRecHitVsPtVsEtaPerTrack->setAxisTitle("Track p_{T} [GeV] ", 2);
0497 
0498       histname = "NumberMIRecHitVsPtVsEtaPerTrack_";
0499       NumberOfMIRecHitVsPtVsEtaPerTrack = ibooker.bookProfile2D(
0500           histname + CategoryName, histname + CategoryName, Eta2DBin, EtaMin, EtaMax, Pt2DBin, PtMin, PtMax, 0, 15., "");
0501       NumberOfMIRecHitVsPtVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0502       NumberOfMIRecHitVsPtVsEtaPerTrack->setAxisTitle("Track p_{T} [GeV] ", 2);
0503 
0504       histname = "NumberMORecHitVsPtVsEtaPerTrack_";
0505       NumberOfMORecHitVsPtVsEtaPerTrack = ibooker.bookProfile2D(
0506           histname + CategoryName, histname + CategoryName, Eta2DBin, EtaMin, EtaMax, Pt2DBin, PtMin, PtMax, 0, 15., "");
0507       NumberOfMORecHitVsPtVsEtaPerTrack->setAxisTitle("Track #eta ", 1);
0508       NumberOfMORecHitVsPtVsEtaPerTrack->setAxisTitle("Track p_{T} [GeV] ", 2);
0509     }
0510 
0511     histname = "NumberOfValidRecHitsPerTrackVsPt_";
0512     NumberOfValidRecHitsPerTrackVsPt = ibooker.bookProfile(
0513         histname + CategoryName, histname + CategoryName, PtBin, PtMin, PtMax, TKHitMin, TKHitMax, "");
0514     NumberOfValidRecHitsPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
0515     NumberOfValidRecHitsPerTrackVsPt->setAxisTitle("Number of valid RecHits in each Track", 2);
0516 
0517     histname = "NumberOfLostRecHitsPerTrackVsPt_";
0518     NumberOfLostRecHitsPerTrackVsPt = ibooker.bookProfile(
0519         histname + CategoryName, histname + CategoryName, PtBin, PtMin, PtMax, TKHitMin, TKHitMax, "");
0520     NumberOfLostRecHitsPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
0521     NumberOfLostRecHitsPerTrackVsPt->setAxisTitle("Average Number of Lost RecHits per Track", 2);
0522 
0523     histname = "NumberMIRecHitsPerTrackVsPt_";
0524     NumberOfMIRecHitsPerTrackVsPt = ibooker.bookProfile(
0525         histname + CategoryName, histname + CategoryName, PtBin, PtMin, PtMax, TKHitMin, TKHitMax, "");
0526     NumberOfMIRecHitsPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
0527     NumberOfMIRecHitsPerTrackVsPt->setAxisTitle("Average Number of Lost RecHits per Track", 2);
0528 
0529     histname = "NumberMORecHitsPerTrackVsPt_";
0530     NumberOfMORecHitsPerTrackVsPt = ibooker.bookProfile(
0531         histname + CategoryName, histname + CategoryName, PtBin, PtMin, PtMax, TKHitMin, TKHitMax, "");
0532     NumberOfMORecHitsPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
0533     NumberOfMORecHitsPerTrackVsPt->setAxisTitle("Average Number of Lost RecHits per Track", 2);
0534 
0535     std::string layerTypeName[5] = {"", "Off", "3D", "Missing", "Pixel"};
0536     for (int i = 0; i < 4; ++i) {
0537       histname = "NumberOf" + layerTypeName[i] + "LayersPerTrack_";
0538       NumberOfLayersPerTrack[i] =
0539           ibooker.book1D(histname + CategoryName, histname + CategoryName, TKLayBin, TKLayMin, TKLayMax);
0540       NumberOfLayersPerTrack[i]->setAxisTitle("Number of " + layerTypeName[i] + " Layers of each Track", 1);
0541       NumberOfLayersPerTrack[i]->setAxisTitle("Number of Tracks", 2);
0542     }
0543     if (doLayersVsPhiVsEtaPerTrack_ || doAllPlots_)
0544       for (int i = 0; i < 5; ++i) {
0545         histname = "NumberOf" + layerTypeName[i] + "LayersVsPhiVsEtaPerTrack_";
0546         NumberOfLayersVsPhiVsEtaPerTrack[i] = ibooker.bookProfile2D(histname + CategoryName,
0547                                                                     histname + CategoryName,
0548                                                                     Eta2DBin,
0549                                                                     EtaMin,
0550                                                                     EtaMax,
0551                                                                     Phi2DBin,
0552                                                                     PhiMin,
0553                                                                     PhiMax,
0554                                                                     0,
0555                                                                     40.,
0556                                                                     "");
0557         NumberOfLayersVsPhiVsEtaPerTrack[i]->setAxisTitle("Track #eta ", 1);
0558         NumberOfLayersVsPhiVsEtaPerTrack[i]->setAxisTitle("Track #phi ", 2);
0559       }
0560   }
0561 
0562   // book the General Property histograms
0563   // ---------------------------------------------------------------------------------//
0564 
0565   if (doGeneralPropertiesPlots_ || doAllPlots_) {
0566     int Chi2Bin = conf_->getParameter<int>("Chi2Bin");
0567     double Chi2Min = conf_->getParameter<double>("Chi2Min");
0568     double Chi2Max = conf_->getParameter<double>("Chi2Max");
0569 
0570     int Chi2NDFBin = conf_->getParameter<int>("Chi2NDFBin");
0571     double Chi2NDFMin = conf_->getParameter<double>("Chi2NDFMin");
0572     double Chi2NDFMax = conf_->getParameter<double>("Chi2NDFMax");
0573 
0574     int Chi2ProbBin = conf_->getParameter<int>("Chi2ProbBin");
0575     double Chi2ProbMin = conf_->getParameter<double>("Chi2ProbMin");
0576     double Chi2ProbMax = conf_->getParameter<double>("Chi2ProbMax");
0577 
0578     //HI PLOTS////
0579     int TransDCABins = conf_->getParameter<int>("TransDCABins");
0580     double TransDCAMin = conf_->getParameter<double>("TransDCAMin");
0581     double TransDCAMax = conf_->getParameter<double>("TransDCAMax");
0582 
0583     int LongDCABins = conf_->getParameter<int>("LongDCABins");
0584     double LongDCAMin = conf_->getParameter<double>("LongDCAMin");
0585     double LongDCAMax = conf_->getParameter<double>("LongDCAMax");
0586     ///////////////////////////////////////////////////////////////////
0587 
0588     ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
0589 
0590     histname = "Chi2_";
0591     Chi2 = ibooker.book1D(histname + CategoryName, histname + CategoryName, Chi2Bin, Chi2Min, Chi2Max);
0592     Chi2->setAxisTitle("Track #chi^{2}", 1);
0593     Chi2->setAxisTitle("Number of Tracks", 2);
0594 
0595     histname = "Chi2Prob_";
0596     Chi2Prob = ibooker.book1D(histname + CategoryName, histname + CategoryName, Chi2ProbBin, Chi2ProbMin, Chi2ProbMax);
0597     Chi2Prob->setAxisTitle("Track #chi^{2} probability", 1);
0598     Chi2Prob->setAxisTitle("Number of Tracks", 2);
0599 
0600     histname = "Chi2oNDF_";
0601     Chi2oNDF = ibooker.book1D(histname + CategoryName, histname + CategoryName, Chi2NDFBin, Chi2NDFMin, Chi2NDFMax);
0602     Chi2oNDF->setAxisTitle("Track #chi^{2}/ndf", 1);
0603     Chi2oNDF->setAxisTitle("Number of Tracks", 2);
0604 
0605     //////////////
0606     //HI PLOTS///
0607     //////////////
0608     if (doHIPlots_) {
0609       histname = "LongDCASig_";
0610       LongDCASig =
0611           ibooker.book1D(histname + CategoryName, histname + CategoryName, LongDCABins, LongDCAMin, LongDCAMax);
0612       LongDCASig->setAxisTitle("dz/#sigma_{dz}", 1);
0613 
0614       histname = "TransDCASig_";
0615       TransDCASig =
0616           ibooker.book1D(histname + CategoryName, histname + CategoryName, TransDCABins, TransDCAMin, TransDCAMax);
0617       TransDCASig->setAxisTitle("dxy/#sigma_{dxy}", 1);
0618 
0619       histname = "dNdPhi_HighPurity_";
0620       dNdPhi_HighPurity = ibooker.book1D(histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax);
0621       dNdPhi_HighPurity->setAxisTitle("#phi", 1);
0622 
0623       histname = "dNdEta_HighPurity_";
0624       dNdEta_HighPurity = ibooker.book1D(histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax);
0625       dNdEta_HighPurity->setAxisTitle("#eta", 1);
0626 
0627       histname = "dNdPt_HighPurity_";
0628       dNdPt_HighPurity = ibooker.book1D(histname + CategoryName, histname + CategoryName, 150, 0, 0.3);
0629       dNdPt_HighPurity->setAxisTitle("#sigma_{p_{T}}/p_{T}", 1);
0630 
0631       histname = "NhitVsEta_HighPurity_";
0632       NhitVsEta_HighPurity =
0633           ibooker.bookProfile(histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, -0.5, 39.5, "");
0634       NhitVsEta_HighPurity->setAxisTitle("Track #eta", 1);
0635       NhitVsEta_HighPurity->setAxisTitle("Number of Valid RecHits in each Track", 2);
0636 
0637       histname = "NhitVsPhi_HighPurity_";
0638       NhitVsPhi_HighPurity =
0639           ibooker.bookProfile(histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, -0.5, 39.5, "");
0640       NhitVsPhi_HighPurity->setAxisTitle("Track #phi", 1);
0641       NhitVsPhi_HighPurity->setAxisTitle("Number of Valid RecHits in each Track", 2);
0642 
0643       histname = "Ptdist_HighPurity_";
0644       Ptdist_HighPurity = ibooker.book1D(histname + CategoryName, histname + CategoryName, 150, 0, 50.);
0645       Ptdist_HighPurity->setAxisTitle("p_{T} (GeV/c)", 1);
0646       Ptdist_HighPurity->setAxisTitle("Number of Tracks", 2);
0647 
0648       histname = "dNhitdPt_HighPurity_";
0649       dNhitdPt_HighPurity =
0650           ibooker.bookProfile(histname + CategoryName, histname + CategoryName, 150, 0, 25., -0.5, 39.5, "");
0651       dNhitdPt_HighPurity->setAxisTitle("p_{T} (GeV/c)", 1);
0652       dNhitdPt_HighPurity->setAxisTitle("N_{hit}", 2);
0653     }
0654 
0655     if (doDCAPlots_ || doPVPlots_ || doSIPPlots_ || doAllPlots_) {
0656       histname = "xPointOfClosestApproach_";
0657       xPointOfClosestApproach = ibooker.book1D(histname + CategoryName, histname + CategoryName, VXBin, VXMin, VXMax);
0658       xPointOfClosestApproach->setAxisTitle("x component of Track PCA to beam line (cm)", 1);
0659       xPointOfClosestApproach->setAxisTitle("Number of Tracks", 2);
0660 
0661       histname = "yPointOfClosestApproach_";
0662       yPointOfClosestApproach = ibooker.book1D(histname + CategoryName, histname + CategoryName, VYBin, VYMin, VYMax);
0663       yPointOfClosestApproach->setAxisTitle("y component of Track PCA to beam line (cm)", 1);
0664       yPointOfClosestApproach->setAxisTitle("Number of Tracks", 2);
0665 
0666       histname = "zPointOfClosestApproach_";
0667       zPointOfClosestApproach = ibooker.book1D(histname + CategoryName, histname + CategoryName, VZBin, VZMin, VZMax);
0668       zPointOfClosestApproach->setAxisTitle("z component of Track PCA to beam line (cm)", 1);
0669       zPointOfClosestApproach->setAxisTitle("Number of Tracks", 2);
0670 
0671       histname = "xPointOfClosestApproachToPV_";
0672       xPointOfClosestApproachToPV =
0673           ibooker.book1D(histname + CategoryName, histname + CategoryName, VXBin, VXMin, VXMax);
0674       xPointOfClosestApproachToPV->setAxisTitle("x component of Track PCA to pv (cm)", 1);
0675       xPointOfClosestApproachToPV->setAxisTitle("Number of Tracks", 2);
0676 
0677       histname = "yPointOfClosestApproachToPV_";
0678       yPointOfClosestApproachToPV =
0679           ibooker.book1D(histname + CategoryName, histname + CategoryName, VYBin, VYMin, VYMax);
0680       yPointOfClosestApproachToPV->setAxisTitle("y component of Track PCA to pv line (cm)", 1);
0681       yPointOfClosestApproachToPV->setAxisTitle("Number of Tracks", 2);
0682 
0683       histname = "zPointOfClosestApproachToPV_";
0684       zPointOfClosestApproachToPV =
0685           ibooker.book1D(histname + CategoryName, histname + CategoryName, VZBin, VZMin, VZMax);
0686       zPointOfClosestApproachToPV->setAxisTitle("z component of Track PCA to pv line (cm)", 1);
0687       zPointOfClosestApproachToPV->setAxisTitle("Number of Tracks", 2);
0688     }
0689 
0690     // See DataFormats/TrackReco/interface/TrackBase.h for track algorithm enum definition
0691     // http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/DataFormats/TrackReco/interface/TrackBase.h?view=log
0692     histname = "algorithm_";
0693     algorithm = ibooker.book1D(histname + CategoryName,
0694                                histname + CategoryName,
0695                                reco::TrackBase::algoSize,
0696                                0.,
0697                                double(reco::TrackBase::algoSize));
0698     algorithm->setAxisTitle("Tracking algorithm", 1);
0699     algorithm->setAxisTitle("Number of Tracks", 2);
0700 
0701     histname = "originalAlgorithm_";
0702     oriAlgo = ibooker.book1D(histname + CategoryName,
0703                              histname + CategoryName,
0704                              reco::TrackBase::algoSize,
0705                              0.,
0706                              double(reco::TrackBase::algoSize));
0707     oriAlgo->setAxisTitle("Tracking algorithm", 1);
0708     oriAlgo->setAxisTitle("Number of Tracks", 2);
0709 
0710     for (size_t ibin = 0; ibin < reco::TrackBase::algoSize - 1; ibin++) {
0711       algorithm->setBinLabel(ibin + 1, reco::TrackBase::algoNames[ibin]);
0712       oriAlgo->setBinLabel(ibin + 1, reco::TrackBase::algoNames[ibin]);
0713     }
0714 
0715     size_t StopReasonNameSize = sizeof(StopReasonName::StopReasonName) / sizeof(std::string);
0716     histname = "stoppingSource_";
0717     stoppingSource = ibooker.book1D(
0718         histname + CategoryName, histname + CategoryName, StopReasonNameSize, 0., double(StopReasonNameSize));
0719     stoppingSource->setAxisTitle("stopping reason", 1);
0720     stoppingSource->setAxisTitle("Number of Tracks", 2);
0721 
0722     histname = "stoppingSourceVSeta_";
0723     stoppingSourceVSeta =
0724         ibooker.bookProfile(histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, 2, 0., 2.);
0725     stoppingSourceVSeta->setAxisTitle("track #eta", 1);
0726     stoppingSourceVSeta->setAxisTitle("stopped fraction", 2);
0727 
0728     histname = "stoppingSourceVSphi_";
0729     stoppingSourceVSphi =
0730         ibooker.bookProfile(histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, 2, 0., 2.);
0731     stoppingSourceVSphi->setAxisTitle("track #phi", 1);
0732     stoppingSourceVSphi->setAxisTitle("stopped fraction", 2);
0733 
0734     for (size_t ibin = 0; ibin < StopReasonNameSize; ibin++) {
0735       stoppingSource->setBinLabel(ibin + 1, StopReasonName::StopReasonName[ibin], 1);
0736     }
0737   }
0738 }
0739 
0740 void TrackAnalyzer::bookHistosForLScertification(DQMStore::IBooker& ibooker) {
0741   // parameters from the configuration
0742   std::string QualName = conf_->getParameter<std::string>("Quality");
0743   std::string AlgoName = conf_->getParameter<std::string>("AlgoName");
0744 
0745   // use the AlgoName and Quality Name
0746   std::string CategoryName = !QualName.empty() ? AlgoName + "_" + QualName : AlgoName;
0747 
0748   // book LS analysis related histograms
0749   // -----------------------------------
0750   if (doLumiAnalysis_) {
0751     // get binning from the configuration
0752     int TKHitBin = conf_->getParameter<int>("RecHitBin");
0753     double TKHitMin = conf_->getParameter<double>("RecHitMin");
0754     double TKHitMax = conf_->getParameter<double>("RecHitMax");
0755 
0756     int Chi2NDFBin = conf_->getParameter<int>("Chi2NDFBin");
0757     double Chi2NDFMin = conf_->getParameter<double>("Chi2NDFMin");
0758     double Chi2NDFMax = conf_->getParameter<double>("Chi2NDFMax");
0759 
0760     // add by Mia in order to deal w/ LS transitions
0761     ibooker.setCurrentFolder(TopFolder_ + "/LSanalysis");
0762 
0763     histname = "NumberOfRecHitsPerTrack_lumiFlag_";
0764     NumberOfRecHitsPerTrack_lumiFlag =
0765         ibooker.book1D(histname + CategoryName, histname + CategoryName, TKHitBin, TKHitMin, TKHitMax);
0766     NumberOfRecHitsPerTrack_lumiFlag->setAxisTitle("Number of all RecHits of each Track");
0767     NumberOfRecHitsPerTrack_lumiFlag->setAxisTitle("Number of Tracks", 2);
0768 
0769     histname = "Chi2oNDF_lumiFlag_";
0770     Chi2oNDF_lumiFlag =
0771         ibooker.book1D(histname + CategoryName, histname + CategoryName, Chi2NDFBin, Chi2NDFMin, Chi2NDFMax);
0772     Chi2oNDF_lumiFlag->setAxisTitle("Track #chi^{2}/ndf", 1);
0773     Chi2oNDF_lumiFlag->setAxisTitle("Number of Tracks", 2);
0774   }
0775 }
0776 
0777 void TrackAnalyzer::bookHistosForBeamSpot(DQMStore::IBooker& ibooker) {
0778   // parameters from the configuration
0779   std::string QualName = conf_->getParameter<std::string>("Quality");
0780   std::string AlgoName = conf_->getParameter<std::string>("AlgoName");
0781 
0782   // use the AlgoName and Quality Name
0783   std::string CategoryName = !QualName.empty() ? AlgoName + "_" + QualName : AlgoName;
0784   std::string Folder = TopFolder_.substr(0, 2);
0785 
0786   // book the Beam Spot related histograms
0787   // ---------------------------------------------------------------------------------//
0788 
0789   if (doDCAPlots_ || doBSPlots_ || doAllPlots_) {
0790     int DxyErrBin = conf_->getParameter<int>("DxyErrBin");
0791     double DxyErrMax = conf_->getParameter<double>("DxyErrMax");
0792 
0793     int DxyBin = conf_->getParameter<int>("DxyBin");
0794     double DxyMin = conf_->getParameter<double>("DxyMin");
0795     double DxyMax = conf_->getParameter<double>("DxyMax");
0796 
0797     int AbsDxyBin = conf_->getParameter<int>("AbsDxyBin");
0798     double AbsDxyMin = conf_->getParameter<double>("AbsDxyMin");
0799     double AbsDxyMax = conf_->getParameter<double>("AbsDxyMax");
0800 
0801     int PhiBin = conf_->getParameter<int>("PhiBin");
0802     double PhiMin = conf_->getParameter<double>("PhiMin");
0803     double PhiMax = conf_->getParameter<double>("PhiMax");
0804 
0805     int EtaBin = conf_->getParameter<int>("EtaBin");
0806     double EtaMin = conf_->getParameter<double>("EtaMin");
0807     double EtaMax = conf_->getParameter<double>("EtaMax");
0808 
0809     int PtBin = conf_->getParameter<int>("TrackPtBin");
0810     double PtMin = conf_->getParameter<double>("TrackPtMin");
0811     double PtMax = conf_->getParameter<double>("TrackPtMax");
0812 
0813     int X0Bin = conf_->getParameter<int>("X0Bin");
0814     double X0Min = conf_->getParameter<double>("X0Min");
0815     double X0Max = conf_->getParameter<double>("X0Max");
0816 
0817     int Y0Bin = conf_->getParameter<int>("Y0Bin");
0818     double Y0Min = conf_->getParameter<double>("Y0Min");
0819     double Y0Max = conf_->getParameter<double>("Y0Max");
0820 
0821     int Z0Bin = conf_->getParameter<int>("Z0Bin");
0822     double Z0Min = conf_->getParameter<double>("Z0Min");
0823     double Z0Max = conf_->getParameter<double>("Z0Max");
0824 
0825     int VZBinProf = conf_->getParameter<int>("VZBinProf");
0826     double VZMinProf = conf_->getParameter<double>("VZMinProf");
0827     double VZMaxProf = conf_->getParameter<double>("VZMaxProf");
0828 
0829     ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
0830 
0831     histname = "DistanceOfClosestApproachError_";
0832     DistanceOfClosestApproachError =
0833         ibooker.book1D(histname + CategoryName, histname + CategoryName, DxyErrBin, 0., DxyErrMax);
0834     DistanceOfClosestApproachError->setAxisTitle("Track d_{xy} error (cm)", 1);
0835     DistanceOfClosestApproachError->setAxisTitle("Number of Tracks", 2);
0836 
0837     histname = "DistanceOfClosestApproachErrorVsPt_";
0838     DistanceOfClosestApproachErrorVsPt =
0839         ibooker.bookProfile(histname + CategoryName, histname + CategoryName, PtBin, PtMin, PtMax, 0., DxyErrMax);
0840     DistanceOfClosestApproachErrorVsPt->setAxisTitle("Track p_{T} (GeV)", 1);
0841     DistanceOfClosestApproachErrorVsPt->setAxisTitle("Track d_{xy} error (cm)", 2);
0842 
0843     histname = "DistanceOfClosestApproachErrorVsEta_";
0844     DistanceOfClosestApproachErrorVsEta =
0845         ibooker.bookProfile(histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, 0., DxyErrMax);
0846     DistanceOfClosestApproachErrorVsEta->setAxisTitle("Track #eta", 1);
0847     DistanceOfClosestApproachErrorVsEta->setAxisTitle("Track d_{xy} error (cm)", 2);
0848 
0849     histname = "DistanceOfClosestApproachErrorVsPhi_";
0850     DistanceOfClosestApproachErrorVsPhi =
0851         ibooker.bookProfile(histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, 0., DxyErrMax);
0852     DistanceOfClosestApproachErrorVsPhi->setAxisTitle("Track #phi", 1);
0853     DistanceOfClosestApproachErrorVsPhi->setAxisTitle("Track d_{xy} error (cm)", 2);
0854 
0855     histname = "DistanceOfClosestApproachErrorVsDxy_";
0856     DistanceOfClosestApproachErrorVsDxy =
0857         ibooker.bookProfile(histname + CategoryName, histname + CategoryName, DxyBin, DxyMin, DxyMax, 0., DxyErrMax);
0858     DistanceOfClosestApproachErrorVsDxy->setAxisTitle("Track d_{xy}", 1);
0859     DistanceOfClosestApproachErrorVsDxy->setAxisTitle("Track d_{xy} error (cm)", 2);
0860 
0861     histname = "DistanceOfClosestApproachToBS_";
0862     DistanceOfClosestApproachToBS =
0863         ibooker.book1D(histname + CategoryName, histname + CategoryName, DxyBin, DxyMin, DxyMax);
0864     DistanceOfClosestApproachToBS->setAxisTitle("Track d_{xy} wrt beam spot (cm)", 1);
0865     DistanceOfClosestApproachToBS->setAxisTitle("Number of Tracks", 2);
0866 
0867     if (Folder == "Tr") {
0868       histname = "DistanceOfClosestApproachToBSdz_";
0869       DistanceOfClosestApproachToBSdz =
0870           ibooker.book1D(histname + CategoryName, histname + CategoryName, 100, -20.1, 20.1);
0871       DistanceOfClosestApproachToBSdz->setAxisTitle("Track d_{z} wrt beam spot (cm)", 1);
0872       DistanceOfClosestApproachToBSdz->setAxisTitle("Number of Tracks", 2);
0873 
0874       histname = "DistanceOfClosestApproachToBSVsEta_";
0875       DistanceOfClosestApproachToBSVsEta = ibooker.bookProfile(
0876           histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, DxyBin, DxyMin, DxyMax, "");
0877       DistanceOfClosestApproachToBSVsEta->setAxisTitle("Track #eta", 1);
0878       DistanceOfClosestApproachToBSVsEta->setAxisTitle("Track d_{xy} wrt beam spot (cm)", 2);
0879     }
0880 
0881     histname = "AbsDistanceOfClosestApproachToBS_";
0882     AbsDistanceOfClosestApproachToBS =
0883         ibooker.book1D(histname + CategoryName, histname + CategoryName, AbsDxyBin, AbsDxyMin, AbsDxyMax);
0884     AbsDistanceOfClosestApproachToBS->setAxisTitle("Track |d_{xy}| wrt beam spot (cm)", 1);
0885     AbsDistanceOfClosestApproachToBS->setAxisTitle("Number of Tracks", 2);
0886 
0887     histname = "DistanceOfClosestApproachToBSVsPhi_";
0888     DistanceOfClosestApproachToBSVsPhi = ibooker.bookProfile(
0889         histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, DxyBin, DxyMin, DxyMax, "");
0890     DistanceOfClosestApproachToBSVsPhi->setAxisTitle("Track #phi", 1);
0891     DistanceOfClosestApproachToBSVsPhi->setAxisTitle("Track d_{xy} wrt beam spot (cm)", 2);
0892 
0893     histname = "xPointOfClosestApproachVsZ0wrt000_";
0894     xPointOfClosestApproachVsZ0wrt000 = ibooker.bookProfile(
0895         histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max, X0Bin, X0Min, X0Max, "");
0896     xPointOfClosestApproachVsZ0wrt000->setAxisTitle("d_{z} (cm)", 1);
0897     xPointOfClosestApproachVsZ0wrt000->setAxisTitle("x component of Track PCA to beam line (cm)", 2);
0898 
0899     histname = "yPointOfClosestApproachVsZ0wrt000_";
0900     yPointOfClosestApproachVsZ0wrt000 = ibooker.bookProfile(
0901         histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max, Y0Bin, Y0Min, Y0Max, "");
0902     yPointOfClosestApproachVsZ0wrt000->setAxisTitle("d_{z} (cm)", 1);
0903     yPointOfClosestApproachVsZ0wrt000->setAxisTitle("y component of Track PCA to beam line (cm)", 2);
0904 
0905     histname = "xPointOfClosestApproachVsZ0wrtBS_";
0906     xPointOfClosestApproachVsZ0wrtBS = ibooker.bookProfile(
0907         histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max, X0Bin, X0Min, X0Max, "");
0908     xPointOfClosestApproachVsZ0wrtBS->setAxisTitle("d_{z} w.r.t. Beam Spot  (cm)", 1);
0909     xPointOfClosestApproachVsZ0wrtBS->setAxisTitle("x component of Track PCA to BS (cm)", 2);
0910 
0911     histname = "yPointOfClosestApproachVsZ0wrtBS_";
0912     yPointOfClosestApproachVsZ0wrtBS = ibooker.bookProfile(
0913         histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max, Y0Bin, Y0Min, Y0Max, "");
0914     yPointOfClosestApproachVsZ0wrtBS->setAxisTitle("d_{z} w.r.t. Beam Spot (cm)", 1);
0915     yPointOfClosestApproachVsZ0wrtBS->setAxisTitle("y component of Track PCA to BS (cm)", 2);
0916 
0917     histname = "zPointOfClosestApproachVsPhi_";
0918     zPointOfClosestApproachVsPhi = ibooker.bookProfile(
0919         histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, VZBinProf, VZMinProf, VZMaxProf, "");
0920     zPointOfClosestApproachVsPhi->setAxisTitle("Track #phi", 1);
0921     zPointOfClosestApproachVsPhi->setAxisTitle("z component of Track PCA to beam line (cm)", 2);
0922   }
0923 
0924   if (doDCAPlots_ || doPVPlots_ || doAllPlots_) {
0925     int DxyBin = conf_->getParameter<int>("DxyBin");
0926     double DxyMin = conf_->getParameter<double>("DxyMin");
0927     double DxyMax = conf_->getParameter<double>("DxyMax");
0928 
0929     int PhiBin = conf_->getParameter<int>("PhiBin");
0930     double PhiMin = conf_->getParameter<double>("PhiMin");
0931     double PhiMax = conf_->getParameter<double>("PhiMax");
0932 
0933     int X0Bin = conf_->getParameter<int>("X0Bin");
0934     double X0Min = conf_->getParameter<double>("X0Min");
0935     double X0Max = conf_->getParameter<double>("X0Max");
0936 
0937     int Y0Bin = conf_->getParameter<int>("Y0Bin");
0938     double Y0Min = conf_->getParameter<double>("Y0Min");
0939     double Y0Max = conf_->getParameter<double>("Y0Max");
0940 
0941     int Z0Bin = conf_->getParameter<int>("Z0Bin");
0942     double Z0Min = conf_->getParameter<double>("Z0Min");
0943     double Z0Max = conf_->getParameter<double>("Z0Max");
0944 
0945     ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
0946 
0947     histname = "DistanceOfClosestApproachToPV_";
0948     DistanceOfClosestApproachToPV =
0949         ibooker.book1D(histname + CategoryName, histname + CategoryName, DxyBin, DxyMin, DxyMax);
0950     DistanceOfClosestApproachToPV->setAxisTitle("Track d_{xy} w.r.t. PV (cm)", 1);
0951     DistanceOfClosestApproachToPV->setAxisTitle("Number of Tracks", 2);
0952 
0953     histname = "DistanceOfClosestApproachToPVZoom_";
0954     DistanceOfClosestApproachToPVZoom =
0955         ibooker.book1D(histname + CategoryName, histname + CategoryName, 100, -0.08, 0.08);
0956     DistanceOfClosestApproachToPVZoom->setAxisTitle("Track d_{xy} w.r.t. PV (cm)", 1);
0957     DistanceOfClosestApproachToPVZoom->setAxisTitle("Number of Tracks", 2);
0958 
0959     histname = "DeltaZToPV_";
0960     DeltaZToPV = ibooker.book1D(histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max);
0961     DeltaZToPV->setAxisTitle("Track d_{z} w.r.t. PV (cm)", 1);
0962     DeltaZToPV->setAxisTitle("Number of Tracks", 2);
0963 
0964     histname = "DeltaZToPVZoom_";
0965     DeltaZToPVZoom = ibooker.book1D(histname + CategoryName, histname + CategoryName, 100, -0.15, 0.15);
0966     DeltaZToPVZoom->setAxisTitle("Track d_{z} w.r.t. PV (cm)", 1);
0967     DeltaZToPVZoom->setAxisTitle("Number of Tracks", 2);
0968 
0969     histname = "DistanceOfClosestApproachToPVVsPhi_";
0970     DistanceOfClosestApproachToPVVsPhi = ibooker.bookProfile(
0971         histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, DxyBin, DxyMin, DxyMax, "");
0972     DistanceOfClosestApproachToPVVsPhi->setAxisTitle("Track #phi", 1);
0973     DistanceOfClosestApproachToPVVsPhi->setAxisTitle("Track d_{xy} w.r.t. PV (cm)", 2);
0974 
0975     histname = "xPointOfClosestApproachVsZ0wrtPV_";
0976     xPointOfClosestApproachVsZ0wrtPV = ibooker.bookProfile(
0977         histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max, X0Bin, X0Min, X0Max, "");
0978     xPointOfClosestApproachVsZ0wrtPV->setAxisTitle("d_{z} w.r.t. PV (cm)", 1);
0979     xPointOfClosestApproachVsZ0wrtPV->setAxisTitle("x component of Track PCA to PV (cm)", 2);
0980 
0981     histname = "yPointOfClosestApproachVsZ0wrtPV_";
0982     yPointOfClosestApproachVsZ0wrtPV = ibooker.bookProfile(
0983         histname + CategoryName, histname + CategoryName, Z0Bin, Z0Min, Z0Max, Y0Bin, Y0Min, Y0Max, "");
0984     yPointOfClosestApproachVsZ0wrtPV->setAxisTitle("d_{z} w.r.t. PV (cm)", 1);
0985     yPointOfClosestApproachVsZ0wrtPV->setAxisTitle("y component of Track PCA to PV (cm)", 2);
0986   }
0987 
0988   if (doBSPlots_ || doAllPlots_) {
0989     if (doTestPlots_) {
0990       int DxyBin = conf_->getParameter<int>("DxyBin");
0991       double DxyMin = conf_->getParameter<double>("DxyMin");
0992       double DxyMax = conf_->getParameter<double>("DxyMax");
0993 
0994       int PhiBin = conf_->getParameter<int>("PhiBin");
0995       double PhiMin = conf_->getParameter<double>("PhiMin");
0996       double PhiMax = conf_->getParameter<double>("PhiMax");
0997 
0998       histname = "TESTDistanceOfClosestApproachToBS_";
0999       TESTDistanceOfClosestApproachToBS =
1000           ibooker.book1D(histname + CategoryName, histname + CategoryName, DxyBin, DxyMin, DxyMax);
1001       TESTDistanceOfClosestApproachToBS->setAxisTitle("Track d_{xy} wrt beam spot (cm)", 1);
1002       TESTDistanceOfClosestApproachToBS->setAxisTitle("Number of Tracks", 2);
1003 
1004       histname = "TESTDistanceOfClosestApproachToBSVsPhi_";
1005       TESTDistanceOfClosestApproachToBSVsPhi = ibooker.bookProfile(
1006           histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, DxyBin, DxyMin, DxyMax, "");
1007       TESTDistanceOfClosestApproachToBSVsPhi->setAxisTitle("Track #phi", 1);
1008       TESTDistanceOfClosestApproachToBSVsPhi->setAxisTitle("Track d_{xy} wrt beam spot (cm)", 2);
1009     }
1010   }
1011 
1012   // book the Profile plots for DCA related histograms
1013   // ---------------------------------------------------------------------------------//
1014   if (doDCAPlots_ || doAllPlots_) {
1015     if (doDCAwrt000Plots_) {
1016       int EtaBin = conf_->getParameter<int>("EtaBin");
1017       double EtaMin = conf_->getParameter<double>("EtaMin");
1018       double EtaMax = conf_->getParameter<double>("EtaMax");
1019 
1020       int PhiBin = conf_->getParameter<int>("PhiBin");
1021       double PhiMin = conf_->getParameter<double>("PhiMin");
1022       double PhiMax = conf_->getParameter<double>("PhiMax");
1023 
1024       int DxyBin = conf_->getParameter<int>("DxyBin");
1025       double DxyMin = conf_->getParameter<double>("DxyMin");
1026       double DxyMax = conf_->getParameter<double>("DxyMax");
1027 
1028       if (doThetaPlots_) {
1029         int ThetaBin = conf_->getParameter<int>("ThetaBin");
1030         double ThetaMin = conf_->getParameter<double>("ThetaMin");
1031         double ThetaMax = conf_->getParameter<double>("ThetaMax");
1032 
1033         ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
1034         histname = "DistanceOfClosestApproachVsTheta_";
1035         DistanceOfClosestApproachVsTheta = ibooker.bookProfile(
1036             histname + CategoryName, histname + CategoryName, ThetaBin, ThetaMin, ThetaMax, DxyMin, DxyMax, "");
1037         DistanceOfClosestApproachVsTheta->setAxisTitle("Track #theta", 1);
1038         DistanceOfClosestApproachVsTheta->setAxisTitle("Track d_{xy} wrt (0,0,0) (cm)", 2);
1039       }
1040 
1041       histname = "DistanceOfClosestApproachVsEta_";
1042       DistanceOfClosestApproachVsEta = ibooker.bookProfile(
1043           histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, DxyMin, DxyMax, "");
1044       DistanceOfClosestApproachVsEta->setAxisTitle("Track #eta", 1);
1045       DistanceOfClosestApproachVsEta->setAxisTitle("Track d_{xy} wrt (0,0,0) (cm)", 2);
1046       // temporary patch in order to put back those MEs in Muon Workspace
1047 
1048       histname = "DistanceOfClosestApproach_";
1049       DistanceOfClosestApproach =
1050           ibooker.book1D(histname + CategoryName, histname + CategoryName, DxyBin, DxyMin, DxyMax);
1051       DistanceOfClosestApproach->setAxisTitle("Track d_{xy} wrt (0,0,0) (cm)", 1);
1052       DistanceOfClosestApproach->setAxisTitle("Number of Tracks", 2);
1053 
1054       histname = "DistanceOfClosestApproachVsPhi_";
1055       DistanceOfClosestApproachVsPhi = ibooker.bookProfile(
1056           histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, DxyMin, DxyMax, "");
1057       DistanceOfClosestApproachVsPhi->setAxisTitle("Track #phi", 1);
1058       DistanceOfClosestApproachVsPhi->setAxisTitle("Track d_{xy} wrt (0,0,0) (cm)", 2);
1059     }
1060   }
1061 
1062   if (doSIPPlots_ || doAllPlots_) {
1063     const double sipBins = 200;
1064     const double sipMin = -20;
1065     const double sipMax = 20;
1066 
1067     ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
1068 
1069     // SIP wrt. beamspot
1070     histname = "SIPDxyToBS_";
1071     sipDxyToBS = ibooker.book1D(histname + CategoryName, histname + CategoryName, sipBins, sipMin, sipMax);
1072     sipDxyToBS->setAxisTitle("Track dxy significance wrt beam spot", 1);
1073     sipDxyToBS->setAxisTitle("Number of Tracks", 2);
1074 
1075     histname = "SIPDzToBS_";
1076     sipDzToBS = ibooker.book1D(histname + CategoryName, histname + CategoryName, sipBins, sipMin, sipMax);
1077     sipDzToBS->setAxisTitle("Track dz significance wrt beam spot", 1);
1078     sipDzToBS->setAxisTitle("Number of Tracks", 2);
1079 
1080     // SIP wrt. vertex
1081     histname = "SIP3DToPV_";
1082     sip3dToPV = ibooker.book1D(histname + CategoryName, histname + CategoryName, sipBins, sipMin, sipMax);
1083     sip3dToPV->setAxisTitle("3D IP significance wrt primary vertex", 1);
1084     sip3dToPV->setAxisTitle("Number of Tracks", 2);
1085 
1086     histname = "SIP2DToPV_";
1087     sip2dToPV = ibooker.book1D(histname + CategoryName, histname + CategoryName, sipBins, sipMin, sipMax);
1088     sip2dToPV->setAxisTitle("2D IP significance wrt primary vertex", 1);
1089     sip2dToPV->setAxisTitle("Number of Tracks", 2);
1090 
1091     histname = "SIPDxyToPV_";
1092     sipDxyToPV = ibooker.book1D(histname + CategoryName, histname + CategoryName, sipBins, sipMin, sipMax);
1093     sipDxyToPV->setAxisTitle("Track dxy significance wrt primary vertex", 1);
1094     sipDxyToPV->setAxisTitle("Number of Tracks", 2);
1095 
1096     histname = "SIPDzToPV_";
1097     sipDzToPV = ibooker.book1D(histname + CategoryName, histname + CategoryName, sipBins, sipMin, sipMax);
1098     sipDzToPV->setAxisTitle("Track dz significance wrt primary vertex", 1);
1099     sipDzToPV->setAxisTitle("Number of Tracks", 2);
1100   }
1101 }
1102 
1103 // -- Analyse
1104 // ---------------------------------------------------------------------------------//
1105 void TrackAnalyzer::setNumberOfGoodVertices(const edm::Event& iEvent) {
1106   good_vertices_ = 0;
1107 
1108   edm::Handle<reco::VertexCollection> recoPrimaryVerticesHandle = iEvent.getHandle(pvToken_);
1109   if (recoPrimaryVerticesHandle.isValid())
1110     if (!recoPrimaryVerticesHandle->empty())
1111       for (const auto& v : *recoPrimaryVerticesHandle)
1112         if (v.ndof() >= pvNDOF_ && !v.isFake())
1113           ++good_vertices_;
1114 }
1115 
1116 void TrackAnalyzer::setBX(const edm::Event& iEvent) { bx_ = iEvent.bunchCrossing(); }
1117 
1118 void TrackAnalyzer::setLumi(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
1119   // as done by pixelLumi http://cmslxr.fnal.gov/source/DQM/PixelLumi/plugins/PixelLumiDQM.cc
1120 
1121   if (forceSCAL_) {
1122     edm::Handle<LumiScalersCollection> lumiScalers = iEvent.getHandle(lumiscalersToken_);
1123     if (lumiScalers.isValid() && !lumiScalers->empty()) {
1124       LumiScalersCollection::const_iterator scalit = lumiScalers->begin();
1125       scal_lumi_ = scalit->instantLumi();
1126     } else
1127       scal_lumi_ = -1;
1128   } else {
1129     edm::Handle<OnlineLuminosityRecord> metaData = iEvent.getHandle(metaDataToken_);
1130     if (metaData.isValid())
1131       scal_lumi_ = metaData->instLumi();
1132     else
1133       scal_lumi_ = -1;
1134   }
1135 
1136   edm::Handle<edmNew::DetSetVector<SiPixelCluster> > pixelClusters = iEvent.getHandle(pixelClustersToken_);
1137   if (pixelClusters.isValid()) {
1138     TrackerTopology const& tTopo = iSetup.getData(trackerTopologyToken_);
1139 
1140     // Count the number of clusters with at least a minimum
1141     // number of pixels per cluster and at least a minimum charge.
1142     size_t numClusters = 0;
1143     size_t tot = 0;
1144 
1145     edmNew::DetSetVector<SiPixelCluster>::const_iterator pixCluDet = pixelClusters->begin();
1146     for (; pixCluDet != pixelClusters->end(); ++pixCluDet) {
1147       DetId detid = pixCluDet->detId();
1148       size_t subdetid = detid.subdetId();
1149       //      std::cout << tTopo.print(detid) << std::endl;
1150       if (subdetid == (int)PixelSubdetector::PixelBarrel)
1151         if (tTopo.layer(detid) == 1)
1152           continue;
1153 
1154       edmNew::DetSet<SiPixelCluster>::const_iterator pixClu = pixCluDet->begin();
1155       for (; pixClu != pixCluDet->end(); ++pixClu) {
1156         ++tot;
1157         if ((pixClu->size() >= minNumberOfPixelsPerCluster_) && (pixClu->charge() >= minPixelClusterCharge_)) {
1158           ++numClusters;
1159         }
1160       }
1161     }
1162     pixel_lumi_ = lumi_factor_per_bx_ * numClusters / GetLumi::CM2_TO_NANOBARN;  // ?!?!
1163   } else
1164     pixel_lumi_ = -1.;
1165 }
1166 
1167 void TrackAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup, const reco::Track& track) {
1168   auto pt = track.pt();
1169   auto phi = track.phi();
1170   // double eta   = track.eta();
1171   auto phiIn = track.innerPosition().phi();
1172   auto etaIn = track.innerPosition().eta();
1173   auto phiOut = track.outerPosition().phi();
1174   auto etaOut = track.outerPosition().eta();
1175 
1176   int nRecHits = track.hitPattern().numberOfAllHits(reco::HitPattern::TRACK_HITS);
1177   int nValidRecHits = track.numberOfValidHits();
1178   int nLostRecHits = track.numberOfLostHits();
1179   int nLostIn = track.hitPattern().numberOfLostTrackerHits(reco::HitPattern::MISSING_INNER_HITS);
1180   int nLostOut = track.hitPattern().numberOfLostTrackerHits(reco::HitPattern::MISSING_OUTER_HITS);
1181 
1182   auto chi2 = track.chi2();
1183   auto chi2prob = TMath::Prob(track.chi2(), (int)track.ndof());
1184   auto chi2oNDF = track.normalizedChi2();
1185 
1186   std::string Folder = TopFolder_.substr(0, 2);
1187 
1188   if (doHitPropertiesPlots_ || doAllPlots_) {
1189     // rec hits
1190     NumberOfRecHitsPerTrack->Fill(nRecHits);
1191     NumberOfValidRecHitsPerTrack->Fill(nValidRecHits);
1192     NumberOfLostRecHitsPerTrack->Fill(nLostRecHits);
1193     NumberOfMIRecHitsPerTrack->Fill(nLostIn);
1194     NumberOfMORecHitsPerTrack->Fill(nLostOut);
1195     ValidFractionPerTrack->Fill(track.validFraction());
1196 
1197     // 2D plots
1198     if (doRecHitVsPhiVsEtaPerTrack_ || doAllPlots_) {
1199       NumberOfValidRecHitVsPhiVsEtaPerTrack->Fill(etaIn, phiIn, nValidRecHits);
1200       NumberOfLostRecHitVsPhiVsEtaPerTrack->Fill(etaIn, phiIn, nLostRecHits);
1201       NumberOfMIRecHitVsPhiVsEtaPerTrack->Fill(etaIn, phiIn, nLostIn);
1202       NumberOfMORecHitVsPhiVsEtaPerTrack->Fill(etaOut, phiOut, nLostOut);
1203       ValidFractionVsPhiVsEtaPerTrack->Fill(etaIn, phiIn, track.validFraction());
1204     }
1205     if (doRecHitVsPtVsEtaPerTrack_ || doAllPlots_) {
1206       NumberOfValidRecHitVsPtVsEtaPerTrack->Fill(etaIn, pt, nValidRecHits);
1207       NumberOfLostRecHitVsPtVsEtaPerTrack->Fill(etaIn, pt, nLostRecHits);
1208       NumberOfMIRecHitVsPtVsEtaPerTrack->Fill(etaIn, pt, nLostIn);
1209       NumberOfMORecHitVsPtVsEtaPerTrack->Fill(etaOut, pt, nLostOut);
1210     }
1211     NumberOfValidRecHitsPerTrackVsPt->Fill(pt, nValidRecHits);
1212     NumberOfLostRecHitsPerTrackVsPt->Fill(pt, nLostRecHits);
1213     NumberOfMIRecHitsPerTrackVsPt->Fill(pt, nLostIn);
1214     NumberOfMORecHitsPerTrackVsPt->Fill(pt, nLostOut);
1215 
1216     int nLayers[5] = {track.hitPattern().trackerLayersWithMeasurement(),
1217                       track.hitPattern().trackerLayersTotallyOffOrBad(),
1218                       track.hitPattern().numberOfValidStripLayersWithMonoAndStereo() +
1219                           track.hitPattern().pixelLayersWithMeasurement(),
1220                       track.hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS),
1221                       track.hitPattern().pixelLayersWithMeasurement()};
1222 
1223     // layers
1224     for (int i = 0; i < 4; ++i)
1225       NumberOfLayersPerTrack[i]->Fill(nLayers[i]);
1226 
1227     // 2D plots
1228     if (doLayersVsPhiVsEtaPerTrack_ || doAllPlots_)
1229       for (int i = 0; i < 5; ++i)
1230         NumberOfLayersVsPhiVsEtaPerTrack[i]->Fill(etaIn, phiIn, nLayers[i]);
1231   }
1232 
1233   if (doEffFromHitPatternVsPU_ || doAllPlots_)
1234     fillHistosForEfficiencyFromHitPatter(track, "", float(good_vertices_), false);
1235   if (doEffFromHitPatternVsBX_ || doAllPlots_)
1236     fillHistosForEfficiencyFromHitPatter(track, "VsBX", float(bx_), false);
1237   if (doEffFromHitPatternVsLUMI_ || doAllPlots_)
1238     fillHistosForEfficiencyFromHitPatter(track, "VsSCALLUMI", scal_lumi_, false);
1239   //  if (doEffFromHitPatternVsLUMI_ || doAllPlots_) fillHistosForEfficiencyFromHitPatter(track,"VsPIXELLUMI", pixel_lumi_           );
1240   if (doEffFromHitPatternVsPU_ || doAllPlots_)
1241     fillHistosForEfficiencyFromHitPatter(track, "", float(good_vertices_), true);
1242   if (doEffFromHitPatternVsLUMI_ || doAllPlots_)
1243     fillHistosForEfficiencyFromHitPatter(track, "VsSCALLUMI", scal_lumi_, true);
1244 
1245   if (doGeneralPropertiesPlots_ || doAllPlots_) {
1246     // fitting
1247     Chi2->Fill(chi2);
1248     Chi2Prob->Fill(chi2prob);
1249     Chi2oNDF->Fill(chi2oNDF);
1250 
1251     // DCA
1252     // temporary patch in order to put back those MEs in Muon Workspace
1253     if (doDCAPlots_) {
1254       if (doDCAwrt000Plots_) {
1255         DistanceOfClosestApproach->Fill(track.dxy());
1256         DistanceOfClosestApproachVsPhi->Fill(phi, track.dxy());
1257       }
1258 
1259       // PCA
1260       xPointOfClosestApproach->Fill(track.referencePoint().x());
1261       yPointOfClosestApproach->Fill(track.referencePoint().y());
1262       zPointOfClosestApproach->Fill(track.referencePoint().z());
1263     }
1264 
1265     // algorithm
1266     algorithm->Fill(static_cast<double>(track.algo()));
1267     oriAlgo->Fill(static_cast<double>(track.originalAlgo()));
1268 
1269     // stopping source
1270     int max = stoppingSource->getNbinsX();
1271     double stop = track.stopReason() > max ? double(max - 1) : static_cast<double>(track.stopReason());
1272     double stopped = int(StopReason::NOT_STOPPED) == track.stopReason() ? 0. : 1.;
1273     stoppingSource->Fill(stop);
1274     stoppingSourceVSeta->Fill(track.eta(), stopped);
1275     stoppingSourceVSphi->Fill(track.phi(), stopped);
1276   }
1277 
1278   if (doLumiAnalysis_) {
1279     NumberOfRecHitsPerTrack_lumiFlag->Fill(nRecHits);
1280     Chi2oNDF_lumiFlag->Fill(chi2oNDF);
1281   }
1282 
1283   if (doDCAPlots_ || doBSPlots_ || doSIPPlots_ || doAllPlots_) {
1284     edm::Handle<reco::BeamSpot> recoBeamSpotHandle = iEvent.getHandle(beamSpotToken_);
1285     const reco::BeamSpot& bs = *recoBeamSpotHandle;
1286 
1287     DistanceOfClosestApproachError->Fill(track.dxyError());
1288     DistanceOfClosestApproachErrorVsPt->Fill(track.pt(), track.dxyError());
1289     DistanceOfClosestApproachErrorVsEta->Fill(track.eta(), track.dxyError());
1290     DistanceOfClosestApproachErrorVsPhi->Fill(track.phi(), track.dxyError());
1291     DistanceOfClosestApproachErrorVsDxy->Fill(track.dxy(bs.position()), track.dxyError());
1292 
1293     DistanceOfClosestApproachToBS->Fill(track.dxy(bs.position()));
1294 
1295     if (Folder == "Tr") {
1296       DistanceOfClosestApproachToBSdz->Fill(track.dz(bs.position()));
1297       DistanceOfClosestApproachToBSVsEta->Fill(track.eta(), track.dxy(bs.position()));
1298     }
1299 
1300     AbsDistanceOfClosestApproachToBS->Fill(std::abs(track.dxy(bs.position())));
1301     DistanceOfClosestApproachToBSVsPhi->Fill(track.phi(), track.dxy(bs.position()));
1302     zPointOfClosestApproachVsPhi->Fill(track.phi(), track.vz());
1303     xPointOfClosestApproachVsZ0wrt000->Fill(track.dz(), track.vx());
1304     yPointOfClosestApproachVsZ0wrt000->Fill(track.dz(), track.vy());
1305     xPointOfClosestApproachVsZ0wrtBS->Fill(track.dz(bs.position()), (track.vx() - bs.position(track.vz()).x()));
1306     yPointOfClosestApproachVsZ0wrtBS->Fill(track.dz(bs.position()), (track.vy() - bs.position(track.vz()).y()));
1307     if (doTestPlots_) {
1308       TESTDistanceOfClosestApproachToBS->Fill(track.dxy(bs.position(track.vz())));
1309       TESTDistanceOfClosestApproachToBSVsPhi->Fill(track.phi(), track.dxy(bs.position(track.vz())));
1310     }
1311 
1312     if (doSIPPlots_) {
1313       sipDxyToBS->Fill(track.dxy(bs.position()) / track.dxyError());
1314       sipDzToBS->Fill(track.dz(bs.position()) / track.dzError());
1315     }
1316   }
1317 
1318   if (doDCAPlots_ || doPVPlots_ || doSIPPlots_ || doAllPlots_) {
1319     edm::Handle<reco::VertexCollection> recoPrimaryVerticesHandle = iEvent.getHandle(pvToken_);
1320     if (recoPrimaryVerticesHandle.isValid() && !recoPrimaryVerticesHandle->empty()) {
1321       const reco::Vertex& pv = (*recoPrimaryVerticesHandle)[0];
1322 
1323       //////////////////
1324       //HI PLOTS///////
1325       ////////////////
1326 
1327       if (doHIPlots_) {
1328         double longDCAsig = 0, transDCAsig = 0;
1329         double zerr2 = track.dzError() * track.dzError() + pv.zError() * pv.zError();
1330         double xyerr2 = track.d0Error() * track.d0Error() + pv.xError() * pv.yError();
1331         if (zerr2 > 0)
1332           longDCAsig = track.dz(pv.position()) / zerr2;
1333         if (xyerr2 > 0)
1334           transDCAsig = track.dxy(pv.position()) / xyerr2;
1335         LongDCASig->Fill(longDCAsig);
1336         TransDCASig->Fill(transDCAsig);
1337 
1338         if (track.quality(reco::TrackBase::qualityByName(qualityString_)) == 1) {
1339           dNdEta_HighPurity->Fill(track.eta());
1340           dNdPhi_HighPurity->Fill(track.phi());
1341           dNdPt_HighPurity->Fill(track.ptError() / track.pt());
1342           NhitVsEta_HighPurity->Fill(track.eta(), track.numberOfValidHits());
1343           NhitVsPhi_HighPurity->Fill(track.phi(), track.numberOfValidHits());
1344           dNhitdPt_HighPurity->Fill(track.pt(), track.numberOfValidHits());
1345           Ptdist_HighPurity->Fill(track.pt());
1346         }  //end of high quality tracks requirement
1347       }
1348 
1349       xPointOfClosestApproachToPV->Fill(track.vx() - pv.position().x());
1350       yPointOfClosestApproachToPV->Fill(track.vy() - pv.position().y());
1351       zPointOfClosestApproachToPV->Fill(track.dz(pv.position()));
1352       DistanceOfClosestApproachToPV->Fill(track.dxy(pv.position()));
1353       DeltaZToPV->Fill(track.dz(pv.position()));
1354       DistanceOfClosestApproachToPVZoom->Fill(track.dxy(pv.position()));
1355       DeltaZToPVZoom->Fill(track.dz(pv.position()));
1356       DistanceOfClosestApproachToPVVsPhi->Fill(track.phi(), track.dxy(pv.position()));
1357       xPointOfClosestApproachVsZ0wrtPV->Fill(track.dz(pv.position()), (track.vx() - pv.position().x()));
1358       yPointOfClosestApproachVsZ0wrtPV->Fill(track.dz(pv.position()), (track.vy() - pv.position().y()));
1359 
1360       if (doSIPPlots_) {
1361         TransientTrackBuilder const& theB = iSetup.getData(transientTrackBuilderToken_);
1362         reco::TransientTrack transTrack = theB.build(track);
1363 
1364         GlobalVector dir(track.px(), track.py(), track.pz());
1365         std::pair<bool, Measurement1D> ip3d = IPTools::signedImpactParameter3D(transTrack, dir, pv);
1366         std::pair<bool, Measurement1D> ip2d = IPTools::signedTransverseImpactParameter(transTrack, dir, pv);
1367         if (ip3d.first)
1368           sip3dToPV->Fill(ip3d.second.value() / ip3d.second.error());
1369         if (ip2d.first)
1370           sip2dToPV->Fill(ip2d.second.value() / ip2d.second.error());
1371         sipDxyToPV->Fill(track.dxy(pv.position()) / track.dxyError());
1372         sipDzToPV->Fill(track.dz(pv.position()) / track.dzError());
1373       }
1374     }
1375   }
1376 
1377   if (doDCAPlots_ || doAllPlots_) {
1378     if (doDCAwrt000Plots_) {
1379       if (doThetaPlots_) {
1380         DistanceOfClosestApproachVsTheta->Fill(track.theta(), track.d0());
1381       }
1382       DistanceOfClosestApproachVsEta->Fill(track.eta(), track.d0());
1383     }
1384   }
1385 
1386   //Tracker Specific Histograms
1387   if (doTrackerSpecific_ || doAllPlots_) {
1388     fillHistosForTrackerSpecific(track);
1389   }
1390   if (doMeasurementStatePlots_ || doAllPlots_) {
1391     if (stateName_ == "All") {
1392       fillHistosForState(iSetup, track, std::string("OuterSurface"));
1393       fillHistosForState(iSetup, track, std::string("InnerSurface"));
1394       fillHistosForState(iSetup, track, std::string("ImpactPoint"));
1395     } else if (stateName_ != "OuterSurface" && stateName_ != "InnerSurface" && stateName_ != "ImpactPoint" &&
1396                stateName_ != "default") {
1397       fillHistosForState(iSetup, track, std::string("default"));
1398     } else {
1399       fillHistosForState(iSetup, track, stateName_);
1400     }
1401   }
1402 
1403   if (doAllPlots_) {
1404   }
1405 }
1406 
1407 void TrackAnalyzer::fillHistosForEfficiencyFromHitPatter(const reco::Track& track,
1408                                                          const std::string suffix,
1409                                                          const float monitoring,
1410                                                          bool useInac) {
1411   int mon = -1;
1412   for (int i = 0; i < monQuantity::END; i++) {
1413     if (monName[i] == suffix)
1414       mon = i;
1415   }
1416   if (useInac)
1417     mon += monQuantity::END;
1418 
1419   //    if (track.pt() > 1.0 && track.dxy() < 0.1 and monitoring > 0) {
1420   if (track.pt() > 1.0 && track.dxy() < 0.1 and monitoring > -9.) {
1421     auto hp = track.hitPattern();
1422     // Here hit_category is meant to iterate over
1423     // reco::HitPattern::HitCategory, defined here:
1424     // http://cmslxr.fnal.gov/dxr/CMSSW/source/DataFormats/TrackReco/interface/HitPattern.h
1425     for (unsigned int category = 0; category < 3; ++category) {
1426       for (int hit = 0; hit < hp.numberOfAllHits((reco::HitPattern::HitCategory)(category)); ++hit) {
1427         auto pattern = hp.getHitPattern((reco::HitPattern::HitCategory)(category), hit);
1428         // Boolean bad is missing simply because it is inferred and the only missing case.
1429         bool valid = hp.validHitFilter(pattern);
1430         bool missing = hp.missingHitFilter(pattern);
1431         bool inactive = hp.inactiveHitFilter(pattern);
1432         int hit_type = -1;
1433         hit_type = valid ? 0 : (missing ? 1 : (inactive ? 2 : 3));
1434         if (hits_valid_.find(Key(hp.getSubStructure(pattern), hp.getSubSubStructure(pattern), mon)) ==
1435             hits_valid_.end()) {
1436           LogDebug("TrackAnalyzer") << "Invalid combination of detector and subdetector: ("
1437                                     << hp.getSubStructure(pattern) << ", " << hp.getSubSubStructure(pattern) << ", "
1438                                     << mon << "): ignoring it.\n";
1439           continue;
1440         }
1441         switch (hit_type) {
1442           case 0:
1443             hits_valid_[Key(hp.getSubStructure(pattern), hp.getSubSubStructure(pattern), mon)]->Fill(monitoring);
1444             hits_total_[Key(hp.getSubStructure(pattern), hp.getSubSubStructure(pattern), mon)]->Fill(monitoring);
1445             break;
1446           case 2:
1447             if (!useInac)
1448               break;
1449             [[fallthrough]];
1450           case 1:
1451             hits_total_[Key(hp.getSubStructure(pattern), hp.getSubSubStructure(pattern), mon)]->Fill(monitoring);
1452             break;
1453           default:
1454             LogDebug("TrackAnalyzer") << "Invalid hit category used " << hit_type << " ignored\n";
1455         }
1456       }
1457     }
1458   }
1459 }
1460 
1461 // book histograms at differnt measurement points
1462 // ---------------------------------------------------------------------------------//
1463 void TrackAnalyzer::bookHistosForState(std::string sname, DQMStore::IBooker& ibooker) {
1464   // parameters from the configuration
1465   std::string QualName = conf_->getParameter<std::string>("Quality");
1466   std::string AlgoName = conf_->getParameter<std::string>("AlgoName");
1467   std::string Folder = TopFolder_.substr(0, 2);
1468 
1469   // use the AlgoName and Quality Name
1470   std::string CategoryName = !QualName.empty() ? AlgoName + "_" + QualName : AlgoName;
1471 
1472   // get binning from the configuration
1473   double Chi2NDFMin = conf_->getParameter<double>("Chi2NDFMin");
1474   double Chi2NDFMax = conf_->getParameter<double>("Chi2NDFMax");
1475 
1476   int RecHitBin = conf_->getParameter<int>("RecHitBin");
1477   double RecHitMin = conf_->getParameter<double>("RecHitMin");
1478   double RecHitMax = conf_->getParameter<double>("RecHitMax");
1479 
1480   int RecLayBin = conf_->getParameter<int>("RecHitBin");
1481   double RecLayMin = conf_->getParameter<double>("RecHitMin");
1482   double RecLayMax = conf_->getParameter<double>("RecHitMax");
1483 
1484   int PhiBin = conf_->getParameter<int>("PhiBin");
1485   double PhiMin = conf_->getParameter<double>("PhiMin");
1486   double PhiMax = conf_->getParameter<double>("PhiMax");
1487 
1488   int EtaBin = conf_->getParameter<int>("EtaBin");
1489   double EtaMin = conf_->getParameter<double>("EtaMin");
1490   double EtaMax = conf_->getParameter<double>("EtaMax");
1491 
1492   int Phi2DBin = conf_->getParameter<int>("Phi2DBin");
1493   int Eta2DBin = conf_->getParameter<int>("Eta2DBin");
1494 
1495   int ThetaBin = conf_->getParameter<int>("ThetaBin");
1496   double ThetaMin = conf_->getParameter<double>("ThetaMin");
1497   double ThetaMax = conf_->getParameter<double>("ThetaMax");
1498 
1499   int TrackQBin = conf_->getParameter<int>("TrackQBin");
1500   double TrackQMin = conf_->getParameter<double>("TrackQMin");
1501   double TrackQMax = conf_->getParameter<double>("TrackQMax");
1502 
1503   int TrackPtBin = conf_->getParameter<int>("TrackPtBin");
1504   double TrackPtMin = conf_->getParameter<double>("TrackPtMin");
1505   double TrackPtMax = conf_->getParameter<double>("TrackPtMax");
1506 
1507   int TrackPBin = conf_->getParameter<int>("TrackPBin");
1508   double TrackPMin = conf_->getParameter<double>("TrackPMin");
1509   double TrackPMax = conf_->getParameter<double>("TrackPMax");
1510 
1511   int TrackPxBin = conf_->getParameter<int>("TrackPxBin");
1512   double TrackPxMin = conf_->getParameter<double>("TrackPxMin");
1513   double TrackPxMax = conf_->getParameter<double>("TrackPxMax");
1514 
1515   int TrackPyBin = conf_->getParameter<int>("TrackPyBin");
1516   double TrackPyMin = conf_->getParameter<double>("TrackPyMin");
1517   double TrackPyMax = conf_->getParameter<double>("TrackPyMax");
1518 
1519   int TrackPzBin = conf_->getParameter<int>("TrackPzBin");
1520   double TrackPzMin = conf_->getParameter<double>("TrackPzMin");
1521   double TrackPzMax = conf_->getParameter<double>("TrackPzMax");
1522 
1523   int ptErrBin = conf_->getParameter<int>("ptErrBin");
1524   double ptErrMin = conf_->getParameter<double>("ptErrMin");
1525   double ptErrMax = conf_->getParameter<double>("ptErrMax");
1526 
1527   int pxErrBin = conf_->getParameter<int>("pxErrBin");
1528   double pxErrMin = conf_->getParameter<double>("pxErrMin");
1529   double pxErrMax = conf_->getParameter<double>("pxErrMax");
1530 
1531   int pyErrBin = conf_->getParameter<int>("pyErrBin");
1532   double pyErrMin = conf_->getParameter<double>("pyErrMin");
1533   double pyErrMax = conf_->getParameter<double>("pyErrMax");
1534 
1535   int pzErrBin = conf_->getParameter<int>("pzErrBin");
1536   double pzErrMin = conf_->getParameter<double>("pzErrMin");
1537   double pzErrMax = conf_->getParameter<double>("pzErrMax");
1538 
1539   int pErrBin = conf_->getParameter<int>("pErrBin");
1540   double pErrMin = conf_->getParameter<double>("pErrMin");
1541   double pErrMax = conf_->getParameter<double>("pErrMax");
1542 
1543   int phiErrBin = conf_->getParameter<int>("phiErrBin");
1544   double phiErrMin = conf_->getParameter<double>("phiErrMin");
1545   double phiErrMax = conf_->getParameter<double>("phiErrMax");
1546 
1547   int etaErrBin = conf_->getParameter<int>("etaErrBin");
1548   double etaErrMin = conf_->getParameter<double>("etaErrMin");
1549   double etaErrMax = conf_->getParameter<double>("etaErrMax");
1550 
1551   double Chi2ProbMin = conf_->getParameter<double>("Chi2ProbMin");
1552   double Chi2ProbMax = conf_->getParameter<double>("Chi2ProbMax");
1553 
1554   ibooker.setCurrentFolder(TopFolder_);
1555 
1556   TkParameterMEs tkmes;
1557 
1558   std::string histTag = (sname == "default") ? CategoryName : sname + "_" + CategoryName;
1559 
1560   if (doAllPlots_) {
1561     // general properties
1562     ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
1563 
1564     if (doThetaPlots_) {
1565       histname = "Chi2oNDFVsTheta_" + histTag;
1566       tkmes.Chi2oNDFVsTheta =
1567           ibooker.bookProfile(histname, histname, ThetaBin, ThetaMin, ThetaMax, Chi2NDFMin, Chi2NDFMax, "");
1568       tkmes.Chi2oNDFVsTheta->setAxisTitle("Track #theta", 1);
1569       tkmes.Chi2oNDFVsTheta->setAxisTitle("Track #chi^{2}/ndf", 2);
1570     }
1571     histname = "Chi2oNDFVsPhi_" + histTag;
1572     tkmes.Chi2oNDFVsPhi = ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, Chi2NDFMin, Chi2NDFMax, "");
1573     tkmes.Chi2oNDFVsPhi->setAxisTitle("Track #phi", 1);
1574     tkmes.Chi2oNDFVsPhi->setAxisTitle("Track #chi^{2}/ndf", 2);
1575 
1576     histname = "Chi2ProbVsPhi_" + histTag;
1577     tkmes.Chi2ProbVsPhi = ibooker.bookProfile(
1578         histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, Chi2ProbMin, Chi2ProbMax);
1579     tkmes.Chi2ProbVsPhi->setAxisTitle("Tracks #phi", 1);
1580     tkmes.Chi2ProbVsPhi->setAxisTitle("Track #chi^{2} probability", 2);
1581 
1582     histname = "Chi2ProbVsEta_" + histTag;
1583     tkmes.Chi2ProbVsEta = ibooker.bookProfile(
1584         histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, Chi2ProbMin, Chi2ProbMax);
1585     tkmes.Chi2ProbVsEta->setAxisTitle("Tracks #eta", 1);
1586     tkmes.Chi2ProbVsEta->setAxisTitle("Track #chi^{2} probability", 2);
1587   }
1588 
1589   // general properties
1590   ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
1591 
1592   histname = "Chi2oNDFVsEta_" + histTag;
1593   tkmes.Chi2oNDFVsEta = ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, Chi2NDFMin, Chi2NDFMax, "");
1594   tkmes.Chi2oNDFVsEta->setAxisTitle("Track #eta", 1);
1595   tkmes.Chi2oNDFVsEta->setAxisTitle("Track #chi^{2}/ndf", 2);
1596 
1597   histname = "Chi2oNDFVsPt_" + histTag;
1598   tkmes.Chi2oNDFVsPt =
1599       ibooker.bookProfile(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax, Chi2NDFMin, Chi2NDFMax, "");
1600   tkmes.Chi2oNDFVsPt->setAxisTitle("Track p_{T} (GeV/c)", 1);
1601   tkmes.Chi2oNDFVsPt->setAxisTitle("Track #chi^{2}/ndf", 2);
1602 
1603   histname = "Chi2oNDFVsNHits_" + histTag;
1604   tkmes.Chi2oNDFVsNHits = ibooker.bookProfile(histname, histname, 50, 0., 50, Chi2NDFMin, Chi2NDFMax, "");
1605   tkmes.Chi2oNDFVsNHits->setAxisTitle("Track NHits", 1);
1606   tkmes.Chi2oNDFVsNHits->setAxisTitle("Track #chi^{2}/ndf", 2);
1607 
1608   histname = "TrackP_" + histTag;
1609   tkmes.TrackP = ibooker.book1D(histname, histname, TrackPBin, TrackPMin, TrackPMax);
1610   tkmes.TrackP->setAxisTitle("Track |p| (GeV/c)", 1);
1611   tkmes.TrackP->setAxisTitle("Number of Tracks", 2);
1612 
1613   histname = "TrackPt_" + histTag;
1614   tkmes.TrackPt = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1615   tkmes.TrackPt->setAxisTitle("Track p_{T} (GeV/c)", 1);
1616   tkmes.TrackPt->setAxisTitle("Number of Tracks", 2);
1617 
1618   if (doTrackPxPyPlots_) {
1619     histname = "TrackPx_" + histTag;
1620     tkmes.TrackPx = ibooker.book1D(histname, histname, TrackPxBin, TrackPxMin, TrackPxMax);
1621     tkmes.TrackPx->setAxisTitle("Track p_{x} (GeV/c)", 1);
1622     tkmes.TrackPx->setAxisTitle("Number of Tracks", 2);
1623 
1624     histname = "TrackPy_" + histTag;
1625     tkmes.TrackPy = ibooker.book1D(histname, histname, TrackPyBin, TrackPyMin, TrackPyMax);
1626     tkmes.TrackPy->setAxisTitle("Track p_{y} (GeV/c)", 1);
1627     tkmes.TrackPy->setAxisTitle("Number of Tracks", 2);
1628   }
1629   histname = "TrackPz_" + histTag;
1630   tkmes.TrackPz = ibooker.book1D(histname, histname, TrackPzBin, TrackPzMin, TrackPzMax);
1631   tkmes.TrackPz->setAxisTitle("Track p_{z} (GeV/c)", 1);
1632   tkmes.TrackPz->setAxisTitle("Number of Tracks", 2);
1633 
1634   histname = "TrackPhi_" + histTag;
1635   tkmes.TrackPhi = ibooker.book1D(histname, histname, PhiBin, PhiMin, PhiMax);
1636   tkmes.TrackPhi->setAxisTitle("Track #phi", 1);
1637   tkmes.TrackPhi->setAxisTitle("Number of Tracks", 2);
1638 
1639   histname = "TrackEta_" + histTag;
1640   tkmes.TrackEta = ibooker.book1D(histname, histname, EtaBin, EtaMin, EtaMax);
1641   tkmes.TrackEta->setAxisTitle("Track #eta", 1);
1642   tkmes.TrackEta->setAxisTitle("Number of Tracks", 2);
1643 
1644   if (Folder == "Tr") {
1645     histname = "TrackPtHighPurity_" + histTag;
1646     tkmes.TrackPtHighPurity = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1647     tkmes.TrackPtHighPurity->setAxisTitle("Track p_{T} (GeV/c)", 1);
1648     tkmes.TrackPtHighPurity->setAxisTitle("Number of High Purity Tracks", 2);
1649 
1650     histname = "TrackPtTight_" + histTag;
1651     tkmes.TrackPtTight = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1652     tkmes.TrackPtTight->setAxisTitle("Track p_{T} (GeV/c)", 1);
1653     tkmes.TrackPtTight->setAxisTitle("Number of Tight Tracks", 2);
1654 
1655     histname = "TrackPtLoose_" + histTag;
1656     tkmes.TrackPtLoose = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1657     tkmes.TrackPtLoose->setAxisTitle("Track p_{T} (GeV/c)", 1);
1658     tkmes.TrackPtLoose->setAxisTitle("Number of Loose Tracks", 2);
1659 
1660     histname = "Quality_";
1661     tkmes.Quality = ibooker.book1D(histname + CategoryName, histname + CategoryName, 3, 0., 3.);
1662     tkmes.Quality->setAxisTitle("Track quality", 1);
1663     tkmes.Quality->setAxisTitle("Number of Tracks", 2);
1664 
1665     for (size_t ibin = 0; ibin < 3; ibin++) {
1666       tkmes.Quality->setBinLabel(ibin + 1, reco::TrackBase::qualityNames[ibin]);
1667     }
1668 
1669     histname = "TrackPt_NegEta_Phi_btw_neg16_neg32_" + histTag;
1670     tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1671     tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32->setAxisTitle("Track p_{T} (GeV/c)", 1);
1672     tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32->setAxisTitle("Number of Tracks", 2);
1673 
1674     histname = "TrackPt_NegEta_Phi_btw_0_neg16_" + histTag;
1675     tkmes.TrackPt_NegEta_Phi_btw_0_neg16 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1676     tkmes.TrackPt_NegEta_Phi_btw_0_neg16->setAxisTitle("Track p_{T} (GeV/c)", 1);
1677     tkmes.TrackPt_NegEta_Phi_btw_0_neg16->setAxisTitle("Number of Tracks", 2);
1678 
1679     histname = "TrackPt_NegEta_Phi_btw_16_0_" + histTag;
1680     tkmes.TrackPt_NegEta_Phi_btw_16_0 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1681     tkmes.TrackPt_NegEta_Phi_btw_16_0->setAxisTitle("Track p_{T} (GeV/c)", 1);
1682     tkmes.TrackPt_NegEta_Phi_btw_16_0->setAxisTitle("Number of Tracks", 2);
1683 
1684     histname = "TrackPt_NegEta_Phi_btw_32_16_" + histTag;
1685     tkmes.TrackPt_NegEta_Phi_btw_32_16 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1686     tkmes.TrackPt_NegEta_Phi_btw_32_16->setAxisTitle("Track p_{T} (GeV/c)", 1);
1687     tkmes.TrackPt_NegEta_Phi_btw_32_16->setAxisTitle("Number of Tracks", 2);
1688 
1689     histname = "TrackPt_PosEta_Phi_btw_neg16_neg32_" + histTag;
1690     tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1691     tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32->setAxisTitle("Track p_{T} (GeV/c)", 1);
1692     tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32->setAxisTitle("Number of Tracks", 2);
1693 
1694     histname = "TrackPt_PosEta_Phi_btw_0_neg16_" + histTag;
1695     tkmes.TrackPt_PosEta_Phi_btw_0_neg16 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1696     tkmes.TrackPt_PosEta_Phi_btw_0_neg16->setAxisTitle("Track p_{T} (GeV/c)", 1);
1697     tkmes.TrackPt_PosEta_Phi_btw_0_neg16->setAxisTitle("Number of Tracks", 2);
1698 
1699     histname = "TrackPt_PosEta_Phi_btw_16_0_" + histTag;
1700     tkmes.TrackPt_PosEta_Phi_btw_16_0 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1701     tkmes.TrackPt_PosEta_Phi_btw_16_0->setAxisTitle("Track p_{T} (GeV/c)", 1);
1702     tkmes.TrackPt_PosEta_Phi_btw_16_0->setAxisTitle("Number of Tracks", 2);
1703 
1704     histname = "TrackPt_PosEta_Phi_btw_32_16_" + histTag;
1705     tkmes.TrackPt_PosEta_Phi_btw_32_16 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1706     tkmes.TrackPt_PosEta_Phi_btw_32_16->setAxisTitle("Track p_{T} (GeV/c)", 1);
1707     tkmes.TrackPt_PosEta_Phi_btw_32_16->setAxisTitle("Number of Tracks", 2);
1708 
1709     histname = "Ratio_byFolding_" + histTag;
1710     tkmes.Ratio_byFolding = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1711     tkmes.Ratio_byFolding->setAxisTitle("Track p_{T} (GeV/c)", 1);
1712 
1713     histname = "Ratio_byFolding2_" + histTag;
1714     tkmes.Ratio_byFolding2 = ibooker.book1D(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax);
1715     tkmes.Ratio_byFolding2->setAxisTitle("Track p_{T} (GeV/c)", 1);
1716 
1717     histname = "TrackEtaHighpurity_" + histTag;
1718     tkmes.TrackEtaHighPurity = ibooker.book1D(histname, histname, EtaBin, EtaMin, EtaMax);
1719     tkmes.TrackEtaHighPurity->setAxisTitle("Track #eta", 1);
1720     tkmes.TrackEtaHighPurity->setAxisTitle("Number of High Purity Tracks", 2);
1721 
1722     histname = "TrackEtaTight_" + histTag;
1723     tkmes.TrackEtaTight = ibooker.book1D(histname, histname, EtaBin, EtaMin, EtaMax);
1724     tkmes.TrackEtaTight->setAxisTitle("Track #eta", 1);
1725     tkmes.TrackEtaTight->setAxisTitle("Number of Tight Tracks", 2);
1726 
1727     histname = "TrackEtaLoose_" + histTag;
1728     tkmes.TrackEtaLoose = ibooker.book1D(histname, histname, EtaBin, EtaMin, EtaMax);
1729     tkmes.TrackEtaLoose->setAxisTitle("Track #eta", 1);
1730     tkmes.TrackEtaLoose->setAxisTitle("Number of Loose Tracks", 2);
1731 
1732     histname = "TrackEtaPhiInverted_" + histTag;
1733     tkmes.TrackEtaPhiInverted = ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
1734     tkmes.TrackEtaPhiInverted->setAxisTitle("Track #eta", 1);
1735     tkmes.TrackEtaPhiInverted->setAxisTitle("Track #phi", 2);
1736 
1737     histname = "TrackEtaPhiInvertedoutofphase_" + histTag;
1738     tkmes.TrackEtaPhiInvertedoutofphase =
1739         ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
1740     tkmes.TrackEtaPhiInvertedoutofphase->setAxisTitle("Track #eta", 1);
1741     tkmes.TrackEtaPhiInvertedoutofphase->setAxisTitle("Track #phi", 2);
1742 
1743     histname = "TrackQoverP_" + histTag;
1744     tkmes.TrackQoverP = ibooker.book1D(histname, histname, 10 * TrackQBin, TrackQMin, TrackQMax);
1745     tkmes.TrackQoverP->setAxisTitle("Track QoverP", 1);
1746     tkmes.TrackQoverP->setAxisTitle("Number of Tracks", 2);
1747   }
1748 
1749   histname = "TrackEtaPhi_" + histTag;
1750   tkmes.TrackEtaPhi = ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
1751   tkmes.TrackEtaPhi->setAxisTitle("Track #eta", 1);
1752   tkmes.TrackEtaPhi->setAxisTitle("Track #phi", 2);
1753 
1754   histname = "TrackEtaPhiInner_" + histTag;
1755   tkmes.TrackEtaPhiInner = ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
1756   tkmes.TrackEtaPhiInner->setAxisTitle("Track #eta", 1);
1757   tkmes.TrackEtaPhiInner->setAxisTitle("Track #phi", 2);
1758 
1759   histname = "TrackEtaPhiOuter_" + histTag;
1760   tkmes.TrackEtaPhiOuter = ibooker.book2D(histname, histname, Eta2DBin, EtaMin, EtaMax, Phi2DBin, PhiMin, PhiMax);
1761   tkmes.TrackEtaPhiOuter->setAxisTitle("Track #eta", 1);
1762   tkmes.TrackEtaPhiOuter->setAxisTitle("Track #phi", 2);
1763 
1764   if (doThetaPlots_) {
1765     histname = "TrackTheta_" + histTag;
1766     tkmes.TrackTheta = ibooker.book1D(histname, histname, ThetaBin, ThetaMin, ThetaMax);
1767     tkmes.TrackTheta->setAxisTitle("Track #theta", 1);
1768     tkmes.TrackTheta->setAxisTitle("Number of Tracks", 2);
1769   }
1770   histname = "TrackQ_" + histTag;
1771   tkmes.TrackQ = ibooker.book1D(histname, histname, TrackQBin, TrackQMin, TrackQMax);
1772   tkmes.TrackQ->setAxisTitle("Track Charge", 1);
1773   tkmes.TrackQ->setAxisTitle("Number of Tracks", 2);
1774 
1775   histname = "TrackPErrOverP_" + histTag;
1776   tkmes.TrackPErr = ibooker.book1D(histname, histname, pErrBin, pErrMin, pErrMax);
1777   tkmes.TrackPErr->setAxisTitle("track error(p)/p", 1);
1778   tkmes.TrackPErr->setAxisTitle("Number of Tracks", 2);
1779 
1780   histname = "TrackPtErrOverPt_" + histTag;
1781   tkmes.TrackPtErr = ibooker.book1D(histname, histname, ptErrBin, ptErrMin, ptErrMax);
1782   tkmes.TrackPtErr->setAxisTitle("track error(p_{T})/p_{T}", 1);
1783   tkmes.TrackPtErr->setAxisTitle("Number of Tracks", 2);
1784 
1785   histname = "TrackPtErrOverPtVsEta_" + histTag;
1786   tkmes.TrackPtErrVsEta = ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, ptErrMin, ptErrMax);
1787   tkmes.TrackPtErrVsEta->setAxisTitle("Track #eta", 1);
1788   tkmes.TrackPtErrVsEta->setAxisTitle("track error(p_{T})/p_{T}", 2);
1789 
1790   if (doTrackPxPyPlots_) {
1791     histname = "TrackPxErrOverPx_" + histTag;
1792     tkmes.TrackPxErr = ibooker.book1D(histname, histname, pxErrBin, pxErrMin, pxErrMax);
1793     tkmes.TrackPxErr->setAxisTitle("track error(p_{x})/p_{x}", 1);
1794     tkmes.TrackPxErr->setAxisTitle("Number of Tracks", 2);
1795 
1796     histname = "TrackPyErrOverPy_" + histTag;
1797     tkmes.TrackPyErr = ibooker.book1D(histname, histname, pyErrBin, pyErrMin, pyErrMax);
1798     tkmes.TrackPyErr->setAxisTitle("track error(p_{y})/p_{y}", 1);
1799     tkmes.TrackPyErr->setAxisTitle("Number of Tracks", 2);
1800   }
1801   histname = "TrackPzErrOverPz_" + histTag;
1802   tkmes.TrackPzErr = ibooker.book1D(histname, histname, pzErrBin, pzErrMin, pzErrMax);
1803   tkmes.TrackPzErr->setAxisTitle("track error(p_{z})/p_{z}", 1);
1804   tkmes.TrackPzErr->setAxisTitle("Number of Tracks", 2);
1805 
1806   histname = "TrackPhiErr_" + histTag;
1807   tkmes.TrackPhiErr = ibooker.book1D(histname, histname, phiErrBin, phiErrMin, phiErrMax);
1808   tkmes.TrackPhiErr->setAxisTitle("track error(#phi)");
1809   tkmes.TrackPhiErr->setAxisTitle("Number of Tracks", 2);
1810 
1811   histname = "TrackEtaErr_" + histTag;
1812   tkmes.TrackEtaErr = ibooker.book1D(histname, histname, etaErrBin, etaErrMin, etaErrMax);
1813   tkmes.TrackEtaErr->setAxisTitle("track error(#eta)");
1814   tkmes.TrackEtaErr->setAxisTitle("Number of Tracks", 2);
1815 
1816   // rec hit profiles
1817   ibooker.setCurrentFolder(TopFolder_ + "/GeneralProperties");
1818   histname = "NumberOfRecHitsPerTrackVsPhi_" + histTag;
1819   tkmes.NumberOfRecHitsPerTrackVsPhi =
1820       ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, RecHitBin, RecHitMin, RecHitMax, "");
1821   tkmes.NumberOfRecHitsPerTrackVsPhi->setAxisTitle("Track #phi", 1);
1822   tkmes.NumberOfRecHitsPerTrackVsPhi->setAxisTitle("Number of RecHits in each Track", 2);
1823 
1824   if (doThetaPlots_) {
1825     histname = "NumberOfRecHitsPerTrackVsTheta_" + histTag;
1826     tkmes.NumberOfRecHitsPerTrackVsTheta =
1827         ibooker.bookProfile(histname, histname, ThetaBin, ThetaMin, ThetaMax, RecHitBin, RecHitMin, RecHitMax, "");
1828     tkmes.NumberOfRecHitsPerTrackVsTheta->setAxisTitle("Track #phi", 1);
1829     tkmes.NumberOfRecHitsPerTrackVsTheta->setAxisTitle("Number of RecHits in each Track", 2);
1830   }
1831   histname = "NumberOfRecHitsPerTrackVsEta_" + histTag;
1832   tkmes.NumberOfRecHitsPerTrackVsEta =
1833       ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, RecHitBin, RecHitMin, RecHitMax, "");
1834   tkmes.NumberOfRecHitsPerTrackVsEta->setAxisTitle("Track #eta", 1);
1835   tkmes.NumberOfRecHitsPerTrackVsEta->setAxisTitle("Number of RecHits in each Track", 2);
1836 
1837   histname = "NumberOfValidRecHitsPerTrackVsPhi_" + histTag;
1838   tkmes.NumberOfValidRecHitsPerTrackVsPhi =
1839       ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, RecHitMin, RecHitMax, "");
1840   tkmes.NumberOfValidRecHitsPerTrackVsPhi->setAxisTitle("Track #phi", 1);
1841   tkmes.NumberOfValidRecHitsPerTrackVsPhi->setAxisTitle("Number of valid RecHits in each Track", 2);
1842 
1843   histname = "NumberOfValidRecHitsPerTrackVsEta_" + histTag;
1844   tkmes.NumberOfValidRecHitsPerTrackVsEta =
1845       ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, RecHitMin, RecHitMax, "");
1846   tkmes.NumberOfValidRecHitsPerTrackVsEta->setAxisTitle("Track #eta", 1);
1847   tkmes.NumberOfValidRecHitsPerTrackVsEta->setAxisTitle("Number of valid RecHits in each Track", 2);
1848 
1849   histname = "NumberOfValidRecHitsPerTrackVsPt_" + histTag;
1850   tkmes.NumberOfValidRecHitsPerTrackVsPt =
1851       ibooker.bookProfile(histname, histname, TrackPtBin, TrackPtMin, TrackPtMax, RecHitMin, RecHitMax, "");
1852   tkmes.NumberOfValidRecHitsPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
1853   tkmes.NumberOfValidRecHitsPerTrackVsPt->setAxisTitle("Number of valid RecHits in each Track", 2);
1854 
1855   //////////////////////////////////////////
1856   histname = "NumberOfLayersPerTrackVsPhi_" + histTag;
1857   tkmes.NumberOfLayersPerTrackVsPhi =
1858       ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, RecLayBin, RecLayMin, RecLayMax, "");
1859   tkmes.NumberOfLayersPerTrackVsPhi->setAxisTitle("Track #phi", 1);
1860   tkmes.NumberOfLayersPerTrackVsPhi->setAxisTitle("Number of Layers in each Track", 2);
1861 
1862   if (doThetaPlots_) {
1863     histname = "NumberOfLayersPerTrackVsTheta_" + histTag;
1864     tkmes.NumberOfLayersPerTrackVsTheta =
1865         ibooker.bookProfile(histname, histname, ThetaBin, ThetaMin, ThetaMax, RecLayBin, RecLayMin, RecLayMax, "");
1866     tkmes.NumberOfLayersPerTrackVsTheta->setAxisTitle("Track #phi", 1);
1867     tkmes.NumberOfLayersPerTrackVsTheta->setAxisTitle("Number of Layers in each Track", 2);
1868   }
1869   histname = "NumberOfLayersPerTrackVsEta_" + histTag;
1870   tkmes.NumberOfLayersPerTrackVsEta =
1871       ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, RecLayBin, RecLayMin, RecLayMax, "");
1872   tkmes.NumberOfLayersPerTrackVsEta->setAxisTitle("Track #eta", 1);
1873   tkmes.NumberOfLayersPerTrackVsEta->setAxisTitle("Number of Layers in each Track", 2);
1874 
1875   if (doThetaPlots_) {
1876     histname = "Chi2oNDFVsTheta_" + histTag;
1877     tkmes.Chi2oNDFVsTheta =
1878         ibooker.bookProfile(histname, histname, ThetaBin, ThetaMin, ThetaMax, Chi2NDFMin, Chi2NDFMax, "");
1879     tkmes.Chi2oNDFVsTheta->setAxisTitle("Track #theta", 1);
1880     tkmes.Chi2oNDFVsTheta->setAxisTitle("Track #chi^{2}/ndf", 2);
1881   }
1882   if (doAllPlots_) {
1883     histname = "Chi2oNDFVsPhi_" + histTag;
1884     tkmes.Chi2oNDFVsPhi = ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, Chi2NDFMin, Chi2NDFMax, "");
1885     tkmes.Chi2oNDFVsPhi->setAxisTitle("Track #phi", 1);
1886     tkmes.Chi2oNDFVsPhi->setAxisTitle("Track #chi^{2}/ndf", 2);
1887 
1888     histname = "Chi2oNDFVsEta_" + histTag;
1889     tkmes.Chi2oNDFVsEta = ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, Chi2NDFMin, Chi2NDFMax, "");
1890     tkmes.Chi2oNDFVsEta->setAxisTitle("Track #eta", 1);
1891     tkmes.Chi2oNDFVsEta->setAxisTitle("Track #chi^{2}/ndf", 2);
1892 
1893     histname = "Chi2ProbVsPhi_" + histTag;
1894     tkmes.Chi2ProbVsPhi = ibooker.bookProfile(
1895         histname + CategoryName, histname + CategoryName, PhiBin, PhiMin, PhiMax, Chi2ProbMin, Chi2ProbMax);
1896     tkmes.Chi2ProbVsPhi->setAxisTitle("Tracks #phi", 1);
1897     tkmes.Chi2ProbVsPhi->setAxisTitle("Track #chi^{2} probability", 2);
1898 
1899     histname = "Chi2ProbVsEta_" + histTag;
1900     tkmes.Chi2ProbVsEta = ibooker.bookProfile(
1901         histname + CategoryName, histname + CategoryName, EtaBin, EtaMin, EtaMax, Chi2ProbMin, Chi2ProbMax);
1902     tkmes.Chi2ProbVsEta->setAxisTitle("Tracks #eta", 1);
1903     tkmes.Chi2ProbVsEta->setAxisTitle("Track #chi^{2} probability", 2);
1904   }
1905 
1906   // now put the MEs in the map
1907   TkParameterMEMap.insert(std::make_pair(sname, tkmes));
1908 }
1909 
1910 // fill histograms at differnt measurement points
1911 // ---------------------------------------------------------------------------------//
1912 void TrackAnalyzer::fillHistosForState(const edm::EventSetup& iSetup, const reco::Track& track, std::string sname) {
1913   //get the kinematic parameters
1914   double p, px, py, pz, pt, theta, phi, eta, q;
1915   double pxerror, pyerror, pzerror, pterror, perror, phierror, etaerror;
1916 
1917   std::string Folder = TopFolder_.substr(0, 2);
1918 
1919   auto phiIn = track.innerPosition().phi();
1920   auto etaIn = track.innerPosition().eta();
1921   auto phiOut = track.outerPosition().phi();
1922   auto etaOut = track.outerPosition().eta();
1923 
1924   if (sname == "default") {
1925     p = track.p();
1926     px = track.px();
1927     py = track.py();
1928     pz = track.pz();
1929     pt = track.pt();
1930     phi = track.phi();
1931     theta = track.theta();
1932     eta = track.eta();
1933     q = track.charge();
1934 
1935     pterror = (pt) ? track.ptError() / (pt * pt) : 0.0;
1936     pxerror = -1.0;
1937     pyerror = -1.0;
1938     pzerror = -1.0;
1939     perror = -1.0;
1940     phierror = track.phiError();
1941     etaerror = track.etaError();
1942 
1943   } else {
1944     TransientTrackBuilder const& theB = iSetup.getData(transientTrackBuilderToken_);
1945     reco::TransientTrack TransTrack = theB.build(track);
1946 
1947     TrajectoryStateOnSurface TSOS;
1948 
1949     if (sname == "OuterSurface")
1950       TSOS = TransTrack.outermostMeasurementState();
1951     else if (sname == "InnerSurface")
1952       TSOS = TransTrack.innermostMeasurementState();
1953     else if (sname == "ImpactPoint")
1954       TSOS = TransTrack.impactPointState();
1955 
1956     p = TSOS.globalMomentum().mag();
1957     px = TSOS.globalMomentum().x();
1958     py = TSOS.globalMomentum().y();
1959     pz = TSOS.globalMomentum().z();
1960     pt = TSOS.globalMomentum().perp();
1961     phi = TSOS.globalMomentum().phi();
1962     theta = TSOS.globalMomentum().theta();
1963     eta = TSOS.globalMomentum().eta();
1964     q = TSOS.charge();
1965 
1966     //get the error of the kinimatic parameters
1967     AlgebraicSymMatrix66 errors = TSOS.cartesianError().matrix();
1968     double partialPterror =
1969         errors(3, 3) * pow(TSOS.globalMomentum().x(), 2) + errors(4, 4) * pow(TSOS.globalMomentum().y(), 2);
1970     pterror = sqrt(partialPterror) / TSOS.globalMomentum().perp();
1971     pxerror = sqrt(errors(3, 3)) / TSOS.globalMomentum().x();
1972     pyerror = sqrt(errors(4, 4)) / TSOS.globalMomentum().y();
1973     pzerror = sqrt(errors(5, 5)) / TSOS.globalMomentum().z();
1974     perror = sqrt(partialPterror + errors(5, 5) * pow(TSOS.globalMomentum().z(), 2)) / TSOS.globalMomentum().mag();
1975     phierror = sqrt(TSOS.curvilinearError().matrix()(2, 2));
1976     etaerror = sqrt(TSOS.curvilinearError().matrix()(1, 1)) * fabs(sin(TSOS.globalMomentum().theta()));
1977   }
1978 
1979   std::map<std::string, TkParameterMEs>::iterator iPos = TkParameterMEMap.find(sname);
1980   if (iPos != TkParameterMEMap.end()) {
1981     TkParameterMEs tkmes = iPos->second;
1982 
1983     // momentum
1984     tkmes.TrackP->Fill(p);
1985     if (doTrackPxPyPlots_) {
1986       tkmes.TrackPx->Fill(px);
1987       tkmes.TrackPy->Fill(py);
1988     }
1989     tkmes.TrackPz->Fill(pz);
1990     tkmes.TrackPt->Fill(pt);
1991 
1992     // angles
1993     tkmes.TrackPhi->Fill(phi);
1994     tkmes.TrackEta->Fill(eta);
1995     tkmes.TrackEtaPhi->Fill(eta, phi);
1996 
1997     if (Folder == "Tr") {
1998       tkmes.TrackEtaPhiInverted->Fill(eta, -1 * phi);
1999       tkmes.TrackEtaPhiInvertedoutofphase->Fill(eta, M_PI - phi);
2000       tkmes.TrackEtaPhiInvertedoutofphase->Fill(eta, -(phi + M_PI));
2001       //pT histograms to create efficiency vs pT plot, only for the most inefficient region.
2002 
2003       if (eta < 0. && phi < -1.6) {
2004         tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32->Fill(pt);
2005       }
2006       if (eta < 0. && phi < 0 && phi >= -1.6) {
2007         tkmes.TrackPt_NegEta_Phi_btw_0_neg16->Fill(pt);
2008       }
2009       if (eta < 0. && phi < 1.6 && phi >= 0) {
2010         tkmes.TrackPt_NegEta_Phi_btw_16_0->Fill(pt);
2011       }
2012       if (eta < 0. && phi >= 1.6) {
2013         tkmes.TrackPt_NegEta_Phi_btw_32_16->Fill(pt);
2014       }
2015       if (eta >= 0. && phi < -1.6) {
2016         tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32->Fill(pt);
2017       }
2018       if (eta >= 0. && phi < 0 && phi >= -1.6) {
2019         tkmes.TrackPt_PosEta_Phi_btw_0_neg16->Fill(pt);
2020       }
2021       if (eta >= 0. && phi < 1.6 && phi >= 0) {
2022         tkmes.TrackPt_PosEta_Phi_btw_16_0->Fill(pt);
2023       }
2024       if (eta >= 0. && phi >= 1.6) {
2025         tkmes.TrackPt_PosEta_Phi_btw_32_16->Fill(pt);
2026       }
2027 
2028       float A[8];
2029       A[0] = tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32->integral();
2030       A[1] = tkmes.TrackPt_NegEta_Phi_btw_0_neg16->integral();
2031       A[2] = tkmes.TrackPt_NegEta_Phi_btw_16_0->integral();
2032       A[3] = tkmes.TrackPt_NegEta_Phi_btw_32_16->integral();
2033       A[4] = tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32->integral();
2034       A[5] = tkmes.TrackPt_PosEta_Phi_btw_0_neg16->integral();
2035       A[6] = tkmes.TrackPt_PosEta_Phi_btw_16_0->integral();
2036       A[7] = tkmes.TrackPt_PosEta_Phi_btw_32_16->integral();
2037 
2038       //WZ (the worst zone)
2039       int WZ = 0;
2040       float minA = A[0];
2041       for (int w = 1; w < 8; w++) {
2042         if (minA > A[w]) {
2043           minA = A[w];
2044           WZ = w;
2045         }
2046       }
2047 
2048       switch (WZ) {
2049         case 1:
2050           tkmes.Ratio_byFolding->divide(
2051               tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32, tkmes.TrackPt_NegEta_Phi_btw_32_16, 1., 1., "B");
2052           tkmes.Ratio_byFolding2->divide(
2053               tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32, tkmes.TrackPt_NegEta_Phi_btw_0_neg16, 1., 1., "B");
2054           break;
2055         case 2:
2056           tkmes.Ratio_byFolding->divide(
2057               tkmes.TrackPt_NegEta_Phi_btw_0_neg16, tkmes.TrackPt_NegEta_Phi_btw_16_0, 1., 1., "B");
2058           tkmes.Ratio_byFolding2->divide(
2059               tkmes.TrackPt_NegEta_Phi_btw_0_neg16, tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32, 1., 1., "B");
2060           break;
2061         case 3:
2062           tkmes.Ratio_byFolding->divide(
2063               tkmes.TrackPt_NegEta_Phi_btw_16_0, tkmes.TrackPt_NegEta_Phi_btw_0_neg16, 1., 1., "B");
2064           tkmes.Ratio_byFolding2->divide(
2065               tkmes.TrackPt_NegEta_Phi_btw_16_0, tkmes.TrackPt_NegEta_Phi_btw_32_16, 1., 1., "B");
2066           break;
2067         case 4:
2068           tkmes.Ratio_byFolding->divide(
2069               tkmes.TrackPt_NegEta_Phi_btw_32_16, tkmes.TrackPt_NegEta_Phi_btw_neg16_neg32, 1., 1., "B");
2070           tkmes.Ratio_byFolding2->divide(
2071               tkmes.TrackPt_NegEta_Phi_btw_32_16, tkmes.TrackPt_NegEta_Phi_btw_16_0, 1., 1., "B");
2072           break;
2073         case 5:
2074           tkmes.Ratio_byFolding->divide(
2075               tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32, tkmes.TrackPt_PosEta_Phi_btw_32_16, 1., 1., "B");
2076           tkmes.Ratio_byFolding2->divide(
2077               tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32, tkmes.TrackPt_PosEta_Phi_btw_0_neg16, 1., 1., "B");
2078           break;
2079         case 6:
2080           tkmes.Ratio_byFolding->divide(
2081               tkmes.TrackPt_PosEta_Phi_btw_0_neg16, tkmes.TrackPt_PosEta_Phi_btw_16_0, 1., 1., "B");
2082           tkmes.Ratio_byFolding2->divide(
2083               tkmes.TrackPt_PosEta_Phi_btw_0_neg16, tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32, 1., 1., "B");
2084           break;
2085         case 7:
2086           tkmes.Ratio_byFolding->divide(
2087               tkmes.TrackPt_PosEta_Phi_btw_16_0, tkmes.TrackPt_PosEta_Phi_btw_0_neg16, 1., 1., "B");
2088           tkmes.Ratio_byFolding2->divide(
2089               tkmes.TrackPt_PosEta_Phi_btw_16_0, tkmes.TrackPt_PosEta_Phi_btw_32_16, 1., 1., "B");
2090           break;
2091         case 8:
2092           tkmes.Ratio_byFolding->divide(
2093               tkmes.TrackPt_PosEta_Phi_btw_32_16, tkmes.TrackPt_PosEta_Phi_btw_neg16_neg32, 1., 1., "B");
2094           tkmes.Ratio_byFolding2->divide(
2095               tkmes.TrackPt_PosEta_Phi_btw_32_16, tkmes.TrackPt_PosEta_Phi_btw_16_0, 1., 1., "B");
2096           break;
2097       }
2098       tkmes.Ratio_byFolding->setAxisTitle("Efficiency(Ratio)_" + std::to_string(WZ), 2);
2099       tkmes.Ratio_byFolding2->setAxisTitle("Efficiency(Ratio)_" + std::to_string(WZ), 2);
2100 
2101       if (track.quality(reco::TrackBase::highPurity)) {
2102         tkmes.TrackPtHighPurity->Fill(pt);
2103         tkmes.Quality->Fill(reco::TrackBase::highPurity, 1.);
2104       }
2105       if (track.quality(reco::TrackBase::tight)) {
2106         tkmes.TrackPtTight->Fill(pt);
2107         tkmes.Quality->Fill(reco::TrackBase::tight, 1.);
2108       }
2109       if (track.quality(reco::TrackBase::loose)) {
2110         tkmes.TrackPtLoose->Fill(pt);
2111         tkmes.Quality->Fill(reco::TrackBase::loose, 1.);
2112       }
2113       if (track.quality(reco::TrackBase::highPurity)) {
2114         tkmes.TrackEtaHighPurity->Fill(eta);
2115       }
2116       if (track.quality(reco::TrackBase::tight)) {
2117         tkmes.TrackEtaTight->Fill(eta);
2118       }
2119       if (track.quality(reco::TrackBase::loose)) {
2120         tkmes.TrackEtaLoose->Fill(eta);
2121       }
2122 
2123       if (p > 0.) {
2124         tkmes.TrackQoverP->Fill(q / p);
2125       }
2126     }
2127 
2128     tkmes.TrackEtaPhiInner->Fill(etaIn, phiIn);
2129     tkmes.TrackEtaPhiOuter->Fill(etaOut, phiOut);
2130 
2131     if (doThetaPlots_) {
2132       tkmes.TrackTheta->Fill(theta);
2133     }
2134     tkmes.TrackQ->Fill(q);
2135 
2136     // errors
2137     tkmes.TrackPtErr->Fill(pterror);
2138     tkmes.TrackPtErrVsEta->Fill(eta, pterror);
2139     if (doTrackPxPyPlots_) {
2140       tkmes.TrackPxErr->Fill(pxerror);
2141       tkmes.TrackPyErr->Fill(pyerror);
2142     }
2143     tkmes.TrackPzErr->Fill(pzerror);
2144     tkmes.TrackPErr->Fill(perror);
2145     tkmes.TrackPhiErr->Fill(phierror);
2146     tkmes.TrackEtaErr->Fill(etaerror);
2147 
2148     int nRecHits = track.hitPattern().numberOfAllHits(reco::HitPattern::TRACK_HITS);
2149     int nValidRecHits = track.numberOfValidHits();
2150     // rec hits
2151     tkmes.NumberOfRecHitsPerTrackVsPhi->Fill(phi, nRecHits);
2152     if (doThetaPlots_) {
2153       tkmes.NumberOfRecHitsPerTrackVsTheta->Fill(theta, nRecHits);
2154     }
2155     tkmes.NumberOfRecHitsPerTrackVsEta->Fill(eta, nRecHits);
2156     tkmes.NumberOfValidRecHitsPerTrackVsPhi->Fill(phi, nValidRecHits);
2157     tkmes.NumberOfValidRecHitsPerTrackVsEta->Fill(eta, nValidRecHits);
2158     tkmes.NumberOfValidRecHitsPerTrackVsPt->Fill(pt, nValidRecHits);
2159 
2160     int nLayers = track.hitPattern().trackerLayersWithMeasurement();
2161     // rec layers
2162     tkmes.NumberOfLayersPerTrackVsPhi->Fill(phi, nLayers);
2163     if (doThetaPlots_) {
2164       tkmes.NumberOfLayersPerTrackVsTheta->Fill(theta, nLayers);
2165     }
2166     tkmes.NumberOfLayersPerTrackVsEta->Fill(eta, nLayers);
2167 
2168     double chi2prob = TMath::Prob(track.chi2(), (int)track.ndof());
2169     double chi2oNDF = track.normalizedChi2();
2170 
2171     tkmes.Chi2oNDFVsEta->Fill(eta, chi2oNDF);
2172     tkmes.Chi2oNDFVsPt->Fill(pt, chi2oNDF);
2173     tkmes.Chi2oNDFVsNHits->Fill(nRecHits, chi2oNDF);
2174 
2175     if (doAllPlots_) {
2176       // general properties
2177       if (doThetaPlots_) {
2178         tkmes.Chi2oNDFVsTheta->Fill(theta, chi2oNDF);
2179       }
2180       tkmes.Chi2oNDFVsPhi->Fill(phi, chi2oNDF);
2181       tkmes.Chi2ProbVsPhi->Fill(phi, chi2prob);
2182       tkmes.Chi2ProbVsEta->Fill(eta, chi2prob);
2183     }
2184   }
2185 }
2186 
2187 void TrackAnalyzer::bookHistosForTrackerSpecific(DQMStore::IBooker& ibooker) {
2188   // parameters from the configuration
2189   std::string QualName = conf_->getParameter<std::string>("Quality");
2190   std::string AlgoName = conf_->getParameter<std::string>("AlgoName");
2191 
2192   // use the AlgoName and Quality Name
2193   std::string CategoryName = !QualName.empty() ? AlgoName + "_" + QualName : AlgoName;
2194 
2195   int PhiBin = conf_->getParameter<int>("PhiBin");
2196   double PhiMin = conf_->getParameter<double>("PhiMin");
2197   double PhiMax = conf_->getParameter<double>("PhiMax");
2198 
2199   int EtaBin = conf_->getParameter<int>("EtaBin");
2200   double EtaMin = conf_->getParameter<double>("EtaMin");
2201   double EtaMax = conf_->getParameter<double>("EtaMax");
2202 
2203   int PtBin = conf_->getParameter<int>("TrackPtBin");
2204   double PtMin = conf_->getParameter<double>("TrackPtMin");
2205   double PtMax = conf_->getParameter<double>("TrackPtMax");
2206 
2207   // book hit property histograms
2208   // ---------------------------------------------------------------------------------//
2209   ibooker.setCurrentFolder(TopFolder_ + "/HitProperties");
2210 
2211   std::vector<std::string> subdetectors = conf_->getParameter<std::vector<std::string> >("subdetectors");
2212   int detBin = conf_->getParameter<int>("subdetectorBin");
2213 
2214   for (const auto& det : subdetectors) {
2215     // hits properties
2216     ibooker.setCurrentFolder(TopFolder_ + "/HitProperties/" + det);
2217 
2218     TkRecHitsPerSubDetMEs recHitsPerSubDet_mes;
2219 
2220     recHitsPerSubDet_mes.detectorTag = det;
2221     int detID = -1;
2222     if (det == "TIB")
2223       detID = StripSubdetector::TIB;  // 3
2224     if (det == "TOB")
2225       detID = StripSubdetector::TOB;  // 5
2226     if (det == "TID")
2227       detID = StripSubdetector::TID;  // 4
2228     if (det == "TEC")
2229       detID = StripSubdetector::TEC;  // 6
2230     if (det == "PixBarrel")
2231       detID = PixelSubdetector::PixelBarrel;  // 1
2232     if (det == "PixEndcap")
2233       detID = PixelSubdetector::PixelEndcap;  // 2
2234     if (det == "Pixel")
2235       detID = 0;
2236     if (det == "Strip")
2237       detID = 7;
2238 
2239     recHitsPerSubDet_mes.detectorId = detID;
2240 
2241     histname = "NumberOfRecHitsPerTrack_" + det + "_" + CategoryName;
2242     recHitsPerSubDet_mes.NumberOfRecHitsPerTrack =
2243         ibooker.book1D(histname, histname, detBin, -0.5, double(detBin) - 0.5);
2244     recHitsPerSubDet_mes.NumberOfRecHitsPerTrack->setAxisTitle("Number of " + det + " valid RecHits in each Track", 1);
2245     recHitsPerSubDet_mes.NumberOfRecHitsPerTrack->setAxisTitle("Number of Tracks", 2);
2246 
2247     histname = "NumberOfRecHitsPerTrackVsPhi_" + det + "_" + CategoryName;
2248     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsPhi =
2249         ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, detBin, -0.5, double(detBin) - 0.5, "");
2250     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsPhi->setAxisTitle("Track #phi", 1);
2251     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsPhi->setAxisTitle("Number of " + det + " valid RecHits in each Track",
2252                                                                     2);
2253 
2254     histname = "NumberOfRecHitsPerTrackVsEta_" + det + "_" + CategoryName;
2255     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsEta =
2256         ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, detBin, -0.5, double(detBin) - 0.5, "");
2257     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsEta->setAxisTitle("Track #eta", 1);
2258     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsEta->setAxisTitle("Number of " + det + " valid RecHits in each Track",
2259                                                                     2);
2260 
2261     histname = "NumberOfRecHitsPerTrackVsPt_" + det + "_" + CategoryName;
2262     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsPt =
2263         ibooker.bookProfile(histname, histname, PtBin, PtMin, PtMax, detBin, -0.5, double(detBin) - 0.5, "");
2264     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
2265     recHitsPerSubDet_mes.NumberOfRecHitsPerTrackVsPt->setAxisTitle("Number of " + det + " valid RecHits in each Track",
2266                                                                    2);
2267 
2268     histname = "NumberOfLayersPerTrack_" + det + "_" + CategoryName;
2269     recHitsPerSubDet_mes.NumberOfLayersPerTrack =
2270         ibooker.book1D(histname, histname, detBin, -0.5, double(detBin) - 0.5);
2271     recHitsPerSubDet_mes.NumberOfLayersPerTrack->setAxisTitle("Number of " + det + " valid Layers in each Track", 1);
2272     recHitsPerSubDet_mes.NumberOfLayersPerTrack->setAxisTitle("Number of Tracks", 2);
2273 
2274     histname = "NumberOfLayersPerTrackVsPhi_" + det + "_" + CategoryName;
2275     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsPhi =
2276         ibooker.bookProfile(histname, histname, PhiBin, PhiMin, PhiMax, detBin, -0.5, double(detBin) - 0.5, "");
2277     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsPhi->setAxisTitle("Track #phi", 1);
2278     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsPhi->setAxisTitle("Number of " + det + " valid Layers in each Track",
2279                                                                    2);
2280 
2281     histname = "NumberOfLayersPerTrackVsEta_" + det + "_" + CategoryName;
2282     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsEta =
2283         ibooker.bookProfile(histname, histname, EtaBin, EtaMin, EtaMax, detBin, -0.5, double(detBin) - 0.5, "");
2284     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsEta->setAxisTitle("Track #eta", 1);
2285     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsEta->setAxisTitle("Number of " + det + " valid Layers in each Track",
2286                                                                    2);
2287 
2288     histname = "NumberOfLayersPerTrackVsPt_" + det + "_" + CategoryName;
2289     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsPt =
2290         ibooker.bookProfile(histname, histname, PtBin, PtMin, PtMax, detBin, -0.5, double(detBin) - 0.5, "");
2291     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsPt->setAxisTitle("Track p_{T} [GeV]", 1);
2292     recHitsPerSubDet_mes.NumberOfLayersPerTrackVsPt->setAxisTitle("Number of " + det + " valid Layers in each Track",
2293                                                                   2);
2294 
2295     TkRecHitsPerSubDetMEMap.insert(std::pair<std::string, TkRecHitsPerSubDetMEs>(det, recHitsPerSubDet_mes));
2296   }
2297 }
2298 
2299 void TrackAnalyzer::fillHistosForTrackerSpecific(const reco::Track& track) {
2300   double phi = track.phi();
2301   double eta = track.eta();
2302   double pt = track.pt();
2303 
2304   for (std::map<std::string, TkRecHitsPerSubDetMEs>::iterator it = TkRecHitsPerSubDetMEMap.begin();
2305        it != TkRecHitsPerSubDetMEMap.end();
2306        it++) {
2307     int nValidLayers = 0;
2308     int nValidRecHits = 0;
2309     int substr = it->second.detectorId;
2310     switch (substr) {
2311       case 0:
2312         nValidLayers = track.hitPattern().pixelBarrelLayersWithMeasurement() +
2313                        track.hitPattern().pixelEndcapLayersWithMeasurement();  // case 0: pixel
2314         nValidRecHits = track.hitPattern().numberOfValidPixelBarrelHits() +
2315                         track.hitPattern().numberOfValidPixelEndcapHits();  // case 0: pixel
2316         break;
2317       case StripSubdetector::TIB:
2318         nValidLayers = track.hitPattern().stripTIBLayersWithMeasurement();  // case 3: strip TIB
2319         nValidRecHits = track.hitPattern().numberOfValidStripTIBHits();     // case 3: strip TIB
2320         break;
2321       case StripSubdetector::TID:
2322         nValidLayers = track.hitPattern().stripTIDLayersWithMeasurement();  // case 4: strip TID
2323         nValidRecHits = track.hitPattern().numberOfValidStripTIDHits();     // case 4: strip TID
2324         break;
2325       case StripSubdetector::TOB:
2326         nValidLayers = track.hitPattern().stripTOBLayersWithMeasurement();  // case 5: strip TOB
2327         nValidRecHits = track.hitPattern().numberOfValidStripTOBHits();     // case 5: strip TOB
2328         break;
2329       case StripSubdetector::TEC:
2330         nValidLayers = track.hitPattern().stripTECLayersWithMeasurement();  // case 6: strip TEC
2331         nValidRecHits = track.hitPattern().numberOfValidStripTECHits();     // case 6: strip TEC
2332         break;
2333       case PixelSubdetector::PixelBarrel:
2334         nValidLayers = track.hitPattern().pixelBarrelLayersWithMeasurement();  // case 1: pixel PXB
2335         nValidRecHits = track.hitPattern().numberOfValidPixelBarrelHits();     // case 1: pixel PXB
2336         break;
2337       case PixelSubdetector::PixelEndcap:
2338         nValidLayers = track.hitPattern().pixelEndcapLayersWithMeasurement();  // case 2: pixel PXF
2339         nValidRecHits = track.hitPattern().numberOfValidPixelEndcapHits();     // case 2: pixel PXF
2340         break;
2341       case 7:
2342         nValidLayers = track.hitPattern().stripTIBLayersWithMeasurement()  // case 7: strip
2343                        + track.hitPattern().stripTIDLayersWithMeasurement() +
2344                        track.hitPattern().stripTOBLayersWithMeasurement() +
2345                        track.hitPattern().stripTECLayersWithMeasurement();
2346         nValidRecHits = track.hitPattern().numberOfValidStripTIBHits()  // case 7: strip
2347                         + track.hitPattern().numberOfValidStripTIDHits() +
2348                         track.hitPattern().numberOfValidStripTOBHits() + track.hitPattern().numberOfValidStripTECHits();
2349         break;
2350       default:
2351         break;
2352     }
2353 
2354     //Fill Layers and RecHits
2355     it->second.NumberOfRecHitsPerTrack->Fill(nValidRecHits);
2356     it->second.NumberOfRecHitsPerTrackVsPhi->Fill(phi, nValidRecHits);
2357     it->second.NumberOfRecHitsPerTrackVsEta->Fill(eta, nValidRecHits);
2358     it->second.NumberOfRecHitsPerTrackVsPt->Fill(pt, nValidRecHits);
2359 
2360     it->second.NumberOfLayersPerTrack->Fill(nValidLayers);
2361     it->second.NumberOfLayersPerTrackVsPhi->Fill(phi, nValidLayers);
2362     it->second.NumberOfLayersPerTrackVsEta->Fill(eta, nValidLayers);
2363     it->second.NumberOfLayersPerTrackVsPt->Fill(pt, nValidLayers);
2364   }
2365 }