CbmRoot
CbmL1TrackFitter.cxx
Go to the documentation of this file.
1 /*
2  *=====================================================
3  *
4  * CBM Level 1 Reconstruction
5  *
6  * Authors: I.Kisel, S.Gorbunov
7  *
8  * e-mail : ikisel@kip.uni-heidelberg.de
9  *
10  *=====================================================
11  *
12  * Fit reconstructed tracks and find primary vertex
13  *
14  */
15 
16 #include "CbmL1.h"
17 
18 #include "L1Algo/L1AddMaterial.h"
19 #include "L1Algo/L1Algo.h"
20 #include "L1Algo/L1Extrapolation.h"
21 #include "L1Algo/L1Filtration.h"
22 #include "L1Algo/L1StsHit.h"
23 #include "L1Algo/L1TrackPar.h"
24 
25 #include "CbmKF.h"
26 #include "CbmKFMath.h"
28 
29 #include "TStopwatch.h"
30 
31 void CbmL1::TrackFitter(vector<CbmL1Track>& Tracks, CbmL1Vtx* V) {
32  TStopwatch timer;
33  timer.Start();
34  /*
35  //int nt=0;
36  for( vector<CbmL1Track>::iterator i = Tracks.begin(); i!=Tracks.end(); ++i)
37  {
38  CbmL1Track &T = *i;
39 
40  int stmin = 1000, stmax = -1000;
41  for ( vector<L1StsHit*>::iterator j = T.StsHits.begin(); j != T.StsHits.end(); ++j)
42  {
43  if ((*j)->iStation < stmin ) stmin = (*j)->iStation;
44  if ((*j)->iStation > stmax ) stmax = (*j)->iStation;
45  }
46 
47  T.nStations = stmax - stmin + 1;
48  T.is_long = ( T.StsHits.size() >= 4 ) && ( T.nStations >=4 );
49 
50  //T.is_long = T.is_long &&( vMCPoints[T.MapsHits.back()->MC_Point].mother_ID==-1 );
51  //if ( !T.is_long ) continue;
52 
53  static L1FieldRegion fld[20];
54  {
55  vector<L1StsHit*>::iterator ih2 = T.StsHits.begin(), ih1, ih0;
56  ih1 = ih2;
57  ih1++;
58  ih0 = ih1;
59  ih0++;
60  int ist0 = (*ih0)->iStation;
61  int ist1 = (*ih1)->iStation;
62  int ist2 = (*ih2)->iStation;
63  L1Station *st0 = &(algo->vStations[ist0]);
64  L1Station *st1 = &(algo->vStations[ist1]);
65  L1Station *st2 = &(algo->vStations[ist2]);
66  L1FieldValue B0, B1, B2;
67  fvec Z0= st0->z, Z1= st1->z, Z2= st2->z ;
68  st0->fieldSlice.GetFieldValue( (*ih0)->x, (*ih0)->y, B0 );
69  st1->fieldSlice.GetFieldValue( (*ih1)->x, (*ih1)->y, B1 );
70  st2->fieldSlice.GetFieldValue( (*ih2)->x, (*ih2)->y, B2 );
71  fld[ist0].Set( B0, Z0, B1, Z1, B2, Z2 );
72  fld[ist1] = fld[ist0];
73  fld[ist2] = fld[ist0];
74  if( ih0!=T.StsHits.end() ){
75  while(1){
76  ih2 = ih1; B2 = B1; Z2 = Z1; st2 = st1;
77  ih1 = ih0; B1 = B0; Z1 = Z0; st1 = st0;
78  ih0++;
79  if( ih0==T.StsHits.end() ) break;
80  ist0 = (*ih0)->iStation;
81  st0 = &(algo->vStations[ist0]);
82  Z0 = st0->z;
83  st0->fieldSlice.GetFieldValue( (*ih0)->x, (*ih0)->y, B0 );
84  fld[ist0].Set( B0, Z0, B1, Z1, B2, Z2 );
85  }
86  }
87  }
88  fvec vINF = 100.;
89  L1TrackPar tp;
90  for( int i=0; i<5; i++ ) *((&tp.x)+i) = T.T[i];
91  {
92  fvec qp0 = tp.qp;
93  tp.NDF = 2;
94  tp.chi2 = 0;
95  vector<L1StsHit*>::iterator ih = T.StsHits.begin();
96  int ist = (*ih)->iStation;
97  L1Station *st = &(algo->vStations[ist]);
98  tp.x = (*ih)->x;
99  tp.y = (*ih)->y;
100  tp.z = st->z;
101  tp.C00 = st->XYInfo.C00;
102  tp.C10 = st->XYInfo.C10;
103  tp.C11 = st->XYInfo.C11;
104  for( int i=3; i<15; i++ ) *((&tp.C00)+i) = 0;
105  tp.C22 = tp.C33 = tp.C44 = vINF;
106  for( ; ih!= T.StsHits.end(); ih++ ){
107  ist = (*ih)->iStation;
108  st = &(algo->vStations[ist]);
109  L1Extrapolate( tp, st->z, qp0, fld[ist] );
110  fvec u_f = (*ih)->u_front, u_b = (*ih)->u_back;
111  L1Filter( tp, st->frontInfo, u_f );
112  L1Filter( tp, st->backInfo, u_b );
113  L1AddMaterial( tp, st->materialInfo, qp0 );
114  }
115  }
116  for( int i=0; i<6; i++ ) T.TLast[i] = (*((&tp.x)+i))[0] ;
117  for( int i=0; i<15; i++ ) T.CLast[i] = (*((&tp.C00)+i))[0];
118 
119  {
120  fvec qp0 = tp.qp;
121  tp.NDF = 2;
122  tp.chi2 = 0;
123  vector<L1StsHit*>::reverse_iterator ih = T.StsHits.rbegin();
124  int ist = (*ih)->iStation;
125  L1Station *st = &(algo->vStations[ist]);
126  tp.x = (*ih)->x;
127  tp.y = (*ih)->y;
128  tp.z = st->z;
129  tp.C00 = st->XYInfo.C00;
130  tp.C10 = st->XYInfo.C10;
131  tp.C11 = st->XYInfo.C11;
132  for( int i=3; i<15; i++ ) *((&tp.C00)+i) = 0;
133  tp.C22 = tp.C33 = tp.C44 = vINF;
134  for( ; ih!= T.StsHits.rend(); ih++ ){
135  ist = (*ih)->iStation;
136  st = &(algo->vStations[ist]);
137  L1Extrapolate( tp, st->z, qp0, fld[ist] );
138  fvec u_f = (*ih)->u_front, u_b = (*ih)->u_back;
139  L1Filter( tp, st->frontInfo, u_f );
140  L1Filter( tp, st->backInfo, u_b );
141  L1AddMaterial( tp, st->materialInfo, qp0 );
142  }
143  }
144  for( int i=0; i<6; i++ ) T.T[i] = (*((&tp.x)+i))[0] ;
145  for( int i=0; i<15; i++ ) T.C[i] = (*((&tp.C00)+i))[0];
146  T.chi2 = tp.chi2[0];
147  T.NDF = tp.NDF[0]-5;
148  }
149  timer.Stop();
150 
151  stat_vtx_ntracks = 0;
152 
153  if(V){ // primary vertex fit
154 
155  vector<CbmKFTrackInterface*> vTracks;
156 
157  { for( vector<CbmL1Track>::iterator i = Tracks.begin(); i!=Tracks.end(); ++i)
158  {
159  if( ( i->StsHits.size() < 5 ) || ( i->nStations <5 ) ) continue;
160  vTracks.push_back( &*i );
161  stat_vtx_ntracks ++;
162  }
163  }
164  cout<<"Fit vertex"<<endl;
165  if ( vTracks.size()>=3 )
166  {
167  CbmKFPrimaryVertexFinder PVFinder;
168  PVFinder.SetTracks( vTracks );
169  PVFinder.Fit(*V);
170  }
171  }// prim. vtx
172  */
173  //c_time.Stop();
174  //stat_fit_time += double(c_time.Time());
175  //timer.Stop();
176  stat_fit_time += timer.CpuTime();
177  stat_fit_time_ntracks += Tracks.size();
178 }
L1Algo.h
CbmKFPrimaryVertexFinder.h
CbmKF.h
CbmL1.h
CbmKFMath.h
L1TrackPar.h
L1Extrapolation.h
L1AddMaterial.h
L1StsHit.h
CbmL1Vtx
Definition: CbmL1Vtx.h:22
L1Filtration.h