CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DQM/SiStripMonitorSummary/src/SiStripBaseCondObjDQM.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripMonitorSummary/interface/SiStripBaseCondObjDQM.h"
00002 
00003 #include "TCanvas.h"
00004 
00005 // -----
00006 
00007 
00008 
00009 SiStripBaseCondObjDQM::SiStripBaseCondObjDQM(const edm::EventSetup & eSetup,
00010                                              edm::ParameterSet const& hPSet,
00011                                              edm::ParameterSet const& fPSet ):
00012   eSetup_(eSetup),
00013   hPSet_(hPSet),
00014   fPSet_(fPSet),
00015   cacheID_memory(0),
00016   dqmStore_(edm::Service<DQMStore>().operator->()){
00017 
00018   reader = new SiStripDetInfoFileReader(edm::FileInPath(std::string("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat") ).fullPath());
00019   
00020   Mod_On_                  = fPSet_.getParameter<bool>("Mod_On");
00021   HistoMaps_On_            = fPSet_.getParameter<bool>("HistoMaps_On");
00022   SummaryOnLayerLevel_On_  = fPSet_.getParameter<bool>("SummaryOnLayerLevel_On");
00023   SummaryOnStringLevel_On_ = fPSet_.getParameter<bool>("SummaryOnStringLevel_On");
00024 
00025   GrandSummary_On_         = fPSet_.getParameter<bool>("GrandSummary_On");
00026 
00027   CondObj_fillId_    = hPSet_.getParameter<std::string>("CondObj_fillId");
00028   CondObj_name_      = hPSet_.getParameter<std::string>("CondObj_name");
00029  
00030 
00031   //Warning message from wrong input:
00032   if(SummaryOnLayerLevel_On_ && SummaryOnStringLevel_On_){
00033     edm::LogWarning("SiStripBaseCondObjDQM") 
00034        << "[SiStripBaseCondObjDQM::SiStripBaseCondObjDQMs] PLEASE CHECK : String and layer level options can not be activated together"
00035        << std::endl; 
00036   }
00037 
00038   //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)
00039   if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) bookTkMap(hPSet_.getParameter<std::string>("TkMapName"));
00040 
00041 
00042   minValue=hPSet_.getParameter<double>("minValue");
00043   maxValue=hPSet_.getParameter<double>("maxValue");
00044 
00045 }
00046 // -----
00047 
00048 
00049 //======================================
00050 // -----
00051 void SiStripBaseCondObjDQM::analysis(const edm::EventSetup & eSetup_){
00052  
00053   cacheID_current=  getCache(eSetup_);
00054   
00055   if (cacheID_memory == cacheID_current) return;
00056   
00057   getConditionObject(eSetup_);
00058 
00059   //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)
00060   if(fPSet_.getParameter<bool>("ActiveDetIds_On") || hPSet_.getParameter<bool>("ActiveDetIds_On"))
00061     getActiveDetIds(eSetup_);
00062   else
00063     activeDetIds=reader->getAllDetIds();
00064 
00065   selectModules(activeDetIds);
00066 
00067   if(Mod_On_ )                                            { fillModMEs(activeDetIds); }
00068   if(SummaryOnLayerLevel_On_ || SummaryOnStringLevel_On_ ){ fillSummaryMEs(activeDetIds);}
00069 
00070   std::string filename = hPSet_.getParameter<std::string>("TkMapName");
00071   if (filename!=""){
00072     char sRun[128];
00073     sprintf(sRun,"_Run_%d",eSetup_.iovSyncValue().eventID().run());
00074     filename.insert(filename.find("."),sRun);
00075     
00076     saveTkMap(filename.c_str(), minValue, maxValue);
00077   }
00078 }
00079 // -----
00080 
00081 
00082 //=====================================
00083 // -----
00084 void SiStripBaseCondObjDQM::analysisOnDemand(const edm::EventSetup & eSetup_, 
00085                                             std::string requestedSubDetector, 
00086                                             uint32_t requestedSide, 
00087                                             uint32_t requestedLayer){
00088   
00089   getConditionObject(eSetup_);
00090   getActiveDetIds(eSetup_);
00091    
00092   std::vector<uint32_t> requestedDetIds_;
00093   requestedDetIds_.clear();
00094   
00095   SiStripSubStructure substructure_;
00096   
00097   if(requestedSubDetector=="TIB"){ 
00098       substructure_.getTIBDetectors( activeDetIds, requestedDetIds_, requestedLayer,0,0,0);
00099   }
00100   else if(requestedSubDetector=="TID"){ 
00101       substructure_.getTIDDetectors( activeDetIds, requestedDetIds_, requestedSide,requestedLayer,0,0);
00102   }
00103   else if(requestedSubDetector=="TOB"){  
00104       substructure_.getTOBDetectors( activeDetIds, requestedDetIds_, requestedLayer,0,0);
00105   }
00106   else if(requestedSubDetector=="TEC"){  
00107       substructure_.getTECDetectors( activeDetIds, requestedDetIds_, requestedSide,requestedLayer,0,0,0,0);
00108   } 
00109 
00110   analysisOnDemand(eSetup_,requestedDetIds_);
00111  
00112 }
00113 // -----
00114 
00115 //===========================================
00116 // -----
00117 void SiStripBaseCondObjDQM::analysisOnDemand(const edm::EventSetup & eSetup_, uint32_t  detIdOnDemand){
00118  
00119   unsigned long long cacheID_current=  getCache(eSetup_);
00120   
00121   if (cacheID_memory == cacheID_current) return;
00122   
00123   getConditionObject(eSetup_);
00124   
00125   std::vector<uint32_t> vdetIdsOnDemand_;
00126   vdetIdsOnDemand_.push_back(detIdOnDemand); // fillModMEs needs a vector 
00127 
00128   fillModMEs(vdetIdsOnDemand_); 
00129   
00130 }
00131 // -----
00132 //===============================================
00133 // -----
00134 void SiStripBaseCondObjDQM::analysisOnDemand(const edm::EventSetup & eSetup_, std::vector<uint32_t>  detIdsOnDemand){
00135  
00136   unsigned long long cacheID_current=  getCache(eSetup_);
00137   
00138   if (cacheID_memory == cacheID_current) return;
00139   
00140   getConditionObject(eSetup_);
00141   
00142 
00143   fillSummaryMEs(detIdsOnDemand); 
00144   
00145 }
00146 // -----
00147 //====================================
00148 // -----
00149 std::vector<uint32_t> SiStripBaseCondObjDQM::getCabledModules() {     
00150  
00151   std::vector<uint32_t> cabledDetIds_;  
00152   eSetup_.get<SiStripDetCablingRcd>().get(detCablingHandle_);
00153   detCablingHandle_->addActiveDetectorsRawIds(cabledDetIds_);
00154 
00155   return cabledDetIds_;  
00156 
00157 }
00158 // -----
00159 
00160 
00161 //=========================================================
00162 // -----
00163 
00164 //#FIXME : very long method. please factorize it
00165  
00166 void SiStripBaseCondObjDQM::selectModules(std::vector<uint32_t> & detIds_){
00167    
00168   ModulesToBeExcluded_     = fPSet_.getParameter< std::vector<unsigned int> >("ModulesToBeExcluded");
00169   ModulesToBeIncluded_     = fPSet_.getParameter< std::vector<unsigned int> >("ModulesToBeIncluded");
00170   SubDetectorsToBeExcluded_= fPSet_.getParameter< std::vector<std::string> >("SubDetectorsToBeExcluded");  
00171  
00172   if(fPSet_.getParameter<bool>("restrictModules") 
00173      && ModulesToBeExcluded_.size()==0 
00174      && ModulesToBeIncluded_.size()==0 ){
00175     edm::LogWarning("SiStripBaseCondObjDQM") 
00176        << "[SiStripBaseCondObjDQM::selectModules] PLEASE CHECK : no modules to be exclude/included in your cfg"
00177        << std::endl; 
00178   }
00179 
00180  
00181  
00182   
00183   // --> detIds to start with
00184 
00185   if( fPSet_.getParameter<bool>("restrictModules")){
00186       
00187     if( ModulesToBeIncluded_.size()>0 ){
00188      std::vector<uint32_t> tmp;
00189      tmp.clear();
00190      set_intersection( detIds_.begin(), detIds_.end(),  
00191                        ModulesToBeIncluded_.begin(), ModulesToBeIncluded_.end(),
00192                        inserter(tmp,tmp.begin()));
00193      swap(detIds_,tmp);
00194    }
00195     
00196   }
00197 
00198   
00199 
00200   // -----
00201   // *** exclude modules ***
00202   
00203   if( fPSet_.getParameter<bool>("restrictModules") ){
00204     
00205     std::sort(detIds_.begin(),detIds_.end());
00206 
00207     for( std::vector<uint32_t>::const_iterator modIter_  = ModulesToBeExcluded_.begin(); 
00208                                                modIter_ != ModulesToBeExcluded_.end(); modIter_++){
00209       
00210       std::vector<uint32_t>::iterator detIter_=std::lower_bound(detIds_.begin(),detIds_.end(),*modIter_);
00211       detIds_.erase(detIter_);
00212       detIter_--;
00213      
00214     }
00215   
00216   }
00217   // *** exclude modules ***
00218   // -----
00219    
00220 
00221   // -----
00222   // *** restrict to a particular subdetector ***
00223    
00224   if( *(SubDetectorsToBeExcluded_.begin()) !="none" ){
00225     
00226     std::vector<uint32_t> tmp;
00227 
00228     SiStripSubStructure substructure_;
00229     
00230     for( std::vector<std::string>::const_iterator modIter_  = SubDetectorsToBeExcluded_.begin(); 
00231                                                  modIter_ != SubDetectorsToBeExcluded_.end(); modIter_++){
00232       tmp.clear();
00233 
00234       if (*modIter_=="TIB")     { substructure_.getTIBDetectors(detIds_, tmp, 0,0,0,0);}
00235       else if (*modIter_=="TOB") { substructure_.getTOBDetectors(detIds_, tmp, 0,0,0);}
00236       else if (*modIter_=="TID") { substructure_.getTIDDetectors(detIds_, tmp, 0,0,0,0);}
00237       else if (*modIter_=="TEC") { substructure_.getTECDetectors(detIds_, tmp, 0,0,0,0,0,0);}
00238       else {
00239         edm::LogWarning("SiStripBaseCondObjDQM") 
00240        << "[SiStripBaseCondObjDQM::selectModules] PLEASE CHECK : no correct (name) subdetector to be excluded in your cfg"
00241        << std::endl; 
00242       }
00243 
00244       std::vector<uint32_t>::iterator iterBegin_=std::lower_bound(detIds_.begin(),
00245                                                                   detIds_.end(),
00246                                                                   *min_element(tmp.begin(), tmp.end()));
00247                                                                   
00248       std::vector<uint32_t>::iterator iterEnd_=std::lower_bound(detIds_.begin(),
00249                                                                 detIds_.end(),
00250                                                                 *max_element(tmp.begin(), tmp.end()));
00251                                                                 
00252       for(std::vector<uint32_t>::iterator detIter_ = iterEnd_;
00253                                          detIter_!= iterBegin_-1;detIter_--){
00254           detIds_.erase(detIter_);
00255       } 
00256 
00257     } // loop SubDetectorsToBeExcluded_
00258   }
00259 
00260   
00261   // -----
00262   // *** fill only one Module per layer ***
00263 
00264   if(fPSet_.getParameter<std::string>("ModulesToBeFilled") == "onlyOneModulePerLayer"){
00265    
00266     std::vector<uint32_t> tmp;
00267     std::vector<uint32_t> layerDetIds;
00268 
00269     SiStripSubStructure substructure_;
00270     
00271     for(unsigned int i=1; i<5 ; i++){
00272       tmp.clear();
00273       substructure_.getTIBDetectors(detIds_, tmp, i,0,0,0);
00274       if(tmp.size() !=0) { layerDetIds.push_back(*(tmp.begin()));}
00275     }
00276     for(unsigned int i=1; i<7 ; i++){
00277       tmp.clear();
00278       substructure_.getTOBDetectors(detIds_, tmp, i,0,0);
00279       if(tmp.size() !=0) { layerDetIds.push_back(*(tmp.begin()));}
00280     }
00281     for(unsigned int i=1; i<4 ; i++){
00282       tmp.clear();
00283       substructure_.getTIDDetectors(detIds_, tmp, 1,i,0,0);
00284       if(tmp.size() !=0) { layerDetIds.push_back(*(tmp.begin()));}
00285       substructure_.getTIDDetectors(detIds_, tmp, 2,i,0,0);
00286       if(tmp.size() !=0) { layerDetIds.push_back(*(tmp.begin()));}
00287     }  
00288     for(unsigned int i=1; i<10 ; i++){
00289       tmp.clear();
00290       substructure_.getTECDetectors(detIds_, tmp, 1,i,0,0,0,0);
00291       if(tmp.size() !=0) { layerDetIds.push_back(*(tmp.begin()));}
00292       substructure_.getTECDetectors(detIds_, tmp, 2,i,0,0,0,0);
00293       if(tmp.size() !=0) { layerDetIds.push_back(*(tmp.begin()));}
00294     }
00295     
00296     detIds_.clear();
00297     detIds_=layerDetIds;
00298 
00299   }
00300   // -----
00301 
00302    
00303 } //selectModules
00304 // -----
00305 
00306 
00307 //=================================================
00308 // -----
00309 void SiStripBaseCondObjDQM::getModMEs(ModMEs& CondObj_ME, const uint32_t& detId_){
00310   
00311   std::map< uint32_t, ModMEs >::const_iterator ModMEsMap_iter = ModMEsMap_.find(detId_);
00312 
00313   if (ModMEsMap_iter != ModMEsMap_.end()){ 
00314   
00315     CondObj_ME=ModMEsMap_iter->second;
00316   
00317     if( ( CondObj_fillId_ =="ProfileAndCumul" || CondObj_fillId_ =="onlyProfile") && CondObj_ME.ProfileDistr ) { 
00318       CondObj_ME.ProfileDistr ->Reset();    
00319     }
00320        
00321     if( (CondObj_fillId_ =="ProfileAndCumul" || CondObj_fillId_ =="onlyCumul" ) &&  CondObj_ME.CumulDistr ){
00322       CondObj_ME.CumulDistr ->Reset();
00323     }
00324     else {
00325       edm::LogWarning("SiStripBaseCondObjDQM") 
00326         << "[SiStripBaseCondObjDQM::getModMEs] PLEASE CHECK : CondObj_fillId option mispelled";
00327     }
00328     return; 
00329 
00330   }
00331   
00332   // --> profile defined for all CondData
00333   if ( (CondObj_fillId_ =="ProfileAndCumul" || CondObj_fillId_ =="onlyProfile")) {
00334     bookProfileMEs(CondObj_ME,detId_);
00335   }  
00336   
00337   // --> cumul currently only defined for noise and apvgain
00338   if( (CondObj_fillId_ =="ProfileAndCumul" || CondObj_fillId_ =="onlyCumul" )
00339       &&(CondObj_name_ == "noise" || CondObj_name_ == "apvgain")          ) bookCumulMEs(CondObj_ME,detId_);
00340   
00341  
00342   ModMEsMap_.insert( std::make_pair(detId_,CondObj_ME) );
00343   
00344 }
00345 // ---- 
00346 
00347 //===============================================
00348 // -----
00349 //%FIXME: very long method, factorize
00350 void SiStripBaseCondObjDQM::getSummaryMEs(ModMEs& CondObj_ME, const uint32_t& detId_){
00351 
00352   std::map<uint32_t, ModMEs>::const_iterator SummaryMEsMap_iter;
00353 
00354   if(CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_ ){
00355     SummaryMEsMap_iter = SummaryMEsMap_.find(getStringNameAndId(detId_).second);
00356   }
00357   else {
00358     SummaryMEsMap_iter = SummaryMEsMap_.find(getLayerNameAndId(detId_).second);
00359   }
00360    
00361   if (SummaryMEsMap_iter != SummaryMEsMap_.end()){ return;}
00362 
00363   //FIXME t's not good that the base class has to know about which derived class shoudl exist.
00364   // please modify this part. implement virtual functions, esplicited in the derived classes
00365   // --> currently only profile summary defined for all condition objects except quality
00366   if(  (CondObj_fillId_ =="ProfileAndCumul" || CondObj_fillId_ =="onlyProfile" ) &&
00367      (
00368       CondObj_name_ == "pedestal"     || 
00369       CondObj_name_ == "noise"         || 
00370       CondObj_name_ == "lowthreshold"  || 
00371       CondObj_name_ == "highthreshold" || 
00372       CondObj_name_ == "apvgain"       || 
00373       CondObj_name_ == "lorentzangle") ) {
00374     if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel"))     
00375            if (CondObj_ME.SummaryOfProfileDistr) { bookSummaryProfileMEs(CondObj_ME,detId_);
00376       }  
00377     
00378 }
00379     
00380   // --> currently only genuine cumul LA
00381   if(   (CondObj_fillId_ =="ProfileAndCumul" || CondObj_fillId_ =="onlyCumul" ) &&
00382         (CondObj_name_ == "lorentzangle" ||  CondObj_name_ == "noise")  ) {
00383     if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel"))
00384       if (CondObj_ME.SummaryOfCumulDistr) { bookSummaryCumulMEs(CondObj_ME,detId_); } 
00385   } 
00386                           
00387   // --> currently only summary as a function of detId for noise, pedestal and apvgain 
00388   if(      CondObj_name_ == "noise"         ||
00389            CondObj_name_ == "lowthreshold"  || 
00390            CondObj_name_ == "highthreshold" || 
00391            CondObj_name_ == "apvgain"       || 
00392            CondObj_name_ == "pedestal"      || 
00393            CondObj_name_ == "quality"           ) {
00394     if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel"))          
00395       if (CondObj_ME.SummaryDistr) { bookSummaryMEs(CondObj_ME,detId_); } 
00396     
00397   } 
00398                           
00399   if(CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) {
00400     //FIXME getStringNameandId takes time. not need to call it every timne. put the call at the beginning of the method and caache the string 
00401     SummaryMEsMap_.insert( std::make_pair(getStringNameAndId(detId_).second,CondObj_ME) );
00402   }
00403   else {
00404     SummaryMEsMap_.insert( std::make_pair(getLayerNameAndId(detId_).second,CondObj_ME) );
00405   }
00406 
00407 }
00408 // ---- 
00409 
00410 //====================================================
00411 // -----
00412 void SiStripBaseCondObjDQM::bookProfileMEs(SiStripBaseCondObjDQM::ModMEs& CondObj_ME, const uint32_t& detId_){
00413      
00414   int   hProfile_NchX  = 0;
00415   double hProfile_LowX  = 0;
00416   double hProfile_HighX = 0;
00417   
00418   std::string hProfile_description;
00419   hProfile_description   = hPSet_.getParameter<std::string>("Profile_description");
00420       
00421   std::string hProfile_xTitle, hProfile_yTitle;
00422   hProfile_xTitle          = hPSet_.getParameter<std::string>("Profile_xTitle");
00423   hProfile_yTitle          = hPSet_.getParameter<std::string>("Profile_yTitle");
00424             
00425   if( CondObj_name_!= "apvgain" ){
00426     
00427     int nStrip      = reader->getNumberOfApvsAndStripLength(detId_).first*128;
00428         
00429     hProfile_NchX           = nStrip;
00430     hProfile_LowX           = 0.5;
00431     hProfile_HighX          = nStrip+0.5;
00432   }
00433   else {
00434         
00435     int nApv      = reader->getNumberOfApvsAndStripLength(detId_).first;
00436         
00437     hProfile_NchX           = nApv;
00438     hProfile_LowX           = 0.5;
00439     hProfile_HighX          = nApv+0.5;
00440   }
00441       
00442   folder_organizer.setDetectorFolder(detId_); 
00443       
00444   std::string hProfile_Name; 
00445   hProfile_Name = hidmanager.createHistoId(hProfile_description, "det", detId_);
00446       
00447   std::string hProfile;
00448   hProfile = hProfile_Name ;
00449     
00450   CondObj_ME.ProfileDistr = dqmStore_->book1D(hProfile_Name, hProfile, hProfile_NchX, hProfile_LowX, hProfile_HighX);
00451   CondObj_ME.ProfileDistr->setAxisTitle(hProfile_xTitle,1);
00452   CondObj_ME.ProfileDistr->setAxisTitle(hProfile_yTitle,2);
00453   dqmStore_->tag(CondObj_ME.ProfileDistr, detId_);
00454   
00455 }
00456 // -----
00457 
00458 
00459 //=============================================      
00460 // -----
00461 void SiStripBaseCondObjDQM::bookCumulMEs(SiStripBaseCondObjDQM::ModMEs& CondObj_ME, const uint32_t& detId_){
00462 
00463   int    hCumul_NchX    = 0;
00464   double hCumul_LowX    = 0;
00465   double hCumul_HighX   = 0;
00466      
00467   std::string hCumul_description;
00468   hCumul_description   = hPSet_.getParameter<std::string>("Cumul_description");
00469       
00470   std::string hCumul_xTitle, hCumul_yTitle;
00471   hCumul_xTitle        = hPSet_.getParameter<std::string>("Cumul_xTitle");
00472   hCumul_yTitle        = hPSet_.getParameter<std::string>("Cumul_yTitle");
00473       
00474   hCumul_NchX          = hPSet_.getParameter<int>("Cumul_NchX");
00475   hCumul_LowX          = hPSet_.getParameter<double>("Cumul_LowX");
00476   hCumul_HighX         = hPSet_.getParameter<double>("Cumul_HighX");
00477       
00478   folder_organizer.setDetectorFolder(detId_); 
00479       
00480   std::string hCumul_name; 
00481   hCumul_name   = hidmanager.createHistoId(hCumul_description  , "det", detId_); ;
00482       
00483   std::string hCumul_title;
00484   hCumul_title   = hCumul_name ;
00485       
00486   CondObj_ME.CumulDistr = dqmStore_->book1D(hCumul_name, 
00487                                             hCumul_title, 
00488                                             hCumul_NchX, 
00489                                             hCumul_LowX, 
00490                                             hCumul_HighX);
00491   CondObj_ME.CumulDistr->setAxisTitle(hCumul_xTitle,1);
00492   CondObj_ME.CumulDistr->setAxisTitle(hCumul_yTitle,2);
00493   dqmStore_->tag(CondObj_ME.CumulDistr, detId_);
00494       
00495 } 
00496 // ---- 
00497 
00498 
00499 //===========================================
00500 // -----
00501 //#FIXME: same comments: factorize, and remove any reference to derived classes
00502 void SiStripBaseCondObjDQM::bookSummaryProfileMEs(SiStripBaseCondObjDQM::ModMEs& CondObj_ME, const uint32_t& detId_){
00503   
00504   std::vector<uint32_t> sameLayerDetIds_;
00505 
00506   int   hSummaryOfProfile_NchX    = 0;
00507   double hSummaryOfProfile_LowX    = 0;
00508   double hSummaryOfProfile_HighX   = 0;
00509      
00510   std::string hSummaryOfProfile_description;
00511   hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00512       
00513   std::string hSummaryOfProfile_xTitle, hSummaryOfProfile_yTitle;
00514   hSummaryOfProfile_xTitle        = hPSet_.getParameter<std::string>("SummaryOfProfile_xTitle");
00515   hSummaryOfProfile_yTitle        = hPSet_.getParameter<std::string>("SummaryOfProfile_yTitle");
00516   
00517   int hSummaryOfProfile_NchY;
00518   double hSummaryOfProfile_LowY, hSummaryOfProfile_HighY;
00519   hSummaryOfProfile_NchY          = hPSet_.getParameter<int>("SummaryOfProfile_NchY");
00520   hSummaryOfProfile_LowY          = hPSet_.getParameter<double>("SummaryOfProfile_LowY");
00521   hSummaryOfProfile_HighY         = hPSet_.getParameter<double>("SummaryOfProfile_HighY");
00522   
00523   int nStrip, nApv, layerId_;    
00524   
00525   if(CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) { layerId_= getStringNameAndId(detId_).second;}
00526   else                                                          { layerId_= getLayerNameAndId(detId_).second;}
00527 
00528 
00529      
00530   if( CondObj_name_ == "pedestal" || CondObj_name_ == "noise"|| CondObj_name_ == "lowthreshold" || CondObj_name_ == "highthreshold" ){ // plot in strip number
00531     
00532     if( (layerId_ > 610 && layerId_ < 620) || // TID & TEC have 768 strips at maximum
00533         (layerId_ > 620 && layerId_ < 630) ||
00534         (layerId_ > 410 && layerId_ < 414) ||
00535         (layerId_ > 420 && layerId_ < 424) ){ nStrip =768;} 
00536     else { nStrip      = reader->getNumberOfApvsAndStripLength(detId_).first*128;}
00537     
00538     hSummaryOfProfile_NchX           = nStrip;
00539     hSummaryOfProfile_LowX           = 0.5;
00540     hSummaryOfProfile_HighX          = nStrip+0.5;
00541   
00542   }  
00543   else if( (CondObj_name_ == "lorentzangle" && SummaryOnLayerLevel_On_) || CondObj_name_ == "quality"){ // plot in detId-number
00544 
00545     // -----
00546     // get detIds belonging to same layer to fill X-axis with detId-number
00547                                            
00548     uint32_t subDetId_ =  ((detId_>>25)&0x7);
00549     SiStripSubStructure substructure_;
00550   
00551     sameLayerDetIds_.clear();
00552   
00553     if(subDetId_==3){  //  TIB
00554       substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_,TIBDetId(detId_).layerNumber(),0,0,TIBDetId(detId_).stringNumber());  
00555     }
00556     else if(subDetId_==4){  // TID
00557       substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_,0,0,0,0);
00558     }
00559     else if(subDetId_==5){  // TOB
00560       substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, TOBDetId(detId_).layerNumber(),0,0);
00561     }
00562     else if(subDetId_==6){  // TEC
00563       substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
00564     }
00565 
00566     hSummaryOfProfile_NchX           = sameLayerDetIds_.size(); 
00567     hSummaryOfProfile_LowX           = 0.5;
00568     hSummaryOfProfile_HighX          = sameLayerDetIds_.size()+0.5;
00569  
00570   } 
00571   else if( CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_){ // plot in detId-number
00572 
00573     // -----
00574     // get detIds belonging to same string to fill X-axis with detId-number
00575                                            
00576     uint32_t subDetId_ =  ((detId_>>25)&0x7);
00577     SiStripSubStructure substructure_;
00578     
00579     sameLayerDetIds_.clear(); 
00580     
00581     if(subDetId_==3){  //  TIB    
00582       if(TIBDetId(detId_).isInternalString()){
00583         substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(detId_).layerNumber(),0,1,TIBDetId(detId_).stringNumber()); }
00584       else if(TIBDetId(detId_).isExternalString()){
00585         substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds_, TIBDetId(detId_).layerNumber(),0,2,TIBDetId(detId_).stringNumber()); }
00586     }
00587     else if(subDetId_==4){  // TID
00588       substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0);
00589     }
00590     else if(subDetId_==5){  // TOB
00591       substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds_, TOBDetId(detId_).layerNumber(),0,TOBDetId(detId_).rodNumber());
00592     }
00593     else if(subDetId_==6){  // TEC
00594       substructure_.getTECDetectors(activeDetIds, sameLayerDetIds_, 0,0,0,0,0,0);
00595     }
00596 
00597 
00598     hSummaryOfProfile_NchX           = sameLayerDetIds_.size(); 
00599     hSummaryOfProfile_LowX           = 0.5;
00600     hSummaryOfProfile_HighX          = sameLayerDetIds_.size()+0.5;
00601  
00602   } 
00603   else if( CondObj_name_ == "apvgain"){
00604  
00605     if( (layerId_ > 610 && layerId_ < 620) || // TID & TEC have 6 apvs at maximum
00606         (layerId_ > 620 && layerId_ < 630) ||
00607         (layerId_ > 410 && layerId_ < 414) ||
00608         (layerId_ > 420 && layerId_ < 424) ){ nApv =6;} 
00609     else { nApv     = reader->getNumberOfApvsAndStripLength(detId_).first;}
00610     
00611     hSummaryOfProfile_NchX           = nApv;
00612     hSummaryOfProfile_LowX           = 0.5;
00613     hSummaryOfProfile_HighX          = nApv+0.5;
00614  
00615   }
00616   else {
00617     edm::LogWarning("SiStripBaseCondObjDQM") 
00618        << "[SiStripBaseCondObjDQM::bookSummaryProfileMEs] PLEASE CHECK : x-axis label in your cfg"
00619        << std::endl; 
00620   }
00621   
00622   uint32_t layer_=0;
00623       
00624   layer_ = folder_organizer.GetSubDetAndLayer(detId_).second;
00625       
00626   folder_organizer.setLayerFolder(detId_,layer_); 
00627       
00628   std::string hSummaryOfProfile_name; 
00629   
00630   // ---
00631   int subdetectorId_ = ((detId_>>25)&0x7);
00632   
00633  
00634   if( subdetectorId_<3 ||subdetectorId_>6 ){ 
00635     edm::LogError("SiStripBaseCondObjDQM")
00636        << "[SiStripBaseCondObjDQM::bookSummaryProfileMEs] WRONG INPUT : no such subdetector type : "
00637        << subdetectorId_ << " no folder set!" 
00638        << std::endl;
00639     return;
00640   }
00641   // ---
00642   
00643   if(CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) { 
00644     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer" , getStringNameAndId(detId_).first,"") ;
00645   }
00646   else {
00647     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer" , getLayerNameAndId(detId_).first,"") ;
00648   }
00649       
00650   std::string hSummaryOfProfile_title;
00651   hSummaryOfProfile_title   = hSummaryOfProfile_name ;
00652            
00653   CondObj_ME.SummaryOfProfileDistr = dqmStore_->bookProfile(hSummaryOfProfile_name, 
00654                                                             hSummaryOfProfile_title, 
00655                                                             hSummaryOfProfile_NchX, 
00656                                                             hSummaryOfProfile_LowX, 
00657                                                             hSummaryOfProfile_HighX, 
00658                                                             hSummaryOfProfile_NchY, 
00659                                                             hSummaryOfProfile_LowY, 
00660                                                             hSummaryOfProfile_HighY);
00661   CondObj_ME.SummaryOfProfileDistr->setAxisTitle(hSummaryOfProfile_xTitle,1);
00662   CondObj_ME.SummaryOfProfileDistr->setAxisTitle(hSummaryOfProfile_yTitle,2);
00663   CondObj_ME.SummaryOfProfileDistr->setAxisRange(hSummaryOfProfile_LowY, hSummaryOfProfile_HighY,2);
00664  
00665   // -----
00666   // in order to get the right detId-number labelled in right bin of x-axis
00667   
00668   if( CondObj_name_ == "quality" ){
00669     
00670     unsigned int iBin=0;
00671     
00672     for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00673     
00674       iBin++;
00675       char sameLayerDetIds_Name[1024];
00676       sprintf(sameLayerDetIds_Name,"%u",sameLayerDetIds_[i]);
00677       CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, sameLayerDetIds_Name);
00678     
00679     }
00680   } 
00681   if( CondObj_name_ == "lorentzangle"){
00682 
00683     // Put the detIds for the -z side as following the geometrical order:
00684       reverse(sameLayerDetIds_.begin(), sameLayerDetIds_.begin()+sameLayerDetIds_.size()/2);
00685 
00686       unsigned int iBin=0;
00687        for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){ 
00688          iBin++;
00689          if (!SummaryOnStringLevel_On_){
00690            // remove the label for detIds:
00691              CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, "");
00692          }  
00693      
00694          if (SummaryOnStringLevel_On_){
00695       // Label with module position instead of detIds:
00696            char sameLayerDetIds_Name[1024];
00697            if(subdetectorId_==3){//re-abelling for TIB
00698              if(TIBDetId(sameLayerDetIds_[i]).isZPlusSide()){
00699                sprintf(sameLayerDetIds_Name,"%i",TIBDetId(sameLayerDetIds_[i]).module());}
00700              else if(TIBDetId(sameLayerDetIds_[i]).isZMinusSide()){
00701                sprintf(sameLayerDetIds_Name,"%i",-TIBDetId(sameLayerDetIds_[i]).module());}
00702              CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, sameLayerDetIds_Name);
00703            }
00704            else if(subdetectorId_==5){//re-abelling for TOB
00705              if(TOBDetId(sameLayerDetIds_[i]).isZPlusSide())      { sprintf(sameLayerDetIds_Name,"%i",TOBDetId(sameLayerDetIds_[i]).module());}
00706              else if(TOBDetId(sameLayerDetIds_[i]).isZMinusSide()) { sprintf(sameLayerDetIds_Name,"%i",-TOBDetId(sameLayerDetIds_[i]).module());}
00707              CondObj_ME.SummaryOfProfileDistr->setBinLabel(iBin, sameLayerDetIds_Name);
00708            }
00709          }
00710        } 
00711  
00712        
00713 
00714 
00715   // -----
00716       
00717   dqmStore_->tag(CondObj_ME.SummaryOfProfileDistr, layer_);
00718       
00719   } // if "lorentzangle"
00720 
00721 }
00722 // ---- 
00723 
00724 
00725 //=============================================================
00726 // -----
00727 void SiStripBaseCondObjDQM::bookSummaryCumulMEs(SiStripBaseCondObjDQM::ModMEs& CondObj_ME, const uint32_t& detId_){
00728     
00729   int   hSummaryOfCumul_NchX    = 0;
00730   double hSummaryOfCumul_LowX    = 0;
00731   double hSummaryOfCumul_HighX   = 0;
00732         
00733   std::string hSummaryOfCumul_description;
00734   hSummaryOfCumul_description  = hPSet_.getParameter<std::string>("SummaryOfCumul_description");
00735         
00736   std::string hSummaryOfCumul_xTitle, hSummaryOfCumul_yTitle;
00737   hSummaryOfCumul_xTitle        = hPSet_.getParameter<std::string>("SummaryOfCumul_xTitle");
00738   hSummaryOfCumul_yTitle        = hPSet_.getParameter<std::string>("SummaryOfCumul_yTitle");
00739         
00740   hSummaryOfCumul_NchX          = hPSet_.getParameter<int>("SummaryOfCumul_NchX");
00741   hSummaryOfCumul_LowX          = hPSet_.getParameter<double>("SummaryOfCumul_LowX");
00742   hSummaryOfCumul_HighX         = hPSet_.getParameter<double>("SummaryOfCumul_HighX");
00743         
00744   uint32_t layer_=0;
00745         
00746   layer_ = folder_organizer.GetSubDetAndLayer(detId_).second;
00747         
00748   folder_organizer.setLayerFolder(detId_,layer_); 
00749         
00750   std::string hSummaryOfCumul_name; 
00751   
00752   // ---
00753   int subdetectorId_ = ((detId_>>25)&0x7);
00754   
00755   if( subdetectorId_<3 || subdetectorId_>6 ){ 
00756     edm::LogError("SiStripBaseCondObjDQM")
00757        << "[SiStripBaseCondObjDQM::bookSummaryCumulMEs] WRONG INPUT : no such subdetector type : "
00758        << subdetectorId_ << " no folder set!" 
00759        << std::endl;
00760     return;
00761   }
00762   // ---
00763   
00764   // LA Histos are plotted for each string:
00765   if(CondObj_name_ == "lorentzangle" && SummaryOnStringLevel_On_) { 
00766     hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer" , getStringNameAndId(detId_).first, "") ;
00767   }
00768   else {  
00769     hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer" , getLayerNameAndId(detId_).first, "") ;
00770   }
00771 
00772         
00773   std::string hSummaryOfCumul_title;
00774   hSummaryOfCumul_title   = hSummaryOfCumul_name ;
00775         
00776   CondObj_ME.SummaryOfCumulDistr = dqmStore_->book1D(hSummaryOfCumul_name, 
00777                                                      hSummaryOfCumul_title, 
00778                                                      hSummaryOfCumul_NchX, 
00779                                                      hSummaryOfCumul_LowX, 
00780                                                      hSummaryOfCumul_HighX);
00781 
00782   CondObj_ME.SummaryOfCumulDistr->setAxisTitle(hSummaryOfCumul_xTitle,1);
00783   CondObj_ME.SummaryOfCumulDistr->setAxisTitle(hSummaryOfCumul_yTitle,2);
00784         
00785   dqmStore_->tag(CondObj_ME.SummaryOfCumulDistr, layer_);
00786         
00787 }
00788 // -----
00789 
00790 //================================================
00791 // -----
00792 //FIXME same as before: factorize
00793 void SiStripBaseCondObjDQM::bookSummaryMEs(SiStripBaseCondObjDQM::ModMEs& CondObj_ME, const uint32_t& detId_){
00794   
00795   std::vector<uint32_t> sameLayerDetIds_;
00796 
00797   int   hSummary_NchX    = 0;
00798   double hSummary_LowX    = 0;
00799   double hSummary_HighX   = 0;
00800      
00801   std::string hSummary_description;
00802   hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00803       
00804   std::string hSummary_xTitle, hSummary_yTitle;
00805   hSummary_xTitle        = hPSet_.getParameter<std::string>("Summary_xTitle");
00806   hSummary_yTitle        = hPSet_.getParameter<std::string>("Summary_yTitle");
00807   
00808   int hSummary_NchY;
00809   double hSummary_LowY, hSummary_HighY;
00810   hSummary_NchY          = hPSet_.getParameter<int>("Summary_NchY");
00811   hSummary_LowY          = hPSet_.getParameter<double>("Summary_LowY");
00812   hSummary_HighY         = hPSet_.getParameter<double>("Summary_HighY");
00813        
00814 
00815   // -----
00816   // get detIds belonging to same layer to fill X-axis with detId-number
00817                                            
00818   
00819   sameLayerDetIds_.clear();
00820    
00821   sameLayerDetIds_=GetSameLayerDetId(activeDetIds,detId_);
00822 
00823   hSummary_NchX           = sameLayerDetIds_.size(); 
00824   hSummary_LowX           = 0.5;
00825   hSummary_HighX          = sameLayerDetIds_.size()+0.5;
00826   
00827   uint32_t layer_=0;
00828       
00829   layer_ = folder_organizer.GetSubDetAndLayer(detId_).second;
00830       
00831   folder_organizer.setLayerFolder(detId_,layer_); 
00832       
00833   std::string hSummary_name; 
00834   
00835   // ---
00836   int subdetectorId_ = ((detId_>>25)&0x7);
00837   
00838  
00839   if( subdetectorId_<3 ||subdetectorId_>6 ){ 
00840     edm::LogError("SiStripBaseCondObjDQM")
00841        << "[SiStripBaseCondObjDQM::bookSummaryMEs] WRONG INPUT : no such subdetector type : "
00842        << subdetectorId_ << " no folder set!" 
00843        << std::endl;
00844     return;
00845   }
00846   // ---
00847   
00848   hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00849                                                        "layer" , 
00850                                                         getLayerNameAndId(detId_).first,
00851                                                         "") ;
00852       
00853   std::string hSummary_title;
00854   hSummary_title   = hSummary_name ;
00855            
00856   CondObj_ME.SummaryDistr = dqmStore_->bookProfile(hSummary_name, 
00857                                                    hSummary_title, 
00858                                                    hSummary_NchX, 
00859                                                    hSummary_LowX, 
00860                                                    hSummary_HighX, 
00861                                                    hSummary_NchY, 
00862                                                    hSummary_LowY, 
00863                                                    hSummary_HighY);
00864   CondObj_ME.SummaryDistr->setAxisTitle(hSummary_xTitle,1);
00865   CondObj_ME.SummaryDistr->setAxisTitle(hSummary_yTitle,2);
00866   CondObj_ME.SummaryDistr->setAxisRange(hSummary_LowY, hSummary_HighY,2);
00867  
00868   // -----
00869   // in order to get the right detId-number labelled in right bin of x-axis
00870   unsigned int iBin=0;
00871     
00872   for(unsigned int i=0;i< sameLayerDetIds_.size(); i++){
00873     
00874     iBin++;
00875     char sameLayerDetIds_Name[1024];
00876     sprintf(sameLayerDetIds_Name,"%u",sameLayerDetIds_[i]);
00877     if(iBin%100==0)
00878       CondObj_ME.SummaryDistr->setBinLabel(iBin, sameLayerDetIds_Name);
00879     
00880   }
00881   // -----
00882       
00883   dqmStore_->tag(CondObj_ME.SummaryDistr, layer_);
00884       
00885 } 
00886 
00887 
00888 //==========================================================
00889 // -----
00890 std::pair<std::string,uint32_t> SiStripBaseCondObjDQM::getLayerNameAndId(const uint32_t& detId_){
00891 
00892   int subdetectorId_ = ((detId_>>25)&0x7);
00893   int layerId_=0;
00894 
00895   std::stringstream layerName;
00896   
00897   if( subdetectorId_ == 3 ){ //TIB
00898 
00899     for( unsigned int i = 1; i < 5; i++ ){
00900       if( TIBDetId( detId_ ).layer() ==i ){ 
00901         layerName << "TIB__layer__" << i;
00902         layerId_ = 300 + i;
00903       }
00904     }
00905     
00906   }
00907 
00908   else if( subdetectorId_ == 4 ){ //TIDD
00909     
00910     if( TIDDetId( detId_ ).side() == 1 ) { // TIDD side 1
00911       
00912       for( unsigned int i = 1; i < 4; i++ ){
00913         if(TIDDetId(detId_).wheel()==i){ 
00914           layerName << "TID__side__1__wheel__" << i;
00915           layerId_ = 410 + i;
00916         }
00917       }
00918       
00919     }
00920 
00921     else if( TIDDetId( detId_ ).side() == 2 ) { // TIDD side 2
00922       
00923       for( unsigned int i = 1; i < 4; i++ ) {
00924         if(TIDDetId(detId_).wheel()==i){ 
00925           layerName << "TID__side__2__wheel__" << i;
00926           layerId_ = 420 + i;
00927         }
00928       }
00929 
00930     }
00931 
00932   }
00933 
00934 
00935   else if( subdetectorId_ == 5 ){ // TOB
00936     
00937     for( unsigned int i = 1; i < 7; i++ ) {
00938       if( TOBDetId( detId_ ).layer() == i ) { 
00939         layerName << "TOB__layer__" << i;
00940         layerId_ = 500 + i;
00941       }
00942     }
00943     
00944   }
00945 
00946   else if( subdetectorId_ == 6 ){ // TEC
00947     
00948     if( TECDetId( detId_ ).side() == 1) { // TEC side 1
00949       
00950       for( unsigned int i = 1; i < 10; i++ ) {
00951         if( TECDetId( detId_ ).wheel() == i ) { 
00952           layerName << "TEC__side__1__wheel__" << i;
00953           layerId_ = 610 + i;
00954         }
00955       }
00956 
00957     }
00958 
00959     else if( TECDetId( detId_ ).side() == 2 ) { // TEC side 2
00960       
00961       for( unsigned int i = 1; i < 10; i++ ) {
00962         if( TECDetId( detId_ ).wheel() == i ) { 
00963           layerName << "TEC__side__2__wheel__" << i;
00964           layerId_ = 620 + i;
00965         }
00966       }
00967 
00968      }
00969   }
00970   
00971   return std::make_pair( layerName.str(), layerId_ );
00972 
00973 }
00974 
00975 //=================================================
00976 //---------------
00977 
00978 
00979 std::pair<std::string,uint32_t> SiStripBaseCondObjDQM::getStringNameAndId(const uint32_t& detId_){
00980 
00981   int subdetectorId_ = ((detId_>>25)&0x7);
00982   int layerStringId_=0;
00983   
00984   std::stringstream layerStringName;
00985   
00986   if( subdetectorId_==3 ){ //TIB
00987     if(TIBDetId(detId_).layer()==1 && TIBDetId(detId_).isInternalString()){ //1st layer int
00988       for( unsigned int i=1; i < 27 ;i++){
00989         if(TIBDetId(detId_).stringNumber()==i){  
00990           layerStringName << "TIB_L1_Int_Str_" << i;
00991           layerStringId_ = 30110+i; 
00992         }
00993       }      
00994     }
00995     else  if(TIBDetId(detId_).layer()==1 && TIBDetId(detId_).isExternalString()){ //1st layer ext
00996       for( unsigned int i=1; i < 31 ;i++){
00997         if(TIBDetId(detId_).stringNumber()==i){  
00998           layerStringName << "TIB_L1_Ext_Str_" << i;
00999           layerStringId_ = 301200+i; 
01000         }
01001       }      
01002     }
01003     else if(TIBDetId(detId_).layer()==2 && TIBDetId(detId_).isInternalString()){ //2nd layer int
01004       for( unsigned int i=1; i < 35 ;i++){
01005         if(TIBDetId(detId_).stringNumber()==i){  
01006           layerStringName << "TIB_L2_Int_Str_" << i;
01007           layerStringId_ = 302100+i; 
01008         }
01009       }      
01010     }
01011     else if(TIBDetId(detId_).layer()==2 && TIBDetId(detId_).isExternalString()){ //2nd layer ext
01012       for( unsigned int i=1; i < 39 ;i++){
01013         if(TIBDetId(detId_).stringNumber()==i){  
01014           layerStringName << "TIB_L2_Ext_Str_" << i;
01015           layerStringId_ = 302200+i; 
01016         }
01017       }      
01018     }
01019     else if(TIBDetId(detId_).layer()==3 && TIBDetId(detId_).isInternalString()){ //3rd layer int
01020       for( unsigned int i=1; i < 45 ;i++){
01021         if(TIBDetId(detId_).stringNumber()==i){  
01022           layerStringName << "TIB_L3_Int_Str_" << i;
01023           layerStringId_ = 303100+i; 
01024         }
01025       }      
01026     }
01027     else if(TIBDetId(detId_).layer()==3 && TIBDetId(detId_).isExternalString()){ //3rd layer ext
01028       for( unsigned int i=1; i < 47 ;i++){
01029         if(TIBDetId(detId_).stringNumber()==i){  
01030           layerStringName << "TIB_L3_Ext_Str_" << i;
01031           layerStringId_ = 303200+i; 
01032         }
01033       }      
01034     }
01035     else if(TIBDetId(detId_).layer()==4 && TIBDetId(detId_).isInternalString()){ //4th layer int
01036       for( unsigned int i=1; i < 53 ;i++){
01037         if(TIBDetId(detId_).stringNumber()==i){  
01038           layerStringName << "TIB_L4_Int_Str_" << i;
01039           layerStringId_ = 304100+i; 
01040         }
01041       }      
01042     }
01043     else if(TIBDetId(detId_).layer()==4 && TIBDetId(detId_).isExternalString()){ //4th layer ext
01044       for( unsigned int i=1; i < 57 ;i++){
01045         if(TIBDetId(detId_).stringNumber()==i){  
01046           layerStringName << "TIB_L4_Ext_Str_" << i;
01047           layerStringId_ = 304200+i; 
01048         }
01049       }      
01050     }
01051   } //TIB
01052 
01053 
01054   else if( subdetectorId_==5 ){ // TOB
01055     if(TOBDetId(detId_).layer()==1){ //1st layer
01056       for( unsigned int i=1; i < 43 ;i++){
01057         if(TOBDetId(detId_).rodNumber()==i){  
01058           layerStringName << "TOB_L1_Rod_" << i;
01059           layerStringId_ = 50100+i;
01060         }
01061       }      
01062     }
01063     else if(TOBDetId(detId_).layer()==2){ //2nd layer
01064       for( unsigned int i=1; i < 49 ;i++){
01065         if(TOBDetId(detId_).rodNumber()==i){  
01066           layerStringName << "TOB_L2_Rod_" << i;
01067           layerStringId_ = 50200+i; 
01068         }
01069       }      
01070     }
01071     else if(TOBDetId(detId_).layer()==3){ //3rd layer
01072       for( unsigned int i=1; i < 55 ;i++){
01073         if(TOBDetId(detId_).rodNumber()==i){  
01074           layerStringName << "TOB_L3_Rod_" << i;
01075           layerStringId_ = 50300+i; 
01076         }
01077       }      
01078     }
01079     else if(TOBDetId(detId_).layer()==4){ //4th layer
01080       for( unsigned int i=1; i < 61 ;i++){
01081         if(TOBDetId(detId_).rodNumber()==i){  
01082           layerStringName << "TOB_L4_Rod_" << i;
01083           layerStringId_ = 50400+i; 
01084         }
01085       }      
01086     }
01087     else if(TOBDetId(detId_).layer()==5){ //5th layer
01088       for( unsigned int i=1; i < 67 ;i++){
01089         if(TOBDetId(detId_).rodNumber()==i){  
01090           layerStringName << "TOB_L5_Rod_" << i;
01091           layerStringId_ = 50500+i; 
01092         }
01093       }      
01094     }
01095     else if(TOBDetId(detId_).layer()==6){ //6st layer
01096       for( unsigned int i=1; i < 75 ;i++){
01097         if(TOBDetId(detId_).rodNumber()==i){  
01098           layerStringName << "TOB_L6_Rod_" << i;
01099           layerStringId_ = 50600+i; 
01100         }
01101       }      
01102     }
01103   }//TOB
01104 
01105   return std::make_pair( layerStringName.str(), layerStringId_ );
01106 
01107 }
01108 
01109 
01110 
01111     
01112 //========================
01113 std::vector<uint32_t> SiStripBaseCondObjDQM::GetSameLayerDetId(std::vector<uint32_t> activeDetIds,uint32_t selDetId ){
01114  
01115   std::vector<uint32_t> sameLayerDetIds;
01116   sameLayerDetIds.clear();
01117 
01118   SiStripSubStructure substructure_;
01119   
01120   uint32_t subselDetId_ =  ((selDetId>>25)&0x7);
01121 
01122   if(subselDetId_==3){  //  TIB
01123     substructure_.getTIBDetectors(activeDetIds, sameLayerDetIds, TIBDetId(selDetId).layer(),0,0,0);  
01124   }
01125   else if(subselDetId_==4){  // TID
01126     substructure_.getTIDDetectors(activeDetIds, sameLayerDetIds, TIDDetId(selDetId).side(),TIDDetId(selDetId).wheel(),0,0);
01127   }
01128   else if(subselDetId_==5){  // TOB
01129     substructure_.getTOBDetectors(activeDetIds, sameLayerDetIds, TOBDetId(selDetId).layer(),0,0);
01130   }
01131   else if(subselDetId_==6){  // TEC
01132     substructure_.getTECDetectors(activeDetIds, sameLayerDetIds, TECDetId(selDetId).side(),TECDetId(selDetId).wheel(),0,0,0,0);
01133   }
01134 
01135   return sameLayerDetIds;
01136   
01137 }
01138 
01139 
01140 //==========================
01141 void SiStripBaseCondObjDQM::bookTkMap(const std::string& TkMapname){
01142   tkMap= new TrackerMap(TkMapname.c_str());
01143 }
01144 
01145 //==========================
01146 void SiStripBaseCondObjDQM::fillTkMap(const uint32_t& detid, const float& value){
01147   tkMap->fill(detid,value);
01148 }
01149 
01150 //==========================
01151 void SiStripBaseCondObjDQM::saveTkMap(const std::string& TkMapname, double minValue, double maxValue){
01152   if(tkMapScaler.size()!=0){
01153     //check that saturation is below x%  below minValue and above minValue, and in case re-arrange.
01154     float th=hPSet_.getParameter<double>("saturatedFraction");
01155 
01156     size_t imin=0,imax=0;
01157     float entries=0 ;
01158     for(size_t i=0;i<tkMapScaler.size();++i)
01159       entries+=tkMapScaler[i];
01160 
01161     float min=0 ;
01162     for(size_t i=0;(i<tkMapScaler.size()) && (min<th);++i){
01163       min+=tkMapScaler[i]/entries;
01164       imin=i;
01165     }
01166 
01167     float max=0;
01168     // for(size_t i=tkMapScaler.size()-1;(i>=0) && (max<th);--i){ // Wrong
01169     // Since i is unsigned, i >= 0 is always true,
01170     // and the loop termination condition is never reached.
01171     // We offset the loop index by one to fix this.
01172     for(size_t j=tkMapScaler.size();(j>0) && (max<th);--j){ 
01173       size_t i = j - 1;
01174       max+=tkMapScaler[i]/entries;
01175       imax=i;
01176     }
01177     
01178     //reset maxValue;
01179     if(maxValue<imax){
01180       edm::LogInfo("")<< "Resetting TkMap maxValue from " << maxValue << " to " << imax;
01181       maxValue=imax;
01182     }
01183     //reset minValue;
01184     if(minValue>imin){
01185       edm::LogInfo("")<< "Resetting TkMap minValue from " << minValue << " to " << imin;
01186       minValue=imin;
01187     }
01188   }
01189 
01190   tkMap->save(false, minValue, maxValue, TkMapname.c_str());
01191   tkMap->setPalette(1); tkMap->showPalette(true);
01192 
01193 }
01194 
01195 
01196 //==========================
01197 void SiStripBaseCondObjDQM::end(){
01198   edm::LogInfo("SiStripBaseCondObjDQM") 
01199     << "SiStripBase::end"
01200     << std::endl; 
01201 }
01202 
01203 //==========================
01204 void SiStripBaseCondObjDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds){
01205   ModMEs CondObj_ME;
01206  
01207   for(std::vector<uint32_t>::const_iterator detIter_=selectedDetIds.begin();
01208                                            detIter_!=selectedDetIds.end();++detIter_){
01209     fillMEsForDet(CondObj_ME,*detIter_);
01210   }
01211 }
01212 
01213 //==========================
01214 void SiStripBaseCondObjDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
01215   
01216   for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
01217       detIter_!= selectedDetIds.end();detIter_++){
01218     fillMEsForLayer(SummaryMEsMap_, *detIter_);    
01219   }
01220 
01221   for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
01222 
01223     ModMEs selME;
01224     selME = iter->second;
01225 
01226     if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
01227 
01228       if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
01229 
01230         TCanvas c1("c1");
01231         selME.SummaryOfProfileDistr->getTProfile()->Draw();
01232         std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
01233         name+=".png";
01234         c1.Print(name.c_str());
01235       }
01236     }
01237     if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
01238 
01239       TCanvas c1("c1");
01240       selME.SummaryDistr->getTH1()->Draw();
01241       std::string name (selME.SummaryDistr->getTH1()->GetTitle());
01242       name+=".png";
01243       c1.Print(name.c_str());
01244     }
01245     if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputCumulativeSummaryAtLayerLevelAsImage")){
01246 
01247       if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
01248 
01249         TCanvas c1("c1");
01250         selME.SummaryOfCumulDistr->getTH1()->Draw();
01251         std::string name (selME.SummaryOfCumulDistr->getTH1()->GetTitle());
01252         name+=".png";
01253         c1.Print(name.c_str());
01254       }
01255     }
01256 
01257   }
01258  
01259 }