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