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