Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/SiStripMonitorSummary/interface/SiStripNoisesDQM.h"
0002 
0003 SiStripNoisesDQM::SiStripNoisesDQM(edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> noiseToken,
0004                                    edm::RunNumber_t iRun,
0005                                    edm::ParameterSet const &hPSet,
0006                                    edm::ParameterSet const &fPSet,
0007                                    const TrackerTopology *tTopo,
0008                                    const TkDetMap *tkDetMap,
0009                                    const SiStripApvGain *gainHandle)
0010     : SiStripBaseCondObjDQMGet<SiStripNoises, SiStripNoisesRcd>{noiseToken, iRun, hPSet, fPSet, tTopo},
0011       gainHandle_{gainHandle} {
0012   // Build the Histo_TkMap:
0013   if (HistoMaps_On_) {
0014     Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "MeanNoise_TkMap", 0.);
0015   }
0016 }
0017 
0018 SiStripNoisesDQM::~SiStripNoisesDQM() {}
0019 
0020 void SiStripNoisesDQM::getActiveDetIds(const edm::EventSetup &eSetup) {
0021   getConditionObject(eSetup);
0022   condObj_->getDetIds(activeDetIds);
0023 }
0024 
0025 void SiStripNoisesDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
0026   ModMEs selModME_ = _selModME_;
0027   std::vector<uint32_t> DetIds;
0028   condObj_->getDetIds(DetIds);
0029 
0030   const auto noiseRange = condObj_->getRange(selDetId_);
0031 
0032   int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
0033 
0034   getModMEs(selModME_, selDetId_);
0035 
0036   float gainFactor;
0037   float stripnoise;
0038 
0039   SiStripApvGain::Range gainRange;
0040   if (gainHandle_) {
0041     gainRange = gainHandle_->getRange(selDetId_);
0042   }
0043 
0044   for (int istrip = 0; istrip < nStrip; ++istrip) {
0045     if (gainHandle_)
0046       gainFactor = gainHandle_->getStripGain(istrip, gainRange) ? gainHandle_->getStripGain(istrip, gainRange) : 1.;
0047     else
0048       gainFactor = 1;
0049 
0050     stripnoise = condObj_->getNoise(istrip, noiseRange) / gainFactor;
0051     if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
0052       selModME_.ProfileDistr->Fill(istrip + 1, stripnoise);
0053     }
0054     if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
0055       selModME_.CumulDistr->Fill(stripnoise);
0056     }
0057   }  // istrip
0058 }
0059 
0060 // -----
0061 // FIXME too long. factorize this method.
0062 // FIXME the number of lines of code in the derived classes should be reduced
0063 // ONLY at what cannot be done in the base class because of the specific
0064 // implementation
0065 // FIXME of the derived class. Moreover, several loops on the same quantities
0066 // should be avoided...
0067 
0068 void SiStripNoisesDQM::fillMEsForLayer(
0069     /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_) {
0070   // ----
0071   int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
0072 
0073   if (subdetectorId_ < 3 || subdetectorId_ > 6) {
0074     edm::LogError("SiStripNoisesDQM") << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such "
0075                                          "subdetector type : "
0076                                       << subdetectorId_ << " no folder set!" << std::endl;
0077     return;
0078   }
0079   // ----
0080 
0081   const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
0082   ModMEs selME_;
0083   if (selMEsMapIter_ != SummaryMEsMap_.end())
0084     selME_ = selMEsMapIter_->second;
0085   getSummaryMEs(selME_, selDetId_);
0086 
0087   const auto noiseRange = condObj_->getRange(selDetId_);
0088   int nStrip = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first * 128;
0089 
0090   float stripnoise = -1.;
0091   float meanNoise = 0;
0092   int Nbadstrips = 0;
0093 
0094   SiStripApvGain::Range gainRange;
0095   if (gainHandle_) {
0096     gainRange = gainHandle_->getRange(selDetId_);
0097   }
0098   float gainFactor = 1;
0099 
0100   SiStripHistoId hidmanager;
0101 
0102   if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
0103     // --> profile summary
0104     std::string hSummaryOfProfile_description;
0105     hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
0106 
0107     std::string hSummaryOfProfile_name;
0108     hSummaryOfProfile_name =
0109         hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
0110   }
0111   if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")) {
0112     std::string hSummaryOfCumul_description;
0113     hSummaryOfCumul_description = hPSet_.getParameter<std::string>("Cumul_description");
0114 
0115     std::string hSummaryOfCumul_name;
0116     hSummaryOfCumul_name =
0117         hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "");
0118   }
0119   if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
0120     // --> cumul summary
0121     std::string hSummary_description;
0122     hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
0123 
0124     std::string hSummary_name;
0125     hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
0126   }
0127 
0128   for (int istrip = 0; istrip < nStrip; ++istrip) {
0129     if (gainHandle_) {
0130       gainFactor = gainHandle_->getStripGain(istrip, gainRange) ? gainHandle_->getStripGain(istrip, gainRange) : 1.;
0131     } else {
0132       gainFactor = 1.;
0133     }
0134 
0135     stripnoise = condObj_->getNoise(istrip, noiseRange) / gainFactor;
0136     meanNoise += stripnoise;
0137     if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
0138       if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
0139         selME_.SummaryOfProfileDistr->Fill(istrip + 1, stripnoise);
0140       }
0141     }
0142 
0143     if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")) {
0144       if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
0145         selME_.SummaryOfCumulDistr->Fill(stripnoise);
0146       }
0147     }
0148 
0149     // Fill the TkMap
0150     if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
0151       fillTkMap(selDetId_, stripnoise);
0152     }
0153 
0154   }  // istrip
0155 
0156   if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
0157     meanNoise = meanNoise / (nStrip - Nbadstrips);
0158     // get detIds belonging to same layer to fill X-axis with detId-number
0159 
0160     std::vector<uint32_t> sameLayerDetIds_;
0161     sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
0162 
0163     std::vector<uint32_t>::const_iterator ibound =
0164         lower_bound(sameLayerDetIds_.begin(), sameLayerDetIds_.end(), selDetId_);
0165     if (ibound != sameLayerDetIds_.end() && *ibound == selDetId_)
0166       selME_.SummaryDistr->Fill(ibound - sameLayerDetIds_.begin() + 1, meanNoise);
0167 
0168     // Fill the Histo_TkMap with the mean Noise:
0169     if (HistoMaps_On_) {
0170       Tk_HM_->fill(selDetId_, meanNoise);
0171     }
0172 
0173     // Check the axis range for tkmap, and in case redefine;
0174     int intNoise = int(meanNoise);
0175     if (intNoise + 1 > (int)tkMapScaler.size()) {
0176       tkMapScaler.resize(intNoise + 1, 0);
0177     }
0178     tkMapScaler[intNoise]++;
0179   }
0180 }