]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSRawStreamSPD.h
068dd86243d184cf17198c15fe6995512b1beaf7
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSPD.h
1 #ifndef ALIITSRAWSTREAMSPD_H
2 #define ALIITSRAWSTREAMSPD_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 class provides access to ITS SPD digits in raw data.
11 ///
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include "AliITSRawStream.h"
15 #include "AliITSRawStreamSPDErrorLog.h"
16
17 class AliITSRawStreamSPD: public AliITSRawStream {
18   public :
19     AliITSRawStreamSPD(AliRawReader* rawReader);
20     AliITSRawStreamSPD(const AliITSRawStreamSPD& rstream);
21     AliITSRawStreamSPD& operator=(const AliITSRawStreamSPD& rstream);
22     virtual ~AliITSRawStreamSPD() {};
23
24     virtual Bool_t   Next();
25     virtual Int_t   ReadCalibHeader();
26
27     // the 2 methods below are equivalent to AliITSRawStream::GetCoord1 and GetCoord2
28     // together with the AliITSRawStream::GetModuleID these are the "offline" coordinates
29     Int_t    GetColumn() const {return fCoord1;};
30     Int_t    GetRow() const {return fCoord2;};
31
32     // together with the AliRawReader::GetDDLID() these are the "online" coordinates
33     UShort_t GetHalfStaveNr() const {return fHalfStaveNr;}
34     UShort_t GetChipAddr() const {return fChipAddr;}
35     Int_t    GetChipCol() const {return fCol;};
36     Int_t    GetChipRow() const {return fRow;};
37
38     // module mapping
39     static Int_t GetModuleNumber(UInt_t iDDL, UInt_t iModule);
40     static Int_t GetModuleNumber(UInt_t iDDL, UInt_t iHS, UInt_t iChip) 
41       {return GetOfflineModuleFromOnline(iDDL,iHS,iChip);}
42
43     // coordinate conversions:
44     static Bool_t OfflineToOnline(UInt_t module, UInt_t colM, UInt_t RowM, UInt_t& eq, UInt_t& hs, UInt_t& chip, UInt_t& col, UInt_t& row);
45     static Bool_t OnlineToOffline(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row, UInt_t& module, UInt_t& colM, UInt_t& rowM);
46     // coordinate conversions - offline->online
47     static UInt_t GetOnlineEqIdFromOffline(UInt_t module);
48     static UInt_t GetOnlineHSFromOffline(UInt_t module);
49     static UInt_t GetOnlineChipFromOffline(UInt_t module, UInt_t colM);
50     static UInt_t GetOnlineColFromOffline(UInt_t module, UInt_t colM);
51     static UInt_t GetOnlineRowFromOffline(UInt_t module, UInt_t rowM);
52     // coordinate conversions - online->offline
53     static UInt_t GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip);
54     static UInt_t GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col);
55     static UInt_t GetOfflineRowFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t row);
56
57
58     Bool_t GetHalfStavePresent(UInt_t hs);
59
60     // use the methods below to extract the information from the calibration header
61     UInt_t GetHrouterNr() const {return (fCalHeadWord[0] & 0x0000003f);}
62     Bool_t GetHhalfStaveScanned(UInt_t hs) const;
63     UInt_t GetHtype() const {return (Int_t)((fCalHeadWord[1]) & 0x000000ff);}
64     Bool_t GetHdataFormat() const {return (Bool_t)(((fCalHeadWord[1]) & 0x00000100)>>8);}
65     UInt_t GetHtriggers() const {return fCalHeadWord[2];}
66     Bool_t GetHchipPresent(UInt_t hs, UInt_t chip) const;
67     UInt_t GetHdacStart() const {return ((fCalHeadWord[5]>>24) & 0x000000ff);}
68     UInt_t GetHdacEnd() const {return ((fCalHeadWord[5]>>16) & 0x000000ff);}
69     UInt_t GetHdacStep() const {return ((fCalHeadWord[5]>>8) & 0x000000ff);}
70     UInt_t GetHdacId() const {return ((fCalHeadWord[5]) & 0x000000ff);}
71     UInt_t GetHrowStart() const {return (UInt_t) ((fCalHeadWord[6]>>24) & 0x000000ff);}
72     UInt_t GetHrowEnd() const {return (UInt_t) ((fCalHeadWord[6]>>16) & 0x000000ff);}
73     UInt_t GetHrowValue() const {return (UInt_t) ((fCalHeadWord[6]>> 8) & 0x000000ff);}
74     UInt_t GetHdacValue() const {return (Int_t) ((fCalHeadWord[6]) & 0x000000ff);}
75     UInt_t GetHdacHigh(UInt_t hs) const;
76     UInt_t GetHdacLow(UInt_t hs) const;
77     UInt_t GetHTPAmp(UInt_t hs) const;
78     Bool_t GetHminTHchipPresent(UInt_t chip) const;
79     void   ActivateAdvancedErrorLog(Bool_t activate, AliITSRawStreamSPDErrorLog* advLogger = NULL);
80     static const Char_t* GetErrorName(UInt_t errorCode);
81
82
83     enum {kDDLsNumber = 20};      // number of DDLs in SPD
84     enum {kModulesPerDDL = 12};   // number of modules in each DDL
85     enum {kCalHeadLenMax = 16};   // maximum number of calib header words
86     enum ESPDRawStreamError {
87       kTotal,
88       kHeaderMissingErr,
89       kTrailerMissingErr,
90       kTrailerWithoutHeaderErr,
91       kHeaderCountErr,
92       kTrailerCountErr,
93       kFillUnexpectErr,
94       kFillMissingErr,
95       kWrongFillWordErr,
96       kNumberHitsErr,
97       kEventCounterErr,
98       kDDLNumberErr,
99       kHSNumberErr,
100       kChipAddrErr,
101       kCalHeaderLengthErr
102     };
103
104   private :
105     static const Int_t fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL];  // mapping DDL/module -> module number
106
107     Bool_t      ReadNextShort();
108     Bool_t      ReadNextInt();
109     void        NewEvent();
110     void        CheckHeaderAndTrailerCount(Int_t ddlID);
111
112     Int_t       fEventCounter;                // chip event counter
113     UShort_t    fChipAddr;                    // chip nr
114     UShort_t    fHalfStaveNr;                 // half stave nr
115     UInt_t      fCol;                         // chip column nr
116     UInt_t      fRow;                         // chip row nr
117     UInt_t      fCalHeadWord[kCalHeadLenMax]; // calibration header words
118                 
119     UShort_t    fData;            // 16 bit data word read
120     UInt_t      fOffset;          // offset for cell column
121     UInt_t      fHitCount;        // counter of hits
122     UChar_t     fDataChar1, fDataChar2, fDataChar3, fDataChar4; // temps part of a 32bit word
123     Bool_t      fFirstWord;       // keeps track of which of the two 16bit words out of the 32bit word to read when ReadNextShort is called
124     Bool_t      fCalHeadRead[20];            // calibration header read flags (reset at new event)
125     UInt_t      fPrevEventId;                // previous event id (needed to know if there is a new event)
126
127     UInt_t      fEqPLBytesRead;              // bytes read for current equipment payload
128     UInt_t      fEqPLChipHeadersRead;        // number of chip headers found in current equipment payload
129     UInt_t      fEqPLChipTrailersRead;       // number of chip trailers found in current equipment payload
130     Bool_t      fHeaderOrTrailerReadLast;    // in previous words, was a header (true) or a trailer (false) read last
131     UInt_t      fExpectedHeaderTrailerCount; // expected number of headers and trailers for the current equipment payload
132     Bool_t      fFillOutOfSynch;             // has a fill word been put in the wrong place?
133     Int_t       fDDLID;                      // ddl id 
134     Int_t       fLastDDLID;                  // ddl id for equipment read in previous words
135
136     Bool_t      fAdvancedErrorLog;           // is the advanced error logging activated?
137     AliITSRawStreamSPDErrorLog *fAdvLogger;  // pointer to special error logger object
138
139     ClassDef(AliITSRawStreamSPD, 0) // class for reading ITS SPD raw digits
140 };
141
142 #endif