]>
Commit | Line | Data |
---|---|---|
2906f4c2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides access to ITS SPD digits in raw data. | |
21 | /// | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliITSRawStreamSPD.h" | |
25 | #include "AliRawReader.h" | |
26 | ||
27 | ClassImp(AliITSRawStreamSPD) | |
28 | ||
29 | ||
c42b9ed0 | 30 | // this map has to change, waiting for the new geometry |
2906f4c2 | 31 | const Int_t AliITSRawStreamSPD::fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL] = { |
32 | { 0, 1, 4, 5, 80, 81, 84, 85, 88, 89, 92, 93}, | |
2906f4c2 | 33 | { 8, 9,12,13, 96, 97,100,101,104,105,108,109}, |
2906f4c2 | 34 | {16,17,20,21,112,113,116,117,120,121,124,125}, |
2906f4c2 | 35 | {24,25,28,29,128,129,132,133,136,137,140,141}, |
2906f4c2 | 36 | {32,33,36,37,144,145,148,149,152,153,156,157}, |
2906f4c2 | 37 | {40,41,44,45,160,161,164,165,168,169,172,173}, |
2906f4c2 | 38 | {48,49,52,53,176,177,180,181,184,185,188,189}, |
2906f4c2 | 39 | {56,57,60,61,192,193,196,197,200,201,204,205}, |
2906f4c2 | 40 | {64,65,68,69,208,209,212,213,216,217,220,221}, |
2906f4c2 | 41 | {72,73,76,77,224,225,228,229,232,233,236,237}, |
72600597 | 42 | { 2, 3, 6, 7, 82, 83, 86, 87, 90, 91, 94, 95}, |
43 | {10,11,14,15, 98, 99,102,103,106,107,110,111}, | |
44 | {18,19,22,23,114,115,118,119,122,123,126,127}, | |
45 | {26,27,30,31,130,131,134,135,138,139,142,143}, | |
46 | {34,35,38,39,146,147,150,151,154,155,158,159}, | |
47 | {42,43,46,47,162,163,166,167,170,171,174,175}, | |
48 | {50,51,54,55,178,179,182,183,186,187,190,191}, | |
49 | {58,59,62,63,194,195,198,199,202,203,206,207}, | |
50 | {66,67,70,71,210,211,214,215,218,219,222,223}, | |
2906f4c2 | 51 | {74,75,78,79,226,227,230,231,234,235,238,239} |
52 | }; | |
53 | ||
54 | ||
55 | AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) : | |
56 | AliITSRawStream(rawReader), | |
c42b9ed0 | 57 | fEventNumber(-1),fChipAddr(0),fHalfStaveNr(0), |
58 | fData(0),fOffset(0),fHitCount(0), | |
59 | fDataChar1(0),fDataChar2(0),fDataChar3(0),fDataChar4(0), | |
60 | fFirstWord(kTRUE),fPrevEventId(0xffffffff) | |
2906f4c2 | 61 | { |
c42b9ed0 | 62 | // create an object to read ITS SPD raw digits |
362c9d61 | 63 | fRawReader->Select("ITSSPD"); |
c42b9ed0 | 64 | // reset calib header words |
65 | for (UInt_t iword=0; iword<kCalHeadLenMax; iword++) { | |
66 | fCalHeadWord[iword]=0xffffffff; | |
67 | } | |
68 | NewEvent(); | |
2906f4c2 | 69 | } |
70 | ||
72600597 | 71 | Bool_t AliITSRawStreamSPD::ReadNextShort() |
72 | { | |
c42b9ed0 | 73 | // read next 16 bit word into fData |
72600597 | 74 | if (fFirstWord) { |
72600597 | 75 | Bool_t b1 = fRawReader->ReadNextChar(fDataChar1); |
76 | if (!b1) return kFALSE; | |
77 | Bool_t b2, b3, b4; | |
78 | b2 = fRawReader->ReadNextChar(fDataChar2); | |
79 | b3 = fRawReader->ReadNextChar(fDataChar3); | |
80 | b4 = fRawReader->ReadNextChar(fDataChar4); | |
81 | if (!(b2 && b3 && b4)) { | |
82 | return kFALSE; | |
83 | } | |
84 | fData = fDataChar3+(fDataChar4<<8); | |
c42b9ed0 | 85 | if ((*fRawReader->GetEventId())!=fPrevEventId) { // if new event... |
86 | NewEvent(); | |
87 | fPrevEventId=(*fRawReader->GetEventId()); | |
88 | } | |
89 | fFirstWord=kFALSE; | |
72600597 | 90 | } |
91 | else { | |
92 | fFirstWord=kTRUE; | |
93 | fData = fDataChar1+(fDataChar2<<8); | |
94 | } | |
95 | ||
96 | return kTRUE; | |
97 | } | |
98 | ||
c42b9ed0 | 99 | Bool_t AliITSRawStreamSPD::ReadNextInt() |
72600597 | 100 | { |
c42b9ed0 | 101 | // reads next 32 bit into fDataChar1..4 |
102 | // (if first 16 bits read already, just completes the present word) | |
103 | if (fFirstWord) { | |
104 | if (ReadNextShort() && ReadNextShort()) { | |
105 | return kTRUE; | |
106 | } | |
107 | } | |
108 | else { | |
109 | if (ReadNextShort()) { | |
110 | return kTRUE; | |
111 | } | |
112 | } | |
113 | return kFALSE; | |
114 | } | |
115 | ||
116 | void AliITSRawStreamSPD::NewEvent() | |
117 | { | |
118 | // call this to reset flags for a new event | |
119 | for (UInt_t eqId=0; eqId<20; eqId++) { | |
120 | fCalHeadRead[eqId]=kFALSE; | |
121 | } | |
122 | fEventNumber=-1; | |
123 | } | |
124 | ||
125 | Bool_t AliITSRawStreamSPD::ReadCalibHeader() | |
126 | { | |
127 | // read the extra calibration header | |
128 | // returns kTRUE if the header is present and has length > 0 | |
72600597 | 129 | |
c42b9ed0 | 130 | Int_t ddlID = fRawReader->GetDDLID(); |
131 | if (ddlID==-1) { // we may need to read one word to get the blockAttr | |
132 | if (!ReadNextShort()) return kFALSE; | |
133 | ddlID = fRawReader->GetDDLID(); | |
134 | } | |
72600597 | 135 | UChar_t attr = fRawReader->GetBlockAttributes(); |
c42b9ed0 | 136 | if (ddlID>=0 && ddlID<20) fCalHeadRead[ddlID]=kTRUE; |
72600597 | 137 | if ((attr & 0x40) == 0x40) { // is the header present? |
c42b9ed0 | 138 | if (ReadNextInt()) { |
72600597 | 139 | // length of cal header: |
140 | UInt_t calLen = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24); | |
c42b9ed0 | 141 | if (calLen>kCalHeadLenMax) { |
142 | Error("ReadCalibHeader", "Header length problem. %d > %d (max)",calLen,kCalHeadLenMax); | |
143 | return kFALSE; | |
144 | } | |
145 | else if (calLen>0) { | |
146 | for (UInt_t iword=0; iword<calLen; iword++) { | |
147 | if (ReadNextInt()) { | |
148 | fCalHeadWord[iword] = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24); | |
149 | } | |
150 | else { | |
151 | Error("ReadCalibHeader", "header length problem"); | |
152 | return kFALSE; | |
153 | } | |
154 | } | |
155 | return kTRUE; | |
72600597 | 156 | } |
157 | } | |
158 | } | |
c42b9ed0 | 159 | |
160 | return kFALSE; | |
72600597 | 161 | } |
2906f4c2 | 162 | |
163 | Bool_t AliITSRawStreamSPD::Next() | |
164 | { | |
165 | // read the next raw digit | |
166 | // returns kFALSE if there is no digit left | |
167 | ||
c42b9ed0 | 168 | Int_t ddlID=-1; |
2906f4c2 | 169 | fPrevModuleID = fModuleID; |
c42b9ed0 | 170 | |
72600597 | 171 | while (ReadNextShort()) { |
c42b9ed0 | 172 | |
173 | ddlID = fRawReader->GetDDLID(); | |
174 | if (ddlID>=0 && ddlID<20) { | |
175 | if (!fCalHeadRead[ddlID]) { | |
176 | ReadCalibHeader(); | |
177 | } | |
178 | } | |
179 | else { | |
180 | Error("Next", "DDL number error (= %d) , setting it to 19", ddlID); | |
181 | ddlID=19; | |
182 | } | |
183 | ||
72600597 | 184 | if ((fData & 0xC000) == 0x4000) { // header |
2906f4c2 | 185 | fHitCount = 0; |
186 | UShort_t eventNumber = (fData >> 4) & 0x007F; | |
187 | if (fEventNumber < 0) { | |
188 | fEventNumber = eventNumber; | |
72600597 | 189 | } |
190 | else if (eventNumber != fEventNumber) { | |
c42b9ed0 | 191 | Error("Next", "mismatching event numbers: %d != %d", |
2906f4c2 | 192 | eventNumber, fEventNumber); |
193 | } | |
c42b9ed0 | 194 | fChipAddr = fData & 0x000F; |
195 | if (fChipAddr>9) { | |
196 | Error("Next", "overflow chip addr (= %d) , setting it to 9", fChipAddr); | |
197 | fChipAddr=9; | |
2906f4c2 | 198 | } |
c42b9ed0 | 199 | fHalfStaveNr = (fData & 0x3800)>>11; |
200 | if (fHalfStaveNr>5 || fRawReader->TestBlockAttribute(fHalfStaveNr)) { | |
201 | Error("Next", "half stave number error(=%d) , setting it to 5", fHalfStaveNr); | |
202 | fHalfStaveNr=5; | |
2906f4c2 | 203 | } |
c42b9ed0 | 204 | // translate ("online") ddl, hs, chip nr to ("offline") module id : |
205 | fModuleID = fgkDDLModuleMap[ddlID][fHalfStaveNr*2+fChipAddr/5]; | |
206 | fOffset = 32 * (fChipAddr % 5); | |
72600597 | 207 | } |
208 | else if ((fData & 0xC000) == 0x0000) { // trailer | |
2906f4c2 | 209 | UShort_t hitCount = fData & 0x1FFF; |
210 | if (hitCount != fHitCount) Error("Next", "wrong number of hits: %d != %d", fHitCount, hitCount); | |
72600597 | 211 | } |
212 | else if ((fData & 0xC000) == 0x8000) { // pixel hit | |
2906f4c2 | 213 | fHitCount++; |
c42b9ed0 | 214 | fCol = (fData & 0x001F); |
215 | fRow = (fData >> 5) & 0x00FF; | |
216 | ||
217 | // translate ("online") chipcol, chiprow to ("offline") col (coord1), row (coord2): | |
218 | // This will change, waiting for new geometry!!! | |
219 | fCoord1 = fCol; | |
220 | // if (fModuleID < 80 && ddlID < 10) fCoord1=31-fCoord1; | |
221 | // else if (fModuleID >=80 && ddlID >=10) fCoord1=31-fCoord1; | |
222 | fCoord1 += fOffset; | |
223 | // if (ddlID>=10) fCoord1=159-fCoord1; | |
224 | fCoord2 = fRow; | |
225 | // if (fModuleID<80) fCoord2=255-fCoord2; | |
226 | ||
2906f4c2 | 227 | return kTRUE; |
72600597 | 228 | } |
229 | else { // fill word | |
2906f4c2 | 230 | if ((fData & 0xC000) != 0xC000) Error("Next", "wrong fill word!"); |
231 | } | |
232 | ||
233 | } | |
234 | ||
235 | return kFALSE; | |
236 | } | |
c42b9ed0 | 237 | |
238 | Bool_t AliITSRawStreamSPD::GetHalfStavePresent(UInt_t hs) { | |
239 | // Reads the half stave present status from the block attributes | |
240 | Int_t ddlID = fRawReader->GetDDLID(); | |
241 | if (ddlID==-1) { | |
242 | Warning("GetHalfStavePresent", "DDL ID = -1. Cannot read block attributes. Return kFALSE."); | |
243 | return kFALSE; | |
244 | } | |
245 | else { | |
246 | if (hs>=6) { | |
247 | Warning("GetHalfStavePresent", "HS >= 6 requested (%d). Return kFALSE.",hs); | |
248 | return kFALSE; | |
249 | } | |
250 | UChar_t attr = fRawReader->GetBlockAttributes(); | |
251 | if (((attr>>hs) & 0x01) == 0x01) { // bit set means not present | |
252 | return kFALSE; | |
253 | } | |
254 | else { | |
255 | return kTRUE; | |
256 | } | |
257 | } | |
258 | } | |
259 | ||
260 | Bool_t AliITSRawStreamSPD::GetHhalfStaveScanned(UInt_t hs) const { | |
261 | if (hs<6) return (Bool_t)((fCalHeadWord[0]>>(6+hs)) & (0x00000001)); | |
262 | else return kFALSE; | |
263 | } | |
264 | Bool_t AliITSRawStreamSPD::GetHchipPresent(UInt_t hs, UInt_t chip) const { | |
265 | if (hs<6 && chip<10) return ((( fCalHeadWord[hs/3+3]>>((hs%3)*10+chip)) & 0x00000001) == 1); | |
266 | else return kFALSE; | |
267 | } | |
268 | UInt_t AliITSRawStreamSPD::GetHdacHigh(UInt_t hs) const { | |
269 | if (hs<6) return (fCalHeadWord[hs/2+7]>>(24-16*(hs%2)) & 0x000000ff); | |
270 | else return 0; | |
271 | } | |
272 | UInt_t AliITSRawStreamSPD::GetHdacLow(UInt_t hs) const { | |
273 | if (hs<6) return (fCalHeadWord[hs/2+7]>>(16-16*(hs%2)) & 0x000000ff); | |
274 | else return 0; | |
275 | } | |
276 | UInt_t AliITSRawStreamSPD::GetHTPAmp(UInt_t hs) const { | |
277 | if (hs<6) return fCalHeadWord[hs+10]; | |
278 | else return 0; | |
279 | } |