3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ///////////////////////////////////////////////////////////////////////////////
10 /// This is the base class for reading raw data.
12 ///////////////////////////////////////////////////////////////////////////////
15 #include "AliRawDataHeader.h"
18 class AliRawReader: public TObject {
21 AliRawReader(const AliRawReader& rawReader);
22 AliRawReader& operator = (const AliRawReader& rawReader);
23 virtual ~AliRawReader() {};
25 void Select(Int_t detectorID,
26 Int_t minDDLID = -1, Int_t maxDDLID = -1);
27 void SelectEquipment(Int_t equipmentType,
28 Int_t minEquipmentId = -1,
29 Int_t maxEquipmentId = -1);
30 void SkipInvalid(Bool_t skip = kTRUE)
31 {fSkipInvalid = skip;};
32 void SelectEvents(Int_t type);
34 virtual UInt_t GetType() const = 0;
35 virtual UInt_t GetRunNumber() const = 0;
36 virtual const UInt_t* GetEventId() const = 0;
37 virtual const UInt_t* GetTriggerPattern() const = 0;
38 virtual const UInt_t* GetDetectorPattern() const = 0;
39 virtual const UInt_t* GetAttributes() const = 0;
40 virtual const UInt_t* GetSubEventAttributes() const = 0;
41 virtual UInt_t GetLDCId() const = 0;
42 virtual UInt_t GetGDCId() const = 0;
44 virtual Int_t GetEquipmentSize() const = 0;
45 virtual Int_t GetEquipmentType() const = 0;
46 virtual Int_t GetEquipmentId() const = 0;
47 virtual const UInt_t* GetEquipmentAttributes() const = 0;
48 virtual Int_t GetEquipmentElementSize() const = 0;
50 Int_t GetDetectorID() const
51 {if (GetEquipmentId() >= 0) return (GetEquipmentId() >> 8); else return -1;};
52 Int_t GetDDLID() const
53 {if (GetEquipmentId() >= 0) return (GetEquipmentId() & 0xFF); else return -1;};
55 Int_t GetDataSize() const
56 {if (fHeader) return fHeader->fSize - sizeof(AliRawDataHeader);
57 else return GetEquipmentSize();};
59 Int_t GetVersion() const
60 {if (fHeader) return fHeader->fVersion; else return -1;};
61 Bool_t IsValid() const
62 {if (fHeader) return fHeader->TestAttribute(0);
64 Bool_t IsCompressed() const
65 {if (fHeader) return fHeader->TestAttribute(1);
67 Bool_t TestBlockAttribute(Int_t index) const
68 {if (fHeader) return fHeader->TestAttribute(index);
70 UChar_t GetBlockAttributes() const
71 {if (fHeader) return fHeader->GetAttributes();
73 UInt_t GetStatusBits() const
74 {if (fHeader) return fHeader->GetStatus();
76 const AliRawDataHeader* GetDataHeader() const
79 virtual Bool_t ReadHeader() = 0;
80 virtual Bool_t ReadNextData(UChar_t*& data) = 0;
81 virtual Bool_t ReadNextInt(UInt_t& data);
82 virtual Bool_t ReadNextShort(UShort_t& data);
83 virtual Bool_t ReadNextChar(UChar_t& data);
85 virtual Bool_t Reset() = 0;
87 virtual Bool_t NextEvent() = 0;
88 virtual Bool_t RewindEvents() = 0;
90 enum {kErrMagic=1, kErrNoDataHeader=2,
91 kErrSize=4, kErrOutOfBounds=8};
92 virtual Int_t CheckData() const;
93 Int_t GetErrorCode() const {return fErrorCode;};
95 void DumpData(Int_t limit = -1);
98 Bool_t IsSelected() const;
99 Bool_t IsEventSelected() const;
101 virtual Bool_t ReadNext(UChar_t* data, Int_t size) = 0;
103 AliRawDataHeader* fHeader; // current data header
104 Int_t fCount; // counter of bytes to be read for current DDL
106 Int_t fSelectEquipmentType; // type of selected equipment (<0 = no selection)
107 Int_t fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection)
108 Int_t fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection)
109 Bool_t fSkipInvalid; // skip invalid data
110 Int_t fSelectEventType; // type of selected events (<0 = no selection)
112 Int_t fErrorCode; // code of last error
114 ClassDef(AliRawReader, 0) // base class for reading raw digits