ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
minimumTestPHGenFit.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file minimumTestPHGenFit.cc
1 
7 //STL
8 #include <vector>
9 
10 //ROOT
11 #include <TVector3.h>
12 #include <TMatrixDSym.h>
13 
14 //GenFit
15 #include <GenFit/AbsTrackRep.h>
16 #include <GenFit/RKTrackRep.h>
17 #include <GenFit/StateOnPlane.h>
18 
19 //PHGenFit
20 #include <phgenfit/Fitter.h>
21 #include <phgenfit/Track.h>
22 #include <phgenfit/Measurement.h>
23 #include <phgenfit/PlanarMeasurement.h>
24 #include <phgenfit/SpacepointMeasurement.h>
25 
26 #include <phfield/PHFieldUtility.h>
27 
28 #define LogDEBUG std::cout<<"DEBUG: "<<__LINE__<<"\n"
29 
30 void get_seed(TVector3& seed_pos, TVector3& seed_mom, TMatrixDSym& seed_cov)
31 {
32  seed_pos.SetXYZ(0,0,0);
33  seed_mom.SetXYZ(10,-5,0);
34  seed_cov.ResizeTo(6,6);
35 }
36 
37 std::vector<TVector3> get_raw_measurements()
38 {
39  std::vector<TVector3> v_pos;
40  v_pos.push_back(TVector3(2.22459,-1.54767,-2.37792));
41  v_pos.push_back(TVector3(3.80050,-2.64444,-2.16561));
42  v_pos.push_back(TVector3(7.80344,-5.41815,-1.98928));
43  v_pos.push_back(TVector3(8.63214,-5.97797,-1.59626));
44  return v_pos;
45 }
46 
47 int main(int argc, char**argv) {
48 
50  PHGenFit::Fitter* fitter = new PHGenFit::Fitter("sPHENIX_Geo.root",
52  "KalmanFitter","RKTrackRep",false);
53 
55  int pid = -13; //mu+
56  genfit::AbsTrackRep* rep = new genfit::RKTrackRep(pid);
57 
59  TVector3 seed_pos;
60  TVector3 seed_mom;
61  TMatrixDSym seed_cov;
62  get_seed(seed_pos,seed_mom, seed_cov);
63  PHGenFit::Track* track = new PHGenFit::Track(rep, seed_pos,seed_mom, seed_cov);
64 
66  std::vector<TVector3> v_pos = get_raw_measurements();
67  double res_phi = 0.005; //cm
68  double res_z = 0.04; //cm
69  std::vector<PHGenFit::Measurement*> measurements;
70  for (unsigned int imeasurement = 0; imeasurement < v_pos.size(); imeasurement++) {
71  TVector3 pos = v_pos[imeasurement];
72  TVector3 n(pos.x(),pos.Y(),0);
73  PHGenFit::Measurement* meas = new PHGenFit::PlanarMeasurement(pos,n,res_phi, res_z);
74  //PHGenFit::Measurement* meas = new PHGenFit::SpacepointMeasurement(pos,res_phi);
75  meas->getMeasurement()->Print();
76  measurements.push_back(meas);
77  }
78 
80  track->addMeasurements(measurements);
81 
83  fitter->processTrack(track, false);
84 
86  //genfit::MeasuredStateOnPlane* state = track->extrapolateToLine(TVector3(0, 0, 0), TVector3(0, 0, 1));
87  //genfit::MeasuredStateOnPlane* state = track->extrapolateToPoint(TVector3(0, 0, 0));
88  genfit::MeasuredStateOnPlane* state = track->extrapolateToCylinder(1.,TVector3(0, 0, 0), TVector3(0, 0, 1));
89  state->Print();
90  delete state;
91 
93  //fitter->displayEvent();
94 
96 
97  delete track;
98 
99  delete fitter;
100 
101  return 0;
102 }