Adding a method to access the event timestamp - GetTimestamp(). The method does not...
[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"
8de97894 20
1fb5b4a8 21class AliRawEventHeaderBase;
a6e7b125 22
a6e7b125 23class 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
30 void Select(Int_t detectorID,
31 Int_t minDDLID = -1, Int_t maxDDLID = -1);
362c9d61 32 void Select(const char *detectorName,
33 Int_t minDDLID = -1, Int_t maxDDLID = -1);
f224de6c 34 void SelectEquipment(Int_t equipmentType,
35 Int_t minEquipmentId = -1,
36 Int_t maxEquipmentId = -1);
39f9963f 37 void SkipInvalid(Bool_t skip = kTRUE)
38 {fSkipInvalid = skip;};
dd9a70fe 39 void SelectEvents(Int_t type);
299738b9 40 virtual void RequireHeader(Bool_t required)
18882b3b 41 {fRequireHeader = required;};
a6e7b125 42
1fb5b4a8 43 virtual const AliRawEventHeaderBase* GetEventHeader() const {return NULL;};
44
42d20574 45 virtual UInt_t GetType() const = 0;
46 virtual UInt_t GetRunNumber() const = 0;
47 virtual const UInt_t* GetEventId() const = 0;
48 virtual const UInt_t* GetTriggerPattern() const = 0;
49 virtual const UInt_t* GetDetectorPattern() const = 0;
50 virtual const UInt_t* GetAttributes() const = 0;
e94ad92c 51 virtual const UInt_t* GetSubEventAttributes() const = 0;
c946ab02 52 virtual UInt_t GetLDCId() const = 0;
42d20574 53 virtual UInt_t GetGDCId() const = 0;
741c154c 54 virtual UInt_t GetTimestamp() const = 0;
04fa961a 55
c946ab02 56 virtual Int_t GetEquipmentSize() const = 0;
57 virtual Int_t GetEquipmentType() const = 0;
58 virtual Int_t GetEquipmentId() const = 0;
0cfe2438 59 Int_t GetMappedEquipmentId() const;
60 Bool_t LoadEquipmentIdsMap(const char *fileName);
c946ab02 61 virtual const UInt_t* GetEquipmentAttributes() const = 0;
62 virtual Int_t GetEquipmentElementSize() const = 0;
299738b9 63 virtual Int_t GetEquipmentHeaderSize() const = 0;
a6e7b125 64
0cfe2438 65 Int_t GetDetectorID() const;
66 Int_t GetDDLID() const;
39f9963f 67
c946ab02 68 Int_t GetDataSize() const
527a1d3f 69 {if (fHeader) {
70 if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader);
299738b9 71 else return GetEquipmentSize() - GetEquipmentHeaderSize() - sizeof(AliRawDataHeader);
72 } else return GetEquipmentSize() - GetEquipmentHeaderSize();};
509a7696 73
c946ab02 74 Int_t GetVersion() const
4e99539f 75 {if (fHeader) return fHeader->GetVersion(); else return -1;};
39f9963f 76 Bool_t IsValid() const
77 {if (fHeader) return fHeader->TestAttribute(0);
78 else return kFALSE;};
c946ab02 79 Bool_t IsCompressed() const
39f9963f 80 {if (fHeader) return fHeader->TestAttribute(1);
c946ab02 81 else return kFALSE;};
c3408d7d 82 Bool_t TestBlockAttribute(Int_t index) const
83 {if (fHeader) return fHeader->TestAttribute(index);
84 else return kFALSE;};
85 UChar_t GetBlockAttributes() const
86 {if (fHeader) return fHeader->GetAttributes();
87 else return 0;};
f58b3254 88 UInt_t GetStatusBits() const
89 {if (fHeader) return fHeader->GetStatus();
90 else return 0;};
c3408d7d 91 const AliRawDataHeader* GetDataHeader() const
92 {return fHeader;}
c946ab02 93
94 virtual Bool_t ReadHeader() = 0;
8de97894 95 virtual Bool_t ReadNextData(UChar_t*& data) = 0;
96 virtual Bool_t ReadNextInt(UInt_t& data);
97 virtual Bool_t ReadNextShort(UShort_t& data);
98 virtual Bool_t ReadNextChar(UChar_t& data);
bf22797a 99 virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0;
8de97894 100
101 virtual Bool_t Reset() = 0;
a6e7b125 102
dd9a70fe 103 virtual Bool_t NextEvent() = 0;
104 virtual Bool_t RewindEvents() = 0;
105
39f9963f 106 enum {kErrMagic=1, kErrNoDataHeader=2,
107 kErrSize=4, kErrOutOfBounds=8};
b4857df7 108 virtual Int_t CheckData() const;
bea6b2a4 109 Int_t GetErrorCode() const {return fErrorCode;};
b4857df7 110
509a7696 111 void DumpData(Int_t limit = -1);
112
9fc249d9 113 void AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level,
114 Int_t code,
38cf12f3 115 const char *message = NULL);
9fc249d9 116 void AddMinorErrorLog(Int_t code,
117 const char *message = NULL) {
118 return AddErrorLog(AliRawDataErrorLog::kMinor,code,message);
119 }
120 void AddMajorErrorLog(Int_t code,
121 const char *message = NULL) {
122 return AddErrorLog(AliRawDataErrorLog::kMajor,code,message);
123 }
124 void AddFatalErrorLog(Int_t code,
125 const char *message = NULL) {
126 return AddErrorLog(AliRawDataErrorLog::kFatal,code,message);
127 }
38cf12f3 128 Int_t GetNumberOfErrorLogs() const { return fErrorLogs.GetEntriesFast(); }
79dac785 129 const TClonesArray &GetAllErrorLogs() const { return fErrorLogs; }
38cf12f3 130 AliRawDataErrorLog *GetErrorLog(Int_t i) const {
131 return (AliRawDataErrorLog *)fErrorLogs.UncheckedAt(i);
132 }
133
a6e7b125 134 protected :
42d20574 135 Bool_t IsSelected() const;
dd9a70fe 136 Bool_t IsEventSelected() const;
a6e7b125 137
0cfe2438 138 TArrayI *fEquipmentIdsIn; // array of equipment Ids to be mapped
139 TArrayI *fEquipmentIdsOut; // array of mapped equipment Ids
18882b3b 140
0cfe2438 141 Bool_t fRequireHeader; // if false, data without header is accepted
142
143 AliRawDataHeader* fHeader; // current data header
144 Int_t fCount; // counter of bytes to be read for current DDL
a6e7b125 145
f224de6c 146 Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection)
147 Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection)
148 Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection)
0cfe2438 149 Bool_t fSkipInvalid; // skip invalid data
150 Int_t fSelectEventType; // type of selected events (<0 = no selection)
8de97894 151
0cfe2438 152 Int_t fErrorCode; // code of last error
b4857df7 153
38cf12f3 154 Int_t fEventNumber; // current event number
155 TClonesArray fErrorLogs; // raw data decoding errors
156
a6e7b125 157 ClassDef(AliRawReader, 0) // base class for reading raw digits
158};
159
160#endif