]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliRawReader.h
added low and high flux parameters to the array
[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
636c1780 21class TChain;
1fb5b4a8 22class AliRawEventHeaderBase;
a6e7b125 23
a6e7b125 24class AliRawReader: public TObject {
25 public :
8de97894 26 AliRawReader();
42d20574 27 AliRawReader(const AliRawReader& rawReader);
28 AliRawReader& operator = (const AliRawReader& rawReader);
0cfe2438 29 virtual ~AliRawReader();
8de97894 30
43787b8e 31 static AliRawReader* Create(const char *uri);
32
eb808725 33 virtual void Select(Int_t detectorID,
8de97894 34 Int_t minDDLID = -1, Int_t maxDDLID = -1);
eb808725 35 virtual void Select(const char *detectorName,
362c9d61 36 Int_t minDDLID = -1, Int_t maxDDLID = -1);
eb808725 37 virtual void SelectEquipment(Int_t equipmentType,
f224de6c 38 Int_t minEquipmentId = -1,
39 Int_t maxEquipmentId = -1);
eb808725 40 virtual void SkipInvalid(Bool_t skip = kTRUE)
39f9963f 41 {fSkipInvalid = skip;};
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;
636c1780 123 virtual Bool_t GotoEvent(Int_t event);
124 virtual Int_t GetEventIndex() const { return -1; }
25e82ff5 125 virtual Int_t GetNumberOfEvents() const { return -1; }
dd9a70fe 126
39f9963f 127 enum {kErrMagic=1, kErrNoDataHeader=2,
128 kErrSize=4, kErrOutOfBounds=8};
b4857df7 129 virtual Int_t CheckData() const;
bea6b2a4 130 Int_t GetErrorCode() const {return fErrorCode;};
b4857df7 131
509a7696 132 void DumpData(Int_t limit = -1);
133
9fc249d9 134 void AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level,
135 Int_t code,
38cf12f3 136 const char *message = NULL);
9fc249d9 137 void AddMinorErrorLog(Int_t code,
138 const char *message = NULL) {
139 return AddErrorLog(AliRawDataErrorLog::kMinor,code,message);
140 }
141 void AddMajorErrorLog(Int_t code,
142 const char *message = NULL) {
143 return AddErrorLog(AliRawDataErrorLog::kMajor,code,message);
144 }
145 void AddFatalErrorLog(Int_t code,
146 const char *message = NULL) {
147 return AddErrorLog(AliRawDataErrorLog::kFatal,code,message);
148 }
38cf12f3 149 Int_t GetNumberOfErrorLogs() const { return fErrorLogs.GetEntriesFast(); }
79dac785 150 const TClonesArray &GetAllErrorLogs() const { return fErrorLogs; }
38cf12f3 151 AliRawDataErrorLog *GetErrorLog(Int_t i) const {
152 return (AliRawDataErrorLog *)fErrorLogs.UncheckedAt(i);
153 }
154
2d91a353 155 // Method which can be used in order to force the auto-save on
156 // ESD tree inside AliReconstruction. For the moment it will be
157 // activated only for AliRawReaderDateOnline.
158 virtual Bool_t UseAutoSaveESD() const { return kFALSE; }
636c1780 159 virtual TChain* GetChain() const { return NULL; }
2d91a353 160
a97af23d 161 Bool_t IsRawReaderValid() const { return fIsValid; }
162
a6e7b125 163 protected :
3f7450e0 164 virtual void SelectEvents(Int_t type, ULong64_t triggerMask = 0);
42d20574 165 Bool_t IsSelected() const;
dd9a70fe 166 Bool_t IsEventSelected() const;
a6e7b125 167
0cfe2438 168 TArrayI *fEquipmentIdsIn; // array of equipment Ids to be mapped
169 TArrayI *fEquipmentIdsOut; // array of mapped equipment Ids
18882b3b 170
0cfe2438 171 Bool_t fRequireHeader; // if false, data without header is accepted
172
173 AliRawDataHeader* fHeader; // current data header
174 Int_t fCount; // counter of bytes to be read for current DDL
a6e7b125 175
f224de6c 176 Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection)
177 Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection)
178 Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection)
0cfe2438 179 Bool_t fSkipInvalid; // skip invalid data
180 Int_t fSelectEventType; // type of selected events (<0 = no selection)
00665a00 181 ULong64_t fSelectTriggerMask; // trigger mask for selecting events (0 = no selection)
8de97894 182
0cfe2438 183 Int_t fErrorCode; // code of last error
b4857df7 184
38cf12f3 185 Int_t fEventNumber; // current event number
edd06192 186 TClonesArray fErrorLogs; // raw data decoding errors
187
188 AliRawDataHeader* fHeaderSwapped; // temporary buffer for swapping header on PowerPC
38cf12f3 189
91f76e9b 190 UInt_t SwapWord(UInt_t x) const;
191 UShort_t SwapShort(UShort_t x) const;
192
a97af23d 193 Bool_t fIsValid; // is raw-reader created successfully
194
a6e7b125 195 ClassDef(AliRawReader, 0) // base class for reading raw digits
196};
197
198#endif