Export AliDAQ header file into include
[u/mrichter/AliRoot.git] / RAW / AliRawEventHeaderBase.h
... / ...
CommitLineData
1#ifndef ALIRAWEVENTHEADERBASE_H
2#define ALIRAWEVENTHEADERBASE_H
3
4// Author: Cvetan Cheshkov 10/10/2005
5
6/* Copyright(c) 1998-2005, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
8
9//////////////////////////////////////////////////////////////////////////
10// //
11// AliRawEventHeaderBase //
12// //
13//////////////////////////////////////////////////////////////////////////
14
15//#ifndef ROOT_TObject
16//#include <TObject.h>
17//#endif
18
19class AliRawEventHeaderBase : public TObject {
20
21public:
22 AliRawEventHeaderBase() { fSize=fMagic=fHeadSize=fVersion=fExtendedDataSize=0; fExtendedData = 0x0; fIsSwapped = kFALSE; }
23 virtual ~AliRawEventHeaderBase() { if (fExtendedData) delete [] fExtendedData; }
24
25 void *HeaderBaseBegin() { return (void *) &fSize; }
26 Int_t HeaderBaseSize() const { return (Long_t) &fVersion - (Long_t) &fSize + sizeof(fVersion); }
27 void *HeaderBegin();
28 Int_t HeaderSize() const;
29 Bool_t DataIsSwapped() const { return fIsSwapped; }
30 Bool_t IsSwapped() const { return (fMagic == fgkEventMagicNumberSwapped) ? kTRUE : kFALSE; }
31 Bool_t IsValid() const { return IsSwapped() ? kTRUE : ((fMagic == fgkEventMagicNumber) ? kTRUE : kFALSE); }
32 void Swap();
33
34 UInt_t GetEventSize() const { return fSize; }
35 UInt_t GetMagic() const { return fMagic; }
36 UInt_t GetHeadSize() const { return fHeadSize; }
37 UInt_t GetVersion() const { return fVersion; }
38 UInt_t GetMajorVersion() const { return ((fVersion>>16)&0x0000ffff); }
39 UInt_t GetMinorVersion() const { return (fVersion&0x0000ffff); }
40
41 UInt_t GetExtendedDataSize() const { return fExtendedDataSize; }
42 char* GetExtendedData() const { return fExtendedData; }
43 void SetExtendedDataSize(Int_t size) { fExtendedDataSize = size; }
44 void SetExtendedData(char *data) { fExtendedData = data; }
45
46 const char * GetTypeName();
47 static AliRawEventHeaderBase* Create(char*& data);
48 Int_t ReadHeader(char*& data);
49 UInt_t Get(const char *datamember);
50 const UInt_t* GetP(const char *datamember);
51
52 // The following enumeration can be used once the kEventTypeMask has been
53 // applied to the raw event type
54 enum EAliRawEventType {
55 kStartOfRun = 1, // START_OF_RUN
56 kEndOfRun = 2, // END_OF_RUN
57 kStartOfRunFiles = 3, // START_OF_RUN_FILES
58 kEndOfRunFiles = 4, // END_OF_RUN_FILES
59 kStartOfBurst = 5, // START_OF_BURST
60 kEndOfBurst = 6, // END_OF_BURST
61 kPhysicsEvent = 7, // PHYSICS_EVENT
62 kCalibrationEvent = 8, // CALIBRATION_EVENT
63 kFormatError = 9 // EVENT_FORMAT_ERROR
64 };
65
66private:
67 UInt_t fSize; // size of event in bytes
68 UInt_t fMagic; // magic number used for consistency check
69 UInt_t fHeadSize; // size of header in bytes
70 UInt_t fVersion; // unique version identifier
71
72 UInt_t fExtendedDataSize; // size of header extension data
73 char *fExtendedData; //[fExtendedDataSize] pointer to header extension data
74
75 Bool_t fIsSwapped; // is data swapped
76
77 static const UInt_t fgkEventMagicNumber = 0xDA1E5AFE; // magic word
78 static const UInt_t fgkEventMagicNumberSwapped = 0xFE5A1EDA; // swapped magic word
79
80 ClassDef(AliRawEventHeaderBase,1) // Alice raw event header base class
81};
82
83#define EVENT_HEADER_VERSION(AA,BB) AliRawEventHeaderV##AA##_##BB
84
85#define START_EVENT_HEADER(AA,BB) \
86class AliRawEventHeaderV##AA##_##BB:public AliRawEventHeaderBase { \
87public: \
88 AliRawEventHeaderV##AA##_##BB():AliRawEventHeaderBase() {}; \
89 virtual ~AliRawEventHeaderV##AA##_##BB() {}; \
90private:
91
92#define END_EVENT_HEADER(AA,BB) \
93ClassDef(AliRawEventHeaderV##AA##_##BB,1) \
94}; \
95ClassImp(AliRawEventHeaderV##AA##_##BB)
96
97#endif