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  * $Date: 2012/04/27 13:45:59 $
5  * $Revision: 1.10 $
6  * \author Dongwook Jang, Soon Yung Jun
7  *
8 */
9 
10 #include <iostream>
11 #include <fstream>
12 #include <math.h>
13 
16 
19 
23 
25 
26  init_ = false;
27 
29 
30  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
31 
32  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
33 
34  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
35 
36  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
37 
38  // histograms...
39  for(int i=0; i<nHists_; i++) {
40  meanMinutely_[i] = 0;
41  sigmaMinutely_[i] = 0;
42 
43  meanHourly_[i] = 0;
44  sigmaHourly_[i] = 0;
45 
46  previousHist_[i] = 0;
47  currentHist_[i] = 0;
48  } // for
49 
50 }
51 
52 
54 }
55 
56 
58 
59  ievt_ = 0;
60 
61  if ( dqmStore_ ) {
62  dqmStore_->setCurrentFolder(prefixME_ + "/EBTrendClient");
63  dqmStore_->rmdir(prefixME_ + "/EBTrendClient");
64  }
65 
66  // noise,
67  // entries of EBOT rec hit thr occupancy
68  // entries of EBOT tp digi occupancy
69  // rec hit energy
70  // ebtmt timing mean ID summary
71  // ebtmt timing RMS ID summary
72  //
73 
74  int index = 0;
75 
76  moduleNames_[index] = "EBClusterTask"; // TH1
77  histTitles_[index] = "EBCLT BC energy";
78  index++;
79 
80  moduleNames_[index] = "EBClusterTask"; // TH1
81  histTitles_[index] = "EBCLT SC energy";
82  index++;
83 
84  moduleNames_[index] = "EBSummaryClient"; // TProfile
85  histTitles_[index] = "EBPOT pedestal G12 mean";
86  index++;
87 
88  moduleNames_[index] = "EBSummaryClient"; // TProfile
89  histTitles_[index] = "EBPOT pedestal G12 rms";
90  index++;
91 
92  moduleNames_[index] = "EBOccupancyTask"; // TH2
93  histTitles_[index] = "EBOT rec hit thr occupancy";
94  index++;
95 
96  moduleNames_[index] = "EBOccupancyTask"; // TH2
97  histTitles_[index] = "EBOT TP digi thr occupancy";
98  index++;
99 
100 }
101 
102 
104 
105  if ( ! mergeRuns_ ) this->reset();
106 
107  start_time_ = time(NULL);
108 
109 }
110 
111 
113 
114 }
115 
116 
118 
119  for(int i=0; i<nHists_; i++) {
122 
123  if(meanHourly_[i]) meanHourly_[i]->Reset();
124  if(sigmaHourly_[i]) sigmaHourly_[i]->Reset();
125  }// for
126 
127 }
128 
129 
131 
132  init_ = true;
133 
135 
136  if ( dqmStore_ ) {
137  dqmStore_->setCurrentFolder(prefixME_ + "/EBTrendClient");
138 
139  for(int i=0; i<nHists_; i++) {
140 
141  // minutely
142 
143  histo = "Average of " + histTitles_[i] + " Vs 5Minutes";
144  meanMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
145  meanMinutely_[i]->setAxisTitle("Minutes", 1);
146  histo = "Average of " + histTitles_[i] + " / 5 minutes";
147  meanMinutely_[i]->setAxisTitle(histo.c_str(), 2);
148 
149  histo = "RMS of " + histTitles_[i] + " Vs 5Minutes";
150  sigmaMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
151  sigmaMinutely_[i]->setAxisTitle("Minutes", 1);
152  histo = "RMS of " + histTitles_[i] + " / 5 minutes";
153  sigmaMinutely_[i]->setAxisTitle(histo.c_str(), 2);
154 
155 
156  // hourly
157 
158  histo = "Average of " + histTitles_[i] + " Vs 1Hour";
159  meanHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
160  meanHourly_[i]->setAxisTitle("Hours", 1);
161  histo = "Average of " + histTitles_[i] + " / hour";
162  meanHourly_[i]->setAxisTitle(histo.c_str(), 2);
163 
164  histo = "RMS of " + histTitles_[i] + " Vs 1Hour";
165  sigmaHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
166  sigmaHourly_[i]->setAxisTitle("Hours", 1);
167  histo = "RMS of " + histTitles_[i] + " / hour";
168  sigmaHourly_[i]->setAxisTitle(histo.c_str(), 2);
169 
170  }// for i
171 
172  }// if
173 
174 }
175 
176 
178 
179  if ( ! init_ ) return;
180 
181  if ( dqmStore_ ) {
182  dqmStore_->setCurrentFolder(prefixME_ + "/EBTrendClient");
183 
184  for(int i=0; i<nHists_; i++) {
185  if(meanMinutely_[i]) dqmStore_->removeElement( meanMinutely_[i]->getName());
186  meanMinutely_[i] = 0;
187  if(sigmaMinutely_[i]) dqmStore_->removeElement( sigmaMinutely_[i]->getName());
188  sigmaMinutely_[i] = 0;
189 
190  if(meanHourly_[i]) dqmStore_->removeElement( meanHourly_[i]->getName());
191  meanHourly_[i] = 0;
192  if(sigmaHourly_[i]) dqmStore_->removeElement( sigmaHourly_[i]->getName());
193  sigmaHourly_[i] = 0;
194 
195  if(previousHist_[i]) delete previousHist_[i];
196  previousHist_[i] = 0;
197  if(currentHist_[i]) delete currentHist_[i];
198  currentHist_[i] = 0;
199 
200  }// for
201 
202  }
203 
204  init_ = false;
205 
206 }
207 
208 
210 
211  edm::LogInfo("EBTrendClient") << "analyzed " << ievt_ << " events";
212 
213  if ( enableCleanup_ ) this->cleanup();
214 
215 }
216 
217 
219 
220  if ( ! init_ ) this->setup();
221 
222  ievt_++;
223 
224  // --------------------------------------------------
225  // Collect time information
226  // --------------------------------------------------
227 
228  updateTime();
229 
230  // long int diff_time = (current_time_ - start_time_)/60;
231 
232  long int minuteBinDiff = -1;
233  long int minuteDiff = -1;
234  // ecaldqm::calcBins(5,1,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
235  ecaldqm::calcBins(5,60,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
236 
237  if(minuteBinDiff <= 0) return;
238 
239  long int hourBinDiff = -1;
240  long int hourDiff = -1;
241  ecaldqm::calcBins(1,3600,start_time_,last_time_,current_time_,hourBinDiff,hourDiff);
242 
243 
244  for(int i=0; i<nHists_; i++){
245 
246  mean_[i] = rms_[i] = 0;
247 
248  // delete previous hists if any
249  if(previousHist_[i]) delete previousHist_[i];
250 
251  // assign currentHists to previousHists
253 
254  } // for i
255 
256 
258 
259  MonitorElement* me;
260 
261  // get clones of histograms from other tasks or clients
262  // assign cloned histogrmas to currentHist_[i]
263 
264  for(int i=0; i<nHists_; i++) {
265  histo = prefixME_ + "/" + moduleNames_[i] + "/" + histTitles_[i];
266  me = dqmStore_->get(histo.c_str());
267  currentHist_[i] = ecaldqm::cloneIt(me,histo);
268  }
269 
270 
271  // Get mean and rms and fill Profile
272 
273  for(int i=0; i<nHists_; i++){
274 
276 
277  if(verbose_) {
278  std::cout << std::scientific;
279  std::cout << "EBTrendClient mean["<<i<<"] = " << mean_[i] << ", \t rms["<<i<<"] = " << rms_[i] << std::endl;
280  }
281 
282  ecaldqm::shift2Right(meanMinutely_[i]->getTProfile(), minuteBinDiff);
283  meanMinutely_[i]->Fill(minuteDiff,mean_[i]);
284 
285  ecaldqm::shift2Right(sigmaMinutely_[i]->getTProfile(), minuteBinDiff);
286  sigmaMinutely_[i]->Fill(minuteDiff,rms_[i]);
287 
288  ecaldqm::shift2Right(meanHourly_[i]->getTProfile(), hourBinDiff);
289  meanHourly_[i]->Fill(hourDiff,mean_[i]);
290 
291  ecaldqm::shift2Right(sigmaHourly_[i]->getTProfile(), hourBinDiff);
292  sigmaHourly_[i]->Fill(hourDiff,rms_[i]);
293  } // for i
294 
295 
296 }
297 
298 
300 
303 
304 }
305 
TObject * previousHist_[nHists_]
Definition: EBTrendClient.h:99
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:94
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
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:85
std::string prefixME_
Definition: EBTrendClient.h:73
void beginJob(void)
void Fill(long long x)
TObject * currentHist_[nHists_]
MonitorElement * sigmaMinutely_[nHists_]
Definition: EBTrendClient.h:82
void analyze(const edm::Event &e, const edm::EventSetup &c)
virtual ~EBTrendClient()
void removeElement(const std::string &name)
Definition: DQMStore.cc:2577
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:1036
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:1473
void updateTime(void)
double mean_[nHists_]
Definition: EBTrendClient.h:96
Ecal Monitor Utils for Client.
EBTrendClient(const edm::ParameterSet &ps)
Ecal Monitor Utility functions.
MonitorElement * meanHourly_[nHists_]
Definition: EBTrendClient.h:84
double rms_[nHists_]
Definition: EBTrendClient.h:97
void beginRun(const edm::Run &r, const edm::EventSetup &c)
void cleanup(void)
const int nHists_
Definition: EBTrendClient.h:25
TObject * cloneIt(MonitorElement *me, std::string histo)
tuple cout
Definition: gather_cfg.py:121
std::string moduleNames_[nHists_]
Definition: EBTrendClient.h:93
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:81
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void getMeanRms(TObject *pre, TObject *cur, double &mean, double &rms)
DQMStore * dqmStore_
Definition: EBTrendClient.h:71
Definition: Run.h:36