]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliAltroRawStream.h
Add the number of local boards
[u/mrichter/AliRoot.git] / RAW / AliAltroRawStream.h
1 #ifndef ALIALTRORAWSTREAM_H
2 #define ALIALTRORAWSTREAM_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 a base class for reading raw data digits in Altro format
11 /// The class is able to read both old and new RCU trailer formats
12 /// One can switch between formats using fIsOldRCUFormat flag.
13 /// In case the Common Data Header is 7 32-bit words long, one
14 /// can use the fIsShortDataHeader flag.
15 ///
16 ///////////////////////////////////////////////////////////////////////////////
17
18 #include <TObject.h>
19
20 class AliRawReader;
21
22 class AliAltroRawStream: public TObject {
23   public :
24     AliAltroRawStream(AliRawReader* rawReader);
25     virtual ~AliAltroRawStream();
26
27     virtual void             Reset();
28     virtual Bool_t           Next();
29
30     Int_t GetDDLNumber()  const { return fDDLNumber; }  // Provide current DDL number
31     Int_t GetPrevDDLNumber() const { return fPrevDDLNumber; }// Provide previous DDL number
32     Bool_t  IsNewDDLNumber() const {return (fDDLNumber != fPrevDDLNumber);};
33     Int_t GetRCUId()      const { return fRCUId; }      // Provide current RCU identifier
34     Int_t GetPrevRCUId()  const { return fPrevRCUId; }  // Provide previous RCU identifier
35     Bool_t  IsNewRCUId() const {return (fRCUId != fPrevRCUId);};
36     Int_t GetHWAddress()  const { return fHWAddress; }  // Provide current hardware address
37     Int_t GetPrevHWAddress() const { return fPrevHWAddress; }  // Provide previous hardware address
38     Bool_t  IsNewHWAddress() const {return (fHWAddress != fPrevHWAddress) || IsNewDDLNumber();};
39     Int_t GetTime()       const { return fTime; }       // Provide index of current time bin
40     Int_t GetPrevTime()   const { return fPrevTime; }   // Provide index of previous time bin
41     Bool_t  IsNewTime()   const {return (fTime != fPrevTime) || IsNewHWAddress();};
42     Int_t GetSignal()     const { return fSignal; }     // Provide signal in ADC counts
43     Int_t GetTimeLength() const { return fTimeBunch; }  // Provide total length of current time bunch
44
45     Int_t GetBranch()     const; // Provide the branch index for the current hardware address
46     Int_t GetFEC()        const; // Provide the front-end card index for the current hardware address
47     Int_t GetAltro()      const; // Provide the altro chip index for the current hardware address
48     Int_t GetChannel()    const; // Provide the channel index for the current hardware address
49
50     Bool_t  GetRCUTrailerData(UChar_t*& data) const;              // Provide a pointer to RCU trailer
51     Int_t   GetRCUTrailerSize() const { return fRCUTrailerSize; } // Provide size of RCU trailer
52
53     void SelectRawData(Int_t detId);                           // Select raw data for specific detector id
54     void SelectRawData(const char *detName);                   // Select raw data for specific detector name
55
56     void  SetNoAltroMapping(Bool_t flag) { fNoAltroMapping = flag; }  // Specify whenever to use or not the altro mapping
57     void  SetOldRCUFormat(Bool_t flag)   { fIsOldRCUFormat = flag; }  // Specify whenever to use or not the old RCU trailer format
58     void  SetShortDataHeader(Bool_t flag) { fIsShortDataHeader = flag; } // Specify whenever to assume or not a short CDH format
59
60     void PrintDebug() const; // Print debug information in case of decoding errors
61     void AddMappingErrorLog(const char *message = NULL);
62
63     enum EAltroRawStreamError {
64       kRCUTrailerSizeErr = 1,
65       kAltroTrailerErr = 2,
66       kBunchLengthReadErr = 3,
67       kTimeBinReadErr = 4,
68       kAmplitudeReadErr = 5,
69       k32bitWordReadErr = 6,
70       kBadAltroMapping = 7
71     };
72
73     AliAltroRawStream& operator = (const AliAltroRawStream& stream);
74     AliAltroRawStream(const AliAltroRawStream& stream);
75
76   protected:
77
78     Bool_t           fNoAltroMapping;  // temporary flag in case of no altro mapping is provided
79     Short_t          fSegmentation[3]; // temporary container for the dummy trailer, to be removed
80
81     Bool_t           fIsOldRCUFormat;  // flag used to select between old and new RCU trailer format
82     Bool_t           fIsShortDataHeader; // flag used to select between normal and short CDH format
83
84   private :
85
86     UShort_t         GetNextWord();
87     Bool_t           ReadTrailer();
88     Bool_t           ReadDummyTrailer();
89     void             ReadBunch();
90     void             ReadAmplitude();
91     Int_t            GetPosition();
92     UInt_t           Get32bitWord(Int_t &index);
93
94     Int_t            fDDLNumber;    // index of current DDL number
95     Int_t            fPrevDDLNumber;// index of previous DDL number
96     Int_t            fRCUId;        // current RCU identifier
97     Int_t            fPrevRCUId;    // previous RCU identifier
98     Short_t          fHWAddress;    // current hardware address
99     Short_t          fPrevHWAddress;// previous hardware address
100     Int_t            fTime;         // index of current time bin
101     Int_t            fPrevTime;     // index of previous time bin
102     Int_t            fSignal;       // signal in ADC counts
103     Int_t            fTimeBunch;    // total length of the current time bunch
104
105     AliRawReader*    fRawReader;    // object for reading the raw data
106
107
108     UChar_t*         fData;         // raw data
109
110     Int_t            fPosition;     // current (10 bit) position in fData
111     Int_t            fCount;        // counter of words to be read for current trailer
112     Int_t            fBunchLength;  // remaining number of signal bins in the current bunch
113
114     UChar_t*         fRCUTrailerData; // pointer to RCU trailer data
115     Int_t            fRCUTrailerSize; // size of RCU trailer data in bytes
116
117     ClassDef(AliAltroRawStream, 0)  // base class for reading Altro raw digits
118 };
119
120 #endif