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