CMS 3D CMS Logo

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