]>
Commit | Line | Data |
---|---|---|
2906f4c2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
27 | ClassImp(AliITSRawStreamSPD) | |
28 | ||
29 | ||
30 | const 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 | }; | |
52 | ||
53 | ||
54 | AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) : | |
55 | AliITSRawStream(rawReader), | |
56 | fData(0), | |
57 | fDDLNumber(-1), | |
58 | fEventNumber(-1), | |
2906f4c2 | 59 | fOffset(0), |
72600597 | 60 | fHitCount(0), |
61 | fDataChar1(0), | |
62 | fDataChar2(0), | |
63 | fDataChar3(0), | |
64 | fDataChar4(0), | |
65 | fFirstWord(kTRUE) | |
2906f4c2 | 66 | { |
67 | // create an object to read ITS SPD raw digits | |
68 | ||
362c9d61 | 69 | fRawReader->Select("ITSSPD"); |
2906f4c2 | 70 | } |
71 | ||
72600597 | 72 | Bool_t AliITSRawStreamSPD::ReadNextShort() |
73 | { | |
74 | if (fFirstWord) { | |
75 | fFirstWord=kFALSE; | |
76 | Bool_t b1 = fRawReader->ReadNextChar(fDataChar1); | |
77 | if (!b1) return kFALSE; | |
78 | Bool_t b2, b3, b4; | |
79 | b2 = fRawReader->ReadNextChar(fDataChar2); | |
80 | b3 = fRawReader->ReadNextChar(fDataChar3); | |
81 | b4 = fRawReader->ReadNextChar(fDataChar4); | |
82 | if (!(b2 && b3 && b4)) { | |
83 | return kFALSE; | |
84 | } | |
85 | fData = fDataChar3+(fDataChar4<<8); | |
86 | } | |
87 | else { | |
88 | fFirstWord=kTRUE; | |
89 | fData = fDataChar1+(fDataChar2<<8); | |
90 | } | |
91 | ||
92 | return kTRUE; | |
93 | } | |
94 | ||
95 | void AliITSRawStreamSPD::SkipCalibHeader() | |
96 | { | |
97 | // Checks if there is an extra calibration header | |
98 | // present in the raw data. Reads past this in that case. | |
99 | ||
100 | fRawReader->ReadHeader(); // need this to get access to the block attributes | |
101 | UChar_t attr = fRawReader->GetBlockAttributes(); | |
102 | if ((attr & 0x40) == 0x40) { // is the header present? | |
103 | Bool_t b1, b2, b3, b4; | |
104 | b1 = fRawReader->ReadNextChar(fDataChar1); | |
105 | b2 = fRawReader->ReadNextChar(fDataChar2); | |
106 | b3 = fRawReader->ReadNextChar(fDataChar3); | |
107 | b4 = fRawReader->ReadNextChar(fDataChar4); | |
108 | if (b1 && b2 && b3 && b4) { | |
109 | // length of cal header: | |
110 | UInt_t calLen = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24); | |
111 | // read past the cal header: | |
112 | UInt_t tmpData; | |
113 | for (UInt_t iword=0; iword<calLen; iword++) { | |
114 | fRawReader->ReadNextInt(tmpData); | |
115 | } | |
116 | } | |
117 | } | |
118 | } | |
2906f4c2 | 119 | |
120 | Bool_t AliITSRawStreamSPD::Next() | |
121 | { | |
122 | // read the next raw digit | |
123 | // returns kFALSE if there is no digit left | |
124 | ||
125 | fPrevModuleID = fModuleID; | |
72600597 | 126 | // while (fRawReader->ReadNextShort(fData)) { |
127 | while (ReadNextShort()) { | |
128 | if ((fData & 0xC000) == 0x4000) { // header | |
2906f4c2 | 129 | fHitCount = 0; |
130 | UShort_t eventNumber = (fData >> 4) & 0x007F; | |
131 | if (fEventNumber < 0) { | |
132 | fEventNumber = eventNumber; | |
72600597 | 133 | } |
134 | else if (eventNumber != fEventNumber) { | |
2906f4c2 | 135 | Warning("Next", "mismatching event numbers: %d != %d", |
136 | eventNumber, fEventNumber); | |
137 | } | |
138 | UShort_t chipAddr = fData & 0x000F; | |
72600597 | 139 | if (chipAddr>9) { |
140 | Error("Next", "overflow chip addr (= %d) , setting it to 9", chipAddr); | |
141 | chipAddr=9; | |
2906f4c2 | 142 | } |
72600597 | 143 | UShort_t halfStaveNr = (fData & 0x3800)>>11; |
144 | if (halfStaveNr>5 || fRawReader->TestBlockAttribute(halfStaveNr)) { | |
145 | Error("Next", "half stave number error(= %d) , setting it to 5", halfStaveNr); | |
146 | halfStaveNr=5; | |
2906f4c2 | 147 | } |
72600597 | 148 | fDDLNumber = fRawReader->GetDDLID(); |
149 | if (fDDLNumber>19 || fDDLNumber<0) { | |
150 | Error("Next", "DDL number error (= %d) , setting it to 19", fDDLNumber); | |
151 | fDDLNumber=19; | |
2906f4c2 | 152 | } |
72600597 | 153 | fModuleID = fgkDDLModuleMap[fDDLNumber][halfStaveNr*2+chipAddr/5]; |
2906f4c2 | 154 | fOffset = 32 * (chipAddr % 5); |
72600597 | 155 | } |
156 | else if ((fData & 0xC000) == 0x0000) { // trailer | |
2906f4c2 | 157 | UShort_t hitCount = fData & 0x1FFF; |
158 | if (hitCount != fHitCount) Error("Next", "wrong number of hits: %d != %d", fHitCount, hitCount); | |
72600597 | 159 | } |
160 | else if ((fData & 0xC000) == 0x8000) { // pixel hit | |
2906f4c2 | 161 | fHitCount++; |
162 | fCoord1 = (fData & 0x001F) + fOffset; | |
163 | fCoord2 = (fData >> 5) & 0x00FF; | |
164 | return kTRUE; | |
72600597 | 165 | } |
166 | else { // fill word | |
2906f4c2 | 167 | if ((fData & 0xC000) != 0xC000) Error("Next", "wrong fill word!"); |
168 | } | |
169 | ||
170 | } | |
171 | ||
172 | return kFALSE; | |
173 | } |