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  * $Date: 2012/06/18 08:23:10 $
15  * $Revision: 1.20 $
16  * \author J. Temple
17  * \brief Hcal Beam Monitor Client class
18  */
19 
20 HcalBeamClient::HcalBeamClient(std::string myname)
21 {
22  name_=myname;
23 }
24 
25 HcalBeamClient::HcalBeamClient(std::string myname, const edm::ParameterSet& ps)
26 {
27  name_=myname;
28  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
29  debug_ = ps.getUntrackedParameter<int>("debug",0);
30  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
31  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
32  prefixME_.append("/");
33  subdir_ = ps.getUntrackedParameter<std::string>("BeamFolder","BeamMonitor_Hcal/"); // BeamMonitor_Hcal
34  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
35  subdir_.append("/");
36  subdir_=prefixME_+subdir_;
37 
38  validHtmlOutput_ = ps.getUntrackedParameter<bool>("Beam_validHtmlOutput",true);
39  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
40  // known hot/dead channels blacked out on plot
41  badChannelStatusMask_ = ps.getUntrackedParameter<int>("Beam_BadChannelStatusMask",
42  ps.getUntrackedParameter<int>("BadChannelStatusMask",
45  ));
46 
47  minerrorrate_ = ps.getUntrackedParameter<double>("Beam_minerrorrate",
48  ps.getUntrackedParameter<double>("minerrorrate",0.05));
49  minevents_ = ps.getUntrackedParameter<int>("Beam_minLS",1);
50  // minevents_ = ps.getUntrackedParameter<int>("Beam_minevents",
51  // ps.getUntrackedParameter<int>("minevents",1));
52  Online_ = ps.getUntrackedParameter<bool>("online",false);
53 
54  ProblemCells=0;
56 }
57 
59 {
60  if (debug_>2) std::cout <<"\tHcalBeamClient::analyze()"<<std::endl;
61  enoughevents_=false;
63 }
64 
66 {
67  if (debug_>2) std::cout <<"\t\tHcalBeamClient::calculateProblems()"<<std::endl;
68  if(!dqmStore_) return;
69  double totalLumiBlocks=0;
70  // reminder:: lumi histograms work a bit differently, counting total number of lumi blocks, not total number of events
71  int etabins=0, phibins=0, zside=0;
72  double problemvalue=0;
73 
74  // Clear away old problems
75  if (ProblemCells!=0)
76  {
78  (ProblemCells->getTH2F())->SetMaximum(1.05);
79  (ProblemCells->getTH2F())->SetMinimum(0.);
80  }
81  for (unsigned int d=0;ProblemCellsByDepth!=0 && d<ProblemCellsByDepth->depth.size();++d)
82  {
83  if (ProblemCellsByDepth->depth[d]!=0)
84  {
85  ProblemCellsByDepth->depth[d]->Reset();
86  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMaximum(1.05);
87  (ProblemCellsByDepth->depth[d]->getTH2F())->SetMinimum(0.);
88  }
89  }
90 
91  // Get histograms that are used in testing
92  // currently none used,
93 
94  // get the dead and hot cell lumi histograms
95  TH2F* dead = 0;
96  TH2F* hot = 0;
97  MonitorElement* me;
98  me=dqmStore_->get(subdir_+"Lumi/HFlumi_total_deadcells");
99  if (me!=0)
100  dead=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,dead,debug_);
101  else if (debug_>0) std::cout <<" <HcalBeamClient::calculateProblems> Unable to get dead cell plot 'HFlumi_total_deadcells"<<std::endl;
102  me=dqmStore_->get(subdir_+"Lumi/HFlumi_total_hotcells");
103  if (me!=0)
104  hot=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_,dead,debug_);
105  else if (debug_>0) std::cout <<" <HcalBeamClient::calculateProblems> Unable to get hot cell plot 'HFlumi_total_hotcells"<<std::endl;
106  int myieta=0;
107  int mydepth=0;
108  int myiphi=0;
109 
110  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
111 
112  if (dead!=0 || hot!=0)
113  {
114  if (dead!=0)
115  {
116  totalLumiBlocks=dead->GetBinContent(-1,-1);
117  etabins=dead->GetNbinsX();
118  phibins=dead->GetNbinsY();
119  }
120  else
121  {
122  totalLumiBlocks=hot->GetBinContent(-1,-1);
123  etabins=hot->GetNbinsX();
124  phibins=hot->GetNbinsY();
125  }
126  if (totalLumiBlocks<minevents_ || totalLumiBlocks==0)
127  return;
128  for (int i=0;i<etabins;++i)
129  {
130  i<=3 ? myieta = i-36 : myieta=i+29; // separate HFM, HFP
131  if (abs(myieta)==33 || abs(myieta)==34)
132  mydepth=1;
133  else if (abs(myieta)==35 || abs(myieta)==36)
134  mydepth=2;
135  for (int j=0;j<phibins;++j)
136  {
137  problemvalue=0;
138  myiphi=2*j+1; // lumi HF histograms only have 36 bins
139  if (dead!=0 && dead->GetBinContent(i+1,j+1)*1./totalLumiBlocks>minerrorrate_)
140  {
141  problemvalue+=dead->GetBinContent(i+1,j+1)*1./totalLumiBlocks;
142  if (debug_>1) std::cout <<"<HcalBeamClient::calculateProblem> Dead cell found at ieta = "<<myieta<<" iphi = "<<myiphi<<" depth = "<<mydepth<<std::endl;
143  }
144  if (hot!=0 && hot->GetBinContent(i+1,j+1)*1./totalLumiBlocks>minerrorrate_)
145  {
146  problemvalue+=hot->GetBinContent(i+1,j+1)*1./totalLumiBlocks;
147  if (debug_>1) std::cout <<"<HcalBeamClient::calculateProblem> hot cell found at ieta = "<<myieta<<" iphi = "<<myiphi<<" depth = "<<mydepth<<std::endl;
148  }
149  if (problemvalue==0) continue;
150 
151  // Search for known bad problems in channel status db
152  HcalDetId hcalid(HcalForward, myieta, myiphi, mydepth);
153  if (badstatusmap.find(hcalid)!=badstatusmap.end())
154  problemvalue=999;
155  myieta<0 ? zside=-1 : zside=1;
156  ProblemCellsByDepth->depth[mydepth-1]->Fill(myieta+zside,myiphi,problemvalue);
157  if (ProblemCells!=0) ProblemCells->Fill(myieta+zside,myiphi,problemvalue);
158  }
159  }
160  }
161 
162 
163  if (ProblemCells==0)
164  {
165  if (debug_>0) std::cout <<"<HcalBeamClient::analyze> ProblemCells histogram does not exist!"<<std::endl;
166  return;
167  }
168 
169  // Normalization of ProblemCell plot, in the case where there are errors in multiple depths
170  etabins=(ProblemCells->getTH2F())->GetNbinsX();
171  phibins=(ProblemCells->getTH2F())->GetNbinsY();
172  for (int eta=0;eta<etabins;++eta)
173  {
174  for (int phi=0;phi<phibins;++phi)
175  {
178  }
179  }
182  return;
183 }
184 
186 {
188  if (debug_>0)
189  {
190  std::cout <<"<HcalBeamClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
192  }
193 }
195 
197 {
198  enoughevents_=false;
199  if (!dqmStore_)
200  {
201  if (debug_>0) std::cout <<"<HcalBeamClient::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  if (ProblemCells==0)
209  ProblemCells=dqmStore_->book2D(" Problem BeamMonitor",
210  " Problem Beam Monitor Rate for all HCAL;ieta;iphi",
211  85,-42.5,42.5,
212  72,0.5,72.5);
213  problemnames_.push_back(ProblemCells->getName());
214  if (debug_>1)
215  std::cout << "Tried to create ProblemCells Monitor Element in directory "<<subdir_<<" \t Failed? "<<(ProblemCells==0)<<std::endl;
216  dqmStore_->setCurrentFolder(subdir_+"problem_beammonitor");
217  nevts_=0;
218  if (ProblemCellsByDepth!=0) return; // histograms already set up
220  ProblemCellsByDepth->setup(dqmStore_," Problem BeamMonitor Rate");
221  for (unsigned int i=0; i<ProblemCellsByDepth->depth.size();++i)
222  problemnames_.push_back(ProblemCellsByDepth->depth[i]->getName());
223 }
224 
226 
229 
231 {
232  if (!ProblemCells)
233  {
234  if (debug_>1) std::cout <<"<HcalBeamClient::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 
263 bool HcalBeamClient::hasWarnings_Temp(void){return false;}
264 bool HcalBeamClient::hasOther_Temp(void){return false;}
265 bool HcalBeamClient::test_enabled(void){return true;}
266 
267 
268 void HcalBeamClient::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 HcalBeamClient::updateChannelStatus
275 
277 {}
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="")
#define abs(x)
Definition: mlp_lapack.h:159
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
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:1468
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:2761
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:845
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:429
Definition: DDAxes.h:10