CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDetDiagNoiseMonitorClient.cc
Go to the documentation of this file.
4 
8 
9 #include <iostream>
10 
11 /*
12  * \file HcalDetDiagNoiseMonitorClient.cc
13  *
14  * \author J. Temple
15  * \brief Hcal DetDiagNoiseMonitor 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>("DetDiagNoiseMonitorFolder","DetDiagNoiseMonitor_Hcal/"); // DetDiagNoiseMonitor_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>("DetDiagNoiseMonitor_validHtmlOutput",true);
37  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
38  badChannelStatusMask_ = ps.getUntrackedParameter<int>("DetDiagNoiseMonitor_BadChannelStatusMask",
39  ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
40 
41  minerrorrate_ = ps.getUntrackedParameter<double>("DetDiagNoiseMonitor_minerrorrate",
42  ps.getUntrackedParameter<double>("minerrorrate",0.05));
43  minevents_ = ps.getUntrackedParameter<int>("DetDiagNoiseMonitor_minevents",
44  ps.getUntrackedParameter<int>("minevents",1));
45  ProblemCells=0;
47 }
48 
50 {
51  if (debug_>2) std::cout <<"\tHcalDetDiagNoiseMonitorClient::analyze()"<<std::endl;
53 }
54 
56 {
57  if (debug_>2) std::cout <<"\t\tHcalDetDiagNoiseMonitorClient::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  // This is a sample of how to get a histogram from the task that can then be used for evaluation purposes
86  /*
87  TH2F* BadTiming[4];
88  TH2F* BadEnergy[4];
89  MonitorElement* me;
90  for (int i=0;i<4;++i)
91  {
92  std::string s=subdir_+name[i]+" Problem Bad Laser Timing";
93  me=dqmStore_->get(s.c_str());
94  if (me!=0) BadTiming[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadTiming[i], debug_);
95  else if (debug_>0) std::cout <<"<HcalDetDiagNoiseMonitorClient::analyze> could not get histogram '"<<s<<"'"<<std::endl;
96  s=subdir_+name[i]+" Problem Bad Laser Energy";
97  me=dqmStore_->get(s.c_str());
98  if (me!=0) BadEnergy[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadEnergy[i], debug_);
99  else if (debug_>0) std::cout <<"<HcalDetDiagNoiseMonitorClient::analyze> could not get histogram '"<<s<<"'"<<std::endl;
100  }
101  */
102 
103  // Because we're clearing and re-forming the problem cell histogram here, we don't need to do any cute
104  // setting of the underflow bin to 0, and we can plot results as a raw rate between 0-1.
105 
106  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
107  {
108  if (ProblemCellsByDepth->depth[d]==0) continue;
109 
110  //totalevents=DigiPresentByDepth[d]->GetBinContent(0);
111  //totalevents=0;
112  // Check underflow bins for events processed
113  /*
114  if (BadTiming[d]!=0) totalevents = BadTiming[d]->GetBinContent(0);
115  else if (BadEnergy[d]!=0) totalevents = BadEnergy[d]->GetBinContent(0);
116  */
117  //if (totalevents==0 || totalevents<minevents_) continue;
118 
119  //totalevents=1; // temporary value pending removal of histogram normalization from tasks
120 
121  etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
122  phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
123  for (int eta=0;eta<etabins;++eta)
124  {
125  int ieta=CalcIeta(eta,d+1);
126  if (ieta==-9999) continue;
127  for (int phi=0;phi<phibins;++phi)
128  {
129  problemvalue=0;
130  /*
131  if (BadTiming[d]!=0) problemvalue += BadTiming[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
132  else if (BadEnergy[d]!=0) problemvalue += BadEnergy[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
133  */
134  if (problemvalue==0) continue;
135  // problem value is a rate; we can normalize it here
136  problemvalue = std::min(1.,problemvalue);
137 
138  zside=0;
139  if (isHF(eta,d+1)) // shift ieta by 1 for HF
140  ieta<0 ? zside = -1 : zside = 1;
141 
142  // For problem cells that exceed our allowed rate,
143  // set the values to -1 if the cells are already marked in the status database
144  if (problemvalue>minerrorrate_)
145  {
146  HcalSubdetector subdet=HcalEmpty;
147  if (isHB(eta,d+1))subdet=HcalBarrel;
148  else if (isHE(eta,d+1)) subdet=HcalEndcap;
149  else if (isHF(eta,d+1)) subdet=HcalForward;
150  else if (isHO(eta,d+1)) subdet=HcalOuter;
151  HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
152  if (badstatusmap.find(hcalid)!=badstatusmap.end())
153  problemvalue=999;
154  }
155 
156  ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
157  if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
158  } // loop on phi
159  } // loop on eta
160  } // loop on depth
161 
162  if (ProblemCells==0)
163  {
164  if (debug_>0) std::cout <<"<HcalDetDiagNoiseMonitorClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
165  return;
166  }
167 
168  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
169  etabins=(ProblemCells->getTH2F())->GetNbinsX();
170  phibins=(ProblemCells->getTH2F())->GetNbinsY();
171  for (int eta=0;eta<etabins;++eta)
172  {
173  for (int phi=0;phi<phibins;++phi)
174  {
177  }
178  }
179 
182  return;
183 }
184 
186 {
188  if (debug_>0)
189  {
190  std::cout <<"<HcalDetDiagNoiseMonitorClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
192  }
193 }
195 
197 {
198  enoughevents_=false;
199  if (!dqmStore_)
200  {
201  if (debug_>0) std::cout <<"<HcalDetDiagNoiseMonitorClient::beginRun> dqmStore does not exist!"<<std::endl;
202  return;
203  }
205  problemnames_.clear();
206 
207  // Put the appropriate name of your problem summary here
208  ProblemCells=dqmStore_->book2D(" ProblemDetDiagNoiseMonitor",
209  " Problem DetDiagNoiseMonitor Rate for all HCAL;ieta;iphi",
210  85,-42.5,42.5,
211  72,0.5,72.5);
212  problemnames_.push_back(ProblemCells->getName());
213  if (debug_>1)
214  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
215  dqmStore_->setCurrentFolder(subdir_+"problem_DetDiagNoiseMonitor");
217  ProblemCellsByDepth->setup(dqmStore_," Problem DetDiagNoiseMonitor Rate");
218  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
219  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
220  nevts_=0;
221 }
222 
224 
227 
229 {
230  if (!ProblemCells)
231  {
232  if (debug_>1) std::cout <<"<HcalDetDiagNoiseMonitorClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
233  return false;
234  }
235  int problemcount=0;
236  int ieta=-9999;
237 
238  for (int depth=0;depth<4; ++depth)
239  {
240  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
241  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
242  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
243  {
244  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
245  {
246  ieta=CalcIeta(hist_eta,depth+1);
247  if (ieta==-9999) continue;
248  if (ProblemCellsByDepth->depth[depth]==0)
249  continue;
250  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
251  ++problemcount;
252 
253  } // for (int hist_phi=1;...)
254  } // for (int hist_eta=1;...)
255  } // for (int depth=0;...)
256 
257  if (problemcount>0) return true;
258  return false;
259 }
260 
264 
265 
266 void HcalDetDiagNoiseMonitorClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
267 {
268  // This gets called by HcalMonitorClient
269  // trigger primitives don't yet contribute to channel status (though they could...)
270  // see dead or hot cell code for an example
271 
272 } //void HcalDetDiagNoiseMonitorClient::updateChannelStatus
273 
275 {}
bool isHO(int etabin, int depth)
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)
std::vector< std::string > HcalEtaPhiHistNames()
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 Fill(long long x)
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
std::vector< std::string > problemnames_
EtaPhiHists * ProblemCellsByDepth
HcalSubdetector
Definition: HcalAssistant.h:31
T min(T a, T b)
Definition: MathUtil.h:58
bool isHB(int etabin, int depth)
bool isHF(int etabin, int depth)
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_
tuple cout
Definition: gather_cfg.py:121
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