New flat raw-data event format. The details can be found at: http://indico.cern.ch...
[u/mrichter/AliRoot.git] / RAW / AliRawEventHeaderBase.h
CommitLineData
f2dc6b20 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:
f3c1e83c 22 AliRawEventHeaderBase();
f2dc6b20 23 virtual ~AliRawEventHeaderBase() { if (fExtendedData) delete [] fExtendedData; }
24
33314186 25 void *HeaderBaseBegin() const { return (void *) &fSize; }
f2dc6b20 26 Int_t HeaderBaseSize() const { return (Long_t) &fVersion - (Long_t) &fSize + sizeof(fVersion); }
33314186 27 void *HeaderBegin() const;
f2dc6b20 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();
e653e3e1 33 UInt_t SwapWord(UInt_t x) const;
34 void SwapData(const void* data, const void* buf, UInt_t size);
f2dc6b20 35
36 UInt_t GetEventSize() const { return fSize; }
37 UInt_t GetMagic() const { return fMagic; }
38 UInt_t GetHeadSize() const { return fHeadSize; }
39 UInt_t GetVersion() const { return fVersion; }
40 UInt_t GetMajorVersion() const { return ((fVersion>>16)&0x0000ffff); }
41 UInt_t GetMinorVersion() const { return (fVersion&0x0000ffff); }
42
43 UInt_t GetExtendedDataSize() const { return fExtendedDataSize; }
44 char* GetExtendedData() const { return fExtendedData; }
f2dc6b20 45
12e921cc 46 const char * GetTypeName() const;
ec835ab5 47 static const char * GetTypeName(UInt_t eventType);
f2dc6b20 48 static AliRawEventHeaderBase* Create(char*& data);
33778962 49 void AllocateExtendedData(Int_t extsize);
f2dc6b20 50 Int_t ReadHeader(char*& data);
33778962 51 Int_t ReadExtendedData(char*& data);
11d31ad9 52 UInt_t Get(const char *datamember) const;
53 const UInt_t* GetP(const char *datamember) const;
f2dc6b20 54
12e921cc 55 void Print( const Option_t* opt ="" ) const;
56
33314186 57 Int_t GetFirstEqIndex() const { return fFirstEqIndex; }
58 Int_t GetLastEqIndex() const { return fLastEqIndex; }
59 void AddEqIndex(Int_t index);
60 void Reset();
61
f2dc6b20 62 // The following enumeration can be used once the kEventTypeMask has been
63 // applied to the raw event type
64 enum EAliRawEventType {
65 kStartOfRun = 1, // START_OF_RUN
66 kEndOfRun = 2, // END_OF_RUN
67 kStartOfRunFiles = 3, // START_OF_RUN_FILES
68 kEndOfRunFiles = 4, // END_OF_RUN_FILES
69 kStartOfBurst = 5, // START_OF_BURST
70 kEndOfBurst = 6, // END_OF_BURST
71 kPhysicsEvent = 7, // PHYSICS_EVENT
72 kCalibrationEvent = 8, // CALIBRATION_EVENT
9c8e7883 73 kFormatError = 9, // EVENT_FORMAT_ERROR
cce65444 74 kStartOfData = 10, // START_OF_DATA
9c8e7883 75 kEndOfData = 11, // END_OF_DATA
76 kSystemSoftwareTriggerEvent = 12, // SYSTEM_SOFTWARE_TRIGGER_EVENT
77 kDetectorSoftwareTriggerEvent = 13 // DETECTOR_SOFTWARE_TRIGGER_EVENT
f2dc6b20 78 };
79
80private:
f3c1e83c 81 AliRawEventHeaderBase(const AliRawEventHeaderBase&);
82 AliRawEventHeaderBase& operator=(const AliRawEventHeaderBase&);
83
f2dc6b20 84 UInt_t fSize; // size of event in bytes
85 UInt_t fMagic; // magic number used for consistency check
86 UInt_t fHeadSize; // size of header in bytes
87 UInt_t fVersion; // unique version identifier
88
89 UInt_t fExtendedDataSize; // size of header extension data
33778962 90 UInt_t fExtendedAllocSize;//! size of allocated memory for header extension data
f2dc6b20 91 char *fExtendedData; //[fExtendedDataSize] pointer to header extension data
92
93 Bool_t fIsSwapped; // is data swapped
936875a4 94 Int_t fHeaderSize; //! cache for the header size estimate
33314186 95 void *fHeaderBegin; //! cache for the header begin pointer
96
97 Int_t fFirstEqIndex; // index of the first equipment
98 Int_t fLastEqIndex; // index of the last equipment
f2dc6b20 99
100 static const UInt_t fgkEventMagicNumber = 0xDA1E5AFE; // magic word
101 static const UInt_t fgkEventMagicNumberSwapped = 0xFE5A1EDA; // swapped magic word
102
33314186 103 ClassDef(AliRawEventHeaderBase,4) // Alice raw event header base class
f2dc6b20 104};
105
3a27fc42 106#define EVENT_HEADER_VERSION(AA,BB) AliRawEventHeaderV##AA##_##BB
107
f2dc6b20 108#define START_EVENT_HEADER(AA,BB) \
3a27fc42 109class AliRawEventHeaderV##AA##_##BB:public AliRawEventHeaderBase { \
f2dc6b20 110public: \
3a27fc42 111 AliRawEventHeaderV##AA##_##BB():AliRawEventHeaderBase() {}; \
112 virtual ~AliRawEventHeaderV##AA##_##BB() {}; \
f2dc6b20 113private:
114
115#define END_EVENT_HEADER(AA,BB) \
3a27fc42 116ClassDef(AliRawEventHeaderV##AA##_##BB,1) \
f2dc6b20 117}; \
3a27fc42 118ClassImp(AliRawEventHeaderV##AA##_##BB)
f2dc6b20 119
120#endif