Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-05 04:09:42

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