CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQM/SiStripMonitorSummary/src/SiStripApvGainsDQM.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripMonitorSummary/interface/SiStripApvGainsDQM.h"
00002 
00003 
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "TCanvas.h"
00006 
00007 // -----
00008 SiStripApvGainsDQM::SiStripApvGainsDQM(const edm::EventSetup & eSetup,
00009                                        edm::ParameterSet const& hPSet,
00010                                        edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup,hPSet, fPSet){
00011 
00012   // Build the Histo_TkMap:
00013   if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","MeanApvGain_TkMap",0.);
00014 
00015 }
00016 // -----
00017 
00018 // -----
00019 SiStripApvGainsDQM::~SiStripApvGainsDQM(){}
00020 // -----
00021 
00022 
00023 // -----
00024 void SiStripApvGainsDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00025 
00026   getConditionObject(eSetup);
00027   gainHandle_->getDetIds(activeDetIds);
00028 
00029 }
00030 // -----
00031 
00032 
00033 
00034 
00035 // -----
00036 void SiStripApvGainsDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds){
00037 
00038   ModMEs CondObj_ME;
00039 
00040   for(std::vector<uint32_t>::const_iterator detIter_ =selectedDetIds.begin();
00041       detIter_!=selectedDetIds.end();++detIter_){
00042     fillMEsForDet(CondObj_ME,*detIter_);
00043   }  
00044 }  
00045 
00046   
00047 // -----
00048 void SiStripApvGainsDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
00049   
00050   std::vector<uint32_t> DetIds;
00051   gainHandle_->getDetIds(DetIds);
00052 
00053   SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00054   
00055   int nApv =  reader->getNumberOfApvsAndStripLength(selDetId_).first;
00056     
00057   getModMEs(selModME_,selDetId_);
00058  
00059   for( int iapv=0;iapv<nApv;++iapv){
00060     try{
00061       if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00062         selModME_.ProfileDistr->Fill(iapv+1,gainHandle_->getApvGain(iapv,gainRange));
00063       }
00064       if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00065         selModME_.CumulDistr  ->Fill(gainHandle_->getApvGain(iapv,gainRange));
00066       }
00067 
00068     // Fill the TkMap
00069     if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00070       fillTkMap(selDetId_, gainHandle_->getApvGain(iapv,gainRange));
00071     }
00072 
00073     } 
00074     catch(cms::Exception& e){
00075       edm::LogError("SiStripApvGainsDQM")          
00076         << "[SiStripApvGainsDQM::fillMEsForDet] cms::Exception accessing gainHandle_->getApvGain(iapv,gainRange) for apv "  
00077         << iapv 
00078         << " and detid " 
00079         << selDetId_  
00080         << " :  " 
00081         << e.what() ;
00082     }
00083   }
00084 }
00085 
00086 // -----
00087 void SiStripApvGainsDQM::fillSummaryMEs(const std::vector<uint32_t>  & selectedDetIds){
00088   
00089   for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00090       detIter_!= selectedDetIds.end();detIter_++){
00091     fillMEsForLayer(SummaryMEsMap_, *detIter_);
00092   }
00093 
00094   for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
00095 
00096     ModMEs selME;
00097     selME = iter->second;
00098 
00099     if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
00100 
00101       TCanvas c1("c1");
00102       selME.SummaryOfProfileDistr->getTProfile()->Draw();
00103       std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
00104       name+=".png";
00105       c1.Print(name.c_str());
00106     }
00107     if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
00108 
00109       TCanvas c1("c1");
00110       selME.SummaryDistr->getTH1()->Draw();
00111       std::string name (selME.SummaryDistr->getTH1()->GetTitle());
00112       name+=".png";
00113       c1.Print(name.c_str());
00114     }
00115   }
00116 
00117 }  
00118 
00119 // -----
00120 void SiStripApvGainsDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00121     
00122   int subdetectorId_ = ((selDetId_>>25)&0x7);
00123   
00124   if( subdetectorId_<3 ||subdetectorId_>6 ){ 
00125     edm::LogError("SiStripApvGainsDQM")
00126       << "[SiStripApvGainsDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00127       << subdetectorId_ << " no folder set!" 
00128       << std::endl;
00129     return;
00130   }
00131   // ----
00132          
00133   std::map<uint32_t, ModMEs>::iterator selMEsMapIter_  = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00134   ModMEs selME_;
00135   selME_ =selMEsMapIter_->second;
00136   getSummaryMEs(selME_,selDetId_);
00137   
00138   SiStripApvGain::Range gainRange = gainHandle_->getRange(selDetId_);
00139   int nApv =  reader->getNumberOfApvsAndStripLength(selDetId_).first;
00140   
00141   float meanApvGain=0;
00142 
00143   SiStripHistoId hidmanager;
00144 
00145   if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00146 
00147     // --> profile summary    
00148     std::string hSummaryOfProfile_description;
00149     hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00150   
00151     std::string hSummaryOfProfile_name; 
00152     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, 
00153                                                          "layer", 
00154                                                          getLayerNameAndId(selDetId_).first, "") ;
00155   
00156     for( int iapv=0;iapv<nApv;++iapv){
00157     
00158       try{ 
00159         meanApvGain = meanApvGain +gainHandle_ ->getApvGain(iapv,gainRange);
00160         selME_.SummaryOfProfileDistr->Fill(iapv+1,gainHandle_->getApvGain(iapv,gainRange));
00161       } 
00162       catch(cms::Exception& e){
00163         edm::LogError("SiStripApvGainsDQM")          
00164           << "[SiStripApvGainsDQM::fillMEsForLayer] cms::Exception accessing gainHandle_->getApvGain(istrip,gainRange) for strip "  
00165           << iapv
00166           << " and detid " 
00167           << selDetId_  
00168           << " :  " 
00169           << e.what() ;
00170       }
00171 
00172     // Fill the TkMap
00173     if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00174       fillTkMap(selDetId_, gainHandle_->getApvGain(iapv,gainRange));
00175     }
00176 
00177     }// iapv
00178 
00179     meanApvGain  = meanApvGain/nApv;
00180 
00181     // Fill the TkHistoMap with meanApvgain:
00182     if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
00183 
00184   }//if Fill ...
00185 
00186 
00187   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00188   
00189     // -->  summary    
00190     std::string hSummary_description;
00191     hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00192   
00193     std::string hSummary_name; 
00194     hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00195                                                 "layer", 
00196                                                 getLayerNameAndId(selDetId_).first, 
00197                                                 "") ;
00198 
00199 
00200     // get detIds belonging to same layer to fill X-axis with detId-number
00201   
00202     std::vector<uint32_t> sameLayerDetIds_;
00203   
00204     sameLayerDetIds_.clear();
00205 
00206     sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00207   
00208     unsigned int iBin=0;
00209     for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
00210       if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
00211     }
00212 
00213     for( int iapv=0;iapv<nApv;++iapv){
00214       try{
00215         meanApvGain = meanApvGain +gainHandle_ ->getApvGain(iapv,gainRange);
00216         selME_.SummaryDistr->Fill(iBin,gainHandle_->getApvGain(iapv,gainRange));
00217       }
00218       catch(cms::Exception& e){
00219         edm::LogError("SiApvGainsDQM")          
00220           << "[SiStripApvGainsDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->gainHandle_->getApvGain(iapv,gainRange) for apv "  
00221           << iapv
00222           << "and detid " 
00223           << selDetId_  
00224           << " :  " 
00225           << e.what() ;
00226       }
00227     }//iapv
00228     meanApvGain  = meanApvGain/nApv;
00229 
00230     // Fill the TkHistoMap with meanApvgain:
00231     //    if(HistoMaps_On_ ) Tk_HM_->setBinContent(selDetId_, meanApvGain);
00232 
00233   }//if Fill ...
00234 }  
00235 // -----
00236 
00237 
00238 
00239 
00240 
00241