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