Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
main2.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file main2.cc
1 #include <ConstField.h>
2 #include <Exception.h>
3 #include <FieldManager.h>
4 #include <KalmanFitterRefTrack.h>
5 #include <StateOnPlane.h>
6 #include <Track.h>
7 #include <TrackPoint.h>
8 
9 #include <MaterialEffects.h>
10 #include <RKTrackRep.h>
11 #include <TGeoMaterialInterface.h>
12 
13 #include <EventDisplay.h>
14 
15 #include <PlanarMeasurement.h>
16 
17 #include <TEveManager.h>
18 #include <TGeoManager.h>
19 #include <TVector3.h>
20 #include <vector>
21 
22 #include "TDatabasePDG.h"
23 #include <TMath.h>
24 
25 
26 
27 
28 int main() {
29 
30  // init geometry and mag. field
31  new TGeoManager("Geometry", "Geane geometry");
32  TGeoManager::Import("genfitGeom.root");
34  genfit::FieldManager::getInstance()->init(new genfit::ConstField(0. ,10., 0.)); // 1 T
35 
36 
37  // init event display
39 
40 
41  // init fitter
43 
44 
45  // particle pdg code; pion hypothesis
46  const int pdg = 211;
47 
48  // start values for the fit, e.g. from pattern recognition
49  TVector3 pos(0, 0, 0);
50  TVector3 mom(0, 0, 3);
51 
52 
53  // trackrep
55 
56  // create track
57  genfit::Track fitTrack(rep, pos, mom);
58 
59 
60  const int detId(0); // detector ID
61  int planeId(0); // detector plane ID
62  int hitId(0); // hit ID
63 
64  double detectorResolution(0.001); // resolution of planar detectors
65  TMatrixDSym hitCov(2);
66  hitCov.UnitMatrix();
67  hitCov *= detectorResolution*detectorResolution;
68 
69 
70  // add some planar hits to track with coordinates I just made up
71  TVectorD hitCoords(2);
72  hitCoords[0] = 0;
73  hitCoords[1] = 0;
74  genfit::PlanarMeasurement* measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, detId, ++hitId, nullptr);
75  measurement->setPlane(genfit::SharedPlanePtr(new genfit::DetPlane(TVector3(0,0,0), TVector3(1,0,0), TVector3(0,1,0))), ++planeId);
76  fitTrack.insertPoint(new genfit::TrackPoint(measurement, &fitTrack));
77 
78  hitCoords[0] = -0.15;
79  hitCoords[1] = 0;
80  measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, detId, ++hitId, nullptr);
81  measurement->setPlane(genfit::SharedPlanePtr(new genfit::DetPlane(TVector3(0,0,10), TVector3(1,0,0), TVector3(0,1,0))), ++planeId);
82  fitTrack.insertPoint(new genfit::TrackPoint(measurement, &fitTrack));
83 
84  hitCoords[0] = -0.4;
85  hitCoords[1] = 0;
86  measurement = new genfit::PlanarMeasurement(hitCoords, hitCov, detId, ++hitId, nullptr);
87  measurement->setPlane(genfit::SharedPlanePtr(new genfit::DetPlane(TVector3(0,0,20), TVector3(1,0,0), TVector3(0,1,0))), ++planeId);
88  fitTrack.insertPoint(new genfit::TrackPoint(measurement, &fitTrack));
89 
90 
91 
92  //check
93  fitTrack.checkConsistency();
94 
95  // do the fit
96  fitter->processTrack(&fitTrack);
97 
98  // print fit result
99  fitTrack.getFittedState().Print();
100 
101  //check
102  fitTrack.checkConsistency();
103 
104 
105  display->addEvent(&fitTrack);
106 
107 
108  delete fitter;
109 
110  // open event display
111  display->open();
112 
113 }
114 
115