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  stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
62  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
63  selModME_.ProfileDistr->Fill(istrip+1,stripnoise);
64  }
65  if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
66  selModME_.CumulDistr->Fill(stripnoise);
67  }
68  } //istrip
69 
70 }
71 
72 
73 // -----
74 //FIXME too long. factorize this method.
75 //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
76 //FIXME of the derived class. Moreover, several loops on the same quantities should be avoided...
77 
78 void SiStripNoisesDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_){
79 
80  // ----
81  int subdetectorId_ = ((selDetId_>>25)&0x7);
82 
83  if( subdetectorId_<3 ||subdetectorId_>6 ){
84  edm::LogError("SiStripNoisesDQM")
85  << "[SiStripNoisesDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
86  << subdetectorId_ << " no folder set!"
87  << std::endl;
88  return;
89  }
90  // ----
91 
92  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
93  ModMEs selME_;
94  if ( selMEsMapIter_ != SummaryMEsMap_.end())
95  selME_ =selMEsMapIter_->second;
96  getSummaryMEs(selME_,selDetId_);
97 
98  SiStripNoises::Range noiseRange = noiseHandle_->getRange(selDetId_);
99  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
100 
101  float stripnoise=-1.;
102  float meanNoise=0;
103  int Nbadstrips=0;
104 
105  SiStripApvGain::Range gainRange;
107  gainRange = gainHandle_->getRange(selDetId_);
108  }
109  float gainFactor=1;
110 
112 
113  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
114  // --> profile summary
115  std::string hSummaryOfProfile_description;
116  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
117 
118  std::string hSummaryOfProfile_name;
119  hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description,
120  "layer",
121  getLayerNameAndId(selDetId_).first,
122  "") ;
123  }
124  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
125  std::string hSummaryOfCumul_description;
126  hSummaryOfCumul_description = hPSet_.getParameter<std::string>("Cumul_description");
127 
128  std::string hSummaryOfCumul_name;
129  hSummaryOfCumul_name = hidmanager.createHistoLayer(hSummaryOfCumul_description, "layer", getStringNameAndId(selDetId_).first, "") ;
130  }
131  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
132  // --> cumul summary
133  std::string hSummary_description;
134  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
135 
136  std::string hSummary_name;
137  hSummary_name = hidmanager.createHistoLayer(hSummary_description,
138  "layer",
139  getLayerNameAndId(selDetId_).first,
140  "") ;
141  }
142 
143 
144  for( int istrip=0;istrip<nStrip;++istrip){
145 
147  gainFactor= gainHandle_ ->getStripGain(istrip,gainRange);
148  } else{
149  gainFactor=1.;
150  }
151 
152  stripnoise=noiseHandle_->getNoise(istrip,noiseRange)/gainFactor;
153  meanNoise+=stripnoise;
154  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
155  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
156  selME_.SummaryOfProfileDistr->Fill(istrip+1,stripnoise);
157  }
158  }
159 
160  if(hPSet_.getParameter<bool>("FillCumulativeSummaryAtLayerLevel")){
161  if( CondObj_fillId_ =="onlyCumul" || CondObj_fillId_ =="ProfileAndCumul"){
162  selME_.SummaryOfCumulDistr->Fill(stripnoise);
163  }
164  }
165 
166  // Fill the TkMap
167  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
168  fillTkMap(selDetId_, stripnoise);
169  }
170 
171  } //istrip
172 
173 
174  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
175 
176  meanNoise = meanNoise/(nStrip-Nbadstrips);
177  // get detIds belonging to same layer to fill X-axis with detId-number
178 
179  std::vector<uint32_t> sameLayerDetIds_;
180  sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_);
181 
182  std::vector<uint32_t>::const_iterator ibound=lower_bound(sameLayerDetIds_.begin(),sameLayerDetIds_.end(),selDetId_);
183  if(ibound!=sameLayerDetIds_.end() && *ibound==selDetId_)
184  selME_.SummaryDistr->Fill(ibound-sameLayerDetIds_.begin()+1,meanNoise);
185 
186 
187  // Fill the Histo_TkMap with the mean Noise:
188  if(HistoMaps_On_ ){Tk_HM_->fill(selDetId_, meanNoise); }
189 
190 
191  //Check the axis range for tkmap, and in case redefine;
192  int intNoise = int(meanNoise);
193  if(intNoise+1 > (int)tkMapScaler.size()){
194  tkMapScaler.resize(intNoise+1,0);
195  }
196  tkMapScaler[intNoise]++;
197 
198  }
199 
200 }
201 
202 
203 
204 
205 
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_)
T getParameter(std::string const &) const
void fillMEsForDet(ModMEs selModME_, uint32_t selDetId_)
ADDITON OF TK_HISTO_MAP.
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)
std::map< uint32_t, ModMEs > SummaryMEsMap_
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:94
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_)
void fillMEsForLayer(uint32_t selDetId_)
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_)