CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripNoisesDQM.cc
Go to the documentation of this file.
2 
3 
5 
6 #include "TCanvas.h"
7 
8 // -----
10  edm::ParameterSet const& hPSet,
11  edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
12  gainRenormalisation_ = hPSet_.getParameter<bool>("GainRenormalisation");
14 
15 
16  // Build the Histo_TkMap:
17  if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","MeanNoise_TkMap",0.);
18 
19 }
20 // -----
21 
22 // -----
24 // -----
25 
26 
27 // -----
29 
30  getConditionObject(eSetup);
31  noiseHandle_->getDetIds(activeDetIds);
32 
33 }
34 
35 // -----
36 void SiStripNoisesDQM::fillMEsForDet(ModMEs selModME_, uint32_t selDetId_){
37 
38  std::vector<uint32_t> DetIds;
39  noiseHandle_->getDetIds(DetIds);
40 
41  SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
42 
43  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
44 
45  getModMEs(selModME_,selDetId_);
46 
47  float gainFactor;
48  float stripnoise;
49 
50  SiStripApvGain::Range gainRange;
52  gainRange = gainHandle_->getRange(selDetId_);
53  }
54 
55  for( int istrip=0;istrip<nStrip;++istrip){
57  gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
58  else
59  gainFactor=1;
60 
61  try{
62  stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
63  }catch(cms::Exception& e){
64  edm::LogError("SiStripNoisesDQM")
65  << "[SiStripNoisesDQM::fillMEsForDet] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
66  << istrip
67  << " and detid "
68  << selDetId_
69  << " : "
70  << e.what() ;
71  stripnoise=-1.;
72  }
73  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
74  selModME_.ProfileDistr->Fill(istrip+1,stripnoise);
75  }
76  if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
77  selModME_.CumulDistr->Fill(stripnoise);
78  }
79  } //istrip
80 }
81 
82 
83 // -----
84 //FIXME too long. factorize this method.
85 //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
86 //FIXME of the derived class. Moreover, several loops on the same quantities should be avoided...
87 
88 void SiStripNoisesDQM::fillMEsForLayer( std::map<uint32_t, ModMEs> selMEsMap_, uint32_t selDetId_){
89 
90  // ----
91  int subdetectorId_ = ((selDetId_>>25)&0x7);
92 
93  if( subdetectorId_<3 ||subdetectorId_>6 ){
94  edm::LogError("SiStripNoisesDQM")
95  << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
96  << subdetectorId_ << " no folder set!"
97  << std::endl;
98  return;
99  }
100  // ----
101 
102  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = selMEsMap_.find(getLayerNameAndId(selDetId_).second);
103  ModMEs selME_;
104  selME_ =selMEsMapIter_->second;
105  getSummaryMEs(selME_,selDetId_);
106 
107  SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
108  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
109  float stripnoise;
110  float meanNoise=0;
111  int Nbadstrips=0;
112 
113  SiStripApvGain::Range gainRange;
115  gainRange = gainHandle_->getRange(selDetId_);
116  }
117  float gainFactor=1;
118 
120 
121  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
122  // --> profile summary
123  std::string hSummaryOfProfile_description;
124  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
125 
126  std::string hSummaryOfProfile_name;
127  hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description,
128  "layer",
129  getLayerNameAndId(selDetId_).first,
130  "") ;
131  }
132  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
133  std::string hSummaryOfCumul_description;
134  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("Cumul_description");
135 
136  std::string hSummaryOfCumul_name;
137  hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;
138  }
139  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
140  // --> cumul summary
141  std::string hSummary_description;
142  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
143 
144  std::string hSummary_name;
145  hSummary_name = hidmanager.createHistoLayer(hSummary_description,
146  "layer",
147  getLayerNameAndId(selDetId_).first,
148  "") ;
149  }
150 
151  for( int istrip=0;istrip<nStrip;++istrip){
153  gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
154  } else{
155  gainFactor=1.;
156  }
157 
158  try{
159  stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
160  meanNoise+=stripnoise;
161  }
162  catch(cms::Exception& e){
163  edm::LogError("SiStripNoisesDQM")
164  << "[SiStripNoisesDQM::fillMEsForLayer] cms::Exception accessing noiseHandle_->getNoise(istrip,noiseRange) for strip "
165  << istrip
166  << " and detid "
167  << selDetId_
168  << " : "
169  << e.what() ;
170  stripnoise=-1;
171  Nbadstrips++;
172  }
173  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
174  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
175  selME_.SummaryOfProfileDistr->Fill(istrip+1,stripnoise);
176  }
177  }
178 
179  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
180  if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
181  selME_.SummaryOfCumulDistr->Fill(stripnoise);
182  }
183  }
184 
185  // Fill the TkMap
186  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
187  fillTkMap(selDetId_, stripnoise);
188  }
189 
190  } //istrip
191 
192  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
193 
194  meanNoise = meanNoise/(nStrip-Nbadstrips);
195  // get detIds belonging to same layer to fill X-axis with detId-number
196 
197  std::vector<uint32_t> sameLayerDetIds_;
198  sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
199 
200  std::vector<uint32_t>::const_iterator ibound=lower_bound(sameLayerDetIds_.begin(),sameLayerDetIds_.end(),selDetId_);
201  if(ibound!=sameLayerDetIds_.end() && *ibound==selDetId_)
202  selME_.SummaryDistr->Fill(ibound-sameLayerDetIds_.begin()+1,meanNoise);
203 
204 
205  // Fill the Histo_TkMap with the mean Noise:
206  if(HistoMaps_On_ ){Tk_HM_->fill(selDetId_, meanNoise); }
207 
208 
209  //Check the axis range for tkmap, and in case redefine;
210  int intNoise = int(meanNoise);
211  if(intNoise+1 > (int)tkMapScaler.size()){
212  tkMapScaler.resize(intNoise+1,0);
213  }
214  tkMapScaler[intNoise]++;
215 
216  }
217 
218 
219 }
220 
221 
222 
223 
224 
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
virtual char const * what() const
Definition: Exception.cc:97
T getParameter(std::string const &) const
void fillMEsForDet(ModMEs selModME_, uint32_t selDetId_)
ADDITON OF TK_HISTO_MAP.
void fillMEsForLayer(std::map< uint32_t, ModMEs > selModMEsMap_, uint32_t selDetId_)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::vector< uint32_t > GetSameLayerDetId(std::vector< uint32_t > activeDetIds, uint32_t selDetId)
std::vector< int > tkMapScaler
void fillTkMap(const uint32_t &detid, const float &value)
void Fill(long long x)
U second(std::pair< T, U > const &p)
virtual ~SiStripNoisesDQM()
SiStripDetInfoFileReader * reader
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:130
std::pair< ContainerIterator, ContainerIterator > Range
bool first
Definition: L1TdeRCT.cc:79
SiStripNoisesDQM(const edm::EventSetup &eSetup, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
edm::ESHandle< SiStripNoises > noiseHandle_
void getActiveDetIds(const edm::EventSetup &eSetup)
std::pair< std::string, uint32_t > getStringNameAndId(const uint32_t &detId_)
void getConditionObject(const edm::EventSetup &eSetup)
const T & get() const
Definition: EventSetup.h:55
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_)
std::vector< uint32_t > activeDetIds
edm::ESHandle< SiStripApvGain > gainHandle_
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:41
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_)