CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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, const edm::EventSetup& es){
00041    
00042   //Retrieve tracker topology from geometry
00043   edm::ESHandle<TrackerTopology> tTopoHandle;
00044   es.get<IdealGeometryRecord>().get(tTopoHandle);
00045   const TrackerTopology* const tTopo = tTopoHandle.product();
00046 
00047   ModMEs CondObj_ME;
00048   
00049     
00050   for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00051       detIter_!= selectedDetIds.end();detIter_++){
00052       
00053     fillMEsForDet(CondObj_ME,*detIter_,tTopo);
00054       
00055   }
00056 }    
00057 // -----
00058 
00059 
00060 
00061 //======================================================================================
00062 // -----
00063 
00064 
00065 
00066 void SiStripThresholdDQM::fillMEsForDet(const ModMEs& _selModME_, uint32_t selDetId_, const TrackerTopology* tTopo){
00067   ModMEs selModME_ = _selModME_;
00068   std::vector<uint32_t> DetIds;
00069   thresholdHandle_->getDetIds(DetIds);
00070     
00071  
00072   SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
00073   int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00074 
00075 
00076     getModMEs(selModME_,selDetId_,tTopo);
00077 
00078 
00079     
00080   for( int istrip=0;istrip<nStrip;++istrip){
00081       if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00082         if(WhichThreshold=="Low")
00083           selModME_.ProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getLth());
00084         if(WhichThreshold=="High")
00085           selModME_.ProfileDistr->Fill(istrip+1,thresholdHandle_->getData(istrip,ThresholdRange).getHth());
00086       }
00087   }// istrip
00088   
00089     
00090 } 
00091 
00092    
00093 // -----
00094 
00095 
00096 
00097 //=======================================================================================
00098 // -----
00099 void SiStripThresholdDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds, const edm::EventSetup& es){
00100    
00101    //Retrieve tracker topology from geometry
00102    edm::ESHandle<TrackerTopology> tTopoHandle;
00103    es.get<IdealGeometryRecord>().get(tTopoHandle);
00104    const TrackerTopology* const tTopo = tTopoHandle.product();
00105 
00106    for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
00107        detIter_!= selectedDetIds.end();detIter_++){
00108      fillMEsForLayer(/*SummaryMEsMap_,*/ *detIter_,tTopo);
00109 
00110    }
00111   
00112 }    
00113 // -----
00114 
00115 
00116 //=======================================================================================
00117 // -----
00118 void SiStripThresholdDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_, const TrackerTopology* tTopo){
00119 
00120   // ----
00121   int subdetectorId_ = ((selDetId_>>25)&0x7);
00122     
00123   if( subdetectorId_<3 || subdetectorId_>6 ){ 
00124     edm::LogError("SiStripThresholdDQM")
00125       << "[SiStripThresholdDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00126       << subdetectorId_ << " no folder set!" 
00127       << std::endl;
00128     return;
00129   }
00130   // ----
00131      
00132    std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_,tTopo).second);
00133    ModMEs selME_;
00134    if ( selMEsMapIter_ != SummaryMEsMap_.end())
00135      selME_ =selMEsMapIter_->second;
00136 
00137    getSummaryMEs(selME_,selDetId_,tTopo);
00138 
00139     
00140    SiStripThreshold::Range ThresholdRange = thresholdHandle_->getRange(selDetId_);
00141   
00142    int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00143   
00144      SiStripHistoId hidmanager;
00145   
00146   
00147   if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00148     // --> profile summary    
00149   
00150     std::string hSummaryOfProfile_description;
00151     hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00152   
00153     std::string hSummaryOfProfile_name; 
00154   
00155     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, "layer", getLayerNameAndId(selDetId_,tTopo).first, "") ;
00156 
00157   
00158     
00159     for( int istrip=0;istrip<nStrip;++istrip){
00160     
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     }// istrip  
00172 
00173 
00174 
00175   }//if Fill
00176 
00177  
00178 
00179   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00180     
00181     // --> summary  
00182     
00183     std::string hSummary_description;
00184     hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00185   
00186     std::string hSummary_name; 
00187     hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00188                                                 "layer", 
00189                                                 getLayerNameAndId(selDetId_,tTopo).first, 
00190                                                 "") ;
00191 
00192 
00193     float meanLowThreshold=0;
00194     float meanHighThreshold=0;
00195   
00196     for( int istrip=0;istrip<nStrip;++istrip){
00197     
00198         meanLowThreshold = meanLowThreshold + thresholdHandle_->getData(istrip,ThresholdRange).getLth();
00199         meanHighThreshold = meanHighThreshold + thresholdHandle_->getData(istrip,ThresholdRange).getHth();
00200     }//istrip
00201   
00202   
00203     meanLowThreshold = meanLowThreshold/nStrip;
00204     meanHighThreshold = meanHighThreshold/nStrip;
00205   
00206   
00207     // -----
00208     // get detIds belonging to same layer to fill X-axis with detId-number
00209   
00210     std::vector<uint32_t> sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_,tTopo);
00211   
00212     unsigned int iBin=0;
00213     for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
00214       if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
00215     }   
00216   
00217     if(WhichThreshold=="Low"){
00218       selME_.SummaryDistr->Fill(iBin,meanLowThreshold);
00219       if(HistoMaps_On_ ) Tk_HM_L->fill(selDetId_, meanLowThreshold);
00220     }
00221     if(WhichThreshold=="High"){
00222       selME_.SummaryDistr->Fill(iBin,meanHighThreshold);
00223       if(HistoMaps_On_ )Tk_HM_H->fill(selDetId_, meanHighThreshold);
00224     }
00225   
00226   }//if Fill ...
00227   
00228 
00229 
00230 }  
00231 // -----
00232