Line data Source code
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 : // Class to decode compressed SDD Raw Data format //
21 : // The 32 bits for a data word are defined as follows: //
22 : // 31 control bit (0=data word, 1= control word) //
23 : // 30 - //
24 : // 29 | //
25 : // 28 |-> 4 bits to identify the Carlos (0-11) inside the DDL //
26 : // 27 - //
27 : // 26 detecor side (0= left, =right) //
28 : // 25 - //
29 : // 24 | //
30 : // 23 | //
31 : // 22 | //
32 : // 21 |-> 8 bits to identify the anode number (0-255) //
33 : // 20 | //
34 : // 19 | //
35 : // 18 - //
36 : // 17 - //
37 : // 16 | //
38 : // 15 | //
39 : // 14 | //
40 : // 13 |-> 8 bits to identify the time bin (0-255) //
41 : // 12 | //
42 : // 11 | //
43 : // 10 - //
44 : // 9 - //
45 : // 8 | //
46 : // 7 | //
47 : // 6 | //
48 : // 5 | //
49 : // 4 |-> 10 bit for the ADC counts //
50 : // 3 | //
51 : // 2 | //
52 : // 1 | //
53 : // 0 - //
54 : // //
55 : // Plus 3 types of control words //
56 : // identified by the the 4 most significant bits (31-28) //
57 : // 1) Jitter word = 1000 //
58 : // 2) JTAG answer = 1100 //
59 : // 3) End of module data (needed by the Cluster Finder) = 1111 //
60 : // //
61 : // Origin: F.Prino, Torino, prino@to.infn.it //
62 : // //
63 : ///////////////////////////////////////////////////////////////////
64 :
65 :
66 :
67 : #include "AliITSRawStreamSDDCompressed.h"
68 : #include "AliRawReader.h"
69 : #include "AliLog.h"
70 :
71 118 : ClassImp(AliITSRawStreamSDDCompressed)
72 :
73 :
74 :
75 : //______________________________________________________________________
76 : AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(AliRawReader* rawReader) :
77 0 : AliITSRawStream(rawReader),
78 0 : fDDLModuleMap(0),
79 0 : fData(0),
80 0 : fCarlosId(-1),
81 0 : fChannel(0),
82 0 : fJitter(0),
83 0 : fDDL(0),
84 0 : fADCEncoded(0)
85 0 : {
86 : // create an object to read ITS SDD raw digits
87 0 : for(Int_t im=0;im<kSDDModules;im++){
88 0 : fLowThresholdArray[im][0]=0;
89 0 : fLowThresholdArray[im][1]=0;
90 : }
91 0 : fRawReader->Reset();
92 0 : fRawReader->Select("ITSSDD");
93 :
94 :
95 0 : }
96 :
97 : //______________________________________________________________________
98 : AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(const AliITSRawStreamSDDCompressed& rs) :
99 0 : AliITSRawStream(rs.fRawReader),
100 0 : fDDLModuleMap(rs.fDDLModuleMap),
101 0 : fData(0),
102 0 : fCarlosId(-1),
103 0 : fChannel(0),
104 0 : fJitter(0),
105 0 : fDDL(0),
106 0 : fADCEncoded(0)
107 0 : {
108 : // copy constructor
109 0 : AliError("Copy constructor should not be used.");
110 0 : }
111 : //__________________________________________________________________________
112 : AliITSRawStreamSDDCompressed& AliITSRawStreamSDDCompressed::operator=(const AliITSRawStreamSDDCompressed& rs) {
113 : // assignment operator
114 : if (this!=&rs) {}
115 0 : AliError("Assignment opertator should not be used.");
116 0 : return *this;
117 : }
118 :
119 : //______________________________________________________________________
120 0 : AliITSRawStreamSDDCompressed::~AliITSRawStreamSDDCompressed(){
121 0 : if(fDDLModuleMap) delete fDDLModuleMap;
122 0 : }
123 :
124 :
125 : //______________________________________________________________________
126 : Int_t AliITSRawStreamSDDCompressed::DecompAmbra(Int_t value) const
127 : {
128 : // AMBRA decompression (from 8 to 10 bit)
129 :
130 0 : if ((value & 0x80) == 0) {
131 0 : return value & 0x7f;
132 0 : } else if ((value & 0x40) == 0) {
133 0 : if(value&1) return 0x080 + ((value & 0x3f) << 1);
134 0 : return 0x081 + ((value & 0x3f) << 1);
135 0 : } else if ((value & 0x20) == 0) {
136 0 : if(value&1) return 0x103 + ((value & 0x1f) << 3);
137 0 : return 0x104 + ((value & 0x1f) << 3);
138 : } else {
139 0 : if(value&1) return 0x207 + ((value & 0x1f) << 4);
140 0 : return 0x208 + ((value & 0x1f) << 4);
141 : }
142 :
143 0 : }
144 : //______________________________________________________________________
145 : Bool_t AliITSRawStreamSDDCompressed::Next()
146 : {
147 : // read the next raw digit
148 : // returns kFALSE if there is no digit left
149 : // returns kTRUE and fCompletedModule=kFALSE and fCompletedDDL=kFALSE when a digit is found
150 : // returns kTRUE and fCompletedModule=kTRUE and fCompletedDDL=kFALSE when a module is completed (=3x3FFFFFFF footer words)
151 : // returns kTRUE and fCompletedModule=kFALSE and fCompletedDDL=kTRUE when a DDL is completed (=jitter word)
152 :
153 :
154 : UInt_t idJit=8; // Jitter word has the 4 most significant bits = 1000
155 : UInt_t idEom=15; // end of module has the 4 most significant bits = 1111
156 : UInt_t idJtag=12; // end of module has the 4 most significant bits = 1100
157 :
158 : UInt_t maskmod=15; // last 4 bits for module number in end of module word
159 : UInt_t maskCarlos=15<<27; // 4 bits (27-30) for CarlosId in data word
160 : UInt_t maskSide=1<<26; // 1 bit (26) for side in data word
161 : UInt_t maskAnode=255<<18; // 8 bits (18-25) for Nanode in data word
162 : UInt_t maskTb=255<<10; // 8 bits (10-27) for Ntimebin in data word
163 : UInt_t maskADC=1023; // 10 bits (0-9) for ADC in data word
164 : UInt_t maskCode=7; // 3 bits (0-2) for ADC range in encoded-ADC case
165 :
166 0 : while(kTRUE){
167 0 : if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
168 0 : UInt_t mostsigbits=fData>>28;
169 0 : if(fData==0xFFFFFFFF){
170 : // CarlosRX header do nothing
171 0 : } else if(mostsigbits==idEom){
172 : // end of module word
173 0 : fCarlosId=fData&maskmod;
174 0 : fDDL=fRawReader->GetDDLID();
175 0 : if(fDDL<0) return kFALSE;
176 0 : fModuleID = GetModuleNumber(fDDL,fCarlosId);
177 0 : fCompletedDDL=kFALSE;
178 0 : fCompletedModule=kTRUE;
179 0 : return kTRUE;
180 0 : } else if(mostsigbits==idJit){
181 : // jitter word
182 0 : fJitter = fData&0x000000ff;
183 0 : fCompletedModule=kFALSE;
184 0 : fCompletedDDL=kTRUE;
185 0 : return kTRUE;
186 0 : } else if(mostsigbits==idJtag){
187 : // jtag word -> skipped
188 0 : continue;
189 0 : }else if(mostsigbits<8){
190 : // data word
191 0 : fCarlosId=(fData&maskCarlos)>>27;
192 0 : fDDL=fRawReader->GetDDLID();
193 0 : if(fDDL<0) return kFALSE;
194 0 : fModuleID = GetModuleNumber(fDDL,fCarlosId);
195 0 : fChannel=(fData&maskSide)>>26;
196 0 : fCoord1=(fData&maskAnode)>>18;
197 0 : fCoord2=(fData&maskTb)>>10;
198 : Int_t sig8bit;
199 0 : if(fADCEncoded){
200 0 : UInt_t code=fData&maskCode;
201 0 : if (code < 2 || code > 7){
202 0 : AliError(Form("Wrong ADC code value %d",code));
203 0 : continue;
204 : }
205 0 : UInt_t adcmask=(1<<code)-1;
206 0 : sig8bit=((fData&(adcmask<<3))>>3) + (1<<code);
207 0 : }else{
208 0 : sig8bit=fData&maskADC;
209 : }
210 0 : sig8bit+=fLowThresholdArray[fModuleID-kSPDModules][fChannel];
211 0 : fSignal=DecompAmbra(sig8bit);
212 0 : fCompletedModule=kFALSE;
213 0 : fCompletedDDL=kFALSE;
214 0 : return kTRUE;
215 : }
216 0 : }
217 : return kFALSE;
218 0 : }
219 :
220 :
|