1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////
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) //
25 // 28 |-> 4 bits to identify the Carlos (0-11) inside the DDL //
27 // 26 detecor side (0= left, =right) //
32 // 21 |-> 8 bits to identify the anode number (0-255) //
40 // 13 |-> 8 bits to identify the time bin (0-255) //
49 // 4 |-> 10 bit for the ADC counts //
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 //
61 // Origin: F.Prino, Torino, prino@to.infn.it //
63 ///////////////////////////////////////////////////////////////////
67 #include "AliITSRawStreamSDDCompressed.h"
68 #include "AliRawReader.h"
71 ClassImp(AliITSRawStreamSDDCompressed)
75 //______________________________________________________________________
76 AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(AliRawReader* rawReader) :
77 AliITSRawStream(rawReader),
86 // create an object to read ITS SDD raw digits
87 for(Int_t im=0;im<kSDDModules;im++){
88 fLowThresholdArray[im][0]=0;
89 fLowThresholdArray[im][1]=0;
92 fRawReader->Select("ITSSDD");
97 //______________________________________________________________________
98 AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(const AliITSRawStreamSDDCompressed& rs) :
99 AliITSRawStream(rs.fRawReader),
100 fDDLModuleMap(rs.fDDLModuleMap),
109 AliError("Copy constructor should not be used.");
111 //__________________________________________________________________________
112 AliITSRawStreamSDDCompressed& AliITSRawStreamSDDCompressed::operator=(const AliITSRawStreamSDDCompressed& rs) {
113 // assignment operator
115 AliError("Assignment opertator should not be used.");
119 //______________________________________________________________________
120 AliITSRawStreamSDDCompressed::~AliITSRawStreamSDDCompressed(){
121 if(fDDLModuleMap) delete fDDLModuleMap;
125 //______________________________________________________________________
126 Int_t AliITSRawStreamSDDCompressed::DecompAmbra(Int_t value) const
128 // AMBRA decompression (from 8 to 10 bit)
130 if ((value & 0x80) == 0) {
132 } else if ((value & 0x40) == 0) {
133 if(value&1) return 0x080 + ((value & 0x3f) << 1);
134 return 0x081 + ((value & 0x3f) << 1);
135 } else if ((value & 0x20) == 0) {
136 if(value&1) return 0x103 + ((value & 0x1f) << 3);
137 return 0x104 + ((value & 0x1f) << 3);
139 if(value&1) return 0x207 + ((value & 0x1f) << 4);
140 return 0x208 + ((value & 0x1f) << 4);
144 //______________________________________________________________________
145 Bool_t AliITSRawStreamSDDCompressed::Next()
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)
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
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
167 if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
168 UInt_t mostsigbits=fData>>28;
169 if(fData==0xFFFFFFFF){
170 // CarlosRX header do nothing
171 } else if(mostsigbits==idEom){
172 // end of module word
173 fCarlosId=fData&maskmod;
174 fDDL=fRawReader->GetDDLID();
175 if(fDDL<0) return kFALSE;
176 fModuleID = GetModuleNumber(fDDL,fCarlosId);
177 fCompletedDDL=kFALSE;
178 fCompletedModule=kTRUE;
180 } else if(mostsigbits==idJit){
182 fJitter = fData&0x000000ff;
183 fCompletedModule=kFALSE;
186 } else if(mostsigbits==idJtag){
187 // jtag word -> skipped
189 }else if(mostsigbits<8){
191 fCarlosId=(fData&maskCarlos)>>27;
192 fDDL=fRawReader->GetDDLID();
193 if(fDDL<0) return kFALSE;
194 fModuleID = GetModuleNumber(fDDL,fCarlosId);
195 fChannel=(fData&maskSide)>>26;
196 fCoord1=(fData&maskAnode)>>18;
197 fCoord2=(fData&maskTb)>>10;
200 UInt_t code=fData&maskCode;
201 if (code < 2 || code > 7){
202 AliError(Form("Wrong ADC code value %d",code));
205 UInt_t adcmask=(1<<code)-1;
206 sig8bit=((fData&(adcmask<<3))>>3) + (1<<code);
208 sig8bit=fData&maskADC;
210 sig8bit+=fLowThresholdArray[fModuleID-kSPDModules][fChannel];
211 fSignal=DecompAmbra(sig8bit);
212 fCompletedModule=kFALSE;
213 fCompletedDDL=kFALSE;