]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliRawReader.h
Avoid redeclaration of HEPEVT (Mac)
[u/mrichter/AliRoot.git] / RAW / AliRawReader.h
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
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////////
9 ///
10 /// This is the base class for reading raw data.
11 ///
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include <TObject.h>
15 #include "AliRawDataHeader.h"
16
17
18 class AliRawReader: public TObject {
19   public :
20     AliRawReader();
21     AliRawReader(const AliRawReader& rawReader);
22     AliRawReader& operator = (const AliRawReader& rawReader);
23     virtual ~AliRawReader() {};
24
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);
33     void             RequireHeader(Bool_t required = kTRUE)
34       {fRequireHeader = required;};
35
36     virtual UInt_t   GetType() const = 0;
37     virtual UInt_t   GetRunNumber() const = 0;
38     virtual const UInt_t* GetEventId() const = 0;
39     virtual const UInt_t* GetTriggerPattern() const = 0;
40     virtual const UInt_t* GetDetectorPattern() const = 0;
41     virtual const UInt_t* GetAttributes() const = 0;
42     virtual const UInt_t* GetSubEventAttributes() const = 0;
43     virtual UInt_t   GetLDCId() const = 0;
44     virtual UInt_t   GetGDCId() const = 0;
45
46     virtual Int_t    GetEquipmentSize() const = 0;
47     virtual Int_t    GetEquipmentType() const = 0;
48     virtual Int_t    GetEquipmentId() const = 0;
49     virtual const UInt_t* GetEquipmentAttributes() const = 0;
50     virtual Int_t    GetEquipmentElementSize() const = 0;
51
52     Int_t            GetDetectorID() const 
53       {if (GetEquipmentId() >= 0) return (GetEquipmentId() >> 8); else return -1;};
54     Int_t            GetDDLID() const 
55       {if (GetEquipmentId() >= 0) return (GetEquipmentId() & 0xFF); else return -1;};
56
57     Int_t            GetDataSize() const 
58       {if (fHeader) {
59         if (fHeader->fSize != 0xFFFFFFFF) return fHeader->fSize - sizeof(AliRawDataHeader); 
60         else return GetEquipmentSize() - sizeof(AliRawDataHeader);
61       } else return GetEquipmentSize();};
62
63     Int_t            GetVersion() const 
64       {if (fHeader) return fHeader->fVersion; else return -1;};
65     Bool_t           IsValid() const 
66       {if (fHeader) return fHeader->TestAttribute(0); 
67       else return kFALSE;};
68     Bool_t           IsCompressed() const 
69       {if (fHeader) return fHeader->TestAttribute(1); 
70       else return kFALSE;};
71     Bool_t           TestBlockAttribute(Int_t index) const
72       {if (fHeader) return fHeader->TestAttribute(index); 
73       else return kFALSE;};
74     UChar_t          GetBlockAttributes() const 
75       {if (fHeader) return fHeader->GetAttributes(); 
76       else return 0;};
77     UInt_t           GetStatusBits() const
78       {if (fHeader) return fHeader->GetStatus(); 
79       else return 0;};
80     const AliRawDataHeader* GetDataHeader() const
81       {return fHeader;}
82
83     virtual Bool_t   ReadHeader() = 0;
84     virtual Bool_t   ReadNextData(UChar_t*& data) = 0;
85     virtual Bool_t   ReadNextInt(UInt_t& data);
86     virtual Bool_t   ReadNextShort(UShort_t& data);
87     virtual Bool_t   ReadNextChar(UChar_t& data);
88     virtual Bool_t   ReadNext(UChar_t* data, Int_t size) = 0;
89
90     virtual Bool_t   Reset() = 0;
91
92     virtual Bool_t   NextEvent() = 0;
93     virtual Bool_t   RewindEvents() = 0;
94
95     enum {kErrMagic=1, kErrNoDataHeader=2, 
96           kErrSize=4, kErrOutOfBounds=8};
97     virtual Int_t    CheckData() const;
98     Int_t            GetErrorCode() const {return fErrorCode;};
99
100     void             DumpData(Int_t limit = -1);
101
102   protected :
103     Bool_t           IsSelected() const;
104     Bool_t           IsEventSelected() const;
105
106     Bool_t           fRequireHeader; // if false, data without header is accepted
107
108     AliRawDataHeader* fHeader;     // current data header
109     Int_t            fCount;       // counter of bytes to be read for current DDL
110
111     Int_t            fSelectEquipmentType;  // type of selected equipment (<0 = no selection)
112     Int_t            fSelectMinEquipmentId; // minimal index of selected equipment (<0 = no selection)
113     Int_t            fSelectMaxEquipmentId; // maximal index of selected equipment (<0 = no selection)
114     Bool_t           fSkipInvalid;       // skip invalid data
115     Int_t            fSelectEventType;   // type of selected events (<0 = no selection)
116
117     Int_t            fErrorCode;         // code of last error
118
119     ClassDef(AliRawReader, 0) // base class for reading raw digits
120 };
121
122 #endif