CMS 3D CMS Logo

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