1 #include <ConstField.h>
3 #include <FieldManager.h>
4 #include <KalmanFitterRefTrack.h>
5 #include <StateOnPlane.h>
7 #include <TrackPoint.h>
9 #include <MaterialEffects.h>
10 #include <RKTrackRep.h>
11 #include <TGeoMaterialInterface.h>
13 #include <EventDisplay.h>
15 #include <HelixTrackModel.h>
16 #include <MeasurementCreator.h>
18 #include <GFRaveVertexFactory.h>
20 #include <TDatabasePDG.h>
21 #include <TEveManager.h>
22 #include <TGeoManager.h>
28 #include <TClonesArray.h>
31 #include <TDatabasePDG.h>
46 new TGeoManager(
"Geometry",
"Geane geometry");
47 TGeoManager::Import(
"genfitGeom.root");
61 vertexFactory.setMethod(
"kalman-smoothing:1");
66 TFile* trackFile =
new TFile(
"tracks.root",
"RECREATE");
68 TTree* tree =
new TTree(
"tree",
"fitted tracks");
69 TClonesArray trackArray(
"genfit::Track");
70 tree->Branch(
"trackBranch", &trackArray, 32000, -1);
72 TClonesArray vertexArray(
"genfit::GFRaveVertex");
73 tree->Branch(
"vertexBranch", &vertexArray, 32000, -1);
75 std::vector<genfit::Track*> tracks;
76 std::vector<genfit::GFRaveVertex*> vertices;
79 for (
unsigned int iEvent=0; iEvent<10; ++iEvent){
88 unsigned int nTracks = gRandom->Uniform(2, 10);
90 for (
unsigned int iTrack=0; iTrack<nTracks; ++iTrack){
93 TVector3 pos(0, 0, 0);
95 mom.SetPhi(gRandom->Uniform(0.,2*TMath::Pi()));
96 mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi()));
97 mom.SetMag(gRandom->Uniform(0.2, 1.));
102 const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.);
107 unsigned int nMeasurements = gRandom->Uniform(5, 15);
111 const bool smearPosMom =
true;
112 const double posSmear = 0.1;
113 const double momSmear = 3. /180.*TMath::Pi();
114 const double momMagSmear = 0.1;
119 posM.SetX(gRandom->Gaus(posM.X(),posSmear));
120 posM.SetY(gRandom->Gaus(posM.Y(),posSmear));
121 posM.SetZ(gRandom->Gaus(posM.Z(),posSmear));
123 momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear));
124 momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear));
125 momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag()));
129 double resolution = 0.01;
130 for (
int i = 0; i < 3; ++i)
131 covM(i,i) = resolution*resolution;
132 for (
int i = 3; i < 6; ++i)
133 covM(i,i) = pow(resolution / nMeasurements /
sqrt(3), 2);
145 TVectorD seedState(6);
146 TMatrixDSym seedCov(6);
149 new(trackArray[iTrack])
genfit::Track(rep, seedState, seedCov);
151 tracks.push_back(trackPtr);
154 std::vector<genfit::eMeasurementType> measurementTypes;
155 for (
unsigned int i = 0; i < nMeasurements; ++i)
156 measurementTypes.push_back(genfit::eMeasurementType(gRandom->Uniform(8)));
161 for (
unsigned int i=1; i<measurementTypes.size(); ++i){
162 std::vector<genfit::AbsMeasurement*> measurements = measurementCreator.create(measurementTypes[i], i*5.);
167 std::cerr<<
"Exception, next track"<<std::endl;
168 std::cerr << e.what();
173 assert(trackPtr->checkConsistency());
177 fitter->processTrack(trackPtr);
180 std::cerr << e.what();
181 std::cerr <<
"Exception, next track" << std::endl;
186 assert(trackPtr->checkConsistency());
193 vertexFactory.findVertices(&vertices, tracks);
195 for (
unsigned int i=0; i<vertices.size(); ++i) {
199 for (
unsigned int j=0; j<vtx->
getNTracks(); ++j) {
200 std::cout <<
"track parameters uniqueID: " << vtx->getParameters(j)->GetUniqueID() <<
"\n";
205 for (
unsigned int i=0; i<tracks.size(); ++i) {
207 std::cout <<
"track uniqueID: " << trk->GetUniqueID() <<
"\n";
212 std::cout <<
"trackArray nr of entries: " << trackArray.GetEntries() <<
"\n";
218 display->addEvent(tracks);
Abstract base class for Kalman fitter and derived fitting algorithms.
Abstract base class for a track representation.
virtual void setPosMomCov(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) const =0
Set position, momentum and covariance of state.
virtual void get6DStateCov(const MeasuredStateOnPlane &state, TVectorD &stateVec, TMatrixDSym &cov) const
Translates MeasuredStateOnPlane into 6D state vector (x, y, z, p_x, p_y, p_z) and 6x6 covariance.
Event display designed to run with Genfit.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
static FieldManager * getInstance()
Get singleton instance.
void init(AbsBField *b)
set the magnetic field here. Magnetic field classes must be derived from AbsBField.
Vertex factory for producing GFRaveVertex objects from Track objects.
unsigned int getNTracks() const
Number of tracks the vertex is made of.
Helix track model for testing purposes.
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...
#StateOnPlane with additional covariance matrix.
Create different measurement types along a HelixTrackModel for testing purposes.
void setTrackModel(const HelixTrackModel *model)
Takes ownership!
AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v)
AbsMaterialInterface implementation for use with ROOT's TGeoManager.
Object containing AbsMeasurement and AbsFitterInfo objects.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
double sqrt(double a)
sqrt for double
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
int main(int argc, char **argv)
Run all tests.