CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDetDiagTimingClient.cc
Go to the documentation of this file.
4 
8 
9 #include <iostream>
10 
11 /*
12  * \file HcalDetDiagTimingClient.cc
13  *
14  * \author J. Temple
15  * \brief Hcal DetDiagTiming 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>("DetDiagTimingFolder","DetDiagTimingMonitor_Hcal/"); // DetDiagTiming_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>("DetDiagTiming_validHtmlOutput",true);
37  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
38  badChannelStatusMask_ = ps.getUntrackedParameter<int>("DetDiagTiming_BadChannelStatusMask",
39  ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
40 
41  minerrorrate_ = ps.getUntrackedParameter<double>("DetDiagTiming_minerrorrate",
42  ps.getUntrackedParameter<double>("minerrorrate",0.05));
43  minevents_ = ps.getUntrackedParameter<int>("DetDiagTiming_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 <<"\tHcalDetDiagTimingClient::analyze()"<<std::endl;
55 }
56 
58 {
59  if (debug_>2) std::cout <<"\t\tHcalDetDiagTimingClient::calculateProblems()"<<std::endl;
60  if(!dqmStore_) return;
61  //double totalevents=0;
62  int etabins=0, phibins=0, zside=0;
63  double problemvalue=0;
64 
65  // Clear away old problems
66  if (ProblemCells!=0)
67  {
69  (ProblemCells->getTH2F())->SetMaximum(1.05);
70  (ProblemCells->getTH2F())->SetMinimum(0.);
71  }
72  for (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
73  {
74  if (ProblemCellsByDepth->depth[d]!=0)
75  {
76  ProblemCellsByDepth->depth[d]->Reset();
77  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
78  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
79  }
80  }
81  enoughevents_=true;
82  // Get histograms that are used in testing
83  // currently none used,
84 
85  std::vector<std::string> name = HcalEtaPhiHistNames();
86 
87  // This is a sample of how to get a histogram from the task that can then be used for evaluation purposes
88  /*
89  TH2F* BadTiming[4];
90  TH2F* BadEnergy[4];
91  MonitorElement* me;
92  for (int i=0;i<4;++i)
93  {
94  std::string s=subdir_+name[i]+" Problem Bad Laser Timing";
95  me=dqmStore_->get(s.c_str());
96  if (me!=0) BadTiming[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadTiming[i], debug_);
97  else if (debug_>0) std::cout <<"<HcalDetDiagTimingClient::analyze> could not get histogram '"<<s<<"'"<<std::endl;
98  s=subdir_+name[i]+" Problem Bad Laser Energy";
99  me=dqmStore_->get(s.c_str());
100  if (me!=0) BadEnergy[i]=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, BadEnergy[i], debug_);
101  else if (debug_>0) std::cout <<"<HcalDetDiagTimingClient::analyze> could not get histogram '"<<s<<"'"<<std::endl;
102  }
103  */
104 
105  // Because we're clearing and re-forming the problem cell histogram here, we don't need to do any cute
106  // setting of the underflow bin to 0, and we can plot results as a raw rate between 0-1.
107 
108  for (unsigned int d=0;d<ProblemCellsByDepth->depth.size();++d)
109  {
110  if (ProblemCellsByDepth->depth[d]==0) continue;
111 
112  //totalevents=DigiPresentByDepth[d]->GetBinContent(0);
113  //totalevents=0;
114  // Check underflow bins for events processed
115  /*
116  if (BadTiming[d]!=0) totalevents = BadTiming[d]->GetBinContent(0);
117  else if (BadEnergy[d]!=0) totalevents = BadEnergy[d]->GetBinContent(0);
118  */
119  //if (totalevents==0 || totalevents<minevents_) continue;
120 
121  //totalevents=1; // temporary value pending removal of histogram normalization from tasks
122 
123  etabins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsX();
124  phibins=(ProblemCellsByDepth->depth[d]->getTH2F())->GetNbinsY();
125  for (int eta=0;eta<etabins;++eta)
126  {
127  int ieta=CalcIeta(eta,d+1);
128  if (ieta==-9999) continue;
129  for (int phi=0;phi<phibins;++phi)
130  {
131  problemvalue=0;
132  /*
133  if (BadTiming[d]!=0) problemvalue += BadTiming[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
134  else if (BadEnergy[d]!=0) problemvalue += BadEnergy[d]->GetBinContent(eta+1,phi+1)*1./totalevents;
135  */
136  if (problemvalue==0) continue;
137  // problem value is a rate; we can normalize it here
138  problemvalue = std::min(1.,problemvalue);
139 
140  zside=0;
141  if (isHF(eta,d+1)) // shift ieta by 1 for HF
142  ieta<0 ? zside = -1 : zside = 1;
143 
144  // For problem cells that exceed our allowed rate,
145  // set the values to -1 if the cells are already marked in the status database
146  if (problemvalue>minerrorrate_)
147  {
148  HcalSubdetector subdet=HcalEmpty;
149  if (isHB(eta,d+1))subdet=HcalBarrel;
150  else if (isHE(eta,d+1)) subdet=HcalEndcap;
151  else if (isHF(eta,d+1)) subdet=HcalForward;
152  else if (isHO(eta,d+1)) subdet=HcalOuter;
153  HcalDetId hcalid(subdet, ieta, phi+1, (int)(d+1));
154  if (badstatusmap.find(hcalid)!=badstatusmap.end())
155  problemvalue=999;
156  }
157 
158  ProblemCellsByDepth->depth[d]->setBinContent(eta+1,phi+1,problemvalue);
159  if (ProblemCells!=0) ProblemCells->Fill(ieta+zside,phi+1,problemvalue);
160  } // loop on phi
161  } // loop on eta
162  } // loop on depth
163 
164  if (ProblemCells==0)
165  {
166  if (debug_>0) std::cout <<"<HcalDetDiagTimingClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
167  return;
168  }
169 
170  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
171  etabins=(ProblemCells->getTH2F())->GetNbinsX();
172  phibins=(ProblemCells->getTH2F())->GetNbinsY();
173  for (int eta=0;eta<etabins;++eta)
174  {
175  for (int phi=0;phi<phibins;++phi)
176  {
179  }
180  }
181 
184  return;
185 }
186 
188 {
190  if (debug_>0)
191  {
192  std::cout <<"<HcalDetDiagTimingClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
194  }
195 }
197 
199 {
200  enoughevents_=false;
201  if (!dqmStore_)
202  {
203  if (debug_>0) std::cout <<"<HcalDetDiagTimingClient::beginRun> dqmStore does not exist!"<<std::endl;
204  return;
205  }
207  problemnames_.clear();
208 
209  // Put the appropriate name of your problem summary here
210  ProblemCells=dqmStore_->book2D(" ProblemDetDiagTiming",
211  " Problem DetDiagTiming Rate for all HCAL;ieta;iphi",
212  85,-42.5,42.5,
213  72,0.5,72.5);
214  problemnames_.push_back(ProblemCells->getName());
215  if (debug_>1)
216  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
217  dqmStore_->setCurrentFolder(subdir_+"problem_DetDiagTiming");
219  ProblemCellsByDepth->setup(dqmStore_," Problem DetDiagTiming Rate");
220  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
221  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
222  nevts_=0;
223 }
224 
226 
229 
231 {
232  if (!ProblemCells)
233  {
234  if (debug_>1) std::cout <<"<HcalDetDiagTimingClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
235  return false;
236  }
237  int problemcount=0;
238  int ieta=-9999;
239 
240  for (int depth=0;depth<4; ++depth)
241  {
242  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
243  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
244  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
245  {
246  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
247  {
248  ieta=CalcIeta(hist_eta,depth+1);
249  if (ieta==-9999) continue;
250  if (ProblemCellsByDepth->depth[depth]==0)
251  continue;
252  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
253  ++problemcount;
254 
255  } // for (int hist_phi=1;...)
256  } // for (int hist_eta=1;...)
257  } // for (int depth=0;...)
258 
259  if (problemcount>0) return true;
260  return false;
261 }
262 
264 bool HcalDetDiagTimingClient::hasOther_Temp(void){return false;}
266 
267 
268 void HcalDetDiagTimingClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
269 {
270  // This gets called by HcalMonitorClient
271  // trigger primitives don't yet contribute to channel status (though they could...)
272  // see dead or hot cell code for an example
273 
274 } //void HcalDetDiagTimingClient::updateChannelStatus
275 
277 {}
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)
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)
bool isHF(int etabin, int depth)
std::string subdir_
std::map< HcalDetId, unsigned int > badstatusmap
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
double getBinContent(int binx) const
get content of bin (1-D)
HcalDetDiagTimingClient()
Constructors.
std::string prefixME_
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
Definition: DDAxes.h:10