]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSRawStreamSPD.h
Code cleanup: elimination of hard coded numbers
[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
16
17 class AliITSRawStreamSPD: public AliITSRawStream {
18   public :
19     AliITSRawStreamSPD(AliRawReader* rawReader);
20     virtual ~AliITSRawStreamSPD() {};
21
22     virtual Bool_t   Next();
23     virtual Bool_t   ReadCalibHeader();
24
25     // the 2 methods below are equivalent to AliITSRawStream::GetCoord1 and GetCoord2
26     // together with the AliITSRawStream::GetModuleID these are the "offline" coordinates
27     Int_t    GetColumn() const {return fCoord1;};
28     Int_t    GetRow() const {return fCoord2;};
29
30     // together with the AliRawReader::GetDDLID() these are the "online" coordinates
31     UShort_t GetHalfStaveNr() const {return fHalfStaveNr;}
32     UShort_t GetChipAddr() const {return fChipAddr;}
33     Int_t    GetChipCol() const {return fCol;};
34     Int_t    GetChipRow() const {return fRow;};
35
36     // module mapping, iModule = halfStaveNr*2+chipAddr/5
37     static Int_t GetModuleNumber(UInt_t iDDL, UInt_t iModule) {return fgkDDLModuleMap[iDDL][iModule];}
38     
39     Bool_t GetHalfStavePresent(UInt_t hs);
40
41     // use the methods below to extract the information from the calibration header
42     UInt_t GetHrouterNr() const {return (fCalHeadWord[0] & 0x0000003f);}
43     Bool_t GetHhalfStaveScanned(UInt_t hs) const;
44     UInt_t GetHtype() const {return (Int_t)((fCalHeadWord[1]) & 0x000000ff);}
45     Bool_t GetHdataFormat() const {return (Bool_t)(((fCalHeadWord[1]) & 0x00000100)>>8);}
46     UInt_t GetHtriggers() const {return fCalHeadWord[2];}
47     Bool_t GetHchipPresent(UInt_t hs, UInt_t chip) const;
48     UInt_t GetHdacStart() const {return ((fCalHeadWord[5]>>24) & 0x000000ff);}
49     UInt_t GetHdacEnd() const {return ((fCalHeadWord[5]>>16) & 0x000000ff);}
50     UInt_t GetHdacStep() const {return ((fCalHeadWord[5]>>8) & 0x000000ff);}
51     UInt_t GetHdacId() const {return ((fCalHeadWord[5]) & 0x000000ff);}
52     UInt_t GetHrowStart() const {return (UInt_t) ((fCalHeadWord[6]>>24) & 0x000000ff);}
53     UInt_t GetHrowEnd() const {return (UInt_t) ((fCalHeadWord[6]>>16) & 0x000000ff);}
54     UInt_t GetHrowValue() const {return (UInt_t) ((fCalHeadWord[6]>> 8) & 0x000000ff);}
55     UInt_t GetHdacValue() const {return (Int_t) ((fCalHeadWord[6]) & 0x000000ff);}
56     UInt_t GetHdacHigh(UInt_t hs) const;
57     UInt_t GetHdacLow(UInt_t hs) const;
58     UInt_t GetHTPAmp(UInt_t hs) const;
59
60     enum {kDDLsNumber = 20};      // number of DDLs in SPD
61     enum {kModulesPerDDL = 12};   // number of modules in each DDL
62     enum {kCalHeadLenMax = 16};   // maximum number of calib header words
63     enum ESPDRawStreamError {
64       kCalHeaderLengthErr = 1,
65       kDDLNumberErr = 2,
66       kEventNumberErr = 3,
67       kChipAddrErr = 4,
68       kStaveNumberErr = 5,
69       kNumbHitsErr = 6,
70       kWrongWordErr = 7,
71       kHalfStaveStatusErr = 8
72     };
73
74   private :
75     static const Int_t fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL];  // mapping DDL/module -> module number
76
77     Bool_t           ReadNextShort();
78     Bool_t           ReadNextInt();
79     void             NewEvent();
80
81     Int_t            fEventNumber;                 // chip event counter
82     UShort_t         fChipAddr;                    // chip nr
83     UShort_t         fHalfStaveNr;                 // half stave nr
84     UInt_t           fCol;                         // chip column nr
85     UInt_t           fRow;                         // chip row nr
86     UInt_t           fCalHeadWord[kCalHeadLenMax]; // calibration header words
87
88     UShort_t         fData;            // 16 bit data word read
89     UInt_t           fOffset;          // offset for cell column
90     UInt_t           fHitCount;        // counter of hits
91     UChar_t          fDataChar1, fDataChar2, fDataChar3, fDataChar4; // temps part of a 32bit word
92     Bool_t           fFirstWord;       // keeps track of which of the two 16bit words out of the 32bit word to read when ReadNextShort is called
93     Bool_t           fCalHeadRead[20];             // calibration header read flags (reset at new event)
94     UInt_t           fPrevEventId;                 // previous event id (needed to know if there is a new event)
95
96     ClassDef(AliITSRawStreamSPD, 0) // class for reading ITS SPD raw digits
97 };
98
99 #endif