CMS 3D CMS Logo

SiStripBaseCondObjDQM.cc
Go to the documentation of this file.
6 
7 #include "TCanvas.h"
8 
10  edm::ParameterSet const &hPSet,
11  edm::ParameterSet const &fPSet,
12  const TrackerTopology *tTopo)
13  : hPSet_(hPSet), fPSet_(fPSet), tTopo_(tTopo), dqmStore_(edm::Service<DQMStore>().operator->()), runNumber_(iRun) {
14  detInfo_ =
16 
17  Mod_On_ = fPSet_.getParameter<bool>("Mod_On");
18  HistoMaps_On_ = fPSet_.getParameter<bool>("HistoMaps_On");
19  SummaryOnLayerLevel_On_ = fPSet_.getParameter<bool>("SummaryOnLayerLevel_On");
20  SummaryOnStringLevel_On_ = fPSet_.getParameter<bool>("SummaryOnStringLevel_On");
21 
22  GrandSummary_On_ = fPSet_.getParameter<bool>("GrandSummary_On");
23 
24  CondObj_fillId_ = hPSet_.getParameter<std::string>("CondObj_fillId");
25  CondObj_name_ = hPSet_.getParameter<std::string>("CondObj_name");
26 
27  // Warning message from wrong input:
29  edm::LogWarning("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::SiStripBaseCondObjDQMs] PLEASE CHECK : "
30  "String and layer level options can not be activated together"
31  << std::endl;
32  }
33 
34  // The OR of the two conditions allow to switch on this feature for all the
35  // components (if the FillConditions_PSet has the TkMap_On =true) or for
36  // single MEs (if the PSet for a ME has the TkMap_On =true)
37  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On"))
39 
40  minValue = hPSet_.getParameter<double>("minValue");
41  maxValue = hPSet_.getParameter<double>("maxValue");
42 }
43 
45  if (checkChanged(eSetup_)) {
46  getConditionObject(eSetup_);
47 
48  // The OR of the two conditions allows to switch on this feature for all the
49  // components (if the FillConditions_PSet has the ActiveDetIds_On =true) or
50  // for single MEs (if the PSet for a ME has the ActiveDetIds_On =true)
51  if (fPSet_.getParameter<bool>("ActiveDetIds_On") || hPSet_.getParameter<bool>("ActiveDetIds_On"))
52  getActiveDetIds(eSetup_);
53  else
55 
57 
58  if (Mod_On_) {
60  }
63  }
64 
65  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
67  if (!filename.empty()) {
68  constexpr unsigned int kSLen = 128;
69  char sRun[kSLen];
70  snprintf(sRun, kSLen, "_Run_%d", runNumber_);
71  filename.insert(filename.find('.'), sRun);
72 
74  }
75  }
76  }
77 }
78 
80  std::string requestedSubDetector,
81  uint32_t requestedSide,
82  uint32_t requestedLayer) {
83  getConditionObject(eSetup_);
84  getActiveDetIds(eSetup_);
85 
86  std::vector<uint32_t> requestedDetIds_;
87  requestedDetIds_.clear();
88 
89  if (requestedSubDetector == "TIB") {
90  SiStripSubStructure::getTIBDetectors(activeDetIds, requestedDetIds_, tTopo_, requestedLayer, 0, 0, 0);
91  } else if (requestedSubDetector == "TID") {
92  SiStripSubStructure::getTIDDetectors(activeDetIds, requestedDetIds_, tTopo_, requestedSide, requestedLayer, 0, 0);
93  } else if (requestedSubDetector == "TOB") {
94  SiStripSubStructure::getTOBDetectors(activeDetIds, requestedDetIds_, tTopo_, requestedLayer, 0, 0);
95  } else if (requestedSubDetector == "TEC") {
97  activeDetIds, requestedDetIds_, tTopo_, requestedSide, requestedLayer, 0, 0, 0, 0);
98  }
99 
100  analysisOnDemand(eSetup_, requestedDetIds_);
101 }
102 
103 void SiStripBaseCondObjDQM::analysisOnDemand(const edm::EventSetup &eSetup_, uint32_t detIdOnDemand) {
104  if (checkChanged(eSetup_)) {
105  getConditionObject(eSetup_);
106 
107  std::vector<uint32_t> vdetIdsOnDemand_;
108  vdetIdsOnDemand_.push_back(detIdOnDemand); // fillModMEs needs a vector
109 
110  fillModMEs(vdetIdsOnDemand_);
111  }
112 }
113 
115  const std::vector<uint32_t> &detIdsOnDemand) {
116  if (checkChanged(eSetup_)) {
117  getConditionObject(eSetup_);
118  fillSummaryMEs(detIdsOnDemand);
119  }
120 }
121 
122 //#FIXME : very long method. please factorize it
123 void SiStripBaseCondObjDQM::selectModules(std::vector<uint32_t> &detIds_) {
124  edm::LogInfo("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::selectModules] input detIds_: " << detIds_.size()
125  << std::endl;
126 
127  if (fPSet_.getParameter<bool>("restrictModules")) {
128  std::vector<DetIdSelector> included_subdetsels;
129  std::vector<std::string> included_subdets =
130  fPSet_.getParameter<std::vector<std::string>>("ModulesToBeIncluded_DetIdSelector");
131  for (std::vector<std::string>::const_iterator wsdps = included_subdets.begin(); wsdps != included_subdets.end();
132  ++wsdps) {
133  included_subdetsels.push_back(DetIdSelector(*wsdps));
134  }
135 
136  std::vector<uint32_t> modulesToBeIncluded;
137  for (const auto detid : detIds_) {
138  for (const auto &detidsel : included_subdetsels) {
139  if (detidsel.isSelected(detid)) {
140  modulesToBeIncluded.push_back(detid);
141  break;
142  // std::cout << "detId: " << *detid << " is selected" <<
143  // std::endl;
144  }
145  }
146  }
147 
148  // -----
149  // *** exclude modules ***
150  std::vector<DetIdSelector> excluded_subdetsels;
151  std::vector<std::string> excluded_subdets =
152  fPSet_.getParameter<std::vector<std::string>>("ModulesToBeExcluded_DetIdSelector");
153  excluded_subdetsels.reserve(excluded_subdets.size());
154  for (const auto &wsdps : excluded_subdets) {
155  excluded_subdetsels.push_back(DetIdSelector(wsdps));
156  }
157 
158  std::vector<uint32_t> modulesToBeExcluded;
159  for (const auto detid : detIds_) {
160  for (const auto &detidsel : excluded_subdetsels) {
161  if (detidsel.isSelected(detid)) {
162  modulesToBeExcluded.push_back(detid);
163  break;
164  }
165  }
166  }
167 
168  ModulesToBeExcluded_ = fPSet_.getParameter<std::vector<unsigned int>>("ModulesToBeExcluded");
169  ModulesToBeIncluded_ = fPSet_.getParameter<std::vector<unsigned int>>("ModulesToBeIncluded");
170  SubDetectorsToBeExcluded_ = fPSet_.getParameter<std::vector<std::string>>("SubDetectorsToBeExcluded");
171 
172  // vectors to be sorted otherwise the intersection is non computed properly
173 
176 
177  if (modulesToBeExcluded.empty() && modulesToBeIncluded.empty() && ModulesToBeExcluded_.empty() &&
178  ModulesToBeIncluded_.empty())
179  edm::LogWarning("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::selectModules] PLEASE CHECK : no modules "
180  "to be exclude/included in your cfg"
181  << std::endl;
182 
183  modulesToBeIncluded.insert(modulesToBeIncluded.end(), ModulesToBeIncluded_.begin(), ModulesToBeIncluded_.end());
184  edm::LogInfo("SiStripBaseCondObjDQM")
185  << "[SiStripBaseCondObjDQM::selectModules] modulesToBeIncluded: " << modulesToBeIncluded.size() << std::endl;
186  modulesToBeExcluded.insert(modulesToBeExcluded.end(), ModulesToBeExcluded_.begin(), ModulesToBeExcluded_.end());
187  edm::LogInfo("SiStripBaseCondObjDQM")
188  << "[SiStripBaseCondObjDQM::selectModules] modulesToBeExcluded: " << modulesToBeExcluded.size() << std::endl;
189 
190  // apply modules selection
191  if (!modulesToBeIncluded.empty()) {
192  std::vector<uint32_t> tmp;
193  // The intersection of two sets is formed only by the elements that are
194  // present in both sets
195  set_intersection(detIds_.begin(),
196  detIds_.end(),
197  modulesToBeIncluded.begin(),
198  modulesToBeIncluded.end(),
199  inserter(tmp, tmp.begin()));
200  swap(detIds_, tmp);
201  }
202 
203  std::sort(detIds_.begin(), detIds_.end());
204  if (!modulesToBeExcluded.empty()) {
205  for (const auto mod : modulesToBeExcluded) {
206  auto detid = std::lower_bound(detIds_.begin(), detIds_.end(), mod);
207  if (detid != detIds_.end())
208  detIds_.erase(detid);
209  detid--;
210  }
211  }
212 
213  // -----
214  // *** restrict to a particular subdetector ***
215 
216  if (*(SubDetectorsToBeExcluded_.begin()) != "none") {
217  std::vector<uint32_t> tmp;
218 
219  for (const auto &mod : SubDetectorsToBeExcluded_) {
220  tmp.clear();
221 
222  if (mod == "TIB") {
223  SiStripSubStructure::getTIBDetectors(detIds_, tmp, tTopo_, 0, 0, 0, 0);
224  } else if (mod == "TOB") {
225  SiStripSubStructure::getTOBDetectors(detIds_, tmp, tTopo_, 0, 0, 0);
226  } else if (mod == "TID") {
227  SiStripSubStructure::getTIDDetectors(detIds_, tmp, tTopo_, 0, 0, 0, 0);
228  } else if (mod == "TEC") {
229  SiStripSubStructure::getTECDetectors(detIds_, tmp, tTopo_, 0, 0, 0, 0, 0, 0);
230  } else {
231  edm::LogWarning("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::selectModules] PLEASE CHECK : no "
232  "correct (name) subdetector to be excluded in your cfg"
233  << std::endl;
234  }
235 
236  const auto iterBegin_ = std::lower_bound(detIds_.begin(), detIds_.end(), *min_element(tmp.begin(), tmp.end()));
237 
238  const auto iterEnd_ = std::lower_bound(detIds_.begin(), detIds_.end(), *max_element(tmp.begin(), tmp.end()));
239 
240  for (auto detIter_ = iterEnd_; detIter_ != iterBegin_ - 1; detIter_--) {
241  detIds_.erase(detIter_);
242  }
243 
244  } // loop SubDetectorsToBeExcluded_
245  }
246  }
247  edm::LogInfo("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::selectModules] output detIds_: " << detIds_.size()
248  << std::endl;
249 
250  // -----
251  // *** fill only one Module per layer ***
252 
253  if (fPSet_.getParameter<std::string>("ModulesToBeFilled") == "onlyOneModulePerLayer") {
254  std::vector<uint32_t> tmp;
255  std::vector<uint32_t> layerDetIds;
256 
257  for (unsigned int i = 1; i < 5; i++) {
258  tmp.clear();
259  SiStripSubStructure::getTIBDetectors(detIds_, tmp, tTopo_, i, 0, 0, 0);
260  if (!tmp.empty()) {
261  layerDetIds.push_back(*(tmp.begin()));
262  }
263  }
264  for (unsigned int i = 1; i < 7; i++) {
265  tmp.clear();
267  if (!tmp.empty()) {
268  layerDetIds.push_back(*(tmp.begin()));
269  }
270  }
271  for (unsigned int i = 1; i < 4; i++) {
272  tmp.clear();
273  SiStripSubStructure::getTIDDetectors(detIds_, tmp, tTopo_, 1, i, 0, 0);
274  if (!tmp.empty()) {
275  layerDetIds.push_back(*(tmp.begin()));
276  }
277  SiStripSubStructure::getTIDDetectors(detIds_, tmp, tTopo_, 2, i, 0, 0);
278  if (!tmp.empty()) {
279  layerDetIds.push_back(*(tmp.begin()));
280  }
281  }
282  for (unsigned int i = 1; i < 10; i++) {
283  tmp.clear();
284  SiStripSubStructure::getTECDetectors(detIds_, tmp, tTopo_, 1, i, 0, 0, 0, 0);
285  if (!tmp.empty()) {
286  layerDetIds.push_back(*(tmp.begin()));
287  }
288  SiStripSubStructure::getTECDetectors(detIds_, tmp, tTopo_, 2, i, 0, 0, 0, 0);
289  if (!tmp.empty()) {
290  layerDetIds.push_back(*(tmp.begin()));
291  }
292  }
293 
294  detIds_.clear();
295  detIds_ = layerDetIds;
296  }
297  // -----
298 
299 } // selectModules
300 
301 void SiStripBaseCondObjDQM::getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_) {
302  const auto ModMEsMap_iter = ModMEsMap_.find(detId_);
303 
304  if (ModMEsMap_iter != ModMEsMap_.end()) {
305  CondObj_ME = ModMEsMap_iter->second;
306 
307  if ((CondObj_fillId_ == "ProfileAndCumul" || CondObj_fillId_ == "onlyProfile") && CondObj_ME.ProfileDistr) {
308  CondObj_ME.ProfileDistr->Reset();
309  }
310 
311  if ((CondObj_fillId_ == "ProfileAndCumul" || CondObj_fillId_ == "onlyCumul") && CondObj_ME.CumulDistr) {
312  CondObj_ME.CumulDistr->Reset();
313  } else {
314  edm::LogWarning("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::getModMEs] PLEASE CHECK : CondObj_fillId "
315  "option mispelled";
316  }
317  return;
318  }
319 
320  // --> profile defined for all CondData
321  if ((CondObj_fillId_ == "ProfileAndCumul" || CondObj_fillId_ == "onlyProfile")) {
322  bookProfileMEs(CondObj_ME, detId_);
323  }
324 
325  // --> cumul currently only defined for noise and apvgain
326  if ((CondObj_fillId_ == "ProfileAndCumul" || CondObj_fillId_ == "onlyCumul") &&
327  (CondObj_name_ == "noise" || CondObj_name_ == "apvgain"))
328  bookCumulMEs(CondObj_ME, detId_);
329 
330  ModMEsMap_.insert(std::make_pair(detId_, CondObj_ME));
331 }
332 
333 //%FIXME: very long method, factorize
334 void SiStripBaseCondObjDQM::getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_) {
335  std::map<uint32_t, ModMEs>::const_iterator SummaryMEsMap_iter;
336 
337  if (CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) {
338  SummaryMEsMap_iter = SummaryMEsMap_.find(getStringNameAndId(detId_).second);
339  } else if (CondObj_name_ == "bpcorrection" && SummaryOnStringLevel_On_) {
340  SummaryMEsMap_iter = SummaryMEsMap_.find(getStringNameAndId(detId_).second);
341  } else {
342  SummaryMEsMap_iter = SummaryMEsMap_.find(getLayerNameAndId(detId_).second);
343  }
344 
345  if (SummaryMEsMap_iter != SummaryMEsMap_.end()) {
346  return;
347  }
348 
349  // FIXME t's not good that the base class has to know about which derived
350  // class shoudl exist.
351  // please modify this part. implement virtual functions, esplicited in the
352  // derived classes
353  // --> currently only profile summary defined for all condition objects except
354  // quality
355  if ((CondObj_fillId_ == "ProfileAndCumul" || CondObj_fillId_ == "onlyProfile") &&
356  (CondObj_name_ == "pedestal" || CondObj_name_ == "noise" || CondObj_name_ == "lowthreshold" ||
357  CondObj_name_ == "highthreshold" || CondObj_name_ == "apvgain" || CondObj_name_ == "bpcorrection" ||
358  CondObj_name_ == "lorentzangle")) {
359  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel"))
360  if (!CondObj_ME.SummaryOfProfileDistr) {
361  bookSummaryProfileMEs(CondObj_ME, detId_);
362  }
363  }
364 
365  // --> currently only genuine cumul LA
366  if ((CondObj_fillId_ == "ProfileAndCumul" || CondObj_fillId_ == "onlyCumul") &&
367  (CondObj_name_ == "lorentzangle" || CondObj_name_ == "bpcorrection" || CondObj_name_ == "noise")) {
368  if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel"))
369  if (!CondObj_ME.SummaryOfCumulDistr) {
370  bookSummaryCumulMEs(CondObj_ME, detId_);
371  }
372  }
373 
374  // --> currently only summary as a function of detId for noise, pedestal and
375  // apvgain
376  if (CondObj_name_ == "noise" || CondObj_name_ == "lowthreshold" || CondObj_name_ == "highthreshold" ||
377  CondObj_name_ == "apvgain" || CondObj_name_ == "pedestal" || CondObj_name_ == "quality") {
378  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel"))
379  if (!CondObj_ME.SummaryDistr) {
380  bookSummaryMEs(CondObj_ME, detId_);
381  }
382  }
383 
384  if (CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) {
385  // FIXME getStringNameandId takes time. not need to call it every timne. put
386  // the call at the beginning of the method and caache the string
387  SummaryMEsMap_.insert(std::make_pair(getStringNameAndId(detId_).second, CondObj_ME));
388  } else if (CondObj_name_ == "bpcorrection" && SummaryOnStringLevel_On_) {
389  // FIXME getStringNameandId takes time. not need to call it every timne. put
390  // the call at the beginning of the method and caache the string
391  SummaryMEsMap_.insert(std::make_pair(getStringNameAndId(detId_).second, CondObj_ME));
392  } else {
393  SummaryMEsMap_.insert(std::make_pair(getLayerNameAndId(detId_).second, CondObj_ME));
394  }
395 }
396 // ----
397 
398 //====================================================
399 // -----
400 void SiStripBaseCondObjDQM::bookProfileMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_) {
401  int hProfile_NchX = 0;
402  double hProfile_LowX = 0;
403  double hProfile_HighX = 0;
404 
405  std::string hProfile_description;
406  hProfile_description = hPSet_.getParameter<std::string>("Profile_description");
407 
408  std::string hProfile_xTitle, hProfile_yTitle;
409  hProfile_xTitle = hPSet_.getParameter<std::string>("Profile_xTitle");
410  hProfile_yTitle = hPSet_.getParameter<std::string>("Profile_yTitle");
411 
412  if (CondObj_name_ != "apvgain") {
413  int nStrip = detInfo_.getNumberOfApvsAndStripLength(detId_).first * 128;
414 
415  hProfile_NchX = nStrip;
416  hProfile_LowX = 0.5;
417  hProfile_HighX = nStrip + 0.5;
418  } else {
419  int nApv = detInfo_.getNumberOfApvsAndStripLength(detId_).first;
420 
421  hProfile_NchX = nApv;
422  hProfile_LowX = 0.5;
423  hProfile_HighX = nApv + 0.5;
424  }
425 
427 
428  std::string hProfile_Name;
429  hProfile_Name = hidmanager.createHistoId(hProfile_description, "det", detId_);
430 
431  std::string hProfile;
432  hProfile = hProfile_Name;
433 
434  CondObj_ME.ProfileDistr = dqmStore_->book1D(hProfile_Name, hProfile, hProfile_NchX, hProfile_LowX, hProfile_HighX);
435  CondObj_ME.ProfileDistr->setAxisTitle(hProfile_xTitle, 1);
436  CondObj_ME.ProfileDistr->setAxisTitle(hProfile_yTitle, 2);
437 }
438 // -----
439 
440 //=============================================
441 // -----
442 void SiStripBaseCondObjDQM::bookCumulMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_) {
443  int hCumul_NchX = 0;
444  double hCumul_LowX = 0;
445  double hCumul_HighX = 0;
446 
447  std::string hCumul_description;
448  hCumul_description = hPSet_.getParameter<std::string>("Cumul_description");
449 
450  std::string hCumul_xTitle, hCumul_yTitle;
451  hCumul_xTitle = hPSet_.getParameter<std::string>("Cumul_xTitle");
452  hCumul_yTitle = hPSet_.getParameter<std::string>("Cumul_yTitle");
453 
454  hCumul_NchX = hPSet_.getParameter<int>("Cumul_NchX");
455  hCumul_LowX = hPSet_.getParameter<double>("Cumul_LowX");
456  hCumul_HighX = hPSet_.getParameter<double>("Cumul_HighX");
457 
459 
460  std::string hCumul_name;
461  hCumul_name = hidmanager.createHistoId(hCumul_description, "det", detId_);
462  ;
463 
464  std::string hCumul_title;
465  hCumul_title = hCumul_name;
466 
467  CondObj_ME.CumulDistr = dqmStore_->book1D(hCumul_name, hCumul_title, hCumul_NchX, hCumul_LowX, hCumul_HighX);
468  CondObj_ME.CumulDistr->setAxisTitle(hCumul_xTitle, 1);
469  CondObj_ME.CumulDistr->setAxisTitle(hCumul_yTitle, 2);
470 }
471 // ----
472 
473 //===========================================
474 // -----
475 //#FIXME: same comments: factorize, and remove any reference to derived classes
477  std::vector<uint32_t> sameLayerDetIds_;
478 
479  int hSummaryOfProfile_NchX = 0;
480  double hSummaryOfProfile_LowX = 0;
481  double hSummaryOfProfile_HighX = 0;
482 
483  std::string hSummaryOfProfile_description;
484  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
485 
486  std::string hSummaryOfProfile_xTitle, hSummaryOfProfile_yTitle;
487  hSummaryOfProfile_xTitle = hPSet_.getParameter<std::string>("SummaryOfProfile_xTitle");
488  hSummaryOfProfile_yTitle = hPSet_.getParameter<std::string>("SummaryOfProfile_yTitle");
489 
490  int hSummaryOfProfile_NchY;
491  double hSummaryOfProfile_LowY, hSummaryOfProfile_HighY;
492  hSummaryOfProfile_NchY = hPSet_.getParameter<int>("SummaryOfProfile_NchY");
493  hSummaryOfProfile_LowY = hPSet_.getParameter<double>("SummaryOfProfile_LowY");
494  hSummaryOfProfile_HighY = hPSet_.getParameter<double>("SummaryOfProfile_HighY");
495 
496  int nStrip, nApv, layerId_;
497 
498  if (CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) {
499  layerId_ = getStringNameAndId(detId_).second;
500  } else if (CondObj_name_ == "bpcorrection" && SummaryOnStringLevel_On_) {
501  layerId_ = getStringNameAndId(detId_).second;
502  } else {
503  layerId_ = getLayerNameAndId(detId_).second;
504  }
505 
506  if (CondObj_name_ == "pedestal" || CondObj_name_ == "noise" || CondObj_name_ == "lowthreshold" ||
507  CondObj_name_ == "highthreshold") { // plot in strip number
508 
509  if ((layerId_ > 610 && layerId_ < 620) || // TID & TEC have 768 strips at maximum
510  (layerId_ > 620 && layerId_ < 630) || (layerId_ > 410 && layerId_ < 414) ||
511  (layerId_ > 420 && layerId_ < 424)) {
512  nStrip = 768;
513  } else {
514  nStrip = detInfo_.getNumberOfApvsAndStripLength(detId_).first * 128;
515  }
516 
517  hSummaryOfProfile_NchX = nStrip;
518  hSummaryOfProfile_LowX = 0.5;
519  hSummaryOfProfile_HighX = nStrip + 0.5;
520 
521  } else if (((CondObj_name_ == "lorentzangle" || CondObj_name_ == "bpcorrection") && SummaryOnLayerLevel_On_) ||
522  CondObj_name_ == "quality") { // plot in detId-number
523 
524  // -----
525  // get detIds belonging to same layer to fill X-axis with detId-number
526 
527  sameLayerDetIds_.clear();
528 
529  switch (DetId(detId_).subdetId()) {
532  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tibLayer(detId_), 0, 0, tTopo_->tibString(detId_));
533  break;
535  SiStripSubStructure::getTIDDetectors(activeDetIds, sameLayerDetIds_, tTopo_, 0, 0, 0, 0);
536  break;
538  SiStripSubStructure::getTOBDetectors(activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tobLayer(detId_), 0, 0);
539  break;
541  SiStripSubStructure::getTECDetectors(activeDetIds, sameLayerDetIds_, tTopo_, 0, 0, 0, 0, 0, 0);
542  break;
543  }
544 
545  hSummaryOfProfile_NchX = sameLayerDetIds_.size();
546  hSummaryOfProfile_LowX = 0.5;
547  hSummaryOfProfile_HighX = sameLayerDetIds_.size() + 0.5;
548 
549  } else if ((CondObj_name_ == "lorentzangle" || CondObj_name_ == "bpcorrection") &&
550  SummaryOnStringLevel_On_) { // plot in detId-number
551 
552  // -----
553  // get detIds belonging to same string to fill X-axis with detId-number
554 
555  sameLayerDetIds_.clear();
556 
557  switch (DetId(detId_).subdetId()) {
559  if (tTopo_->tibIsInternalString(detId_)) {
561  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tibLayer(detId_), 0, 1, tTopo_->tibString(detId_));
562  } else if (tTopo_->tibIsExternalString(detId_)) {
564  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tibLayer(detId_), 0, 2, tTopo_->tibString(detId_));
565  }
566  break;
568  SiStripSubStructure::getTIDDetectors(activeDetIds, sameLayerDetIds_, tTopo_, 0, 0, 0, 0);
569  break;
572  activeDetIds, sameLayerDetIds_, tTopo_, tTopo_->tobLayer(detId_), 0, tTopo_->tobRod(detId_));
573  break;
575  SiStripSubStructure::getTECDetectors(activeDetIds, sameLayerDetIds_, tTopo_, 0, 0, 0, 0, 0, 0);
576  break;
577  }
578 
579  hSummaryOfProfile_NchX = sameLayerDetIds_.size();
580  hSummaryOfProfile_LowX = 0.5;
581  hSummaryOfProfile_HighX = sameLayerDetIds_.size() + 0.5;
582 
583  } else if (CondObj_name_ == "apvgain") {
584  if ((layerId_ > 610 && layerId_ < 620) || // TID & TEC have 6 apvs at maximum
585  (layerId_ > 620 && layerId_ < 630) || (layerId_ > 410 && layerId_ < 414) ||
586  (layerId_ > 420 && layerId_ < 424)) {
587  nApv = 6;
588  } else {
589  nApv = detInfo_.getNumberOfApvsAndStripLength(detId_).first;
590  }
591 
592  hSummaryOfProfile_NchX = nApv;
593  hSummaryOfProfile_LowX = 0.5;
594  hSummaryOfProfile_HighX = nApv + 0.5;
595 
596  } else {
597  edm::LogWarning("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::bookSummaryProfileMEs] PLEASE CHECK : "
598  "x-axis label in your cfg"
599  << std::endl;
600  }
601 
602  uint32_t layer_ = 0;
603 
605 
607 
608  std::string hSummaryOfProfile_name;
609 
610  // ---
611  int subdetectorId_ = ((detId_ >> 25) & 0x7);
612 
613  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
614  edm::LogError("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::bookSummaryProfileMEs] WRONG INPUT : no "
615  "such subdetector type : "
616  << subdetectorId_ << " no folder set!" << std::endl;
617  return;
618  }
619  // ---
620 
621  if ((CondObj_name_ == "lorentzangle" || CondObj_name_ == "bpcorrection") && SummaryOnStringLevel_On_) {
622  hSummaryOfProfile_name =
623  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getStringNameAndId(detId_).first, "");
624  } else {
625  hSummaryOfProfile_name =
626  hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(detId_).first, "");
627  }
628 
629  std::string hSummaryOfProfile_title;
630  hSummaryOfProfile_title = hSummaryOfProfile_name;
631 
632  CondObj_ME.SummaryOfProfileDistr = dqmStore_->bookProfile(hSummaryOfProfile_name,
633  hSummaryOfProfile_title,
634  hSummaryOfProfile_NchX,
635  hSummaryOfProfile_LowX,
636  hSummaryOfProfile_HighX,
637  hSummaryOfProfile_NchY,
638  0.,
639  0.);
640  // hSummaryOfProfile_LowY,
641  // hSummaryOfProfile_HighY);
642  CondObj_ME.SummaryOfProfileDistr->setAxisTitle(hSummaryOfProfile_xTitle, 1);
643  CondObj_ME.SummaryOfProfileDistr->setAxisTitle(hSummaryOfProfile_yTitle, 2);
644  CondObj_ME.SummaryOfProfileDistr->setAxisRange(hSummaryOfProfile_LowY, hSummaryOfProfile_HighY, 2);
645 
646  // -----
647  // in order to get the right detId-number labelled in right bin of x-axis
648 
649  if (CondObj_name_ == "quality") {
650  unsigned int iBin = 0;
651 
652  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
653  iBin++;
654  char sameLayerDetIds_Name[1024];
655  sprintf(sameLayerDetIds_Name, "%u", sameLayerDetIds_[i]);
656  CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, sameLayerDetIds_Name);
657  }
658  }
659  if (CondObj_name_ == "lorentzangle" || CondObj_name_ == "bpcorrection") {
660  // Put the detIds for the -z side as following the geometrical order:
661  reverse(sameLayerDetIds_.begin(), sameLayerDetIds_.begin() + sameLayerDetIds_.size() / 2);
662 
663  unsigned int iBin = 0;
664  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
665  iBin++;
667  // remove the label for detIds:
668  CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, "");
669  }
670 
672  // Label with module position instead of detIds:
673  char sameLayerDetIds_Name[1024];
674  if (subdetectorId_ == 3) { // re-abelling for TIB
675  if (tTopo_->tibIsZPlusSide(sameLayerDetIds_[i])) {
676  sprintf(sameLayerDetIds_Name, "%i", tTopo_->tibModule(sameLayerDetIds_[i]));
677  } else if (tTopo_->tibIsZMinusSide(sameLayerDetIds_[i])) {
678  sprintf(sameLayerDetIds_Name, "%i", -tTopo_->tibModule(sameLayerDetIds_[i]));
679  }
680  CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, sameLayerDetIds_Name);
681  } else if (subdetectorId_ == 5) { // re-abelling for TOB
682  if (tTopo_->tobIsZPlusSide(sameLayerDetIds_[i])) {
683  sprintf(sameLayerDetIds_Name, "%i", tTopo_->tobModule(sameLayerDetIds_[i]));
684  } else if (tTopo_->tobIsZMinusSide(sameLayerDetIds_[i])) {
685  sprintf(sameLayerDetIds_Name, "%i", -tTopo_->tobModule(sameLayerDetIds_[i]));
686  }
687  CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, sameLayerDetIds_Name);
688  }
689  }
690  }
691 
692  // -----
693 
694  } // if "lorentzangle"
695 }
696 
698  int hSummaryOfCumul_NchX = 0;
699  double hSummaryOfCumul_LowX = 0;
700  double hSummaryOfCumul_HighX = 0;
701 
702  std::string hSummaryOfCumul_description;
703  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
704 
705  std::string hSummaryOfCumul_xTitle, hSummaryOfCumul_yTitle;
706  hSummaryOfCumul_xTitle = hPSet_.getParameter<std::string>("SummaryOfCumul_xTitle");
707  hSummaryOfCumul_yTitle = hPSet_.getParameter<std::string>("SummaryOfCumul_yTitle");
708 
709  hSummaryOfCumul_NchX = hPSet_.getParameter<int>("SummaryOfCumul_NchX");
710  hSummaryOfCumul_LowX = hPSet_.getParameter<double>("SummaryOfCumul_LowX");
711  hSummaryOfCumul_HighX = hPSet_.getParameter<double>("SummaryOfCumul_HighX");
712 
713  uint32_t layer_ = 0;
714 
716 
718 
719  std::string hSummaryOfCumul_name;
720 
721  // ---
722  int subdetectorId_ = ((detId_ >> 25) & 0x7);
723 
724  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
725  edm::LogError("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::bookSummaryCumulMEs] WRONG INPUT : no such "
726  "subdetector type : "
727  << subdetectorId_ << " no folder set!" << std::endl;
728  return;
729  }
730  // ---
731 
732  // LA and BP Histos are plotted for each string:
733  if ((CondObj_name_ == "lorentzangle" || CondObj_name_ == "bpcorrection") && SummaryOnStringLevel_On_) {
734  hSummaryOfCumul_name =
735  hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(detId_).first, "");
736  } else {
737  hSummaryOfCumul_name =
738  hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getLayerNameAndId(detId_).first, "");
739  }
740 
741  std::string hSummaryOfCumul_title;
742  hSummaryOfCumul_title = hSummaryOfCumul_name;
743 
744  CondObj_ME.SummaryOfCumulDistr = dqmStore_->book1D(
745  hSummaryOfCumul_name, hSummaryOfCumul_title, hSummaryOfCumul_NchX, hSummaryOfCumul_LowX, hSummaryOfCumul_HighX);
746 
747  CondObj_ME.SummaryOfCumulDistr->setAxisTitle(hSummaryOfCumul_xTitle, 1);
748  CondObj_ME.SummaryOfCumulDistr->setAxisTitle(hSummaryOfCumul_yTitle, 2);
749 }
750 
751 // FIXME same as before: factorize
752 void SiStripBaseCondObjDQM::bookSummaryMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_) {
753  std::vector<uint32_t> sameLayerDetIds_;
754 
755  int hSummary_NchX = 0;
756  double hSummary_LowX = 0;
757  double hSummary_HighX = 0;
758 
759  std::string hSummary_description;
760  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
761 
762  std::string hSummary_xTitle, hSummary_yTitle;
763  hSummary_xTitle = hPSet_.getParameter<std::string>("Summary_xTitle");
764  hSummary_yTitle = hPSet_.getParameter<std::string>("Summary_yTitle");
765 
766  int hSummary_NchY;
767  double hSummary_LowY, hSummary_HighY;
768  hSummary_NchY = hPSet_.getParameter<int>("Summary_NchY");
769  hSummary_LowY = hPSet_.getParameter<double>("Summary_LowY");
770  hSummary_HighY = hPSet_.getParameter<double>("Summary_HighY");
771 
772  // -----
773  // get detIds belonging to same layer to fill X-axis with detId-number
774 
775  sameLayerDetIds_.clear();
776 
777  sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, detId_);
778 
779  hSummary_NchX = sameLayerDetIds_.size();
780  hSummary_LowX = 0.5;
781  hSummary_HighX = sameLayerDetIds_.size() + 0.5;
782 
783  uint32_t layer_ = 0;
784 
786 
788 
789  std::string hSummary_name;
790 
791  // ---
792  int subdetectorId_ = ((detId_ >> 25) & 0x7);
793 
794  if (subdetectorId_ < 3 || subdetectorId_ > 6) {
795  edm::LogError("SiStripBaseCondObjDQM") << "[SiStripBaseCondObjDQM::bookSummaryMEs] WRONG INPUT : no such "
796  "subdetector type : "
797  << subdetectorId_ << " no folder set!" << std::endl;
798  return;
799  }
800  // ---
801 
802  hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(detId_).first, "");
803 
804  std::string hSummary_title;
805  hSummary_title = hSummary_name;
806 
807  CondObj_ME.SummaryDistr = dqmStore_->bookProfile(
808  hSummary_name, hSummary_title, hSummary_NchX, hSummary_LowX, hSummary_HighX, hSummary_NchY, 0., 0.);
809  // hSummary_LowY,
810  // hSummary_HighY);
811  CondObj_ME.SummaryDistr->setAxisTitle(hSummary_xTitle, 1);
812  CondObj_ME.SummaryDistr->setAxisTitle(hSummary_yTitle, 2);
813  CondObj_ME.SummaryDistr->setAxisRange(hSummary_LowY, hSummary_HighY, 2);
814 
815  // -----
816  // in order to get the right detId-number labelled in right bin of x-axis
817  unsigned int iBin = 0;
818 
819  for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
820  iBin++;
821  char sameLayerDetIds_Name[1024];
822  sprintf(sameLayerDetIds_Name, "%u", sameLayerDetIds_[i]);
823  if (iBin % 100 == 0)
824  CondObj_ME.SummaryDistr->setBinLabel(iBin, sameLayerDetIds_Name);
825  }
826 }
827 
828 std::pair<std::string, uint32_t> SiStripBaseCondObjDQM::getLayerNameAndId(const uint32_t &detId_) {
829  int subdetectorId_ = ((detId_ >> 25) & 0x7);
830  int layerId_ = 0;
831 
832  std::stringstream layerName;
833 
834  if (subdetectorId_ == 3) { // TIB
835 
836  for (unsigned int i = 1; i < 5; i++) {
837  if (tTopo_->tibLayer(detId_) == i) {
838  layerName << "TIB__layer__" << i;
839  layerId_ = 300 + i;
840  }
841  }
842 
843  }
844 
845  else if (subdetectorId_ == 4) { // TIDD
846 
847  if (tTopo_->tidSide(detId_) == 1) { // TIDD side 1
848 
849  for (unsigned int i = 1; i < 4; i++) {
850  if (tTopo_->tidWheel(detId_) == i) {
851  layerName << "TID__side__1__wheel__" << i;
852  layerId_ = 410 + i;
853  }
854  }
855 
856  }
857 
858  else if (tTopo_->tidSide(detId_) == 2) { // TIDD side 2
859 
860  for (unsigned int i = 1; i < 4; i++) {
861  if (tTopo_->tidWheel(detId_) == i) {
862  layerName << "TID__side__2__wheel__" << i;
863  layerId_ = 420 + i;
864  }
865  }
866  }
867 
868  }
869 
870  else if (subdetectorId_ == 5) { // TOB
871 
872  for (unsigned int i = 1; i < 7; i++) {
873  if (tTopo_->tobLayer(detId_) == i) {
874  layerName << "TOB__layer__" << i;
875  layerId_ = 500 + i;
876  }
877  }
878 
879  }
880 
881  else if (subdetectorId_ == 6) { // TEC
882 
883  if (tTopo_->tecSide(detId_) == 1) { // TEC side 1
884 
885  for (unsigned int i = 1; i < 10; i++) {
886  if (tTopo_->tecWheel(detId_) == i) {
887  layerName << "TEC__side__1__wheel__" << i;
888  layerId_ = 610 + i;
889  }
890  }
891 
892  }
893 
894  else if (tTopo_->tecSide(detId_) == 2) { // TEC side 2
895 
896  for (unsigned int i = 1; i < 10; i++) {
897  if (tTopo_->tecWheel(detId_) == i) {
898  layerName << "TEC__side__2__wheel__" << i;
899  layerId_ = 620 + i;
900  }
901  }
902  }
903  }
904 
905  return std::make_pair(layerName.str(), layerId_);
906 }
907 
908 std::pair<std::string, uint32_t> SiStripBaseCondObjDQM::getStringNameAndId(const uint32_t &detId_) {
909  int subdetectorId_ = ((detId_ >> 25) & 0x7);
910  int layerStringId_ = 0;
911 
912  std::stringstream layerStringName;
913 
914  if (subdetectorId_ == 3) { // TIB
915  if (tTopo_->tibLayer(detId_) == 1 && tTopo_->tibIsInternalString(detId_)) { // 1st layer int
916  for (unsigned int i = 1; i < 27; i++) {
917  if (tTopo_->tibString(detId_) == i) {
918  layerStringName << "TIB_L1_Int_Str_" << i;
919  layerStringId_ = 30110 + i;
920  }
921  }
922  } else if (tTopo_->tibLayer(detId_) == 1 && tTopo_->tibIsExternalString(detId_)) { // 1st layer ext
923  for (unsigned int i = 1; i < 31; i++) {
924  if (tTopo_->tibString(detId_) == i) {
925  layerStringName << "TIB_L1_Ext_Str_" << i;
926  layerStringId_ = 301200 + i;
927  }
928  }
929  } else if (tTopo_->tibLayer(detId_) == 2 && tTopo_->tibIsInternalString(detId_)) { // 2nd layer int
930  for (unsigned int i = 1; i < 35; i++) {
931  if (tTopo_->tibString(detId_) == i) {
932  layerStringName << "TIB_L2_Int_Str_" << i;
933  layerStringId_ = 302100 + i;
934  }
935  }
936  } else if (tTopo_->tibLayer(detId_) == 2 && tTopo_->tibIsExternalString(detId_)) { // 2nd layer ext
937  for (unsigned int i = 1; i < 39; i++) {
938  if (tTopo_->tibString(detId_) == i) {
939  layerStringName << "TIB_L2_Ext_Str_" << i;
940  layerStringId_ = 302200 + i;
941  }
942  }
943  } else if (tTopo_->tibLayer(detId_) == 3 && tTopo_->tibIsInternalString(detId_)) { // 3rd layer int
944  for (unsigned int i = 1; i < 45; i++) {
945  if (tTopo_->tibString(detId_) == i) {
946  layerStringName << "TIB_L3_Int_Str_" << i;
947  layerStringId_ = 303100 + i;
948  }
949  }
950  } else if (tTopo_->tibLayer(detId_) == 3 && tTopo_->tibIsExternalString(detId_)) { // 3rd layer ext
951  for (unsigned int i = 1; i < 47; i++) {
952  if (tTopo_->tibString(detId_) == i) {
953  layerStringName << "TIB_L3_Ext_Str_" << i;
954  layerStringId_ = 303200 + i;
955  }
956  }
957  } else if (tTopo_->tibLayer(detId_) == 4 && tTopo_->tibIsInternalString(detId_)) { // 4th layer int
958  for (unsigned int i = 1; i < 53; i++) {
959  if (tTopo_->tibString(detId_) == i) {
960  layerStringName << "TIB_L4_Int_Str_" << i;
961  layerStringId_ = 304100 + i;
962  }
963  }
964  } else if (tTopo_->tibLayer(detId_) == 4 && tTopo_->tibIsExternalString(detId_)) { // 4th layer ext
965  for (unsigned int i = 1; i < 57; i++) {
966  if (tTopo_->tibString(detId_) == i) {
967  layerStringName << "TIB_L4_Ext_Str_" << i;
968  layerStringId_ = 304200 + i;
969  }
970  }
971  }
972  } // TIB
973 
974  else if (subdetectorId_ == 5) { // TOB
975  if (tTopo_->tobLayer(detId_) == 1) { // 1st layer
976  for (unsigned int i = 1; i < 43; i++) {
977  if (tTopo_->tobRod(detId_) == i) {
978  layerStringName << "TOB_L1_Rod_" << i;
979  layerStringId_ = 50100 + i;
980  }
981  }
982  } else if (tTopo_->tobLayer(detId_) == 2) { // 2nd layer
983  for (unsigned int i = 1; i < 49; i++) {
984  if (tTopo_->tobRod(detId_) == i) {
985  layerStringName << "TOB_L2_Rod_" << i;
986  layerStringId_ = 50200 + i;
987  }
988  }
989  } else if (tTopo_->tobLayer(detId_) == 3) { // 3rd layer
990  for (unsigned int i = 1; i < 55; i++) {
991  if (tTopo_->tobRod(detId_) == i) {
992  layerStringName << "TOB_L3_Rod_" << i;
993  layerStringId_ = 50300 + i;
994  }
995  }
996  } else if (tTopo_->tobLayer(detId_) == 4) { // 4th layer
997  for (unsigned int i = 1; i < 61; i++) {
998  if (tTopo_->tobRod(detId_) == i) {
999  layerStringName << "TOB_L4_Rod_" << i;
1000  layerStringId_ = 50400 + i;
1001  }
1002  }
1003  } else if (tTopo_->tobLayer(detId_) == 5) { // 5th layer
1004  for (unsigned int i = 1; i < 67; i++) {
1005  if (tTopo_->tobRod(detId_) == i) {
1006  layerStringName << "TOB_L5_Rod_" << i;
1007  layerStringId_ = 50500 + i;
1008  }
1009  }
1010  } else if (tTopo_->tobLayer(detId_) == 6) { // 6st layer
1011  for (unsigned int i = 1; i < 75; i++) {
1012  if (tTopo_->tobRod(detId_) == i) {
1013  layerStringName << "TOB_L6_Rod_" << i;
1014  layerStringId_ = 50600 + i;
1015  }
1016  }
1017  }
1018  } // TOB
1019 
1020  return std::make_pair(layerStringName.str(), layerStringId_);
1021 }
1022 
1023 std::vector<uint32_t> SiStripBaseCondObjDQM::GetSameLayerDetId(const std::vector<uint32_t> &activeDetIds,
1024  uint32_t selDetId) {
1025  std::vector<uint32_t> sameLayerDetIds;
1026  sameLayerDetIds.clear();
1027 
1028  switch (DetId(selDetId).subdetId()) {
1029  case StripSubdetector::TIB:
1030  SiStripSubStructure::getTIBDetectors(activeDetIds, sameLayerDetIds, tTopo_, tTopo_->tibLayer(selDetId), 0, 0, 0);
1031  break;
1032  case StripSubdetector::TID:
1034  activeDetIds, sameLayerDetIds, tTopo_, tTopo_->tidSide(selDetId), tTopo_->tidWheel(selDetId), 0, 0);
1035  break;
1036  case StripSubdetector::TOB:
1037  SiStripSubStructure::getTOBDetectors(activeDetIds, sameLayerDetIds, tTopo_, tTopo_->tobLayer(selDetId), 0, 0);
1038  break;
1039  case StripSubdetector::TEC:
1041  activeDetIds, sameLayerDetIds, tTopo_, tTopo_->tecSide(selDetId), tTopo_->tecWheel(selDetId), 0, 0, 0, 0);
1042  break;
1043  }
1044 
1045  return sameLayerDetIds;
1046 }
1047 
1048 void SiStripBaseCondObjDQM::bookTkMap(const std::string &TkMapname) { tkMap = new TrackerMap(TkMapname); }
1049 
1050 void SiStripBaseCondObjDQM::fillTkMap(const uint32_t &detid, const float &value) { tkMap->fill(detid, value); }
1051 
1052 void SiStripBaseCondObjDQM::saveTkMap(const std::string &TkMapname, double minValue, double maxValue) {
1053  if (!tkMapScaler.empty()) {
1054  // check that saturation is below x% below minValue and above minValue, and
1055  // in case re-arrange.
1056  float th = hPSet_.getParameter<double>("saturatedFraction");
1057 
1058  size_t imin = 0, imax = 0;
1059  float entries = 0;
1060  for (size_t i = 0; i < tkMapScaler.size(); ++i)
1061  entries += tkMapScaler[i];
1062 
1063  float min = 0;
1064  for (size_t i = 0; (i < tkMapScaler.size()) && (min < th); ++i) {
1065  min += tkMapScaler[i] / entries;
1066  imin = i;
1067  }
1068 
1069  float max = 0;
1070  // for(size_t i=tkMapScaler.size()-1;(i>=0) && (max<th);--i){ // Wrong
1071  // Since i is unsigned, i >= 0 is always true,
1072  // and the loop termination condition is never reached.
1073  // We offset the loop index by one to fix this.
1074  for (size_t j = tkMapScaler.size(); (j > 0) && (max < th); --j) {
1075  size_t i = j - 1;
1076  max += tkMapScaler[i] / entries;
1077  imax = i;
1078  }
1079 
1080  // reset maxValue;
1081  if (maxValue < imax) {
1082  edm::LogInfo("SiStripBaseCondObjDQM") << "Resetting TkMap maxValue from " << maxValue << " to " << imax;
1083  maxValue = imax;
1084  }
1085  // reset minValue;
1086  if (minValue > imin) {
1087  edm::LogInfo("SiStripBaseCondObjDQM") << "Resetting TkMap minValue from " << minValue << " to " << imin;
1088  minValue = imin;
1089  }
1090  }
1091 
1092  tkMap->save(false, minValue, maxValue, TkMapname, 4500, 2400);
1093  tkMap->setPalette(1);
1094  tkMap->showPalette(true);
1095 }
1096 
1098  edm::LogInfo("SiStripBaseCondObjDQM") << "SiStripBaseCondObjDQM::end" << std::endl;
1099 }
1100 
1101 void SiStripBaseCondObjDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
1102  ModMEs CondObj_ME;
1103  for (const auto det : selectedDetIds) {
1104  fillMEsForDet(CondObj_ME, det);
1105  }
1106 }
1107 
1108 //==========================
1109 void SiStripBaseCondObjDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
1110  for (const auto det : selectedDetIds) {
1111  fillMEsForLayer(/*SummaryMEsMap_,*/ det);
1112  }
1113 
1114  for (const auto &itm : SummaryMEsMap_) {
1115  ModMEs selME;
1116  selME = itm.second;
1117 
1118  if (hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") &&
1119  fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")) {
1120  if (CondObj_fillId_ == "onlyProfile" || CondObj_fillId_ == "ProfileAndCumul") {
1121  TCanvas c1("c1");
1122  selME.SummaryOfProfileDistr->getTProfile()->Draw();
1123  std::string name(selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
1124  name += ".png";
1125  c1.Print(name.c_str());
1126  }
1127  }
1128  if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") &&
1129  fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
1130  TCanvas c1("c1");
1131  selME.SummaryDistr->getTH1()->Draw();
1133  name += ".png";
1134  c1.Print(name.c_str());
1135  }
1136  if (hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") &&
1137  fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")) {
1138  if (CondObj_fillId_ == "onlyCumul" || CondObj_fillId_ == "ProfileAndCumul") {
1139  TCanvas c1("c1");
1140  selME.SummaryOfCumulDistr->getTH1()->Draw();
1142  name += ".png";
1143  c1.Print(name.c_str());
1144  }
1145  }
1146  }
1147 }
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
std::map< uint32_t, ModMEs > ModMEsMap_
static const char runNumber_[]
static constexpr auto TEC
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const char layer_[]
unsigned int tobLayer(const DetId &id) const
void getTIBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tibDetRawIds, const TrackerTopology *trackerTopology, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t int_ext=0, uint32_t string=0)
std::vector< uint32_t > ModulesToBeExcluded_
virtual TProfile * getTProfile() const
bool tibIsZPlusSide(const DetId &id) const
void selectModules(std::vector< uint32_t > &detIds_)
const TrackerTopology * tTopo_
bool tobIsZMinusSide(const DetId &id) const
virtual void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds)
void bookTkMap(const std::string &TkMapname)
unsigned int tibModule(const DetId &id) const
unsigned int tidSide(const DetId &id) const
bool tibIsExternalString(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
bool tibIsZMinusSide(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tibString(const DetId &id) const
void getTIDDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tidDetRawIds, const TrackerTopology *trackerTopology, uint32_t side=0, uint32_t wheel=0, uint32_t ring=0, uint32_t ster=0)
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=false)
SiStripFolderOrganizer folder_organizer
std::vector< int > tkMapScaler
void saveTkMap(const std::string &TkMapname, double minValue, double maxValue)
void getTECDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tecDetRawIds, const TrackerTopology *trackerTopology, uint32_t side=0, uint32_t wheel=0, uint32_t petal_bkw_frw=0, uint32_t petal=0, uint32_t ring=0, uint32_t ster=0)
Log< level::Error, false > LogError
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
void fillTkMap(const uint32_t &detid, const float &value)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
U second(std::pair< T, U > const &p)
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
std::map< uint32_t, ModMEs > SummaryMEsMap_
void bookCumulMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_)
void showPalette(bool printflag1)
Definition: TrackerMap.h:157
unsigned int tecSide(const DetId &id) const
virtual void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
void analysisOnDemand(const edm::EventSetup &eSetup_, uint32_t detIdOnDemand)
void setPalette(int numpalette)
Definition: TrackerMap.h:155
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:811
virtual void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_)=0
virtual void fillMEsForLayer(uint32_t selDetId_)=0
SiStripDetInfo read(std::string filePath)
Definition: value.py:1
static constexpr auto TOB
bool tobIsZPlusSide(const DetId &id) const
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual std::string getTitle() const
get MonitorElement title
virtual void getConditionObject(const edm::EventSetup &eSetup_)=0
virtual void getActiveDetIds(const edm::EventSetup &eSetup)=0
Log< level::Info, false > LogInfo
void analysis(const edm::EventSetup &eSetup_)
std::vector< uint32_t > ModulesToBeIncluded_
Definition: DetId.h:17
SiStripBaseCondObjDQM(edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet, const TrackerTopology *tTopo)
static constexpr auto TIB
std::pair< std::string, uint32_t > getStringNameAndId(const uint32_t &detId_)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
bool tibIsInternalString(const DetId &id) const
unsigned int tobRod(const DetId &id) const
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=false)
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
virtual TH1 * getTH1() const
HLT enums.
std::vector< uint32_t > GetSameLayerDetId(const std::vector< uint32_t > &activeDetIds, uint32_t selDetId)
virtual void fillModMEs(const std::vector< uint32_t > &selectedDetIds)
std::vector< uint32_t > activeDetIds
static constexpr char const *const kDefaultFile
void bookSummaryCumulMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_)
unsigned int RunNumber_t
unsigned int tibLayer(const DetId &id) const
unsigned int tobModule(const DetId &id) const
Log< level::Warning, false > LogWarning
void getTOBDetectors(const std::vector< uint32_t > &inputDetRawIds, std::vector< uint32_t > &tobDetRawIds, const TrackerTopology *trackerTopology, uint32_t layer=0, uint32_t bkw_frw=0, uint32_t rod=0)
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual bool checkChanged(const edm::EventSetup &eSetup)=0
void bookSummaryProfileMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_)
tmp
align.sh
Definition: createJobs.py:716
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
static constexpr auto TID
const std::vector< uint32_t > & getAllDetIds() const noexcept
std::vector< std::string > SubDetectorsToBeExcluded_
void fill(int layer, int ring, int nmod, float x)
Definition: TrackerMap.cc:3289
void bookProfileMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void bookSummaryMEs(SiStripBaseCondObjDQM::ModMEs &CondObj_ME, const uint32_t &detId_)
std::vector< std::string > set_intersection(std::vector< std::string > const &v1, std::vector< std::string > const &v2)