CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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     try{      
00077       if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00078         if(WhichThreshold=="Low")
00079           selModME_.ProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getLth());
00080         if(WhichThreshold=="High")
00081           selModME_.ProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getHth());
00082       }
00083     } 
00084     catch(cms::Exception& e){
00085       edm::LogError("SiStripThresholdDQM")          
00086         << "[SiStripThresholdDQM::fillMEsForDet] cms::Exception accessing thresholdHandle_->getData(istrip,ThresholdRange) for strip "  
00087         << istrip 
00088         << " and detid " 
00089         << selDetId_  
00090         << " :  " 
00091         << e.what() ;
00092     }
00093   }// istrip
00094   
00095     
00096 } 
00097 
00098    
00099 // -----
00100 
00101 
00102 
00103 //=======================================================================================
00104 // -----
00105 void SiStripThresholdDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds){
00106    
00107    for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00108        detIter_!= selectedDetIds.end();detIter_++){
00109      fillMEsForLayer(SummaryMEsMap_, *detIter_);
00110 
00111    }
00112   
00113 }    
00114 // -----
00115 
00116 
00117 //=======================================================================================
00118 // -----
00119 void SiStripThresholdDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00120 
00121   // ----
00122   int subdetectorId_ = ((selDetId_>>25)&0x7);
00123     
00124   if( subdetectorId_<3 || subdetectorId_>6 ){ 
00125     edm::LogError("SiStripThresholdDQM")
00126       << "[SiStripThresholdDQM::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     
00139    SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
00140   
00141    int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00142   
00143      SiStripHistoId hidmanager;
00144   
00145   
00146   if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00147     // --> profile summary    
00148   
00149     std::string hSummaryOfProfile_description;
00150     hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00151   
00152     std::string hSummaryOfProfile_name; 
00153   
00154     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_).first, "") ;
00155 
00156   
00157     
00158     for( int istrip=0;istrip<nStrip;++istrip){
00159     
00160       try{ 
00161         if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00162           if(WhichThreshold=="Low"){
00163             selME_.SummaryOfProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getLth());
00164             if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) fillTkMap(selDetId_, thresholdHandle_->getData(istrip,ThresholdRange).getLth());
00165           }
00166           if(WhichThreshold=="High"){
00167             selME_.SummaryOfProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getHth());
00168             if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) fillTkMap(selDetId_, thresholdHandle_->getData(istrip,ThresholdRange).getHth());
00169           }
00170         }
00171       } 
00172       catch(cms::Exception& e){
00173         edm::LogError("SiStripThresholdDQM")          
00174           << "[SiStripThresholdDQM::fillMEsForLayer] cms::Exception accessing thresholdHandle_->getData(istrip,ThresholdRange) for strip "  
00175           << istrip 
00176           << " and detid " 
00177           << selDetId_  
00178           << " :  " 
00179           << e.what() ;
00180       }
00181     }// istrip  
00182 
00183 
00184 
00185   }//if Fill
00186 
00187  
00188 
00189   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00190     
00191     // --> summary  
00192     
00193     std::string hSummary_description;
00194     hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00195   
00196     std::string hSummary_name; 
00197     hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00198                                                 "layer", 
00199                                                 getLayerNameAndId(selDetId_).first, 
00200                                                 "") ;
00201 
00202 
00203     float meanLowThreshold=0;
00204     float meanHighThreshold=0;
00205   
00206     for( int istrip=0;istrip<nStrip;++istrip){
00207     
00208       try{
00209         meanLowThreshold = meanLowThreshold + thresholdHandle_->getData(istrip,ThresholdRange).getLth();
00210         meanHighThreshold = meanHighThreshold + thresholdHandle_->getData(istrip,ThresholdRange).getHth();
00211       }
00212       catch(cms::Exception& e){
00213         edm::LogError("SiStripNoisesDQM")          
00214           << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing thresholdHandle_->getThreshold(istrip,ThresholdRange) for strip "  
00215           << istrip 
00216           << "and detid " 
00217           << selDetId_  
00218           << " :  " 
00219           << e.what() ;      
00220       }
00221     
00222     }//istrip
00223   
00224   
00225     meanLowThreshold = meanLowThreshold/nStrip;
00226     meanHighThreshold = meanHighThreshold/nStrip;
00227   
00228   
00229     // -----
00230     // get detIds belonging to same layer to fill X-axis with detId-number
00231   
00232     std::vector<uint32_t> sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00233   
00234     unsigned int iBin=0;
00235     for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
00236       if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
00237     }   
00238   
00239     if(WhichThreshold=="Low"){
00240       selME_.SummaryDistr->Fill(iBin,meanLowThreshold);
00241       if(HistoMaps_On_ ) Tk_HM_L->fill(selDetId_, meanLowThreshold);
00242     }
00243     if(WhichThreshold=="High"){
00244       selME_.SummaryDistr->Fill(iBin,meanHighThreshold);
00245       if(HistoMaps_On_ )Tk_HM_H->fill(selDetId_, meanHighThreshold);
00246     }
00247   
00248   }//if Fill ...
00249   
00250 
00251 
00252 }  
00253 // -----
00254