Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/SiStripMonitorSummary/interface/SiStripThresholdDQM.h"
0002 
0003 SiStripThresholdDQM::SiStripThresholdDQM(edm::ESGetToken<SiStripThreshold, SiStripThresholdRcd> token,
0004                                          edm::RunNumber_t iRun,
0005                                          edm::ParameterSet const &hPSet,
0006                                          edm::ParameterSet const &fPSet,
0007                                          const TrackerTopology *tTopo,
0008                                          const TkDetMap *tkDetMap)
0009     : SiStripBaseCondObjDQMGet<SiStripThreshold, SiStripThresholdRcd>{token, iRun, hPSet, fPSet, tTopo} {
0010   WhichThreshold = hPSet.getParameter<std::string>("WhichThreshold");
0011 
0012   if (HistoMaps_On_) {
0013     if (WhichThreshold == "Low")
0014       Tk_HM_L = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "LowThresh_TkMap", 0.);
0015     if (WhichThreshold == "High")
0016       Tk_HM_H = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "HighThresh_TkMap", 0.);
0017   }
0018 }
0019 
0020 SiStripThresholdDQM::~SiStripThresholdDQM() {}
0021 
0022 void SiStripThresholdDQM::getActiveDetIds(const edm::EventSetup &eSetup) {
0023   getConditionObject(eSetup);
0024   condObj_->getDetIds(activeDetIds);
0025 }
0026 
0027 void SiStripThresholdDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
0028   ModMEs CondObj_ME;
0029   for (const auto det : selectedDetIds) {
0030     fillMEsForDet(CondObj_ME, det);
0031   }
0032 }
0033 
0034 void SiStripThresholdDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
0035   ModMEs selModME_ = _selModME_;
0036   std::vector<uint32_t> DetIds;
0037   condObj_->getDetIds(DetIds);
0038 
0039   const auto ThresholdRange = condObj_->getRange(selDetId_);
0040   int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
0041 
0042   getModMEs(selModME_, selDetId_);
0043 
0044   for (int istrip = 0; istrip < nStrip; ++istrip) {
0045     if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
0046       if (WhichThreshold == "Low")
0047         selModME_.ProfileDistr->Fill(istrip + 1, condObj_->getData(istrip, ThresholdRange).getLth());
0048       if (WhichThreshold == "High")
0049         selModME_.ProfileDistr->Fill(istrip + 1, condObj_->getData(istrip, ThresholdRange).getHth());
0050     }
0051   }  // istrip
0052 }
0053 
0054 void SiStripThresholdDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
0055   for (const auto det : selectedDetIds) {
0056     fillMEsForLayer(/*SummaryMEsMap_,*/ det);
0057   }
0058 }
0059 
0060 void SiStripThresholdDQM::fillMEsForLayer(
0061     /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_) {
0062   // ----
0063   int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
0064 
0065   if (subdetectorId_ < 3 || subdetectorId_ > 6) {
0066     edm::LogError("SiStripThresholdDQM") << "[SiStripThresholdDQM::fillMEsForLayer] WRONG INPUT : no such "
0067                                             "subdetector type : "
0068                                          << subdetectorId_ << " no folder set!" << std::endl;
0069     return;
0070   }
0071   // ----
0072 
0073   const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
0074   ModMEs selME_;
0075   if (selMEsMapIter_ != SummaryMEsMap_.end())
0076     selME_ = selMEsMapIter_->second;
0077 
0078   getSummaryMEs(selME_, selDetId_);
0079 
0080   const auto ThresholdRange = condObj_->getRange(selDetId_);
0081 
0082   int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
0083 
0084   SiStripHistoId hidmanager;
0085 
0086   if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
0087     // --> profile summary
0088 
0089     std::string hSummaryOfProfile_description;
0090     hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
0091 
0092     std::string hSummaryOfProfile_name;
0093 
0094     hSummaryOfProfile_name =
0095         hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
0096 
0097     for (int istrip = 0; istrip < nStrip; ++istrip) {
0098       if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
0099         if (WhichThreshold == "Low") {
0100           selME_.SummaryOfProfileDistr->Fill(istrip + 1, condObj_->getData(istrip, ThresholdRange).getLth());
0101           if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On"))
0102             fillTkMap(selDetId_, condObj_->getData(istrip, ThresholdRange).getLth());
0103         }
0104         if (WhichThreshold == "High") {
0105           selME_.SummaryOfProfileDistr->Fill(istrip + 1, condObj_->getData(istrip, ThresholdRange).getHth());
0106           if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On"))
0107             fillTkMap(selDetId_, condObj_->getData(istrip, ThresholdRange).getHth());
0108         }
0109       }
0110     }  // istrip
0111 
0112   }  // if Fill
0113 
0114   if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
0115     // --> summary
0116 
0117     std::string hSummary_description;
0118     hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
0119 
0120     std::string hSummary_name;
0121     hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
0122 
0123     float meanLowThreshold = 0;
0124     float meanHighThreshold = 0;
0125 
0126     for (int istrip = 0; istrip < nStrip; ++istrip) {
0127       meanLowThreshold = meanLowThreshold + condObj_->getData(istrip, ThresholdRange).getLth();
0128       meanHighThreshold = meanHighThreshold + condObj_->getData(istrip, ThresholdRange).getHth();
0129     }  // istrip
0130 
0131     meanLowThreshold = meanLowThreshold / nStrip;
0132     meanHighThreshold = meanHighThreshold / nStrip;
0133 
0134     // -----
0135     // get detIds belonging to same layer to fill X-axis with detId-number
0136 
0137     std::vector<uint32_t> sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
0138 
0139     unsigned int iBin = 0;
0140     for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
0141       if (sameLayerDetIds_[i] == selDetId_) {
0142         iBin = i + 1;
0143       }
0144     }
0145 
0146     if (WhichThreshold == "Low") {
0147       selME_.SummaryDistr->Fill(iBin, meanLowThreshold);
0148       if (HistoMaps_On_)
0149         Tk_HM_L->fill(selDetId_, meanLowThreshold);
0150     }
0151     if (WhichThreshold == "High") {
0152       selME_.SummaryDistr->Fill(iBin, meanHighThreshold);
0153       if (HistoMaps_On_)
0154         Tk_HM_H->fill(selDetId_, meanHighThreshold);
0155     }
0156 
0157   }  // if Fill ...
0158 }