CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDataCertification.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DQMO/HcalMonitorClient/HcalDataCertification
4 // Class: HcalDataCertification
5 //
13 //
14 // Original Author: "Igor Vodopiyanov"
15 // Created: Nov-21 2008
16 // $Id: HcalDataCertification.cc,v 1.12 2010/03/25 16:55:40 temple Exp $
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 #include <stdio.h>
23 #include <math.h>
24 #include <sstream>
25 #include <fstream>
26 #include <exception>
27 #include <string>
28 
29 // user include files
32 
36 
42 
43 //
44 // class declaration
45 //
46 
48  public:
51 
52  private:
53  virtual void beginJob() ;
54  virtual void analyze(const edm::Event&, const edm::EventSetup&);
55  virtual void endJob() ;
56  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) ;
57  virtual void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) ;
58  void endRun(const edm::Run & r, const edm::EventSetup & c);
59  void CertifyHcal();
60 
61  // ----------member data ---------------------------
62 
74  int debug_;
75  std::string rootFolder_;
76 };
77 
78 //
79 // constants, enums and typedefs
80 //
81 
82 //
83 // static data member definitions
84 //
85 
86 //
87 // constructors and destructor
88 //
89 
91 {
92  // now do what ever initialization is needed
93  debug_ = iConfig.getUntrackedParameter<int>("debug",0);
94  rootFolder_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder","Hcal");
96 }
97 
99 {
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 }
103 
104 //
105 // member functions
106 //
107 
108 // ------------ method called to for each event ------------
109 void
111 
112 // ------------ method called once each job just before starting event loop ------------
113 void
115 {
116  if (debug_>0) std::cout<<"<HcalDataCertification> beginJob"<< std::endl;
117 
119  std::string currDir = dbe_->pwd();
120  if (debug_>0) std::cout << "--- Current Directory " << currDir << std::endl;
121  std::vector<MonitorElement*> mes = dbe_->getAllContents("");
122  if (debug_>0) std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
123 
124  dbe_->setCurrentFolder(rootFolder_+"/EventInfo/");
125 
126  CertificationSummary = dbe_->bookFloat("CertificationSummary");
127 
128  CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","HcalCertificationSummaryMap",7,0.,7.,1,0.,1.);
137  CertificationSummaryMap->setBinLabel(1,"Status",2);
138 
139  dbe_->setCurrentFolder(rootFolder_+"/EventInfo/CertificationContents/");
140  Hcal_HB = dbe_->bookFloat("Hcal_HB");
141  Hcal_HE = dbe_->bookFloat("Hcal_HE");
142  Hcal_HF = dbe_->bookFloat("Hcal_HF");
143  Hcal_HO = dbe_->bookFloat("Hcal_HO");
144  Hcal_HFlumi = dbe_->bookFloat("Hcal_HFlumi");
145  Hcal_HO0 = dbe_->bookFloat("Hcal_HO0");
146  Hcal_HO12 = dbe_->bookFloat("Hcal_HO12");
147 
148 }
149 
150 // ------------ method called once each job just after ending the event loop ------------
151 void
153 {
154  if (debug_>0) std::cout << "<HcalDataCertification> endJob " << std::endl;
155 }
156 
157 // ------------ method called just before starting a new run ------------
158 void
160 {
161  if (debug_>0) std::cout<<"<HcalDataCertification> beginLuminosityBlock"<<std::endl;
162 }
163 
164 // ------------ method called right after a run ends ------------
165 void
167 {
168  CertifyHcal();
169 }
170 
172 {
173  CertifyHcal();
174 }
175 
177 {
178 
179  float hcalFrac,reportFrac,dcsFrac,daqFrac;
180  float fracHCAL[7][3];
181  float certHcal[7];
182 
183  if (debug_>0) {
185  std::string currDir = dbe_->pwd();
186  std::cout << "<HcalDataCertification::endLuminosityBlock> --- Current Directory " << currDir << std::endl;
187  std::vector<MonitorElement*> mes = dbe_->getAllContents("");
188  std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
189  }
190 
191  if (dbe_->get(rootFolder_+"/EventInfo/DCSSummary")) {
192  dcsFrac = (dbe_->get(rootFolder_+"/EventInfo/DCSSummary"))->getFloatValue();
193  }
194  else dcsFrac = -1;
195 
196  if (dbe_->get(rootFolder_+"/EventInfo/DAQSummary")) {
197  daqFrac = (dbe_->get(rootFolder_+"/EventInfo/DAQSummary"))->getFloatValue();
198  }
199  else daqFrac = -1;
200 
201  if (dbe_->get(rootFolder_+"/EventInfo/reportSummary")) {
202  reportFrac = (dbe_->get(rootFolder_+"/EventInfo/reportSummary"))->getFloatValue();
203  }
204  else reportFrac = -1;
205 
206  hcalFrac = 99.;
207  hcalFrac = TMath::Min(hcalFrac,reportFrac);
208  hcalFrac = TMath::Min(hcalFrac,daqFrac);
209  hcalFrac = TMath::Min(hcalFrac,dcsFrac);
210  if (debug_>0) {
211  std::cout<<"dcsFrac= "<<dcsFrac<<std::endl;
212  std::cout<<"daqFrac= "<<daqFrac<<std::endl;
213  std::cout<<"reportFrac= "<<reportFrac<<std::endl;
214  std::cout<<"CertificationSummary= "<<hcalFrac<<std::endl;
215  }
216 
217  // reportSummary
218 
219  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB")) {
220  fracHCAL[0][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB"))->getFloatValue();
221  }
222  else fracHCAL[0][0] = -1;
223 
224  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE")) {
225  fracHCAL[1][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE"))->getFloatValue();
226  }
227  else fracHCAL[1][0] = -1;
228 
229  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO")) {
230  fracHCAL[2][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO"))->getFloatValue();
231  }
232  else fracHCAL[2][0] = -1;
233 
234  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF")) {
235  fracHCAL[3][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF"))->getFloatValue();
236  }
237  else fracHCAL[3][0] = -1;
238 
239  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0")) {
240  fracHCAL[4][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0"))->getFloatValue();
241  }
242  else fracHCAL[4][0] = -1;
243 
244  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12")) {
245  fracHCAL[5][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12"))->getFloatValue();
246  }
247  else fracHCAL[5][0] = -1;
248 
249 
250  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi")) {
251  fracHCAL[6][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi"))->getFloatValue();
252  }
253  else fracHCAL[6][0] = -1;
254 
255  // DAQ
256 
257  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB")) {
258  fracHCAL[0][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB"))->getFloatValue();
259  }
260  else fracHCAL[0][1] = -1;
261 
262  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE")) {
263  fracHCAL[1][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE"))->getFloatValue();
264  }
265  else fracHCAL[1][1] = -1;
266 
267  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO")) {
268  fracHCAL[2][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO"))->getFloatValue();
269  }
270  else fracHCAL[2][1] = -1;
271 
272  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF")) {
273  fracHCAL[3][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF"))->getFloatValue();
274  }
275  else fracHCAL[3][1] = -1;
276 
277  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0")) {
278  fracHCAL[4][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0"))->getFloatValue();
279  }
280  else fracHCAL[4][1] = -1;
281 
282  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12")) {
283  fracHCAL[5][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12"))->getFloatValue();
284  }
285  else fracHCAL[5][1] = -1;
286 
287  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi")) {
288  fracHCAL[6][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi"))->getFloatValue();
289  }
290  else fracHCAL[6][1] = -1;
291 
292  // DCS
293 
294  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB")) {
295  fracHCAL[0][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB"))->getFloatValue();
296  }
297  else fracHCAL[0][2] = -1;
298 
299  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE")) {
300  fracHCAL[1][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE"))->getFloatValue();
301  }
302  else fracHCAL[1][2] = -1;
303 
304  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO")) {
305  fracHCAL[2][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO"))->getFloatValue();
306  }
307  else fracHCAL[2][2] = -1;
308 
309  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF")) {
310  fracHCAL[3][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF"))->getFloatValue();
311  }
312  else fracHCAL[3][2] = -1;
313 
314  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0")) {
315  fracHCAL[4][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0"))->getFloatValue();
316  }
317  else fracHCAL[4][2] = -1;
318 
319  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12")) {
320  fracHCAL[5][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12"))->getFloatValue();
321  }
322  else fracHCAL[5][2] = -1;
323 
324 
325  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi")) {
326  fracHCAL[6][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi"))->getFloatValue();
327  }
328  else fracHCAL[6][2] = -1;
329 
330  for (int ii=0;ii<7;ii++) {
331  certHcal[ii] = 99.0;
332  for (int jj=0; jj<2;jj++) certHcal[ii] = TMath::Min(certHcal[ii],fracHCAL[ii][jj]);
333  CertificationSummaryMap->setBinContent(ii+1,1,certHcal[ii]);
334  if (debug_>0) std::cout<<"certFrac["<<ii<<"]= "<<certHcal[ii]<<std::endl;
335  }
336 
337  CertificationSummary->Fill(hcalFrac);
338  Hcal_HB->Fill(certHcal[0]);
339  Hcal_HE->Fill(certHcal[1]);
340  Hcal_HO->Fill(certHcal[2]);
341  Hcal_HF->Fill(certHcal[3]);
342  Hcal_HO0->Fill(certHcal[4]);
343  Hcal_HO12->Fill(certHcal[5]);
344  Hcal_HFlumi->Fill(certHcal[6]);
345 
346 // ---------------------- end of certification
347  if (debug_>0) std::cout << "<HcalDataCertification::MEfilled= " << std::endl;
348 
349 }
350 
351 //define this as a plug-in
HcalDataCertification(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
void endRun(const edm::Run &r, const edm::EventSetup &c)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * CertificationSummary
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:456
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1474
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:243
MonitorElement * CertificationSummaryMap
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
tuple cout
Definition: gather_cfg.py:41
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:647
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31
const std::string & pwd(void) const
Definition: DQMStore.cc:209