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  setupProblemCells_=true;
56 }
57 
59 {
60  if (debug_>2) std::cout <<"\tHcalBeamClient::analyze()"<<std::endl;
61  enoughevents_=false;
62 
64 
65  calculateProblems(ib,ig);
66 }
67 
69 {
70  if (debug_>2) std::cout <<"\t\tHcalBeamClient::calculateProblems()"<<std::endl;
71  double totalLumiBlocks=0;
72  // reminder:: lumi histograms work a bit differently, counting total number of lumi blocks, not total number of events
73  int etabins=0, phibins=0, zside=0;
74  double problemvalue=0;
75 
76  // Clear away old problems
77  if (ProblemCells!=0)
78  {
80  (ProblemCells->getTH2F())->SetMaximum(1.05);
81  (ProblemCells->getTH2F())->SetMinimum(0.);
82  }
83  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
84  {
85  if (ProblemCellsByDepth->depth[d]!=0)
86  {
87  ProblemCellsByDepth->depth[d]->Reset();
88  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
89  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
90  }
91  }
92 
93  // Get histograms that are used in testing
94  // currently none used,
95 
96  // get the dead and hot cell lumi histograms
97  TH2F* dead = 0;
98  TH2F* hot = 0;
99  MonitorElement* me;
100  me=ig.get(subdir_+"Lumi/HFlumi_total_deadcells");
101  if (me!=0)
102  dead=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,dead,debug_);
103  else if (debug_>0) std::cout <<" <HcalBeamClient::calculateProblems> Unable to get dead cell plot 'HFlumi_total_deadcells"<<std::endl;
104  me=ig.get(subdir_+"Lumi/HFlumi_total_hotcells");
105  if (me!=0)
106  hot=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,dead,debug_);
107  else if (debug_>0) std::cout <<" <HcalBeamClient::calculateProblems> Unable to get hot cell plot 'HFlumi_total_hotcells"<<std::endl;
108  int myieta=0;
109  int mydepth=0;
110  int myiphi=0;
111 
112  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
113 
114  if (dead!=0 || hot!=0)
115  {
116  if (dead!=0)
117  {
118  totalLumiBlocks=dead->GetBinContent(-1,-1);
119  etabins=dead->GetNbinsX();
120  phibins=dead->GetNbinsY();
121  }
122  else
123  {
124  totalLumiBlocks=hot->GetBinContent(-1,-1);
125  etabins=hot->GetNbinsX();
126  phibins=hot->GetNbinsY();
127  }
128  if (totalLumiBlocks<minevents_ || totalLumiBlocks==0)
129  return;
130  for (int i=0;i<etabins;++i)
131  {
132  i<=3 ? myieta = i-36 : myieta=i+29; // separate HFM, HFP
133  if (abs(myieta)==33 || abs(myieta)==34)
134  mydepth=1;
135  else if (abs(myieta)==35 || abs(myieta)==36)
136  mydepth=2;
137  for (int j=0;j<phibins;++j)
138  {
139  problemvalue=0;
140  myiphi=2*j+1; // lumi HF histograms only have 36 bins
141  if (dead!=0 && dead->GetBinContent(i+1,j+1)*1./totalLumiBlocks>minerrorrate_)
142  {
143  problemvalue+=dead->GetBinContent(i+1,j+1)*1./totalLumiBlocks;
144  if (debug_>1) std::cout <<"<HcalBeamClient::calculateProblem> Dead cell found at ieta = "<<myieta<<" iphi = "<<myiphi<<" depth = "<<mydepth<<std::endl;
145  }
146  if (hot!=0 && hot->GetBinContent(i+1,j+1)*1./totalLumiBlocks>minerrorrate_)
147  {
148  problemvalue+=hot->GetBinContent(i+1,j+1)*1./totalLumiBlocks;
149  if (debug_>1) std::cout <<"<HcalBeamClient::calculateProblem> hot cell found at ieta = "<<myieta<<" iphi = "<<myiphi<<" depth = "<<mydepth<<std::endl;
150  }
151  if (problemvalue==0) continue;
152 
153  // Search for known bad problems in channel status db
154  HcalDetId hcalid(HcalForward, myieta, myiphi, mydepth);
155  if (badstatusmap.find(hcalid)!=badstatusmap.end())
156  problemvalue=999;
157  myieta<0 ? zside=-1 : zside=1;
158  ProblemCellsByDepth->depth[mydepth-1]->Fill(myieta+zside,myiphi,problemvalue);
159  if (ProblemCells!=0) ProblemCells->Fill(myieta+zside,myiphi,problemvalue);
160  }
161  }
162  }
163 
164 
165  if (ProblemCells==0)
166  {
167  if (debug_>0) std::cout <<"<HcalBeamClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
168  return;
169  }
170 
171  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
172  etabins=(ProblemCells->getTH2F())->GetNbinsX();
173  phibins=(ProblemCells->getTH2F())->GetNbinsY();
174  for (int eta=0;eta<etabins;++eta)
175  {
176  for (int phi=0;phi<phibins;++phi)
177  {
180  }
181  }
184  return;
185 }
186 
188 
190 {
191 
193  problemnames_.clear();
194 
195  // Put the appropriate name of your problem summary here
196  if (ProblemCells==0)
197  ProblemCells=ib.book2D(" Problem BeamMonitor",
198  " Problem Beam Monitor Rate for all HCAL;ieta;iphi",
199  85,-42.5,42.5,
200  72,0.5,72.5);
201  problemnames_.push_back(ProblemCells->getName());
202  if (debug_>1)
203  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
204  ib.setCurrentFolder(subdir_+"problem_beammonitor");
205  nevts_=0;
206  if (ProblemCellsByDepth!=0) return; // histograms already set up
208  ProblemCellsByDepth->setup(ib," Problem BeamMonitor Rate");
209  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
210  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
211 
212  setupProblemCells_ = false;
213 
214 }
215 
216 //
218 {
219  enoughevents_=false;
220 }
221 
222 //void HcalBeamClient::endRun(void){analyze();}
223 
226 
228 {
229  if (!ProblemCells)
230  {
231  if (debug_>1) std::cout <<"<HcalBeamClient::hasErrors_Temp> ProblemCells histogram does not exist!"<<std::endl;
232  return false;
233  }
234  int problemcount=0;
235  int ieta=-9999;
236 
237  for (int depth=0;depth<4; ++depth)
238  {
239  int etabins = (ProblemCells->getTH2F())->GetNbinsX();
240  int phibins = (ProblemCells->getTH2F())->GetNbinsY();
241  for (int hist_eta=0;hist_eta<etabins;++hist_eta)
242  {
243  for (int hist_phi=0; hist_phi<phibins;++hist_phi)
244  {
245  ieta=CalcIeta(hist_eta,depth+1);
246  if (ieta==-9999) continue;
248  continue;
249  if (ProblemCellsByDepth->depth[depth]->getBinContent(hist_eta,hist_phi)>minerrorrate_)
250  ++problemcount;
251 
252  } // for (int hist_phi=1;...)
253  } // for (int hist_eta=1;...)
254  } // for (int depth=0;...)
255 
256  if (problemcount>0) return true;
257  return false;
258 }
259 
260 bool HcalBeamClient::hasWarnings_Temp(void){return false;}
261 bool HcalBeamClient::hasOther_Temp(void){return false;}
262 bool HcalBeamClient::test_enabled(void){return true;}
263 
264 
265 void HcalBeamClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual)
266 {
267  // This gets called by HcalMonitorClient
268  // trigger primitives don't yet contribute to channel status (though they could...)
269  // see dead or hot cell code for an example
270 
271 } //void HcalBeamClient::updateChannelStatus
272 
274 {
276 }
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)
int ib
Definition: cuy.py:660
void beginRun(void)
bool hasErrors_Temp(void)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
bool test_enabled(void)
int zside(DetId const &)
T eta() const
bool hasWarnings_Temp(void)
void Fill(long long x)
void cleanup(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 setup(DQMStore::IBooker &m_dbe, std::string Name, std::string Units="")
virtual void calculateProblems(void)
void analyze(DQMStore::IBooker &, DQMStore::IGetter &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
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
TH2F * getTH2F(void) const
void doProblemCellSetup(DQMStore::IBooker &, DQMStore::IGetter &)
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
void Reset(void)
reset ME (ie. contents, errors, etc)
Definition: DDAxes.h:10