CMS 3D CMS Logo

SiStripThresholdDQM.cc
Go to the documentation of this file.
4 
5 #include "TCanvas.h"
6 
7 // -----
9  edm::RunNumber_t iRun,
10  edm::ParameterSet const &hPSet,
11  edm::ParameterSet const &fPSet)
12  : SiStripBaseCondObjDQM(eSetup, iRun, hPSet, fPSet) {
13  WhichThreshold = hPSet.getParameter<std::string>("WhichThreshold");
14 
15  // Build the Histo_TkMap:
16  if (HistoMaps_On_) {
17  edm::ESHandle<TkDetMap> tkDetMapHandle;
18  eSetup.get<TrackerTopologyRcd>().get(tkDetMapHandle);
19  const TkDetMap *tkDetMap = tkDetMapHandle.product();
20  if (WhichThreshold == "Low")
21  Tk_HM_L = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "LowThresh_TkMap", 0.);
22  if (WhichThreshold == "High")
23  Tk_HM_H = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "HighThresh_TkMap", 0.);
24  }
25 }
26 
27 // -----
28 
29 // -----
31 // -----
32 
33 // -----
35  getConditionObject(eSetup);
37 }
38 // -----
39 
40 //=====================================================================================
41 
42 // -----
43 void SiStripThresholdDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds, const edm::EventSetup &es) {
44  // Retrieve tracker topology from geometry
46  es.get<TrackerTopologyRcd>().get(tTopoHandle);
47  const TrackerTopology *const tTopo = tTopoHandle.product();
48 
49  ModMEs CondObj_ME;
50 
51  for (std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin(); detIter_ != selectedDetIds.end();
52  detIter_++) {
53  fillMEsForDet(CondObj_ME, *detIter_, tTopo);
54  }
55 }
56 // -----
57 
58 //======================================================================================
59 // -----
60 
61 void SiStripThresholdDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_, const TrackerTopology *tTopo) {
62  ModMEs selModME_ = _selModME_;
63  std::vector<uint32_t> DetIds;
64  thresholdHandle_->getDetIds(DetIds);
65 
66  SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
67  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first * 128;
68 
69  getModMEs(selModME_, selDetId_, tTopo);
70 
71  for (int istrip = 0; istrip < nStrip; ++istrip) {
72  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
73  if (WhichThreshold == "Low")
74  selModME_.ProfileDistr->Fill(istrip + 1, thresholdHandle_->getData(istrip, ThresholdRange).getLth());
75  if (WhichThreshold == "High")
76  selModME_.ProfileDistr->Fill(istrip + 1, thresholdHandle_->getData(istrip, ThresholdRange).getHth());
77  }
78  } // istrip
79 }
80 
81 // -----
82 
83 //=======================================================================================
84 // -----
85 void SiStripThresholdDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds, const edm::EventSetup &es) {
86  // Retrieve tracker topology from geometry
88  es.get<TrackerTopologyRcd>().get(tTopoHandle);
89  const TrackerTopology *const tTopo = tTopoHandle.product();
90 
91  for (std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin(); detIter_ != selectedDetIds.end();
92  detIter_++) {
93  fillMEsForLayer(/*SummaryMEsMap_,*/ *detIter_, tTopo);
94  }
95 }
96 // -----
97 
98 //=======================================================================================
99 // -----
101  /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_, const TrackerTopology *tTopo) {
102  // ----
103  int subdetectorId_ = ((selDetId_ >> 25) & 0x7);
104 
105  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
106  edm::LogError("SiStripThresholdDQM") << "[SiStripThresholdDQM::fillMEsForLayer] WRONG INPUT : no such "
107  "subdetector type : "
108  << subdetectorId_ << " no folder set!" << std::endl;
109  return;
110  }
111  // ----
112 
113  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_, tTopo).second);
114  ModMEs selME_;
115  if (selMEsMapIter_ != SummaryMEsMap_.end())
116  selME_ = selMEsMapIter_->second;
117 
118  getSummaryMEs(selME_, selDetId_, tTopo);
119 
120  SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
121 
122  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first * 128;
123 
125 
126  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")) {
127  // --> profile summary
128 
129  std::string hSummaryOfProfile_description;
130  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
131 
132  std::string hSummaryOfProfile_name;
133 
134  hSummaryOfProfile_name = hidmanager.createHistoLayer(
135  hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_, tTopo).first, "");
136 
137  for (int istrip = 0; istrip < nStrip; ++istrip) {
138  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
139  if (WhichThreshold == "Low") {
140  selME_.SummaryOfProfileDistr->Fill(istrip + 1, thresholdHandle_->getData(istrip, ThresholdRange).getLth());
141  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On"))
142  fillTkMap(selDetId_, thresholdHandle_->getData(istrip, ThresholdRange).getLth());
143  }
144  if (WhichThreshold == "High") {
145  selME_.SummaryOfProfileDistr->Fill(istrip + 1, thresholdHandle_->getData(istrip, ThresholdRange).getHth());
146  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On"))
147  fillTkMap(selDetId_, thresholdHandle_->getData(istrip, ThresholdRange).getHth());
148  }
149  }
150  } // istrip
151 
152  } // if Fill
153 
154  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
155  // --> summary
156 
157  std::string hSummary_description;
158  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
159 
160  std::string hSummary_name;
161  hSummary_name =
162  hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_, tTopo).first, "");
163 
164  float meanLowThreshold = 0;
165  float meanHighThreshold = 0;
166 
167  for (int istrip = 0; istrip < nStrip; ++istrip) {
168  meanLowThreshold = meanLowThreshold + thresholdHandle_->getData(istrip, ThresholdRange).getLth();
169  meanHighThreshold = meanHighThreshold + thresholdHandle_->getData(istrip, ThresholdRange).getHth();
170  } // istrip
171 
172  meanLowThreshold = meanLowThreshold / nStrip;
173  meanHighThreshold = meanHighThreshold / nStrip;
174 
175  // -----
176  // get detIds belonging to same layer to fill X-axis with detId-number
177 
178  std::vector<uint32_t> sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_, tTopo);
179 
180  unsigned int iBin = 0;
181  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
182  if (sameLayerDetIds_[i] == selDetId_) {
183  iBin = i + 1;
184  }
185  }
186 
187  if (WhichThreshold == "Low") {
188  selME_.SummaryDistr->Fill(iBin, meanLowThreshold);
189  if (HistoMaps_On_)
190  Tk_HM_L->fill(selDetId_, meanLowThreshold);
191  }
192  if (WhichThreshold == "High") {
193  selME_.SummaryDistr->Fill(iBin, meanHighThreshold);
194  if (HistoMaps_On_)
195  Tk_HM_H->fill(selDetId_, meanHighThreshold);
196  }
197 
198  } // if Fill ...
199 }
200 // -----
std::unique_ptr< TkHistoMap > Tk_HM_L
T getParameter(std::string const &) const
void getConditionObject(const edm::EventSetup &eSetup) override
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::unique_ptr< TkHistoMap > Tk_HM_H
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
edm::ESHandle< SiStripThreshold > thresholdHandle_
void fillTkMap(const uint32_t &detid, const float &value)
void Fill(long long x)
U second(std::pair< T, U > const &p)
std::map< uint32_t, ModMEs > SummaryMEsMap_
SiStripDetInfoFileReader * reader
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es) override
void getActiveDetIds(const edm::EventSetup &eSetup) override
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId, const TrackerTopology *tTopo)
SiStripThreshold::Data getData(const uint16_t &strip, const Range &range) const
void fillModMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es) override
std::pair< ContainerIterator, ContainerIterator > Range
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_, const TrackerTopology *tTopo)
T get() const
Definition: EventSetup.h:71
std::vector< uint32_t > activeDetIds
void fillMEsForLayer(uint32_t selDetId_, const TrackerTopology *tTopo) override
unsigned int RunNumber_t
SiStripThresholdDQM(const edm::EventSetup &eSetup, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
const Range getRange(const uint32_t &detID) const
T const * product() const
Definition: ESHandle.h:86
void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_, const TrackerTopology *tTopo) override