Belle II Software  release-08-01-10
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");
33  genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface());
34  genfit::FieldManager::getInstance()->init(new genfit::ConstField(0. ,10., 0.)); // 1 T
35 
36 
37  // init event display
38  genfit::EventDisplay* display = genfit::EventDisplay::getInstance();
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 
Abstract base class for Kalman fitter and derived fitting algorithms.
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
Constant Magnetic field.
Definition: ConstField.h:37
Detector plane.
Definition: DetPlane.h:59
Event display designed to run with Genfit.
Definition: EventDisplay.h:59
static FieldManager * getInstance()
Get singleton instance.
Definition: FieldManager.h:119
void init(AbsBField *b)
set the magnetic field here. Magnetic field classes must be derived from AbsBField.
Definition: FieldManager.h:78
Kalman filter implementation with linearization around a reference track.
void init(AbsMaterialInterface *matIfc)
set the material interface here. Material interface classes must be derived from AbsMaterialInterface...
Measurement class implementing a planar hit geometry (1 or 2D).
AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v)
Definition: RKTrackRep.h:72
AbsMaterialInterface implementation for use with ROOT's TGeoManager.
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:46
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91