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 
51  private:
52  virtual void beginJob() override ;
53  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
54  virtual void endJob() override ;
55  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override ;
56  virtual void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override ;
57  void endRun(const edm::Run & r, const edm::EventSetup & c) override;
58  void CertifyHcal();
59 
60  // ----------member data ---------------------------
61 
73  int debug_;
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");
95 }
96 
98 {
99  // do anything here that needs to be done at desctruction time
100  // (e.g. close files, deallocate resources etc.)
101 }
102 
103 //
104 // member functions
105 //
106 
107 // ------------ method called to for each event ------------
108 void
110 
111 // ------------ method called once each job just before starting event loop ------------
112 void
114 {
115  if (debug_>0) std::cout<<"<HcalDataCertification> beginJob"<< std::endl;
116 
118  std::string currDir = dbe_->pwd();
119  if (debug_>0) std::cout << "--- Current Directory " << currDir << std::endl;
120  std::vector<MonitorElement*> mes = dbe_->getAllContents("");
121  if (debug_>0) std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
122 
123  dbe_->setCurrentFolder(rootFolder_+"/EventInfo/");
124 
125  CertificationSummary = dbe_->bookFloat("CertificationSummary");
126 
127  CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","HcalCertificationSummaryMap",7,0.,7.,1,0.,1.);
136  CertificationSummaryMap->setBinLabel(1,"Status",2);
137 
138  dbe_->setCurrentFolder(rootFolder_+"/EventInfo/CertificationContents/");
139  Hcal_HB = dbe_->bookFloat("Hcal_HB");
140  Hcal_HE = dbe_->bookFloat("Hcal_HE");
141  Hcal_HF = dbe_->bookFloat("Hcal_HF");
142  Hcal_HO = dbe_->bookFloat("Hcal_HO");
143  Hcal_HFlumi = dbe_->bookFloat("Hcal_HFlumi");
144  Hcal_HO0 = dbe_->bookFloat("Hcal_HO0");
145  Hcal_HO12 = dbe_->bookFloat("Hcal_HO12");
146 
147 }
148 
149 // ------------ method called once each job just after ending the event loop ------------
150 void
152 {
153  if (debug_>0) std::cout << "<HcalDataCertification> endJob " << std::endl;
154 }
155 
156 // ------------ method called just before starting a new run ------------
157 void
159 {
160  if (debug_>0) std::cout<<"<HcalDataCertification> beginLuminosityBlock"<<std::endl;
161 }
162 
163 // ------------ method called right after a run ends ------------
164 void
166 {
167  CertifyHcal();
168 }
169 
171 {
172  CertifyHcal();
173 }
174 
176 {
177 
178  float hcalFrac,reportFrac,dcsFrac,daqFrac;
179  float fracHCAL[7][3];
180  float certHcal[7];
181 
182  if (debug_>0) {
184  std::string currDir = dbe_->pwd();
185  std::cout << "<HcalDataCertification::endLuminosityBlock> --- Current Directory " << currDir << std::endl;
186  std::vector<MonitorElement*> mes = dbe_->getAllContents("");
187  std::cout << "found " << mes.size() << " monitoring elements:" << std::endl;
188  }
189 
190  if (dbe_->get(rootFolder_+"/EventInfo/DCSSummary")) {
191  dcsFrac = (dbe_->get(rootFolder_+"/EventInfo/DCSSummary"))->getFloatValue();
192  }
193  else dcsFrac = -1;
194 
195  if (dbe_->get(rootFolder_+"/EventInfo/DAQSummary")) {
196  daqFrac = (dbe_->get(rootFolder_+"/EventInfo/DAQSummary"))->getFloatValue();
197  }
198  else daqFrac = -1;
199 
200  if (dbe_->get(rootFolder_+"/EventInfo/reportSummary")) {
201  reportFrac = (dbe_->get(rootFolder_+"/EventInfo/reportSummary"))->getFloatValue();
202  }
203  else reportFrac = -1;
204 
205  hcalFrac = 99.;
206  hcalFrac = TMath::Min(hcalFrac,reportFrac);
207  hcalFrac = TMath::Min(hcalFrac,daqFrac);
208  hcalFrac = TMath::Min(hcalFrac,dcsFrac);
209  if (debug_>0) {
210  std::cout<<"dcsFrac= "<<dcsFrac<<std::endl;
211  std::cout<<"daqFrac= "<<daqFrac<<std::endl;
212  std::cout<<"reportFrac= "<<reportFrac<<std::endl;
213  std::cout<<"CertificationSummary= "<<hcalFrac<<std::endl;
214  }
215 
216  // reportSummary
217 
218  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB")) {
219  fracHCAL[0][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HB"))->getFloatValue();
220  }
221  else fracHCAL[0][0] = -1;
222 
223  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE")) {
224  fracHCAL[1][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HE"))->getFloatValue();
225  }
226  else fracHCAL[1][0] = -1;
227 
228  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO")) {
229  fracHCAL[2][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO"))->getFloatValue();
230  }
231  else fracHCAL[2][0] = -1;
232 
233  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF")) {
234  fracHCAL[3][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HF"))->getFloatValue();
235  }
236  else fracHCAL[3][0] = -1;
237 
238  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0")) {
239  fracHCAL[4][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO0"))->getFloatValue();
240  }
241  else fracHCAL[4][0] = -1;
242 
243  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12")) {
244  fracHCAL[5][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HO12"))->getFloatValue();
245  }
246  else fracHCAL[5][0] = -1;
247 
248 
249  if (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi")) {
250  fracHCAL[6][0] = (dbe_->get(rootFolder_+"/EventInfo/reportSummaryContents/Hcal_HFlumi"))->getFloatValue();
251  }
252  else fracHCAL[6][0] = -1;
253 
254  // DAQ
255 
256  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB")) {
257  fracHCAL[0][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HB"))->getFloatValue();
258  }
259  else fracHCAL[0][1] = -1;
260 
261  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE")) {
262  fracHCAL[1][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HE"))->getFloatValue();
263  }
264  else fracHCAL[1][1] = -1;
265 
266  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO")) {
267  fracHCAL[2][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO"))->getFloatValue();
268  }
269  else fracHCAL[2][1] = -1;
270 
271  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF")) {
272  fracHCAL[3][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HF"))->getFloatValue();
273  }
274  else fracHCAL[3][1] = -1;
275 
276  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0")) {
277  fracHCAL[4][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO0"))->getFloatValue();
278  }
279  else fracHCAL[4][1] = -1;
280 
281  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12")) {
282  fracHCAL[5][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HO12"))->getFloatValue();
283  }
284  else fracHCAL[5][1] = -1;
285 
286  if (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi")) {
287  fracHCAL[6][1] = (dbe_->get(rootFolder_+"/EventInfo/DAQContents/Hcal_HFlumi"))->getFloatValue();
288  }
289  else fracHCAL[6][1] = -1;
290 
291  // DCS
292 
293  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB")) {
294  fracHCAL[0][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HB"))->getFloatValue();
295  }
296  else fracHCAL[0][2] = -1;
297 
298  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE")) {
299  fracHCAL[1][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HE"))->getFloatValue();
300  }
301  else fracHCAL[1][2] = -1;
302 
303  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO")) {
304  fracHCAL[2][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO"))->getFloatValue();
305  }
306  else fracHCAL[2][2] = -1;
307 
308  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF")) {
309  fracHCAL[3][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HF"))->getFloatValue();
310  }
311  else fracHCAL[3][2] = -1;
312 
313  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0")) {
314  fracHCAL[4][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO0"))->getFloatValue();
315  }
316  else fracHCAL[4][2] = -1;
317 
318  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12")) {
319  fracHCAL[5][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HO12"))->getFloatValue();
320  }
321  else fracHCAL[5][2] = -1;
322 
323 
324  if (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi")) {
325  fracHCAL[6][2] = (dbe_->get(rootFolder_+"/EventInfo/DCSContents/Hcal_HFlumi"))->getFloatValue();
326  }
327  else fracHCAL[6][2] = -1;
328 
329  for (int ii=0;ii<7;ii++) {
330  certHcal[ii] = 99.0;
331  for (int jj=0; jj<2;jj++) certHcal[ii] = TMath::Min(certHcal[ii],fracHCAL[ii][jj]);
332  CertificationSummaryMap->setBinContent(ii+1,1,certHcal[ii]);
333  if (debug_>0) std::cout<<"certFrac["<<ii<<"]= "<<certHcal[ii]<<std::endl;
334  }
335 
336  CertificationSummary->Fill(hcalFrac);
337  Hcal_HB->Fill(certHcal[0]);
338  Hcal_HE->Fill(certHcal[1]);
339  Hcal_HO->Fill(certHcal[2]);
340  Hcal_HF->Fill(certHcal[3]);
341  Hcal_HO0->Fill(certHcal[4]);
342  Hcal_HO12->Fill(certHcal[5]);
343  Hcal_HFlumi->Fill(certHcal[6]);
344 
345 // ---------------------- end of certification
346  if (debug_>0) std::cout << "<HcalDataCertification::MEfilled= " << std::endl;
347 
348 }
349 
350 //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)
#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)
int ii
Definition: cuy.py:588
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:879
void Fill(long long x)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1906
int iEvent
Definition: GenABIO.cc:230
MonitorElement * CertificationSummaryMap
virtual void beginJob() override
void endRun(const edm::Run &r, const edm::EventSetup &c) override
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1693
virtual void endJob() override
tuple cout
Definition: gather_cfg.py:121
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:1070
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41
const std::string & pwd(void) const
Definition: DQMStore.cc:627
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override