QwAnalysis
MQwCodaControlEvent.cc
Go to the documentation of this file.
1 #include "MQwCodaControlEvent.h"
2 
3 #include "QwLog.h"
4 
7 }
8 
10 
12 {
13  fFoundControlEvents = kFALSE;
14  fPrestartTime = 0;
16  fRunType = 0;
17  fEndTime = 0;
18  fEndEventCount = 0;
19  fNumberPause = 0;
20  fPauseTime.clear();
21  fPauseEventCount.clear();
22  fNumberGo = 0;
23  fGoTime.clear();
24  fGoEventCount.clear();
25  fStartTime = 0;
26  fPrestartDatime.Set(UInt_t(0));
27  fStartDatime.Set(UInt_t(0));
28  fEndDatime.Set(UInt_t(0));
29 }
30 
31 void MQwCodaControlEvent::ProcessControlEvent(UInt_t evtype, UInt_t* buffer){
32  UInt_t local_time;
33  UInt_t local_evcount;
34 
35  local_time = buffer[0];
36  local_evcount = buffer[2];
37  if (evtype==kSYNC_EVENT){
38  UInt_t local_status = buffer[1];
39  ProcessSync(local_time, local_status);
40  } else if (evtype==kPRESTART_EVENT){
41  UInt_t local_runnumber = buffer[1];
42  UInt_t local_runtype = buffer[2];
43  ProcessPrestart(local_time, local_runnumber, local_runtype);
44  } else if (evtype==kGO_EVENT){
45  ProcessGo(local_time, local_evcount);
46  } else if (evtype==kPAUSE_EVENT){
47  ProcessPause(local_time, local_evcount);
48  } else if (evtype==kEND_EVENT){
49  ProcessEnd(local_time, local_evcount);
50  } else {
51  // This isn't a control event.
52  // Do nothing.
53  }
54 }
55 
56 
57 void MQwCodaControlEvent::ProcessSync(UInt_t local_time, UInt_t statuscode)
58 {
59  fFoundControlEvents = kTRUE;
60  // To be implemented...
61 }
62 
63 
64 void MQwCodaControlEvent::ProcessPrestart(UInt_t local_time, UInt_t local_runnumber,
65  UInt_t local_runtype)
66 {
67  fFoundControlEvents = kTRUE;
68  //
70  //
71  fPrestartTime = local_time;
72  fPrestartRunNumber = local_runnumber;
73  fRunType = local_runtype;
75 }
76 
77 void MQwCodaControlEvent::ProcessPause(UInt_t local_time, UInt_t evt_count)
78 {
79  fFoundControlEvents = kTRUE;
80  //
81  fNumberPause++;
82  fPauseEventCount.push_back(evt_count);
83  fPauseTime.push_back(local_time);
84 }
85 
86 void MQwCodaControlEvent::ProcessGo(UInt_t local_time, UInt_t evt_count)
87 {
88  fFoundControlEvents = kTRUE;
89  //
90  fNumberGo++;
91  fGoEventCount.push_back(evt_count);
92  fGoTime.push_back(local_time);
93  if (fNumberGo == 1){
94  fStartTime = fGoTime[0];
96  }
97 }
98 
99 void MQwCodaControlEvent::ProcessEnd(UInt_t local_time, UInt_t evt_count)
100 {
101  fFoundControlEvents = kTRUE;
102  //
103  fEndTime = local_time;
104  fEndEventCount = evt_count;
105  fEndDatime.Set(fEndTime);
106 }
107 
108 
110 {
111  if (index>=0 && index<(Int_t)fNumberGo) return fGoTime[index];
112  return 0;
113 }
114 
116 {
117  if (index>=0 && index<(Int_t)fNumberGo) return fGoEventCount[index];
118  return 0;
119 }
120 
122 {
123  if (index>=0 && index<(Int_t)fNumberPause) return fPauseTime[index];
124  return 0;
125 }
126 
128 {
129  if (index>=0 && index<(Int_t)fNumberPause) return fPauseEventCount[index];
130  return 0;
131 }
132 
133 
135 {
136  return fStartDatime.AsSQLString();
137 }
138 
140 {
141  return fEndDatime.AsSQLString();
142 }
143 
144 
146 {
147  if (fFoundControlEvents){
148  // At least one control event has been found.
149  // Report the control event data we did find.
150  Int_t i;
151  QwMessage << "Run Number: " << fPrestartRunNumber << QwLog::endl;
152  QwMessage << "Run Type: " << fRunType << QwLog::endl;
153  QwMessage << "PreStart Time: " << fPrestartTime << QwLog::endl;
154  QwMessage << "Start Time: " << fStartTime << QwLog::endl;
155  QwMessage << "End Time: " << fEndTime << QwLog::endl;
156  QwMessage << "End Event Counter: " << fEndEventCount << QwLog::endl;
157  if (fEndTime>0 && fStartTime>0)
158  QwMessage << "Run Duration (sec): " << fEndTime-fStartTime << QwLog::endl;
159  else
160  QwMessage << "Run Duration (sec): " << "n/a" << QwLog::endl;
161  QwMessage << "SQL-Formatted Start Time: " << GetStartSQLTime()
162  << QwLog::endl;
163  QwMessage << "SQL-Formatted End Time: " << GetEndSQLTime()
164  << QwLog::endl;
165  QwMessage << "Number of Pauses during this run: " << fNumberPause
166  << QwLog::endl;
167  for (i=0; i<(Int_t)fNumberPause; i++) {
168  QwMessage << "Pause Number: " << i
169  <<"; Events so far: " << fPauseEventCount[i]
170  << "; Runtime since start (sec): "
171  << fPauseTime[i]-fStartTime;
172  if ((Int_t)fNumberGo > i+1){
173  QwMessage << "; Duration of Pause (sec): "
174  << fGoTime[i+1]-fPauseTime[i]
175  << QwLog::endl;
176  }else {
178  }
179  }
180  }
181 }
182 
183 
185 {
186  return (time_t) GetStartTime();
187 }
188 
189 
191 {
192  // if GetEndTime is equal to 0
193  // we wiil see the end time as
194  //
195  UInt_t end_time = GetEndTime();
196  UInt_t qweak_end_time = 1338523199;
197  // 2012-05-31 23:59:59 in the MySQL database
198  // $date -d@1338523199
199  // Thu May 31 23:59:59 EDT 2012 in a xterm (Linux)
200 
201  if(end_time) return (time_t) end_time;
202  else return (time_t) qweak_end_time;
203 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
UInt_t GetGoTime(int index=0)
UInt_t GetPauseTime(int index=0)
std::vector< UInt_t > fGoTime
void ProcessPause(UInt_t local_time, UInt_t evt_count)
void ProcessControlEvent(UInt_t evtype, UInt_t *buffer)
A logfile class, based on an identical class in the Hermes analyzer.
UInt_t GetGoEventCount(int index=0)
UInt_t GetPauseEventCount(int index=0)
void ProcessPrestart(UInt_t local_time, UInt_t local_runnumber, UInt_t local_runtype)
std::vector< UInt_t > fGoEventCount
std::vector< UInt_t > fPauseTime
void ProcessGo(UInt_t local_time, UInt_t evt_count)
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
void ProcessSync(UInt_t local_time, UInt_t statuscode)
void ProcessEnd(UInt_t local_time, UInt_t evt_count)
std::vector< UInt_t > fPauseEventCount