Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:47

0001 // -*- C++ -*-
0002 // Package:    SiStripMonitorCluster
0003 // Class:      SiStripMonitorCluster
0004 /**\class SiStripMonitorCluster SiStripMonitorCluster.cc
0005  * DQM/SiStripMonitorCluster/src/SiStripMonitorCluster.cc
0006  */
0007 // Original Author:  Dorian Kcira
0008 //         Created:  Wed Feb  1 16:42:34 CET 2006
0009 
0010 // std library includes
0011 #include <cmath>
0012 #include <fstream>
0013 #include <numeric>
0014 #include <vector>
0015 #include <iostream>
0016 
0017 // user includes
0018 #include "CalibTracker/SiStripCommon/interface/SiStripDCSStatus.h"
0019 #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
0020 #include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"
0021 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
0022 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
0023 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0024 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
0025 #include "DQM/SiStripMonitorCluster/interface/SiStripMonitorCluster.h"
0026 #include "DQMServices/Core/interface/DQMStore.h"
0027 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0028 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0029 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
0030 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0031 #include "DataFormats/TrackerCommon/interface/SiStripSubStructure.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 #include "FWCore/ServiceRegistry/interface/Service.h"
0034 #include "FWCore/Utilities/interface/ESInputTag.h"
0035 #include "FWCore/Utilities/interface/Transition.h"
0036 
0037 // ROOT includes
0038 #include "TNamed.h"
0039 #include "TMath.h"
0040 
0041 //--------------------------------------------------------------------------------------------
0042 SiStripMonitorCluster::SiStripMonitorCluster(const edm::ParameterSet& iConfig)
0043     : conf_(iConfig),
0044       show_mechanical_structure_view(true),
0045       show_readout_view(false),
0046       show_control_view(false),
0047       select_all_detectors(false),
0048       reset_each_run(false),
0049       m_cacheID_(0),
0050       qualityLabel_{conf_.getParameter<std::string>("StripQualityLabel")},
0051       trackerTopologyRunToken_{esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()},
0052       tkDetMapToken_{esConsumes<TkDetMap, TrackerTopologyRcd, edm::Transition::BeginRun>()},
0053       siStripDetCablingRunToken_{esConsumes<SiStripDetCabling, SiStripDetCablingRcd, edm::Transition::BeginRun>()},
0054       trackerTopologyEventToken_{esConsumes<TrackerTopology, TrackerTopologyRcd>()},
0055       siStripNoisesToken_{esConsumes<SiStripNoises, SiStripNoisesRcd>()},
0056       siStripGainToken_{esConsumes<SiStripGain, SiStripGainRcd>()},
0057       siStripQualityToken_{esConsumes<SiStripQuality, SiStripQualityRcd>(edm::ESInputTag("", qualityLabel_))},
0058       siStripDetCablingEventToken_{esConsumes<SiStripDetCabling, SiStripDetCablingRcd>()} {
0059   // initialize
0060   passBPTXfilter_ = true;
0061 
0062   // initialize GenericTriggerEventFlag by specific configuration
0063   // in this way, one can set specific selections for different MEs
0064   genTriggerEventFlagBPTXfilter_ =
0065       new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("BPTXfilter"), consumesCollector(), *this);
0066   genTriggerEventFlagPixelDCSfilter_ = new GenericTriggerEventFlag(
0067       iConfig.getParameter<edm::ParameterSet>("PixelDCSfilter"), consumesCollector(), *this);
0068   genTriggerEventFlagStripDCSfilter_ = new GenericTriggerEventFlag(
0069       iConfig.getParameter<edm::ParameterSet>("StripDCSfilter"), consumesCollector(), *this);
0070 
0071   firstEvent = -1;
0072   eventNb = 0;
0073 
0074   // Detector Partitions
0075   SubDetPhasePartMap["TIB"] = "TI";
0076   SubDetPhasePartMap["TID__MINUS"] = "TI";
0077   SubDetPhasePartMap["TID__PLUS"] = "TI";
0078   SubDetPhasePartMap["TOB"] = "TO";
0079   SubDetPhasePartMap["TEC__MINUS"] = "TM";
0080   SubDetPhasePartMap["TEC__PLUS"] = "TP";
0081 
0082   // get on/off option for every cluster from cfi
0083   edm::ParameterSet ParametersnClusters = conf_.getParameter<edm::ParameterSet>("TH1nClusters");
0084   layerswitchncluson = ParametersnClusters.getParameter<bool>("layerswitchon");
0085   moduleswitchncluson = ParametersnClusters.getParameter<bool>("moduleswitchon");
0086 
0087   edm::ParameterSet ParametersClusterCharge = conf_.getParameter<edm::ParameterSet>("TH1ClusterCharge");
0088   layerswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("layerswitchon");
0089   moduleswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("moduleswitchon");
0090   subdetswitchcluschargeon = ParametersClusterCharge.getParameter<bool>("subdetswitchon");
0091 
0092   edm::ParameterSet ParametersClusterStoN = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoN");
0093   layerswitchclusstonon = ParametersClusterStoN.getParameter<bool>("layerswitchon");
0094   moduleswitchclusstonon = ParametersClusterStoN.getParameter<bool>("moduleswitchon");
0095 
0096   edm::ParameterSet ParametersClusterStoNVsPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
0097   layerswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("layerswitchon");
0098   moduleswitchclusstonVsposon = ParametersClusterStoNVsPos.getParameter<bool>("moduleswitchon");
0099 
0100   edm::ParameterSet ParametersClusterPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterPos");
0101   layerswitchclusposon = ParametersClusterPos.getParameter<bool>("layerswitchon");
0102   moduleswitchclusposon = ParametersClusterPos.getParameter<bool>("moduleswitchon");
0103 
0104   edm::ParameterSet ParametersClusterDigiPos = conf_.getParameter<edm::ParameterSet>("TH1ClusterDigiPos");
0105   layerswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("layerswitchon");
0106   moduleswitchclusdigiposon = ParametersClusterDigiPos.getParameter<bool>("moduleswitchon");
0107 
0108   edm::ParameterSet ParametersClusterNoise = conf_.getParameter<edm::ParameterSet>("TH1ClusterNoise");
0109   layerswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("layerswitchon");
0110   moduleswitchclusnoiseon = ParametersClusterNoise.getParameter<bool>("moduleswitchon");
0111 
0112   edm::ParameterSet ParametersClusterWidth = conf_.getParameter<edm::ParameterSet>("TH1ClusterWidth");
0113   layerswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("layerswitchon");
0114   moduleswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("moduleswitchon");
0115   subdetswitchcluswidthon = ParametersClusterWidth.getParameter<bool>("subdetswitchon");
0116 
0117   edm::ParameterSet ParametersModuleLocalOccupancy = conf_.getParameter<edm::ParameterSet>("TH1ModuleLocalOccupancy");
0118   layerswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("layerswitchon");
0119   moduleswitchlocaloccupancy = ParametersModuleLocalOccupancy.getParameter<bool>("moduleswitchon");
0120 
0121   edm::ParameterSet ParametersNrOfClusterizedStrips = conf_.getParameter<edm::ParameterSet>("TH1NrOfClusterizedStrips");
0122   layerswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("layerswitchon");
0123   moduleswitchnrclusterizedstrip = ParametersNrOfClusterizedStrips.getParameter<bool>("moduleswitchon");
0124 
0125   edm::ParameterSet ParametersClusterProf = conf_.getParameter<edm::ParameterSet>("TProfNumberOfCluster");
0126   layerswitchnumclusterprofon = ParametersClusterProf.getParameter<bool>("layerswitchon");
0127 
0128   edm::ParameterSet ParametersClusterWidthProf = conf_.getParameter<edm::ParameterSet>("TProfClusterWidth");
0129   layerswitchclusterwidthprofon = ParametersClusterWidthProf.getParameter<bool>("layerswitchon");
0130 
0131   edm::ParameterSet ParametersTotClusterProf = conf_.getParameter<edm::ParameterSet>("TProfTotalNumberOfClusters");
0132   subdetswitchtotclusprofon = ParametersTotClusterProf.getParameter<bool>("subdetswitchon");
0133 
0134   edm::ParameterSet ParametersTotClusterTH1 = conf_.getParameter<edm::ParameterSet>("TH1TotalNumberOfClusters");
0135   subdetswitchtotclusth1on = ParametersTotClusterTH1.getParameter<bool>("subdetswitchon");
0136 
0137   edm::ParameterSet ParametersClusterApvProf = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
0138   subdetswitchapvcycleprofon = ParametersClusterApvProf.getParameter<bool>("subdetswitchon");
0139 
0140   edm::ParameterSet ParametersClustersApvTH2 = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
0141   subdetswitchapvcycleth2on = ParametersClustersApvTH2.getParameter<bool>("subdetswitchon");
0142 
0143   edm::ParameterSet ParametersApvCycleDBxProf2 = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
0144   subdetswitchapvcycledbxprof2on = ParametersApvCycleDBxProf2.getParameter<bool>("subdetswitchon");
0145 
0146   edm::ParameterSet ParametersDBxCycleProf = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
0147   subdetswitchdbxcycleprofon = ParametersDBxCycleProf.getParameter<bool>("subdetswitchon");
0148 
0149   edm::ParameterSet ParametersCStripVsCPix = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
0150   globalswitchcstripvscpix = ParametersCStripVsCPix.getParameter<bool>("globalswitchon");
0151 
0152   edm::ParameterSet ParametersMultiplicityRegionsTH1 = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
0153   globalswitchMultiRegions = ParametersMultiplicityRegionsTH1.getParameter<bool>("globalswitchon");
0154 
0155   edm::ParameterSet ParametersApvCycleVsDBxGlobalTH2 = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
0156   globalswitchapvcycledbxth2on = ParametersApvCycleVsDBxGlobalTH2.getParameter<bool>("globalswitchon");
0157 
0158   edm::ParameterSet ParametersNoiseStrip2ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
0159   globalswitchstripnoise2apvcycle = ParametersNoiseStrip2ApvCycle.getParameter<bool>("globalswitchon");
0160 
0161   edm::ParameterSet ParametersNoiseStrip3ApvCycle = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
0162   globalswitchstripnoise3apvcycle = ParametersNoiseStrip3ApvCycle.getParameter<bool>("globalswitchon");
0163 
0164   edm::ParameterSet ParametersMainDiagonalPosition = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
0165   globalswitchmaindiagonalposition = ParametersMainDiagonalPosition.getParameter<bool>("globalswitchon");
0166 
0167   edm::ParameterSet ClusterMultiplicityRegions = conf_.getParameter<edm::ParameterSet>("MultiplicityRegions");
0168   k0 = ClusterMultiplicityRegions.getParameter<double>("k0");
0169   q0 = ClusterMultiplicityRegions.getParameter<double>("q0");
0170   dk0 = ClusterMultiplicityRegions.getParameter<double>("dk0");
0171   maxClus = ClusterMultiplicityRegions.getParameter<double>("MaxClus");
0172   minPix = ClusterMultiplicityRegions.getParameter<double>("MinPix");
0173 
0174   edm::ParameterSet ParametersNclusVsCycleTimeProf2D = conf_.getParameter<edm::ParameterSet>("NclusVsCycleTimeProf2D");
0175   globalswitchnclusvscycletimeprof2don = ParametersNclusVsCycleTimeProf2D.getParameter<bool>("globalswitchon");
0176 
0177   edm::ParameterSet ParametersFEDCluster = conf_.getParameter<edm::ParameterSet>("TProfNClustersFED");
0178   globalswitchFEDCluster = ParametersFEDCluster.getParameter<bool>("globalswitchon");
0179 
0180   edm::ParameterSet ParametersClusWidthVsAmpTH2 = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
0181   clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("globalswitchon");
0182   layer_clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("layerswitchon");
0183   subdet_clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("subdetswitchon");
0184   module_clusterWidth_vs_amplitude_on = ParametersClusWidthVsAmpTH2.getParameter<bool>("moduleswitchon");
0185 
0186   clustertkhistomapon = conf_.getParameter<bool>("TkHistoMap_On");
0187   clusterchtkhistomapon = conf_.getParameter<bool>("ClusterChTkHistoMap_On");
0188   createTrendMEs = conf_.getParameter<bool>("CreateTrendMEs");
0189   trendVs10Ls_ = conf_.getParameter<bool>("TrendVs10LS");
0190   Mod_On_ = conf_.getParameter<bool>("Mod_On");
0191   ClusterHisto_ = conf_.getParameter<bool>("ClusterHisto");
0192 
0193   topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
0194 
0195   // Poducer name of input StripClusterCollection
0196   clusterProducerStripToken_ =
0197       consumes<edmNew::DetSetVector<SiStripCluster> >(conf_.getParameter<edm::InputTag>("ClusterProducerStrip"));
0198   clusterProducerPixToken_ =
0199       consumes<edmNew::DetSetVector<SiPixelCluster> >(conf_.getParameter<edm::InputTag>("ClusterProducerPix"));
0200   /*
0201   clusterProducerStrip_ =
0202   conf_.getParameter<edm::InputTag>("ClusterProducerStrip"); clusterProducerPix_
0203   = conf_.getParameter<edm::InputTag>("ClusterProducerPix");
0204   */
0205   // cluster quality conditions
0206   edm::ParameterSet cluster_condition = conf_.getParameter<edm::ParameterSet>("ClusterConditions");
0207   applyClusterQuality_ = cluster_condition.getParameter<bool>("On");
0208   sToNLowerLimit_ = cluster_condition.getParameter<double>("minStoN");
0209   sToNUpperLimit_ = cluster_condition.getParameter<double>("maxStoN");
0210   widthLowerLimit_ = cluster_condition.getParameter<double>("minWidth");
0211   widthUpperLimit_ = cluster_condition.getParameter<double>("maxWidth");
0212 
0213   // Event History Producer
0214   //  historyProducer_ = conf_.getParameter<edm::InputTag>("HistoryProducer");
0215   historyProducerToken_ = consumes<EventWithHistory>(conf_.getParameter<edm::InputTag>("HistoryProducer"));
0216   // Apv Phase Producer
0217   //  apvPhaseProducer_ = conf_.getParameter<edm::InputTag>("ApvPhaseProducer");
0218   apvPhaseProducerToken_ = consumes<APVCyclePhaseCollection>(conf_.getParameter<edm::InputTag>("ApvPhaseProducer"));
0219   // Create DCS Status
0220   bool checkDCS = conf_.getParameter<bool>("UseDCSFiltering");
0221   if (checkDCS)
0222     dcsStatus_ = new SiStripDCSStatus(consumesCollector());
0223   else
0224     dcsStatus_ = nullptr;
0225 }
0226 
0227 SiStripMonitorCluster::~SiStripMonitorCluster() {
0228   if (dcsStatus_)
0229     delete dcsStatus_;
0230   if (genTriggerEventFlagBPTXfilter_)
0231     delete genTriggerEventFlagBPTXfilter_;
0232   if (genTriggerEventFlagPixelDCSfilter_)
0233     delete genTriggerEventFlagPixelDCSfilter_;
0234   if (genTriggerEventFlagStripDCSfilter_)
0235     delete genTriggerEventFlagStripDCSfilter_;
0236 }
0237 
0238 //--------------------------------------------------------------------------------------------
0239 void SiStripMonitorCluster::dqmBeginRun(const edm::Run& run, const edm::EventSetup& es) {
0240   // Initialize the GenericTriggerEventFlag
0241   if (genTriggerEventFlagBPTXfilter_->on())
0242     genTriggerEventFlagBPTXfilter_->initRun(run, es);
0243   if (genTriggerEventFlagPixelDCSfilter_->on())
0244     genTriggerEventFlagPixelDCSfilter_->initRun(run, es);
0245   if (genTriggerEventFlagStripDCSfilter_->on())
0246     genTriggerEventFlagStripDCSfilter_->initRun(run, es);
0247 }
0248 
0249 //--------------------------------------------------------------------------------------------
0250 void SiStripMonitorCluster::createMEs(const edm::EventSetup& es, DQMStore::IBooker& ibooker) {
0251   if (show_mechanical_structure_view) {
0252     const TrackerTopology* const tTopo = &es.getData(trackerTopologyRunToken_);
0253     const TkDetMap* tkDetMap = &es.getData(tkDetMapToken_);
0254     const SiStripDetCabling& siStripDetCabling = es.getData(siStripDetCablingRunToken_);
0255 
0256     // get list of active detectors from SiStripDetCabling
0257     std::vector<uint32_t> activeDets;
0258     siStripDetCabling.addActiveDetectorsRawIds(activeDets);
0259 
0260     SiStripFolderOrganizer folder_organizer;
0261     folder_organizer.setSiStripFolderName(topFolderName_);
0262     folder_organizer.setSiStripFolder();
0263 
0264     // Create TkHistoMap for Cluster
0265     if (clustertkhistomapon) {
0266       //      std::cout << "[SiStripMonitorCluster::createMEs] topFolderName_: "
0267       //      << topFolderName_ << "     ";
0268       if ((topFolderName_ == "SiStrip") or (std::string::npos != topFolderName_.find("HLT")))
0269         tkmapcluster =
0270             std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_, "TkHMap_NumberOfCluster", 0., true);
0271       else
0272         tkmapcluster = std::make_unique<TkHistoMap>(
0273             tkDetMap, ibooker, topFolderName_ + "/TkHistoMap", "TkHMap_NumberOfCluster", 0., false);
0274     }
0275     if (clusterchtkhistomapon) {
0276       if ((topFolderName_ == "SiStrip") or (std::string::npos != topFolderName_.find("HLT")))
0277         tkmapclusterch =
0278             std::make_unique<TkHistoMap>(tkDetMap, ibooker, topFolderName_, "TkHMap_ClusterCharge", 0., true);
0279       else
0280         tkmapclusterch = std::make_unique<TkHistoMap>(
0281             tkDetMap, ibooker, topFolderName_ + "/TkHistoMap", "TkHMap_ClusterCharge", 0., false);
0282     }
0283 
0284     // loop over detectors and book MEs
0285     edm::LogInfo("SiStripTkDQM|SiStripMonitorCluster") << "nr. of activeDets:  " << activeDets.size();
0286     for (std::vector<uint32_t>::iterator detid_iterator = activeDets.begin(); detid_iterator != activeDets.end();
0287          detid_iterator++) {
0288       uint32_t detid = (*detid_iterator);
0289       // remove any eventual zero elements - there should be none, but just in
0290       // case
0291       if (detid == 0) {
0292         activeDets.erase(detid_iterator);
0293         continue;
0294       }
0295 
0296       if (Mod_On_) {
0297         ModMEs mod_single;
0298         // set appropriate folder using SiStripFolderOrganizer
0299         folder_organizer.setDetectorFolder(detid, tTopo);  // pass the detid to this method
0300         if (reset_each_run)
0301           ResetModuleMEs(detid);
0302         createModuleMEs(mod_single, detid, ibooker, siStripDetCabling);
0303         // append to ModuleMEsMap
0304         ModuleMEsMap.insert(std::make_pair(detid, mod_single));
0305       }
0306 
0307       // Create Layer Level MEs if they are not created already
0308       std::pair<std::string, int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
0309       SiStripHistoId hidmanager;
0310       std::string label = hidmanager.getSubdetid(detid, tTopo, false);
0311 
0312       std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(label);
0313       if (iLayerME == LayerMEsMap.end()) {
0314         // get detids for the layer
0315         int32_t lnumber = det_layer_pair.second;
0316         std::vector<uint32_t> layerDetIds;
0317         if (det_layer_pair.first == "TIB") {
0318           SiStripSubStructure::getTIBDetectors(activeDets, layerDetIds, tTopo, lnumber, 0, 0, 0);
0319         } else if (det_layer_pair.first == "TOB") {
0320           SiStripSubStructure::getTOBDetectors(activeDets, layerDetIds, tTopo, lnumber, 0, 0);
0321         } else if (det_layer_pair.first == "TID" && lnumber > 0) {
0322           SiStripSubStructure::getTIDDetectors(activeDets, layerDetIds, tTopo, 2, std::abs(lnumber), 0, 0);
0323         } else if (det_layer_pair.first == "TID" && lnumber < 0) {
0324           SiStripSubStructure::getTIDDetectors(activeDets, layerDetIds, tTopo, 1, std::abs(lnumber), 0, 0);
0325         } else if (det_layer_pair.first == "TEC" && lnumber > 0) {
0326           SiStripSubStructure::getTECDetectors(activeDets, layerDetIds, tTopo, 2, std::abs(lnumber), 0, 0, 0, 0);
0327         } else if (det_layer_pair.first == "TEC" && lnumber < 0) {
0328           SiStripSubStructure::getTECDetectors(activeDets, layerDetIds, tTopo, 1, std::abs(lnumber), 0, 0, 0, 0);
0329         }
0330         LayerDetMap[label] = layerDetIds;
0331 
0332         // book Layer MEs
0333         folder_organizer.setLayerFolder(detid, tTopo, det_layer_pair.second);
0334         createLayerMEs(label, layerDetIds.size(), ibooker);
0335       }
0336       // book sub-detector plots
0337       auto sdet_pair = folder_organizer.getSubDetFolderAndTag(detid, tTopo);
0338       if (SubDetMEsMap.find(sdet_pair.second) == SubDetMEsMap.end()) {
0339         ibooker.setCurrentFolder(sdet_pair.first);
0340 
0341         createSubDetMEs(sdet_pair.second, ibooker);
0342       }
0343     }  // end of loop over detectors
0344 
0345     // Create Global Histogram
0346     if (globalswitchapvcycledbxth2on) {
0347       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0348       edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2ApvCycleVsDBxGlobal");
0349       std::string HistoName = "DeltaBx_vs_ApvCycle";
0350       GlobalApvCycleDBxTH2 = ibooker.book2D(HistoName,
0351                                             HistoName,
0352                                             GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
0353                                             GlobalTH2Parameters.getParameter<double>("xmin"),
0354                                             GlobalTH2Parameters.getParameter<double>("xmax"),
0355                                             GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
0356                                             GlobalTH2Parameters.getParameter<double>("ymin"),
0357                                             GlobalTH2Parameters.getParameter<double>("ymax"));
0358       GlobalApvCycleDBxTH2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)", 1);
0359       GlobalApvCycleDBxTH2->setAxisTitle("Delta Bunch Crossing Cycle", 2);
0360 
0361       // plot DeltaBX ***************************
0362       edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1DBxGlobal");
0363       HistoName = "DeltaBx";
0364       GlobalDBxTH1 = ibooker.book1D(HistoName,
0365                                     HistoName,
0366                                     GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
0367                                     GlobalTH1Parameters.getParameter<double>("xmin"),
0368                                     GlobalTH1Parameters.getParameter<double>("xmax"));
0369       GlobalDBxTH1->setAxisTitle("Delta Bunch Crossing", 1);
0370 
0371       // plot DeltaBXCycle ***************************
0372       edm::ParameterSet DBxCycle = conf_.getParameter<edm::ParameterSet>("TH1DBxCycleGlobal");
0373       HistoName = "DeltaBxCycle";
0374       GlobalDBxCycleTH1 = ibooker.book1D(HistoName,
0375                                          HistoName,
0376                                          DBxCycle.getParameter<int32_t>("Nbinsx"),
0377                                          DBxCycle.getParameter<double>("xmin"),
0378                                          DBxCycle.getParameter<double>("xmax"));
0379       GlobalDBxCycleTH1->setAxisTitle("Delta Bunch Crossing Cycle", 1);
0380     }
0381 
0382     if (globalswitchcstripvscpix) {
0383       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0384       edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2CStripVsCpixel");
0385       std::string HistoName = "StripClusVsPixClus";
0386       GlobalCStripVsCpix = ibooker.book2D(HistoName,
0387                                           HistoName,
0388                                           GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
0389                                           GlobalTH2Parameters.getParameter<double>("xmin"),
0390                                           GlobalTH2Parameters.getParameter<double>("xmax"),
0391                                           GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
0392                                           GlobalTH2Parameters.getParameter<double>("ymin"),
0393                                           GlobalTH2Parameters.getParameter<double>("ymax"));
0394       GlobalCStripVsCpix->setAxisTitle("Strip Clusters", 1);
0395       GlobalCStripVsCpix->setAxisTitle("Pix Clusters", 2);
0396 
0397       // Absolute Bunch Crossing ***********************
0398       edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1ABx_CSCP");
0399       HistoName = "AbsoluteBx_CStripVsCpixel";
0400       GlobalABXTH1_CSCP = ibooker.book1D(HistoName,
0401                                          HistoName,
0402                                          GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
0403                                          GlobalTH1Parameters.getParameter<double>("xmin"),
0404                                          GlobalTH1Parameters.getParameter<double>("xmax"));
0405       GlobalABXTH1_CSCP->setAxisTitle("Absolute Bunch Crossing", 1);
0406     }
0407 
0408     if (globalswitchMultiRegions) {
0409       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0410       edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH1MultiplicityRegions");
0411       std::string HistoName = "ClusterMultiplicityRegions";
0412       PixVsStripMultiplicityRegions = ibooker.book1D(HistoName,
0413                                                      HistoName,
0414                                                      GlobalTH2Parameters.getParameter<int32_t>("Nbinx"),
0415                                                      GlobalTH2Parameters.getParameter<double>("xmin"),
0416                                                      GlobalTH2Parameters.getParameter<double>("xmax"));
0417       PixVsStripMultiplicityRegions->setAxisTitle("");
0418       PixVsStripMultiplicityRegions->setBinLabel(1, "Main Diagonal");
0419       PixVsStripMultiplicityRegions->setBinLabel(2, "Strip Noise");
0420       PixVsStripMultiplicityRegions->setBinLabel(3, "High Strip Noise");
0421       PixVsStripMultiplicityRegions->setBinLabel(4, "Beam Background");
0422       PixVsStripMultiplicityRegions->setBinLabel(5, "No Strip Clusters");
0423     }
0424 
0425     if (globalswitchmaindiagonalposition) {
0426       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0427       edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1MainDiagonalPosition");
0428       std::string HistoName = "MainDiagonal Position";
0429       GlobalMainDiagonalPosition = ibooker.book1D(HistoName,
0430                                                   HistoName,
0431                                                   GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
0432                                                   GlobalTH1Parameters.getParameter<double>("xmin"),
0433                                                   GlobalTH1Parameters.getParameter<double>("xmax"));
0434       GlobalMainDiagonalPosition->setAxisTitle("atan(NPix/(k*NStrip))");
0435 
0436       // PLOT MainDiagonalPosition_vs_BX ***************************
0437       edm::ParameterSet GlobalTProfParameters = conf_.getParameter<edm::ParameterSet>("TProfMainDiagonalPosition");
0438       HistoName = "MainDiagonalPosition_vs_BX";
0439       GlobalMainDiagonalPosition_vs_BX = ibooker.bookProfile(HistoName,
0440                                                              HistoName,
0441                                                              GlobalTProfParameters.getParameter<int32_t>("Nbinsx"),
0442                                                              GlobalTProfParameters.getParameter<double>("xmin"),
0443                                                              GlobalTProfParameters.getParameter<double>("xmax"),
0444                                                              GlobalTProfParameters.getParameter<int32_t>("Nbinsy"),
0445                                                              GlobalTProfParameters.getParameter<double>("ymin"),
0446                                                              GlobalTProfParameters.getParameter<double>("ymax"));
0447 
0448       GlobalMainDiagonalPosition_vs_BX->setAxisTitle("Absolute BX", 1);
0449       GlobalMainDiagonalPosition_vs_BX->setAxisTitle("tan^{-1}(NPix/k*NStrip))", 2);
0450 
0451       edm::ParameterSet GlobalTH2Parameters = conf_.getParameter<edm::ParameterSet>("TH2MainDiagonalPosition");
0452       HistoName = "TH2MainDiagonalPosition_vs_BX";
0453       GlobalTH2MainDiagonalPosition_vs_BX = ibooker.book2D(HistoName,
0454                                                            HistoName,
0455                                                            GlobalTH2Parameters.getParameter<int32_t>("Nbinsx"),
0456                                                            GlobalTH2Parameters.getParameter<double>("xmin"),
0457                                                            GlobalTH2Parameters.getParameter<double>("xmax"),
0458                                                            GlobalTH2Parameters.getParameter<int32_t>("Nbinsy"),
0459                                                            GlobalTH2Parameters.getParameter<double>("ymin"),
0460                                                            GlobalTH2Parameters.getParameter<double>("ymax"));
0461       GlobalTH2MainDiagonalPosition_vs_BX->setAxisTitle("Absolute BX", 1);
0462       GlobalTH2MainDiagonalPosition_vs_BX->setAxisTitle("tan^{-1}(NPix/k*NStrip))", 2);
0463     }
0464 
0465     // TO BE ADDED !!!
0466     /*
0467     if ( globalswitchapvcycledbxth2on or globalswitchcstripvscpix or
0468     globalswitchMultiRegions or ClusterHisto_ ) {
0469     ibooker.setCurrentFolder(topFolderName_+"/MechanicalView/");
0470       std::string HistoName = "BPTX rate";
0471       BPTXrateTrend = ibooker.bookProfile(HistoName,HistoName, LSBin, LSMin,
0472     LSMax, 0, 10000.,""); BPTXrateTrend->getTH1()->SetCanExtend(TH1::kAllAxes);
0473       BPTXrateTrend->setAxisTitle("#Lumi section",1);
0474       BPTXrateTrend->setAxisTitle("Number of BPTX events per LS",2);
0475     }
0476     */
0477 
0478     if (globalswitchstripnoise2apvcycle) {
0479       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0480       edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise2ApvCycle");
0481       std::string HistoName = "StripNoise_ApvCycle";
0482       StripNoise2Cycle = ibooker.book1D(HistoName,
0483                                         HistoName,
0484                                         GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
0485                                         GlobalTH1Parameters.getParameter<double>("xmin"),
0486                                         GlobalTH1Parameters.getParameter<double>("xmax"));
0487       StripNoise2Cycle->setAxisTitle("APV Cycle");
0488     }
0489 
0490     if (globalswitchstripnoise3apvcycle) {
0491       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0492       edm::ParameterSet GlobalTH1Parameters = conf_.getParameter<edm::ParameterSet>("TH1StripNoise3ApvCycle");
0493       std::string HistoName = "HighStripNoise_ApvCycle";
0494       StripNoise3Cycle = ibooker.book1D(HistoName,
0495                                         HistoName,
0496                                         GlobalTH1Parameters.getParameter<int32_t>("Nbinsx"),
0497                                         GlobalTH1Parameters.getParameter<double>("xmin"),
0498                                         GlobalTH1Parameters.getParameter<double>("xmax"));
0499       StripNoise3Cycle->setAxisTitle("APV Cycle");
0500     }
0501 
0502     if (globalswitchnclusvscycletimeprof2don) {
0503       const char* HistoName = "StripClusVsBXandOrbit";
0504       const char* HistoTitle =
0505           "Strip cluster multiplicity vs BX mod(70) and Orbit;Event 1 BX "
0506           "mod(70);time [Orb#]";
0507       edm::ParameterSet ParametersNclusVsCycleTimeProf2D =
0508           conf_.getParameter<edm::ParameterSet>("NclusVsCycleTimeProf2D");
0509       NclusVsCycleTimeProf2D = ibooker.bookProfile2D(HistoName,
0510                                                      HistoTitle,
0511                                                      ParametersNclusVsCycleTimeProf2D.getParameter<int32_t>("Nbins"),
0512                                                      ParametersNclusVsCycleTimeProf2D.getParameter<double>("xmin"),
0513                                                      ParametersNclusVsCycleTimeProf2D.getParameter<double>("xmax"),
0514                                                      ParametersNclusVsCycleTimeProf2D.getParameter<int32_t>("Nbinsy"),
0515                                                      ParametersNclusVsCycleTimeProf2D.getParameter<double>("ymin"),
0516                                                      ParametersNclusVsCycleTimeProf2D.getParameter<double>("ymax"),
0517                                                      0,
0518                                                      0);
0519       if (NclusVsCycleTimeProf2D->kind() == MonitorElement::Kind::TPROFILE2D)
0520         NclusVsCycleTimeProf2D->setCanExtend(TH1::kAllAxes);
0521     }
0522     if (clusterWidth_vs_amplitude_on) {
0523       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0524       edm::ParameterSet ParametersClusWidthVsAmpTH2 = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
0525       const char* HistoName = "ClusterWidths_vs_Amplitudes";
0526       const char* HistoTitle =
0527           "Cluster widths vs amplitudes;Amplitudes (integrated ADC "
0528           "counts);Cluster widths";
0529       ClusWidthVsAmpTH2 = ibooker.book2D(HistoName,
0530                                          HistoTitle,
0531                                          ParametersClusWidthVsAmpTH2.getParameter<int32_t>("Nbinsx"),
0532                                          ParametersClusWidthVsAmpTH2.getParameter<double>("xmin"),
0533                                          ParametersClusWidthVsAmpTH2.getParameter<double>("xmax"),
0534                                          ParametersClusWidthVsAmpTH2.getParameter<int32_t>("Nbinsy"),
0535                                          ParametersClusWidthVsAmpTH2.getParameter<double>("ymin"),
0536                                          ParametersClusWidthVsAmpTH2.getParameter<double>("ymax"));
0537     }
0538 
0539     if (ClusterHisto_) {
0540       ibooker.setCurrentFolder(topFolderName_ + "/MechanicalView/");
0541       edm::ParameterSet PixelCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusPx");
0542       std::string HistoName = "NumberOfClustersInPixel";
0543       NumberOfPixelClus = ibooker.book1D(HistoName,
0544                                          HistoName,
0545                                          PixelCluster.getParameter<int32_t>("Nbinsx"),
0546                                          PixelCluster.getParameter<double>("xmin"),
0547                                          PixelCluster.getParameter<double>("xmax"));
0548       NumberOfPixelClus->setAxisTitle("# of Clusters in Pixel", 1);
0549       NumberOfPixelClus->setAxisTitle("Number of Events", 2);
0550       //
0551       edm::ParameterSet StripCluster = conf_.getParameter<edm::ParameterSet>("TH1NClusStrip");
0552       HistoName = "NumberOfClustersInStrip";
0553       NumberOfStripClus = ibooker.book1D(HistoName,
0554                                          HistoName,
0555                                          StripCluster.getParameter<int32_t>("Nbinsx"),
0556                                          StripCluster.getParameter<double>("xmin"),
0557                                          StripCluster.getParameter<double>("xmax"));
0558       NumberOfStripClus->setAxisTitle("# of Clusters in Strip", 1);
0559       NumberOfStripClus->setAxisTitle("Number of Events", 2);
0560 
0561       // NumberOfClustersinStrip vs BX PLOT ****************************
0562       edm::ParameterSet StripClusterBX = conf_.getParameter<edm::ParameterSet>("TProfNClusStrip");
0563       HistoName = "NumberOfClustersInStrip_vs_BX";
0564       NumberOfStripClus_vs_BX = ibooker.bookProfile(HistoName,
0565                                                     HistoName,
0566                                                     StripClusterBX.getParameter<int32_t>("Nbinsx"),
0567                                                     StripClusterBX.getParameter<double>("xmin"),
0568                                                     StripClusterBX.getParameter<double>("xmax"),
0569                                                     StripClusterBX.getParameter<int32_t>("Nbinsy"),
0570                                                     StripClusterBX.getParameter<double>("ymin"),
0571                                                     StripClusterBX.getParameter<double>("ymax"));
0572 
0573       NumberOfStripClus_vs_BX->setAxisTitle("Absolute BX", 1);
0574       NumberOfStripClus_vs_BX->setAxisTitle("# of Clusters in Strip", 2);
0575 
0576       // NumberOfClustersinStrip vs BX PLOT ****************************
0577       edm::ParameterSet PixelClusterBX = conf_.getParameter<edm::ParameterSet>("TProfNClusPixel");
0578       HistoName = "NumberOfClustersInPixel_vs_BX";
0579       NumberOfPixelClus_vs_BX = ibooker.bookProfile(HistoName,
0580                                                     HistoName,
0581                                                     PixelClusterBX.getParameter<int32_t>("Nbinsx"),
0582                                                     PixelClusterBX.getParameter<double>("xmin"),
0583                                                     PixelClusterBX.getParameter<double>("xmax"),
0584                                                     PixelClusterBX.getParameter<int32_t>("Nbinsy"),
0585                                                     PixelClusterBX.getParameter<double>("ymin"),
0586                                                     PixelClusterBX.getParameter<double>("ymax"));
0587 
0588       NumberOfPixelClus_vs_BX->setAxisTitle("Absolute BX", 1);
0589       NumberOfPixelClus_vs_BX->setAxisTitle("# of Clusters in Pixel", 2);
0590 
0591       if (globalswitchFEDCluster) {
0592         // Number of clusters per FED
0593         edm::ParameterSet FEDCluster = conf_.getParameter<edm::ParameterSet>("TProfNClustersFED");
0594         HistoName = "NumberOfClustersinFED_v_FEDID";
0595         NumberOfFEDClus = ibooker.bookProfile(HistoName,
0596                                               HistoName,
0597                                               FEDCluster.getParameter<int32_t>("Nbinsx"),
0598                                               FEDCluster.getParameter<double>("xmin"),
0599                                               FEDCluster.getParameter<double>("xmax"),
0600                                               FEDCluster.getParameter<int32_t>("Nbinsy"),
0601                                               FEDCluster.getParameter<double>("ymin"),
0602                                               FEDCluster.getParameter<double>("ymax"),
0603                                               "");
0604         NumberOfFEDClus->setAxisTitle("FED ID", 1);
0605         NumberOfFEDClus->setAxisTitle("Mean # of Cluster in FED", 2);
0606       }
0607     }
0608 
0609   }  // end of if
0610 }  // end of method
0611 
0612 //--------------------------------------------------------------------------------------------
0613 
0614 void SiStripMonitorCluster::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& es) {
0615   if (show_mechanical_structure_view) {
0616     unsigned long long cacheID = es.get<SiStripDetCablingRcd>().cacheIdentifier();
0617     if (m_cacheID_ != cacheID) {
0618       m_cacheID_ = cacheID;
0619       edm::LogInfo("SiStripMonitorCluster") << "SiStripMonitorCluster::bookHistograms: "
0620                                             << " Creating MEs for new Cabling ";
0621 
0622       createMEs(es, ibooker);
0623     }
0624   } else if (reset_each_run) {
0625     edm::LogInfo("SiStripMonitorCluster") << "SiStripMonitorCluster::bookHistograms: "
0626                                           << " Resetting MEs ";
0627     for (std::map<uint32_t, ModMEs>::const_iterator idet = ModuleMEsMap.begin(); idet != ModuleMEsMap.end(); idet++) {
0628       ResetModuleMEs(idet->first);
0629     }
0630   }
0631 }
0632 
0633 //--------------------------------------------------------------------------------------------
0634 void SiStripMonitorCluster::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0635   // Retrieve tracker topology from geometry
0636   const TrackerTopology* const tTopo = &iSetup.getData(trackerTopologyEventToken_);
0637 
0638   // Filter out events if Trigger Filtering is requested
0639   passBPTXfilter_ = (iEvent.isRealData() and genTriggerEventFlagBPTXfilter_->on())
0640                         ? genTriggerEventFlagBPTXfilter_->accept(iEvent, iSetup)
0641                         : true;
0642   passPixelDCSfilter_ = (iEvent.isRealData() and genTriggerEventFlagPixelDCSfilter_->on())
0643                             ? genTriggerEventFlagPixelDCSfilter_->accept(iEvent, iSetup)
0644                             : true;
0645   passStripDCSfilter_ = (iEvent.isRealData() and genTriggerEventFlagStripDCSfilter_->on())
0646                             ? genTriggerEventFlagStripDCSfilter_->accept(iEvent, iSetup)
0647                             : true;
0648   //  std::cout << "passBPTXfilter_ ? " << passBPTXfilter_ << std::endl;
0649 
0650   // Filter out events if DCS Event if requested
0651   bool passDCSFilter_ = !(dcsStatus_ && !dcsStatus_->getStatus(iEvent, iSetup));
0652 
0653   runNb = iEvent.id().run();
0654   eventNb++;
0655 
0656   if (!iEvent.isRealData()) {
0657     trendVar = trendVs10Ls_ ? iEvent.eventAuxiliary().luminosityBlock() / 10.f
0658                             : iEvent.eventAuxiliary().luminosityBlock();  // 10 lumisection : lumisection
0659 
0660   } else {
0661     trendVar = trendVs10Ls_ ? iEvent.orbitNumber() / (10 * 262144.0)
0662                             : iEvent.orbitNumber() / (1 * 262144.0);  // 10 lumisection : lumisection
0663   }
0664 
0665   int NPixClusters = 0, NStripClusters = 0, MultiplicityRegion = 0;
0666   bool isPixValid = false;
0667 
0668   const SiStripNoises& siStripNoises = iSetup.getData(siStripNoisesToken_);
0669   const SiStripGain& siStripGain = iSetup.getData(siStripGainToken_);
0670   const SiStripQuality& siStripQuality = iSetup.getData(siStripQualityToken_);
0671   const SiStripDetCabling& siStripDetCabling = iSetup.getData(siStripDetCablingEventToken_);
0672 
0673   // get collection of DetSetVector of clusters from Event
0674   edm::Handle<edmNew::DetSetVector<SiStripCluster> > cluster_detsetvektor;
0675   iEvent.getByToken(clusterProducerStripToken_, cluster_detsetvektor);
0676 
0677   // get pixel clusters
0678   edm::Handle<edmNew::DetSetVector<SiPixelCluster> > cluster_detsetvektor_pix;
0679   iEvent.getByToken(clusterProducerPixToken_, cluster_detsetvektor_pix);
0680 
0681   if (!cluster_detsetvektor.isValid())
0682     return;
0683 
0684   const edmNew::DetSetVector<SiStripCluster>* StrC = cluster_detsetvektor.product();
0685   NStripClusters = StrC->data().size();
0686 
0687   if (cluster_detsetvektor_pix.isValid()) {
0688     const edmNew::DetSetVector<SiPixelCluster>* PixC = cluster_detsetvektor_pix.product();
0689     NPixClusters = PixC->data().size();
0690     isPixValid = true;
0691     MultiplicityRegion = FindRegion(NStripClusters, NPixClusters);
0692 
0693     if (passBPTXfilter_ and passPixelDCSfilter_ and passStripDCSfilter_ and passDCSFilter_) {
0694       if (globalswitchcstripvscpix)
0695         GlobalCStripVsCpix->Fill(NStripClusters, NPixClusters);
0696       if (globalswitchmaindiagonalposition && NStripClusters > 0)
0697         GlobalMainDiagonalPosition->Fill(atan(NPixClusters / (k0 * NStripClusters)));
0698 
0699       if (globalswitchMultiRegions)
0700         PixVsStripMultiplicityRegions->Fill(MultiplicityRegion);
0701     }
0702 
0703     if (ClusterHisto_ and passDCSFilter_) {
0704       if (passBPTXfilter_ and passPixelDCSfilter_)
0705         NumberOfPixelClus->Fill(NPixClusters);
0706       if (passBPTXfilter_ and passStripDCSfilter_)
0707         NumberOfStripClus->Fill(NStripClusters);
0708     }
0709   }
0710   // initialise # of clusters to zero
0711   for (std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.begin(); iSubdet != SubDetMEsMap.end();
0712        iSubdet++) {
0713     iSubdet->second.totNClusters = 0;
0714   }
0715 
0716   SiStripFolderOrganizer folder_organizer;
0717   bool found_layer_me = false;
0718   // Map of cumulative clusters per fed ID.
0719   std::map<int, int> FEDID_v_clustersum;
0720 
0721   for (std::map<std::string, std::vector<uint32_t> >::const_iterator iterLayer = LayerDetMap.begin();
0722        iterLayer != LayerDetMap.end();
0723        iterLayer++) {
0724     std::string layer_label = iterLayer->first;
0725 
0726     int ncluster_layer = 0;
0727     std::map<std::string, LayerMEs>::iterator iLayerME = LayerMEsMap.find(layer_label);
0728 
0729     // get Layer MEs
0730     LayerMEs layer_single;
0731     if (iLayerME != LayerMEsMap.end()) {
0732       layer_single = iLayerME->second;
0733       found_layer_me = true;
0734     }
0735 
0736     int ncluster_ring[20] = {0};
0737 
0738     bool found_module_me = false;
0739     uint16_t iDet = 0;
0740     std::string subdet_label = "";
0741     // loop over all modules in the layer
0742     for (std::vector<uint32_t>::const_iterator iterDets = iterLayer->second.begin();
0743          iterDets != iterLayer->second.end();
0744          iterDets++) {
0745       iDet++;
0746       // detid and type of ME
0747       uint32_t detid = (*iterDets);
0748 
0749       // Get SubDet label once
0750       if (subdet_label.empty())
0751         subdet_label = folder_organizer.getSubDetFolderAndTag(detid, tTopo).second;
0752 
0753       // DetId and corresponding set of MEs
0754       ModMEs mod_single;
0755       if (Mod_On_) {
0756         std::map<uint32_t, ModMEs>::iterator imodME = ModuleMEsMap.find(detid);
0757         if (imodME != ModuleMEsMap.end()) {
0758           mod_single = imodME->second;
0759           found_module_me = true;
0760         }
0761       } else
0762         found_module_me = false;
0763 
0764       edmNew::DetSetVector<SiStripCluster>::const_iterator isearch =
0765           cluster_detsetvektor->find(detid);  // search  clusters of detid
0766 
0767       if (isearch == cluster_detsetvektor->end() and passDCSFilter_) {
0768         if (found_module_me && moduleswitchncluson && (mod_single.NumberOfClusters)) {
0769           (mod_single.NumberOfClusters)->Fill(0.);  // no clusters for this
0770                                                     // detector module,fill
0771                                                     // histogram with 0
0772         }
0773         if (clustertkhistomapon)
0774           tkmapcluster->fill(detid, 0.);
0775         if (clusterchtkhistomapon)
0776           tkmapclusterch->fill(detid, 0.);
0777         if (found_layer_me && layerswitchnumclusterprofon)
0778           layer_single.LayerNumberOfClusterProfile->Fill(iDet, 0.0);
0779       }
0780 
0781       if (isearch == cluster_detsetvektor->end()) {
0782         continue;  // no clusters for this detid => jump to next step of loop
0783       }
0784 
0785       // cluster_detset is a structure, cluster_detset.data is a
0786       // std::vector<SiStripCluster>, cluster_detset.id is uint32_t
0787       // edmNew::DetSet<SiStripCluster> cluster_detset =
0788       // (*cluster_detsetvektor)[detid]; // the statement above makes sure there
0789       // exists an element with 'detid'
0790       edmNew::DetSet<SiStripCluster> cluster_detset = (*isearch);
0791 
0792       //////////////////////////////////////////////////////////////
0793       // Get all FED connections associated with given detID.
0794       // All connections for a detid have same FED Id therefore one FEDID is
0795       // associated with a given detID. Vector of constant FedChannelConnection
0796       // objects to variable pointers.
0797       std::vector<const FedChannelConnection*> fedConnections = siStripDetCabling.getConnections(detid);
0798 
0799       // Filling FED Id associated clusters map.
0800 
0801       int good_fcc_index = -999;
0802       for (unsigned int x = 0; x < fedConnections.size(); x++) {
0803         if (fedConnections[x] != nullptr) {
0804           good_fcc_index = x;
0805           break;
0806         }
0807       }
0808       if (good_fcc_index != -999 && fedConnections[good_fcc_index] != nullptr) {
0809         int temp_fedid = fedConnections[good_fcc_index]->fedId();
0810         if (FEDID_v_clustersum.find(temp_fedid) != FEDID_v_clustersum.end()) {
0811           if (cluster_detset.size() < 1000 && !cluster_detset.empty()) {
0812             FEDID_v_clustersum[temp_fedid] = FEDID_v_clustersum.find(temp_fedid)->second + cluster_detset.size();
0813           }
0814         } else {
0815           if (cluster_detset.size() < 1000 && !cluster_detset.empty()) {
0816             FEDID_v_clustersum[temp_fedid] = cluster_detset.size();
0817           }
0818         }
0819       } else {
0820         edm::LogInfo("SiStripMonitorCluster") << "SiStripMonitorCluster::analyze WARNING! no good connections "
0821                                                  "for detid = "
0822                                               << detid << endl;
0823       }
0824       //////////////////////////////////////////////////////////////
0825 
0826       // Filling TkHistoMap with number of clusters for each module
0827       if (clustertkhistomapon and passDCSFilter_) {
0828         tkmapcluster->fill(detid, static_cast<float>(cluster_detset.size()));
0829       }
0830 
0831       if (moduleswitchncluson && found_module_me && (mod_single.NumberOfClusters != nullptr) &&
0832           passDCSFilter_) {  // nr. of clusters per module
0833         (mod_single.NumberOfClusters)->Fill(static_cast<float>(cluster_detset.size()));
0834       }
0835 
0836       if (found_layer_me && layerswitchnumclusterprofon && passDCSFilter_)
0837         layer_single.LayerNumberOfClusterProfile->Fill(iDet, static_cast<float>(cluster_detset.size()));
0838       ncluster_layer += cluster_detset.size();
0839 
0840       short total_clusterized_strips = 0;
0841 
0842       SiStripNoises::Range detNoiseRange = siStripNoises.getRange(detid);
0843       SiStripApvGain::Range detGainRange = siStripGain.getRange(detid);
0844       SiStripQuality::Range qualityRange = siStripQuality.getRange(detid);
0845 
0846       for (edmNew::DetSet<SiStripCluster>::const_iterator clusterIter = cluster_detset.begin();
0847            clusterIter != cluster_detset.end();
0848            clusterIter++) {
0849         const auto& ampls = clusterIter->amplitudes();
0850         // cluster position
0851         float cluster_position = clusterIter->barycenter();
0852         // start defined as nr. of first strip beloning to the cluster
0853         short cluster_start = clusterIter->firstStrip();
0854         // width defined as nr. of strips that belong to cluster
0855         short cluster_width = ampls.size();
0856         // add nr of strips of this cluster to total nr. of clusterized strips
0857         total_clusterized_strips = total_clusterized_strips + cluster_width;
0858 
0859         if (clusterchtkhistomapon and passDCSFilter_)
0860           tkmapclusterch->fill(detid, static_cast<float>(clusterIter->charge()));
0861 
0862         // cluster signal and noise from the amplitudes
0863         float cluster_signal = 0.0;
0864         float cluster_noise = 0.0;
0865         int nrnonzeroamplitudes = 0;
0866         float noise2 = 0.0;
0867         float noise = 0.0;
0868         for (uint iamp = 0; iamp < ampls.size(); iamp++) {
0869           if (ampls[iamp] > 0) {  // nonzero amplitude
0870             cluster_signal += ampls[iamp];
0871             if (!siStripQuality.IsStripBad(qualityRange, clusterIter->firstStrip() + iamp)) {
0872               noise = siStripNoises.getNoise(clusterIter->firstStrip() + iamp, detNoiseRange) /
0873                       siStripGain.getStripGain(clusterIter->firstStrip() + iamp, detGainRange);
0874             }
0875             noise2 += noise * noise;
0876             nrnonzeroamplitudes++;
0877           }
0878         }  // End loop over cluster amplitude
0879 
0880         if (nrnonzeroamplitudes > 0)
0881           cluster_noise = sqrt(noise2 / nrnonzeroamplitudes);
0882 
0883         if (applyClusterQuality_ &&
0884             (cluster_signal / cluster_noise < sToNLowerLimit_ || cluster_signal / cluster_noise > sToNUpperLimit_ ||
0885              cluster_width < widthLowerLimit_ || cluster_width > widthUpperLimit_))
0886           continue;
0887 
0888         ClusterProperties cluster_properties;
0889         cluster_properties.charge = cluster_signal;
0890         cluster_properties.position = cluster_position;
0891         cluster_properties.start = cluster_start;
0892         cluster_properties.width = cluster_width;
0893         cluster_properties.noise = cluster_noise;
0894 
0895         // Fill Module Level MEs
0896         if (found_module_me and passDCSFilter_)
0897           fillModuleMEs(mod_single, cluster_properties);
0898 
0899         // Fill Layer Level MEs
0900         if (found_layer_me and passDCSFilter_) {
0901           fillLayerMEs(layer_single, cluster_properties);
0902           if (layerswitchclusterwidthprofon)
0903             layer_single.LayerClusterWidthProfile->Fill(iDet, cluster_width);
0904         }
0905 
0906         if (subdetswitchcluschargeon || subdetswitchcluswidthon) {
0907           std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
0908           if (iSubdet != SubDetMEsMap.end()) {
0909             if (subdetswitchcluschargeon and passDCSFilter_)
0910               iSubdet->second.SubDetClusterChargeTH1->Fill(cluster_signal);
0911             if (subdetswitchcluswidthon and passDCSFilter_)
0912               iSubdet->second.SubDetClusterWidthTH1->Fill(cluster_width);
0913           }
0914         }
0915 
0916         if (subdet_clusterWidth_vs_amplitude_on and passDCSFilter_) {
0917           std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
0918           if (iSubdet != SubDetMEsMap.end())
0919             iSubdet->second.SubDetClusWidthVsAmpTH2->Fill(cluster_signal, cluster_width);
0920         }
0921 
0922         if (clusterWidth_vs_amplitude_on and passDCSFilter_) {
0923           ClusWidthVsAmpTH2->Fill(cluster_signal, cluster_width);
0924         }
0925 
0926         if (subdetswitchtotclusprofon &&
0927             (subdet_label.find("TID") != std::string::npos || subdet_label.find("TEC") != std::string::npos)) {
0928           std::pair<std::string, int32_t> det_ring_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo, true);
0929           ncluster_ring[std::abs(det_ring_pair.second)]++;
0930         }
0931 
0932       }  // end loop over clusters
0933 
0934       if (subdetswitchtotclusprofon) {
0935         std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
0936         std::pair<std::string, int32_t> det_layer_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo);
0937         iSubdet->second.SubDetNumberOfClusterPerLayerTrend->Fill(
0938             trendVar, std::abs(det_layer_pair.second), ncluster_layer);
0939       }
0940 
0941       if (subdetswitchtotclusprofon &&
0942           (subdet_label.find("TID") != std::string::npos || subdet_label.find("TEC") != std::string::npos)) {
0943         std::pair<std::string, int32_t> det_ring_pair = folder_organizer.GetSubDetAndLayer(detid, tTopo, true);
0944         layer_single.LayerNumberOfClusterPerRingTrend->Fill(
0945             trendVar, std::abs(det_ring_pair.second), ncluster_ring[std::abs(det_ring_pair.second)]);
0946       }
0947 
0948       short total_nr_strips = siStripDetCabling.nApvPairs(detid) * 2 * 128;  // get correct # of avp pairs
0949       float local_occupancy = static_cast<float>(total_clusterized_strips) / static_cast<float>(total_nr_strips);
0950       if (found_module_me and passDCSFilter_) {
0951         if (moduleswitchnrclusterizedstrip && mod_single.NrOfClusterizedStrips) {  // nr of clusterized strips
0952           mod_single.NrOfClusterizedStrips->Fill(static_cast<float>(total_clusterized_strips));
0953         }
0954 
0955         if (moduleswitchlocaloccupancy && mod_single.ModuleLocalOccupancy) {  // Occupancy
0956           mod_single.ModuleLocalOccupancy->Fill(local_occupancy);
0957         }
0958       }
0959       if (layerswitchlocaloccupancy && found_layer_me && layer_single.LayerLocalOccupancy && passDCSFilter_) {
0960         fillME(layer_single.LayerLocalOccupancy, local_occupancy);
0961         if (createTrendMEs)
0962           fillME(layer_single.LayerLocalOccupancyTrend, trendVar, local_occupancy);
0963       }
0964     }
0965 
0966     if (subdetswitchtotclusprofon)
0967       fillME(layer_single.LayerNumberOfClusterTrend, trendVar, ncluster_layer);
0968 
0969     std::map<std::string, SubDetMEs>::iterator iSubdet = SubDetMEsMap.find(subdet_label);
0970     if (iSubdet != SubDetMEsMap.end())
0971       iSubdet->second.totNClusters += ncluster_layer;
0972   }  /// end of layer loop
0973 
0974   //  EventHistory
0975   edm::Handle<EventWithHistory> event_history;
0976   iEvent.getByToken(historyProducerToken_, event_history);
0977 
0978   // Phase of APV
0979   edm::Handle<APVCyclePhaseCollection> apv_phase_collection;
0980   iEvent.getByToken(apvPhaseProducerToken_, apv_phase_collection);
0981 
0982   if (event_history.isValid() && !event_history.failedToGet() && apv_phase_collection.isValid() &&
0983       !apv_phase_collection.failedToGet()) {
0984     long long dbx = event_history->deltaBX();
0985     long long tbx = event_history->absoluteBX();
0986 
0987     bool global_histo_filled = false;
0988     bool MultiplicityRegion_Vs_APVcycle_filled = false;
0989 
0990     // plot n 2
0991     if (passBPTXfilter_ and passPixelDCSfilter_ and passStripDCSfilter_ && passDCSFilter_) {
0992       if (globalswitchcstripvscpix)
0993         GlobalABXTH1_CSCP->Fill(tbx % 3564);
0994     }
0995     // plot n 2
0996 
0997     for (std::map<std::string, SubDetMEs>::iterator it = SubDetMEsMap.begin(); it != SubDetMEsMap.end(); it++) {
0998       std::string sdet = it->first;
0999       // std::string sdet = sdet_tag.substr(0,sdet_tag.find_first_of("_"));
1000       SubDetMEs sdetmes = it->second;
1001 
1002       int the_phase = APVCyclePhaseCollection::invalid;
1003       long long tbx_corr = tbx;
1004 
1005       if (SubDetPhasePartMap.find(sdet) != SubDetPhasePartMap.end())
1006         the_phase = apv_phase_collection->getPhase(SubDetPhasePartMap[sdet]);
1007       if (the_phase == APVCyclePhaseCollection::nopartition || the_phase == APVCyclePhaseCollection::multiphase ||
1008           the_phase == APVCyclePhaseCollection::invalid) {
1009         the_phase = 30;
1010         // std::cout << " subdet " << it->first << " not valid" << " MR " <<
1011         // MultiplicityRegion <<std::endl;
1012       }
1013       tbx_corr -= the_phase;
1014 
1015       long long dbxincycle = event_history->deltaBXinCycle(the_phase);
1016       // std::cout<<"dbx in cycle: " << dbxincycle << std::endl;
1017       if (globalswitchapvcycledbxth2on && !global_histo_filled && passDCSFilter_) {
1018         GlobalApvCycleDBxTH2->Fill(tbx_corr % 70, dbx);
1019         GlobalDBxTH1->Fill(dbx);
1020         GlobalDBxCycleTH1->Fill(dbxincycle);
1021         global_histo_filled = true;
1022       }
1023 
1024       // Fill MainDiagonalPosition plots ***************
1025       if (cluster_detsetvektor_pix.isValid()) {
1026         if (ClusterHisto_) {
1027           if (passBPTXfilter_ and passStripDCSfilter_ and passDCSFilter_) {
1028             NumberOfStripClus_vs_BX->Fill(tbx % 3564, NStripClusters);
1029             if (passPixelDCSfilter_) {
1030               NumberOfPixelClus_vs_BX->Fill(tbx % 3564, NPixClusters);
1031               if (globalswitchmaindiagonalposition && NStripClusters > 0) {
1032                 GlobalMainDiagonalPosition_vs_BX->Fill(tbx % 3564, atan(NPixClusters / (k0 * NStripClusters)));
1033                 GlobalTH2MainDiagonalPosition_vs_BX->Fill(tbx % 3564, atan(NPixClusters / (k0 * NStripClusters)));
1034               }
1035             }
1036           }
1037 
1038           // Filling # clusters per FED ID histogram from FED Id clusters map
1039           // (for all layers simultaneously).
1040           map<int, int>::iterator it;
1041           // for(it=FEDID_v_clustersum.begin(); it!=FEDID_v_clustersum.end();
1042           // it++){
1043           for (auto const& fedidEntry : FEDID_v_clustersum) {
1044             // NumberOfFEDClus->Fill(it->first,it->second);
1045             if (passDCSFilter_)
1046               NumberOfFEDClus->Fill(fedidEntry.first, fedidEntry.second);
1047             // if(it->first < 100){
1048             //  Trend_NumberOfFEDClus->Fill(trendVar,it->first,it->second);
1049             //}
1050           }
1051           FEDID_v_clustersum.clear();
1052         }
1053       }
1054 
1055       if (isPixValid && !MultiplicityRegion_Vs_APVcycle_filled && passDCSFilter_) {
1056         if (globalswitchstripnoise2apvcycle && MultiplicityRegion == 2) {
1057           StripNoise2Cycle->Fill(tbx_corr % 70);
1058         }
1059         if (globalswitchstripnoise3apvcycle && MultiplicityRegion == 3) {
1060           StripNoise3Cycle->Fill(tbx_corr % 70);
1061         }
1062         MultiplicityRegion_Vs_APVcycle_filled = true;
1063       }
1064 
1065       if (subdetswitchtotclusth1on and passDCSFilter_)
1066         sdetmes.SubDetTotClusterTH1->Fill(sdetmes.totNClusters);
1067       if (subdetswitchtotclusprofon)
1068         sdetmes.SubDetTotClusterProf->Fill(trendVar, sdetmes.totNClusters);
1069       if (subdetswitchapvcycleprofon and passDCSFilter_)
1070         sdetmes.SubDetClusterApvProf->Fill(tbx_corr % 70, sdetmes.totNClusters);
1071       if (subdetswitchapvcycleth2on and passDCSFilter_)
1072         sdetmes.SubDetClusterApvTH2->Fill(tbx_corr % 70, sdetmes.totNClusters);
1073       if (subdetswitchdbxcycleprofon and passDCSFilter_) {
1074         sdetmes.SubDetClusterDBxCycleProf->Fill(dbxincycle, sdetmes.totNClusters);
1075       }
1076       if (subdetswitchapvcycledbxprof2on and passDCSFilter_)
1077         sdetmes.SubDetApvDBxProf2->Fill(tbx_corr % 70, dbx, sdetmes.totNClusters);
1078     }
1079 
1080     if (globalswitchnclusvscycletimeprof2don and passDCSFilter_) {
1081       long long tbx_corr = tbx;
1082       int the_phase = apv_phase_collection->getPhase("All");
1083 
1084       if (the_phase == APVCyclePhaseCollection::nopartition || the_phase == APVCyclePhaseCollection::multiphase ||
1085           the_phase == APVCyclePhaseCollection::invalid)
1086         the_phase = 30;
1087 
1088       tbx_corr -= the_phase;
1089 
1090       NclusVsCycleTimeProf2D->Fill(tbx_corr % 70, (int)event_history->_orbit, NStripClusters);
1091     }
1092   }
1093 }
1094 //
1095 // -- Reset MEs
1096 //------------------------------------------------------------------------------
1097 void SiStripMonitorCluster::ResetModuleMEs(uint32_t idet) {
1098   std::map<uint32_t, ModMEs>::iterator pos = ModuleMEsMap.find(idet);
1099   ModMEs mod_me = pos->second;
1100 
1101   if (moduleswitchncluson)
1102     mod_me.NumberOfClusters->Reset();
1103   if (moduleswitchclusposon)
1104     mod_me.ClusterPosition->Reset();
1105   if (moduleswitchclusdigiposon)
1106     mod_me.ClusterDigiPosition->Reset();
1107   if (moduleswitchclusstonVsposon)
1108     mod_me.ClusterSignalOverNoiseVsPos->Reset();
1109   if (moduleswitchcluswidthon)
1110     mod_me.ClusterWidth->Reset();
1111   if (moduleswitchcluschargeon)
1112     mod_me.ClusterCharge->Reset();
1113   if (moduleswitchclusnoiseon)
1114     mod_me.ClusterNoise->Reset();
1115   if (moduleswitchclusstonon)
1116     mod_me.ClusterSignalOverNoise->Reset();
1117   if (moduleswitchlocaloccupancy)
1118     mod_me.ModuleLocalOccupancy->Reset();
1119   if (moduleswitchnrclusterizedstrip)
1120     mod_me.NrOfClusterizedStrips->Reset();
1121   if (module_clusterWidth_vs_amplitude_on)
1122     mod_me.Module_ClusWidthVsAmpTH2->Reset();
1123 }
1124 //
1125 // -- Create Module Level MEs
1126 //
1127 void SiStripMonitorCluster::createModuleMEs(ModMEs& mod_single,
1128                                             uint32_t detid,
1129                                             DQMStore::IBooker& ibooker,
1130                                             const SiStripDetCabling& siStripDetCabling) {
1131   // use SistripHistoId for producing histogram id (and title)
1132   SiStripHistoId hidmanager;
1133   std::string hid;
1134 
1135   // nr. of clusters per module
1136   if (moduleswitchncluson) {
1137     hid = hidmanager.createHistoId("NumberOfClusters", "det", detid);
1138     mod_single.NumberOfClusters = bookME1D("TH1nClusters", hid.c_str(), ibooker);
1139     mod_single.NumberOfClusters->setAxisTitle("number of clusters in one detector module");
1140     mod_single.NumberOfClusters->setStatOverflows(kTRUE);  // over/underflows in Mean calculation
1141   }
1142 
1143   // ClusterPosition
1144   if (moduleswitchclusposon) {
1145     short total_nr_strips = siStripDetCabling.nApvPairs(detid) * 2 * 128;  // get correct # of avp pairs
1146     hid = hidmanager.createHistoId("ClusterPosition", "det", detid);
1147     mod_single.ClusterPosition = ibooker.book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips + 0.5);
1148     mod_single.ClusterPosition->setAxisTitle("cluster position [strip number +0.5]");
1149   }
1150 
1151   // ClusterDigiPosition
1152   if (moduleswitchclusdigiposon) {
1153     short total_nr_strips = siStripDetCabling.nApvPairs(detid) * 2 * 128;  // get correct # of avp pairs
1154     hid = hidmanager.createHistoId("ClusterDigiPosition", "det", detid);
1155     mod_single.ClusterDigiPosition = ibooker.book1D(hid, hid, total_nr_strips, 0.5, total_nr_strips + 0.5);
1156     mod_single.ClusterDigiPosition->setAxisTitle("digi in cluster position [strip number +0.5]");
1157   }
1158 
1159   // ClusterWidth
1160   if (moduleswitchcluswidthon) {
1161     hid = hidmanager.createHistoId("ClusterWidth", "det", detid);
1162     mod_single.ClusterWidth = bookME1D("TH1ClusterWidth", hid.c_str(), ibooker);
1163     mod_single.ClusterWidth->setAxisTitle("cluster width [nr strips]");
1164   }
1165 
1166   // ClusterCharge
1167   if (moduleswitchcluschargeon) {
1168     hid = hidmanager.createHistoId("ClusterCharge", "det", detid);
1169     mod_single.ClusterCharge = bookME1D("TH1ClusterCharge", hid.c_str(), ibooker);
1170     mod_single.ClusterCharge->setAxisTitle("cluster charge [ADC]");
1171   }
1172 
1173   // ClusterNoise
1174   if (moduleswitchclusnoiseon) {
1175     hid = hidmanager.createHistoId("ClusterNoise", "det", detid);
1176     mod_single.ClusterNoise = bookME1D("TH1ClusterNoise", hid.c_str(), ibooker);
1177     mod_single.ClusterNoise->setAxisTitle("cluster noise");
1178   }
1179 
1180   // ClusterSignalOverNoise
1181   if (moduleswitchclusstonon) {
1182     hid = hidmanager.createHistoId("ClusterSignalOverNoise", "det", detid);
1183     mod_single.ClusterSignalOverNoise = bookME1D("TH1ClusterStoN", hid.c_str(), ibooker);
1184     mod_single.ClusterSignalOverNoise->setAxisTitle("ratio of signal to noise for each cluster");
1185   }
1186 
1187   // ClusterSignalOverNoiseVsPos
1188   if (moduleswitchclusstonVsposon) {
1189     hid = hidmanager.createHistoId("ClusterSignalOverNoiseVsPos", "det", detid);
1190     Parameters = conf_.getParameter<edm::ParameterSet>("TH1ClusterStoNVsPos");
1191     mod_single.ClusterSignalOverNoiseVsPos = ibooker.bookProfile(hid.c_str(),
1192                                                                  hid.c_str(),
1193                                                                  Parameters.getParameter<int32_t>("Nbinx"),
1194                                                                  Parameters.getParameter<double>("xmin"),
1195                                                                  Parameters.getParameter<double>("xmax"),
1196                                                                  Parameters.getParameter<int32_t>("Nbiny"),
1197                                                                  Parameters.getParameter<double>("ymin"),
1198                                                                  Parameters.getParameter<double>("ymax"));
1199     mod_single.ClusterSignalOverNoiseVsPos->setAxisTitle("pos");
1200   }
1201 
1202   // ModuleLocalOccupancy
1203   if (moduleswitchlocaloccupancy) {
1204     hid = hidmanager.createHistoId("ClusterLocalOccupancy", "det", detid);
1205     mod_single.ModuleLocalOccupancy = bookME1D("TH1ModuleLocalOccupancy", hid.c_str(), ibooker);
1206     mod_single.ModuleLocalOccupancy->setAxisTitle("module local occupancy [% of clusterized strips]");
1207   }
1208 
1209   // NrOfClusterizedStrips
1210   if (moduleswitchnrclusterizedstrip) {
1211     hid = hidmanager.createHistoId("NrOfClusterizedStrips", "det", detid);
1212     mod_single.NrOfClusterizedStrips = bookME1D("TH1NrOfClusterizedStrips", hid.c_str(), ibooker);
1213     mod_single.NrOfClusterizedStrips->setAxisTitle("number of clusterized strips");
1214   }
1215 
1216   if (module_clusterWidth_vs_amplitude_on) {
1217     hid = hidmanager.createHistoId("ClusterWidths_vs_Amplitudes", "det", detid);
1218     Parameters = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
1219     int32_t Nbinsx = Parameters.getParameter<int32_t>("Nbinsx");
1220     Nbinsx = Nbinsx / 2;  // Without this "rebinning" the job is killed on
1221                           // lxplus. We think it's due to the high memory needed
1222                           // to create all those histograms.
1223     mod_single.Module_ClusWidthVsAmpTH2 = ibooker.book2D(hid.c_str(),
1224                                                          hid.c_str(),
1225                                                          Nbinsx,
1226                                                          Parameters.getParameter<double>("xmin"),
1227                                                          Parameters.getParameter<double>("xmax"),
1228                                                          Parameters.getParameter<int32_t>("Nbinsy"),
1229                                                          Parameters.getParameter<double>("ymin"),
1230                                                          Parameters.getParameter<double>("ymax"));
1231     mod_single.Module_ClusWidthVsAmpTH2->setAxisTitle("Amplitudes (integrated ADC counts)", 1);
1232     mod_single.Module_ClusWidthVsAmpTH2->setAxisTitle("Cluster widths", 2);
1233   }
1234 }
1235 //
1236 // -- Create Module Level MEs
1237 //
1238 void SiStripMonitorCluster::createLayerMEs(std::string label, int ndets, DQMStore::IBooker& ibooker) {
1239   SiStripHistoId hidmanager;
1240 
1241   LayerMEs layerMEs;
1242   layerMEs.LayerClusterStoN = nullptr;
1243   layerMEs.LayerClusterStoNTrend = nullptr;
1244   layerMEs.LayerClusterCharge = nullptr;
1245   layerMEs.LayerClusterChargeTrend = nullptr;
1246   layerMEs.LayerClusterNoise = nullptr;
1247   layerMEs.LayerClusterNoiseTrend = nullptr;
1248   layerMEs.LayerClusterWidth = nullptr;
1249   layerMEs.LayerClusterWidthTrend = nullptr;
1250   layerMEs.LayerLocalOccupancy = nullptr;
1251   layerMEs.LayerLocalOccupancyTrend = nullptr;
1252   layerMEs.LayerNumberOfClusterProfile = nullptr;
1253   layerMEs.LayerNumberOfClusterTrend = nullptr;
1254   layerMEs.LayerNumberOfClusterPerRingTrend = nullptr;
1255   layerMEs.LayerClusterWidthProfile = nullptr;
1256   layerMEs.LayerClusWidthVsAmpTH2 = nullptr;
1257   layerMEs.LayerClusterPosition = nullptr;
1258 
1259   // Cluster Width
1260   if (layerswitchcluswidthon) {
1261     layerMEs.LayerClusterWidth = bookME1D(
1262         "TH1ClusterWidth", hidmanager.createHistoLayer("Summary_ClusterWidth", "layer", label, "").c_str(), ibooker);
1263     if (createTrendMEs)
1264       layerMEs.LayerClusterWidthTrend =
1265           bookMETrend(hidmanager.createHistoLayer("Trend_ClusterWidth", "layer", label, "").c_str(), ibooker);
1266   }
1267 
1268   // Cluster Noise
1269   if (layerswitchclusnoiseon) {
1270     layerMEs.LayerClusterNoise = bookME1D(
1271         "TH1ClusterNoise", hidmanager.createHistoLayer("Summary_ClusterNoise", "layer", label, "").c_str(), ibooker);
1272     if (createTrendMEs)
1273       layerMEs.LayerClusterNoiseTrend =
1274           bookMETrend(hidmanager.createHistoLayer("Trend_ClusterNoise", "layer", label, "").c_str(), ibooker);
1275   }
1276 
1277   // Cluster Charge
1278   if (layerswitchcluschargeon) {
1279     layerMEs.LayerClusterCharge = bookME1D(
1280         "TH1ClusterCharge", hidmanager.createHistoLayer("Summary_ClusterCharge", "layer", label, "").c_str(), ibooker);
1281     if (createTrendMEs)
1282       layerMEs.LayerClusterChargeTrend =
1283           bookMETrend(hidmanager.createHistoLayer("Trend_ClusterCharge", "layer", label, "").c_str(), ibooker);
1284   }
1285 
1286   // Cluster StoN
1287   if (layerswitchclusstonon) {
1288     layerMEs.LayerClusterStoN =
1289         bookME1D("TH1ClusterStoN",
1290                  hidmanager.createHistoLayer("Summary_ClusterSignalOverNoise", "layer", label, "").c_str(),
1291                  ibooker);
1292     if (createTrendMEs)
1293       layerMEs.LayerClusterStoNTrend =
1294           bookMETrend(hidmanager.createHistoLayer("Trend_ClusterSignalOverNoise", "layer", label, "").c_str(), ibooker);
1295   }
1296 
1297   // Cluster Occupancy
1298   if (layerswitchlocaloccupancy) {
1299     layerMEs.LayerLocalOccupancy =
1300         bookME1D("TH1ModuleLocalOccupancy",
1301                  hidmanager.createHistoLayer("Summary_ClusterLocalOccupancy", "layer", label, "").c_str(),
1302                  ibooker);
1303     if (createTrendMEs)
1304       layerMEs.LayerLocalOccupancyTrend =
1305           bookMETrend(hidmanager.createHistoLayer("Trend_ClusterLocalOccupancy", "layer", label, "").c_str(), ibooker);
1306   }
1307 
1308   // # of Cluster Profile
1309   if (layerswitchnumclusterprofon) {
1310     std::string hid = hidmanager.createHistoLayer("NumberOfClusterProfile", "layer", label, "");
1311     layerMEs.LayerNumberOfClusterProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets + 0.5, 21, -0.5, 20.5);
1312   }
1313 
1314   // # of Cluster Trend
1315   if (subdetswitchtotclusprofon) {
1316     layerMEs.LayerNumberOfClusterTrend =
1317         bookMETrend(hidmanager.createHistoLayer("NumberOfClusterTrend", "layer", label, "").c_str(), ibooker);
1318 
1319     if (label.find("TID") != std::string::npos || label.find("TEC") != std::string::npos) {
1320       edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("NumberOfClusterPerRingVsTrendVar");
1321 
1322       layerMEs.LayerNumberOfClusterPerRingTrend = ibooker.bookProfile2D(
1323           "NumberOfClusterPerRingVsTrendVar",
1324           hidmanager.createHistoLayer("NumberOfClusterPerRing_vs_TrendVar", "layer", label, "").c_str(),
1325           Parameters.getParameter<int32_t>("Nbinsx"),
1326           Parameters.getParameter<double>("xmin"),
1327           Parameters.getParameter<double>("xmax"),
1328           Parameters.getParameter<int32_t>("Nbinsy"),
1329           Parameters.getParameter<double>("ymin"),
1330           Parameters.getParameter<double>("ymax"),
1331           0,
1332           0,
1333           "");
1334     }
1335   }
1336 
1337   // Cluster Width Profile
1338   if (layerswitchclusterwidthprofon) {
1339     std::string hid = hidmanager.createHistoLayer("ClusterWidthProfile", "layer", label, "");
1340     layerMEs.LayerClusterWidthProfile = ibooker.bookProfile(hid, hid, ndets, 0.5, ndets + 0.5, 20, -0.5, 19.5);
1341   }
1342 
1343   if (layer_clusterWidth_vs_amplitude_on) {
1344     layerMEs.LayerClusWidthVsAmpTH2 =
1345         bookME2D("ClusWidthVsAmpTH2",
1346                  hidmanager.createHistoLayer("ClusterWidths_vs_Amplitudes", "layer", label, "").c_str(),
1347                  ibooker);
1348   }
1349 
1350   // Cluster Position
1351   if (layerswitchclusposon) {
1352     std::string hid = hidmanager.createHistoLayer("ClusterPosition", "layer", label, "");
1353     layerMEs.LayerClusterPosition = ibooker.book1D(hid, hid, 128 * 6, 0.5, 128 * 6 + 0.5);
1354   }
1355 
1356   LayerMEsMap[label] = layerMEs;
1357 }
1358 //
1359 // -- Create SubDetector MEs
1360 //
1361 void SiStripMonitorCluster::createSubDetMEs(std::string label, DQMStore::IBooker& ibooker) {
1362   SubDetMEs subdetMEs;
1363   subdetMEs.totNClusters = 0;
1364   subdetMEs.SubDetTotClusterTH1 = nullptr;
1365   subdetMEs.SubDetTotClusterProf = nullptr;
1366   subdetMEs.SubDetClusterApvProf = nullptr;
1367   subdetMEs.SubDetClusterApvTH2 = nullptr;
1368   subdetMEs.SubDetClusterDBxCycleProf = nullptr;
1369   subdetMEs.SubDetApvDBxProf2 = nullptr;
1370   subdetMEs.SubDetClusterChargeTH1 = nullptr;
1371   subdetMEs.SubDetClusterWidthTH1 = nullptr;
1372   subdetMEs.SubDetClusWidthVsAmpTH2 = nullptr;
1373   subdetMEs.SubDetNumberOfClusterPerLayerTrend = nullptr;
1374 
1375   std::string HistoName;
1376   // cluster charge
1377   if (subdetswitchcluschargeon) {
1378     HistoName = "ClusterCharge__" + label;
1379     subdetMEs.SubDetClusterChargeTH1 = bookME1D("TH1ClusterCharge", HistoName.c_str(), ibooker);
1380     subdetMEs.SubDetClusterChargeTH1->setAxisTitle("Cluster charge [ADC counts]");
1381     subdetMEs.SubDetClusterChargeTH1->setStatOverflows(kTRUE);  // over/underflows in Mean calculation
1382   }
1383   // cluster width
1384   if (subdetswitchcluswidthon) {
1385     HistoName = "ClusterWidth__" + label;
1386     subdetMEs.SubDetClusterWidthTH1 = bookME1D("TH1ClusterWidth", HistoName.c_str(), ibooker);
1387     subdetMEs.SubDetClusterWidthTH1->setAxisTitle("Cluster width [strips]");
1388     subdetMEs.SubDetClusterWidthTH1->setStatOverflows(kTRUE);  // over/underflows in Mean calculation
1389   }
1390   // Total Number of Cluster - 1D
1391   if (subdetswitchtotclusth1on) {
1392     HistoName = "TotalNumberOfCluster__" + label;
1393     subdetMEs.SubDetTotClusterTH1 = bookME1D("TH1TotalNumberOfClusters", HistoName.c_str(), ibooker);
1394     subdetMEs.SubDetTotClusterTH1->setAxisTitle("Total number of clusters in subdetector");
1395     subdetMEs.SubDetTotClusterTH1->setStatOverflows(kTRUE);  // over/underflows in Mean calculation
1396   }
1397   // Total Number of Cluster vs Time - Profile
1398   if (subdetswitchtotclusprofon) {
1399     edm::ParameterSet Parameters = trendVs10Ls_ ? conf_.getParameter<edm::ParameterSet>("TrendingLS")
1400                                                 : conf_.getParameter<edm::ParameterSet>("Trending");
1401     HistoName = "TotalNumberOfClusterProfile__" + label;
1402     subdetMEs.SubDetTotClusterProf = ibooker.bookProfile(HistoName,
1403                                                          HistoName,
1404                                                          Parameters.getParameter<int32_t>("Nbins"),
1405                                                          Parameters.getParameter<double>("xmin"),
1406                                                          Parameters.getParameter<double>("xmax"),
1407                                                          0,
1408                                                          0,
1409                                                          "");
1410     subdetMEs.SubDetTotClusterProf->setAxisTitle(Parameters.getParameter<std::string>("xaxis"), 1);
1411     if (subdetMEs.SubDetTotClusterProf->kind() == MonitorElement::Kind::TPROFILE)
1412       subdetMEs.SubDetTotClusterProf->setCanExtend(TH1::kAllAxes);
1413 
1414     Parameters = conf_.getParameter<edm::ParameterSet>("NumberOfClusterPerLayerTrendVar");
1415     HistoName = "TotalNumberOfClusterPerLayer__" + label;
1416     subdetMEs.SubDetNumberOfClusterPerLayerTrend = ibooker.bookProfile2D("NumberOfClusterPerLayerTrendVar",
1417                                                                          HistoName.c_str(),
1418                                                                          Parameters.getParameter<int32_t>("Nbinsx"),
1419                                                                          Parameters.getParameter<double>("xmin"),
1420                                                                          Parameters.getParameter<double>("xmax"),
1421                                                                          Parameters.getParameter<int32_t>("Nbinsy"),
1422                                                                          Parameters.getParameter<double>("ymin"),
1423                                                                          Parameters.getParameter<double>("ymax"),
1424                                                                          0,
1425                                                                          0,
1426                                                                          "");
1427     subdetMEs.SubDetNumberOfClusterPerLayerTrend->setAxisTitle("Lumisection", 1);
1428     subdetMEs.SubDetNumberOfClusterPerLayerTrend->setAxisTitle("Layer Number", 2);
1429   }
1430 
1431   // Total Number of Cluster vs APV cycle - Profile
1432   if (subdetswitchapvcycleprofon) {
1433     edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersApvCycle");
1434     HistoName = "Cluster_vs_ApvCycle__" + label;
1435     subdetMEs.SubDetClusterApvProf = ibooker.bookProfile(HistoName,
1436                                                          HistoName,
1437                                                          Parameters.getParameter<int32_t>("Nbins"),
1438                                                          Parameters.getParameter<double>("xmin"),
1439                                                          Parameters.getParameter<double>("xmax"),
1440                                                          200,  // that parameter should not be there !?
1441                                                          Parameters.getParameter<double>("ymin"),
1442                                                          Parameters.getParameter<double>("ymax"),
1443                                                          "");
1444     subdetMEs.SubDetClusterApvProf->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70)", 1);
1445   }
1446 
1447   // Total Number of Clusters vs ApvCycle - 2D
1448   if (subdetswitchapvcycleth2on) {
1449     edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TH2ClustersApvCycle");
1450     HistoName = "Cluster_vs_ApvCycle_2D__" + label;
1451     // Adjusting the scale for 2D histogram
1452     double h2ymax = 9999.0;
1453     double yfact = Parameters.getParameter<double>("yfactor");
1454     if (label.find("TIB") != std::string::npos)
1455       h2ymax = (6984. * 256.) * yfact;
1456     else if (label.find("TID") != std::string::npos)
1457       h2ymax = (2208. * 256.) * yfact;
1458     else if (label.find("TOB") != std::string::npos)
1459       h2ymax = (12906. * 256.) * yfact;
1460     else if (label.find("TEC") != std::string::npos)
1461       h2ymax = (7552. * 2. * 256.) * yfact;
1462 
1463     subdetMEs.SubDetClusterApvTH2 = ibooker.book2D(HistoName,
1464                                                    HistoName,
1465                                                    Parameters.getParameter<int32_t>("Nbinsx"),
1466                                                    Parameters.getParameter<double>("xmin"),
1467                                                    Parameters.getParameter<double>("xmax"),
1468                                                    Parameters.getParameter<int32_t>("Nbinsy"),
1469                                                    Parameters.getParameter<double>("ymin"),
1470                                                    h2ymax);
1471     subdetMEs.SubDetClusterApvTH2->setAxisTitle("Apv Cycle (Corrected Absolute Bx % 70))", 1);
1472     subdetMEs.SubDetClusterApvTH2->setAxisTitle("Total # of Clusters", 2);
1473   }
1474 
1475   // Cluster widths vs amplitudes - 2D
1476   if (subdet_clusterWidth_vs_amplitude_on) {
1477     edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("ClusWidthVsAmpTH2");
1478     HistoName = "ClusterWidths_vs_Amplitudes__" + label;
1479     subdetMEs.SubDetClusWidthVsAmpTH2 = ibooker.book2D(HistoName,
1480                                                        HistoName,
1481                                                        Parameters.getParameter<int32_t>("Nbinsx"),
1482                                                        Parameters.getParameter<double>("xmin"),
1483                                                        Parameters.getParameter<double>("xmax"),
1484                                                        Parameters.getParameter<int32_t>("Nbinsy"),
1485                                                        Parameters.getParameter<double>("ymin"),
1486                                                        Parameters.getParameter<double>("ymax"));
1487     subdetMEs.SubDetClusWidthVsAmpTH2->setAxisTitle("Amplitudes (integrated ADC counts)", 1);
1488     subdetMEs.SubDetClusWidthVsAmpTH2->setAxisTitle("Cluster widths", 2);
1489   }
1490 
1491   // Total Number of Cluster vs DeltaBxCycle - Profile
1492   if (subdetswitchdbxcycleprofon) {
1493     edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProfClustersVsDBxCycle");
1494     HistoName = "Cluster_vs_DeltaBxCycle__" + label;
1495     subdetMEs.SubDetClusterDBxCycleProf = ibooker.bookProfile(HistoName,
1496                                                               HistoName,
1497                                                               Parameters.getParameter<int32_t>("Nbins"),
1498                                                               Parameters.getParameter<double>("xmin"),
1499                                                               Parameters.getParameter<double>("xmax"),
1500                                                               200,  // that parameter should not be there !?
1501                                                               Parameters.getParameter<double>("ymin"),
1502                                                               Parameters.getParameter<double>("ymax"),
1503                                                               "");
1504     subdetMEs.SubDetClusterDBxCycleProf->setAxisTitle("Delta Bunch Crossing Cycle", 1);
1505   }
1506   // DeltaBx vs ApvCycle - 2DProfile
1507   if (subdetswitchapvcycledbxprof2on) {
1508     edm::ParameterSet Parameters = conf_.getParameter<edm::ParameterSet>("TProf2ApvCycleVsDBx");
1509     HistoName = "DeltaBx_vs_ApvCycle__" + label;
1510     subdetMEs.SubDetApvDBxProf2 = ibooker.bookProfile2D(HistoName,
1511                                                         HistoName,
1512                                                         Parameters.getParameter<int32_t>("Nbinsx"),
1513                                                         Parameters.getParameter<double>("xmin"),
1514                                                         Parameters.getParameter<double>("xmax"),
1515                                                         Parameters.getParameter<int32_t>("Nbinsy"),
1516                                                         Parameters.getParameter<double>("ymin"),
1517                                                         Parameters.getParameter<double>("ymax"),
1518                                                         Parameters.getParameter<double>("zmin"),
1519                                                         Parameters.getParameter<double>("zmax"),
1520                                                         "");
1521     subdetMEs.SubDetApvDBxProf2->setAxisTitle("APV Cycle (Corrected Absolute Bx % 70)", 1);
1522     subdetMEs.SubDetApvDBxProf2->setAxisTitle("Delta Bunch Crossing Cycle", 2);
1523   }
1524   SubDetMEsMap[label] = subdetMEs;
1525 }
1526 
1527 //
1528 // -- Fill Module Level Histograms
1529 //
1530 void SiStripMonitorCluster::fillModuleMEs(ModMEs& mod_mes, ClusterProperties& cluster) {
1531   if (moduleswitchclusposon && (mod_mes.ClusterPosition))  // position of cluster
1532     (mod_mes.ClusterPosition)->Fill(cluster.position);
1533 
1534   // position of digis in cluster
1535   if (moduleswitchclusdigiposon && (mod_mes.ClusterDigiPosition)) {
1536     for (int ipos = cluster.start + 1; ipos <= cluster.start + cluster.width; ipos++) {
1537       (mod_mes.ClusterDigiPosition)->Fill(ipos);
1538     }
1539   }
1540 
1541   if (moduleswitchcluswidthon && (mod_mes.ClusterWidth))  // width of cluster
1542     (mod_mes.ClusterWidth)->Fill(static_cast<float>(cluster.width));
1543 
1544   if (moduleswitchclusstonon && (mod_mes.ClusterSignalOverNoise)) {  // SignalToNoise
1545     if (cluster.noise > 0)
1546       (mod_mes.ClusterSignalOverNoise)->Fill(cluster.charge / cluster.noise);
1547   }
1548 
1549   if (moduleswitchclusstonVsposon && (mod_mes.ClusterSignalOverNoiseVsPos)) {  // SignalToNoise
1550     if (cluster.noise > 0)
1551       (mod_mes.ClusterSignalOverNoiseVsPos)->Fill(cluster.position, cluster.charge / cluster.noise);
1552   }
1553 
1554   if (moduleswitchclusnoiseon && (mod_mes.ClusterNoise))  // Noise
1555     (mod_mes.ClusterNoise)->Fill(cluster.noise);
1556 
1557   if (moduleswitchcluschargeon && (mod_mes.ClusterCharge))  // charge of cluster
1558     (mod_mes.ClusterCharge)->Fill(cluster.charge);
1559 
1560   if (module_clusterWidth_vs_amplitude_on)
1561     (mod_mes.Module_ClusWidthVsAmpTH2)->Fill(cluster.charge, cluster.width);
1562 }
1563 //
1564 // -- Fill Layer Level MEs
1565 //
1566 void SiStripMonitorCluster::fillLayerMEs(LayerMEs& layerMEs, ClusterProperties& cluster) {
1567   if (layerswitchclusstonon) {
1568     fillME(layerMEs.LayerClusterStoN, cluster.charge / cluster.noise);
1569     if (createTrendMEs) {
1570       fillME(layerMEs.LayerClusterStoNTrend, trendVar, cluster.charge / cluster.noise);
1571     }
1572   }
1573 
1574   if (layerswitchcluschargeon) {
1575     fillME(layerMEs.LayerClusterCharge, cluster.charge);
1576     if (createTrendMEs) {
1577       fillME(layerMEs.LayerClusterChargeTrend, trendVar, cluster.charge);
1578     }
1579   }
1580 
1581   if (layerswitchclusnoiseon) {
1582     fillME(layerMEs.LayerClusterNoise, cluster.noise);
1583     if (createTrendMEs) {
1584       fillME(layerMEs.LayerClusterNoiseTrend, trendVar, cluster.noise);
1585     }
1586   }
1587 
1588   if (layerswitchcluswidthon) {
1589     fillME(layerMEs.LayerClusterWidth, cluster.width);
1590     if (createTrendMEs) {
1591       fillME(layerMEs.LayerClusterWidthTrend, trendVar, cluster.width);
1592     }
1593   }
1594 
1595   if (layer_clusterWidth_vs_amplitude_on) {
1596     fillME(layerMEs.LayerClusWidthVsAmpTH2, cluster.charge, cluster.width);
1597   }
1598 
1599   if (layerswitchclusposon) {
1600     fillME(layerMEs.LayerClusterPosition, cluster.position);
1601   }
1602 }
1603 //------------------------------------------------------------------------------------------
1604 SiStripMonitorCluster::MonitorElement* SiStripMonitorCluster::bookMETrend(const char* HistoName,
1605                                                                           DQMStore::IBooker& ibooker) {
1606   edm::ParameterSet ParametersTrend = trendVs10Ls_ ? conf_.getParameter<edm::ParameterSet>("TrendingLS")
1607                                                    : conf_.getParameter<edm::ParameterSet>("Trending");
1608   MonitorElement* me = ibooker.bookProfile(HistoName,
1609                                            HistoName,
1610                                            ParametersTrend.getParameter<int32_t>("Nbins"),
1611                                            ParametersTrend.getParameter<double>("xmin"),
1612                                            ParametersTrend.getParameter<double>("xmax"),
1613                                            0,
1614                                            0,
1615                                            "");
1616   if (!me)
1617     return me;
1618   me->setAxisTitle(ParametersTrend.getParameter<std::string>("xaxis"), 1);
1619   if (me->kind() == MonitorElement::Kind::TPROFILE)
1620     me->setCanExtend(TH1::kAllAxes);
1621   return me;
1622 }
1623 
1624 //------------------------------------------------------------------------------------------
1625 SiStripMonitorCluster::MonitorElement* SiStripMonitorCluster::bookME1D(const char* ParameterSetLabel,
1626                                                                        const char* HistoName,
1627                                                                        DQMStore::IBooker& ibooker) {
1628   Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
1629   return ibooker.book1D(HistoName,
1630                         HistoName,
1631                         Parameters.getParameter<int32_t>("Nbinx"),
1632                         Parameters.getParameter<double>("xmin"),
1633                         Parameters.getParameter<double>("xmax"));
1634 }
1635 
1636 //------------------------------------------------------------------------------------------
1637 SiStripMonitorCluster::MonitorElement* SiStripMonitorCluster::bookME2D(const char* ParameterSetLabel,
1638                                                                        const char* HistoName,
1639                                                                        DQMStore::IBooker& ibooker) {
1640   Parameters = conf_.getParameter<edm::ParameterSet>(ParameterSetLabel);
1641   return ibooker.book2D(HistoName,
1642                         HistoName,
1643                         Parameters.getParameter<int32_t>("Nbinsx"),
1644                         Parameters.getParameter<double>("xmin"),
1645                         Parameters.getParameter<double>("xmax"),
1646                         Parameters.getParameter<int32_t>("Nbinsy"),
1647                         Parameters.getParameter<double>("ymin"),
1648                         Parameters.getParameter<double>("ymax"));
1649 }
1650 
1651 int SiStripMonitorCluster::FindRegion(int nstrip, int npix) {
1652   double kplus = k0 * (1 + dk0 / 100);
1653   double kminus = k0 * (1 - dk0 / 100);
1654   int region = 0;
1655 
1656   if (nstrip != 0 && npix >= (nstrip * kminus - q0) && npix <= (nstrip * kplus + q0))
1657     region = 1;
1658   else if (nstrip != 0 && npix < (nstrip * kminus - q0) && nstrip <= maxClus)
1659     region = 2;
1660   else if (nstrip != 0 && npix < (nstrip * kminus - q0) && nstrip > maxClus)
1661     region = 3;
1662   else if (nstrip != 0 && npix > (nstrip * kplus + q0))
1663     region = 4;
1664   else if (npix > minPix && nstrip == 0)
1665     region = 5;
1666   return region;
1667 }