Version rewised by VT 13/05/2008 (see PMSang_base) and further modified by Magali at the end of 2008
calculate momentum in transverse and in longitudinal projections using the different measurements errors parametrisation
256{
265
268 if(nseg<2) {
Log(1,
"PMSang",
"Warning! nseg<2 (%d)- impossible estimate momentum!",nseg);
return -99;}
269 if(npl<nseg) {
Log(1,
"PMSang",
"Warning! npl<nseg (%d, %d) - use track.SetCounters() first",npl,nseg);
return -99;}
270 int plmax = Max(
tr.GetSegmentFirst()->PID(),
tr.GetSegmentLast()->PID() ) + 1;
271 if(plmax<1||plmax>1000) {
Log(1,
"PMSang",
"Warning! plmax = %d - correct the segments PID's!",plmax);
return -99;}
272
273
274 float xmean,ymean,zmean,txmean,tymean,wmean;
275 float xmean0,ymean0,zmean0,txmean0,tymean0,wmean0;
277 float tmean=Sqrt(txmean0*txmean0+ tymean0*tymean0);
278
280 float sigmax=0, sigmay=0;
281 for (
int i =0;i<
tr.N();i++)
282 {
283 aas=
tr.GetSegment(i);
284 sigmax+=(txmean0-aas->
TX())*(txmean0-aas->
TX());
285 sigmay+=(tymean0-aas->
TY())*(tymean0-aas->
TY());
286 }
287 sigmax= Sqrt(sigmax/
tr.N());
288 sigmay= Sqrt(sigmay/
tr.N());
289 for (
int i =0;i<
tr.N();i++)
290 {
291 aas=
tr.GetSegment(i);
292 if(Abs(aas->
TX()-txmean0)>3*sigmax||Abs(aas->
TY()-tymean0)>3*sigmay) {
293 aas->
Set(aas->
ID(),aas->
X(),aas->
Y(),0.,0.,aas->
W(),aas->
Flag());}
294 }
295
297
298
299
300
301
302
303 float PHI=atan2(txmean0,tymean0);
304 for (
int i =0;i<
tr.N();i++)
305 {
306 aas=
tr.GetSegment(i);
307 float slx=aas->
TY()*cos(-PHI)-aas->
TX()*sin(-PHI);
308 float sly=aas->
TX()*cos(-PHI)+ aas->
TY()*sin(-PHI);
309 aas->
Set(aas->
ID(),aas->
X(),aas->
Y(),slx,sly,aas->
W(),aas->
Flag());
310 }
311
313
314
315
316
317
318
320 int stepmax = npl-1;
321 const int size = stepmax+1;
322
323 TVectorF da(size), dax(size), day(size);
324 TArrayI nentr(size), nentrx(size), nentry(size);
325
327 for(int ist=1; ist<=stepmax; ist++)
328 {
329 for(int i1=0; i1<nseg-1; i1++)
330 {
331 s1 =
tr.GetSegment(i1);
333 for(int i2=i1+1; i2<nseg; i2++)
334 {
335 s2 =
tr.GetSegment(i2);
338 if( icell == ist )
339 {
341 {
342 dax[icell-1] += ( (ATan(
s2->
TX())- ATan(
s1->
TX())) * (ATan(
s2->
TX())- ATan(
s1->
TX())) );
343 nentrx[icell-1]+=1;
344 }
346 {
347 day[icell-1] += ( (ATan(
s2->
TY())- ATan(
s1->
TY())) * (ATan(
s2->
TY())- ATan(
s1->
TY())) );
348 nentry[icell-1]+=1;
349 }
351 {
352 da[icell-1] += (( (ATan(
s2->
TX())- ATan(
s1->
TX())) * (ATan(
s2->
TX())- ATan(
s1->
TX())) )
354 nentr[icell-1] +=1;
355 }
356 }
357 }
358 }
359 }
360
361 float Zcorr = Sqrt(1+txmean0*txmean0+tymean0*tymean0);
362
363 int maxX =0, maxY=0, max3D=0;
364 TVectorF vindx(size), errvindx(size),vindy(size), errvindy(size),vind3d(size), errvind3d(size);
365 TVectorF errda(size), errdax(size), errday(size);
366 int ist=0, ist1=0, ist2=0;
367 for(int i=0; i<size; i++)
368 {
369 if( nentrx[i] >= minentr && Abs(dax[i])<0.1)
370 {
371 vindx[ist] = i+1;
372 errvindx[ist] = .25;
373 dax[ist] = Sqrt( dax[i]/(nentrx[i]*Zcorr) );
374 errdax[ist] = dax[ist]/Sqrt(2*nentrx[i]);
375 ist++;
376 maxX=i+1;
377 }
378 if( nentry[i] >= minentr && Abs(day[i])<0.1)
379 {
380 vindy[ist1] = i+1;
381 errvindy[ist1] = .25;
382 day[ist1] = Sqrt( day[i]/(nentry[i]*Zcorr) );
383 errday[ist1] = day[ist1]/Sqrt(2*nentry[i]);
384 ist1++;
385 maxY=i+1;
386 }
387 if( nentr[i] >= minentr/2 && Abs(da[i])<0.1 )
388 {
389 vind3d[ist2] = i+1;
390 errvind3d[ist2] = .25;
391 da[ist2] = Sqrt( da[i]/(2*nentr[i]*Zcorr) );
392 errda[ist2] = da[ist2]/Sqrt(4*nentr[i]);
393 ist2++;
394 max3D=i+1;
395 }
396 }
397
399 dt*=dt;
400 float dtx =
GetDTx(txmean);
401 dtx*=dtx;
402 float dty =
GetDTy(tymean);
403 dty*=dty;
404
406 float chi2_3D =0;
407 float chi2_T =0;
408 float chi2_L =0;
409
416
418 eF1X->SetParameter(0,2000.);
420 eF1Y->SetParameter(0,2000.);
422 eF1->SetParameter(0,2000.);
423
424 if (max3D>0)
425 {
426 eG=
new TGraphErrors(vind3d,da,errvind3d,errda);
428 eP=1./1000.*Abs(
eF1->GetParameter(0));
429 eDP=1./1000.*
eF1->GetParError(0);
432 chi2_3D =
eF1->GetChisquare()/
eF1->GetNDF();
433 if (
eVerbose) printf(
"P3D=%7.2f GeV ; 90%%C.L. range = [%6.2f : %6.2f] ; chi2_3D %6.2f\n",
eP,
ePmin,
ePmax,chi2_3D);
434 }
435 if (maxX>0)
436 {
437 eGX=
new TGraphErrors(vindx,dax,errvindx,errdax);
438 eGX->Fit(
"eF1X",
"QR");
439 ePx=1./1000.*Abs(
eF1X->GetParameter(0));
443 chi2_L =
eF1X->GetChisquare()/
eF1X->GetNDF();
444 if (
eVerbose) printf(
"PL=%7.2f GeV ; 90%%C.L. range = [%6.2f : %6.2f] ; chi2_L %6.2f \n",
ePx,
ePXmin,
ePXmax,chi2_L);
445 }
446 if (maxY>0)
447 {
448 eGY=
new TGraphErrors(vindy,day,errvindy,errday);
449 eGY->Fit(
"eF1Y",
"QR");
450 ePy=1./1000.*Abs(
eF1Y->GetParameter(0));
454 chi2_T =
eF1Y->GetChisquare()/
eF1Y->GetNDF();
455 if (
eVerbose) printf(
"PT=%7.2f GeV ; 90%%C.L. range = [%6.2f : %6.2f] ; chi2_T %6.2f\n",
ePy,
ePYmin,
ePYmax,chi2_T);
456 }
457
459 if (tmean>0.200&&chi2_T<chi2_3D)
460 {
462 if (
eVerbose) printf(
" For this track the evolution of the Transverse projection gives the most accurate estimate of the momentum %7.2f GeV ; 90%%C.L. range = [%6.2f : %6.2f] ; chi2_T /DoF %6.2f\n",
ePy,
ePYmin,
ePYmax,chi2_T);
463}
464
465
466
467
468
469
470
471 return ptrue;
472}
double GetDTx(double Tx)
Definition: EdbMomentumEstimator.h:81
TF1 * MCSErrorFunction(const char *name, float x0, float dtx)
Definition: EdbMomentumEstimator.cxx:658
float eDPy
the fit error
Definition: EdbMomentumEstimator.h:37
float ePx
the fit results
Definition: EdbMomentumEstimator.h:36
double GetDTy(double Ty)
Definition: EdbMomentumEstimator.h:82
float ePy
the estimated momentum
Definition: EdbMomentumEstimator.h:36
float eDPx
Definition: EdbMomentumEstimator.h:37
void EstimateMomentumError(float P, int npl, float ang, float &pmin, float &pmax)
Definition: EdbMomentumEstimator.cxx:699
float eDP
Definition: EdbMomentumEstimator.h:43
double GetDTs(double Ts)
Definition: EdbMomentumEstimator.h:83
Int_t ID() const
Definition: EdbSegP.h:147
Float_t W() const
Definition: EdbSegP.h:151
Int_t Flag() const
Definition: EdbSegP.h:149
void Set(int id, float x, float y, float tx, float ty, float w, int flag)
Definition: EdbSegP.h:87
int FitTrackLine(EdbTrackP &tr)
Definition: EdbTrackFitter.cxx:520