Changes related to the extraction of the V0 finder into a separate class (A. Dainese...
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSPD_OLDGEO.cxx
CommitLineData
7cae5b4e 1/**************************************************************************
2 * Copyright(c) 2007-2009, 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#include "AliLog.h"
27
28ClassImp(AliITSRawStreamSPD)
29
30const Int_t AliITSRawStreamSPD::fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL] = {
31 { 0, 1, 4, 5, 80, 81, 84, 85, 88, 89, 92, 93},
32 { 8, 9,12,13, 96, 97,100,101,104,105,108,109},
33 {16,17,20,21,112,113,116,117,120,121,124,125},
34 {24,25,28,29,128,129,132,133,136,137,140,141},
35 {32,33,36,37,144,145,148,149,152,153,156,157},
36 {40,41,44,45,160,161,164,165,168,169,172,173},
37 {48,49,52,53,176,177,180,181,184,185,188,189},
38 {56,57,60,61,192,193,196,197,200,201,204,205},
39 {64,65,68,69,208,209,212,213,216,217,220,221},
40 {72,73,76,77,224,225,228,229,232,233,236,237},
41 { 2, 3, 6, 7, 82, 83, 86, 87, 90, 91, 94, 95},
42 {10,11,14,15, 98, 99,102,103,106,107,110,111},
43 {18,19,22,23,114,115,118,119,122,123,126,127},
44 {26,27,30,31,130,131,134,135,138,139,142,143},
45 {34,35,38,39,146,147,150,151,154,155,158,159},
46 {42,43,46,47,162,163,166,167,170,171,174,175},
47 {50,51,54,55,178,179,182,183,186,187,190,191},
48 {58,59,62,63,194,195,198,199,202,203,206,207},
49 {66,67,70,71,210,211,214,215,218,219,222,223},
50 {74,75,78,79,226,227,230,231,234,235,238,239}
51};
52//__________________________________________________________________________
53AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) :
54 AliITSRawStream(rawReader),
55 fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0),
56 fData(0),fOffset(0),fHitCount(0),
57 fDataChar1(0),fDataChar2(0),fDataChar3(0),fDataChar4(0),
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)
63{
64 // create an object to read ITS SPD raw digits
65 fRawReader->Select("ITSSPD");
66 // reset calib header words
67 for (UInt_t iword=0; iword<kCalHeadLenMax; iword++) {
68 fCalHeadWord[iword]=0xffffffff;
69 }
70 NewEvent();
71}
72//__________________________________________________________________________
73AliITSRawStreamSPD::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)
83{
84 // copy constructor
85 AliError("Copy constructor should not be used.");
86}
87//__________________________________________________________________________
88AliITSRawStreamSPD& 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//__________________________________________________________________________
95Bool_t AliITSRawStreamSPD::ReadNextShort() {
96 // read next 16 bit word into fData
97 if (fFirstWord) {
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);
108 if ((*fRawReader->GetEventId())!=fPrevEventId) { // if new event...
109 NewEvent();
110 fPrevEventId=(*fRawReader->GetEventId());
111 }
112 fFirstWord=kFALSE;
113 }
114 else {
115 fFirstWord=kTRUE;
116 fData = fDataChar1+(fDataChar2<<8);
117 }
118 fEqPLBytesRead+=2;
119
120 return kTRUE;
121}
122//__________________________________________________________________________
123Bool_t AliITSRawStreamSPD::ReadNextInt() {
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}
138//__________________________________________________________________________
139void AliITSRawStreamSPD::NewEvent() {
140 // call this to reset flags for a new event
141 for (UInt_t eqId=0; eqId<20; eqId++) {
142 fCalHeadRead[eqId]=kFALSE;
143 }
144 fEventCounter = -1;
145 fDDLID = -1;
146 fLastDDLID = -1;
147}
148//__________________________________________________________________________
149Int_t AliITSRawStreamSPD::ReadCalibHeader() {
150 // read the extra calibration header
151 // returns the length of the header if it is present, -1 otherwise
152
153 Int_t ddlID = fRawReader->GetDDLID();
154 if (ddlID==-1) { // we may need to read one word to get the blockAttr
155 if (!ReadNextShort()) return -1;
156 ddlID = fRawReader->GetDDLID();
157 }
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
171 if (ddlID>=0 && ddlID<20) fCalHeadRead[ddlID]=kTRUE;
172 if (fRawReader->TestBlockAttribute(6)) { // is the calib header present?
173 if (ReadNextInt()) {
174 // length of cal header:
175 UInt_t calLen = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24);
176 if (calLen>kCalHeadLenMax) {
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());
181 return -1;
182 }
183 else {
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 {
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());
193 return -1;
194 }
195 }
196 return calLen;
197 }
198 }
199 }
200
201 return -1;
202}
203//__________________________________________________________________________
204Bool_t AliITSRawStreamSPD::Next() {
205// read the next raw digit
206// returns kFALSE if there is no digit left
207
208 fPrevModuleID = fModuleID;
209
210 while (ReadNextShort()) {
211
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 }
220 if (ReadCalibHeader()>=0) continue;
221 }
222 }
223 else {
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;
229 }
230
231 if ((fData & 0xC000) == 0x4000) { // header
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++;
240 fHitCount = 0;
241 UShort_t eventCounter = (fData >> 4) & 0x007F;
242 if (fEventCounter < 0) {
243 fEventCounter = eventCounter;
244 }
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());
259 }
260 fChipAddr = fData & 0x000F;
261 if (fChipAddr>9) {
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;
267 }
268 fHalfStaveNr = (fData & 0x3800)>>11;
269 if (fHalfStaveNr>5 || fRawReader->TestBlockAttribute(fHalfStaveNr)) {
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;
275 }
276 // translate ("online") ddl, hs, chip nr to ("offline") module id :
277 fModuleID = GetOfflineModuleFromOnline(fDDLID,fHalfStaveNr,fChipAddr);
278 }
279 else if ((fData & 0xC000) == 0x0000) { // trailer
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++;
296 UShort_t hitCount = fData & 0x1FFF;
297 if (hitCount != fHitCount){
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());
302 }
303 }
304 else if ((fData & 0xC000) == 0x8000) { // pixel hit
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 }
312 fHitCount++;
313 fCol = (fData & 0x001F);
314 fRow = (fData >> 5) & 0x00FF;
315
316 fCoord1 = GetOfflineColFromOnline(fDDLID,fHalfStaveNr,fChipAddr,fCol);
317 fCoord2 = GetOfflineRowFromOnline(fDDLID,fHalfStaveNr,fChipAddr,fRow);
318
319 return kTRUE;
320 }
321 else { // fill word
322 if ((fData & 0xC000) != 0xC000) {
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;
335 }
336 }
337
338 }
339 if (fDDLID>=0 && fDDLID<20) {
340 CheckHeaderAndTrailerCount(fDDLID);
341 }
342 return kFALSE;
343}
344//__________________________________________________________________________
345void 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//__________________________________________________________________________
363void 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//__________________________________________________________________________
375const 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//__________________________________________________________________________
395Bool_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) {
399 AliWarning("DDL ID = -1. Cannot read block attributes. Return kFALSE.");
400 return kFALSE;
401 }
402 else {
403 if (hs>=6) {
404 AliWarning(Form("HS >= 6 requested (%d). Return kFALSE.",hs));
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}
416//__________________________________________________________________________
417Bool_t AliITSRawStreamSPD::GetHhalfStaveScanned(UInt_t hs) const {
418 if (hs<6) return (Bool_t)((fCalHeadWord[0]>>(6+hs)) & (0x00000001));
419 else return kFALSE;
420}
421Bool_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}
425UInt_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}
429UInt_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}
433UInt_t AliITSRawStreamSPD::GetHTPAmp(UInt_t hs) const {
434 if (hs<6) return fCalHeadWord[hs+10];
435 else return 0;
436}
437Bool_t AliITSRawStreamSPD::GetHminTHchipPresent(UInt_t chip) const {
438 if (chip<10) return ((( fCalHeadWord[7]>>(16+chip)) & 0x00000001) == 1);
439 else return kFALSE;
440}
441//__________________________________________________________________________
442Int_t AliITSRawStreamSPD::GetModuleNumber(UInt_t iDDL, UInt_t iModule) {
443 if (iDDL<20 && iModule<12) return fgkDDLModuleMap[iDDL][iModule];
444 else return 240;
445}
446//__________________________________________________________________________
447Bool_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}
457//__________________________________________________________________________
458Bool_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}
466//__________________________________________________________________________
467UInt_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}
476//__________________________________________________________________________
477UInt_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}
486//__________________________________________________________________________
487UInt_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) {
492 return colM/32 + 5*(iModule%2);
493 }
494 }
495 }
496 return 10; // error
497}
498//__________________________________________________________________________
499UInt_t AliITSRawStreamSPD::GetOnlineColFromOffline(UInt_t module, UInt_t colM) {
500 // offline->online (col)
501 if (colM<160) return colM%32;
502 else return 32; // error
503}
504//__________________________________________________________________________
505UInt_t AliITSRawStreamSPD::GetOnlineRowFromOffline(UInt_t module, UInt_t rowM) {
506 // offline->online (row)
507 if (rowM<256) return rowM;
508 else return 256; // error
509}
510//__________________________________________________________________________
511UInt_t AliITSRawStreamSPD::GetOfflineModuleFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) {
512 // online->offline (module)
513 if (eqId<20 && hs<6 && chip<10) return fgkDDLModuleMap[eqId][hs*2+chip/5];
514 else return 240;
515}
516//__________________________________________________________________________
517UInt_t AliITSRawStreamSPD::GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col) {
518 // online->offline (col)
519 if (eqId>=20 || hs>=6 || chip>=10 || col>=32) return 160; // error
520 UInt_t offset = 32 * (chip % 5);
521 return col+offset;
522}
523//__________________________________________________________________________
524UInt_t AliITSRawStreamSPD::GetOfflineRowFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t row) {
525 // online->offline (row)
526 if (eqId>=20 || hs>=6 || chip>=10 || row>=256) return 256; // error
527 return row;
528}
529
530
531
532