CMS 3D CMS Logo

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