CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DQM/SiStripMonitorSummary/src/SiStripNoisesDQM.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripMonitorSummary/interface/SiStripNoisesDQM.h"
00002 
00003 
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 
00006 #include "TCanvas.h"
00007 
00008 // -----
00009 SiStripNoisesDQM::SiStripNoisesDQM(const edm::EventSetup & eSetup,
00010                                    edm::ParameterSet const& hPSet,
00011                                    edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){  
00012   gainRenormalisation_ = hPSet_.getParameter<bool>("GainRenormalisation");
00013   if( gainRenormalisation_){ eSetup.get<SiStripApvGainRcd>().get(gainHandle_);}
00014 
00015 
00016   // Build the Histo_TkMap:
00017   if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","MeanNoise_TkMap",0.);
00018 
00019 }
00020 // -----
00021 
00022 // -----
00023 SiStripNoisesDQM::~SiStripNoisesDQM(){}
00024 // -----
00025 
00026 
00027 // -----
00028 void SiStripNoisesDQM::getActiveDetIds(const edm::EventSetup & eSetup){
00029   
00030   getConditionObject(eSetup);
00031   noiseHandle_->getDetIds(activeDetIds);
00032 
00033 }
00034 
00035 // -----
00036 void SiStripNoisesDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
00037   
00038   std::vector<uint32_t> DetIds;
00039   noiseHandle_->getDetIds(DetIds);
00040 
00041   SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
00042   
00043   int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00044     
00045   getModMEs(selModME_,selDetId_);
00046   
00047   float gainFactor;
00048   float stripnoise;
00049 
00050   SiStripApvGain::Range gainRange;
00051   if( gainRenormalisation_ ){
00052     gainRange = gainHandle_->getRange(selDetId_);
00053   }
00054 
00055   for( int istrip=0;istrip<nStrip;++istrip){
00056     if( gainRenormalisation_ )
00057       gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00058     else
00059       gainFactor=1;
00060 
00061       stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
00062     if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00063       selModME_.ProfileDistr->Fill(istrip+1,stripnoise);
00064     }
00065     if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00066       selModME_.CumulDistr->Fill(stripnoise);
00067     } 
00068   } //istrip
00069 }
00070   
00071 
00072 // -----
00073 //FIXME too long. factorize this method. 
00074 //FIXME the number of lines of code in the derived classes should be reduced ONLY at what cannot be done in the base class because of the specific implementation
00075 //FIXME of the derived class. Moreover, several loops on the same quantities should be avoided...
00076 
00077 void SiStripNoisesDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00078 
00079   // ----
00080   int subdetectorId_ = ((selDetId_>>25)&0x7);
00081   
00082   if( subdetectorId_<3 ||subdetectorId_>6 ){ 
00083     edm::LogError("SiStripNoisesDQM")
00084       << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00085       << subdetectorId_ << " no folder set!" 
00086       << std::endl;
00087     return;
00088   }
00089   // ----
00090   
00091   std::map<uint32_t, ModMEs>::iterator selMEsMapIter_  = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00092   ModMEs selME_;
00093   selME_ =selMEsMapIter_->second;
00094   getSummaryMEs(selME_,selDetId_);
00095   
00096   SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
00097   int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00098   float stripnoise;
00099   float meanNoise=0;
00100   int Nbadstrips=0;
00101 
00102   SiStripApvGain::Range gainRange;
00103   if(gainRenormalisation_ ){
00104     gainRange = gainHandle_->getRange(selDetId_);
00105   }
00106   float gainFactor=1;
00107   
00108   SiStripHistoId hidmanager;
00109 
00110   if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00111     // --> profile summary    
00112     std::string hSummaryOfProfile_description;
00113     hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00114     
00115     std::string hSummaryOfProfile_name; 
00116     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, 
00117                                                          "layer", 
00118                                                          getLayerNameAndId(selDetId_).first, 
00119                                                          "") ;
00120   }
00121   if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00122     std::string hSummaryOfCumul_description;
00123     hSummaryOfCumul_description  = hPSet_.getParameter<std::string>("Cumul_description");
00124     
00125     std::string hSummaryOfCumul_name; 
00126     hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;    
00127   }   
00128   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00129     // --> cumul summary    
00130     std::string hSummary_description;
00131     hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00132     
00133     std::string hSummary_name; 
00134     hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00135                                                 "layer", 
00136                                                 getLayerNameAndId(selDetId_).first, 
00137                                                 "") ;
00138   }
00139   
00140   for( int istrip=0;istrip<nStrip;++istrip){
00141     if(gainRenormalisation_ ){
00142       gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00143     } else{
00144       gainFactor=1.;
00145     }
00146     
00147       stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
00148       meanNoise+=stripnoise;
00149     if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00150       if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){      
00151         selME_.SummaryOfProfileDistr->Fill(istrip+1,stripnoise);
00152       }
00153     }
00154 
00155     if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00156       if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00157         selME_.SummaryOfCumulDistr->Fill(stripnoise);
00158       }
00159     }
00160 
00161     // Fill the TkMap
00162     if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00163       fillTkMap(selDetId_, stripnoise);   
00164     }
00165   
00166   } //istrip
00167 
00168   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00169     
00170     meanNoise = meanNoise/(nStrip-Nbadstrips);
00171     // get detIds belonging to same layer to fill X-axis with detId-number
00172     
00173     std::vector<uint32_t> sameLayerDetIds_;
00174     sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00175     
00176     std::vector<uint32_t>::const_iterator ibound=lower_bound(sameLayerDetIds_.begin(),sameLayerDetIds_.end(),selDetId_);
00177     if(ibound!=sameLayerDetIds_.end() && *ibound==selDetId_)
00178       selME_.SummaryDistr->Fill(ibound-sameLayerDetIds_.begin()+1,meanNoise);
00179     
00180 
00181     // Fill the Histo_TkMap with the mean Noise:
00182     if(HistoMaps_On_ ){Tk_HM_->fill(selDetId_, meanNoise); }
00183 
00184 
00185     //Check the axis range for tkmap, and in case redefine;
00186     int intNoise = int(meanNoise);
00187     if(intNoise+1 > (int)tkMapScaler.size()){
00188       tkMapScaler.resize(intNoise+1,0);
00189     }
00190     tkMapScaler[intNoise]++;
00191       
00192   } 
00193 
00194 
00195 }
00196   
00197 
00198 
00199 
00200