CMS 3D CMS Logo

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