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: 2010/11/17 19:17:42 $
15  * $Revision: 1.67 $
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));
50 }
51 
53 {
54  if (debug_>2) std::cout <<"\tHcalDigiClient::analyze()"<<std::endl;
56 
57  // Get Pawel's timing plots to form averages
58  TH2F* TimingStudyTime=0;
59  TH2F* TimingStudyOcc=0;
60  std::string s=subdir_+"HFTimingStudy/sumplots/HFTiming_Total_Time";
61 
62  MonitorElement* me=dqmStore_->get(s.c_str());
63  if (me!=0)
64  TimingStudyTime=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,TimingStudyTime, debug_);
65 
66  s=subdir_+"HFTimingStudy/sumplots/HFTiming_Occupancy";
67  me=dqmStore_->get(s.c_str());
68  if (me!=0)
69  TimingStudyOcc=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,TimingStudyOcc, debug_);
70 
71  if (HFTiming_averageTime!=0)
72  {
74  if (TimingStudyTime!=0 && TimingStudyOcc!=0)
75  {
76  int etabins=(HFTiming_averageTime->getTH2F())->GetNbinsX();
77  int phibins=(HFTiming_averageTime->getTH2F())->GetNbinsY();
78  for (int x=1;x<=etabins;++x)
79  for (int y=1;y<=phibins;++y)
80  if (TimingStudyOcc->GetBinContent(x,y)!=0)
81  HFTiming_averageTime->setBinContent(x,y,TimingStudyTime->GetBinContent(x,y)*1./TimingStudyOcc->GetBinContent(x,y));
82  }
83  HFTiming_averageTime->getTH2F()->SetMinimum(0);
84  }
85 }
86 
88 {
89  if (debug_>2) std::cout <<"\t\tHcalDigiClient::calculateProblems()"<<std::endl;
90  if(!dqmStore_) return;
91  int totalevents=0;
92  int etabins=0, phibins=0, zside=0;
93  double problemvalue=0;
94 
95  // Clear away old problems
96  if (ProblemCells!=0)
97  {
99  (ProblemCells->getTH2F())->SetMaximum(1.05);
100  (ProblemCells->getTH2F())->SetMinimum(0.);
101  }
102  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
103  {
104  if (ProblemCellsByDepth->depth[d]!=0)
105  {
106  ProblemCellsByDepth->depth[d]->Reset();
107  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
108  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
109  }
110  }
111 
112  // Get histograms that are used in testing
113  TH2F* BadDigisByDepth[4];
114  TH2F* GoodDigisByDepth[4];
115 
116  std::vector<std::string> name = HcalEtaPhiHistNames();
117 
118  bool gothistos=true;
119 
120  MonitorElement* me;
121  for (int i=0;i<4;++i)
122  {
123  std::string s=subdir_+"bad_digis/bad_digi_occupancy/"+name[i]+"Bad Digi Map";
124  me=dqmStore_->get(s.c_str());
125  if (me==0)
126  {
127  gothistos=false;
128  if (debug_>0) std::cout <<"<HcalDigiClient::calculateProblems> Could not get histogram with name "<<s<<std::endl;
129  }
130  BadDigisByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadDigisByDepth[i], debug_);
131 
132  s=subdir_+"good_digis/digi_occupancy/"+name[i]+" Digi Eta-Phi Occupancy Map";
133  me=dqmStore_->get(s.c_str());
134  if (me==0)
135  {
136  gothistos=false;
137  if (debug_>0) std::cout <<"<HcalDigiClient::calculateProblems> Could not get histogram with name "<<s<<std::endl;
138  }
139  GoodDigisByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadDigisByDepth[i], debug_);
140  }
141 
142  if (gothistos==false)
143  {
144  if (debug_>0) std::cout <<"<HcalDigiClient::calculateProblems> Unable to get all necessary histograms to evaluate problem rate"<<std::endl;
145  return;
146  }
147 
148  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
149  {
150  if (ProblemCellsByDepth->depth[d]==0) continue;
151 
152  if (BadDigisByDepth[d]==0 || GoodDigisByDepth[d]==0) continue;
153  totalevents=(int)GoodDigisByDepth[d]->GetBinContent(0,0);
154  if (totalevents<minevents_ ) continue;
155  enoughevents_=true;
156  etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
157  phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
158  for (int eta=0;eta<etabins;++eta)
159  {
160  int ieta=CalcIeta(eta,d+1);
161  if (ieta==-9999) continue;
162  for (int phi=0;phi<phibins;++phi)
163  {
164  problemvalue=0; // problem fraction sums over all three tests
165  if (BadDigisByDepth[d]->GetBinContent(eta+1,phi+1) > 0) // bad cells found
166  problemvalue=(BadDigisByDepth[d]->GetBinContent(eta+1,phi+1)*1./(BadDigisByDepth[d]->GetBinContent(eta+1,phi+1)+GoodDigisByDepth[d]->GetBinContent(eta+1,phi+1)));
167 
168  zside=0;
169  if (isHF(eta,d+1)) // shift ieta by 1 for HF
170  ieta<0 ? zside = -1 : zside = 1;
171 
172  // For problem cells that exceed our allowed rate,
173  // set the values to -1 if the cells are already marked in the status database
174  if (problemvalue>minerrorrate_)
175  {
176  HcalSubdetector subdet=HcalEmpty;
177  if (isHB(eta,d+1))subdet=HcalBarrel;
178  else if (isHE(eta,d+1)) subdet=HcalEndcap;
179  else if (isHF(eta,d+1)) subdet=HcalForward;
180  else if (isHO(eta,d+1)) subdet=HcalOuter;
181  HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
182  if (badstatusmap.find(hcalid)!=badstatusmap.end())
183  problemvalue=999;
184  }
185  ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
186  if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
187  } // loop on phi
188  } // loop on eta
189  } // loop on depth
190 
191  if (ProblemCells==0)
192  {
193  if (debug_>0) std::cout <<"<HcalDigiClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
194  return;
195  }
196 
197  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
198  etabins=(ProblemCells->getTH2F())->GetNbinsX();
199  phibins=(ProblemCells->getTH2F())->GetNbinsY();
200  for (int eta=0;eta<etabins;++eta)
201  {
202  for (int phi=0;phi<phibins;++phi)
203  {
206  }
207  }
210  return;
211 }
212 
213 
215 {
217  if (debug_>0)
218  {
219  std::cout <<"<HcalDigiClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
221  }
222 }
223 
225 
227 {
228  enoughevents_=false;
229  if (!dqmStore_)
230  {
231  if (debug_>0) std::cout <<"<HcalDigiClient::beginRun> dqmStore does not exist!"<<std::endl;
232  return;
233  }
235  problemnames_.clear();
236  ProblemCells=dqmStore_->book2D(" ProblemDigis",
237  " Problem Digi Rate for all HCAL;ieta;iphi",
238  85,-42.5,42.5,
239  72,0.5,72.5);
240  problemnames_.push_back(ProblemCells->getName());
241  if (debug_>1)
242  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
243  dqmStore_->setCurrentFolder(subdir_+"problem_digis");
245  ProblemCellsByDepth->setup(dqmStore_," Problem Digi Rate");
246  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
247  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
248 
249  nevts_=0;
250 
251  dqmStore_->setCurrentFolder(subdir_+"HFTimingStudy");
252  HFTiming_averageTime=dqmStore_->book2D("HFTimingStudy_Average_Time","HFTimingStudy Average Time (time sample)",83,-41.5,41.5,72,0.5,72.5);
253 }
254 
256 
259 
261 {
262  if (!ProblemCells)
263  {
264  if (debug_>1) std::cout <<"<HcalDigiClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
265  return false;
266  }
267  int problemcount=0;
268  int ieta=-9999;
269 
270  for (int depth=0;depth<4; ++depth)
271  {
272  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
273  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
274  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
275  {
276  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
277  {
278  ieta=CalcIeta(hist_eta,depth+1);
279  if (ieta==-9999) continue;
280  if (ProblemCellsByDepth->depth[depth]==0)
281  continue;
282  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
283  ++problemcount;
284  } // for (int hist_phi=1;...)
285  } // for (int hist_eta=1;...)
286  } // for (int depth=0;...)
287 
288  if (problemcount>0) return true;
289  return false;
290 }
291 
292 bool HcalDigiClient::hasWarnings_Temp(void){return false;}
293 bool HcalDigiClient::hasOther_Temp(void){return false;}
294 bool HcalDigiClient::test_enabled(void){return true;}
295 
296 
297 void HcalDigiClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
298 {
299  // digi client does not alter channel status yet;
300  // look at dead cell or hot cell clients for example code
301 } //void HcalDigiClient::updateChannelStatus
302 
303 
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
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:1270
bool isHB(int etabin, int depth)
void setup(void)
int CalcIeta(int subdet, int eta, int depth)
void calculateProblems(void)
bool isHF(int etabin, int depth)
bool hasWarnings_Temp(void)
void endRun(void)
void FillUnphysicalHEHFBins(EtaPhiHists &hh)
std::string subdir_
std::map< HcalDetId, unsigned int > badstatusmap
void analyze(void)
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixME_
tuple cout
Definition: gather_cfg.py:41
string s
Definition: asciidump.py:422
HcalDigiClient()
Constructors.
void showDirStructure(void) const
Definition: DQMStore.cc:2539
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:647
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: DDAxes.h:10