CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBTrendClient.cc
Go to the documentation of this file.
1 /*
2  * \file EBTrendClient.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_ + "/EBTrendClient");
61  dqmStore_->rmdir(prefixME_ + "/EBTrendClient");
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] = "EBClusterTask"; // TH1
75  histTitles_[index] = "EBCLT BC energy";
76  index++;
77 
78  moduleNames_[index] = "EBClusterTask"; // TH1
79  histTitles_[index] = "EBCLT SC energy";
80  index++;
81 
82  moduleNames_[index] = "EBSummaryClient"; // TProfile
83  histTitles_[index] = "EBPOT pedestal G12 mean";
84  index++;
85 
86  moduleNames_[index] = "EBSummaryClient"; // TProfile
87  histTitles_[index] = "EBPOT pedestal G12 rms";
88  index++;
89 
90  moduleNames_[index] = "EBOccupancyTask"; // TH2
91  histTitles_[index] = "EBOT rec hit thr occupancy";
92  index++;
93 
94  moduleNames_[index] = "EBOccupancyTask"; // TH2
95  histTitles_[index] = "EBOT TP digi thr occupancy";
96  index++;
97 
98 }
99 
100 
102 
103  if ( ! mergeRuns_ ) this->reset();
104 
105  start_time_ = time(NULL);
106 
107 }
108 
109 
111 
112 }
113 
114 
116 
117  for(int i=0; i<nHists_; i++) {
120 
121  if(meanHourly_[i]) meanHourly_[i]->Reset();
122  if(sigmaHourly_[i]) sigmaHourly_[i]->Reset();
123  }// for
124 
125 }
126 
127 
129 
130  init_ = true;
131 
133 
134  if ( dqmStore_ ) {
135  dqmStore_->setCurrentFolder(prefixME_ + "/EBTrendClient");
136 
137  for(int i=0; i<nHists_; i++) {
138 
139  // minutely
140 
141  histo = "Average of " + histTitles_[i] + " Vs 5Minutes";
142  meanMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
143  meanMinutely_[i]->setAxisTitle("Minutes", 1);
144  histo = "Average of " + histTitles_[i] + " / 5 minutes";
145  meanMinutely_[i]->setAxisTitle(histo.c_str(), 2);
146 
147  histo = "RMS of " + histTitles_[i] + " Vs 5Minutes";
148  sigmaMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
149  sigmaMinutely_[i]->setAxisTitle("Minutes", 1);
150  histo = "RMS of " + histTitles_[i] + " / 5 minutes";
151  sigmaMinutely_[i]->setAxisTitle(histo.c_str(), 2);
152 
153 
154  // hourly
155 
156  histo = "Average of " + histTitles_[i] + " Vs 1Hour";
157  meanHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
158  meanHourly_[i]->setAxisTitle("Hours", 1);
159  histo = "Average of " + histTitles_[i] + " / hour";
160  meanHourly_[i]->setAxisTitle(histo.c_str(), 2);
161 
162  histo = "RMS of " + histTitles_[i] + " Vs 1Hour";
163  sigmaHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
164  sigmaHourly_[i]->setAxisTitle("Hours", 1);
165  histo = "RMS of " + histTitles_[i] + " / hour";
166  sigmaHourly_[i]->setAxisTitle(histo.c_str(), 2);
167 
168  }// for i
169 
170  }// if
171 
172 }
173 
174 
176 
177  if ( ! init_ ) return;
178 
179  if ( dqmStore_ ) {
180  dqmStore_->setCurrentFolder(prefixME_ + "/EBTrendClient");
181 
182  for(int i=0; i<nHists_; i++) {
183  if(meanMinutely_[i]) dqmStore_->removeElement( meanMinutely_[i]->getName());
184  meanMinutely_[i] = 0;
185  if(sigmaMinutely_[i]) dqmStore_->removeElement( sigmaMinutely_[i]->getName());
186  sigmaMinutely_[i] = 0;
187 
188  if(meanHourly_[i]) dqmStore_->removeElement( meanHourly_[i]->getName());
189  meanHourly_[i] = 0;
190  if(sigmaHourly_[i]) dqmStore_->removeElement( sigmaHourly_[i]->getName());
191  sigmaHourly_[i] = 0;
192 
193  if(previousHist_[i]) delete previousHist_[i];
194  previousHist_[i] = 0;
195  if(currentHist_[i]) delete currentHist_[i];
196  currentHist_[i] = 0;
197 
198  }// for
199 
200  }
201 
202  init_ = false;
203 
204 }
205 
206 
208 
209  edm::LogInfo("EBTrendClient") << "analyzed " << ievt_ << " events";
210 
211  if ( enableCleanup_ ) this->cleanup();
212 
213 }
214 
215 
217 
218  if ( ! init_ ) this->setup();
219 
220  ievt_++;
221 
222  // --------------------------------------------------
223  // Collect time information
224  // --------------------------------------------------
225 
226  updateTime();
227 
228  // long int diff_time = (current_time_ - start_time_)/60;
229 
230  long int minuteBinDiff = -1;
231  long int minuteDiff = -1;
232  // ecaldqm::calcBins(5,1,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
233  ecaldqm::calcBins(5,60,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
234 
235  if(minuteBinDiff <= 0) return;
236 
237  long int hourBinDiff = -1;
238  long int hourDiff = -1;
239  ecaldqm::calcBins(1,3600,start_time_,last_time_,current_time_,hourBinDiff,hourDiff);
240 
241 
242  for(int i=0; i<nHists_; i++){
243 
244  mean_[i] = rms_[i] = 0;
245 
246  // delete previous hists if any
247  if(previousHist_[i]) delete previousHist_[i];
248 
249  // assign currentHists to previousHists
251 
252  } // for i
253 
254 
256 
257  MonitorElement* me;
258 
259  // get clones of histograms from other tasks or clients
260  // assign cloned histogrmas to currentHist_[i]
261 
262  for(int i=0; i<nHists_; i++) {
263  histo = prefixME_ + "/" + moduleNames_[i] + "/" + histTitles_[i];
264  me = dqmStore_->get(histo.c_str());
265  currentHist_[i] = ecaldqm::cloneIt(me,histo);
266  }
267 
268 
269  // Get mean and rms and fill Profile
270 
271  for(int i=0; i<nHists_; i++){
272 
274 
275  if(verbose_) {
276  std::cout << std::scientific;
277  std::cout << "EBTrendClient mean["<<i<<"] = " << mean_[i] << ", \t rms["<<i<<"] = " << rms_[i] << std::endl;
278  }
279 
280  ecaldqm::shift2Right(meanMinutely_[i]->getTProfile(), minuteBinDiff);
281  meanMinutely_[i]->Fill(minuteDiff,mean_[i]);
282 
283  ecaldqm::shift2Right(sigmaMinutely_[i]->getTProfile(), minuteBinDiff);
284  sigmaMinutely_[i]->Fill(minuteDiff,rms_[i]);
285 
286  ecaldqm::shift2Right(meanHourly_[i]->getTProfile(), hourBinDiff);
287  meanHourly_[i]->Fill(hourDiff,mean_[i]);
288 
289  ecaldqm::shift2Right(sigmaHourly_[i]->getTProfile(), hourBinDiff);
290  sigmaHourly_[i]->Fill(hourDiff,rms_[i]);
291  } // for i
292 
293 
294 }
295 
296 
298 
301 
302 }
303 
TObject * previousHist_[nHists_]
Definition: EBTrendClient.h:97
void reset(void)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
std::string histTitles_[nHists_]
Definition: EBTrendClient.h:92
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
void endRun(const edm::Run &r, const edm::EventSetup &c)
void endJob(void)
#define NULL
Definition: scimark2.h:8
MonitorElement * sigmaHourly_[nHists_]
Definition: EBTrendClient.h:83
std::string prefixME_
Definition: EBTrendClient.h:71
void beginJob(void)
void Fill(long long x)
TObject * currentHist_[nHists_]
Definition: EBTrendClient.h:98
MonitorElement * sigmaMinutely_[nHists_]
Definition: EBTrendClient.h:80
void analyze(const edm::Event &e, const edm::EventSetup &c)
virtual ~EBTrendClient()
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
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
void setup(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:1623
void updateTime(void)
double mean_[nHists_]
Definition: EBTrendClient.h:94
Ecal Monitor Utils for Client.
EBTrendClient(const edm::ParameterSet &ps)
Ecal Monitor Utility functions.
MonitorElement * meanHourly_[nHists_]
Definition: EBTrendClient.h:82
double rms_[nHists_]
Definition: EBTrendClient.h:95
void beginRun(const edm::Run &r, const edm::EventSetup &c)
void cleanup(void)
const int nHists_
Definition: EBTrendClient.h:23
TObject * cloneIt(MonitorElement *me, std::string histo)
tuple cout
Definition: gather_cfg.py:121
std::string moduleNames_[nHists_]
Definition: EBTrendClient.h:91
void calcBins(int binWidth, int divisor, long int start_time, long int last_time, long int current_time, long int &binDiff, long int &diff)
void shift2Right(TH1 *h, int bins)
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)
MonitorElement * meanMinutely_[nHists_]
Definition: EBTrendClient.h:79
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
void getMeanRms(TObject *pre, TObject *cur, double &mean, double &rms)
DQMStore * dqmStore_
Definition: EBTrendClient.h:69
Definition: Run.h:41