CMS 3D CMS Logo

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