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