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  * $Date: 2010/03/27 20:08:00 $
5  * $Revision: 1.7 $
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_ + "/EETrendClient");
63  dqmStore_->rmdir(prefixME_ + "/EETrendClient");
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] = "EEClusterTask"; // TH1
77  histTitles_[index] = "EECLT BC energy";
78  index++;
79 
80  moduleNames_[index] = "EEClusterTask"; // TH1
81  histTitles_[index] = "EECLT SC energy";
82  index++;
83 
84  moduleNames_[index] = "EESummaryClient"; // TProfile
85  histTitles_[index] = "EEPOT pedestal G12 mean";
86  index++;
87 
88  moduleNames_[index] = "EESummaryClient"; // TProfile
89  histTitles_[index] = "EEPOT pedestal G12 rms";
90  index++;
91 
92  moduleNames_[index] = "EEOccupancyTask"; // TH2
93  histTitles_[index] = "EEOT rec hit thr occupancy EE -";
94  index++;
95 
96  moduleNames_[index] = "EEOccupancyTask"; // TH2
97  histTitles_[index] = "EEOT rec hit thr occupancy EE +";
98  index++;
99 
100  moduleNames_[index] = "EEOccupancyTask"; // TH2
101  histTitles_[index] = "EEOT TP digi thr occupancy EE -";
102  index++;
103 
104  moduleNames_[index] = "EEOccupancyTask"; // TH2
105  histTitles_[index] = "EEOT TP digi thr occupancy EE +";
106  index++;
107 
108 }
109 
110 
112 
113  if ( ! mergeRuns_ ) this->reset();
114 
115  start_time_ = time(NULL);
116 
117 }
118 
119 
121 
122 }
123 
124 
126 
127  for(int i=0; i<nHists_; i++) {
130 
131  if(meanHourly_[i]) meanHourly_[i]->Reset();
132  if(sigmaHourly_[i]) sigmaHourly_[i]->Reset();
133  }// for
134 
135 }
136 
137 
139 
140  init_ = true;
141 
142  std::string histo;
143 
144  if ( dqmStore_ ) {
145  dqmStore_->setCurrentFolder(prefixME_ + "/EETrendClient");
146 
147  for(int i=0; i<nHists_; i++) {
148 
149  // minutely
150 
151  histo = "Average of " + histTitles_[i] + " Vs 5Minutes";
152  meanMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
153  meanMinutely_[i]->setAxisTitle("Minutes", 1);
154  histo = "Average of " + histTitles_[i] + " / 5 minutes";
155  meanMinutely_[i]->setAxisTitle(histo.c_str(), 2);
156 
157  histo = "RMS of " + histTitles_[i] + " Vs 5Minutes";
158  sigmaMinutely_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 12, 0.0, 60.0, 100, 0.0, 1.0e6, "s");
159  sigmaMinutely_[i]->setAxisTitle("Minutes", 1);
160  histo = "RMS of " + histTitles_[i] + " / 5 minutes";
161  sigmaMinutely_[i]->setAxisTitle(histo.c_str(), 2);
162 
163 
164  // hourly
165 
166  histo = "Average of " + histTitles_[i] + " Vs 1Hour";
167  meanHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
168  meanHourly_[i]->setAxisTitle("Hours", 1);
169  histo = "Average of " + histTitles_[i] + " / hour";
170  meanHourly_[i]->setAxisTitle(histo.c_str(), 2);
171 
172  histo = "RMS of " + histTitles_[i] + " Vs 1Hour";
173  sigmaHourly_[i] = dqmStore_->bookProfile(histo.c_str(), histo.c_str(), 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
174  sigmaHourly_[i]->setAxisTitle("Hours", 1);
175  histo = "RMS of " + histTitles_[i] + " / hour";
176  sigmaHourly_[i]->setAxisTitle(histo.c_str(), 2);
177 
178  }// for i
179 
180  }// if
181 
182 }
183 
184 
186 
187  if ( ! init_ ) return;
188 
189  if ( dqmStore_ ) {
190  dqmStore_->setCurrentFolder(prefixME_ + "/EETrendClient");
191 
192  for(int i=0; i<nHists_; i++) {
194  meanMinutely_[i] = 0;
196  sigmaMinutely_[i] = 0;
197 
199  meanHourly_[i] = 0;
201  sigmaHourly_[i] = 0;
202 
203  if(previousHist_[i]) delete previousHist_[i];
204  previousHist_[i] = 0;
205  if(currentHist_[i]) delete currentHist_[i];
206  currentHist_[i] = 0;
207 
208  }// for
209 
210  }
211 
212  init_ = false;
213 
214 }
215 
216 
218 
219  edm::LogInfo("EETrendClient") << "analyzed " << ievt_ << " events";
220 
221  if ( enableCleanup_ ) this->cleanup();
222 
223 }
224 
225 
227 
228  if ( ! init_ ) this->setup();
229 
230  ievt_++;
231 
232  // --------------------------------------------------
233  // Collect time information
234  // --------------------------------------------------
235 
236  updateTime();
237 
238  // long int diff_time = (current_time_ - start_time_)/60;
239 
240  long int minuteBinDiff = -1;
241  long int minuteDiff = -1;
242  // ecaldqm::calcBins(5,1,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
243  ecaldqm::calcBins(5,60,start_time_,last_time_,current_time_,minuteBinDiff,minuteDiff);
244 
245  if(minuteBinDiff <= 0) return;
246 
247  long int hourBinDiff = -1;
248  long int hourDiff = -1;
249  ecaldqm::calcBins(1,3600,start_time_,last_time_,current_time_,hourBinDiff,hourDiff);
250 
251 
252  for(int i=0; i<nHists_; i++){
253 
254  mean_[i] = rms_[i] = 0;
255 
256  // delete previous hists if any
257  if(previousHist_[i]) delete previousHist_[i];
258 
259  // assign currentHists to previousHists
261 
262  } // for i
263 
264 
265  std::string histo;
266 
267  MonitorElement* me;
268 
269  // get clones of histograms from other tasks or clients
270  // assign cloned histogrmas to currentHist_[i]
271 
272  for(int i=0; i<nHists_; i++) {
273  histo = prefixME_ + "/" + moduleNames_[i] + "/" + histTitles_[i];
274  me = dqmStore_->get(histo.c_str());
275  currentHist_[i] = ecaldqm::cloneIt(me,histo);
276  }
277 
278 
279  // Get mean and rms and fill Profile
280 
281  for(int i=0; i<nHists_; i++){
282 
284 
285  if(verbose_) {
286  std::cout << std::scientific;
287  std::cout << "EETrendClient mean["<<i<<"] = " << mean_[i] << ", \t rms["<<i<<"] = " << rms_[i] << std::endl;
288  }
289 
290  ecaldqm::shift2Right(meanMinutely_[i]->getTProfile(), minuteBinDiff);
291  meanMinutely_[i]->Fill(minuteDiff,mean_[i]);
292 
293  ecaldqm::shift2Right(sigmaMinutely_[i]->getTProfile(), minuteBinDiff);
294  sigmaMinutely_[i]->Fill(minuteDiff,rms_[i]);
295 
296  ecaldqm::shift2Right(meanHourly_[i]->getTProfile(), hourBinDiff);
297  meanHourly_[i]->Fill(hourDiff,mean_[i]);
298 
299  ecaldqm::shift2Right(sigmaHourly_[i]->getTProfile(), hourBinDiff);
300  sigmaHourly_[i]->Fill(hourDiff,rms_[i]);
301  } // for i
302 
303 
304 }
305 
306 
308 
311 
312 }
313 
T getUntrackedParameter(std::string const &, T const &) const
void shift2Right(TProfile *p, int bins)
Definition: UtilFunctions.h:61
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:2296
void beginRun(const edm::Run &r, const edm::EventSetup &c)
double mean_[nHists_]
Definition: EETrendClient.h:96
void setup(void)
#define NULL
Definition: scimark2.h:8
TObject * previousHist_[nHists_]
Definition: EETrendClient.h:99
DQMStore * dqmStore_
Definition: EETrendClient.h:71
tuple histo
Definition: trackerHits.py:12
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:85
std::string moduleNames_[nHists_]
Definition: EETrendClient.h:93
void removeElement(const std::string &name)
Definition: DQMStore.cc:2338
EETrendClient(const edm::ParameterSet &ps)
MonitorElement * meanMinutely_[nHists_]
Definition: EETrendClient.h:81
TObject * cloneIt(MonitorElement *me, std::string histo)
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:833
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
Ecal Monitor Utils for Client.
Ecal Monitor Utility functions.
TObject * currentHist_[nHists_]
void reset(void)
const int nHists_
Definition: EBTrendClient.h:25
virtual ~EETrendClient()
MonitorElement * meanHourly_[nHists_]
Definition: EETrendClient.h:84
double rms_[nHists_]
Definition: EETrendClient.h:97
tuple cout
Definition: gather_cfg.py:41
void calcBins(int binWidth, int divisor, long int start_time, long int last_time, long int current_time, long int &binDiff, long int &diff)
Definition: UtilFunctions.h:28
MonitorElement * sigmaMinutely_[nHists_]
Definition: EETrendClient.h:82
std::string histTitles_[nHists_]
Definition: EETrendClient.h:94
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:237
void getMeanRms(TObject *pre, TObject *cur, double &mean, double &rms)
std::string prefixME_
Definition: EETrendClient.h:73
Definition: Run.h:31