CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/DQM/SiStripMonitorSummary/src/SiStripThresholdDQM.cc

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