]>
Commit | Line | Data |
---|---|---|
a6e7b125 | 1 | #ifndef ALIRAWREADER_H |
2 | #define ALIRAWREADER_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
bea6b2a4 | 6 | /* $Id$ */ |
7 | ||
8 | /////////////////////////////////////////////////////////////////////////////// | |
9 | /// | |
10 | /// This is the base class for reading raw data. | |
11 | /// | |
12 | /////////////////////////////////////////////////////////////////////////////// | |
13 | ||
a6e7b125 | 14 | #include <TObject.h> |
0cfe2438 | 15 | #include <TArrayI.h> |
38cf12f3 | 16 | #include <TClonesArray.h> |
17 | ||
18 | #include "AliRawDataErrorLog.h" | |
39f9963f | 19 | #include "AliRawDataHeader.h" |
8de97894 | 20 | |
1fb5b4a8 | 21 | class AliRawEventHeaderBase; |
a6e7b125 | 22 | |
a6e7b125 | 23 | class AliRawReader: public TObject { |
24 | public : | |
8de97894 | 25 | AliRawReader(); |
42d20574 | 26 | AliRawReader(const AliRawReader& rawReader); |
27 | AliRawReader& operator = (const AliRawReader& rawReader); | |
0cfe2438 | 28 | virtual ~AliRawReader(); |
8de97894 | 29 | |
43787b8e | 30 | static AliRawReader* Create(const char *uri); |
31 | ||
eb808725 | 32 | virtual void Select(Int_t detectorID, |
8de97894 | 33 | Int_t minDDLID = -1, Int_t maxDDLID = -1); |
eb808725 | 34 | virtual void Select(const char *detectorName, |
362c9d61 | 35 | Int_t minDDLID = -1, Int_t maxDDLID = -1); |
eb808725 | 36 | virtual void SelectEquipment(Int_t equipmentType, |
f224de6c | 37 | Int_t minEquipmentId = -1, |
38 | Int_t maxEquipmentId = -1); | |
eb808725 | 39 | virtual void SkipInvalid(Bool_t skip = kTRUE) |
39f9963f | 40 | {fSkipInvalid = skip;}; |
eb808725 | 41 | virtual void SelectEvents(Int_t type); |
299738b9 | 42 | virtual void RequireHeader(Bool_t required) |
18882b3b | 43 | {fRequireHeader = required;}; |
a6e7b125 | 44 | |
1fb5b4a8 | 45 | virtual const AliRawEventHeaderBase* GetEventHeader() const {return NULL;}; |
46 | ||
42d20574 | 47 | virtual UInt_t GetType() const = 0; |
48 | virtual UInt_t GetRunNumber() const = 0; | |
49 | virtual const UInt_t* GetEventId() const = 0; | |
151bea4e | 50 | UInt_t GetPeriod() const { |
51 | const UInt_t *id = GetEventId(); | |
52 | return (((id)[0]>>4)&0x0fffffff); | |
53 | } | |
54 | UInt_t GetOrbitID() const { | |
55 | const UInt_t *id = GetEventId(); | |
56 | return ((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)); | |
57 | } | |
58 | UShort_t GetBCID() const { | |
59 | const UInt_t *id = GetEventId(); | |
60 | return ((id)[1]&0x00000fff); | |
61 | } | |
42d20574 | 62 | virtual const UInt_t* GetTriggerPattern() const = 0; |
63 | virtual const UInt_t* GetDetectorPattern() const = 0; | |
64 | virtual const UInt_t* GetAttributes() const = 0; | |
e94ad92c | 65 | virtual const UInt_t* GetSubEventAttributes() const = 0; |
c946ab02 | 66 | virtual UInt_t GetLDCId() const = 0; |
42d20574 | 67 | virtual UInt_t GetGDCId() const = 0; |
741c154c | 68 | virtual UInt_t GetTimestamp() const = 0; |
04fa961a | 69 | |
c946ab02 | 70 | virtual Int_t GetEquipmentSize() const = 0; |
71 | virtual Int_t GetEquipmentType() const = 0; | |
72 | virtual Int_t GetEquipmentId() const = 0; | |
0cfe2438 | 73 | Int_t GetMappedEquipmentId() const; |
74 | Bool_t LoadEquipmentIdsMap(const char *fileName); | |
c946ab02 | 75 | virtual const UInt_t* GetEquipmentAttributes() const = 0; |
76 | virtual Int_t GetEquipmentElementSize() const = 0; | |
299738b9 | 77 | virtual Int_t GetEquipmentHeaderSize() const = 0; |
a6e7b125 | 78 | |
0cfe2438 | 79 | Int_t GetDetectorID() const; |
80 | Int_t GetDDLID() const; | |
39f9963f | 81 | |
c946ab02 | 82 | Int_t GetDataSize() const |
527a1d3f | 83 | {if (fHeader) { |
84 | if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader); | |
299738b9 | 85 | else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeader); |
86 | } else return GetEquipmentSize() - GetEquipmentHeaderSize();}; | |
509a7696 | 87 | |
c946ab02 | 88 | Int_t GetVersion() const |
4e99539f | 89 | {if (fHeader) return fHeader->GetVersion(); else return -1;}; |
39f9963f | 90 | Bool_t IsValid() const |
91 | {if (fHeader) return fHeader->TestAttribute(0); | |
92 | else return kFALSE;}; | |
c946ab02 | 93 | Bool_t IsCompressed() const |
39f9963f | 94 | {if (fHeader) return fHeader->TestAttribute(1); |
c946ab02 | 95 | else return kFALSE;}; |
c3408d7d | 96 | Bool_t TestBlockAttribute(Int_t index) const |
97 | {if (fHeader) return fHeader->TestAttribute(index); | |
98 | else return kFALSE;}; | |
99 | UChar_t GetBlockAttributes() const | |
100 | {if (fHeader) return fHeader->GetAttributes(); | |
101 | else return 0;}; | |
f58b3254 | 102 | UInt_t GetStatusBits() const |
103 | {if (fHeader) return fHeader->GetStatus(); | |
104 | else return 0;}; | |
c3408d7d | 105 | const AliRawDataHeader* GetDataHeader() const |
106 | {return fHeader;} | |
c946ab02 | 107 | |
108 | virtual Bool_t ReadHeader() = 0; | |
8de97894 | 109 | virtual Bool_t ReadNextData(UChar_t*& data) = 0; |
110 | virtual Bool_t ReadNextInt(UInt_t& data); | |
111 | virtual Bool_t ReadNextShort(UShort_t& data); | |
112 | virtual Bool_t ReadNextChar(UChar_t& data); | |
bf22797a | 113 | virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0; |
8de97894 | 114 | |
115 | virtual Bool_t Reset() = 0; | |
a6e7b125 | 116 | |
dd9a70fe | 117 | virtual Bool_t NextEvent() = 0; |
118 | virtual Bool_t RewindEvents() = 0; | |
119 | ||
39f9963f | 120 | enum {kErrMagic=1, kErrNoDataHeader=2, |
121 | kErrSize=4, kErrOutOfBounds=8}; | |
b4857df7 | 122 | virtual Int_t CheckData() const; |
bea6b2a4 | 123 | Int_t GetErrorCode() const {return fErrorCode;}; |
b4857df7 | 124 | |
509a7696 | 125 | void DumpData(Int_t limit = -1); |
126 | ||
9fc249d9 | 127 | void AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level, |
128 | Int_t code, | |
38cf12f3 | 129 | const char *message = NULL); |
9fc249d9 | 130 | void AddMinorErrorLog(Int_t code, |
131 | const char *message = NULL) { | |
132 | return AddErrorLog(AliRawDataErrorLog::kMinor,code,message); | |
133 | } | |
134 | void AddMajorErrorLog(Int_t code, | |
135 | const char *message = NULL) { | |
136 | return AddErrorLog(AliRawDataErrorLog::kMajor,code,message); | |
137 | } | |
138 | void AddFatalErrorLog(Int_t code, | |
139 | const char *message = NULL) { | |
140 | return AddErrorLog(AliRawDataErrorLog::kFatal,code,message); | |
141 | } | |
38cf12f3 | 142 | Int_t GetNumberOfErrorLogs() const { return fErrorLogs.GetEntriesFast(); } |
79dac785 | 143 | const TClonesArray &GetAllErrorLogs() const { return fErrorLogs; } |
38cf12f3 | 144 | AliRawDataErrorLog *GetErrorLog(Int_t i) const { |
145 | return (AliRawDataErrorLog *)fErrorLogs.UncheckedAt(i); | |
146 | } | |
147 | ||
a6e7b125 | 148 | protected : |
42d20574 | 149 | Bool_t IsSelected() const; |
dd9a70fe | 150 | Bool_t IsEventSelected() const; |
a6e7b125 | 151 | |
0cfe2438 | 152 | TArrayI *fEquipmentIdsIn; // array of equipment Ids to be mapped |
153 | TArrayI *fEquipmentIdsOut; // array of mapped equipment Ids | |
18882b3b | 154 | |
0cfe2438 | 155 | Bool_t fRequireHeader; // if false, data without header is accepted |
156 | ||
157 | AliRawDataHeader* fHeader; // current data header | |
158 | Int_t fCount; // counter of bytes to be read for current DDL | |
a6e7b125 | 159 | |
f224de6c | 160 | Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection) |
161 | Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection) | |
162 | Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection) | |
0cfe2438 | 163 | Bool_t fSkipInvalid; // skip invalid data |
164 | Int_t fSelectEventType; // type of selected events (<0 = no selection) | |
8de97894 | 165 | |
0cfe2438 | 166 | Int_t fErrorCode; // code of last error |
b4857df7 | 167 | |
38cf12f3 | 168 | Int_t fEventNumber; // current event number |
edd06192 | 169 | TClonesArray fErrorLogs; // raw data decoding errors |
170 | ||
171 | AliRawDataHeader* fHeaderSwapped; // temporary buffer for swapping header on PowerPC | |
38cf12f3 | 172 | |
91f76e9b | 173 | UInt_t SwapWord(UInt_t x) const; |
174 | UShort_t SwapShort(UShort_t x) const; | |
175 | ||
a6e7b125 | 176 | ClassDef(AliRawReader, 0) // base class for reading raw digits |
177 | }; | |
178 | ||
179 | #endif |