]>
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(); | |
4bf6d23d | 52 | return id ? (((id)[0]>>4)&0x0fffffff): 0; |
151bea4e | 53 | } |
54 | UInt_t GetOrbitID() const { | |
55 | const UInt_t *id = GetEventId(); | |
4bf6d23d | 56 | return id ? ((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)) : 0; |
151bea4e | 57 | } |
58 | UShort_t GetBCID() const { | |
59 | const UInt_t *id = GetEventId(); | |
4bf6d23d | 60 | return id ? ((id)[1]&0x00000fff) : 0; |
151bea4e | 61 | } |
42d20574 | 62 | virtual const UInt_t* GetTriggerPattern() const = 0; |
4bf6d23d | 63 | ULong64_t GetClassMask() const { |
64 | const UInt_t *pattern = GetTriggerPattern(); | |
65 | return pattern ? (((ULong64_t)pattern[1] & 0x3ffff) << 32)|(pattern[0]) : 0; | |
66 | } | |
42d20574 | 67 | virtual const UInt_t* GetDetectorPattern() const = 0; |
68 | virtual const UInt_t* GetAttributes() const = 0; | |
e94ad92c | 69 | virtual const UInt_t* GetSubEventAttributes() const = 0; |
c946ab02 | 70 | virtual UInt_t GetLDCId() const = 0; |
42d20574 | 71 | virtual UInt_t GetGDCId() const = 0; |
741c154c | 72 | virtual UInt_t GetTimestamp() const = 0; |
04fa961a | 73 | |
c946ab02 | 74 | virtual Int_t GetEquipmentSize() const = 0; |
75 | virtual Int_t GetEquipmentType() const = 0; | |
76 | virtual Int_t GetEquipmentId() const = 0; | |
0cfe2438 | 77 | Int_t GetMappedEquipmentId() const; |
78 | Bool_t LoadEquipmentIdsMap(const char *fileName); | |
c946ab02 | 79 | virtual const UInt_t* GetEquipmentAttributes() const = 0; |
80 | virtual Int_t GetEquipmentElementSize() const = 0; | |
299738b9 | 81 | virtual Int_t GetEquipmentHeaderSize() const = 0; |
a6e7b125 | 82 | |
0cfe2438 | 83 | Int_t GetDetectorID() const; |
84 | Int_t GetDDLID() const; | |
39f9963f | 85 | |
c946ab02 | 86 | Int_t GetDataSize() const |
527a1d3f | 87 | {if (fHeader) { |
88 | if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader); | |
299738b9 | 89 | else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeader); |
90 | } else return GetEquipmentSize() - GetEquipmentHeaderSize();}; | |
509a7696 | 91 | |
c946ab02 | 92 | Int_t GetVersion() const |
4e99539f | 93 | {if (fHeader) return fHeader->GetVersion(); else return -1;}; |
39f9963f | 94 | Bool_t IsValid() const |
95 | {if (fHeader) return fHeader->TestAttribute(0); | |
96 | else return kFALSE;}; | |
c946ab02 | 97 | Bool_t IsCompressed() const |
39f9963f | 98 | {if (fHeader) return fHeader->TestAttribute(1); |
c946ab02 | 99 | else return kFALSE;}; |
c3408d7d | 100 | Bool_t TestBlockAttribute(Int_t index) const |
101 | {if (fHeader) return fHeader->TestAttribute(index); | |
102 | else return kFALSE;}; | |
103 | UChar_t GetBlockAttributes() const | |
104 | {if (fHeader) return fHeader->GetAttributes(); | |
105 | else return 0;}; | |
f58b3254 | 106 | UInt_t GetStatusBits() const |
107 | {if (fHeader) return fHeader->GetStatus(); | |
108 | else return 0;}; | |
c3408d7d | 109 | const AliRawDataHeader* GetDataHeader() const |
110 | {return fHeader;} | |
c946ab02 | 111 | |
112 | virtual Bool_t ReadHeader() = 0; | |
8de97894 | 113 | virtual Bool_t ReadNextData(UChar_t*& data) = 0; |
114 | virtual Bool_t ReadNextInt(UInt_t& data); | |
115 | virtual Bool_t ReadNextShort(UShort_t& data); | |
116 | virtual Bool_t ReadNextChar(UChar_t& data); | |
bf22797a | 117 | virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0; |
8de97894 | 118 | |
119 | virtual Bool_t Reset() = 0; | |
a6e7b125 | 120 | |
dd9a70fe | 121 | virtual Bool_t NextEvent() = 0; |
122 | virtual Bool_t RewindEvents() = 0; | |
123 | ||
39f9963f | 124 | enum {kErrMagic=1, kErrNoDataHeader=2, |
125 | kErrSize=4, kErrOutOfBounds=8}; | |
b4857df7 | 126 | virtual Int_t CheckData() const; |
bea6b2a4 | 127 | Int_t GetErrorCode() const {return fErrorCode;}; |
b4857df7 | 128 | |
509a7696 | 129 | void DumpData(Int_t limit = -1); |
130 | ||
9fc249d9 | 131 | void AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level, |
132 | Int_t code, | |
38cf12f3 | 133 | const char *message = NULL); |
9fc249d9 | 134 | void AddMinorErrorLog(Int_t code, |
135 | const char *message = NULL) { | |
136 | return AddErrorLog(AliRawDataErrorLog::kMinor,code,message); | |
137 | } | |
138 | void AddMajorErrorLog(Int_t code, | |
139 | const char *message = NULL) { | |
140 | return AddErrorLog(AliRawDataErrorLog::kMajor,code,message); | |
141 | } | |
142 | void AddFatalErrorLog(Int_t code, | |
143 | const char *message = NULL) { | |
144 | return AddErrorLog(AliRawDataErrorLog::kFatal,code,message); | |
145 | } | |
38cf12f3 | 146 | Int_t GetNumberOfErrorLogs() const { return fErrorLogs.GetEntriesFast(); } |
79dac785 | 147 | const TClonesArray &GetAllErrorLogs() const { return fErrorLogs; } |
38cf12f3 | 148 | AliRawDataErrorLog *GetErrorLog(Int_t i) const { |
149 | return (AliRawDataErrorLog *)fErrorLogs.UncheckedAt(i); | |
150 | } | |
151 | ||
2d91a353 | 152 | // Method which can be used in order to force the auto-save on |
153 | // ESD tree inside AliReconstruction. For the moment it will be | |
154 | // activated only for AliRawReaderDateOnline. | |
155 | virtual Bool_t UseAutoSaveESD() const { return kFALSE; } | |
156 | ||
a6e7b125 | 157 | protected : |
42d20574 | 158 | Bool_t IsSelected() const; |
dd9a70fe | 159 | Bool_t IsEventSelected() const; |
a6e7b125 | 160 | |
0cfe2438 | 161 | TArrayI *fEquipmentIdsIn; // array of equipment Ids to be mapped |
162 | TArrayI *fEquipmentIdsOut; // array of mapped equipment Ids | |
18882b3b | 163 | |
0cfe2438 | 164 | Bool_t fRequireHeader; // if false, data without header is accepted |
165 | ||
166 | AliRawDataHeader* fHeader; // current data header | |
167 | Int_t fCount; // counter of bytes to be read for current DDL | |
a6e7b125 | 168 | |
f224de6c | 169 | Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection) |
170 | Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection) | |
171 | Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection) | |
0cfe2438 | 172 | Bool_t fSkipInvalid; // skip invalid data |
173 | Int_t fSelectEventType; // type of selected events (<0 = no selection) | |
8de97894 | 174 | |
0cfe2438 | 175 | Int_t fErrorCode; // code of last error |
b4857df7 | 176 | |
38cf12f3 | 177 | Int_t fEventNumber; // current event number |
edd06192 | 178 | TClonesArray fErrorLogs; // raw data decoding errors |
179 | ||
180 | AliRawDataHeader* fHeaderSwapped; // temporary buffer for swapping header on PowerPC | |
38cf12f3 | 181 | |
91f76e9b | 182 | UInt_t SwapWord(UInt_t x) const; |
183 | UShort_t SwapShort(UShort_t x) const; | |
184 | ||
a6e7b125 | 185 | ClassDef(AliRawReader, 0) // base class for reading raw digits |
186 | }; | |
187 | ||
188 | #endif |