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