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