FEDRA emulsion software from the OPERA Collaboration
EdbTrackFitter Class Reference

#include <EdbTrackFitter.h>

Inheritance diagram for EdbTrackFitter:
Collaboration diagram for EdbTrackFitter:

Public Member Functions

float Chi2SegM (EdbSegP s1, EdbSegP s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
 
float Chi2SegMCS (const EdbSegP &s1, const EdbSegP &s2)
 
 EdbTrackFitter ()
 
int Fit3Pos (EdbTrackP &tr)
 
int FitTrackLine (const EdbTrackP &tr, float &x, float &y, float &z, float &tx, float &ty, float &w)
 
int FitTrackLine (EdbTrackP &tr)
 
float PMS_KF (EdbTrackP &t, float p0=10., float probbest=0.5)
 
void Print ()
 
double ProbSegMCS (EdbSegP *s1, EdbSegP *s2)
 
void SetDefaultBrick ()
 
void SetNsegMax (int nseg)
 
bool SplitTrack (EdbTrackP &t, EdbTrackP &t1, int isplit)
 
int SplitTrackByKink (EdbTrackP *t, TObjArray &tracks, float maxkink)
 
virtual ~EdbTrackFitter ()
 

Static Public Member Functions

static float Chi2ACP (EdbSegP s1, EdbSegP s2, EdbScanCond &cond)
 
static float Chi2ASeg (EdbSegP &s1, EdbSegP &s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
 
static float Chi2ASegLL (EdbSegP &s1, EdbSegP &s2, EdbSegP &s, EdbScanCond &cond1, EdbScanCond &cond2)
 
static float Chi2PSeg (EdbSegP &s1, EdbSegP &s2, EdbSegP &seg, EdbScanCond &cond1, EdbScanCond &cond2)
 
static float Chi2Seg (EdbSegP *s1, EdbSegP *s2)
 
static float MaxChi2Seg (EdbTrackP &tr)
 
static float MaxKink (EdbTrackP &tr)
 
static float MeanChi2Seg (EdbTrackP &tr)
 
static float MeanKink (EdbTrackP &tr)
 
static int RMSprojXY (EdbTrackP &tr, float &ex, float &ey)
 
static float Theta (EdbSegP &s, EdbSegP &s1)
 

Public Attributes

bool eDE_correction
 
float eM
 
float ePcut
 
float ePdef
 
float eTPb
 
float eX0
 

Private Attributes

int eNsegMax
 

Constructor & Destructor Documentation

◆ EdbTrackFitter()

EdbTrackFitter::EdbTrackFitter ( )
38 {
40 }
void SetDefaultBrick()
Definition: EdbTrackFitter.cxx:43

◆ ~EdbTrackFitter()

virtual EdbTrackFitter::~EdbTrackFitter ( )
inlinevirtual
31 {}

Member Function Documentation

◆ Chi2ACP()

float EdbTrackFitter::Chi2ACP ( EdbSegP  s1,
EdbSegP  s2,
EdbScanCond cond 
)
static
125 {
126  // Exact copy of the function traditionally used for the linking of couples
127  //
128  // fast estimation of chi2 in the special case when the position
129  // errors of segments are negligible in respect to angular errors:
130  // sigmaXY/dz << sigmaTXY
131  // application: up/down linking, alignment (offset search)
132  //
133  // All calculation are done in the track plane which remove the
134  // dependency of the polar angle (phi)
135 
136  TVector3 v1,v2,v;
137  v1.SetXYZ( s1.TX(), s1.TY() , -1. );
138  v2.SetXYZ( s2.TX(), s2.TY() , -1. );
139  v.SetXYZ( -( s2.X() - s1.X() ),
140  -( s2.Y() - s1.Y() ),
141  -( s2.Z() - s1.Z() ) );
142 
143  float phi = v.Phi();
144  v.RotateZ( -phi );
145  v1.RotateZ( -phi );
146  v2.RotateZ( -phi );
147 
148  float dz = v.Z();
149  float tx = v.X()/dz;
150  float ty = v.Y()/dz;
151  float stx = cond.SigmaTX(tx);
152  float sty = cond.SigmaTY(ty);
153 
154  float prob1=1., prob2=1.;
155  //if(iprob) {
156  prob1 = cond.ProbSeg(tx,ty,s1.W());
157  prob2 = cond.ProbSeg(tx,ty,s2.W());
158  // }
159  float dtx1 = (v1.X()-tx)*(v1.X()-tx)/stx/stx/prob1;
160  float dty1 = (v1.Y()-ty)*(v1.Y()-ty)/sty/sty/prob1;
161  float dtx2 = (v2.X()-tx)*(v2.X()-tx)/stx/stx/prob2;
162  float dty2 = (v2.Y()-ty)*(v2.Y()-ty)/sty/sty/prob2;
163 
164  float chi2a=TMath::Sqrt(dtx1+dty1+dtx2+dty2)/2.;
165  return chi2a;
166 }
brick dz
Definition: RecDispMC.C:107
float SigmaTX(float ax) const
Definition: EdbScanCond.h:106
float SigmaTY(float ay) const
Definition: EdbScanCond.h:107
float ProbSeg(float tx, float ty, float puls) const
Definition: EdbScanCond.cxx:119
Float_t TX() const
Definition: EdbSegP.h:172
Float_t X() const
Definition: EdbSegP.h:170
Float_t Z() const
Definition: EdbSegP.h:150
Float_t Y() const
Definition: EdbSegP.h:171
Float_t W() const
Definition: EdbSegP.h:148
Float_t TY() const
Definition: EdbSegP.h:173
EdbSegP * s1
Definition: tlg2pattern.C:30
EdbSegP * s2
Definition: tlg2pattern.C:31

◆ Chi2ASeg()

float EdbTrackFitter::Chi2ASeg ( EdbSegP s1,
EdbSegP s2,
EdbSegP seg,
EdbScanCond cond1,
EdbScanCond cond2 
)
static

217 {
218  // fast estimation of chi2 in the special case when the position
219  // errors of segments are negligible in respect to angular errors:
220  // sigmaXY/dz << sigmaTXY
221  // application: up/down linking,
222  //
223  // All calculation are done in the track plane which remove the
224  // dependency of the polar angle (phi)
225 
226  Float_t dz = s2.Z() - s1.Z();
227  seg.Set( 0,
228  0.5*(s1.X() + s2.X()),
229  0.5*(s1.Y() + s2.Y()),
230  (s2.X() - s1.X())/dz,
231  (s2.Y() - s1.Y())/dz,
232  s1.W() + s2.W(),
233  0);
234  seg.SetZ( 0.5*(s2.Z()+s1.Z()) );
235 
236  Float_t phi = -seg.Phi();
237  Double_t s = TMath::Sin(phi);
238  Double_t c = TMath::Cos(phi);
239  Float_t tx = seg.TX()*c-seg.TY()*s;
240  Float_t ty = seg.TX()*s+seg.TY()*c;
241  Float_t tx1 = s1.TX()*c-s1.TY()*s;
242  Float_t ty1 = s1.TX()*s+s1.TY()*c;
243  Float_t tx2 = s2.TX()*c-s2.TY()*s;
244  Float_t ty2 = s2.TX()*s+s2.TY()*c;
245 
246  Float_t stx = cond1.SigmaTX(tx);
247  Float_t sty = cond1.SigmaTY(ty);
248  Float_t prob1 = cond1.ProbSeg(tx,ty,s1.W());
249  Float_t prob2 = cond2.ProbSeg(tx,ty,s2.W());
250 
251  Float_t dtx1 = (tx1-tx)*(tx1-tx)/stx/stx/prob1;
252  Float_t dty1 = (ty1-ty)*(ty1-ty)/sty/sty/prob1;
253  Float_t dtx2 = (tx2-tx)*(tx2-tx)/stx/stx/prob2;
254  Float_t dty2 = (ty2-ty)*(ty2-ty)/sty/sty/prob2;
255  Float_t chi2a = Sqrt(dtx1+dty1+dtx2+dty2)/2.;
256 
257  seg.SetChi2(chi2a);
258  return chi2a;
259 }
void SetZ(float z)
Definition: EdbSegP.h:122
void SetChi2(float chi2)
Definition: EdbSegP.h:132
Float_t Phi() const
Definition: EdbSegP.h:180
void Set(int id, float x, float y, float tx, float ty, float w, int flag)
Definition: EdbSegP.h:86
EdbSegP * s
Definition: tlg2pattern.C:32

◆ Chi2ASegLL()

float EdbTrackFitter::Chi2ASegLL ( EdbSegP s1,
EdbSegP s2,
EdbSegP s,
EdbScanCond cond1,
EdbScanCond cond2 
)
static
170 {
171  // fast estimation of chi2 in the special case when the position
172  // errors of segments are negligible in respect to angular errors:
173  // sigmaXY/dz << sigmaTXY
174  // application: up/down linking,
175  //
176  // All calculation are done in the track plane which remove the
177  // dependency of the polar angle (phi)
178  // In this function the Likelihood estimated by Andrey and stored in s1.eChi2 and s2.eChi2 are used
179 
180  Float_t dz = s2.Z() - s1.Z();
181  seg.Set( 0,
182  0.5*(s1.X() + s2.X()),
183  0.5*(s1.Y() + s2.Y()),
184  (s2.X() - s1.X())/dz,
185  (s2.Y() - s1.Y())/dz,
186  s1.W() + s2.W(),
187  0);
188  seg.SetZ( 0.5*(s2.Z()+s1.Z()) );
189 
190  Float_t phi = -seg.Phi();
191  Double_t s = TMath::Sin(phi);
192  Double_t c = TMath::Cos(phi);
193  Float_t tx = seg.TX()*c-seg.TY()*s;
194  Float_t ty = seg.TX()*s+seg.TY()*c;
195  Float_t tx1 = s1.TX()*c-s1.TY()*s;
196  Float_t ty1 = s1.TX()*s+s1.TY()*c;
197  Float_t tx2 = s2.TX()*c-s2.TY()*s;
198  Float_t ty2 = s2.TX()*s+s2.TY()*c;
199 
200  Float_t stx = cond1.SigmaTX(tx);
201  Float_t sty = cond1.SigmaTY(ty);
202  Float_t prob1 = cond1.ProbLL(tx,ty,s1.Chi2());
203  Float_t prob2 = cond2.ProbLL(tx,ty,s2.Chi2());
204 
205  Float_t dtx1 = (tx1-tx)*(tx1-tx)/stx/stx/prob1;
206  Float_t dty1 = (ty1-ty)*(ty1-ty)/sty/sty/prob1;
207  Float_t dtx2 = (tx2-tx)*(tx2-tx)/stx/stx/prob2;
208  Float_t dty2 = (ty2-ty)*(ty2-ty)/sty/sty/prob2;
209  Float_t chi2a = Sqrt(dtx1+dty1+dtx2+dty2)/2.;
210 
211  seg.SetChi2(chi2a);
212  return chi2a;
213 }
float ProbLL(float tx, float ty, float puls) const
Definition: EdbScanCond.cxx:145
Float_t Chi2() const
Definition: EdbSegP.h:154

◆ Chi2PSeg()

float EdbTrackFitter::Chi2PSeg ( EdbSegP s1,
EdbSegP s2,
EdbSegP seg,
EdbScanCond cond1,
EdbScanCond cond2 
)
static

263 {
264  // fast estimation of chi2 in the special case when only the position
265  // errors used - no any angular informtion:
266  // application: alignment
267 
268  seg.Set( 0,
269  0.5*(s1.X() + s2.X()),
270  0.5*(s1.Y() + s2.Y()),
271  0.5*(s1.TX() + s2.TX()),
272  0.5*(s1.TY() + s2.TY()),
273  s1.W() + s2.W(),
274  0);
275  seg.SetZ( 0.5*(s2.Z()+s1.Z()) );
276 
277  Double_t dx = s2.X()-s1.X();
278  Double_t dy = s2.Y()-s1.Y();
279  Float_t sx = cond1.SigmaX(s1.Theta()); // to test!
280  Float_t sy = cond1.SigmaY(s1.Theta()); // use the same value since MCS is the main source of errors(theta) in SND conditions
281  Double_t chi2 = Sqrt( dx*dx/sx/sx + dy*dy/sy/sy );
282  seg.SetChi2(chi2);
283  return chi2;
284 }
float SigmaX(float ax) const
Definition: EdbScanCond.h:102
float SigmaY(float ay) const
Definition: EdbScanCond.h:103
Float_t Theta() const
Definition: EdbSegP.h:181
Float_t chi2
Definition: testBGReduction_By_ANN.C:14

◆ Chi2Seg()

float EdbTrackFitter::Chi2Seg ( EdbSegP s1,
EdbSegP s2 
)
static
63 {
64  // Estimation of chi2 using the covariance matrix
65  // Return value: Prob: is Chi2 probability (area of the tail of Chi2-distribution)
66  // If we accept couples with Prob >= ProbMin then ProbMin is the
67  // probability to reject the good couple
68  //
69  // The mass and momentum of the tr are used for multiple scattering estimation
70 
71  double dz;
72  float prob;
73  VtVector par( (double)(tr->X()),
74  (double)(tr->Y()),
75  (double)(tr->TX()),
76  (double)(tr->TY()) );
77  VtSymMatrix cov(4); // covariance matrix for seg0 (measurements errors)
78  for(int k=0; k<4; k++)
79  for(int l=0; l<4; l++) cov(k,l) = (tr->COV())(k,l);
80 
81  Double_t chi2=0.;
82  dz = s->Z()-tr->Z();
83  VtSqMatrix pred(4); //propagation matrix for track parameters (x,y,tx,ty)
84  pred.clear();
85  pred(0,0) = 1.;
86  pred(1,1) = 1.;
87  pred(2,2) = 1.;
88  pred(3,3) = 1.;
89  pred(0,2) = dz;
90  pred(1,3) = dz;
91  VtVector parpred(4); // prediction from seg0 to seg
92  parpred = pred*par;
93  VtSymMatrix covpred(4); // covariance matrix for prediction
94  covpred = pred*(cov*pred.T());
95 
96  VtSymMatrix dmeas(4); // original covariance matrix for seg2
97  for(int k=0; k<4; k++)
98  for(int l=0; l<4; l++) dmeas(k,l) = (s->COV())(k,l);
99 
100  covpred = covpred.dsinv();
101  dmeas = dmeas.dsinv();
102  cov = covpred + dmeas;
103  cov = cov.dsinv();
104 
105  VtVector meas( (double)(s->X()),
106  (double)(s->Y()),
107  (double)(s->TX()),
108  (double)(s->TY()) );
109 
110  par = cov*(covpred*parpred + dmeas*meas); // new parameters for seg
111  chi2 = (par-parpred)*(covpred*(par-parpred)) + (par-meas)*(dmeas*(par-meas));
112  prob = (float)TMath::Prob(chi2,4);
113 
114  tr->Set(tr->ID(),(float)par(0),(float)par(1),(float)par(2),(float)par(3),tr->W(),tr->Flag());
115  tr->SetCOV( cov.array(), 4 );
116  tr->SetChi2((float)chi2);
117  tr->SetProb(prob);
118  tr->SetZ(s->Z());
119  tr->SetW(tr->W()+s->W());
120  return TMath::Sqrt(chi2/4.);
121 }
T Prob(const T &rhs, int n)
Definition: Prob.hh:37
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
TMatrixD & COV() const
Definition: EdbSegP.h:120
Definition: VtSqMatrix.hh:50
Definition: VtSymMatrix.hh:49
Definition: VtVector.hh:45

◆ Chi2SegM()

float EdbTrackFitter::Chi2SegM ( EdbSegP  s1,
EdbSegP  s2,
EdbSegP s,
EdbScanCond cond1,
EdbScanCond cond2 
)
315 {
316  // full estimation of chi2 without covariance matrix - the result seems to be identical to Chi2Seg
317  // VT: 19-Sep-2007
318  //
319  // Input: 2 segments passed by value because them will be modified during calculations
320  // Return value - the result of the fit - passed by value
321 
322  // 1) calcualte the mean direction vector for the 2-seg group
323 
324  float dz = s2.Z() - s1.Z();
325  float tbx=0, tby=0, wbx=0, wby=0;
326  if(Abs(dz) > 0.1 ) {
327  tbx = (s2.X() - s1.X())/(s2.Z() - s1.Z());
328  tby = (s2.Y() - s1.Y())/(s2.Z() - s1.Z());
329  wbx = Sqrt( cond1.SigmaX(tbx)*cond1.SigmaX(tbx) + cond2.SigmaX(tbx)*cond2.SigmaX(tbx) ) / dz;
330  wby = Sqrt( cond1.SigmaY(tby)*cond1.SigmaY(tby) + cond2.SigmaY(tby)*cond2.SigmaY(tby) ) / dz;
331  }
332  float w1x = 1./cond1.SigmaTX(s1.TX()); w1x*=w1x;
333  float w1y = 1./cond1.SigmaTY(s1.TY()); w1y*=w1y;
334  float w2x = 1./cond2.SigmaTX(s2.TX()); w2x*=w2x;
335  float w2y = 1./cond2.SigmaTY(s2.TY()); w2y*=w2y;
336 
337  float TX = (s1.TX()*w1x + s2.TX()*w2x + tbx*wbx)/(w1x+w2x+wbx);
338  float TY = (s1.TY()*w1y + s2.TY()*w2y + tby*wby)/(w1y+w2y+wby);
339 
340  // 2) calcualte the COG of the 2-seg group
341 
342  w1x = 1./cond1.SigmaX(TX); w1x *= w1x;
343  w1y = 1./cond1.SigmaY(TY); w1y *= w1y;
344  w2x = 1./cond2.SigmaX(TX); w2x *= w2x;
345  w2y = 1./cond2.SigmaY(TY); w2y *= w2y;
346  float Z = (s1.Z()*(w1x+w1y) + s2.Z()*(w2x+w2y))/(w1x+w1y+w2x+w2y);
347  float X = (s1.X()*(w1x+w1y) + s2.X()*(w2x+w2y))/(w1x+w1y+w2x+w2y);
348  float Y = (s1.Y()*(w1x+w1y) + s2.Y()*(w2x+w2y))/(w1x+w1y+w2x+w2y);
349  //printf("COG: x %f y %f z %f\n",X,Y,Z);
350 
351  s.SetX(X);
352  s.SetY(Y);
353  s.SetTX(TX);
354  s.SetTY(TY);
355  s.SetW(s1.W()+s2.W());
356  s.SetZ(Z);
357 
358  float PHI = ATan2(TY,TX); // angle of the 2-seg group plane
359  float T = Sqrt(TX*TX+TY*TY);
360 
361  EdbAffine2D aff;
362  aff.Rotate(PHI);
363  //aff.ShiftX(X);
364  //aff.ShiftY(Y);
365  aff.Invert();
366  s1.Transform(&aff);
367  s2.Transform(&aff);
368  s.Transform(&aff);
369 
370  float stx1 = cond1.SigmaTX(T), sty1 = cond1.SigmaTY(0);
371  float stx2 = cond2.SigmaTX(T), sty2 = cond2.SigmaTY(0);
372  w1x = 1./(stx1*stx1); w1y = 1./(sty1*sty1);
373  w2x = 1./(stx2*stx2); w2y = 1./(sty2*sty2);
374 
375  //printf("w1x %f w2x %f w1y %f w2y %f\n",w1x,w2x,w1y,w2y);
376  float chi2t = ( (s1.TX()-T)*(s1.TX()-T)*w1x +
377  s1.TY()*s1.TY() *w1y +
378  (s2.TX()-T)*(s2.TX()-T)*w2x +
379  s2.TY()*s2.TY() *w2y )/4.;
380  //printf("angular component of chi2 = %f\n",chi2t);
381 
382  float sx1 = cond1.SigmaX(T), sy1 = cond1.SigmaY(0);
383  float sx2 = cond2.SigmaX(T), sy2 = cond2.SigmaY(0);
384 
385  float dx1 = s1.X()-(s.X()+(s1.Z()-s.Z())*s.TX());
386  float dy1 = s1.Y()-(s.Y()+(s1.Z()-s.Z())*s.TY());
387  float dx2 = s2.X()-(s.X()+(s2.Z()-s.Z())*s.TX());
388  float dy2 = s2.Y()-(s.Y()+(s2.Z()-s.Z())*s.TY());
389 
390  float chi2pos = dx1*dx1/sx1/sx1+dy1*dy1/sy1/sy1+dx2*dx2/sx2/sx2+dy2*dy2/sy2/sy2/4.;
391  //printf("position component of chi2 = %f\n",chi2pos);
392  s.SetChi2( Sqrt(chi2t+chi2pos) );
393  aff.Invert();
394  s.Transform(&aff);
395  //s.Print();
396 
397  return s.Chi2();
398 }
Definition: EdbAffine.h:17
void Invert()
Definition: EdbAffine.cxx:103
void Rotate(float angle)
Definition: EdbAffine.cxx:383
void SetY(Float_t y)
Definition: EdbSegP.h:175
void SetTX(Float_t tx)
Definition: EdbSegP.h:176
void SetX(Float_t x)
Definition: EdbSegP.h:174
void SetTY(Float_t ty)
Definition: EdbSegP.h:177
void SetW(float w)
Definition: EdbSegP.h:129
virtual void Transform(const EdbAffine2D *a)
struct @8 Z
Double_t X
Definition: tlg2pattern.C:77
Double_t Y
Definition: tlg2pattern.C:77
Double_t TY
Definition: tlg2pattern.C:79
Double_t TX
Definition: tlg2pattern.C:79

◆ Chi2SegMCS()

float EdbTrackFitter::Chi2SegMCS ( const EdbSegP s1,
const EdbSegP s2 
)

Use hardcoded value because EdbSegP::DZem() contains sum of chi2 for microtracks.

292  {
293 
294  // double DZemul=s1.DZem()+s2.DZem();
296  double DZemul=88;
297 
298  double dzem=0.5*(s1.DZ()+s2.DZ())+DZemul;
299  double dz=TMath::Abs(s1.Z()-s2.Z());
300  double dzpb=dz-dzem;
301  if(dzpb<=0)return 0;
302  double dist=EdbSegP::Distance(s1,s2);
303  dist*=dzpb/dz;
304  double mom=s1.P();
305  if(mom<=0)mom=ePdef;
306  double theta0=EdbPhysics::ThetaMCS(mom,eM,dist,eX0);
307 
308  double theta=TMath::Sqrt2()*EdbSegP::Angle(s1,s2);
309  double chi=theta/theta0;
310  Log(5,"Chi2SegMCS",Form("dist=%6.4f (%6.4f), p=%6.2f, th=%4.3g(%4.3g) => chi2=%5.4g",dist,eX0,mom,theta,theta0,chi*chi));
311  return chi*chi;
312 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
static double ThetaMCS(float p, float mass, float dx, float x0)
Definition: EdbPhys.cxx:44
Float_t DZ() const
Definition: EdbSegP.h:151
Float_t P() const
Definition: EdbSegP.h:149
static Float_t Distance(const EdbSegP &s1, const EdbSegP &s2)
Definition: EdbSegP.cxx:463
static Float_t Angle(const EdbSegP &s1, const EdbSegP &s2)
Definition: EdbSegP.cxx:470
float eX0
Definition: EdbTrackFitter.h:22
float ePdef
Definition: EdbTrackFitter.h:24
float eM
Definition: EdbTrackFitter.h:23

◆ Fit3Pos()

int EdbTrackFitter::Fit3Pos ( EdbTrackP tr)
589 {
590  // fit track by straight line using coordinates only and update track parameters
591  int nseg=tr.N();
592  float x[100], y[100], z[100], w[100];
593  float x0,y0,z0,tx,ty,ex,ey;
594  for(int i=0; i<nseg; i++) {
595  EdbSegP *s = tr.GetSegment(i);
596  x[i]=s->X();
597  y[i]=s->Y();
598  z[i]=s->Z();
599  w[i]=s->W();
600  }
601  int rv=EdbMath::LFIT3(x,y,z,w,nseg,x0,y0,z0,tx,ty,ex,ey);
602  tr.SetX(x0);
603  tr.SetY(y0);
604  tr.SetZ(z0);
605  tr.SetTX(tx);
606  tr.SetTY(ty);
607 //TODO errors
608  return rv;
609 }
brick z0
Definition: RecDispMC.C:106
static int LFIT3(float *X, float *Y, float *Z, float *W, int L, float &X0, float &Y0, float &Z0, float &TX, float &TY, float &EX, float &EY)
Definition: EdbMath.cxx:313
Definition: EdbSegP.h:18
void w(int rid=2, int nviews=2)
Definition: test.C:27

◆ FitTrackLine() [1/2]

int EdbTrackFitter::FitTrackLine ( const EdbTrackP tr,
float &  x,
float &  y,
float &  z,
float &  tx,
float &  ty,
float &  w 
)
547 {
548  // track fit by averaging of segments parameters and return the mean values
549 
550  int nseg=tr.N();
551  x=0; y=0; z=0; tx=0; ty=0; w=0;
552  EdbSegP *seg=0;
553  for(int i=0; i<nseg; i++) {
554  seg = tr.GetSegment(i);
555  x += seg->X();
556  y += seg->Y();
557  z += seg->Z();
558  tx += seg->TX();
559  ty += seg->TY();
560  w += seg->W();
561  }
562  x /= nseg;
563  y /= nseg;
564  z /= nseg;
565  tx /= nseg;
566  ty /= nseg;
567  return nseg;
568 }

◆ FitTrackLine() [2/2]

int EdbTrackFitter::FitTrackLine ( EdbTrackP tr)
520 {
521  // track fit by averaging of segments parameters and put them as the track parameters
522  float x,y,z,tx,ty,w;
523  FitTrackLine(tr,x,y,z,tx,ty,w);
524  tr.Set(tr.ID(),x,y,tx,ty,w,tr.Flag());
525  tr.SetZ(z);
526 
527  tr.ClearF();
528  int nseg=tr.N();
529  for(int i=0; i<nseg; i++) {
530  EdbSegP *s = tr.GetSegment(i);
531  float dz = s->Z()-z;
532  EdbSegP *segf = new EdbSegP(*s);
533 
534  segf->Set( s->ID(), x + tx*dz, y+ty*dz, tx, ty, 1.,s->Flag());
535  segf->SetErrorP ( tr.SP() );
536  //segf.SetChi2(0.);
537  //segf.SetProb(1.);
538  segf->SetP( tr.P() );
539  tr.AddSegmentF(segf);
540  }
541 
542  return tr.N();
543 }
Int_t ID() const
Definition: EdbSegP.h:144
void SetP(float p)
Definition: EdbSegP.h:130
void SetErrorP(float sp2)
Definition: EdbSegP.h:93
Int_t Flag() const
Definition: EdbSegP.h:146
int FitTrackLine(EdbTrackP &tr)
Definition: EdbTrackFitter.cxx:519

◆ MaxChi2Seg()

float EdbTrackFitter::MaxChi2Seg ( EdbTrackP tr)
static
402 {
403  // return the maximal seg-to-seg chi2 along the track
404  float chimax=0,chi=0;
405  if(t.N()<2) return chimax;
406  for(int i=0; i<t.N()-1; i++) {
407  EdbSegP s(*t.GetSegment(i));
408  chi = Chi2Seg(&s,t.GetSegment(i+1));
409  chimax = chi > chimax ? chi : chimax;
410  }
411  return chimax;
412 }
TTree * t
Definition: check_shower.C:4
static float Chi2Seg(EdbSegP *s1, EdbSegP *s2)
Definition: EdbTrackFitter.cxx:62

◆ MaxKink()

float EdbTrackFitter::MaxKink ( EdbTrackP tr)
static
429 {
430  // return the maximal seg-to-seg kink theta angle
431  float kink=0,theta=0;
432  if(t.N()<2) return kink;
433  for(int i=0; i<t.N()-1; i++) {
434  theta = Theta(*t.GetSegment(i),*t.GetSegment(i+1));
435  kink = theta > kink ? theta : kink;
436  }
437  return kink;
438 }
static float Theta(EdbSegP &s, EdbSegP &s1)
Definition: EdbTrackFitter.cxx:451

◆ MeanChi2Seg()

float EdbTrackFitter::MeanChi2Seg ( EdbTrackP tr)
static
416 {
417  float meanchi=0;
418  if(t.N()<2) return meanchi;
419  for(int i=0; i<t.N()-1; i++) {
420  EdbSegP s(*t.GetSegment(i));
421  meanchi += Chi2Seg(&s,t.GetSegment(i+1));
422  }
423  return meanchi /= (t.N()-1);
424 }

◆ MeanKink()

float EdbTrackFitter::MeanKink ( EdbTrackP tr)
static
442 {
443  float meankink=0;
444  if(t.N()<2) return 0;
445  for(int i=0; i<t.N()-1; i++)
446  meankink += Theta(*t.GetSegment(i),*t.GetSegment(i+1));
447  return meankink /= (t.N()-1);
448 }

◆ PMS_KF()

float EdbTrackFitter::PMS_KF ( EdbTrackP t,
float  p0 = 10.,
float  probbest = 0.5 
)
497 {
498  // select track momentum in a way to have the given chi2-probablity calculated by KF
499 
500  if(t.N()<2) return 0;
501  float prob=0;
502  float pu=100., pl=0., p=p0;
503  int nstep = 0;
504  while( Abs(prob-probbest)>0.001 ) {
505  nstep++;
506  t.SetP(p);
507  t.FitTrackKFS(true);
508  prob = t.Prob();
509  if(prob<probbest) pu=p;
510  else pl=p;
511  if(nstep>30) break;
512  p = (pu+pl)/2.;
513  }
514  if(nstep>20) printf("Warning in EdbTrackFitter::PMS_KF: nstep=%d nseg=%d p=%f prob=%f\n",nstep,t.N(),p,prob);
515  return t.P();
516 }
p
Definition: testBGReduction_AllMethods.C:8

◆ Print()

void EdbTrackFitter::Print ( )
54 {
55  printf("EdbTrackFitter seetings:\n");
56  printf("eX0 = %f\n",eX0);
57  printf("eM = %f\n",eM);
58  printf("\n");
59 }

◆ ProbSegMCS()

double EdbTrackFitter::ProbSegMCS ( EdbSegP s1,
EdbSegP s2 
)
287  {
288  if(s1->P()<=0)s1->SetP(ePdef);
289  return EdbPVRec::ProbeSeg(s1,s2,eX0,eM);
290 }
static double ProbeSeg(const EdbTrackP *s1, EdbTrackP *s2, const float X0=5810.)
Definition: EdbPVRec.cxx:2654

◆ RMSprojXY()

int EdbTrackFitter::RMSprojXY ( EdbTrackP tr,
float &  ex,
float &  ey 
)
static
572 {
573  // fit track by straight line using coordinates only and return RMS's
574  int nseg=tr.N();
575  float x[100], y[100], z[100], w[100];
576  float x0,y0,z0,tx,ty;
577  for(int i=0; i<nseg; i++) {
578  EdbSegP *s = tr.GetSegment(i);
579  x[i]=s->X();
580  y[i]=s->Y();
581  z[i]=s->Z();
582  w[i]=s->W();
583  }
584  return EdbMath::LFIT3(x,y,z,w,nseg,x0,y0,z0,tx,ty,ex,ey);
585 }

◆ SetDefaultBrick()

void EdbTrackFitter::SetDefaultBrick ( )
44 {
46  eTPb = 1000./1300.;
47  ePcut = 0.050;
48  eM = 0.13957;
49  eDE_correction = false;
50 }
static float kX0_Pb()
Definition: EdbPhys.h:22
float eTPb
Definition: EdbTrackFitter.h:25
bool eDE_correction
Definition: EdbTrackFitter.h:27
float ePcut
Definition: EdbTrackFitter.h:26

◆ SetNsegMax()

void EdbTrackFitter::SetNsegMax ( int  nseg)
inline
33 {eNsegMax=nseg;}
int eNsegMax
Definition: EdbTrackFitter.h:19

◆ SplitTrack()

bool EdbTrackFitter::SplitTrack ( EdbTrackP t,
EdbTrackP t1,
int  isplit 
)
458 {
459  // split track t in 2 at the point isplit - will be the first segment of of t1
460  if(t.N()<isplit) return false;
461  for(int i=t.N()-1; i>=isplit; i--) {
462  t1.AddSegment( t.GetSegment(i) );
463  t.RemoveSegment( t.GetSegment(i) );
464  }
465  t.SetCounters();
466  //t1.FitTrackKFS(true, X0, 0);
467  t1.SetCounters();
468  t1.SetM(t.M());
469  t1.SetP(t.P());
470  //t1.FitTrackKFS(true, X0, 0);
471 
472  return true;
473 }
void AddSegment(EdbSegP *s)
Definition: EdbPattern.h:219
void SetCounters()
Definition: EdbPattern.h:164
void SetM(float m)
Definition: EdbPattern.h:159

◆ SplitTrackByKink()

int EdbTrackFitter::SplitTrackByKink ( EdbTrackP t,
TObjArray &  tracks,
float  maxkink 
)
477 {
478  // split track t in several tracks accourding to maxkink
479  // return total number of tracks after splitting;
480  // after splitting all new tracks added to the array "tracks"
481 
482  if(t->N()<1) return 0;
483  if(t->N()<2) return 1;
484  int nsplit=1;
485  for(int i=t->N()-1; i>0; i--)
486  if( Theta(*t->GetSegment(i),*t->GetSegment(i-1)) >= maxkink ) {
487  EdbTrackP *t1 = new EdbTrackP();
488  SplitTrack(*t,*t1, i);
489  tracks.Add(t1);
490  nsplit++;
491  }
492  return nsplit;
493 }
bool SplitTrack(EdbTrackP &t, EdbTrackP &t1, int isplit)
Definition: EdbTrackFitter.cxx:457
Definition: EdbPattern.h:118
TTree * tracks
Definition: check_tr.C:19

◆ Theta()

float EdbTrackFitter::Theta ( EdbSegP s,
EdbSegP s1 
)
static
452 {
453  return Sqrt( (s.TX()-s1.TX())*(s.TX()-s1.TX()) + (s.TY()-s1.TY())*(s.TY()-s1.TY()) );
454 }

Member Data Documentation

◆ eDE_correction

bool EdbTrackFitter::eDE_correction

◆ eM

float EdbTrackFitter::eM

◆ eNsegMax

int EdbTrackFitter::eNsegMax
private

◆ ePcut

float EdbTrackFitter::ePcut

◆ ePdef

float EdbTrackFitter::ePdef

◆ eTPb

float EdbTrackFitter::eTPb

◆ eX0

float EdbTrackFitter::eX0

The documentation for this class was generated from the following files: