Line data Source code
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 "AliRawReader.h"
15 : #include "AliITSRawStream.h"
16 : #include "AliITSRawStreamSPDErrorLog.h"
17 :
18 : class AliITSRawStreamSPD: public AliITSRawStream {
19 : public :
20 : AliITSRawStreamSPD(AliRawReader* rawReader);
21 : AliITSRawStreamSPD(const AliITSRawStreamSPD& rstream);
22 : AliITSRawStreamSPD& operator=(const AliITSRawStreamSPD& rstream);
23 16 : virtual ~AliITSRawStreamSPD() {};
24 :
25 : virtual Bool_t Next();
26 : virtual Int_t ReadCalibHeader();
27 :
28 : // the 2 methods below are equivalent to AliITSRawStream::GetCoord1 and GetCoord2
29 : // together with the AliITSRawStream::GetModuleID these are the "offline" coordinates
30 0 : Int_t GetColumn() const {return fCoord1;};
31 0 : Int_t GetRow() const {return fCoord2;};
32 :
33 : // together with the AliRawReader::GetDDLID() these are the "online" coordinates
34 0 : UShort_t GetHalfStaveNr() const {return fHalfStaveNr;}
35 0 : UShort_t GetChipAddr() const {return fChipAddr;}
36 0 : Int_t GetChipCol() const {return fCol;};
37 0 : Int_t GetChipRow() const {return fRow;};
38 :
39 : // module mapping
40 : static Int_t GetModuleNumber(UInt_t iDDL, UInt_t iModule);
41 : static Int_t GetModuleNumber(UInt_t iDDL, UInt_t iHS, UInt_t iChip)
42 0 : {return GetOfflineModuleFromOnline(iDDL,iHS,iChip);}
43 :
44 : // coordinate conversions:
45 : 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);
46 : 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);
47 : // coordinate conversions - offline->online
48 : static UInt_t GetOnlineEqIdFromOffline(UInt_t module);
49 : static UInt_t GetOnlineHSFromOffline(UInt_t module);
50 : static UInt_t GetOnlineChipFromOffline(UInt_t module, UInt_t colM);
51 : static UInt_t GetOnlineColFromOffline(UInt_t module, UInt_t colM);
52 : static UInt_t GetOnlineRowFromOffline(UInt_t module, UInt_t rowM);
53 : // coordinate conversions - online->offline
54 : static UInt_t GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip);
55 : static UInt_t GetOfflineChipKeyFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip);
56 : static UInt_t GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col);
57 : static UInt_t GetOfflineRowFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t row);
58 :
59 : Bool_t GetFastOrSignal(UInt_t eq, UInt_t hs, UInt_t chip);
60 :
61 0 : Int_t GetEventCounter() const {return fEventCounter;} // get last read event counter value
62 : Short_t GetEventCounterFullEq(UInt_t eq) const;
63 : Short_t GetEventCounterFullHS(UInt_t eq, UInt_t hs) const;
64 : Short_t GetEventCounterFullChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
65 : Bool_t IsEventCounterFullConsistent() const;
66 :
67 : Bool_t IsActiveEq(UInt_t eq) const;
68 : Bool_t IsActiveHS(UInt_t eq, UInt_t hs) const;
69 : Bool_t IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
70 :
71 : Bool_t GetHalfStavePresent(UInt_t hs);
72 :
73 : Int_t GetHword(UInt_t index);
74 : // use the methods below to extract the information from the scan calibration header:
75 0 : UInt_t GetHrouterNr() const {return (fCalHeadWord[0] & 0x0000003f);}
76 : Bool_t GetHhalfStaveScanned(UInt_t hs) const;
77 0 : UInt_t GetHtype() const {return (Int_t)((fCalHeadWord[1]) & 0x000000ff);}
78 0 : Bool_t GetHdataFormat() const {return (Bool_t)(((fCalHeadWord[1]) & 0x00000100)>>8);}
79 0 : UInt_t GetHtriggers() const {return fCalHeadWord[2];}
80 : Bool_t GetHchipPresent(UInt_t hs, UInt_t chip) const;
81 0 : UInt_t GetHdacStart() const {return ((fCalHeadWord[5]>>24) & 0x000000ff);}
82 0 : UInt_t GetHdacEnd() const {return ((fCalHeadWord[5]>>16) & 0x000000ff);}
83 0 : UInt_t GetHdacStep() const {return ((fCalHeadWord[5]>>8) & 0x000000ff);}
84 0 : UInt_t GetHdacId() const {return ((fCalHeadWord[5]) & 0x000000ff);}
85 0 : UInt_t GetHrowStart() const {return (UInt_t) ((fCalHeadWord[6]>>24) & 0x000000ff);}
86 0 : UInt_t GetHrowEnd() const {return (UInt_t) ((fCalHeadWord[6]>>16) & 0x000000ff);}
87 0 : UInt_t GetHrowValue() const {return (UInt_t) ((fCalHeadWord[6]>> 8) & 0x000000ff);}
88 0 : UInt_t GetHrowSpan() const {return (UInt_t) ((fCalHeadWord[6]) & 0x000000ff);}
89 0 : UInt_t GetHdacValue() const {return (Int_t) ((fCalHeadWord[6]) & 0x000000ff);}
90 : UInt_t GetHdacHigh(UInt_t hs) const;
91 : UInt_t GetHdacLow(UInt_t hs) const;
92 : UInt_t GetHTPAmp(UInt_t hs) const;
93 : Bool_t GetHminTHchipPresent(UInt_t chip) const;
94 0 : UInt_t GetHglobalDBversion() const {return fCalHeadWord[16];}
95 : // use the methods below to extract the information from the fo calibration header:
96 0 : UInt_t GetFOHrouterNr() const {return GetHrouterNr();}
97 0 : UInt_t GetFOHtype() const {return GetHtype();}
98 0 : UInt_t GetFOHtriggers() const {return GetHtriggers();}
99 0 : Bool_t GetFOHchipPresent(UInt_t hs, UInt_t chip) const {return GetHchipPresent(hs,chip);}
100 0 : UInt_t GetFOHglobalDBversion() const {return fCalHeadWord[5];}
101 0 : UInt_t GetFOHMatrixID() const {return fCalHeadWord[6] & 0x0000000f;}
102 0 : UInt_t GetFOHpixelCol() const {return (fCalHeadWord[6] >> 20) & 0x0000001f;}
103 0 : UInt_t GetFOHpixelRow() const {return (fCalHeadWord[6] >> 10) & 0x000000ff;}
104 : UInt_t GetFOHnumDacs() const;
105 : UInt_t GetFOHdacIndex(UInt_t index) const;
106 : UInt_t GetFOHdacValue(UInt_t index) const;
107 : UInt_t GetFOHchipCount(UInt_t hs, UInt_t chip) const;
108 :
109 : void ActivateAdvancedErrorLog(Bool_t activate, AliITSRawStreamSPDErrorLog* advLogger = NULL);
110 0 : AliITSRawStreamSPDErrorLog* GetAdvancedErrorLog() {return fAdvLogger;}
111 :
112 : static const Char_t* GetErrorName(UInt_t errorCode);
113 :
114 : enum {kDDLsNumber = 20}; // number of DDLs in SPD
115 : enum {kModulesPerDDL = 12}; // number of modules in each DDL
116 : enum {kCalHeadLenMax = 64}; // maximum number of calib header words
117 : enum ESPDRawStreamError {
118 : kTotal,
119 : kHeaderMissingErr,
120 : kTrailerMissingErr,
121 : kTrailerWithoutHeaderErr,
122 : kHeaderCountErr,
123 : kTrailerCountErr,
124 : kFillUnexpectErr,
125 : kFillMissingErr,
126 : kWrongFillWordErr,
127 : kNumberHitsErr,
128 : kEventCounterErr,
129 : kDDLNumberErr,
130 : kHSNumberErr,
131 : kChipAddrErr,
132 : kCalHeaderLengthErr,
133 : kAdvEventCounterErr, // used by SPDmood
134 : kAdvEventCounterOrderErr,// used by SPDmood
135 : kTrailerErrorBitErr,
136 : kLinkRxDetectorFatalErr,
137 : kTSMtriggerErr,
138 : kHighMultiplicityFlag
139 : };
140 :
141 : private :
142 : static const Int_t fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL]; // mapping DDL/module -> module number
143 :
144 : Bool_t ReadNextShort();
145 : Bool_t ReadNextInt();
146 : void NewEvent();
147 : void CheckHeaderAndTrailerCount(Int_t ddlID);
148 :
149 : Int_t fEventCounter; // chip event counter
150 : Short_t fEventCounterFull[20][6][10]; // chip event counter
151 :
152 : UShort_t fChipAddr; // chip nr
153 : UShort_t fHalfStaveNr; // half stave nr
154 : UInt_t fCol; // chip column nr
155 : UInt_t fRow; // chip row nr
156 : UInt_t fCalHeadWord[kCalHeadLenMax]; // calibration header words
157 : UInt_t fCalHeadLen; // calibration header length
158 :
159 : UShort_t fData; // 16 bit data word read
160 : UInt_t fOffset; // offset for cell column
161 : UInt_t fHitCount; // counter of hits
162 : UChar_t fDataChar1, fDataChar2, fDataChar3, fDataChar4; // temps part of a 32bit word
163 : Bool_t fFirstWord; // keeps track of which of the two 16bit words out of the 32bit word to read when ReadNextShort is called
164 : Bool_t fCalHeadRead[20]; // calibration header read flags (reset at new event)
165 : UInt_t fPrevEventId; // previous event id (needed to know if there is a new event)
166 :
167 : UInt_t fEqPLBytesRead; // bytes read for current equipment payload
168 : UInt_t fEqPLChipHeadersRead; // number of chip headers found in current equipment payload
169 : UInt_t fEqPLChipTrailersRead; // number of chip trailers found in current equipment payload
170 : Bool_t fHeaderOrTrailerReadLast; // in previous words, was a header (true) or a trailer (false) read last
171 : UInt_t fExpectedHeaderTrailerCount; // expected number of headers and trailers for the current equipment payload
172 : Bool_t fFillOutOfSynch; // has a fill word been put in the wrong place?
173 : Int_t fDDLID; // ddl id
174 : Int_t fLastDDLID; // ddl id for equipment read in previous words
175 :
176 : Bool_t fAdvancedErrorLog; // is the advanced error logging activated?
177 : AliITSRawStreamSPDErrorLog *fAdvLogger; // pointer to special error logger object
178 :
179 : Bool_t fFastOrSignal[20][6][10]; // fastor signal bit (one per chip)
180 :
181 : Bool_t fActiveEq[20]; // which equipments are active (found in data)
182 : Bool_t fActiveHS[20][6]; // which half-staves are active (blockattribute bits)
183 : Bool_t fActiveChip[20][6][10]; // which chips are active (found in data)
184 :
185 118 : ClassDef(AliITSRawStreamSPD, 0) // class for reading ITS SPD raw digits
186 : };
187 :
188 : #endif
|