CMS 3D CMS Logo

SiStripApvGainsDQM.cc
Go to the documentation of this file.
2 
3 #include "TCanvas.h"
4 
6  edm::RunNumber_t iRun,
7  edm::ParameterSet const &hPSet,
8  edm::ParameterSet const &fPSet,
9  const TrackerTopology *tTopo,
10  const TkDetMap *tkDetMap)
11  : SiStripBaseCondObjDQMGet<SiStripApvGain, SiStripApvGainRcd>{token, iRun, hPSet, fPSet, tTopo} {
12  if (HistoMaps_On_) {
13  Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "MeanApvGain_TkMap", 0.);
14  }
15 }
16 
18 
20  getConditionObject(eSetup);
22 }
23 
24 void SiStripApvGainsDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
25  ModMEs CondObj_ME;
26  for (const auto detIter : selectedDetIds) {
27  fillMEsForDet(CondObj_ME, detIter);
28  }
29 }
30 
31 void SiStripApvGainsDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
32  ModMEs selModME_ = _selModME_;
33  std::vector<uint32_t> DetIds;
34  condObj_->getDetIds(DetIds);
35 
36  const auto gainRange = condObj_->getRange(selDetId_);
37 
38  int nApv = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first;
39 
40  getModMEs(selModME_, selDetId_);
41 
42  for (int iapv = 0; iapv < nApv; ++iapv) {
43  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
44  selModME_.ProfileDistr->Fill(iapv + 1, condObj_->getApvGain(iapv, gainRange));
45  }
46  if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
47  selModME_.CumulDistr->Fill(condObj_->getApvGain(iapv, gainRange));
48  }
49 
50  // Fill the TkMap
51  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
52  fillTkMap(selDetId_, condObj_->getApvGain(iapv, gainRange));
53  }
54  }
55 }
56 
57 void SiStripApvGainsDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
58  for (const auto det : selectedDetIds) {
59  fillMEsForLayer(/*SummaryMEsMap_,*/ det);
60  }
61 
62  for (const auto &itm : SummaryMEsMap_) {
63  ModMEs selME = itm.second;
64  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") &&
65  fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")) {
66  TCanvas c1("c1");
67  selME.SummaryOfProfileDistr->getTProfile()->Draw();
68  std::string name(selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
69  name += ".png";
70  c1.Print(name.c_str());
71  }
72  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") &&
73  fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
74  TCanvas c1("c1");
75  selME.SummaryDistr->getTH1()->Draw();
77  name += ".png";
78  c1.Print(name.c_str());
79  }
80  }
81 }
82 
84  /*std::map<uint32_t, ModMEs> selMEsMap_, */ uint32_t selDetId_) {
85  int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
86 
87  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
88  edm::LogError("SiStripApvGainsDQM") << "[SiStripApvGainsDQM::fillMEsForLayer] WRONG INPUT : no such "
89  "subdetector type : "
90  << subdetectorId_ << " no folder set!" << std::endl;
91  return;
92  }
93  // ----
94 
95  const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
96  ModMEs selME_;
97  if (selMEsMapIter_ != SummaryMEsMap_.end())
98  selME_ = selMEsMapIter_->second;
99  getSummaryMEs(selME_, selDetId_);
100 
101  const auto gainRange = condObj_->getRange(selDetId_);
102  int nApv = detInfo_.getNumberOfApvsAndStripLength(selDetId_).first;
103 
104  float meanApvGain = 0;
105 
107 
108  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
109  // --> profile summary
110  std::string hSummaryOfProfile_description;
111  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
112 
113  std::string hSummaryOfProfile_name;
114  hSummaryOfProfile_name =
115  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "");
116 
117  for (int iapv = 0; iapv < nApv; ++iapv) {
118  meanApvGain = meanApvGain + condObj_->getApvGain(iapv, gainRange);
119  selME_.SummaryOfProfileDistr->Fill(iapv + 1, condObj_->getApvGain(iapv, gainRange));
120 
121  // Fill the TkMap
122  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
123  fillTkMap(selDetId_, condObj_->getApvGain(iapv, gainRange));
124  }
125 
126  } // iapv
127 
128  meanApvGain = meanApvGain / nApv;
129 
130  // Fill the TkHistoMap with meanApvgain:
131  if (HistoMaps_On_)
132  Tk_HM_->setBinContent(selDetId_, meanApvGain);
133 
134  } // if Fill ...
135 
136  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
137  // --> summary
138  std::string hSummary_description;
139  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
140 
141  std::string hSummary_name;
142  hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
143 
144  // get detIds belonging to same layer to fill X-axis with detId-number
145 
146  std::vector<uint32_t> sameLayerDetIds_;
147 
148  sameLayerDetIds_.clear();
149 
150  sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
151 
152  unsigned int iBin = 0;
153  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
154  if (sameLayerDetIds_[i] == selDetId_) {
155  iBin = i + 1;
156  }
157  }
158 
159  for (int iapv = 0; iapv < nApv; ++iapv) {
160  meanApvGain = meanApvGain + condObj_->getApvGain(iapv, gainRange);
161  selME_.SummaryDistr->Fill(iBin, condObj_->getApvGain(iapv, gainRange));
162  } // iapv
163  meanApvGain = meanApvGain / nApv;
164 
165  // Fill the TkHistoMap with meanApvgain:
166  // if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
167 
168  } // if Fill ...
169 }
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
virtual TProfile * getTProfile() const
void fillMEsForLayer(uint32_t selDetId_) override
static float getApvGain(uint16_t apv, const Range &range)
~SiStripApvGainsDQM() override
Log< level::Error, false > LogError
void fillTkMap(const uint32_t &detid, const float &value)
void Fill(long long x)
U second(std::pair< T, U > const &p)
void getActiveDetIds(const edm::EventSetup &eSetup) override
std::map< uint32_t, ModMEs > SummaryMEsMap_
void getDetIds(std::vector< uint32_t > &DetIds_) const
SiStripApvGainsDQM(edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > token, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet, const TrackerTopology *tTopo, const TkDetMap *tkDetMap)
void fillModMEs(const std::vector< uint32_t > &selectedDetIds) override
virtual std::string getTitle() const
get MonitorElement title
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void getConditionObject(const edm::EventSetup &eSetup) override
void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_) override
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
virtual TH1 * getTH1() const
const Range getRange(const uint32_t detID) const
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId)
std::vector< uint32_t > activeDetIds
unsigned int RunNumber_t
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds) override
std::unique_ptr< TkHistoMap > Tk_HM_