]>
Commit | Line | Data |
---|---|---|
2906f4c2 | 1 | /************************************************************************** |
27639c72 | 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 | ||
ceb607d0 | 16 | /* $Id$*/ |
2906f4c2 | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides access to ITS SDD digits in raw data. | |
21 | /// | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliITSRawStreamSDD.h" | |
25 | #include "AliRawReader.h" | |
39a7c5cc | 26 | #include "AliLog.h" |
2906f4c2 | 27 | |
28 | ClassImp(AliITSRawStreamSDD) | |
1ba0280f | 29 | |
30 | const UInt_t AliITSRawStreamSDD::fgkCodeLength[8] = {8, 18, 2, 3, 4, 5, 6, 7}; | |
2906f4c2 | 31 | |
979b5a5f | 32 | //______________________________________________________________________ |
2906f4c2 | 33 | AliITSRawStreamSDD::AliITSRawStreamSDD(AliRawReader* rawReader) : |
e56160b8 | 34 | AliITSRawStream(rawReader), |
979b5a5f | 35 | fDDLModuleMap(0), |
e56160b8 | 36 | fData(0), |
0cc008b8 | 37 | fResetSkip(kTRUE), |
a97b3678 | 38 | fEventId(0), |
14dceddf | 39 | fCarlosId(-1), |
e56160b8 | 40 | fChannel(0), |
a97b3678 | 41 | fJitter(0), |
6297cc01 | 42 | fEightBitSignal(0), |
43 | fDecompressAmbra(kTRUE) | |
9c8e7d50 | 44 | { |
2906f4c2 | 45 | // create an object to read ITS SDD raw digits |
27639c72 | 46 | Reset(); |
83ec5e27 | 47 | for(Int_t im=0;im<kSDDModules;im++){ |
48 | fLowThresholdArray[im][0]=0; | |
49 | fLowThresholdArray[im][1]=0; | |
50 | } | |
765a9f95 | 51 | for(Int_t i=0;i<kFifoWords;i++) fNfifo[i]=0; |
a97b3678 | 52 | fRawReader->Reset(); |
362c9d61 | 53 | fRawReader->Select("ITSSDD"); |
1ba0280f | 54 | |
27639c72 | 55 | for(Short_t i=0; i<kCarlosWords; i++) fICarlosWord[i]=0x30000000 + i; // 805306368+i; |
56 | for(Short_t i=0; i<kFifoWords; i++) fIFifoWord[i]=0x30000010 + i; // 805306384+i; | |
1ba0280f | 57 | } |
58 | ||
979b5a5f | 59 | //______________________________________________________________________ |
60 | AliITSRawStreamSDD::AliITSRawStreamSDD(const AliITSRawStreamSDD& rs) : | |
61 | AliITSRawStream(rs.fRawReader), | |
62 | fDDLModuleMap(rs.fDDLModuleMap), | |
63 | fData(0), | |
0cc008b8 | 64 | fResetSkip(kTRUE), |
979b5a5f | 65 | fEventId(0), |
66 | fCarlosId(-1), | |
67 | fChannel(0), | |
68 | fJitter(0), | |
6297cc01 | 69 | fEightBitSignal(0), |
70 | fDecompressAmbra(kTRUE) | |
979b5a5f | 71 | { |
72 | // copy constructor | |
73 | AliError("Copy constructor should not be used."); | |
74 | } | |
75 | //__________________________________________________________________________ | |
76 | AliITSRawStreamSDD& AliITSRawStreamSDD::operator=(const AliITSRawStreamSDD& rs) { | |
77 | // assignment operator | |
78 | if (this!=&rs) {} | |
79 | AliError("Assignment opertator should not be used."); | |
80 | return *this; | |
81 | } | |
82 | ||
83 | //______________________________________________________________________ | |
84 | AliITSRawStreamSDD::~AliITSRawStreamSDD(){ | |
85 | if(fDDLModuleMap) delete fDDLModuleMap; | |
86 | } | |
87 | //______________________________________________________________________ | |
1ba0280f | 88 | UInt_t AliITSRawStreamSDD::ReadBits() |
89 | { | |
90 | // read bits from the given channel | |
a97b3678 | 91 | UInt_t result = (fChannelData[fCarlosId][fChannel] & ((1<<fReadBits[fCarlosId][fChannel]) - 1)); |
92 | fChannelData[fCarlosId][fChannel] >>= fReadBits[fCarlosId][fChannel]; | |
93 | fLastBit[fCarlosId][fChannel] -= fReadBits[fCarlosId][fChannel]; | |
1ba0280f | 94 | return result; |
2906f4c2 | 95 | } |
96 | ||
979b5a5f | 97 | //______________________________________________________________________ |
1ba0280f | 98 | Int_t AliITSRawStreamSDD::DecompAmbra(Int_t value) const |
99 | { | |
a97b3678 | 100 | // AMBRA decompression (from 8 to 10 bit) |
101 | ||
1ba0280f | 102 | if ((value & 0x80) == 0) { |
103 | return value & 0x7f; | |
104 | } else if ((value & 0x40) == 0) { | |
105 | return 0x081 + ((value & 0x3f) << 1); | |
106 | } else if ((value & 0x20) == 0) { | |
107 | return 0x104 + ((value & 0x1f) << 3); | |
108 | } else { | |
109 | return 0x208 + ((value & 0x1f) << 4); | |
110 | } | |
a97b3678 | 111 | |
1ba0280f | 112 | } |
2906f4c2 | 113 | |
979b5a5f | 114 | //______________________________________________________________________ |
2906f4c2 | 115 | Bool_t AliITSRawStreamSDD::Next() |
116 | { | |
117 | // read the next raw digit | |
118 | // returns kFALSE if there is no digit left | |
de075dae | 119 | // returns kTRUE and fCompletedModule=kFALSE and fCompletedDDL=kFALSE when a digit is found |
120 | // returns kTRUE and fCompletedModule=kTRUE and fCompletedDDL=kFALSE when a module is completed (=3x3FFFFFFF footer words) | |
121 | // returns kTRUE and fCompletedModule=kFALSE and fCompletedDDL=kTRUE when a DDL is completed (=jitter word) | |
5dfa68c5 | 122 | |
2906f4c2 | 123 | fPrevModuleID = fModuleID; |
5dfa68c5 | 124 | fCompletedModule=kFALSE; |
a97b3678 | 125 | |
a97b3678 | 126 | while (kTRUE) { |
0cc008b8 | 127 | if(fResetSkip){ |
128 | Reset(); | |
129 | Bool_t kSkip = SkipHeaderWord(); | |
130 | if(!kSkip) return kSkip; | |
131 | fResetSkip=kFALSE; | |
132 | } | |
8345a1cf | 133 | if ((fChannel < 0) || (fCarlosId < 0) || (fChannel >= 2) || (fCarlosId >= kModulesPerDDL) || (fLastBit[fCarlosId][fChannel] < fReadBits[fCarlosId][fChannel]) ) { |
14dceddf | 134 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word |
70881050 | 135 | |
5dfa68c5 | 136 | |
c3ad350c | 137 | if((fData >> 16) == 0x7F00){ // jitter word |
de075dae | 138 | fJitter = fData&0x000000ff; |
0cc008b8 | 139 | fResetSkip=kTRUE; |
de075dae | 140 | fCompletedModule=kFALSE; |
141 | fCompletedDDL=kTRUE; | |
142 | return kTRUE; | |
143 | } | |
5dfa68c5 | 144 | |
14dceddf | 145 | UInt_t nData28= fData >> 28; |
146 | UInt_t nData30= fData >> 30; | |
147 | ||
148 | ||
149 | if (nData28== 0x02) { // header | |
150 | fEventId = (fData >> 3) & 0x07FF; | |
151 | } else if (nData28== 0x03) { // Carlos and FIFO words or Footers | |
152 | if(fData>=fICarlosWord[0]&&fData<=fICarlosWord[11]) { // Carlos Word | |
14dceddf | 153 | fCarlosId = fData-fICarlosWord[0]; |
154 | Int_t iFifoIdx = fCarlosId/3; | |
14dceddf | 155 | fNfifo[iFifoIdx] = fCarlosId; |
156 | } else if (fData>=fIFifoWord[0]&&fData<=fIFifoWord[3]){ // FIFO word | |
14dceddf | 157 | fCarlosId = fNfifo[fData-fIFifoWord[0]]; |
158 | } else if(fData==0x3FFFFFFF){ // Carlos footer | |
fffa954f | 159 | fICountFoot[fCarlosId]++; // stop before the last word (last word=jitter) |
160 | if(fICountFoot[fCarlosId]==3){ | |
161 | fCompletedModule=kTRUE; | |
de075dae | 162 | fCompletedDDL=kFALSE; |
fffa954f | 163 | return kTRUE; |
9c8e7d50 | 164 | } |
14dceddf | 165 | } else if(fData==0x3F1F1F1F){ // CarlosRX footer |
70881050 | 166 | // CARLOSRX footer -- do nothing |
14dceddf | 167 | }else{ |
70881050 | 168 | fRawReader->AddMajorErrorLog(kDataError,"Bad footer"); |
fd2d1992 | 169 | AliWarning(Form("Invalid data: bad footer %08X\n", fData)); |
14dceddf | 170 | return kFALSE; |
9c8e7d50 | 171 | } |
14dceddf | 172 | } else if (nData30 == 0x02 || nData30 == 0x03) { |
173 | fChannel = nData30-2; | |
fffa954f | 174 | fChannelData[fCarlosId][fChannel] += |
175 | (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fCarlosId][fChannel]); | |
176 | fLastBit[fCarlosId][fChannel] += 30; | |
70881050 | 177 | } else if (nData28== 0x04) { |
178 | // JTAG word -- do nothing | |
a97b3678 | 179 | } else { // unknown data format |
9c8e7d50 | 180 | fRawReader->AddMajorErrorLog(kDataFormatErr,Form("Invalid data %8.8x",fData)); |
b24ea968 | 181 | AliWarning(Form("Invalid data: %08X\n", fData)); |
9c8e7d50 | 182 | return kFALSE; |
a97b3678 | 183 | } |
184 | ||
8345a1cf | 185 | if(fCarlosId>=0 && fCarlosId <kModulesPerDDL){ |
e2fc1bc8 | 186 | Int_t nDDL=fRawReader->GetDDLID(); |
b24ea968 | 187 | fModuleID = GetModuleNumber(nDDL,fCarlosId); |
8345a1cf | 188 | } |
a97b3678 | 189 | } else { // decode data |
a97b3678 | 190 | if (fReadCode[fCarlosId][fChannel]) {// read the next code word |
9c8e7d50 | 191 | fChannelCode[fCarlosId][fChannel] = ReadBits(); |
192 | fReadCode[fCarlosId][fChannel] = kFALSE; | |
193 | fReadBits[fCarlosId][fChannel] = fgkCodeLength[fChannelCode[fCarlosId][fChannel]]; | |
a97b3678 | 194 | } else { // read the next data word |
9c8e7d50 | 195 | UInt_t data = ReadBits(); |
196 | fReadCode[fCarlosId][fChannel] = kTRUE; | |
197 | fReadBits[fCarlosId][fChannel] = 3; | |
198 | if (fChannelCode[fCarlosId][fChannel] == 0) { // set the time bin | |
199 | fTimeBin[fCarlosId][fChannel] = data; | |
200 | } else if (fChannelCode[fCarlosId][fChannel] == 1) { // next anode | |
201 | fTimeBin[fCarlosId][fChannel] = 0; | |
202 | fAnode[fCarlosId][fChannel]++; | |
203 | } else { // ADC signal data | |
6297cc01 | 204 | fEightBitSignal=data + (1 << fChannelCode[fCarlosId][fChannel]); |
205 | if(fDecompressAmbra) fSignal = DecompAmbra(fEightBitSignal + fLowThresholdArray[fModuleID-kSPDModules][fChannel]); | |
9c8e7d50 | 206 | fCoord1 = fAnode[fCarlosId][fChannel]; |
207 | fCoord2 = fTimeBin[fCarlosId][fChannel]; | |
208 | fTimeBin[fCarlosId][fChannel]++; | |
de075dae | 209 | fCompletedModule=kFALSE; |
210 | fCompletedDDL=kFALSE; | |
9c8e7d50 | 211 | return kTRUE; |
212 | } | |
a97b3678 | 213 | } |
214 | } | |
215 | } | |
14dceddf | 216 | return kFALSE; |
2906f4c2 | 217 | } |
1ba0280f | 218 | |
979b5a5f | 219 | //______________________________________________________________________ |
a97b3678 | 220 | void AliITSRawStreamSDD::Reset(){ |
765a9f95 | 221 | |
a97b3678 | 222 | //reset data member for a new ddl |
a97b3678 | 223 | for(Int_t i=0;i<2;i++){ |
224 | for(Int_t ic=0;ic<kModulesPerDDL;ic++){ | |
225 | fChannelData[ic][i]=0; | |
226 | fLastBit[ic][i]=0; | |
227 | fChannelCode[ic][i]=0; | |
14dceddf | 228 | fReadCode[ic][i]=kTRUE; |
229 | fReadBits[ic][i]=3; | |
a97b3678 | 230 | fTimeBin[ic][i]=0; |
231 | fAnode[ic][i]=0; | |
b24ea968 | 232 | fICountFoot[ic]=0; |
a97b3678 | 233 | } |
a97b3678 | 234 | } |
a97b3678 | 235 | } |
765a9f95 | 236 | |
979b5a5f | 237 | //______________________________________________________________________ |
83ec5e27 | 238 | Bool_t AliITSRawStreamSDD::SkipHeaderWord(){ |
8345a1cf | 239 | // skip the 1 DDL header word = 0xffffffff |
83ec5e27 | 240 | while (kTRUE) { |
241 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; | |
765a9f95 | 242 | if ((fData >> 30) == 0x01) continue; // JTAG word |
83ec5e27 | 243 | if(fData==0xFFFFFFFF) return kTRUE; |
765a9f95 | 244 | } |
765a9f95 | 245 | } |
246 |