CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalNZSClient.cc
Go to the documentation of this file.
4 
8 
9 #include <iostream>
10 
11 /*
12  * \file HcalNZSClient.cc
13  *
14  * \author J. Temple
15  * \brief Hcal NZS 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>("NZSFolder","NZSMonitor_Hcal/"); // NZSMonitor_Hcal/
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>("NZS_validHtmlOutput",true);
37  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
38  badChannelStatusMask_ = ps.getUntrackedParameter<int>("NZS_BadChannelStatusMask",
39  ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
40 
41  minerrorrate_ = ps.getUntrackedParameter<double>("NZS_minerrorrate",
42  ps.getUntrackedParameter<double>("minerrorrate",0.01));
43  minevents_ = ps.getUntrackedParameter<int>("NZS_minevents",
44  ps.getUntrackedParameter<int>("minevents",1));
45  ProblemCells=0;
47 }
48 
50 {
51  if (debug_>2) std::cout <<"\tHcalNZSClient::analyze()"<<std::endl;
53 }
54 
56 {
57  if (debug_>2) std::cout <<"\t\tHcalNZSClient::calculateProblems()"<<std::endl;
58  if(!dqmStore_) return;
59  double totalevents=0;
60  int etabins=0, phibins=0, zside=0;
61  double problemvalue=0;
62 
63  // Clear away old problems
64  if (ProblemCells!=0)
65  {
67  (ProblemCells->getTH2F())->SetMaximum(1.05);
68  (ProblemCells->getTH2F())->SetMinimum(0.);
69  }
70  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
71  {
72  if (ProblemCellsByDepth->depth[d]!=0)
73  {
74  ProblemCellsByDepth->depth[d]->Reset();
75  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
76  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
77  }
78  }
79  enoughevents_=true;
80  // Get histograms that are used in testing
81  // currently none used,
82 
83  std::vector<std::string> name = HcalEtaPhiHistNames();
84 
85  /*
86  // This is a sample of how to get a histogram from the task that can then be used for evaluation purposes
87  TH2F* DigiPresentByDepth[i]
88  MonitorElement* me;
89  for (int i=0;i<4;++i)
90  {
91  std::string s=subdir_+"dead_digi_never_present/"+name[i]+"Digi Present At Least Once";
92  me=dqmStore_->get(s.c_str());
93  DigiPresentByDepth[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, DigiPresentByDepth[i], debug_);
94  }
95  */
96 
97 
98  // Because we're clearing and re-forming the problem cell histogram here, we don't need to do any cute
99  // setting of the underflow bin to 0, and we can plot results as a raw rate between 0-1.
100 
101  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
102  {
103  if (ProblemCellsByDepth->depth[d]==0) continue;
104 
105  //totalevents=DigiPresentByDepth[d]->GetBinContent(0);
106  totalevents=0;
107  if (totalevents==0 || totalevents<minevents_) continue;
108  etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
109  phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
110  problemvalue=0;
111  for (int eta=0;eta<etabins;++eta)
112  {
113  int ieta=CalcIeta(eta,d+1);
114  if (ieta==-9999) continue;
115  for (int phi=0;phi<phibins;++phi)
116  {
117  problemvalue=0;
118  //if (DigiPresentByDepth[d]!=0 && DigiPresentByDepth[d]->GetBinContent(eta+1,phi+1)==0) problemvalue=totalevents;
119  if (problemvalue==0) continue;
120  problemvalue/=totalevents; // problem value is a rate; should be between 0 and 1
121  problemvalue = std::min(1.,problemvalue);
122 
123  zside=0;
124  if (isHF(eta,d+1)) // shift ieta by 1 for HF
125  ieta<0 ? zside = -1 : zside = 1;
126 
127  // For problem cells that exceed our allowed rate,
128  // set the values to -1 if the cells are already marked in the status database
129  if (problemvalue>minerrorrate_)
130  {
131  HcalSubdetector subdet=HcalEmpty;
132  if (isHB(eta,d+1))subdet=HcalBarrel;
133  else if (isHE(eta,d+1)) subdet=HcalEndcap;
134  else if (isHF(eta,d+1)) subdet=HcalForward;
135  else if (isHO(eta,d+1)) subdet=HcalOuter;
136  HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
137  if (badstatusmap.find(hcalid)!=badstatusmap.end())
138  problemvalue=999;
139  }
140 
141  ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
142  if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
143  } // loop on phi
144  } // loop on eta
145  } // loop on depth
146 
147  if (ProblemCells==0)
148  {
149  if (debug_>0) std::cout <<"<HcalNZSClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
150  return;
151  }
152 
153  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
154  etabins=(ProblemCells->getTH2F())->GetNbinsX();
155  phibins=(ProblemCells->getTH2F())->GetNbinsY();
156  for (int eta=0;eta<etabins;++eta)
157  {
158  for (int phi=0;phi<phibins;++phi)
159  {
162  }
163  }
164 
167  return;
168 }
169 
171 {
173  if (debug_>0)
174  {
175  std::cout <<"<HcalNZSClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
177  }
178 }
180 
182 {
183  enoughevents_=false;
184  if (!dqmStore_)
185  {
186  if (debug_>0) std::cout <<"<HcalNZSClient::beginRun> dqmStore does not exist!"<<std::endl;
187  return;
188  }
190  problemnames_.clear();
191 
192  // Put the appropriate name of your problem summary here
193  ProblemCells=dqmStore_->book2D(" ProblemNZS",
194  " Problem NZS Rate for all HCAL;ieta;iphi",
195  85,-42.5,42.5,
196  72,0.5,72.5);
197  problemnames_.push_back(ProblemCells->getName());
198  if (debug_>1)
199  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
200  dqmStore_->setCurrentFolder(subdir_+"problem_NZS");
202  ProblemCellsByDepth->setup(dqmStore_," Problem NZS Rate");
203  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
204  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
205  nevts_=0;
206 }
207 
209 
212 
214 {
215  if (!ProblemCells)
216  {
217  if (debug_>1) std::cout <<"<HcalNZSClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
218  return false;
219  }
220  int problemcount=0;
221  int ieta=-9999;
222 
223  for (int depth=0;depth<4; ++depth)
224  {
225  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
226  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
227  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
228  {
229  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
230  {
231  ieta=CalcIeta(hist_eta,depth+1);
232  if (ieta==-9999) continue;
233  if (ProblemCellsByDepth->depth[depth]==0)
234  continue;
235  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
236  ++problemcount;
237 
238  } // for (int hist_phi=1;...)
239  } // for (int hist_eta=1;...)
240  } // for (int depth=0;...)
241 
242  if (problemcount>0) return true;
243  return false;
244 }
245 
246 bool HcalNZSClient::hasWarnings_Temp(void){return false;}
247 bool HcalNZSClient::hasOther_Temp(void){return false;}
248 bool HcalNZSClient::test_enabled(void){return true;}
249 
250 
251 void HcalNZSClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
252 {
253  // This gets called by HcalMonitorClient
254  // trigger primitives don't yet contribute to channel status (though they could...)
255  // see dead or hot cell code for an example
256 
257 } //void HcalNZSClient::updateChannelStatus
258 
260 {}
bool isHO(int etabin, int depth)
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
void calculateProblems(void)
int i
Definition: DBlmapReader.cc:9
MonitorElement * ProblemCells
std::string name()
void setBinContent(int binx, double content)
set content of bin (1-D)
bool test_enabled(void)
std::vector< std::string > HcalEtaPhiHistNames()
bool hasErrors_Temp(void)
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
int zside(DetId const &)
bool isHE(int etabin, int depth)
T eta() const
void beginRun(void)
void Fill(long long x)
bool hasOther_Temp(void)
~HcalNZSClient()
Destructor.
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
std::vector< std::string > problemnames_
EtaPhiHists * ProblemCellsByDepth
HcalSubdetector
Definition: HcalAssistant.h:31
bool isHB(int etabin, int depth)
void endJob(void)
void setup(void)
bool isHF(int etabin, int depth)
void cleanup(void)
HcalNZSClient()
Constructors.
Definition: HcalNZSClient.h:13
std::string subdir_
std::map< HcalDetId, unsigned int > badstatusmap
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixME_
void analyze(void)
bool hasWarnings_Temp(void)
tuple cout
Definition: gather_cfg.py:121
void showDirStructure(void) const
Definition: DQMStore.cc:3282
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:1070
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
void beginJob(void)
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
void endRun(void)
Definition: DDAxes.h:10