Added option for different binning of DCAxy axis in THnSparse. Same width for all...
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSDDCompressed.cxx
CommitLineData
7765ca40 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 - //
7c1b7bcb 27// 26 detecor side (0= left, =right) //
7765ca40 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// //
7c1b7bcb 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 //
7765ca40 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
71ClassImp(AliITSRawStreamSDDCompressed)
72
73
74
75//______________________________________________________________________
76AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(AliRawReader* rawReader) :
77 AliITSRawStream(rawReader),
294a1728 78 fDDLModuleMap(0),
79 fData(0),
80 fCarlosId(-1),
81 fChannel(0),
82 fJitter(0),
83 fDDL(0),
84 fADCEncoded(0)
7765ca40 85{
86// create an object to read ITS SDD raw digits
7765ca40 87 for(Int_t im=0;im<kSDDModules;im++){
88 fLowThresholdArray[im][0]=0;
89 fLowThresholdArray[im][1]=0;
90 }
91 fRawReader->Reset();
92 fRawReader->Select("ITSSDD");
93
94
95}
96
97//______________________________________________________________________
98AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(const AliITSRawStreamSDDCompressed& rs) :
294a1728 99 AliITSRawStream(rs.fRawReader),
100 fDDLModuleMap(rs.fDDLModuleMap),
101 fData(0),
102 fCarlosId(-1),
103 fChannel(0),
104 fJitter(0),
105 fDDL(0),
106 fADCEncoded(0)
7765ca40 107{
108 // copy constructor
109 AliError("Copy constructor should not be used.");
110}
111//__________________________________________________________________________
112AliITSRawStreamSDDCompressed& AliITSRawStreamSDDCompressed::operator=(const AliITSRawStreamSDDCompressed& rs) {
113 // assignment operator
114 if (this!=&rs) {}
115 AliError("Assignment opertator should not be used.");
116 return *this;
117}
118
119//______________________________________________________________________
120AliITSRawStreamSDDCompressed::~AliITSRawStreamSDDCompressed(){
121 if(fDDLModuleMap) delete fDDLModuleMap;
122}
123
124
125//______________________________________________________________________
6297cc01 126Int_t AliITSRawStreamSDDCompressed::DecompAmbra(Int_t value) const
127{
128 // AMBRA decompression (from 8 to 10 bit)
129
130 if ((value & 0x80) == 0) {
131 return value & 0x7f;
132 } else if ((value & 0x40) == 0) {
0b4ad9b0 133 if(value&1) return 0x080 + ((value & 0x3f) << 1);
6297cc01 134 return 0x081 + ((value & 0x3f) << 1);
135 } else if ((value & 0x20) == 0) {
0b4ad9b0 136 if(value&1) return 0x103 + ((value & 0x1f) << 3);
6297cc01 137 return 0x104 + ((value & 0x1f) << 3);
138 } else {
0b4ad9b0 139 if(value&1) return 0x207 + ((value & 0x1f) << 4);
6297cc01 140 return 0x208 + ((value & 0x1f) << 4);
141 }
142
143}
144//______________________________________________________________________
7765ca40 145Bool_t AliITSRawStreamSDDCompressed::Next()
146{
147// read the next raw digit
148// returns kFALSE if there is no digit left
de075dae 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)
7765ca40 152
f7bcb379 153
7c1b7bcb 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
7765ca40 158 UInt_t maskmod=15; // last 4 bits for module number in end of module word
7765ca40 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
294a1728 164 UInt_t maskCode=7; // 3 bits (0-2) for ADC range in encoded-ADC case
f7bcb379 165
166 while(kTRUE){
f7bcb379 167 if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
168 UInt_t mostsigbits=fData>>28;
d9ed1779 169 if(fData==0xFFFFFFFF){
170 // CarlosRX header do nothing
7c1b7bcb 171 } else if(mostsigbits==idEom){
172 // end of module word
f7bcb379 173 fCarlosId=fData&maskmod;
cb6d8373 174 fDDL=fRawReader->GetDDLID();
4d350ec2 175 if(fDDL<0) return kFALSE;
f7bcb379 176 fModuleID = GetModuleNumber(fDDL,fCarlosId);
de075dae 177 fCompletedDDL=kFALSE;
f7bcb379 178 fCompletedModule=kTRUE;
179 return kTRUE;
7c1b7bcb 180 } else if(mostsigbits==idJit){
181 // jitter word
de075dae 182 fJitter = fData&0x000000ff;
183 fCompletedModule=kFALSE;
184 fCompletedDDL=kTRUE;
185 return kTRUE;
7c1b7bcb 186 } else if(mostsigbits==idJtag){
187 // jtag word -> skipped
188 continue;
189 }else if(mostsigbits<8){
190 // data word
f7bcb379 191 fCarlosId=(fData&maskCarlos)>>27;
cb6d8373 192 fDDL=fRawReader->GetDDLID();
4d350ec2 193 if(fDDL<0) return kFALSE;
f7bcb379 194 fModuleID = GetModuleNumber(fDDL,fCarlosId);
195 fChannel=(fData&maskSide)>>26;
196 fCoord1=(fData&maskAnode)>>18;
197 fCoord2=(fData&maskTb)>>10;
294a1728 198 Int_t sig8bit;
199 if(fADCEncoded){
200 UInt_t code=fData&maskCode;
dae869a3 201 if (code < 2 || code > 7){
202 AliError(Form("Wrong ADC code value %d",code));
203 continue;
204 }
294a1728 205 UInt_t adcmask=(1<<code)-1;
206 sig8bit=((fData&(adcmask<<3))>>3) + (1<<code);
207 }else{
208 sig8bit=fData&maskADC;
209 }
6297cc01 210 sig8bit+=fLowThresholdArray[fModuleID-kSPDModules][fChannel];
211 fSignal=DecompAmbra(sig8bit);
f7bcb379 212 fCompletedModule=kFALSE;
de075dae 213 fCompletedDDL=kFALSE;
f7bcb379 214 return kTRUE;
215 }
7765ca40 216 }
217 return kFALSE;
218}
219
220