1 |
nikolas |
1.1 |
#include "PamVMCTrkDig.h" |
2 |
|
|
#include <TMath.h> |
3 |
|
|
|
4 |
|
|
ClassImp(PamVMCTrkDig) |
5 |
|
|
|
6 |
|
|
using TMath::Abs; |
7 |
|
|
|
8 |
|
|
void PamVMCTrkDig::LoadFile(){ |
9 |
|
|
|
10 |
|
|
cout<<"Loading Tracker Calibrations..."<<endl; |
11 |
|
|
|
12 |
|
|
Int_t time=0; |
13 |
|
|
Int_t type=8; |
14 |
|
|
|
15 |
|
|
fdberr = fsql->Query_GL_PARAM(time,type); |
16 |
|
|
//we hardcoded values of time and type of calibrations |
17 |
|
|
//later we'll introduce an options which allow us to load |
18 |
|
|
//from different sources |
19 |
|
|
|
20 |
|
|
if(fdberr<0){ |
21 |
|
|
TString crfname = fpath+"/CalibTrk_00110_000_000.root"; |
22 |
|
|
cout<<"No such record in DB for TRK: time="<<time |
23 |
|
|
<<" type="<<type<<endl |
24 |
|
|
<<"We will use file:"<<crfname<<endl; |
25 |
|
|
|
26 |
|
|
fcrfile = new TFile(crfname); |
27 |
|
|
|
28 |
|
|
} else { |
29 |
|
|
|
30 |
|
|
fquery.str(""); |
31 |
|
|
fquery << fsql->GetPAR()->PATH.Data() << "/"; |
32 |
|
|
fquery << fsql->GetPAR()->NAME.Data(); |
33 |
|
|
|
34 |
|
|
ThrowCalFileUsage("TRK",fquery.str().c_str()); |
35 |
|
|
|
36 |
|
|
fcrfile = new TFile(fquery.str().c_str()); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
if(!fcrfile) ThrowCalFileWarning("TRK"); else |
40 |
|
|
if(fcrfile->IsZombie()){ |
41 |
|
|
ThrowCalFileWarning("TRK"); //critical error |
42 |
|
|
return; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
//Load calibrations. I don't know, some empiric numbers of |
46 |
|
|
//broken VA chips introduced. Should be load as options.. |
47 |
|
|
|
48 |
|
|
//------X-plane------// |
49 |
|
|
TTree *tr1 = (TTree*)fcrfile->Get("CalibTrk1"); |
50 |
|
|
CalibTrk1Event *caldata1 = 0; |
51 |
|
|
tr1->SetBranchAddress("CalibTrk1",&caldata1); |
52 |
|
|
tr1->GetEntry(1); |
53 |
|
|
|
54 |
|
|
Int_t Kview,jj; |
55 |
|
|
|
56 |
|
|
for (Int_t i=0; i<6;i++) { |
57 |
|
|
for (Int_t j=0; j<3072;j++) { |
58 |
|
|
jj=j; |
59 |
|
|
// broken va1 replaced |
60 |
|
|
BrokenStrip(0,4,i,j,jj); |
61 |
|
|
BrokenStrip(5,12,i,j,jj); |
62 |
|
|
|
63 |
|
|
Kview=caldata1->DSPnumber[i]-1; |
64 |
|
|
fPedeTrack[Kview][j]=caldata1->DSPped_par[i][jj]; |
65 |
|
|
fSigmaTrack[Kview][j]=caldata1->DSPsig_par[i][jj]; |
66 |
|
|
if(caldata1->DSPbad_par[i][jj]==1) fSigmaTrack[Kview][j]=-fSigmaTrack[Kview][j]; |
67 |
|
|
}; |
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
//------Y-plane------// |
71 |
|
|
TTree *tr2 = (TTree*)fcrfile->Get("CalibTrk2"); |
72 |
|
|
CalibTrk2Event *caldata2 = 0; |
73 |
|
|
tr2->SetBranchAddress("CalibTrk2",&caldata2); |
74 |
|
|
tr2->GetEntry(1); |
75 |
|
|
|
76 |
|
|
for (Int_t i=0; i<6;i++) { |
77 |
|
|
for (Int_t j=0; j<3072;j++) { |
78 |
|
|
jj=j; |
79 |
|
|
// broken va1 replaced |
80 |
|
|
BrokenStrip(2,3,i,j,jj); |
81 |
|
|
BrokenStrip(2,5,i,j,jj); |
82 |
|
|
BrokenStrip(2,6,i,j,jj); |
83 |
|
|
BrokenStrip(2,7,i,j,jj); |
84 |
|
|
BrokenStrip(2,11,i,j,jj); |
85 |
|
|
|
86 |
|
|
Kview=caldata2->DSPnumber[i]-1; |
87 |
|
|
fPedeTrack[Kview][j]=caldata2->DSPped_par[i][jj]; |
88 |
|
|
fSigmaTrack[Kview][j]=caldata2->DSPsig_par[i][jj]; |
89 |
|
|
if(caldata2->DSPbad_par[i][jj]==1) fSigmaTrack[Kview][j]=-fSigmaTrack[Kview][j]; |
90 |
|
|
}; |
91 |
|
|
}; |
92 |
|
|
|
93 |
|
|
fcrfile->Close(); |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
|
97 |
|
|
void PamVMCTrkDig::DigitizeTrackCalib(Int_t n){ |
98 |
|
|
|
99 |
|
|
cout<<"Starting Tracker Calibrations..."<<endl; |
100 |
|
|
if( (n!=1)&&(n!=2) ) { |
101 |
|
|
cout << "!!!ERROR: Wrong DigitizeTrackCalib argument!!!" << endl; |
102 |
|
|
return; |
103 |
|
|
}; |
104 |
|
|
|
105 |
|
|
fData.clear(); |
106 |
|
|
|
107 |
|
|
UShort_t Dato; |
108 |
|
|
|
109 |
|
|
USBuffer tempdat; //temporary buffer to keep data before writing DSP data |
110 |
|
|
USBuffer::const_iterator p; //iterator; |
111 |
|
|
|
112 |
|
|
Float_t dato1,dato2,dato3,dato4; |
113 |
|
|
UShort_t DatoDec,DatoDec1,DatoDec2,DatoDec3,DatoDec4; |
114 |
|
|
UShort_t EVENT_CAL, PED_L1, ReLength,OveCheckCode; |
115 |
|
|
UShort_t CkSum; |
116 |
|
|
|
117 |
|
|
for (Int_t j=n-1; j<fNviews;j+=2) { //0(1)...12 |
118 |
|
|
CkSum=0; |
119 |
|
|
// here skip the dsp header and his trailer , to be written later |
120 |
|
|
tempdat.clear(); //clearing temporary buffer |
121 |
|
|
for (Int_t i=0; i<fNladder;i++) { //0...2 |
122 |
|
|
for (Int_t k=0; k<fNstrips_ladder;k++) { //0...1023 |
123 |
|
|
// write in buffer the current LADDER |
124 |
|
|
Dato=(UShort_t)fPedeTrack[j][i*fNstrips_ladder+k]; |
125 |
|
|
dato1=fPedeTrack[j][i*fNstrips_ladder+k]-Dato; |
126 |
|
|
|
127 |
|
|
DatoDec1=(UShort_t)(dato1*2); |
128 |
|
|
dato2=dato1*2-DatoDec1; |
129 |
|
|
|
130 |
|
|
DatoDec2=(UShort_t)(dato2*2); |
131 |
|
|
dato3=dato2*2-DatoDec2; |
132 |
|
|
|
133 |
|
|
DatoDec3=(UShort_t)(dato3*2); |
134 |
|
|
dato4=dato3*2-DatoDec3; |
135 |
|
|
|
136 |
|
|
DatoDec4=(UShort_t)(dato4*2); |
137 |
|
|
|
138 |
|
|
DatoDec=DatoDec1*0x0008+DatoDec2*0x0004+DatoDec3*0x0002+DatoDec4*0x0001; |
139 |
|
|
|
140 |
|
|
tempdat.push_back( ((Dato << 4) | (DatoDec & 0x000F)) ); |
141 |
|
|
CkSum^=tempdat.back(); |
142 |
|
|
}; |
143 |
|
|
|
144 |
|
|
for (Int_t k=0; k<fNstrips_ladder;k++) { //0...1023 |
145 |
|
|
// write in buffer the current LADDER |
146 |
|
|
Dato=(UShort_t)fabs(fSigmaTrack[j][i*fNstrips_ladder+k]); |
147 |
|
|
dato1=fabs(fSigmaTrack[j][i*fNstrips_ladder+k])-Dato; |
148 |
|
|
|
149 |
|
|
DatoDec1=(UShort_t)(dato1*2); |
150 |
|
|
dato2=dato1*2-DatoDec1; |
151 |
|
|
|
152 |
|
|
DatoDec2=(UShort_t)(dato2*2); |
153 |
|
|
dato3=dato2*2-DatoDec2; |
154 |
|
|
|
155 |
|
|
DatoDec3=(UShort_t)(dato3*2); |
156 |
|
|
dato4=dato3*2-DatoDec3; |
157 |
|
|
|
158 |
|
|
DatoDec4=(UShort_t)(dato4*2); |
159 |
|
|
|
160 |
|
|
DatoDec=DatoDec1*0x0008+DatoDec2*0x0004+DatoDec3*0x0002+DatoDec4*0x0001; |
161 |
|
|
|
162 |
|
|
tempdat.push_back( ((Dato << 4) | (DatoDec & 0x000F)) ); |
163 |
|
|
CkSum^=tempdat.back(); |
164 |
|
|
}; |
165 |
|
|
|
166 |
|
|
for (Int_t k=0; k<64;k++) { //0...63 |
167 |
|
|
UShort_t DatoBad=0x0000; |
168 |
|
|
for (Int_t nb=0; nb<16;nb++) { |
169 |
|
|
if( fSigmaTrack[j][i*fNstrips_ladder+k*16+nb]<0. ) DatoBad=( DatoBad | (0x8000 >> nb) ); |
170 |
|
|
}; |
171 |
|
|
|
172 |
|
|
tempdat.push_back(DatoBad); |
173 |
|
|
CkSum^=tempdat.back(); |
174 |
|
|
}; |
175 |
|
|
// end ladder |
176 |
|
|
|
177 |
|
|
// write in buffer the end ladder word |
178 |
|
|
|
179 |
|
|
switch(i){ |
180 |
|
|
case 0: |
181 |
|
|
tempdat.push_back(0x1807); |
182 |
|
|
break; |
183 |
|
|
case 1: |
184 |
|
|
tempdat.push_back(0x1808); |
185 |
|
|
break; |
186 |
|
|
case 2: |
187 |
|
|
tempdat.push_back(0x1808); |
188 |
|
|
break; |
189 |
|
|
default: |
190 |
|
|
break; |
191 |
|
|
} |
192 |
|
|
CkSum^=tempdat.back(); |
193 |
|
|
|
194 |
|
|
// write in buffer the TRAILER |
195 |
|
|
ReLength=(UShort_t)((fNstrips_ladder*2+64+1)*2+3); |
196 |
|
|
OveCheckCode=0x0000; |
197 |
|
|
|
198 |
|
|
|
199 |
|
|
tempdat.push_back(0x0000); |
200 |
|
|
tempdat.push_back((ReLength >> 8)); |
201 |
|
|
tempdat.push_back(( (ReLength << 8) | (OveCheckCode & 0x00FF) )); |
202 |
|
|
|
203 |
|
|
}; // end TRAILER |
204 |
|
|
|
205 |
|
|
cout<<"LENGTH OF TEMPDAT"<<tempdat.size()<<endl; |
206 |
|
|
// write in buffer the DSP header |
207 |
|
|
|
208 |
|
|
fData.push_back((0xE800 | ( ((j+1) << 3) | 0x0005) )); |
209 |
|
|
fData.push_back(0x01A9); |
210 |
|
|
fData.push_back(0x8740); |
211 |
|
|
EVENT_CAL=0; |
212 |
|
|
fData.push_back((0x1A00 | ( (0x03FF & EVENT_CAL)>> 1) )); |
213 |
|
|
PED_L1=0; |
214 |
|
|
fData.push_back(( ((EVENT_CAL << 15) | 0x5002 ) | ((0x03FF & PED_L1) << 2) )); |
215 |
|
|
fData.push_back(0x8014); |
216 |
|
|
fData.push_back(0x00A0); |
217 |
|
|
fData.push_back(0x0500); |
218 |
|
|
fData.push_back(0x2801); |
219 |
|
|
fData.push_back(0x400A); |
220 |
|
|
fData.push_back(0x0050); |
221 |
|
|
CkSum=(CkSum >> 8)^(CkSum&0x00FF); |
222 |
|
|
fData.push_back((0x0280 | (CkSum >> 3))); |
223 |
|
|
fData.push_back((0x1FFF | (CkSum << 13) )); |
224 |
|
|
|
225 |
|
|
ReLength=(UShort_t)((13*2)+3); |
226 |
|
|
OveCheckCode=0x0000; |
227 |
|
|
fData.push_back(0x0000); |
228 |
|
|
fData.push_back((ReLength >> 8)); |
229 |
|
|
fData.push_back(( (ReLength << 8) | (OveCheckCode & 0x00FF) )); |
230 |
|
|
cout<<"fDATA length before adding:"<<fData.size()<<endl; |
231 |
|
|
// Now we will copy to fData vector data from tempdat: |
232 |
|
|
p = tempdat.begin(); |
233 |
|
|
while( p != tempdat.end() ){ |
234 |
|
|
fData.push_back(*p); |
235 |
|
|
p++; |
236 |
|
|
} |
237 |
|
|
cout<<"fDATA length after adding:"<<fData.size()<<endl; |
238 |
|
|
}; |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
void PamVMCTrkDig::WriteCalib(){ |
242 |
|
|
cout<<"Writing Tracker Calibrations..."<<endl; |
243 |
|
|
fraw->WritePSCU(&fDataPSCU); |
244 |
|
|
fraw->CopyUShortToBuff(&fData); |
245 |
|
|
if(fPadding) fraw->WritePadding(&fDataPadding); |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
void PamVMCTrkDig::LoadMipCor(){ |
249 |
|
|
|
250 |
|
|
std:: cout << "Entering LoadMipCor" << endl; |
251 |
|
|
|
252 |
|
|
Float_t xfactor=1./151.6*1.04; |
253 |
|
|
Float_t yfactor=1./152.1; |
254 |
|
|
|
255 |
|
|
fMipCor[0][0]=140.02*yfactor; |
256 |
|
|
fMipCor[0][1]=140.99*xfactor; |
257 |
|
|
fMipCor[0][2]=134.48*yfactor; |
258 |
|
|
fMipCor[0][3]=144.41*xfactor; |
259 |
|
|
fMipCor[0][4]=140.74*yfactor; |
260 |
|
|
fMipCor[0][5]=142.28*xfactor; |
261 |
|
|
fMipCor[0][6]=134.53*yfactor; |
262 |
|
|
fMipCor[0][7]=140.63*xfactor; |
263 |
|
|
fMipCor[0][8]=135.55*yfactor; |
264 |
|
|
fMipCor[0][9]=138.00*xfactor; |
265 |
|
|
fMipCor[0][10]=154.95*yfactor; |
266 |
|
|
fMipCor[0][11]=158.44*xfactor; |
267 |
|
|
|
268 |
|
|
|
269 |
|
|
fMipCor[1][0]=136.07*yfactor; |
270 |
|
|
fMipCor[1][1]=135.59*xfactor; |
271 |
|
|
fMipCor[1][2]=142.69*yfactor; |
272 |
|
|
fMipCor[1][3]=138.19*xfactor; |
273 |
|
|
fMipCor[1][4]=137.35*yfactor; |
274 |
|
|
fMipCor[1][5]=140.23*xfactor; |
275 |
|
|
fMipCor[1][6]=153.15*yfactor; |
276 |
|
|
fMipCor[1][7]=151.42*xfactor; |
277 |
|
|
fMipCor[1][8]=129.76*yfactor; |
278 |
|
|
fMipCor[1][9]=140.63*xfactor; |
279 |
|
|
fMipCor[1][10]=157.87*yfactor; |
280 |
|
|
fMipCor[1][11]=153.64*xfactor; |
281 |
|
|
|
282 |
|
|
fMipCor[2][0]=134.98*yfactor; |
283 |
|
|
fMipCor[2][1]=143.95*xfactor; |
284 |
|
|
fMipCor[2][2]=140.23*yfactor; |
285 |
|
|
fMipCor[2][3]=138.88*xfactor; |
286 |
|
|
fMipCor[2][4]=137.95*yfactor; |
287 |
|
|
fMipCor[2][5]=134.87*xfactor; |
288 |
|
|
fMipCor[2][6]=157.56*yfactor; |
289 |
|
|
fMipCor[2][7]=157.31*xfactor; |
290 |
|
|
fMipCor[2][8]=141.37*yfactor; |
291 |
|
|
fMipCor[2][9]=143.39*xfactor; |
292 |
|
|
fMipCor[2][10]=156.15*yfactor; |
293 |
|
|
fMipCor[2][11]=158.79*xfactor; |
294 |
|
|
|
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
|
298 |
|
|
void PamVMCTrkDig::Digitize(){ |
299 |
|
|
|
300 |
|
|
fData.clear(); |
301 |
|
|
|
302 |
|
|
|
303 |
|
|
Int_t Iview; |
304 |
|
|
Int_t Nstrip; |
305 |
|
|
|
306 |
|
|
for (Int_t j=0; j<fNviews;j++) { |
307 |
|
|
|
308 |
|
|
for (Int_t i=0; i<fNladder;i++) { |
309 |
|
|
|
310 |
|
|
Float_t commonN1=gRandom->Gaus(0.,fSigmaCommon); |
311 |
|
|
Float_t commonN2=gRandom->Gaus(0.,fSigmaCommon); |
312 |
|
|
for (Int_t k=0; k<fNstrips_ladder;k++) { |
313 |
|
|
Nstrip=i*fNstrips_ladder+k; |
314 |
|
|
Float_t Sigma=Abs(fSigmaTrack[j][Nstrip]); |
315 |
|
|
AdcTrack[j][Nstrip]=gRandom->Gaus(fPedeTrack[j][Nstrip],Sigma ); |
316 |
|
|
if(k<4*128) {AdcTrack[j][Nstrip] += commonN1;} // full correlation of 4 VA1 Com. Noise |
317 |
|
|
else {AdcTrack[j][Nstrip] += commonN2;} // full correlation of 4 VA1 Com. Noise |
318 |
|
|
if(AdcTrack[j][Nstrip] < 0. ) AdcTrack[j][Nstrip]=0.; |
319 |
|
|
if(AdcTrack[j][Nstrip] > 4095.) AdcTrack[j][Nstrip]=4095.; |
320 |
|
|
}; |
321 |
|
|
}; |
322 |
|
|
}; |
323 |
|
|
|
324 |
|
|
if (fhits){ |
325 |
|
|
Float_t ADCfull; |
326 |
|
|
Int_t iladd=0; |
327 |
|
|
for (Int_t ix=0; ix<fhits->GetNXHit();ix++) { |
328 |
|
|
Iview=((fhits->GetXHit(ix))->fnpstrip)*2-1; |
329 |
|
|
Nstrip=(Int_t)((fhits->GetXHit(ix))->fistrip); //-1 |
330 |
|
|
if(Nstrip<fNstrips_ladder) iladd=0; |
331 |
|
|
if((Nstrip>=fNstrips_ladder)&&(Nstrip<2*fNstrips_ladder)) iladd=1; |
332 |
|
|
if((Nstrip>=2*fNstrips_ladder)&&(Nstrip<3*fNstrips_ladder)) iladd=2; |
333 |
|
|
ADCfull=AdcTrack[Iview][Nstrip] += ((fhits->GetXHit(ix))->fqstrip)*fMipCor[iladd][Iview]; |
334 |
|
|
AdcTrack[Iview][Nstrip] *= SaturationTrackx(ADCfull); |
335 |
|
|
}; |
336 |
|
|
|
337 |
|
|
|
338 |
|
|
for (Int_t iy=0; iy<fhits->GetNYHit();iy++) { |
339 |
|
|
Iview=((fhits->GetYHit(iy))->fnpstrip)*2-2; |
340 |
|
|
Nstrip=(Int_t)((fhits->GetYHit(iy))->fistrip); //-1 |
341 |
|
|
if(Nstrip<fNstrips_ladder) iladd=0; |
342 |
|
|
if((Nstrip>=fNstrips_ladder)&&(Nstrip<2*fNstrips_ladder)) iladd=1; |
343 |
|
|
if((Nstrip>=2*fNstrips_ladder)&&(Nstrip<3*fNstrips_ladder)) iladd=2; |
344 |
|
|
ADCfull=AdcTrack[Iview][Nstrip] -= ((fhits->GetYHit(iy))->fqstrip)*fMipCor[iladd][Iview]; |
345 |
|
|
AdcTrack[Iview][Nstrip] *= SaturationTracky(ADCfull); |
346 |
|
|
}; |
347 |
|
|
|
348 |
|
|
CompressTrackData(); |
349 |
|
|
}; |
350 |
|
|
} |
351 |
|
|
|
352 |
|
|
|
353 |
|
|
void PamVMCTrkDig::CompressTrackData(){ |
354 |
|
|
|
355 |
|
|
// copy of the corresponding compression fortran routine + new digitization |
356 |
|
|
|
357 |
|
|
Int_t oldval=0; |
358 |
|
|
Int_t newval=0; |
359 |
|
|
Int_t trasmesso=0; |
360 |
|
|
Int_t ntrastot=0; |
361 |
|
|
Float_t real, inte; |
362 |
|
|
Int_t cercacluster=0; |
363 |
|
|
Int_t kt=0; |
364 |
|
|
static const int DSPbufferSize = 4000; // 13 bit buffer to be rearranged in 16 bit Track buffer |
365 |
|
|
UShort_t DataDSP[DSPbufferSize]; // 13 bit buffer to be rearranged in 16 bit Track buffer |
366 |
|
|
UShort_t DSPlength; // 13 bit buffer to be rearranged in 16 bit Track buffer |
367 |
|
|
UShort_t CheckSum, Nword, Dato, DATA, ReLength, OveCheckCode; |
368 |
|
|
Int_t k, diff, clval, clvalp, klp, kl1, kl2, Bit16free, Bit13ToWrite; |
369 |
|
|
|
370 |
|
|
|
371 |
|
|
for (Int_t iv=0; iv<fNviews;iv++) { |
372 |
|
|
memset(DataDSP,0,sizeof(UShort_t)*DSPbufferSize); |
373 |
|
|
DSPlength=16; // skip the header, to be written later |
374 |
|
|
CheckSum=0; |
375 |
|
|
|
376 |
|
|
for (Int_t ladder=0; ladder<fNladder;ladder++) { |
377 |
|
|
k=0; |
378 |
|
|
while (k<fNstrips_ladder) { |
379 |
|
|
// compress write in buffer the current LADDER |
380 |
|
|
if ( k == 0) { |
381 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+k],&inte); |
382 |
|
|
if (real > 0.5) inte=inte+1; |
383 |
|
|
newval=(Int_t)inte -(Int_t)fPedeTrack[iv][ladder*fNstrips_ladder+k]; |
384 |
|
|
// first strip of ladder is transmitted |
385 |
|
|
DataDSP[DSPlength]=( ((UShort_t)inte) & 0x0FFF); |
386 |
|
|
DSPlength++; |
387 |
|
|
ntrastot++; |
388 |
|
|
trasmesso=1; |
389 |
|
|
oldval=newval; |
390 |
|
|
kt=k; |
391 |
|
|
k++; |
392 |
|
|
continue; |
393 |
|
|
}; |
394 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+k],&inte); |
395 |
|
|
if (real > 0.5) inte=inte+1; |
396 |
|
|
newval=(Int_t)inte -(Int_t)(fPedeTrack[iv][ladder*fNstrips_ladder+k]); |
397 |
|
|
|
398 |
|
|
cercacluster=1; //PAR? |
399 |
|
|
|
400 |
|
|
if (cercacluster==1) { |
401 |
|
|
|
402 |
|
|
diff=0; |
403 |
|
|
switch ((iv+1)%2) { |
404 |
|
|
case 0: diff=newval-oldval; |
405 |
|
|
break; |
406 |
|
|
case 1: diff=oldval-newval; |
407 |
|
|
break; |
408 |
|
|
}; |
409 |
|
|
|
410 |
|
|
|
411 |
|
|
if (diff>fCutclu*(Int_t)fabs(fSigmaTrack[iv][ladder*fNstrips_ladder+k]) ) { |
412 |
|
|
clval=newval; |
413 |
|
|
klp=k; // go on to search for maximum |
414 |
|
|
klp++; |
415 |
|
|
|
416 |
|
|
while(klp<fNstrips_ladder) { |
417 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+klp],&inte); |
418 |
|
|
if (real > 0.5) inte=inte+1; |
419 |
|
|
clvalp=(Int_t)inte -(Int_t)fPedeTrack[iv][ladder*fNstrips_ladder+klp]; |
420 |
|
|
if((iv+1)%2==0) { |
421 |
|
|
|
422 |
|
|
if(clvalp>clval) { |
423 |
|
|
clval=clvalp; |
424 |
|
|
k=klp;} |
425 |
|
|
else break; // max of cluster found |
426 |
|
|
|
427 |
|
|
} else { |
428 |
|
|
|
429 |
|
|
if(clvalp<clval) { |
430 |
|
|
clval=clvalp; |
431 |
|
|
k=klp;} |
432 |
|
|
else break; // max of cluster found |
433 |
|
|
}; |
434 |
|
|
klp++; |
435 |
|
|
}; |
436 |
|
|
|
437 |
|
|
kl1=k-fNclst; // max of cluster (or end of ladder ?) |
438 |
|
|
trasmesso=0; |
439 |
|
|
if(kl1<0) kl1=0; |
440 |
|
|
if(kt>=kl1) kl1=kt+1; |
441 |
|
|
if( (kt+1)==kl1 ) trasmesso=1; |
442 |
|
|
|
443 |
|
|
kl2=k+fNclst; |
444 |
|
|
if(kl2>=fNstrips_ladder) kl2=fNstrips_ladder-1; |
445 |
|
|
|
446 |
|
|
for(Int_t klt=kl1 ; klt<=kl2 ; klt++) { |
447 |
|
|
if(trasmesso==0) { |
448 |
|
|
|
449 |
|
|
DataDSP[DSPlength]=( ((UShort_t)klt) | 0x1000); |
450 |
|
|
DSPlength++; |
451 |
|
|
ntrastot++; |
452 |
|
|
|
453 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+klt],&inte); |
454 |
|
|
if (real > 0.5) inte=inte+1; |
455 |
|
|
DataDSP[DSPlength]=( ((UShort_t)inte) & 0x0FFF); |
456 |
|
|
DSPlength++; |
457 |
|
|
ntrastot++; |
458 |
|
|
|
459 |
|
|
} |
460 |
|
|
else { |
461 |
|
|
|
462 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+klt],&inte); |
463 |
|
|
if (real > 0.5) inte=inte+1; |
464 |
|
|
DataDSP[DSPlength]=( ((UShort_t)inte) & 0x0FFF); |
465 |
|
|
DSPlength++; |
466 |
|
|
ntrastot++; |
467 |
|
|
}; |
468 |
|
|
trasmesso=1; |
469 |
|
|
}; // end trasmission |
470 |
|
|
kt=kl2; |
471 |
|
|
k=kl2; |
472 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+kt],&inte); |
473 |
|
|
if (real > 0.5) inte=inte+1; |
474 |
|
|
oldval=(Int_t)inte -(Int_t)fPedeTrack[iv][ladder*fNstrips_ladder+kt]; |
475 |
|
|
k++; |
476 |
|
|
continue; |
477 |
|
|
} |
478 |
|
|
}//END cercacluster |
479 |
|
|
|
480 |
|
|
// start ZOP check for strips no |
481 |
|
|
|
482 |
|
|
if(abs(newval-oldval)>=fCutzop*(Int_t)fabs(fSigmaTrack[iv][ladder*fNstrips_ladder+k]) ) { if(trasmesso==0) { |
483 |
|
|
|
484 |
|
|
DataDSP[DSPlength]=( ((UShort_t)k) | 0x1000); |
485 |
|
|
DSPlength++; |
486 |
|
|
ntrastot++; |
487 |
|
|
|
488 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+k],&inte); |
489 |
|
|
if (real > 0.5) inte=inte+1; |
490 |
|
|
DataDSP[DSPlength]=( ((UShort_t)inte) & 0x0FFF); |
491 |
|
|
DSPlength++; |
492 |
|
|
ntrastot++; |
493 |
|
|
|
494 |
|
|
} else { |
495 |
|
|
real=modff(AdcTrack[iv][ladder*fNstrips_ladder+k],&inte); |
496 |
|
|
if (real > 0.5) inte=inte+1; |
497 |
|
|
DataDSP[DSPlength]=( ((UShort_t)inte) & 0x0FFF); |
498 |
|
|
DSPlength++; |
499 |
|
|
ntrastot++; |
500 |
|
|
}; |
501 |
|
|
trasmesso=1; |
502 |
|
|
oldval=newval; |
503 |
|
|
kt=k; |
504 |
|
|
|
505 |
|
|
} |
506 |
|
|
else trasmesso=0; |
507 |
|
|
// end zop |
508 |
|
|
k++; |
509 |
|
|
}; |
510 |
|
|
|
511 |
|
|
DataDSP[DSPlength]=( ((UShort_t)(ladder+1)) | 0x1800); |
512 |
|
|
DSPlength++; |
513 |
|
|
ntrastot++; |
514 |
|
|
trasmesso=0; |
515 |
|
|
|
516 |
|
|
}; //end cycle inside dsp |
517 |
|
|
|
518 |
|
|
// here put DSP header |
519 |
|
|
DataDSP[0]=(0x1CA0 | ((UShort_t)(iv+1)) ); |
520 |
|
|
Nword=(DSPlength*13)/16; |
521 |
|
|
if( ((DSPlength*13)%16)!=0) Nword++; |
522 |
|
|
DataDSP[1]=(0x1400 | ( Nword >> 10)); |
523 |
|
|
DataDSP[2]=(0x1400 | ( Nword & 0x03FF) ); |
524 |
|
|
DataDSP[3]=(0x1400 | (( (UShort_t)(fraw->GetCounter() >> 10) ) & 0x03FF) ); |
525 |
|
|
DataDSP[4]=(0x1400 | (( (UShort_t)(fraw->GetCounter()) ) & 0x03FF) ); |
526 |
|
|
DataDSP[5]=(0x1400 | ( (UShort_t)(fNclst << 7) ) | ( (UShort_t)(fCutzop << 4) ) |
527 |
|
|
| ( (UShort_t)fCutzop ) ); |
528 |
|
|
DataDSP[6]=0x1400; |
529 |
|
|
DataDSP[7]=0x1400; |
530 |
|
|
DataDSP[8]=0x1400; |
531 |
|
|
DataDSP[9]=0x1400; |
532 |
|
|
DataDSP[10]=0x1400; |
533 |
|
|
DataDSP[11]=0x1400; |
534 |
|
|
DataDSP[12]=0x1400; |
535 |
|
|
DataDSP[13]=0x1400; |
536 |
|
|
DataDSP[14]=(0x1400 | (CheckSum & 0x00FF) ); |
537 |
|
|
DataDSP[15]=0x1C00; |
538 |
|
|
// end DSP header |
539 |
|
|
|
540 |
|
|
// write 13 bit DataDSP bufer inside 16 bit fDataTrack buffer |
541 |
|
|
|
542 |
|
|
Bit16free=16; |
543 |
|
|
DATA = 0; |
544 |
|
|
for (Int_t NDSP=0; NDSP<DSPlength;NDSP++) { |
545 |
|
|
Bit13ToWrite=13; |
546 |
|
|
while(Bit13ToWrite>0) { |
547 |
|
|
if(Bit13ToWrite<=Bit16free) { |
548 |
|
|
Dato=((DataDSP[NDSP]&(0xFFFF >> (16-Bit13ToWrite)))<<(Bit16free-Bit13ToWrite)); |
549 |
|
|
DATA = DATA | Dato ; |
550 |
|
|
Bit16free=Bit16free-Bit13ToWrite; |
551 |
|
|
Bit13ToWrite=0; |
552 |
|
|
if(Bit16free==0) { |
553 |
|
|
if(NDSP>15) CheckSum=CheckSum^DATA; |
554 |
|
|
fData.push_back(DATA); |
555 |
|
|
DATA = 0; |
556 |
|
|
Bit16free=16; |
557 |
|
|
}; |
558 |
|
|
} |
559 |
|
|
else if(Bit13ToWrite>Bit16free) { |
560 |
|
|
Dato=( (DataDSP[NDSP]&(0xFFFF >> (16-Bit13ToWrite) ) ) >> (Bit13ToWrite-Bit16free) ); |
561 |
|
|
DATA = DATA | Dato ; |
562 |
|
|
fData.push_back(DATA); |
563 |
|
|
if(NDSP>15) CheckSum=CheckSum^DATA; |
564 |
|
|
DATA = 0; |
565 |
|
|
Bit13ToWrite=Bit13ToWrite-Bit16free; |
566 |
|
|
Bit16free=16; |
567 |
|
|
}; |
568 |
|
|
|
569 |
|
|
}; // end cycle while(Bit13ToWrite>0) |
570 |
|
|
|
571 |
|
|
}; // end cycle DataDSP |
572 |
|
|
|
573 |
|
|
if(Bit16free!=16) { |
574 |
|
|
fData.push_back(DATA); |
575 |
|
|
DATA= 0; |
576 |
|
|
CheckSum=CheckSum^DATA; |
577 |
|
|
}; |
578 |
|
|
CheckSum=(CheckSum >> 8)^(CheckSum&0x00FF); |
579 |
|
|
fData.at(fData.size()-Nword+11)=(0x0280 | (CheckSum >> 3)); |
580 |
|
|
fData.at(fData.size()-Nword+12)=(0x1C00 | (CheckSum << 13) ); |
581 |
|
|
|
582 |
|
|
// end write 13 bit DataDSP bufer inside 16 bit fDataTrack buffer |
583 |
|
|
|
584 |
|
|
//write trailer on buffer |
585 |
|
|
ReLength=(UShort_t)((Nword+13)*2+3); |
586 |
|
|
OveCheckCode=0x0000; |
587 |
|
|
fData.push_back(0x0000); |
588 |
|
|
fData.push_back((ReLength >> 8)); |
589 |
|
|
fData.push_back(( (ReLength << 8) | (OveCheckCode & 0x00FF) )); |
590 |
|
|
|
591 |
|
|
// end trailer |
592 |
|
|
|
593 |
|
|
|
594 |
|
|
}//END VIEWS CYCLE |
595 |
|
|
|
596 |
|
|
|
597 |
|
|
} |
598 |
|
|
|
599 |
|
|
|
600 |
|
|
Float_t PamVMCTrkDig::SaturationTrackx(Float_t ADC) { |
601 |
|
|
Float_t SatFact=1.; |
602 |
|
|
if(ADC<1.) { SatFact=1./ADC; }; |
603 |
|
|
if(ADC>3000.) { SatFact=3000./ADC; }; |
604 |
|
|
return SatFact; |
605 |
|
|
}; |
606 |
|
|
|
607 |
|
|
|
608 |
|
|
Float_t PamVMCTrkDig::SaturationTracky(Float_t ADC) { |
609 |
|
|
Float_t SatFact=1.; |
610 |
|
|
if(ADC<70.) { SatFact=70./ADC; }; |
611 |
|
|
if(ADC>4095.) { SatFact=4095./ADC; }; |
612 |
|
|
return SatFact; |
613 |
|
|
}; |