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