CMS 3D CMS Logo

SiStripPedestalsDQM.cc
Go to the documentation of this file.
4 #include "TCanvas.h"
5 
6 // -----
8  edm::ParameterSet const& hPSet,
9  edm::ParameterSet const& fPSet):SiStripBaseCondObjDQM(eSetup, hPSet, fPSet){
10 
11  // Build the Histo_TkMap:
12  if(HistoMaps_On_ ) Tk_HM_ = new TkHistoMap("SiStrip/Histo_Map","MeanPed_TkMap",0.);
13 }
14 // -----
15 
16 
17 
18 // -----
20 // -----
21 
22 
23 // -----
25 
26  getConditionObject(eSetup);
28 
29 }
30 // -----
31 
32 
33 // -----
34 void SiStripPedestalsDQM::fillModMEs(const std::vector<uint32_t> & selectedDetIds, const edm::EventSetup& es){
35 
36  //Retrieve tracker topology from geometry
38  es.get<TrackerTopologyRcd>().get(tTopoHandle);
39  const TrackerTopology* const tTopo = tTopoHandle.product();
40 
41  ModMEs CondObj_ME;
42 
43  for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
44  detIter_!= selectedDetIds.end();detIter_++){
45 
46  fillMEsForDet(CondObj_ME,*detIter_,tTopo);
47 
48  }
49 }
50 // -----
51 
52 
53 
54 
55 // -----
56 void SiStripPedestalsDQM::fillMEsForDet(const ModMEs& _selModME_, uint32_t selDetId_, const TrackerTopology* tTopo){
57  ModMEs selModME_ = _selModME_;
58  getModMEs(selModME_,selDetId_,tTopo);
59 
60  SiStripPedestals::Range pedRange = pedestalHandle_->getRange(selDetId_);
61  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
62 
63  for( int istrip=0;istrip<nStrip;++istrip){
64  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
65  selModME_.ProfileDistr->Fill(istrip+1,pedestalHandle_->getPed(istrip,pedRange));
66  }
67  }// istrip
68 
69 }
70 // -----
71 
72 
73 
74 // -----
75 void SiStripPedestalsDQM::fillSummaryMEs(const std::vector<uint32_t> & selectedDetIds, const edm::EventSetup& es){
76 
77  //Retrieve tracker topology from geometry
79  es.get<TrackerTopologyRcd>().get(tTopoHandle);
80  const TrackerTopology* const tTopo = tTopoHandle.product();
81 
82  for(std::vector<uint32_t>::const_iterator detIter_ = selectedDetIds.begin();
83  detIter_!= selectedDetIds.end();detIter_++){
84  fillMEsForLayer(/*SummaryMEsMap_,*/ *detIter_,tTopo);
85  }
86 
87  for (std::map<uint32_t, ModMEs>::iterator iter=SummaryMEsMap_.begin(); iter!=SummaryMEsMap_.end(); iter++){
88 
89  ModMEs selME;
90  selME = iter->second;
91 
92  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryProfileAtLayerLevelAsImage")){
93 
94  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
95 
96  TCanvas c1("c1");
97  selME.SummaryOfProfileDistr->getTProfile()->Draw();
98  std::string name (selME.SummaryOfProfileDistr->getTProfile()->GetTitle());
99  name+=".png";
100  c1.Print(name.c_str());
101  }
102  }
103  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") && fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")){
104 
105  TCanvas c1("c1");
106  selME.SummaryDistr->getTH1()->Draw();
107  std::string name (selME.SummaryDistr->getTH1()->GetTitle());
108  name+=".png";
109  c1.Print(name.c_str());
110  }
111 
112  }
113 
114 }
115 
116 // -----
117 
118 
119 
120 // -----
121 void SiStripPedestalsDQM::fillMEsForLayer( /*std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_, const TrackerTopology* tTopo){
122 
123  // ----
124  int subdetectorId_ = ((selDetId_>>25)&0x7);
125 
126  if( subdetectorId_<3 || subdetectorId_>6 ){
127  edm::LogError("SiStripPedestalsDQM")
128  << "[SiStripPedestalsDQM::fillMEsForLayer] WRONG INPUT : no such subdetector type : "
129  << subdetectorId_ << " no folder set!"
130  << std::endl;
131  return;
132  }
133  // ----
134 
135 // // Cumulative distribution with average Ped value on a layer (not needed):
136 
137  std::map<uint32_t, ModMEs>::iterator selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_,tTopo).second);
138  ModMEs selME_;
139  if ( selMEsMapIter_ != SummaryMEsMap_.end())
140  selME_ =selMEsMapIter_->second;
141  getSummaryMEs(selME_,selDetId_,tTopo);
142 
143  SiStripPedestals::Range pedRange = pedestalHandle_->getRange(selDetId_);
144 
145  int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first*128;
146 
148 
149  if(hPSet_.getParameter<bool>("FillSummaryProfileAtLayerLevel")){
150 
151  // --> profile summary
152 
153  std::string hSummaryOfProfile_description;
154  hSummaryOfProfile_description = hPSet_.getParameter<std::string>("SummaryOfProfile_description");
155 
156  std::string hSummaryOfProfile_name;
157 
158 
159  hSummaryOfProfile_name = hidmanager.createHistoLayer(hSummaryOfProfile_description,
160  "layer",
161  getLayerNameAndId(selDetId_,tTopo).first,
162  "") ;
163 
164  for( int istrip=0;istrip<nStrip;++istrip){
165 
166  if( CondObj_fillId_ =="onlyProfile" || CondObj_fillId_ =="ProfileAndCumul"){
167  selME_.SummaryOfProfileDistr->Fill(istrip+1,pedestalHandle_->getPed(istrip,pedRange));
168  }
169 
170  //fill the TkMap
171  if(fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")){
172  fillTkMap(selDetId_, pedestalHandle_->getPed(istrip,pedRange));
173  }
174 
175  }// istrip
176  }//if Fill ...
177 
178  if(hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")){
179 
180  // --> summary
181 
182  std::string hSummary_description;
183  hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
184 
185  std::string hSummary_name;
186  hSummary_name = hidmanager.createHistoLayer(hSummary_description,
187  "layer",
188  getLayerNameAndId(selDetId_,tTopo).first,
189  "") ;
190  float meanPedestal=0;
191 
192  for( int istrip=0;istrip<nStrip;++istrip){
193 
194  meanPedestal = meanPedestal + pedestalHandle_->getPed(istrip,pedRange);
195 
196  }//istrip
197 
198  meanPedestal = meanPedestal/nStrip;
199 
200 
201  // -----
202  // get detIds belonging to same layer to fill X-axis with detId-number
203 
204  std::vector<uint32_t> sameLayerDetIds_;
205 
206  sameLayerDetIds_.clear();
207 
208  sameLayerDetIds_=GetSameLayerDetId(activeDetIds,selDetId_,tTopo);
209 
210 
211  unsigned int iBin=0;
212  for(unsigned int i=0;i<sameLayerDetIds_.size();i++){
213  if(sameLayerDetIds_[i]==selDetId_){iBin=i+1;}
214  }
215 
216  selME_.SummaryDistr->Fill(iBin,meanPedestal);
217 
218  // Fill the Histo_TkMap with the mean Pedestal:
219  if(HistoMaps_On_ ) Tk_HM_->fill(selDetId_, meanPedestal);
220 
221 
222  }//if Fill ...
223 
224 
225 
226 }
227 // -----
228 
T getParameter(std::string const &) const
edm::ESHandle< SiStripPedestals > pedestalHandle_
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::pair< ContainerIterator, ContainerIterator > Range
void getSummaryMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
void fillModMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es)
void fillTkMap(const uint32_t &detid, const float &value)
SiStripPedestalsDQM(const edm::EventSetup &eSetup, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
void Fill(long long x)
float getPed(const uint16_t &strip, const Range &range) const
U second(std::pair< T, U > const &p)
std::map< uint32_t, ModMEs > SummaryMEsMap_
void fillSummaryMEs(const std::vector< uint32_t > &selectedDetIds, const edm::EventSetup &es)
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)
TH1 * getTH1(void) const
void fillMEsForDet(const ModMEs &selModME_, uint32_t selDetId_, const TrackerTopology *tTopo)
void getConditionObject(const edm::EventSetup &eSetup)
void getDetIds(std::vector< uint32_t > &DetIds_) const
void getModMEs(ModMEs &CondObj_ME, const uint32_t &detId_, const TrackerTopology *tTopo)
const T & get() const
Definition: EventSetup.h:56
void getActiveDetIds(const edm::EventSetup &eSetup)
std::pair< std::string, uint32_t > getLayerNameAndId(const uint32_t &detId_, const TrackerTopology *tTopo)
TProfile * getTProfile(void) const
std::vector< uint32_t > activeDetIds
void fillMEsForLayer(uint32_t selDetId_, const TrackerTopology *tTopo)
const Range getRange(const uint32_t &detID) const
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
T const * product() const
Definition: ESHandle.h:86