CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/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_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
00128   ModMEs selME_;
00129   if ( selMEsMapIter_ != SummaryMEsMap_.end())
00130     selME_ =selMEsMapIter_->second;
00131   getSummaryMEs(selME_,selDetId_);
00132     
00133   SiStripPedestals::Range pedRange = pedestalHandle_->getRange(selDetId_);
00134   
00135   int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00136   
00137   SiStripHistoId hidmanager;
00138 
00139    if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00140   
00141      // --> profile summary    
00142   
00143      std::string hSummaryOfProfile_description;
00144      hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00145   
00146      std::string hSummaryOfProfile_name; 
00147   
00148   
00149     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, 
00150                                                          "layer", 
00151                                                          getLayerNameAndId(selDetId_).first, 
00152                                                          "") ;
00153  
00154     for( int istrip=0;istrip<nStrip;++istrip){
00155     
00156         if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00157           selME_.SummaryOfProfileDistr->Fill(istrip+1,pedestalHandle_->getPed(istrip,pedRange));
00158         }
00159 
00160       //fill the TkMap
00161     if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00162       fillTkMap(selDetId_, pedestalHandle_->getPed(istrip,pedRange));
00163     }
00164 
00165     }// istrip  
00166    }//if Fill ...
00167 
00168   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00169 
00170     // -->  summary  
00171   
00172     std::string hSummary_description;
00173     hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00174   
00175     std::string hSummary_name; 
00176     hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00177                                                 "layer", 
00178                                                 getLayerNameAndId(selDetId_).first, 
00179                                                 "") ;
00180     float meanPedestal=0;
00181   
00182     for( int istrip=0;istrip<nStrip;++istrip){
00183     
00184         meanPedestal = meanPedestal + pedestalHandle_->getPed(istrip,pedRange);
00185     
00186     }//istrip
00187   
00188     meanPedestal = meanPedestal/nStrip;
00189 
00190 
00191     // -----
00192     // get detIds belonging to same layer to fill X-axis with detId-number
00193   
00194     std::vector<uint32_t> sameLayerDetIds_;
00195   
00196     sameLayerDetIds_.clear();
00197 
00198     sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00199   
00200   
00201     unsigned int iBin=0;
00202     for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
00203       if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
00204     }   
00205   
00206     selME_.SummaryDistr->Fill(iBin,meanPedestal);
00207 
00208     // Fill the Histo_TkMap with the mean Pedestal:
00209     if(HistoMaps_On_ ) Tk_HM_->fill(selDetId_, meanPedestal);
00210 
00211 
00212   }//if Fill ...
00213   
00214   
00215   
00216 } 
00217 // -----
00218