File indexing completed on 2023-03-17 10:57:00
0001 #include "DQM/SiStripMonitorSummary/interface/SiStripApvGainsDQM.h"
0002
0003 #include "TCanvas.h"
0004
0005 SiStripApvGainsDQM::SiStripApvGainsDQM(edm::ESGetToken<SiStripApvGain, SiStripApvGainRcd> token,
0006 edm::RunNumber_t iRun,
0007 edm::ParameterSet const &hPSet,
0008 edm::ParameterSet const &fPSet,
0009 const TrackerTopology *tTopo,
0010 const TkDetMap *tkDetMap)
0011 : SiStripBaseCondObjDQMGet<SiStripApvGain, SiStripApvGainRcd>{token, iRun, hPSet, fPSet, tTopo} {
0012 if (HistoMaps_On_) {
0013 Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "MeanApvGain_TkMap", 0.);
0014 }
0015 }
0016
0017 SiStripApvGainsDQM::~SiStripApvGainsDQM() {}
0018
0019 void SiStripApvGainsDQM::getActiveDetIds(const edm::EventSetup &eSetup) {
0020 getConditionObject(eSetup);
0021 condObj_->getDetIds(activeDetIds);
0022 }
0023
0024 void SiStripApvGainsDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
0025 ModMEs CondObj_ME;
0026 for (const auto detIter : selectedDetIds) {
0027 fillMEsForDet(CondObj_ME, detIter);
0028 }
0029 }
0030
0031 void SiStripApvGainsDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
0032 ModMEs selModME_ = _selModME_;
0033 std::vector<uint32_t> DetIds;
0034 condObj_->getDetIds(DetIds);
0035
0036 const auto gainRange = condObj_->getRange(selDetId_);
0037
0038 int nApv = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first;
0039
0040 getModMEs(selModME_, selDetId_);
0041
0042 for (int iapv = 0; iapv < nApv; ++iapv) {
0043 if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
0044 selModME_.ProfileDistr->Fill(iapv + 1, condObj_->getApvGain(iapv, gainRange));
0045 }
0046 if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
0047 selModME_.CumulDistr->Fill(condObj_->getApvGain(iapv, gainRange));
0048 }
0049
0050
0051 if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
0052 fillTkMap(selDetId_, condObj_->getApvGain(iapv, gainRange));
0053 }
0054 }
0055 }
0056
0057 void SiStripApvGainsDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
0058 for (const auto det : selectedDetIds) {
0059 fillMEsForLayer( det);
0060 }
0061
0062 for (const auto &itm : SummaryMEsMap_) {
0063 ModMEs selME = itm.second;
0064 if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") &&
0065 fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")) {
0066 TCanvas c1("c1");
0067 selME.SummaryOfProfileDistr->getTProfile()->Draw();
0068 std::string name(selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
0069 name += ".png";
0070 c1.Print(name.c_str());
0071 }
0072 if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") &&
0073 fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
0074 TCanvas c1("c1");
0075 selME.SummaryDistr->getTH1()->Draw();
0076 std::string name(selME.SummaryDistr->getTitle());
0077 name += ".png";
0078 c1.Print(name.c_str());
0079 }
0080 }
0081 }
0082
0083 void SiStripApvGainsDQM::fillMEsForLayer(
0084 uint32_t selDetId_) {
0085 int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
0086
0087 if (subdetectorId_ < 3 || subdetectorId_ > 6) {
0088 edm::LogError("SiStripApvGainsDQM") << "[SiStripApvGainsDQM::fillMEsForLayer] WRONG INPUT : no such "
0089 "subdetector type : "
0090 << subdetectorId_ << " no folder set!" << std::endl;
0091 return;
0092 }
0093
0094
0095 const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
0096 ModMEs selME_;
0097 if (selMEsMapIter_ != SummaryMEsMap_.end())
0098 selME_ = selMEsMapIter_->second;
0099 getSummaryMEs(selME_, selDetId_);
0100
0101 const auto gainRange = condObj_->getRange(selDetId_);
0102 int nApv = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first;
0103
0104 float meanApvGain = 0;
0105
0106 SiStripHistoId hidmanager;
0107
0108 if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
0109
0110 std::string hSummaryOfProfile_description;
0111 hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
0112
0113 std::string hSummaryOfProfile_name;
0114 hSummaryOfProfile_name =
0115 hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
0116
0117 for (int iapv = 0; iapv < nApv; ++iapv) {
0118 meanApvGain = meanApvGain + condObj_->getApvGain(iapv, gainRange);
0119 selME_.SummaryOfProfileDistr->Fill(iapv + 1, condObj_->getApvGain(iapv, gainRange));
0120
0121
0122 if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
0123 fillTkMap(selDetId_, condObj_->getApvGain(iapv, gainRange));
0124 }
0125
0126 }
0127
0128 meanApvGain = meanApvGain / nApv;
0129
0130
0131 if (HistoMaps_On_)
0132 Tk_HM_->setBinContent(selDetId_, meanApvGain);
0133
0134 }
0135
0136 if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
0137
0138 std::string hSummary_description;
0139 hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
0140
0141 std::string hSummary_name;
0142 hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
0143
0144
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 for (int iapv = 0; iapv < nApv; ++iapv) {
0160 meanApvGain = meanApvGain + condObj_->getApvGain(iapv, gainRange);
0161 selME_.SummaryDistr->Fill(iBin, condObj_->getApvGain(iapv, gainRange));
0162 }
0163 meanApvGain = meanApvGain / nApv;
0164
0165
0166
0167
0168 }
0169 }