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