RawRunHeaderV0.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawRunHeaderV0.h"
2 #include "DAQDataFormats/BitFields.h"
3 #include <boost/format.hpp>
4 
5 // It is requred to
6 // 1. include DAQDataFormats/DataFormatFirst.inc
7 // 2. define CURRENT_CLASS
8 // 3. define CURRENT_CLASS_VERSION for version of the class
9 // OR define LAST_CLASS_VERSION for the main structure of the class
10 // 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
11 // 5. include DAQDataFormats/DataFormatLast.inc
12 // before the declaration of the DataFormat version class in the header.
13 #include "DAQDataFormats/DataFormatFirst.inc"
14 #define CURRENT_CLASS RawRunHeader
15 #define CURRENT_CLASS_VERSION 0
16 #define CURRENT_FIELDS_SUB_NAMESPACE rawrunhdr
17 #include "DAQDataFormats/DataFormatLast.inc"
18 
19 namespace daqdataformats{
20 namespace VERSION_NAMESPACE{
21 
22 //------------------------Constructors------------------------------------------
24  PREVIOUS_VERSION_CLASS_NAME(version)
25  ,ZEROOUT_GET (MarkerHi )
26  ,ZEROOUT_SET (MarkerHi )
27  ,ZEROOUT_GET (MarkerLo )
28  ,ZEROOUT_SET (MarkerLo )
29  ,ZEROOUT_GET (Reserved1 )
30  ,ZEROOUT_SET (Reserved1 )
31  ,ZEROOUT_GET (Reserved2 )
32  ,ZEROOUT_SET (Reserved2 )
33  ,ZEROOUT_GET (Version )
34  ,ZEROOUT_SET (Version )
35  ,ZEROOUT_GET_AND_SET(RunNumber )
37  ,ZEROOUT_GET_AND_SET(ConfigIDX )
38  ,ZEROOUT_GET_AND_SET(Partition )
39  ,ZEROOUT_GET_AND_SET(Subrun )
40  ,ZEROOUT_GET_AND_SET(ConfigurationBlockSet )
41  ,ZEROOUT_GET_AND_SET(RunControlVersion )
42  ,ZEROOUT_GET_AND_SET(RunControlID )
43  ,ZEROOUT_GET_AND_SET(DataLoggerVersion )
44  ,ZEROOUT_GET_AND_SET(DataLoggerID )
45  ,ZEROOUT_GET_AND_SET(RunStartTime )
46  ,ZEROOUT_GET_AND_SET(SubRunStartTime )
47  ,ZEROOUT_GET_AND_SET(SubRunEndTime )
48  ,ZEROOUT_GET_AND_SET(RunEndTime )
49  ,ZEROOUT_GET_AND_SET(TotalEvents )
50  ,ZEROOUT_GET_AND_SET(UniversalEventStartLo )
51  ,ZEROOUT_GET_AND_SET(UniversalEventStartHi )
52  ,ZEROOUT_GET_AND_SET(UniversalEventEndLo )
53  ,ZEROOUT_GET_AND_SET(UniversalEventEndHi )
54  ,ZEROOUT_GET_AND_SET(RunSize )
56  ,ZEROOUT_GET_AND_SET(TriggerCtrlID )
57  ,ZEROOUT_GET_AND_SET(TriggerMC )
58  ,ZEROOUT_GET_AND_SET(VTMod )
59  ,ZEROOUT_GET_AND_SET(ValidTriggerTypesLow )
60  ,ZEROOUT_GET_AND_SET(ValidTriggerTypesHigh )
61  ,ZEROOUT_GET_AND_SET(ValidTriggerTypesHigh2)
62  ,ZEROOUT_GET_AND_SET(TriggerListIDX )
63  ,ZEROOUT_GET_AND_SET(TriggerPrescaleListIDX)
64  ,ZEROOUT_GET_AND_SET(CRC )
65  ,ZEROOUT_FUNCTION(getUniversalEventStart)
66  ,ZEROOUT_FUNCTION(setUniversalEventStart)
67  ,ZEROOUT_FUNCTION(getUniversalEventEnd )
68  ,ZEROOUT_FUNCTION(setUniversalEventEnd )
69  ,ZEROOUT_FUNCTION(setTail )
71  ,ZEROOUT_FUNCTION(advanceEventNumber )
72  ,ZEROOUT_FUNCTION(addValidTriggerTypesLow )
73  ,ZEROOUT_FUNCTION(addValidTriggerTypesHigh )
74  ,ZEROOUT_FUNCTION(addValidTriggerTypesHigh2)
75  ,ZEROOUT_FUNCTION(addRunSize )
76 {}
77 
78 //------------------------------------------------------------------------------
80  PREVIOUS_VERSION_CLASS_NAME(copyin)
81  ,DEEPCOPY_GET (MarkerHi )
82  ,DEEPCOPY_SET (MarkerHi )
83  ,DEEPCOPY_GET (MarkerLo )
84  ,DEEPCOPY_SET (MarkerLo )
85  ,DEEPCOPY_GET (Reserved1 )
86  ,DEEPCOPY_SET (Reserved1 )
87  ,DEEPCOPY_GET (Reserved2 )
88  ,DEEPCOPY_SET (Reserved2 )
89  ,DEEPCOPY_GET (Version )
90  ,DEEPCOPY_SET (Version )
91  ,DEEPCOPY_GET_AND_SET(RunNumber )
93  ,DEEPCOPY_GET_AND_SET(ConfigIDX )
94  ,DEEPCOPY_GET_AND_SET(Partition )
95  ,DEEPCOPY_GET_AND_SET(Subrun )
96  ,DEEPCOPY_GET_AND_SET(ConfigurationBlockSet )
97  ,DEEPCOPY_GET_AND_SET(RunControlVersion )
98  ,DEEPCOPY_GET_AND_SET(RunControlID )
99  ,DEEPCOPY_GET_AND_SET(DataLoggerVersion )
100  ,DEEPCOPY_GET_AND_SET(DataLoggerID )
101  ,DEEPCOPY_GET_AND_SET(RunStartTime )
102  ,DEEPCOPY_GET_AND_SET(SubRunStartTime )
103  ,DEEPCOPY_GET_AND_SET(SubRunEndTime )
104  ,DEEPCOPY_GET_AND_SET(RunEndTime )
105  ,DEEPCOPY_GET_AND_SET(TotalEvents )
106  ,DEEPCOPY_GET_AND_SET(UniversalEventStartLo )
107  ,DEEPCOPY_GET_AND_SET(UniversalEventStartHi )
108  ,DEEPCOPY_GET_AND_SET(UniversalEventEndLo )
109  ,DEEPCOPY_GET_AND_SET(UniversalEventEndHi )
110  ,DEEPCOPY_GET_AND_SET(RunSize )
112  ,DEEPCOPY_GET_AND_SET(TriggerCtrlID )
113  ,DEEPCOPY_GET_AND_SET(TriggerMC )
114  ,DEEPCOPY_GET_AND_SET(VTMod )
115  ,DEEPCOPY_GET_AND_SET(ValidTriggerTypesLow )
116  ,DEEPCOPY_GET_AND_SET(ValidTriggerTypesHigh )
117  ,DEEPCOPY_GET_AND_SET(ValidTriggerTypesHigh2)
118  ,DEEPCOPY_GET_AND_SET(TriggerListIDX )
119  ,DEEPCOPY_GET_AND_SET(TriggerPrescaleListIDX)
120  ,DEEPCOPY_GET_AND_SET(CRC )
121  ,DEEPCOPY_FUNCTION(getUniversalEventStart)
122  ,DEEPCOPY_FUNCTION(setUniversalEventStart)
123  ,DEEPCOPY_FUNCTION(getUniversalEventEnd )
124  ,DEEPCOPY_FUNCTION(setUniversalEventEnd )
125  ,DEEPCOPY_FUNCTION(setTail )
127  ,DEEPCOPY_FUNCTION(advanceEventNumber )
128  ,DEEPCOPY_FUNCTION(addValidTriggerTypesLow )
129  ,DEEPCOPY_FUNCTION(addValidTriggerTypesHigh )
130  ,DEEPCOPY_FUNCTION(addValidTriggerTypesHigh2)
131  ,DEEPCOPY_FUNCTION(addRunSize )
132 {}
133 
134 //------------------------------------------------------------------------------
136 
137 //------------------------------------------------------------------------------
138 // Initialization of data members
140  EXECUTE_FUNCTION(setVersion )(_version);
141  EXECUTE_FUNCTION(setRunSize)(sizeofdata());
144 }
145 
146 
147 //------------------------------------------------------------------------------
148 uint64_t RawRunHeader::getUniversalEventStart () const {
149  return getUint64_t(EXECUTE_FUNCTION(getUniversalEventStartLo)(), EXECUTE_FUNCTION(getUniversalEventStartHi)());
150 }
151 //------------------------------------------------------------------------------
152 bool RawRunHeader::setUniversalEventStart (const uint64_t event) {
153  uint32_t low, high;
154  getLoAndHi(event, low, high);
155 
156  EXECUTE_FUNCTION(setUniversalEventStartHi)(high);
157  RETURN_FUNCTION(setUniversalEventStartLo)(low);
158 }
159 //------------------------------------------------------------------------------
160 uint64_t RawRunHeader::getUniversalEventEnd () const {
161  return getUint64_t( EXECUTE_FUNCTION(getUniversalEventEndLo)() , EXECUTE_FUNCTION(getUniversalEventEndHi)());}
162 //------------------------------------------------------------------------------
163 bool RawRunHeader::setUniversalEventEnd (const uint64_t event) {
164  uint32_t low, high;
165  getLoAndHi(event, low, high);
166 
167  EXECUTE_FUNCTION(setUniversalEventEndHi)(high);
168  RETURN_FUNCTION(setUniversalEventEndLo)(low);
169 }
170 
171 //------------------------------------------------------------------------------
172 bool RawRunHeader::addValidTriggerTypesLow (const uint32_t w){
173  /// Add by applying a bitwize OR
174  const uint32_t word = w | EXECUTE_FUNCTION(getValidTriggerTypesLow)();
175  return setValidTriggerTypesLow(word);
176 }
177 //------------------------------------------------------------------------------
178 bool RawRunHeader::addValidTriggerTypesHigh (const uint32_t w){
179  /// Add by applying a bitwize OR
180  const uint32_t word = w | EXECUTE_FUNCTION(getValidTriggerTypesHigh)();
181  RETURN_FUNCTION(setValidTriggerTypesHigh)(word);
182 }
183 //------------------------------------------------------------------------------
184 bool RawRunHeader::addValidTriggerTypesHigh2(const uint32_t w){
185  /// Add by applying a bitwize OR
186  const uint32_t word = w | EXECUTE_FUNCTION(getValidTriggerTypesHigh2)();
187  RETURN_FUNCTION(setValidTriggerTypesHigh2)(word);
188 }
189 
190 //------------------------------------------------------------------------------
191 bool RawRunHeader::addRunSize (const uint32_t size){ RETURN_FUNCTION(setRunSize)(EXECUTE_FUNCTION(getRunSize)() + size);}
192 //------------------------------------------------------------------------------
193 bool RawRunHeader::advanceEventNumber() { RETURN_FUNCTION(setTotalEvents)(EXECUTE_FUNCTION(getTotalEvents)() + 1);}
194 
195 //------------------------------------------------------------------------------
196 bool RawRunHeader::setTail(){
197  EXECUTE_FUNCTION(setMarkerHi )(rawruntail::Marker_value[0]);
198  EXECUTE_FUNCTION(setMarkerLo )(rawruntail::Marker_value[1]);
199  EXECUTE_FUNCTION(setReserved1)(rawruntail::Marker_value[2]);
200  RETURN_FUNCTION(setReserved2)(rawruntail::Marker_value[3]);
201 }
202 
203 //------------------------------------------------------------------------------
204 bool RawRunHeader::close(){ RETURN_FUNCTION(setCRC)(calculateCheckSum(1));}
205 
206 //------------------------------------------------------------------------------
207 // Printing method
208 void RawRunHeader::print(std::ostream& os) const{
209 
210  os<<boost::format("RawRun Header-------------------------------------- version %d\n")
211  % getVersion();
212 
213  os<<boost::format(" RunNumber=%u") % EXECUTE_FUNCTION(getRunNumber)();
214  os<<boost::format(" RunType=%u") % EXECUTE_FUNCTION(getRunType)();
215  os<<boost::format(" ConfigIDX=%u") % EXECUTE_FUNCTION(getConfigIDX)();
216  os<<boost::format(" Partition=%u") % EXECUTE_FUNCTION(getPartition)();
217  os<<boost::format(" Subrun=%u") % EXECUTE_FUNCTION(getSubrun)();
218  os<<boost::format(" ConfigBlockSet=%u") % EXECUTE_FUNCTION(getConfigurationBlockSet)();
219  os<<boost::format(" RunControlVersion=%u") % EXECUTE_FUNCTION(getRunControlVersion)();
220  os<<boost::format(" RunControlID=%u") % EXECUTE_FUNCTION(getRunControlID)();
221  os<<boost::format(" DataLoggerVersion=%u") % EXECUTE_FUNCTION(getDataLoggerVersion)();
222  os<<boost::format(" DataLoggerID=%u") % EXECUTE_FUNCTION(getDataLoggerID)();
223  os<<boost::format(" RunStartTime=%u") % EXECUTE_FUNCTION(getRunStartTime)();
224  os<<boost::format(" SubRunStartTime=%u") % EXECUTE_FUNCTION(getSubRunStartTime)();
225  os<<boost::format(" SubRunEndTime=%u") % EXECUTE_FUNCTION(getSubRunEndTime )();
226  os<<boost::format(" RunEndTime=%u") % EXECUTE_FUNCTION(getRunEndTime)();
227  os<<boost::format(" TotalEvents=%u") % EXECUTE_FUNCTION(getTotalEvents)();
228  os<<boost::format(" UniversalEventStartLo=%u") % EXECUTE_FUNCTION(getUniversalEventStartLo)();
229  os<<boost::format(" UniversalEventStartHi=%u") % EXECUTE_FUNCTION(getUniversalEventStartHi)();
230  os<<boost::format(" UniversalEventEndLo=%u") % EXECUTE_FUNCTION(getUniversalEventEndLo)();
231  os<<boost::format(" UniversalEventEndHi=%u") % EXECUTE_FUNCTION(getUniversalEventEndHi)();
232  os<<boost::format(" RunSize=%u") % EXECUTE_FUNCTION(getRunSize)();
233  os<<boost::format(" TriggerVersion=%u") % EXECUTE_FUNCTION(getTriggerVersion)();
234  os<<boost::format(" TriggerCtrlID=%u") % EXECUTE_FUNCTION(getTriggerCtrlID)();
235  os<<boost::format(" TriggerMC=%u") % EXECUTE_FUNCTION(getTriggerMC)();
236  os<<boost::format(" VTMod=%u") % EXECUTE_FUNCTION(getVTMod)();
237  os<<boost::format(" ValidTriggerTypesLow=%u") % EXECUTE_FUNCTION(getValidTriggerTypesLow)();
238  os<<boost::format(" ValidTriggerTypesHigh=%u") % EXECUTE_FUNCTION(getValidTriggerTypesHigh)();
239  os<<boost::format(" ValidTriggerTypesHigh2=%u") % EXECUTE_FUNCTION(getValidTriggerTypesHigh2)();
240  os<<boost::format(" TriggerListIDX=%u") % EXECUTE_FUNCTION(getTriggerListIDX)();
241  os<<boost::format(" TriggerPrescaleListIDX=%u") % EXECUTE_FUNCTION(getTriggerPrescaleListIDX)();
242 
243  const uint32_t size_of_data = EXECUTE_FUNCTION(sizeofdata)();
244 
245  os<<"\nRAW:";
246  for(uint32_t i = 0; i < size_of_data; ++i){
247  os<<" ";
248  printWord(i,false, os);
249  }
250 
251  os<<"\nRAW:";
252  for(uint32_t i = 0; i < size_of_data; ++i){
253  if(i > 0)os<<" ";
254  printWord(i,true, os);
255  os<<"\n";
256  }
257 
258 }
259 
260 
261 }}// end of namespaces
#define ZEROOUT_FUNCTION(FUNC)
Definition: FunctionBind.h:52
#define DEEPCOPY_FUNCTION(FUNC)
Definition: FunctionBind.h:40
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
#define DEEPCOPY_GET_AND_SET(FUNC)
Definition: FunctionBind.h:44
RawRunHeader(const version_t)
The default constructor.
#define VERSION_NAMESPACE
void print(std::ostream &os=std::cout) const
#define ZEROOUT_GET(FUNC)
Definition: FunctionBind.h:53
#define DEEPCOPY_GET(FUNC)
Definition: FunctionBind.h:41
#define ZEROOUT_GET_AND_SET(FUNC)
Definition: FunctionBind.h:56
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
#define DEEPCOPY_SET(FUNC)
Definition: FunctionBind.h:43
#define ZEROOUT_SET(FUNC)
Definition: FunctionBind.h:55
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
const XML_Char * version
Definition: expat.h:187
int32_t version_t
Definition: RawDAQData.h:72
static const uint32_t Marker_value[4]
Class to hold the data from the FEBs in correct formats.
Float_t w
Definition: plot.C:20
procfile close()