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