]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSRawStreamSPD.cxx
DCS information for SDD (F. Prino)
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSPD.cxx
CommitLineData
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
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"
d9edae7b 26#include "AliLog.h"
2906f4c2 27
28ClassImp(AliITSRawStreamSPD)
29
2906f4c2 30const Int_t AliITSRawStreamSPD::fgkDDLModuleMap[kDDLsNumber][kModulesPerDDL] = {
31 { 0, 1, 4, 5, 80, 81, 84, 85, 88, 89, 92, 93},
2906f4c2 32 { 8, 9,12,13, 96, 97,100,101,104,105,108,109},
2906f4c2 33 {16,17,20,21,112,113,116,117,120,121,124,125},
2906f4c2 34 {24,25,28,29,128,129,132,133,136,137,140,141},
2906f4c2 35 {32,33,36,37,144,145,148,149,152,153,156,157},
2906f4c2 36 {40,41,44,45,160,161,164,165,168,169,172,173},
2906f4c2 37 {48,49,52,53,176,177,180,181,184,185,188,189},
2906f4c2 38 {56,57,60,61,192,193,196,197,200,201,204,205},
2906f4c2 39 {64,65,68,69,208,209,212,213,216,217,220,221},
2906f4c2 40 {72,73,76,77,224,225,228,229,232,233,236,237},
72600597 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},
2906f4c2 50 {74,75,78,79,226,227,230,231,234,235,238,239}
51};
d9c68335 52//__________________________________________________________________________
2906f4c2 53AliITSRawStreamSPD::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//__________________________________________________________________________
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)
72600597 83{
d9c68335 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() {
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//__________________________________________________________________________
123Bool_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//__________________________________________________________________________
139void 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 149Int_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//__________________________________________________________________________
204Bool_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//__________________________________________________________________________
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//__________________________________________________________________________
c42b9ed0 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) {
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 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}
1fd93b67 437Bool_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 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}
d9c68335 446//__________________________________________________________________________
6727e2db 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}
d9c68335 457//__________________________________________________________________________
6727e2db 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}
d9c68335 466//__________________________________________________________________________
6727e2db 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}
d9c68335 476//__________________________________________________________________________
6727e2db 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}
d9c68335 486//__________________________________________________________________________
6727e2db 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}
d9c68335 498//__________________________________________________________________________
6727e2db 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}
d9c68335 504//__________________________________________________________________________
6727e2db 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}
d9c68335 510//__________________________________________________________________________
6727e2db 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}
d9c68335 516//__________________________________________________________________________
6727e2db 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}
d9c68335 523//__________________________________________________________________________
6727e2db 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}
d9c68335 529
530
531
532