CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EETrendClient.cc
Go to the documentation of this file.
1 /*
2  * \file EETrendClient.cc
3  *
4  * \author Dongwook Jang, Soon Yung Jun
5  *
6 */
7 
8 #include <iostream>
9 #include <fstream>
10 #include <math.h>
11 
14 
17 
21 
23 
24  init_ = false;
25 
27 
28  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
29 
30  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
31 
32  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
33 
34  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
35 
36  // histograms...
37  for(int i=0; i<nHists_; i++) {
38  meanMinutely_[i] = 0;
39  sigmaMinutely_[i] = 0;
40 
41  meanHourly_[i] = 0;
42  sigmaHourly_[i] = 0;
43 
44  previousHist_[i] = 0;
45  currentHist_[i] = 0;
46  } // for
47 
48 }
49 
50 
52 }
53 
54 
56 
57  ievt_ = 0;
58 
59  if ( dqmStore_ ) {
60  dqmStore_->setCurrentFolder(prefixME_ + "/EETrendClient");
61  dqmStore_->rmdir(prefixME_ + "/EETrendClient");
62  }
63 
64  // noise,
65  // entries of EBOT rec hit thr occupancy
66  // entries of EBOT tp digi occupancy
67  // rec hit energy
68  // ebtmt timing mean ID summary
69  // ebtmt timing RMS ID summary
70  //
71 
72  int index = 0;
73 
74  moduleNames_[index] = "EEClusterTask"; // TH1
75  histTitles_[index] = "EECLT BC energy";
76  index++;
77 
78  moduleNames_[index] = "EEClusterTask"; // TH1
79  histTitles_[index] = "EECLT SC energy";
80  index++;
81 
82  moduleNames_[index] = "EESummaryClient"; // TProfile
83  histTitles_[index] = "EEPOT pedestal G12 mean";
84  index++;
85 
86  moduleNames_[index] = "EESummaryClient"; // TProfile
87  histTitles_[index] = "EEPOT pedestal G12 rms";
88  index++;
89 
90  moduleNames_[index] = "EEOccupancyTask"; // TH2
91  histTitles_[index] = "EEOT rec hit thr occupancy EE -";
92  index++;
93 
94  moduleNames_[index] = "EEOccupancyTask"; // TH2
95  histTitles_[index] = "EEOT rec hit thr occupancy EE +";
96  index++;
97 
98  moduleNames_[index] = "EEOccupancyTask"; // TH2
99  histTitles_[index] = "EEOT TP digi thr occupancy EE -";
100  index++;
101 
102  moduleNames_[index] = "EEOccupancyTask"; // TH2
103  histTitles_[index] = "EEOT TP digi thr occupancy EE +";
104  index++;
105 
106 }
107 
108 
110 
111  if ( ! mergeRuns_ ) this->reset();
112 
113  start_time_ = time(NULL);
114 
115 }
116 
117 
119 
120 }
121 
122 
124 
125  for(int i=0; i<nHists_; i++) {
128 
129  if(meanHourly_[i]) meanHourly_[i]->Reset();
130  if(sigmaHourly_[i]) sigmaHourly_[i]->Reset();
131  }// for
132 
133 }
134 
135 
137 
138  init_ = true;
139 
141 
142  if ( dqmStore_ ) {
143  dqmStore_->setCurrentFolder(prefixME_ + "/EETrendClient");
144 
145  for(int i=0; i<nHists_; i++) {
146 
147  // minutely
148 
149  histo = "Average of " + histTitles_[i] + " Vs 5Minutes";
150  meanMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
151  meanMinutely_[i]->setAxisTitle("Minutes", 1);
152  histo = "Average of " + histTitles_[i] + " / 5 minutes";
153  meanMinutely_[i]->setAxisTitle(histo.c_str(), 2);
154 
155  histo = "RMS of " + histTitles_[i] + " Vs 5Minutes";
156  sigmaMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
157  sigmaMinutely_[i]->setAxisTitle("Minutes", 1);
158  histo = "RMS of " + histTitles_[i] + " / 5 minutes";
159  sigmaMinutely_[i]->setAxisTitle(histo.c_str(), 2);
160 
161 
162  // hourly
163 
164  histo = "Average of " + histTitles_[i] + " Vs 1Hour";
165  meanHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
166  meanHourly_[i]->setAxisTitle("Hours", 1);
167  histo = "Average of " + histTitles_[i] + " / hour";
168  meanHourly_[i]->setAxisTitle(histo.c_str(), 2);
169 
170  histo = "RMS of " + histTitles_[i] + " Vs 1Hour";
171  sigmaHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
172  sigmaHourly_[i]->setAxisTitle("Hours", 1);
173  histo = "RMS of " + histTitles_[i] + " / hour";
174  sigmaHourly_[i]->setAxisTitle(histo.c_str(), 2);
175 
176  }// for i
177 
178  }// if
179 
180 }
181 
182 
184 
185  if ( ! init_ ) return;
186 
187  if ( dqmStore_ ) {
188  dqmStore_->setCurrentFolder(prefixME_ + "/EETrendClient");
189 
190  for(int i=0; i<nHists_; i++) {
191  if(meanMinutely_[i]) dqmStore_->removeElement( meanMinutely_[i]->getName());
192  meanMinutely_[i] = 0;
193  if(sigmaMinutely_[i]) dqmStore_->removeElement( sigmaMinutely_[i]->getName());
194  sigmaMinutely_[i] = 0;
195 
196  if(meanHourly_[i]) dqmStore_->removeElement( meanHourly_[i]->getName());
197  meanHourly_[i] = 0;
198  if(sigmaHourly_[i]) dqmStore_->removeElement( sigmaHourly_[i]->getName());
199  sigmaHourly_[i] = 0;
200 
201  if(previousHist_[i]) delete previousHist_[i];
202  previousHist_[i] = 0;
203  if(currentHist_[i]) delete currentHist_[i];
204  currentHist_[i] = 0;
205 
206  }// for
207 
208  }
209 
210  init_ = false;
211 
212 }
213 
214 
216 
217  edm::LogInfo("EETrendClient") << "analyzed " << ievt_ << " events";
218 
219  if ( enableCleanup_ ) this->cleanup();
220 
221 }
222 
223 
225 
226  if ( ! init_ ) this->setup();
227 
228  ievt_++;
229 
230  // --------------------------------------------------
231  // Collect time information
232  // --------------------------------------------------
233 
234  updateTime();
235 
236  // long int diff_time = (current_time_ - start_time_)/60;
237 
238  long int minuteBinDiff = -1;
239  long int minuteDiff = -1;
240  // ecaldqm::calcBins(5,1,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
241  ecaldqm::calcBins(5,60,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
242 
243  if(minuteBinDiff <= 0) return;
244 
245  long int hourBinDiff = -1;
246  long int hourDiff = -1;
247  ecaldqm::calcBins(1,3600,start_time_,last_time_,current_time_,hourBinDiff,hourDiff);
248 
249 
250  for(int i=0; i<nHists_; i++){
251 
252  mean_[i] = rms_[i] = 0;
253 
254  // delete previous hists if any
255  if(previousHist_[i]) delete previousHist_[i];
256 
257  // assign currentHists to previousHists
259 
260  } // for i
261 
262 
264 
265  MonitorElement* me;
266 
267  // get clones of histograms from other tasks or clients
268  // assign cloned histogrmas to currentHist_[i]
269 
270  for(int i=0; i<nHists_; i++) {
271  histo = prefixME_ + "/" + moduleNames_[i] + "/" + histTitles_[i];
272  me = dqmStore_->get(histo.c_str());
273  currentHist_[i] = ecaldqm::cloneIt(me,histo);
274  }
275 
276 
277  // Get mean and rms and fill Profile
278 
279  for(int i=0; i<nHists_; i++){
280 
282 
283  if(verbose_) {
284  std::cout << std::scientific;
285  std::cout << "EETrendClient mean["<<i<<"] = " << mean_[i] << ", \t rms["<<i<<"] = " << rms_[i] << std::endl;
286  }
287 
288  ecaldqm::shift2Right(meanMinutely_[i]->getTProfile(), minuteBinDiff);
289  meanMinutely_[i]->Fill(minuteDiff,mean_[i]);
290 
291  ecaldqm::shift2Right(sigmaMinutely_[i]->getTProfile(), minuteBinDiff);
292  sigmaMinutely_[i]->Fill(minuteDiff,rms_[i]);
293 
294  ecaldqm::shift2Right(meanHourly_[i]->getTProfile(), hourBinDiff);
295  meanHourly_[i]->Fill(hourDiff,mean_[i]);
296 
297  ecaldqm::shift2Right(sigmaHourly_[i]->getTProfile(), hourBinDiff);
298  sigmaHourly_[i]->Fill(hourDiff,rms_[i]);
299  } // for i
300 
301 
302 }
303 
304 
306 
309 
310 }
311 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void endRun(const edm::Run &r, const edm::EventSetup &c)
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
void endJob(void)
void updateTime(void)
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
void beginRun(const edm::Run &r, const edm::EventSetup &c)
double mean_[nHists_]
Definition: EETrendClient.h:94
void setup(void)
#define NULL
Definition: scimark2.h:8
TObject * previousHist_[nHists_]
Definition: EETrendClient.h:97
DQMStore * dqmStore_
Definition: EETrendClient.h:69
void analyze(const edm::Event &e, const edm::EventSetup &c)
void beginJob(void)
void cleanup(void)
void Fill(long long x)
MonitorElement * sigmaHourly_[nHists_]
Definition: EETrendClient.h:83
std::string moduleNames_[nHists_]
Definition: EETrendClient.h:91
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
EETrendClient(const edm::ParameterSet &ps)
MonitorElement * meanMinutely_[nHists_]
Definition: EETrendClient.h:79
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1186
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
Ecal Monitor Utils for Client.
Ecal Monitor Utility functions.
TObject * currentHist_[nHists_]
Definition: EETrendClient.h:98
void reset(void)
const int nHists_
Definition: EBTrendClient.h:23
virtual ~EETrendClient()
TObject * cloneIt(MonitorElement *me, std::string histo)
MonitorElement * meanHourly_[nHists_]
Definition: EETrendClient.h:82
double rms_[nHists_]
Definition: EETrendClient.h:95
tuple cout
Definition: gather_cfg.py:121
void calcBins(int binWidth, int divisor, long int start_time, long int last_time, long int current_time, long int &binDiff, long int &diff)
MonitorElement * sigmaMinutely_[nHists_]
Definition: EETrendClient.h:80
void shift2Right(TH1 *h, int bins)
std::string histTitles_[nHists_]
Definition: EETrendClient.h:92
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
void getMeanRms(TObject *pre, TObject *cur, double &mean, double &rms)
std::string prefixME_
Definition: EETrendClient.h:71
Definition: Run.h:41