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