CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/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     try{
00062       stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
00063     }catch(cms::Exception& e){
00064       edm::LogError("SiStripNoisesDQM")          
00065          << "[SiStripNoisesDQM::fillMEsForDet] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "  
00066          << istrip 
00067          << " and detid " 
00068          << selDetId_  
00069          << " :  " 
00070          << e.what() ;
00071       stripnoise=-1.;
00072     }
00073     if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
00074       selModME_.ProfileDistr->Fill(istrip+1,stripnoise);
00075     }
00076     if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00077       selModME_.CumulDistr->Fill(stripnoise);
00078     } 
00079   } //istrip
00080 }
00081   
00082 
00083 // -----
00084 //FIXME too long. factorize this method. 
00085 //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
00086 //FIXME of the derived class. Moreover, several loops on the same quantities should be avoided...
00087 
00088 void SiStripNoisesDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
00089 
00090   // ----
00091   int subdetectorId_ = ((selDetId_>>25)&0x7);
00092   
00093   if( subdetectorId_<3 ||subdetectorId_>6 ){ 
00094     edm::LogError("SiStripNoisesDQM")
00095       << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
00096       << subdetectorId_ << " no folder set!" 
00097       << std::endl;
00098     return;
00099   }
00100   // ----
00101   
00102   std::map<uint32_t, ModMEs>::iterator selMEsMapIter_  = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
00103   ModMEs selME_;
00104   selME_ =selMEsMapIter_->second;
00105   getSummaryMEs(selME_,selDetId_);
00106   
00107   SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
00108   int nStrip =  reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
00109   float stripnoise;
00110   float meanNoise=0;
00111   int Nbadstrips=0;
00112 
00113   SiStripApvGain::Range gainRange;
00114   if(gainRenormalisation_ ){
00115     gainRange = gainHandle_->getRange(selDetId_);
00116   }
00117   float gainFactor=1;
00118   
00119   SiStripHistoId hidmanager;
00120 
00121   if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00122     // --> profile summary    
00123     std::string hSummaryOfProfile_description;
00124     hSummaryOfProfile_description  = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
00125     
00126     std::string hSummaryOfProfile_name; 
00127     hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description, 
00128                                                          "layer", 
00129                                                          getLayerNameAndId(selDetId_).first, 
00130                                                          "") ;
00131   }
00132   if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00133     std::string hSummaryOfCumul_description;
00134     hSummaryOfCumul_description  = hPSet_.getParameter<std::string>("Cumul_description");
00135     
00136     std::string hSummaryOfCumul_name; 
00137     hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;    
00138   }   
00139   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00140     // --> cumul summary    
00141     std::string hSummary_description;
00142     hSummary_description  = hPSet_.getParameter<std::string>("Summary_description");
00143     
00144     std::string hSummary_name; 
00145     hSummary_name = hidmanager.createHistoLayer(hSummary_description, 
00146                                                 "layer", 
00147                                                 getLayerNameAndId(selDetId_).first, 
00148                                                 "") ;
00149   }
00150   
00151   for( int istrip=0;istrip<nStrip;++istrip){
00152     if(gainRenormalisation_ ){
00153       gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
00154     } else{
00155       gainFactor=1.;
00156     }
00157     
00158     try{ 
00159       stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
00160       meanNoise+=stripnoise;
00161     } 
00162     catch(cms::Exception& e){
00163       edm::LogError("SiStripNoisesDQM")          
00164         << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "  
00165         << istrip 
00166         << " and detid " 
00167         << selDetId_  
00168         << " :  " 
00169         << e.what() ;
00170       stripnoise=-1;
00171       Nbadstrips++;
00172     }      
00173     if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
00174       if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){      
00175         selME_.SummaryOfProfileDistr->Fill(istrip+1,stripnoise);
00176       }
00177     }
00178 
00179     if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
00180       if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
00181         selME_.SummaryOfCumulDistr->Fill(stripnoise);
00182       }
00183     }
00184 
00185     // Fill the TkMap
00186     if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
00187       fillTkMap(selDetId_, stripnoise);   
00188     }
00189   
00190   } //istrip
00191 
00192   if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
00193     
00194     meanNoise = meanNoise/(nStrip-Nbadstrips);
00195     // get detIds belonging to same layer to fill X-axis with detId-number
00196     
00197     std::vector<uint32_t> sameLayerDetIds_;
00198     sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
00199     
00200     std::vector<uint32_t>::const_iterator ibound=lower_bound(sameLayerDetIds_.begin(),sameLayerDetIds_.end(),selDetId_);
00201     if(ibound!=sameLayerDetIds_.end() && *ibound==selDetId_)
00202       selME_.SummaryDistr->Fill(ibound-sameLayerDetIds_.begin()+1,meanNoise);
00203     
00204 
00205     // Fill the Histo_TkMap with the mean Noise:
00206     if(HistoMaps_On_ ){Tk_HM_->fill(selDetId_, meanNoise); }
00207 
00208 
00209     //Check the axis range for tkmap, and in case redefine;
00210     int intNoise = int(meanNoise);
00211     if(intNoise+1 > (int)tkMapScaler.size()){
00212       tkMapScaler.resize(intNoise+1,0);
00213     }
00214     tkMapScaler[intNoise]++;
00215       
00216   } 
00217 
00218 
00219 }
00220   
00221 
00222 
00223 
00224