CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTrigPrimClient.cc
Go to the documentation of this file.
4 
8 
9 #include <iostream>
10 
11 /*
12  * \file HcalTrigPrimClient.cc
13  *
14  * \author J. Temple
15  * \brief Hcal Trigger Primitive Client class
16  */
17 
19 {
20  name_=myname;
21 }
22 
24 {
25  name_=myname;
26  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
27  debug_ = ps.getUntrackedParameter<int>("debug",0);
28  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
29  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
30  prefixME_.append("/");
31  subdir_ = ps.getUntrackedParameter<std::string>("TrigPrimFolder","TrigPrimMonitor_Hcal/"); // TrigPrimMonitor
32  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
33  subdir_.append("/");
34  subdir_=prefixME_+subdir_;
35 
36  validHtmlOutput_ = ps.getUntrackedParameter<bool>("TrigPrim_validHtmlOutput",true);
37  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
38  badChannelStatusMask_ = ps.getUntrackedParameter<int>("TrigPrim_BadChannelStatusMask",
39  ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
40  // Set error rate to 1%, not (earlier) value of 0.1% -- Jeff, 11 May 2010
41  minerrorrate_ = ps.getUntrackedParameter<double>("TrigPrim_minerrorrate",
42  ps.getUntrackedParameter<double>("minerrorrate",0.01));
43  minevents_ = ps.getUntrackedParameter<int>("TrigPrim_minevents",
44  ps.getUntrackedParameter<int>("minevents",1));
45  Online_ = ps.getUntrackedParameter<bool>("online",false);
46 
47  ProblemCells=0;
51 
52  doProblemCellSetup_ = true;
53 }
54 
56 {
57  if (debug_>2) std::cout <<"\tHcalTrigPrimClient::analyze()"<<std::endl;
59  calculateProblems(ib,ig);
60 }
61 
63 {
64  if (debug_>2) std::cout <<"\t\tHcalTrigPrimClient::calculateProblems()"<<std::endl;
65  double totalevents=0;
66  int etabins=0, phibins=0;
67  double problemvalue=0;
68  enoughevents_=false; // assume we lack sufficient events until proven otherwise
69 
70  // Clear away old problems
71  if (ProblemCells!=0)
72  {
74  (ProblemCells->getTH2F())->SetMaximum(1.05);
75  (ProblemCells->getTH2F())->SetMinimum(0.);
76  }
77  for (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
78  {
79  if (ProblemCellsByDepth->depth[d]!=0)
80  {
81  ProblemCellsByDepth->depth[d]->Reset();
82  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
83  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
84  }
85  }
86 
87  for (unsigned int d=0;d<ProblemsByDepthZS_->depth.size();++d)
88  {
89  if (ProblemsByDepthZS_->depth[d]!=0)
90  {
91  ProblemsByDepthZS_->depth[d]->Reset();
92  (ProblemsByDepthZS_->depth[d]->getTH2F())->SetMaximum(1.05);
93  (ProblemsByDepthZS_->depth[d]->getTH2F())->SetMinimum(0.);
94  }
95  }
96 
97  for (unsigned int d=0;d<ProblemsByDepthNZS_->depth.size();++d)
98  {
99  if (ProblemsByDepthNZS_->depth[d]!=0)
100  {
101  ProblemsByDepthNZS_->depth[d]->Reset();
102  (ProblemsByDepthNZS_->depth[d]->getTH2F())->SetMaximum(1.05);
103  (ProblemsByDepthNZS_->depth[d]->getTH2F())->SetMinimum(0.);
104  }
105  }
106 
107  // Get histograms that are used in testing
108  // currently none used,
109 
110  std::vector<std::string> name = HcalEtaPhiHistNames();
111 
112  /*
113  // This is a sample of how to get a histogram from the task that can then be used for evaluation purposes
114  */
115  MonitorElement* me;
116  TH2F *goodZS=0;
117  TH2F *badZS=0;
118  TH2F* goodNZS=0;
119  TH2F* badNZS=0;
120 
121  me=ig.get(subdir_+"Good TPs_ZS");
122  if (!me && debug_>0)
123  std::cout <<"<HcalTrigPrimClient::calculateProblems> Could not get histogram named '"<<subdir_<<"Good TPs_ZS'"<<std::endl;
124  else goodZS = HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, goodZS, debug_);
125 
126  me=ig.get(subdir_+"Bad TPs_ZS");
127  if (!me && debug_>0)
128  std::cout <<"<HcalTrigPrimClient::calculateProblems> Could not get histogram named '"<<subdir_<<"Bad TPs_ZS'"<<std::endl;
129  else badZS = HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, badZS, debug_);
130 
131  me=ig.get(subdir_+"noZS/Good TPs_noZS");
132  if (!me && debug_>0)
133  std::cout <<"<HcalTrigPrimClient::calculateProblems> Could not get histogram named '"<<subdir_<<"noZS/Good TPs_noZS'"<<std::endl;
134  else goodNZS = HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, goodNZS, debug_);
135 
136  me=ig.get(subdir_+"noZS/Bad TPs_noZS");
137  if (!me && debug_>0)
138  std::cout <<"<HcalTrigPrimClient::calculateProblems> Could not get histogram named '"<<subdir_<<"noZS/Bad TPs_noZS'"<<std::endl;
139  else badNZS = HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, badNZS, debug_);
140 
141  // get bin info from good histograms
142  if (goodZS!=0)
143  {
144  etabins=goodZS->GetNbinsX();
145  phibins=goodZS->GetNbinsY();
146  totalevents=goodNZS->GetBinContent(0);
147  }
148  else if (goodNZS!=0)
149  {
150  etabins=goodNZS->GetNbinsX();
151  phibins=goodNZS->GetNbinsY();
152  totalevents=goodNZS->GetBinContent(0);
153  }
154 
155  if (totalevents<minevents_)
156  {
157  enoughevents_=false;
158  if (debug_>2) std::cout <<"<HcalTrigPrimClient::calculateProblems()> Not enough events! events = "<<totalevents<<" minimum required = "<<minevents_<<std::endl;
159  return;
160  }
161  enoughevents_=true;
162 
163  // got good and bad histograms; now let's loop over them
164 
165  int ieta=-99, iphi=-99;
166  int badvalZS=0, goodvalZS=0;
167  int badvalNZS=0, goodvalNZS=0;
168  for (int eta=1;eta<=etabins;++eta)
169  {
170  ieta=eta-33; // Patrick's eta-phi maps starts at ieta=-32
171  for (int phi=1;phi<=phibins;++phi)
172  {
173  badvalZS=0, goodvalZS=0;
174  badvalNZS=0, goodvalNZS=0;
175  iphi=phi;
176  if (badZS!=0) badvalZS=(int)badZS->GetBinContent(eta,phi);
177  if (badNZS!=0) badvalNZS=(int)badNZS->GetBinContent(eta,phi);
178  if (badvalZS+badvalNZS==0) continue;
179  if (goodZS!=0) goodvalZS=(int)goodZS->GetBinContent(eta,phi);
180  if (goodNZS!=0) goodvalNZS=(int)goodNZS->GetBinContent(eta,phi);
181 
182  if (badvalNZS>0)
183  {
184  problemvalue=badvalNZS*1./(badvalNZS+goodvalNZS);
185  if (abs(ieta)<29)
186  {
187  ProblemsByDepthNZS_->depth[0]->Fill(ieta,iphi,problemvalue);
188  if (abs(ieta)==28) // TP 28 spans towers 28 and 29
189  ProblemsByDepthNZS_->depth[0]->Fill(ieta+abs(ieta)/ieta,iphi,problemvalue);
190  }
191  else // HF
192  {
193  /* HF TPs:
194  TP29 = ieta 29-31
195  TP30 = ieta 32-34
196  TP31 = ieta 35-37
197  TP38 = ieta 38-41
198  iphi = 1, 5, ..., with 1 covering iphi=1 and iphi=71, etc.
199  */
200  int newieta=-99;
201  for (int i=0;i<3;++i)
202  {
203  newieta=i+29+3*(abs(ieta)-29)+1; // shift values by 1 for HF in EtaPhiHistsplot
204  if (ieta<0) newieta*=-1;
205  ProblemsByDepthNZS_->depth[0]->Fill(newieta,iphi,problemvalue);
206  ProblemsByDepthNZS_->depth[0]->Fill(newieta,(iphi-2+72)%72,problemvalue);
207  }
208  if (abs(ieta)==32)
209  {
210  ProblemsByDepthNZS_->depth[0]->Fill(42*abs(ieta)/ieta,iphi,problemvalue);
211  ProblemsByDepthNZS_->depth[0]->Fill(newieta,(iphi-2+72)%72,problemvalue);
212  }
213  }
214  } // errors found in NZS;
215  if (badvalZS>0)
216  {
217  problemvalue=badvalZS*1./(badvalZS+goodvalZS);
218  if (abs(ieta)<29) // Make special case for ieta=16 (HB/HE overlap?)
219  {
220  ProblemsByDepthZS_->depth[0]->Fill(ieta,iphi,problemvalue);
221  if (abs(ieta)==28) // TP 28 spans towers 28 and 29
222  ProblemsByDepthZS_->depth[0]->Fill(ieta+abs(ieta)/ieta,iphi,problemvalue);
223  }
224  else
225  {
226  int newieta=-99;
227  for (int i=0;i<3;++i)
228  {
229  newieta=i+29+3*(abs(ieta)-29)+1; // shift values by 1 for HF in EtaPhiHistsplot
230  if (ieta<0) newieta*=-1;
231  ProblemsByDepthZS_->depth[0]->Fill(newieta,iphi,problemvalue);
232  ProblemsByDepthZS_->depth[0]->Fill(newieta,(iphi-2+72)%72,problemvalue);
233  }
234  if (abs(ieta)==32)
235  {
236  ProblemsByDepthZS_->depth[0]->Fill(42*abs(ieta)/ieta,iphi,problemvalue);
237  ProblemsByDepthZS_->depth[0]->Fill(42*abs(ieta)/ieta,(iphi-2+72)%72,problemvalue);
238  }
239  }
240  } // errors found in ZS
241  if (badvalZS>0 || badvalNZS>0)
242  {
243  // Fill overall problem histograms with sum from both ZS & NZS, or ZS only?
244  //problemvalue=(badvalZS+badvalNZS)*1./(badvalZS+badvalNZS+goodvalZS+goodvalNZS);
245 
246  // Update on 8 March -- NZS shows lots of errors; let's not include that in problem cells just yet
247  if (badvalZS==0) continue;
248  problemvalue=(badvalZS*1.)/(badvalZS+goodvalZS);
249  if (abs(ieta)<29) // Make special case for ieta=16 (HB/HE overlap?)
250  {
251  ProblemCellsByDepth->depth[0]->Fill(ieta,iphi,problemvalue);
252  ProblemCells->Fill(ieta,iphi,problemvalue);
253  if (abs(ieta)==28) // TP 28 spans towers 28 and 29
254  {
255  ProblemCellsByDepth->depth[0]->Fill(ieta+abs(ieta)/ieta,iphi,problemvalue);
256  ProblemCells->Fill(ieta+abs(ieta)/ieta,iphi,problemvalue);
257  }
258  }
259  else
260  {
261  int newieta=-99;
262  int newiphi=(iphi-2+72)%72; // forward triggers combine two HF cells; *subtract* 2 to the iphi, and allow wraparound
263  // FIXME:
264  // iphi seems to start at 1 in Patrick's plots, continues mod 4;
265  // adjust in far-forward region, where cells start at iphi=3? Check with Patrick.
266  for (int i=0;i<3;++i)
267  {
268  newieta=i+29+3*(abs(ieta)-29)+1; // shift values by 1 for HF in EtaPhiHistsplot
269  if (ieta<0) newieta*=-1;
270  ProblemCellsByDepth->depth[0]->Fill(newieta,iphi,problemvalue);
271  ProblemCells->Fill(newieta,iphi,problemvalue);
272  ProblemCellsByDepth->depth[0]->Fill(newieta,newiphi,problemvalue);
273  ProblemCells->Fill(newieta,newiphi,problemvalue);
274  }
275  if (abs(ieta)==32)
276  {
277  ProblemCellsByDepth->depth[0]->Fill(42*abs(ieta)/ieta,iphi,problemvalue);
278  ProblemCells->Fill(42*abs(ieta)/ieta,iphi,problemvalue);
279  ProblemCellsByDepth->depth[0]->Fill(42*abs(ieta)/ieta,newiphi,problemvalue);
280  ProblemCells->Fill(42*abs(ieta)/ieta,newiphi,problemvalue);
281  }
282  }
283  }
284  }
285  } // for (int eta=1;eta<etabins;++eta)
286 
287 
288  if (ProblemCells==0)
289  {
290  if (debug_>0) std::cout <<"<HcalTrigPrimClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
291  return;
292  }
293 
294  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
295  etabins=(ProblemCells->getTH2F())->GetNbinsX();
296  phibins=(ProblemCells->getTH2F())->GetNbinsY();
297  for (int eta=0;eta<etabins;++eta)
298  {
299  for (int phi=0;phi<phibins;++phi)
300  {
303  }
304  }
305 
310  return;
311 }
312 
314 
316 {
317 
319  problemnames_.clear();
320 
321  // Put the appropriate name of your problem summary here
322  ProblemCells=ib.book2D(" ProblemTriggerPrimitives",
323  " Problem Trigger Primitive Rate for all HCAL;ieta;iphi",
324  85,-42.5,42.5,
325  72,0.5,72.5);
326  problemnames_.push_back(ProblemCells->getName());
327  if (debug_>1)
328  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
329  ib.setCurrentFolder(subdir_+"problem_triggerprimitives");
331  ProblemCellsByDepth->setup(ib," Problem Trigger Primitive Rate");
332  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
333  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
334  nevts_=0;
335 
336  ib.setCurrentFolder(subdir_+"problem_ZS");
338  ProblemsByDepthZS_->setup(ib,"ZS Problem Trigger Primitive Rate");
339  ib.setCurrentFolder(subdir_+"problem_NZS");
341  ProblemsByDepthNZS_->setup(ib,"NZS Problem Trigger Primitive Rate");
342 
343  doProblemCellSetup_ = false;
344 }
345 
347 {
348  enoughevents_=false;
349 }
350 
351 //void HcalTrigPrimClient::endRun(void){analyze();}
352 
355 
357 {
358  if (!ProblemCells)
359  {
360  if (debug_>1) std::cout <<"<HcalTrigPrimClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
361  return false;
362  }
363  int problemcount=0;
364  int ieta=-9999;
365 
366  for (int depth=0;depth<4; ++depth)
367  {
368  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
369  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
370  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
371  {
372  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
373  {
374  ieta=CalcIeta(hist_eta,depth+1);
375  if (ieta==-9999) continue;
376  if (ProblemCellsByDepth->depth[depth]==0)
377  continue;
378  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
379  ++problemcount;
380 
381  } // for (int hist_phi=1;...)
382  } // for (int hist_eta=1;...)
383  } // for (int depth=0;...)
384 
385  if (problemcount>0) return true;
386  return false;
387 }
388 
389 bool HcalTrigPrimClient::hasWarnings_Temp(void){return false;}
390 bool HcalTrigPrimClient::hasOther_Temp(void){return false;}
391 bool HcalTrigPrimClient::test_enabled(void){return true;}
392 
393 
394 void HcalTrigPrimClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
395 {
396  // This gets called by HcalMonitorClient
397  // trigger primitives don't yet contribute to channel status (though they could...)
398  // see dead or hot cell code for an example
399 
400 } //void HcalTrigPrimClient::updateChannelStatus
401 
403 {
407 }
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)
int ib
Definition: cuy.py:660
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:298
HcalTrigPrimClient()
Constructors.
std::vector< std::string > HcalEtaPhiHistNames()
EtaPhiHists * ProblemsByDepthZS_
T eta() const
void Fill(long long x)
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
std::vector< std::string > problemnames_
EtaPhiHists * ProblemCellsByDepth
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setup(DQMStore::IBooker &m_dbe, std::string Name, std::string Units="")
EtaPhiHists * ProblemsByDepthNZS_
~HcalTrigPrimClient()
Destructor.
virtual void calculateProblems(void)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::string subdir_
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
void analyze(DQMStore::IBooker &, DQMStore::IGetter &)
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixME_
tuple cout
Definition: gather_cfg.py:121
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
TH2F * getTH2F(void) const
void Reset(void)
reset ME (ie. contents, errors, etc)
void setupProblemCells(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: DDAxes.h:10