Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:07

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