CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDigiClient.cc
Go to the documentation of this file.
4 
8 
9 #include <iostream>
10 
11 /*
12  * \file HcalDigiClient.cc
13  *
14  * $Date: 2012/06/18 08:23:10 $
15  * $Revision: 1.70 $
16  * \author J. Temple
17  * \brief DigiClient class
18  */
19 
20 HcalDigiClient::HcalDigiClient(std::string myname)
21 {
22  name_=myname;
23 }
24 
25 HcalDigiClient::HcalDigiClient(std::string myname, const edm::ParameterSet& ps)
26 {
27  name_=myname;
28  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
29  debug_ = ps.getUntrackedParameter<int>("debug",0);
30  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
31  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
32  prefixME_.append("/");
33  subdir_ = ps.getUntrackedParameter<std::string>("DigiFolder","DigiMonitor_Hcal/"); // DigiMonitor_Hcal
34  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
35  subdir_.append("/");
36  subdir_=prefixME_+subdir_;
37 
38  validHtmlOutput_ = ps.getUntrackedParameter<bool>("Digi_validHtmlOutput",true);
39  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
40  badChannelStatusMask_ = ps.getUntrackedParameter<int>("Digi_BadChannelStatusMask",
41  ps.getUntrackedParameter<int>("BadChannelStatusMask",
42  (1<<HcalChannelStatus::HcalCellDead))); // identify channel status values to mask
43 
44  minerrorrate_ = ps.getUntrackedParameter<double>("Digi_minerrorrate",
45  ps.getUntrackedParameter<double>("minerrorrate",0.05));
46  minevents_ = ps.getUntrackedParameter<int>("Digi_minevents",
47  ps.getUntrackedParameter<int>("minevents",1));
48  Online_ = ps.getUntrackedParameter<bool>("online",false);
49 
51  ProblemCells=0;
52 
54 }
55 
57 {
58  if (debug_>2) std::cout <<"\tHcalDigiClient::analyze()"<<std::endl;
60 
61  // Get Pawel's timing plots to form averages
62  TH2F* TimingStudyTime=0;
63  TH2F* TimingStudyOcc=0;
64  std::string s=subdir_+"HFTimingStudy/sumplots/HFTiming_Total_Time";
65 
66  MonitorElement* me=dqmStore_->get(s.c_str());
67  if (me!=0)
68  TimingStudyTime=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,TimingStudyTime, debug_);
69 
70  s=subdir_+"HFTimingStudy/sumplots/HFTiming_Occupancy";
71  me=dqmStore_->get(s.c_str());
72  if (me!=0)
73  TimingStudyOcc=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,TimingStudyOcc, debug_);
74 
75  if (HFTiming_averageTime!=0)
76  {
78  if (TimingStudyTime!=0 && TimingStudyOcc!=0)
79  {
80  int etabins=(HFTiming_averageTime->getTH2F())->GetNbinsX();
81  int phibins=(HFTiming_averageTime->getTH2F())->GetNbinsY();
82  for (int x=1;x<=etabins;++x)
83  for (int y=1;y<=phibins;++y)
84  if (TimingStudyOcc->GetBinContent(x,y)!=0)
85  HFTiming_averageTime->setBinContent(x,y,TimingStudyTime->GetBinContent(x,y)*1./TimingStudyOcc->GetBinContent(x,y));
86  }
87  HFTiming_averageTime->getTH2F()->SetMinimum(0);
88  }
89 }
90 
92 {
93  if (debug_>2) std::cout <<"\t\tHcalDigiClient::calculateProblems()"<<std::endl;
94  if(!dqmStore_) return;
95  int totalevents=0;
96  int etabins=0, phibins=0, zside=0;
97  double problemvalue=0;
98 
99  // Clear away old problems
100  if (ProblemCells!=0)
101  {
102  ProblemCells->Reset();
103  (ProblemCells->getTH2F())->SetMaximum(1.05);
104  (ProblemCells->getTH2F())->SetMinimum(0.);
105  }
106  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
107  {
108  if (ProblemCellsByDepth->depth[d]!=0)
109  {
110  ProblemCellsByDepth->depth[d]->Reset();
111  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
112  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
113  }
114  }
115 
116  // Get histograms that are used in testing
117  TH2F* BadDigisByDepth[4];
118  TH2F* GoodDigisByDepth[4];
119 
120  std::vector<std::string> name = HcalEtaPhiHistNames();
121 
122  bool gothistos=true;
123 
124  MonitorElement* me;
125  for (int i=0;i<4;++i)
126  {
127  std::string s=subdir_+"bad_digis/bad_digi_occupancy/"+name[i]+"Bad Digi Map";
128  me=dqmStore_->get(s.c_str());
129  if (me==0)
130  {
131  gothistos=false;
132  if (debug_>0) std::cout <<"<HcalDigiClient::calculateProblems> Could not get histogram with name "<<s<<std::endl;
133  }
134  BadDigisByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadDigisByDepth[i], debug_);
135 
136  s=subdir_+"good_digis/digi_occupancy/"+name[i]+" Digi Eta-Phi Occupancy Map";
137  me=dqmStore_->get(s.c_str());
138  if (me==0)
139  {
140  gothistos=false;
141  if (debug_>0) std::cout <<"<HcalDigiClient::calculateProblems> Could not get histogram with name "<<s<<std::endl;
142  }
143  GoodDigisByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadDigisByDepth[i], debug_);
144  }
145 
146  if (gothistos==false)
147  {
148  if (debug_>0) std::cout <<"<HcalDigiClient::calculateProblems> Unable to get all necessary histograms to evaluate problem rate"<<std::endl;
149  return;
150  }
151 
152  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
153  {
154  if (ProblemCellsByDepth->depth[d]==0) continue;
155 
156  if (BadDigisByDepth[d]==0 || GoodDigisByDepth[d]==0) continue;
157  totalevents=(int)GoodDigisByDepth[d]->GetBinContent(0,0);
158  if (totalevents<minevents_ ) continue;
159  enoughevents_=true;
160  etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
161  phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
162  for (int eta=0;eta<etabins;++eta)
163  {
164  int ieta=CalcIeta(eta,d+1);
165  if (ieta==-9999) continue;
166  for (int phi=0;phi<phibins;++phi)
167  {
168  problemvalue=0; // problem fraction sums over all three tests
169  if (BadDigisByDepth[d]->GetBinContent(eta+1,phi+1) > 0) // bad cells found
170  problemvalue=(BadDigisByDepth[d]->GetBinContent(eta+1,phi+1)*1./(BadDigisByDepth[d]->GetBinContent(eta+1,phi+1)+GoodDigisByDepth[d]->GetBinContent(eta+1,phi+1)));
171 
172  zside=0;
173  if (isHF(eta,d+1)) // shift ieta by 1 for HF
174  ieta<0 ? zside = -1 : zside = 1;
175 
176  // For problem cells that exceed our allowed rate,
177  // set the values to -1 if the cells are already marked in the status database
178  if (problemvalue>minerrorrate_)
179  {
180  HcalSubdetector subdet=HcalEmpty;
181  if (isHB(eta,d+1))subdet=HcalBarrel;
182  else if (isHE(eta,d+1)) subdet=HcalEndcap;
183  else if (isHF(eta,d+1)) subdet=HcalForward;
184  else if (isHO(eta,d+1)) subdet=HcalOuter;
185  HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
186  if (badstatusmap.find(hcalid)!=badstatusmap.end())
187  problemvalue=999;
188  }
189  ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
190  if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
191  } // loop on phi
192  } // loop on eta
193  } // loop on depth
194 
195  if (ProblemCells==0)
196  {
197  if (debug_>0) std::cout <<"<HcalDigiClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
198  return;
199  }
200 
201  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
202  etabins=(ProblemCells->getTH2F())->GetNbinsX();
203  phibins=(ProblemCells->getTH2F())->GetNbinsY();
204  for (int eta=0;eta<etabins;++eta)
205  {
206  for (int phi=0;phi<phibins;++phi)
207  {
210  }
211  }
214  return;
215 }
216 
217 
219 {
221  if (debug_>0)
222  {
223  std::cout <<"<HcalDigiClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
225  }
226 }
227 
229 
231 {
232  enoughevents_=false;
233  if (!dqmStore_)
234  {
235  if (debug_>0) std::cout <<"<HcalDigiClient::beginRun> dqmStore does not exist!"<<std::endl;
236  return;
237  }
239  problemnames_.clear();
240  ProblemCells=dqmStore_->book2D(" ProblemDigis",
241  " Problem Digi Rate for all HCAL;ieta;iphi",
242  85,-42.5,42.5,
243  72,0.5,72.5);
244  problemnames_.push_back(ProblemCells->getName());
245  if (debug_>1)
246  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
247  dqmStore_->setCurrentFolder(subdir_+"problem_digis");
249  ProblemCellsByDepth->setup(dqmStore_," Problem Digi Rate");
250  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
251  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
252 
253  nevts_=0;
254 
255  dqmStore_->setCurrentFolder(subdir_+"HFTimingStudy");
256  HFTiming_averageTime=dqmStore_->book2D("HFTimingStudy_Average_Time","HFTimingStudy Average Time (time sample)",83,-41.5,41.5,72,0.5,72.5);
257 }
258 
260 
263 
265 {
266  if (!ProblemCells)
267  {
268  if (debug_>1) std::cout <<"<HcalDigiClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
269  return false;
270  }
271  int problemcount=0;
272  int ieta=-9999;
273 
274  for (int depth=0;depth<4; ++depth)
275  {
276  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
277  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
278  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
279  {
280  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
281  {
282  ieta=CalcIeta(hist_eta,depth+1);
283  if (ieta==-9999) continue;
284  if (ProblemCellsByDepth->depth[depth]==0)
285  continue;
286  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
287  ++problemcount;
288  } // for (int hist_phi=1;...)
289  } // for (int hist_eta=1;...)
290  } // for (int depth=0;...)
291 
292  if (problemcount>0) return true;
293  return false;
294 }
295 
296 bool HcalDigiClient::hasWarnings_Temp(void){return false;}
297 bool HcalDigiClient::hasOther_Temp(void){return false;}
298 bool HcalDigiClient::test_enabled(void){return true;}
299 
300 
301 void HcalDigiClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
302 {
303  // digi client does not alter channel status yet;
304  // look at dead cell or hot cell clients for example code
305 } //void HcalDigiClient::updateChannelStatus
306 
308 {}
bool isHO(int etabin, int depth)
void endJob(void)
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
MonitorElement * ProblemCells
std::string name()
void setBinContent(int binx, double content)
set content of bin (1-D)
bool hasErrors_Temp(void)
std::vector< std::string > HcalEtaPhiHistNames()
bool hasOther_Temp(void)
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
MonitorElement * HFTiming_averageTime
bool isHE(int etabin, int depth)
T eta() const
void Fill(long long x)
void beginJob(void)
void cleanup(void)
void beginRun(void)
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
std::vector< std::string > problemnames_
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
EtaPhiHists * ProblemCellsByDepth
HcalSubdetector
Definition: HcalAssistant.h:32
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
bool isHB(int etabin, int depth)
void setup(void)
~HcalDigiClient()
Destructor.
void calculateProblems(void)
bool isHF(int etabin, int depth)
bool hasWarnings_Temp(void)
void endRun(void)
std::string subdir_
std::map< HcalDetId, unsigned int > badstatusmap
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
void analyze(void)
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixME_
tuple cout
Definition: gather_cfg.py:121
HcalDigiClient()
Constructors.
void showDirStructure(void) const
Definition: DQMStore.cc:2761
Definition: DDAxes.h:10
TH2F * getTH2F(void) const
bool test_enabled(void)
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: DDAxes.h:10