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 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <stdio.h>
22 #include <math.h>
23 #include <sstream>
24 #include <fstream>
25 #include <exception>
26 #include <string>
27 
28 // user include files
31 
35 
41 
42 //
43 // class declaration
44 //
45 
47  public:
50 
52  virtual void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig ) override;
53 
54  private:
56 
57  // helper method to book histograms
59 
60  // ----------member data ---------------------------
61 
72  int debug_;
74 
75 };
76 
77 //
78 // constants, enums and typedefs
79 //
80 
81 //
82 // static data member definitions
83 //
84 
85 //
86 // constructors and destructor
87 //
88 
90 {
91  // now do what ever initialization is needed
92  debug_ = iConfig.getUntrackedParameter<int>("debug",0);
93  rootFolder_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder","Hcal");
94 
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 once each job just before starting event loop ------------
109 void
111 {
112  if (debug_>0) std::cout<<"<HcalDataCertification> bookHistograms"<< std::endl;
113 
115  std::string currDir = ib.pwd();
116 
117  ib.setCurrentFolder(rootFolder_+"/EventInfo/");
118 
119  CertificationSummary = ib.bookFloat("CertificationSummary");
120 
121  CertificationSummaryMap = ib.book2D("CertificationSummaryMap","HcalCertificationSummaryMap",7,0.,7.,1,0.,1.);
130  CertificationSummaryMap->setBinLabel(1,"Status",2);
131 
132  ib.setCurrentFolder(rootFolder_+"/EventInfo/CertificationContents/");
133  Hcal_HB = ib.bookFloat("Hcal_HB");
134  Hcal_HE = ib.bookFloat("Hcal_HE");
135  Hcal_HF = ib.bookFloat("Hcal_HF");
136  Hcal_HO = ib.bookFloat("Hcal_HO");
137  Hcal_HFlumi = ib.bookFloat("Hcal_HFlumi");
138  Hcal_HO0 = ib.bookFloat("Hcal_HO0");
139  Hcal_HO12 = ib.bookFloat("Hcal_HO12");
140 
141 }
142 
143 
144 
145 // ------------ method called right after a run ends ------------
146 void
148 {
149  // check if MonitorElements exits
150  // book them if not
151  if ( !CertificationSummary ) {
152  bookHistograms(ib);
153  }
154  CertifyHcal(ib,ig);
155 }
156 
157 // this used to be endRun, after migration I make it dqmEndJob
159 {
160  // check if MonitorElements exits
161  // book them if not
162  if ( !CertificationSummary ) {
163  bookHistograms(ib);
164  }
165  CertifyHcal(ib,ig);
166 }
167 
169 {
170 
171  float hcalFrac,reportFrac,dcsFrac,daqFrac;
172  float fracHCAL[7][3];
173  float certHcal[7];
174 
175  if (debug_>0) {
177  std::string currDir = ib.pwd();
178  std::cout << "<HcalDataCertification::endLuminosityBlock> --- Current Directory " << currDir << std::endl;
179  }
180 
181  if (ig.get(rootFolder_+"/EventInfo/DCSSummary")) {
182  dcsFrac = (ig.get(rootFolder_+"/EventInfo/DCSSummary"))->getFloatValue();
183  }
184  else dcsFrac = -1;
185 
186  if (ig.get(rootFolder_+"/EventInfo/DAQSummary")) {
187  daqFrac = (ig.get(rootFolder_+"/EventInfo/DAQSummary"))->getFloatValue();
188  }
189  else daqFrac = -1;
190 
191  if (ig.get(rootFolder_+"/EventInfo/reportSummary")) {
192  reportFrac = (ig.get(rootFolder_+"/EventInfo/reportSummary"))->getFloatValue();
193  }
194  else reportFrac = -1;
195 
196  hcalFrac = 99.;
197  hcalFrac = TMath::Min(hcalFrac,reportFrac);
198  hcalFrac = TMath::Min(hcalFrac,daqFrac);
199  hcalFrac = TMath::Min(hcalFrac,dcsFrac);
200  if (debug_>0) {
201  std::cout<<"dcsFrac= "<<dcsFrac<<std::endl;
202  std::cout<<"daqFrac= "<<daqFrac<<std::endl;
203  std::cout<<"reportFrac= "<<reportFrac<<std::endl;
204  std::cout<<"CertificationSummary= "<<hcalFrac<<std::endl;
205  }
206 
207  // reportSummary
208 
209  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB")) {
210  fracHCAL[0][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB"))->getFloatValue();
211  }
212  else fracHCAL[0][0] = -1;
213 
214  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE")) {
215  fracHCAL[1][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE"))->getFloatValue();
216  }
217  else fracHCAL[1][0] = -1;
218 
219  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO")) {
220  fracHCAL[2][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO"))->getFloatValue();
221  }
222  else fracHCAL[2][0] = -1;
223 
224  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF")) {
225  fracHCAL[3][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF"))->getFloatValue();
226  }
227  else fracHCAL[3][0] = -1;
228 
229  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0")) {
230  fracHCAL[4][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0"))->getFloatValue();
231  }
232  else fracHCAL[4][0] = -1;
233 
234  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12")) {
235  fracHCAL[5][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12"))->getFloatValue();
236  }
237  else fracHCAL[5][0] = -1;
238 
239 
240  if (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi")) {
241  fracHCAL[6][0] = (ig.get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi"))->getFloatValue();
242  }
243  else fracHCAL[6][0] = -1;
244 
245  // DAQ
246 
247  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB")) {
248  fracHCAL[0][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB"))->getFloatValue();
249  }
250  else fracHCAL[0][1] = -1;
251 
252  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE")) {
253  fracHCAL[1][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE"))->getFloatValue();
254  }
255  else fracHCAL[1][1] = -1;
256 
257  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO")) {
258  fracHCAL[2][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO"))->getFloatValue();
259  }
260  else fracHCAL[2][1] = -1;
261 
262  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF")) {
263  fracHCAL[3][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF"))->getFloatValue();
264  }
265  else fracHCAL[3][1] = -1;
266 
267  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0")) {
268  fracHCAL[4][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0"))->getFloatValue();
269  }
270  else fracHCAL[4][1] = -1;
271 
272  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12")) {
273  fracHCAL[5][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12"))->getFloatValue();
274  }
275  else fracHCAL[5][1] = -1;
276 
277  if (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi")) {
278  fracHCAL[6][1] = (ig.get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi"))->getFloatValue();
279  }
280  else fracHCAL[6][1] = -1;
281 
282  // DCS
283 
284  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB")) {
285  fracHCAL[0][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB"))->getFloatValue();
286  }
287  else fracHCAL[0][2] = -1;
288 
289  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE")) {
290  fracHCAL[1][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE"))->getFloatValue();
291  }
292  else fracHCAL[1][2] = -1;
293 
294  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO")) {
295  fracHCAL[2][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO"))->getFloatValue();
296  }
297  else fracHCAL[2][2] = -1;
298 
299  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF")) {
300  fracHCAL[3][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF"))->getFloatValue();
301  }
302  else fracHCAL[3][2] = -1;
303 
304  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0")) {
305  fracHCAL[4][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0"))->getFloatValue();
306  }
307  else fracHCAL[4][2] = -1;
308 
309  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12")) {
310  fracHCAL[5][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12"))->getFloatValue();
311  }
312  else fracHCAL[5][2] = -1;
313 
314 
315  if (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi")) {
316  fracHCAL[6][2] = (ig.get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi"))->getFloatValue();
317  }
318  else fracHCAL[6][2] = -1;
319 
320  for (int ii=0;ii<7;ii++) {
321  certHcal[ii] = 99.0;
322  for (int jj=0; jj<2;jj++) certHcal[ii] = TMath::Min(certHcal[ii],fracHCAL[ii][jj]);
323  CertificationSummaryMap->setBinContent(ii+1,1,certHcal[ii]);
324  if (debug_>0) std::cout<<"certFrac["<<ii<<"]= "<<certHcal[ii]<<std::endl;
325  }
326 
327  CertificationSummary->Fill(hcalFrac);
328  Hcal_HB->Fill(certHcal[0]);
329  Hcal_HE->Fill(certHcal[1]);
330  Hcal_HO->Fill(certHcal[2]);
331  Hcal_HF->Fill(certHcal[3]);
332  Hcal_HO0->Fill(certHcal[4]);
333  Hcal_HO12->Fill(certHcal[5]);
334  Hcal_HFlumi->Fill(certHcal[6]);
335 
336 // ---------------------- end of certification
337  if (debug_>0) std::cout << "<HcalDataCertification::MEfilled= " << std::endl;
338 
339 }
340 
341 //define this as a plug-in
HcalDataCertification(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
void bookHistograms(DQMStore::IBooker &)
void setBinContent(int binx, double content)
set content of bin (1-D)
int ib
Definition: cuy.py:660
virtual void dqmEndLuminosityBlock(DQMStore::IBooker &ib, DQMStore::IGetter &ig, const edm::LuminosityBlock &, const edm::EventSetup &) override
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const std::string & pwd(void)
Definition: DQMStore.cc:282
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)
#define NULL
Definition: scimark2.h:8
T Min(T a, T b)
Definition: MathUtil.h:39
int ii
Definition: cuy.py:588
virtual void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) override
void Fill(long long x)
MonitorElement * CertificationSummaryMap
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:330
tuple cout
Definition: gather_cfg.py:121
void CertifyHcal(DQMStore::IBooker &, DQMStore::IGetter &)
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109