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