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