CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DQM/SiStripMonitorSummary/src/SiStripPedestalsDQM.cc

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