11 #include <GenFit/RKTrackRep.h>
19 #include <GenFit/StateOnPlane.h>
25 #include <g4hough/SvtxTrackMap.h>
26 #include <g4hough/SvtxTrackMap_v1.h>
27 #include <g4hough/SvtxTrack_v1.h>
31 #include <phgenfit/Fitter.h>
32 #include <phgenfit/PlanarMeasurement.h>
33 #include <phgenfit/Track.h>
35 #include <phfield/PHFieldUtility.h>
36 #include <phgeom/PHGeomUtility.h>
40 #define LogDebug(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
41 #define LogError(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
42 #define LogWarning(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
44 #define _N_DETECTOR_LAYER 5
50 , _truth_container(NULL)
53 , _fit_alg_name(
"KalmanFitterRefTrack")
54 , _do_evt_display(
false)
55 , _phi_resolution(50
E-4)
58 , _pat_rec_hit_finding_eff(1.)
59 , _pat_rec_nosise_prob(0.)
91 field,
"KalmanFitterRefTrack",
"RKTrackRep",
116 LogError(
"_trackmap_out not found!");
126 TVector3 seed_pos(0, 0, 0);
127 TVector3 seed_mom(0, 0, 0);
128 TMatrixDSym seed_cov(6);
131 std::vector<PHGenFit::Measurement*> measurements;
133 const bool _use_vertex_in_fitting =
true;
137 if (_use_vertex_in_fitting)
140 TVector3(0, 0, 0), 0.0050, 0.0050);
141 measurements.push_back(vtx_meas);
146 if (measurements.size() < 3)
178 if (fitting_err != 0)
199 "PHCompositeNode",
"DST"));
202 cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << endl;
209 "PHCompositeNode",
"FGEM"));
215 cout <<
"FGEM node added" << endl;
224 cout <<
"FGEM/ForwardTrackMap node added" << endl;
237 cout <<
PHWHERE <<
" PHG4TruthInfoContainer node not found on node tree"
246 if (!phg4hit &&
_event < 2)
260 cout <<
PHWHERE <<
" ForwardTrackMap node not found on node tree"
270 std::vector<PHGenFit::Measurement*>& meas_out, TVector3& seed_pos,
271 TVector3& seed_mom, TMatrixDSym& seed_cov,
const bool do_smearing)
273 seed_pos.SetXYZ(0, 0, 0);
274 seed_mom.SetXYZ(0, 0, 10);
275 seed_cov.ResizeTo(6, 6);
277 for (
int i = 0;
i < 3;
i++)
282 for (
int i = 3;
i < 6;
i++)
289 TVector3 True_mom(particle->
get_px(), particle->
get_py(),
296 const double momSmear = 3. / 180. * TMath::Pi();
297 const double momMagSmear = 0.1;
299 seed_mom.SetPhi(gRandom->Gaus(True_mom.Phi(), momSmear));
300 seed_mom.SetTheta(gRandom->Gaus(True_mom.Theta(), momSmear));
302 gRandom->Gaus(True_mom.Mag(),
303 momMagSmear * True_mom.Mag()));
319 itr !=
_phg4hits[ilayer]->getHits().second; ++itr)
331 meas_out.push_back(meas);
343 double chi2 = phgf_track->
get_chi2();
344 double ndf = phgf_track->
get_ndf();
347 TVector3 mom = gf_state->
getMom();
360 double dca2d = gf_state->
getState()[3];
372 out_track->
set_px(mom.Px());
373 out_track->
set_py(mom.Py());
374 out_track->
set_pz(mom.Pz());
376 out_track->
set_x(pos.X());
377 out_track->
set_y(pos.Y());
378 out_track->
set_z(pos.Z());
380 for (
int i = 0;
i < 6;
i++)
382 for (
int j =
i;
j < 6;
j++)
400 TVector3
v(
pos.X(),
pos.Y(), 0);
403 TVector3
u = v.Cross(TVector3(0, 0, 1));
408 pos.SetX(g4hit->
get_avg_x() + u_smear * u.X() + v_smear * v.X());
409 pos.SetY(g4hit->
get_avg_y() + u_smear * u.Y() + v_smear * v.Y());
434 double u_smear = gRandom->Gaus(0, dphi);
435 double v_smear = gRandom->Gaus(0, dr);
436 pos.SetX(vtx.X() + u_smear * u.X() + v_smear * v.X());
437 pos.SetY(vtx.Y() + u_smear * u.Y() + v_smear * v.Y());