]>
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 | |
636c1780 | 21 | class TChain; |
1fb5b4a8 | 22 | class AliRawEventHeaderBase; |
33314186 | 23 | class AliRawVEvent; |
a6e7b125 | 24 | |
a6e7b125 | 25 | class AliRawReader: public TObject { |
969d3431 | 26 | friend class AliEveEventManager; |
a6e7b125 | 27 | public : |
8de97894 | 28 | AliRawReader(); |
42d20574 | 29 | AliRawReader(const AliRawReader& rawReader); |
30 | AliRawReader& operator = (const AliRawReader& rawReader); | |
0cfe2438 | 31 | virtual ~AliRawReader(); |
8de97894 | 32 | |
43787b8e | 33 | static AliRawReader* Create(const char *uri); |
34 | ||
eb808725 | 35 | virtual void Select(Int_t detectorID, |
8de97894 | 36 | Int_t minDDLID = -1, Int_t maxDDLID = -1); |
eb808725 | 37 | virtual void Select(const char *detectorName, |
362c9d61 | 38 | Int_t minDDLID = -1, Int_t maxDDLID = -1); |
eb808725 | 39 | virtual void SelectEquipment(Int_t equipmentType, |
f224de6c | 40 | Int_t minEquipmentId = -1, |
41 | Int_t maxEquipmentId = -1); | |
eb808725 | 42 | virtual void SkipInvalid(Bool_t skip = kTRUE) |
39f9963f | 43 | {fSkipInvalid = skip;}; |
299738b9 | 44 | virtual void RequireHeader(Bool_t required) |
18882b3b | 45 | {fRequireHeader = required;}; |
a6e7b125 | 46 | |
1fb5b4a8 | 47 | virtual const AliRawEventHeaderBase* GetEventHeader() const {return NULL;}; |
33314186 | 48 | virtual const AliRawVEvent* GetEvent() const {return NULL;} |
1fb5b4a8 | 49 | |
42d20574 | 50 | virtual UInt_t GetType() const = 0; |
51 | virtual UInt_t GetRunNumber() const = 0; | |
52 | virtual const UInt_t* GetEventId() const = 0; | |
151bea4e | 53 | UInt_t GetPeriod() const { |
54 | const UInt_t *id = GetEventId(); | |
4bf6d23d | 55 | return id ? (((id)[0]>>4)&0x0fffffff): 0; |
151bea4e | 56 | } |
57 | UInt_t GetOrbitID() const { | |
58 | const UInt_t *id = GetEventId(); | |
4bf6d23d | 59 | return id ? ((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff)) : 0; |
151bea4e | 60 | } |
61 | UShort_t GetBCID() const { | |
62 | const UInt_t *id = GetEventId(); | |
4bf6d23d | 63 | return id ? ((id)[1]&0x00000fff) : 0; |
151bea4e | 64 | } |
42d20574 | 65 | virtual const UInt_t* GetTriggerPattern() const = 0; |
4bf6d23d | 66 | ULong64_t GetClassMask() const { |
67 | const UInt_t *pattern = GetTriggerPattern(); | |
68 | return pattern ? (((ULong64_t)pattern[1] & 0x3ffff) << 32)|(pattern[0]) : 0; | |
69 | } | |
42d20574 | 70 | virtual const UInt_t* GetDetectorPattern() const = 0; |
71 | virtual const UInt_t* GetAttributes() const = 0; | |
e94ad92c | 72 | virtual const UInt_t* GetSubEventAttributes() const = 0; |
c946ab02 | 73 | virtual UInt_t GetLDCId() const = 0; |
42d20574 | 74 | virtual UInt_t GetGDCId() const = 0; |
741c154c | 75 | virtual UInt_t GetTimestamp() const = 0; |
04fa961a | 76 | |
c946ab02 | 77 | virtual Int_t GetEquipmentSize() const = 0; |
78 | virtual Int_t GetEquipmentType() const = 0; | |
79 | virtual Int_t GetEquipmentId() const = 0; | |
0cfe2438 | 80 | Int_t GetMappedEquipmentId() const; |
81 | Bool_t LoadEquipmentIdsMap(const char *fileName); | |
c946ab02 | 82 | virtual const UInt_t* GetEquipmentAttributes() const = 0; |
83 | virtual Int_t GetEquipmentElementSize() const = 0; | |
299738b9 | 84 | virtual Int_t GetEquipmentHeaderSize() const = 0; |
a6e7b125 | 85 | |
0cfe2438 | 86 | Int_t GetDetectorID() const; |
87 | Int_t GetDDLID() const; | |
39f9963f | 88 | |
c946ab02 | 89 | Int_t GetDataSize() const |
527a1d3f | 90 | {if (fHeader) { |
91 | if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader); | |
299738b9 | 92 | else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeader); |
93 | } else return GetEquipmentSize() - GetEquipmentHeaderSize();}; | |
509a7696 | 94 | |
c946ab02 | 95 | Int_t GetVersion() const |
4e99539f | 96 | {if (fHeader) return fHeader->GetVersion(); else return -1;}; |
39f9963f | 97 | Bool_t IsValid() const |
98 | {if (fHeader) return fHeader->TestAttribute(0); | |
99 | else return kFALSE;}; | |
c946ab02 | 100 | Bool_t IsCompressed() const |
39f9963f | 101 | {if (fHeader) return fHeader->TestAttribute(1); |
c946ab02 | 102 | else return kFALSE;}; |
c3408d7d | 103 | Bool_t TestBlockAttribute(Int_t index) const |
104 | {if (fHeader) return fHeader->TestAttribute(index); | |
105 | else return kFALSE;}; | |
106 | UChar_t GetBlockAttributes() const | |
107 | {if (fHeader) return fHeader->GetAttributes(); | |
108 | else return 0;}; | |
f58b3254 | 109 | UInt_t GetStatusBits() const |
110 | {if (fHeader) return fHeader->GetStatus(); | |
111 | else return 0;}; | |
c3408d7d | 112 | const AliRawDataHeader* GetDataHeader() const |
113 | {return fHeader;} | |
c946ab02 | 114 | |
115 | virtual Bool_t ReadHeader() = 0; | |
8de97894 | 116 | virtual Bool_t ReadNextData(UChar_t*& data) = 0; |
117 | virtual Bool_t ReadNextInt(UInt_t& data); | |
118 | virtual Bool_t ReadNextShort(UShort_t& data); | |
119 | virtual Bool_t ReadNextChar(UChar_t& data); | |
bf22797a | 120 | virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0; |
8de97894 | 121 | |
122 | virtual Bool_t Reset() = 0; | |
a6e7b125 | 123 | |
dd9a70fe | 124 | virtual Bool_t NextEvent() = 0; |
125 | virtual Bool_t RewindEvents() = 0; | |
636c1780 | 126 | virtual Bool_t GotoEvent(Int_t event); |
66964465 | 127 | virtual Bool_t GotoEventWithID(Int_t event, |
128 | UInt_t period, | |
129 | UInt_t orbitID, | |
130 | UShort_t bcID); | |
636c1780 | 131 | virtual Int_t GetEventIndex() const { return -1; } |
25e82ff5 | 132 | virtual Int_t GetNumberOfEvents() const { return -1; } |
dd9a70fe | 133 | |
39f9963f | 134 | enum {kErrMagic=1, kErrNoDataHeader=2, |
135 | kErrSize=4, kErrOutOfBounds=8}; | |
b4857df7 | 136 | virtual Int_t CheckData() const; |
bea6b2a4 | 137 | Int_t GetErrorCode() const {return fErrorCode;}; |
b4857df7 | 138 | |
509a7696 | 139 | void DumpData(Int_t limit = -1); |
140 | ||
9fc249d9 | 141 | void AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level, |
142 | Int_t code, | |
38cf12f3 | 143 | const char *message = NULL); |
9fc249d9 | 144 | void AddMinorErrorLog(Int_t code, |
145 | const char *message = NULL) { | |
146 | return AddErrorLog(AliRawDataErrorLog::kMinor,code,message); | |
147 | } | |
148 | void AddMajorErrorLog(Int_t code, | |
149 | const char *message = NULL) { | |
150 | return AddErrorLog(AliRawDataErrorLog::kMajor,code,message); | |
151 | } | |
152 | void AddFatalErrorLog(Int_t code, | |
153 | const char *message = NULL) { | |
154 | return AddErrorLog(AliRawDataErrorLog::kFatal,code,message); | |
155 | } | |
38cf12f3 | 156 | Int_t GetNumberOfErrorLogs() const { return fErrorLogs.GetEntriesFast(); } |
79dac785 | 157 | const TClonesArray &GetAllErrorLogs() const { return fErrorLogs; } |
38cf12f3 | 158 | AliRawDataErrorLog *GetErrorLog(Int_t i) const { |
159 | return (AliRawDataErrorLog *)fErrorLogs.UncheckedAt(i); | |
160 | } | |
161 | ||
2d91a353 | 162 | // Method which can be used in order to force the auto-save on |
163 | // ESD tree inside AliReconstruction. For the moment it will be | |
164 | // activated only for AliRawReaderDateOnline. | |
165 | virtual Bool_t UseAutoSaveESD() const { return kFALSE; } | |
636c1780 | 166 | virtual TChain* GetChain() const { return NULL; } |
2d91a353 | 167 | |
a97af23d | 168 | Bool_t IsRawReaderValid() const { return fIsValid; } |
169 | ||
56918e2f | 170 | void LoadTriggerClass(const char* name, Int_t index); |
171 | ||
b900a426 | 172 | virtual AliRawReader* CloneSingleEvent() const { return NULL; } |
173 | ||
a6e7b125 | 174 | protected : |
56918e2f | 175 | virtual void SelectEvents(Int_t type, ULong64_t triggerMask = 0, const char *triggerExpr = NULL); |
42d20574 | 176 | Bool_t IsSelected() const; |
dd9a70fe | 177 | Bool_t IsEventSelected() const; |
a6e7b125 | 178 | |
0cfe2438 | 179 | TArrayI *fEquipmentIdsIn; // array of equipment Ids to be mapped |
180 | TArrayI *fEquipmentIdsOut; // array of mapped equipment Ids | |
18882b3b | 181 | |
0cfe2438 | 182 | Bool_t fRequireHeader; // if false, data without header is accepted |
183 | ||
184 | AliRawDataHeader* fHeader; // current data header | |
185 | Int_t fCount; // counter of bytes to be read for current DDL | |
a6e7b125 | 186 | |
f224de6c | 187 | Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection) |
188 | Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection) | |
189 | Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection) | |
0cfe2438 | 190 | Bool_t fSkipInvalid; // skip invalid data |
191 | Int_t fSelectEventType; // type of selected events (<0 = no selection) | |
00665a00 | 192 | ULong64_t fSelectTriggerMask; // trigger mask for selecting events (0 = no selection) |
56918e2f | 193 | TString fSelectTriggerExpr; // trigger expression for selecting events (empty = no selection) |
8de97894 | 194 | |
0cfe2438 | 195 | Int_t fErrorCode; // code of last error |
b4857df7 | 196 | |
38cf12f3 | 197 | Int_t fEventNumber; // current event number |
edd06192 | 198 | TClonesArray fErrorLogs; // raw data decoding errors |
199 | ||
200 | AliRawDataHeader* fHeaderSwapped; // temporary buffer for swapping header on PowerPC | |
38cf12f3 | 201 | |
91f76e9b | 202 | UInt_t SwapWord(UInt_t x) const; |
203 | UShort_t SwapShort(UShort_t x) const; | |
204 | ||
a97af23d | 205 | Bool_t fIsValid; // is raw-reader created successfully |
206 | ||
a6e7b125 | 207 | ClassDef(AliRawReader, 0) // base class for reading raw digits |
208 | }; | |
209 | ||
210 | #endif |