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