]>
Commit | Line | Data |
---|---|---|
2906f4c2 | 1 | /************************************************************************** |
1fd93b67 | 2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * |
2906f4c2 | 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 | ||
c52bf554 | 16 | /* $Id$ */ |
2906f4c2 | 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" | |
d9edae7b | 26 | #include "AliLog.h" |
2906f4c2 | 27 | |
28 | ClassImp(AliITSRawStreamSPD) | |
29 | ||
2906f4c2 | 30 | const Int_t AliITSRawStreamSPD::fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL] = { |
63244738 | 31 | { 4, 5, 0, 1, 80, 81, 84, 85, 88, 89, 92, 93}, |
32 | {12,13, 8, 9, 96, 97,100,101,104,105,108,109}, | |
33 | {20,21,16,17,112,113,116,117,120,121,124,125}, | |
34 | {28,29,24,25,128,129,132,133,136,137,140,141}, | |
35 | {36,37,32,33,144,145,148,149,152,153,156,157}, | |
36 | {44,45,40,41,160,161,164,165,168,169,172,173}, | |
37 | {52,53,48,49,176,177,180,181,184,185,188,189}, | |
38 | {60,61,56,57,192,193,196,197,200,201,204,205}, | |
39 | {68,69,64,65,208,209,212,213,216,217,220,221}, | |
40 | {76,77,72,73,224,225,228,229,232,233,236,237}, | |
41 | { 7, 6, 3, 2, 83, 82, 87, 86, 91, 90, 95, 94}, | |
42 | {15,14,11,10, 99, 98,103,102,107,106,111,110}, | |
43 | {23,22,19,18,115,114,119,118,123,122,127,126}, | |
44 | {31,30,27,26,131,130,135,134,139,138,143,142}, | |
45 | {39,38,35,34,147,146,151,150,155,154,159,158}, | |
46 | {47,46,43,42,163,162,167,166,171,170,175,174}, | |
47 | {55,54,51,50,179,178,183,182,187,186,191,190}, | |
48 | {63,62,59,58,195,194,199,198,203,202,207,206}, | |
49 | {71,70,67,66,211,210,215,214,219,218,223,222}, | |
50 | {79,78,75,74,227,226,231,230,235,234,239,238} | |
2906f4c2 | 51 | }; |
d9c68335 | 52 | //__________________________________________________________________________ |
2906f4c2 | 53 | AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) : |
54 | AliITSRawStream(rawReader), | |
d9c68335 | 55 | fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0), |
c42b9ed0 | 56 | fData(0),fOffset(0),fHitCount(0), |
57 | fDataChar1(0),fDataChar2(0),fDataChar3(0),fDataChar4(0), | |
d9c68335 | 58 | fFirstWord(kTRUE),fPrevEventId(0xffffffff), |
59 | fEqPLBytesRead(0),fEqPLChipHeadersRead(0),fEqPLChipTrailersRead(0), | |
60 | fHeaderOrTrailerReadLast(kFALSE),fExpectedHeaderTrailerCount(0), | |
61 | fFillOutOfSynch(kFALSE),fDDLID(-1),fLastDDLID(-1),fAdvancedErrorLog(kFALSE), | |
62 | fAdvLogger(NULL) | |
2906f4c2 | 63 | { |
c42b9ed0 | 64 | // create an object to read ITS SPD raw digits |
30ec89b5 | 65 | fRawReader->Reset(); |
362c9d61 | 66 | fRawReader->Select("ITSSPD"); |
c42b9ed0 | 67 | // reset calib header words |
68 | for (UInt_t iword=0; iword<kCalHeadLenMax; iword++) { | |
69 | fCalHeadWord[iword]=0xffffffff; | |
70 | } | |
71 | NewEvent(); | |
2906f4c2 | 72 | } |
d9c68335 | 73 | //__________________________________________________________________________ |
74 | AliITSRawStreamSPD::AliITSRawStreamSPD(const AliITSRawStreamSPD& rstream) : | |
75 | AliITSRawStream(rstream.fRawReader), | |
76 | fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0), | |
77 | fData(0),fOffset(0),fHitCount(0), | |
78 | fDataChar1(0),fDataChar2(0),fDataChar3(0),fDataChar4(0), | |
79 | fFirstWord(kTRUE),fPrevEventId(0xffffffff), | |
80 | fEqPLBytesRead(0),fEqPLChipHeadersRead(0),fEqPLChipTrailersRead(0), | |
81 | fHeaderOrTrailerReadLast(kFALSE),fExpectedHeaderTrailerCount(0), | |
82 | fFillOutOfSynch(kFALSE),fDDLID(-1),fLastDDLID(-1),fAdvancedErrorLog(kFALSE), | |
83 | fAdvLogger(NULL) | |
72600597 | 84 | { |
d9c68335 | 85 | // copy constructor |
86 | AliError("Copy constructor should not be used."); | |
87 | } | |
88 | //__________________________________________________________________________ | |
89 | AliITSRawStreamSPD& AliITSRawStreamSPD::operator=(const AliITSRawStreamSPD& rstream) { | |
90 | // assignment operator | |
91 | if (this!=&rstream) {} | |
92 | AliError("Assignment opertator should not be used."); | |
93 | return *this; | |
94 | } | |
95 | //__________________________________________________________________________ | |
96 | Bool_t AliITSRawStreamSPD::ReadNextShort() { | |
c42b9ed0 | 97 | // read next 16 bit word into fData |
72600597 | 98 | if (fFirstWord) { |
72600597 | 99 | Bool_t b1 = fRawReader->ReadNextChar(fDataChar1); |
100 | if (!b1) return kFALSE; | |
101 | Bool_t b2, b3, b4; | |
102 | b2 = fRawReader->ReadNextChar(fDataChar2); | |
103 | b3 = fRawReader->ReadNextChar(fDataChar3); | |
104 | b4 = fRawReader->ReadNextChar(fDataChar4); | |
105 | if (!(b2 && b3 && b4)) { | |
106 | return kFALSE; | |
107 | } | |
108 | fData = fDataChar3+(fDataChar4<<8); | |
c52bf554 | 109 | const UInt_t *intPtr = fRawReader->GetEventId(); |
110 | if (intPtr!=0) { | |
111 | if (*intPtr!=fPrevEventId) { // if new event... | |
112 | NewEvent(); | |
113 | fPrevEventId=*intPtr; | |
114 | } | |
c42b9ed0 | 115 | } |
116 | fFirstWord=kFALSE; | |
72600597 | 117 | } |
118 | else { | |
119 | fFirstWord=kTRUE; | |
120 | fData = fDataChar1+(fDataChar2<<8); | |
121 | } | |
d9c68335 | 122 | fEqPLBytesRead+=2; |
123 | ||
72600597 | 124 | return kTRUE; |
125 | } | |
d9c68335 | 126 | //__________________________________________________________________________ |
127 | Bool_t AliITSRawStreamSPD::ReadNextInt() { | |
c42b9ed0 | 128 | // reads next 32 bit into fDataChar1..4 |
129 | // (if first 16 bits read already, just completes the present word) | |
130 | if (fFirstWord) { | |
131 | if (ReadNextShort() && ReadNextShort()) { | |
132 | return kTRUE; | |
133 | } | |
134 | } | |
135 | else { | |
136 | if (ReadNextShort()) { | |
137 | return kTRUE; | |
138 | } | |
139 | } | |
140 | return kFALSE; | |
141 | } | |
d9c68335 | 142 | //__________________________________________________________________________ |
143 | void AliITSRawStreamSPD::NewEvent() { | |
c42b9ed0 | 144 | // call this to reset flags for a new event |
145 | for (UInt_t eqId=0; eqId<20; eqId++) { | |
146 | fCalHeadRead[eqId]=kFALSE; | |
147 | } | |
d9c68335 | 148 | fEventCounter = -1; |
149 | fDDLID = -1; | |
150 | fLastDDLID = -1; | |
c42b9ed0 | 151 | } |
d9c68335 | 152 | //__________________________________________________________________________ |
3f917533 | 153 | Int_t AliITSRawStreamSPD::ReadCalibHeader() { |
c42b9ed0 | 154 | // read the extra calibration header |
3f917533 | 155 | // returns the length of the header if it is present, -1 otherwise |
72600597 | 156 | |
c42b9ed0 | 157 | Int_t ddlID = fRawReader->GetDDLID(); |
158 | if (ddlID==-1) { // we may need to read one word to get the blockAttr | |
3f917533 | 159 | if (!ReadNextShort()) return -1; |
c42b9ed0 | 160 | ddlID = fRawReader->GetDDLID(); |
161 | } | |
d9c68335 | 162 | // reset flags and counters |
163 | fEqPLBytesRead = 2; | |
164 | fEqPLChipHeadersRead = 0; | |
165 | fEqPLChipTrailersRead = 0; | |
166 | fHeaderOrTrailerReadLast = kFALSE; | |
167 | fFillOutOfSynch = kFALSE; | |
168 | ||
169 | // check what number of chip headers/trailers to expect | |
170 | fExpectedHeaderTrailerCount = 0; | |
171 | for (UInt_t hs=0; hs<6; hs++) { | |
172 | if (!fRawReader->TestBlockAttribute(hs)) fExpectedHeaderTrailerCount+=10; | |
173 | } | |
174 | ||
c42b9ed0 | 175 | if (ddlID>=0 && ddlID<20) fCalHeadRead[ddlID]=kTRUE; |
d9c68335 | 176 | if (fRawReader->TestBlockAttribute(6)) { // is the calib header present? |
c42b9ed0 | 177 | if (ReadNextInt()) { |
72600597 | 178 | // length of cal header: |
179 | UInt_t calLen = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24); | |
c42b9ed0 | 180 | if (calLen>kCalHeadLenMax) { |
d9c68335 | 181 | TString errMess = Form("Header length %d > max = %d",calLen,kCalHeadLenMax); |
182 | AliError(errMess.Data()); | |
183 | fRawReader->AddMajorErrorLog(kCalHeaderLengthErr,errMess.Data()); | |
184 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kCalHeaderLengthErr,ddlID,-1,-1,errMess.Data()); | |
3f917533 | 185 | return -1; |
c42b9ed0 | 186 | } |
d9c68335 | 187 | else { |
c42b9ed0 | 188 | for (UInt_t iword=0; iword<calLen; iword++) { |
189 | if (ReadNextInt()) { | |
190 | fCalHeadWord[iword] = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24); | |
191 | } | |
192 | else { | |
d9c68335 | 193 | TString errMess = "Header length problem"; |
194 | AliError(errMess.Data()); | |
195 | fRawReader->AddMajorErrorLog(kCalHeaderLengthErr,errMess.Data()); | |
196 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kCalHeaderLengthErr,ddlID,-1,-1,errMess.Data()); | |
3f917533 | 197 | return -1; |
c42b9ed0 | 198 | } |
199 | } | |
3f917533 | 200 | return calLen; |
72600597 | 201 | } |
202 | } | |
203 | } | |
c42b9ed0 | 204 | |
3f917533 | 205 | return -1; |
72600597 | 206 | } |
d9c68335 | 207 | //__________________________________________________________________________ |
208 | Bool_t AliITSRawStreamSPD::Next() { | |
2906f4c2 | 209 | // read the next raw digit |
210 | // returns kFALSE if there is no digit left | |
211 | ||
212 | fPrevModuleID = fModuleID; | |
c42b9ed0 | 213 | |
72600597 | 214 | while (ReadNextShort()) { |
c42b9ed0 | 215 | |
d9c68335 | 216 | fLastDDLID = fDDLID; |
217 | fDDLID = fRawReader->GetDDLID(); | |
218 | if (fDDLID>=0 && fDDLID<20) { | |
219 | if (!fCalHeadRead[fDDLID]) { | |
220 | if (fLastDDLID!=-1) { // if not the first equipment for this event | |
221 | fEqPLBytesRead -= 2; | |
222 | CheckHeaderAndTrailerCount(fLastDDLID); | |
223 | } | |
3f917533 | 224 | if (ReadCalibHeader()>=0) continue; |
c42b9ed0 | 225 | } |
226 | } | |
227 | else { | |
d9c68335 | 228 | TString errMess = Form("Error in DDL number (=%d) , setting it to 19",fDDLID); |
229 | AliError(errMess.Data()); | |
230 | fRawReader->AddMajorErrorLog(kDDLNumberErr,errMess.Data()); | |
231 | if (fAdvancedErrorLog) fAdvLogger->AddMessage(errMess.Data()); | |
232 | fDDLID=19; | |
c42b9ed0 | 233 | } |
234 | ||
72600597 | 235 | if ((fData & 0xC000) == 0x4000) { // header |
d9c68335 | 236 | if (fHeaderOrTrailerReadLast) { |
237 | TString errMess = "Chip trailer missing"; | |
238 | AliError(errMess.Data()); | |
239 | fRawReader->AddMajorErrorLog(kTrailerMissingErr,errMess.Data()); | |
240 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kTrailerMissingErr,fLastDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
241 | } | |
242 | fHeaderOrTrailerReadLast = kTRUE; | |
243 | fEqPLChipHeadersRead++; | |
2906f4c2 | 244 | fHitCount = 0; |
d9c68335 | 245 | UShort_t eventCounter = (fData >> 4) & 0x007F; |
246 | if (fEventCounter < 0) { | |
247 | fEventCounter = eventCounter; | |
72600597 | 248 | } |
d9c68335 | 249 | else if (eventCounter != fEventCounter) { |
250 | TString errMess; | |
251 | if (fEqPLChipHeadersRead==1) { | |
252 | errMess = Form("Mismatching event counters between this equipment and the previous: %d != %d", | |
253 | eventCounter,fEventCounter); | |
254 | } | |
255 | else { | |
256 | errMess = Form("Mismatching event counters between this chip header and the previous: %d != %d", | |
257 | eventCounter,fEventCounter); | |
258 | } | |
259 | fEventCounter = eventCounter; | |
260 | AliError(errMess.Data()); | |
261 | fRawReader->AddMajorErrorLog(kEventCounterErr,errMess.Data()); | |
262 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kEventCounterErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
2906f4c2 | 263 | } |
c42b9ed0 | 264 | fChipAddr = fData & 0x000F; |
265 | if (fChipAddr>9) { | |
d9c68335 | 266 | TString errMess = Form("Overflow chip address %d - set to 0",fChipAddr); |
267 | AliError(errMess.Data()); | |
268 | fRawReader->AddMajorErrorLog(kChipAddrErr,errMess.Data()); | |
269 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kChipAddrErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
270 | fChipAddr=0; | |
2906f4c2 | 271 | } |
c42b9ed0 | 272 | fHalfStaveNr = (fData & 0x3800)>>11; |
273 | if (fHalfStaveNr>5 || fRawReader->TestBlockAttribute(fHalfStaveNr)) { | |
d9c68335 | 274 | TString errMess = Form("Half stave number error: %d - set to 0",fHalfStaveNr); |
275 | AliError(errMess.Data()); | |
276 | fRawReader->AddMajorErrorLog(kHSNumberErr,errMess.Data()); | |
277 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHSNumberErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
278 | fHalfStaveNr=0; | |
2906f4c2 | 279 | } |
c42b9ed0 | 280 | // translate ("online") ddl, hs, chip nr to ("offline") module id : |
d9c68335 | 281 | fModuleID = GetOfflineModuleFromOnline(fDDLID,fHalfStaveNr,fChipAddr); |
72600597 | 282 | } |
283 | else if ((fData & 0xC000) == 0x0000) { // trailer | |
d9c68335 | 284 | if ( (fEqPLBytesRead+fFillOutOfSynch*2)%4 != 0 ) { |
285 | TString errMess = "Fill word is missing"; | |
286 | AliError(errMess.Data()); | |
287 | fRawReader->AddMajorErrorLog(kFillMissingErr,errMess.Data()); | |
288 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kFillMissingErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
289 | if (fFillOutOfSynch) fFillOutOfSynch = kFALSE; | |
290 | else fFillOutOfSynch = kTRUE; | |
291 | } | |
292 | if (!fHeaderOrTrailerReadLast) { | |
293 | TString errMess = "Trailer without previous header"; | |
294 | AliError(errMess.Data()); | |
295 | fRawReader->AddMajorErrorLog(kTrailerWithoutHeaderErr,errMess.Data()); | |
296 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kTrailerWithoutHeaderErr,fLastDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
297 | } | |
298 | fHeaderOrTrailerReadLast = kFALSE; | |
299 | fEqPLChipTrailersRead++; | |
2906f4c2 | 300 | UShort_t hitCount = fData & 0x1FFF; |
d9edae7b | 301 | if (hitCount != fHitCount){ |
d9c68335 | 302 | TString errMess = Form("Number of hits %d, while %d expected",fHitCount,hitCount); |
303 | AliError(errMess.Data()); | |
304 | fRawReader->AddMajorErrorLog(kNumberHitsErr,errMess.Data()); | |
305 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kNumberHitsErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
d9edae7b | 306 | } |
307 | } | |
72600597 | 308 | else if ((fData & 0xC000) == 0x8000) { // pixel hit |
d9c68335 | 309 | if (!fHeaderOrTrailerReadLast) { |
310 | TString errMess = "Chip header missing"; | |
311 | AliError(errMess.Data()); | |
312 | fRawReader->AddMajorErrorLog(kHeaderMissingErr,errMess.Data()); | |
313 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderMissingErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
314 | fHeaderOrTrailerReadLast = kTRUE; | |
315 | } | |
2906f4c2 | 316 | fHitCount++; |
c42b9ed0 | 317 | fCol = (fData & 0x001F); |
318 | fRow = (fData >> 5) & 0x00FF; | |
319 | ||
d9c68335 | 320 | fCoord1 = GetOfflineColFromOnline(fDDLID,fHalfStaveNr,fChipAddr,fCol); |
321 | fCoord2 = GetOfflineRowFromOnline(fDDLID,fHalfStaveNr,fChipAddr,fRow); | |
c42b9ed0 | 322 | |
2906f4c2 | 323 | return kTRUE; |
72600597 | 324 | } |
325 | else { // fill word | |
d9edae7b | 326 | if ((fData & 0xC000) != 0xC000) { |
d9c68335 | 327 | TString errMess = "Wrong fill word!"; |
328 | AliError(errMess.Data()); | |
329 | fRawReader->AddMajorErrorLog(kWrongFillWordErr,errMess.Data()); | |
330 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kWrongFillWordErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
331 | } | |
332 | if ( (fEqPLBytesRead+fFillOutOfSynch*2)%4 != 2 ) { | |
333 | TString errMess = "Fill word is unexpected"; | |
334 | AliError(errMess.Data()); | |
335 | fRawReader->AddMajorErrorLog(kFillUnexpectErr,errMess.Data()); | |
336 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kFillUnexpectErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data()); | |
337 | if (fFillOutOfSynch) fFillOutOfSynch = kFALSE; | |
338 | else fFillOutOfSynch = kTRUE; | |
d9edae7b | 339 | } |
2906f4c2 | 340 | } |
341 | ||
342 | } | |
d9c68335 | 343 | if (fDDLID>=0 && fDDLID<20) { |
344 | CheckHeaderAndTrailerCount(fDDLID); | |
345 | } | |
2906f4c2 | 346 | return kFALSE; |
347 | } | |
d9c68335 | 348 | //__________________________________________________________________________ |
349 | void AliITSRawStreamSPD::CheckHeaderAndTrailerCount(Int_t ddlID) { | |
350 | // Checks that the number of header and trailers found for the ddl are as expected | |
351 | if (fEqPLChipHeadersRead != fExpectedHeaderTrailerCount) { | |
352 | TString errMess = Form("Chip header count inconsistent %d != %d (expected) for ddl %d", | |
353 | fEqPLChipHeadersRead,fExpectedHeaderTrailerCount,ddlID); | |
354 | AliError(errMess.Data()); | |
355 | fRawReader->AddMajorErrorLog(kHeaderCountErr,errMess.Data()); | |
356 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,-1,-1,errMess.Data()); | |
357 | } | |
358 | if (fEqPLChipTrailersRead != fExpectedHeaderTrailerCount) { | |
359 | TString errMess = Form("Chip trailer count inconsistent %d != %d (expected) for ddl %d", | |
360 | fEqPLChipTrailersRead,fExpectedHeaderTrailerCount,ddlID); | |
361 | AliError(errMess.Data()); | |
362 | fRawReader->AddMajorErrorLog(kHeaderCountErr,errMess.Data()); | |
363 | if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,-1,-1,errMess.Data()); | |
364 | } | |
365 | } | |
366 | //__________________________________________________________________________ | |
367 | void AliITSRawStreamSPD::ActivateAdvancedErrorLog(Bool_t activate, AliITSRawStreamSPDErrorLog* advLogger) { | |
368 | // Activate the advanced error logging. | |
369 | // Logger object has to be created elsewhere and a pointer sent here. | |
370 | fAdvancedErrorLog=activate; | |
371 | if (activate && advLogger!=NULL) { | |
372 | fAdvLogger = advLogger; | |
373 | } | |
374 | if (fAdvLogger==NULL) { | |
375 | fAdvancedErrorLog=kFALSE; | |
376 | } | |
377 | } | |
378 | //__________________________________________________________________________ | |
379 | const Char_t* AliITSRawStreamSPD::GetErrorName(UInt_t errorCode) { | |
380 | // Returns a string for each error code | |
381 | if (errorCode==kTotal) return "All Errors"; | |
382 | else if (errorCode==kHeaderMissingErr) return "Header Missing"; | |
383 | else if (errorCode==kTrailerMissingErr) return "Trailer Missing"; | |
384 | else if (errorCode==kTrailerWithoutHeaderErr) return "Trailer Unexpected"; | |
385 | else if (errorCode==kHeaderCountErr) return "Header Count Wrong"; | |
386 | else if (errorCode==kTrailerCountErr) return "Trailer Count Wrong"; | |
387 | else if (errorCode==kFillUnexpectErr) return "Fill Unexpected"; | |
388 | else if (errorCode==kFillMissingErr) return "Fill Missing"; | |
389 | else if (errorCode==kWrongFillWordErr) return "Fill Word Wrong"; | |
390 | else if (errorCode==kNumberHitsErr) return "Hit Count Wrong"; | |
391 | else if (errorCode==kEventCounterErr) return "Event Counter Error"; | |
392 | else if (errorCode==kDDLNumberErr) return "DDL Number Error"; | |
393 | else if (errorCode==kHSNumberErr) return "HS Number Error"; | |
394 | else if (errorCode==kChipAddrErr) return "Chip Address Error"; | |
395 | else if (errorCode==kCalHeaderLengthErr) return "Calib Header Length Error"; | |
396 | else return ""; | |
397 | } | |
398 | //__________________________________________________________________________ | |
c42b9ed0 | 399 | Bool_t AliITSRawStreamSPD::GetHalfStavePresent(UInt_t hs) { |
400 | // Reads the half stave present status from the block attributes | |
401 | Int_t ddlID = fRawReader->GetDDLID(); | |
402 | if (ddlID==-1) { | |
d9edae7b | 403 | AliWarning("DDL ID = -1. Cannot read block attributes. Return kFALSE."); |
c42b9ed0 | 404 | return kFALSE; |
405 | } | |
406 | else { | |
407 | if (hs>=6) { | |
d9edae7b | 408 | AliWarning(Form("HS >= 6 requested (%d). Return kFALSE.",hs)); |
c42b9ed0 | 409 | return kFALSE; |
410 | } | |
411 | UChar_t attr = fRawReader->GetBlockAttributes(); | |
412 | if (((attr>>hs) & 0x01) == 0x01) { // bit set means not present | |
413 | return kFALSE; | |
414 | } | |
415 | else { | |
416 | return kTRUE; | |
417 | } | |
418 | } | |
419 | } | |
d9c68335 | 420 | //__________________________________________________________________________ |
c42b9ed0 | 421 | Bool_t AliITSRawStreamSPD::GetHhalfStaveScanned(UInt_t hs) const { |
422 | if (hs<6) return (Bool_t)((fCalHeadWord[0]>>(6+hs)) & (0x00000001)); | |
423 | else return kFALSE; | |
424 | } | |
425 | Bool_t AliITSRawStreamSPD::GetHchipPresent(UInt_t hs, UInt_t chip) const { | |
426 | if (hs<6 && chip<10) return ((( fCalHeadWord[hs/3+3]>>((hs%3)*10+chip)) & 0x00000001) == 1); | |
427 | else return kFALSE; | |
428 | } | |
429 | UInt_t AliITSRawStreamSPD::GetHdacHigh(UInt_t hs) const { | |
430 | if (hs<6) return (fCalHeadWord[hs/2+7]>>(24-16*(hs%2)) & 0x000000ff); | |
431 | else return 0; | |
432 | } | |
433 | UInt_t AliITSRawStreamSPD::GetHdacLow(UInt_t hs) const { | |
434 | if (hs<6) return (fCalHeadWord[hs/2+7]>>(16-16*(hs%2)) & 0x000000ff); | |
435 | else return 0; | |
436 | } | |
437 | UInt_t AliITSRawStreamSPD::GetHTPAmp(UInt_t hs) const { | |
438 | if (hs<6) return fCalHeadWord[hs+10]; | |
439 | else return 0; | |
440 | } | |
1fd93b67 | 441 | Bool_t AliITSRawStreamSPD::GetHminTHchipPresent(UInt_t chip) const { |
442 | if (chip<10) return ((( fCalHeadWord[7]>>(16+chip)) & 0x00000001) == 1); | |
443 | else return kFALSE; | |
444 | } | |
d9c68335 | 445 | //__________________________________________________________________________ |
6727e2db | 446 | Int_t AliITSRawStreamSPD::GetModuleNumber(UInt_t iDDL, UInt_t iModule) { |
447 | if (iDDL<20 && iModule<12) return fgkDDLModuleMap[iDDL][iModule]; | |
448 | else return 240; | |
449 | } | |
d9c68335 | 450 | //__________________________________________________________________________ |
6727e2db | 451 | Bool_t AliITSRawStreamSPD::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) { |
452 | // converts offline coordinates to online | |
453 | eq = GetOnlineEqIdFromOffline(module); | |
454 | hs = GetOnlineHSFromOffline(module); | |
455 | chip = GetOnlineChipFromOffline(module,colM); | |
456 | col = GetOnlineColFromOffline(module,colM); | |
457 | row = GetOnlineRowFromOffline(module,rowM); | |
458 | if (eq>=20 || hs>=6 || chip>=10 || col>=32 || row>=256) return kFALSE; | |
459 | else return kTRUE; | |
460 | } | |
d9c68335 | 461 | //__________________________________________________________________________ |
6727e2db | 462 | Bool_t AliITSRawStreamSPD::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) { |
463 | // converts online coordinates to offline | |
464 | module = GetOfflineModuleFromOnline(eq,hs,chip); | |
465 | colM = GetOfflineColFromOnline(eq,hs,chip,col); | |
466 | rowM = GetOfflineRowFromOnline(eq,hs,chip,row); | |
467 | if (module>=240 || colM>=160 || rowM>=256) return kFALSE; | |
468 | else return kTRUE; | |
469 | } | |
d9c68335 | 470 | //__________________________________________________________________________ |
6727e2db | 471 | UInt_t AliITSRawStreamSPD::GetOnlineEqIdFromOffline(UInt_t module) { |
472 | // offline->online (eq) | |
473 | for (UInt_t eqId=0; eqId<20; eqId++) { | |
474 | for (UInt_t iModule=0; iModule<12; iModule++) { | |
475 | if (GetModuleNumber(eqId,iModule)==(Int_t)module) return eqId; | |
476 | } | |
477 | } | |
478 | return 20; // error | |
479 | } | |
d9c68335 | 480 | //__________________________________________________________________________ |
6727e2db | 481 | UInt_t AliITSRawStreamSPD::GetOnlineHSFromOffline(UInt_t module) { |
482 | // offline->online (hs) | |
483 | for (UInt_t eqId=0; eqId<20; eqId++) { | |
484 | for (UInt_t iModule=0; iModule<12; iModule++) { | |
485 | if (GetModuleNumber(eqId,iModule)==(Int_t)module) return iModule/2; | |
486 | } | |
487 | } | |
488 | return 6; // error | |
489 | } | |
d9c68335 | 490 | //__________________________________________________________________________ |
6727e2db | 491 | UInt_t AliITSRawStreamSPD::GetOnlineChipFromOffline(UInt_t module, UInt_t colM) { |
492 | // offline->online (chip) | |
493 | for (UInt_t eq=0; eq<20; eq++) { | |
494 | for (UInt_t iModule=0; iModule<12; iModule++) { | |
495 | if (GetModuleNumber(eq,iModule)==(Int_t)module) { | |
49c66823 | 496 | if (module<80) { |
497 | if (eq<10) { // side A | |
498 | return (159-colM)/32 + 5*(iModule%2); | |
499 | } | |
500 | else { // side C | |
501 | return colM/32 + 5*(iModule%2); | |
502 | } | |
63244738 | 503 | } |
49c66823 | 504 | else if (module<240) { |
505 | if (eq<10) { // side A | |
506 | return colM/32 + 5*(iModule%2); | |
507 | } | |
508 | else { // side C | |
509 | return (159-colM)/32 + 5*(iModule%2); | |
510 | } | |
63244738 | 511 | } |
6727e2db | 512 | } |
513 | } | |
514 | } | |
515 | return 10; // error | |
516 | } | |
d9c68335 | 517 | //__________________________________________________________________________ |
6727e2db | 518 | UInt_t AliITSRawStreamSPD::GetOnlineColFromOffline(UInt_t module, UInt_t colM) { |
519 | // offline->online (col) | |
63244738 | 520 | if (module<80) { // inner layer |
521 | return colM%32; | |
522 | } | |
523 | else if (module<240) { // outer layer | |
49c66823 | 524 | return colM%32; |
63244738 | 525 | } |
526 | return 32; // error | |
6727e2db | 527 | } |
d9c68335 | 528 | //__________________________________________________________________________ |
6727e2db | 529 | UInt_t AliITSRawStreamSPD::GetOnlineRowFromOffline(UInt_t module, UInt_t rowM) { |
530 | // offline->online (row) | |
63244738 | 531 | if (module<80) { // inner layer |
49c66823 | 532 | return (255-rowM); |
63244738 | 533 | } |
534 | else if (module<240) { // outer layer | |
535 | return (255-rowM); | |
536 | } | |
537 | return 256; // error | |
6727e2db | 538 | } |
d9c68335 | 539 | //__________________________________________________________________________ |
6727e2db | 540 | UInt_t AliITSRawStreamSPD::GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) { |
541 | // online->offline (module) | |
542 | if (eqId<20 && hs<6 && chip<10) return fgkDDLModuleMap[eqId][hs*2+chip/5]; | |
543 | else return 240; | |
544 | } | |
d9c68335 | 545 | //__________________________________________________________________________ |
6727e2db | 546 | UInt_t AliITSRawStreamSPD::GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col) { |
547 | // online->offline (col) | |
548 | if (eqId>=20 || hs>=6 || chip>=10 || col>=32) return 160; // error | |
549 | UInt_t offset = 32 * (chip % 5); | |
63244738 | 550 | if (hs<2) { |
551 | if (eqId<10) { | |
552 | return 159 - (31-col + offset); // inner layer, side A | |
553 | } | |
554 | else { | |
555 | return col + offset; // inner layer, side C | |
556 | } | |
557 | } | |
558 | else { | |
559 | if (eqId<10) { | |
49c66823 | 560 | return (col + offset); // outer layer, side A |
63244738 | 561 | } |
562 | else { | |
49c66823 | 563 | return 159 - (31-col + offset); // outer layer, side C |
63244738 | 564 | } |
565 | } | |
6727e2db | 566 | } |
d9c68335 | 567 | //__________________________________________________________________________ |
6727e2db | 568 | UInt_t AliITSRawStreamSPD::GetOfflineRowFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t row) { |
569 | // online->offline (row) | |
570 | if (eqId>=20 || hs>=6 || chip>=10 || row>=256) return 256; // error | |
49c66823 | 571 | return 255-row; |
6727e2db | 572 | } |
d9c68335 | 573 | |
574 | ||
575 | ||
576 |