CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalBeamClient.cc
Go to the documentation of this file.
4 
8 
9 #include <iostream>
10 
11 /*
12  * \file HcalBeamClient.cc
13  *
14  * \author J. Temple
15  * \brief Hcal Beam Monitor 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>("BeamFolder","BeamMonitor_Hcal/"); // BeamMonitor_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>("Beam_validHtmlOutput",true);
37  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
38  // known hot/dead channels blacked out on plot
39  badChannelStatusMask_ = ps.getUntrackedParameter<int>("Beam_BadChannelStatusMask",
40  ps.getUntrackedParameter<int>("BadChannelStatusMask",
43  ));
44 
45  minerrorrate_ = ps.getUntrackedParameter<double>("Beam_minerrorrate",
46  ps.getUntrackedParameter<double>("minerrorrate",0.05));
47  minevents_ = ps.getUntrackedParameter<int>("Beam_minLS",1);
48  // minevents_ = ps.getUntrackedParameter<int>("Beam_minevents",
49  // ps.getUntrackedParameter<int>("minevents",1));
50  Online_ = ps.getUntrackedParameter<bool>("online",false);
51 
52  ProblemCells=0;
54 }
55 
57 {
58  if (debug_>2) std::cout <<"\tHcalBeamClient::analyze()"<<std::endl;
59  enoughevents_=false;
61 }
62 
64 {
65  if (debug_>2) std::cout <<"\t\tHcalBeamClient::calculateProblems()"<<std::endl;
66  if(!dqmStore_) return;
67  double totalLumiBlocks=0;
68  // reminder:: lumi histograms work a bit differently, counting total number of lumi blocks, not total number of events
69  int etabins=0, phibins=0, zside=0;
70  double problemvalue=0;
71 
72  // Clear away old problems
73  if (ProblemCells!=0)
74  {
76  (ProblemCells->getTH2F())->SetMaximum(1.05);
77  (ProblemCells->getTH2F())->SetMinimum(0.);
78  }
79  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
80  {
81  if (ProblemCellsByDepth->depth[d]!=0)
82  {
83  ProblemCellsByDepth->depth[d]->Reset();
84  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
85  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
86  }
87  }
88 
89  // Get histograms that are used in testing
90  // currently none used,
91 
92  // get the dead and hot cell lumi histograms
93  TH2F* dead = 0;
94  TH2F* hot = 0;
95  MonitorElement* me;
96  me=dqmStore_->get(subdir_+"Lumi/HFlumi_total_deadcells");
97  if (me!=0)
98  dead=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,dead,debug_);
99  else if (debug_>0) std::cout <<" <HcalBeamClient::calculateProblems> Unable to get dead cell plot 'HFlumi_total_deadcells"<<std::endl;
100  me=dqmStore_->get(subdir_+"Lumi/HFlumi_total_hotcells");
101  if (me!=0)
102  hot=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,dead,debug_);
103  else if (debug_>0) std::cout <<" <HcalBeamClient::calculateProblems> Unable to get hot cell plot 'HFlumi_total_hotcells"<<std::endl;
104  int myieta=0;
105  int mydepth=0;
106  int myiphi=0;
107 
108  enoughevents_=true; // beam client works a little differently, counting only lumi blocks that have enough events to process. For this reason, let client continue running regardless of lumi blocks processed
109 
110  if (dead!=0 || hot!=0)
111  {
112  if (dead!=0)
113  {
114  totalLumiBlocks=dead->GetBinContent(-1,-1);
115  etabins=dead->GetNbinsX();
116  phibins=dead->GetNbinsY();
117  }
118  else
119  {
120  totalLumiBlocks=hot->GetBinContent(-1,-1);
121  etabins=hot->GetNbinsX();
122  phibins=hot->GetNbinsY();
123  }
124  if (totalLumiBlocks<minevents_ || totalLumiBlocks==0)
125  return;
126  for (int i=0;i<etabins;++i)
127  {
128  i<=3 ? myieta = i-36 : myieta=i+29; // separate HFM, HFP
129  if (abs(myieta)==33 || abs(myieta)==34)
130  mydepth=1;
131  else if (abs(myieta)==35 || abs(myieta)==36)
132  mydepth=2;
133  for (int j=0;j<phibins;++j)
134  {
135  problemvalue=0;
136  myiphi=2*j+1; // lumi HF histograms only have 36 bins
137  if (dead!=0 && dead->GetBinContent(i+1,j+1)*1./totalLumiBlocks>minerrorrate_)
138  {
139  problemvalue+=dead->GetBinContent(i+1,j+1)*1./totalLumiBlocks;
140  if (debug_>1) std::cout <<"<HcalBeamClient::calculateProblem> Dead cell found at ieta = "<<myieta<<" iphi = "<<myiphi<<" depth = "<<mydepth<<std::endl;
141  }
142  if (hot!=0 && hot->GetBinContent(i+1,j+1)*1./totalLumiBlocks>minerrorrate_)
143  {
144  problemvalue+=hot->GetBinContent(i+1,j+1)*1./totalLumiBlocks;
145  if (debug_>1) std::cout <<"<HcalBeamClient::calculateProblem> hot cell found at ieta = "<<myieta<<" iphi = "<<myiphi<<" depth = "<<mydepth<<std::endl;
146  }
147  if (problemvalue==0) continue;
148 
149  // Search for known bad problems in channel status db
150  HcalDetId hcalid(HcalForward, myieta, myiphi, mydepth);
151  if (badstatusmap.find(hcalid)!=badstatusmap.end())
152  problemvalue=999;
153  myieta<0 ? zside=-1 : zside=1;
154  ProblemCellsByDepth->depth[mydepth-1]->Fill(myieta+zside,myiphi,problemvalue);
155  if (ProblemCells!=0) ProblemCells->Fill(myieta+zside,myiphi,problemvalue);
156  }
157  }
158  }
159 
160 
161  if (ProblemCells==0)
162  {
163  if (debug_>0) std::cout <<"<HcalBeamClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
164  return;
165  }
166 
167  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
168  etabins=(ProblemCells->getTH2F())->GetNbinsX();
169  phibins=(ProblemCells->getTH2F())->GetNbinsY();
170  for (int eta=0;eta<etabins;++eta)
171  {
172  for (int phi=0;phi<phibins;++phi)
173  {
176  }
177  }
180  return;
181 }
182 
184 {
186  if (debug_>0)
187  {
188  std::cout <<"<HcalBeamClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
190  }
191 }
193 
195 {
196  enoughevents_=false;
197  if (!dqmStore_)
198  {
199  if (debug_>0) std::cout <<"<HcalBeamClient::beginRun> dqmStore does not exist!"<<std::endl;
200  return;
201  }
203  problemnames_.clear();
204 
205  // Put the appropriate name of your problem summary here
206  if (ProblemCells==0)
207  ProblemCells=dqmStore_->book2D(" Problem BeamMonitor",
208  " Problem Beam Monitor Rate for all HCAL;ieta;iphi",
209  85,-42.5,42.5,
210  72,0.5,72.5);
211  problemnames_.push_back(ProblemCells->getName());
212  if (debug_>1)
213  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
214  dqmStore_->setCurrentFolder(subdir_+"problem_beammonitor");
215  nevts_=0;
216  if (ProblemCellsByDepth!=0) return; // histograms already set up
218  ProblemCellsByDepth->setup(dqmStore_," Problem BeamMonitor Rate");
219  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
220  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
221 }
222 
224 
227 
229 {
230  if (!ProblemCells)
231  {
232  if (debug_>1) std::cout <<"<HcalBeamClient::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 
261 bool HcalBeamClient::hasWarnings_Temp(void){return false;}
262 bool HcalBeamClient::hasOther_Temp(void){return false;}
263 bool HcalBeamClient::test_enabled(void){return true;}
264 
265 
266 void HcalBeamClient::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 HcalBeamClient::updateChannelStatus
273 
275 {}
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
void setBinContent(int binx, double content)
set content of bin (1-D)
void beginRun(void)
bool hasErrors_Temp(void)
void calculateProblems(void)
bool test_enabled(void)
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
T eta() const
bool hasWarnings_Temp(void)
void Fill(long long x)
void cleanup(void)
void endRun(void)
void setup(void)
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
bool hasOther_Temp(void)
~HcalBeamClient()
Destructor.
std::vector< std::string > problemnames_
HcalBeamClient()
Constructors.
EtaPhiHists * ProblemCellsByDepth
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
void beginJob(void)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
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 endJob(void)
tuple cout
Definition: gather_cfg.py:121
void showDirStructure(void) const
Definition: DQMStore.cc:2962
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:1001
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
void analyze(void)
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
Definition: DDAxes.h:10