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