14 #include <RKTrackRep.h>
22 #include <TDatabasePDG.h>
23 #include <TEveManager.h>
24 #include <TGeoManager.h>
29 #include "TDatabasePDG.h"
35 #define FILENAME "/tmp/streamerTest.root"
41 TFile *f = TFile::Open(
FILENAME,
"RECREATE");
73 std::cout <<
"emptyTrackTest failed." << std::endl;
85 TFile* fOut =
new TFile(
FILENAME,
"RECREATE");
87 TTree* tResults =
new TTree(
"tResults",
"results from track fit");
89 tResults->Branch(
"gfTrack",
"genfit::Track", &fitTrack, 32000, -1);
90 tResults->Branch(
"stateFinal", &stateFinal);
91 tResults->Branch(
"covFinal", &covFinal, 32000, -1);
92 tResults->Branch(
"planeFinal", &planeFinal, 32000, -1);
105 new TGeoManager(
"Geometry",
"Geane geometry");
106 TGeoManager::Import(
"genfitGeom.root");
117 for (
unsigned int iEvent=0; iEvent<
nEvents; ++iEvent){
120 TVector3
pos(0, 0, 0);
121 TVector3
mom(1.,0,0);
122 mom.SetPhi(gRandom->Uniform(0.,2*TMath::Pi()));
123 mom.SetTheta(gRandom->Uniform(0.4*TMath::Pi(),0.6*TMath::Pi()));
124 mom.SetMag(gRandom->Uniform(0.2, 1.));
129 const double charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge()/(3.);
134 unsigned int nMeasurements = gRandom->Uniform(5, 15);
138 const bool smearPosMom =
true;
139 const double posSmear = 0.1;
140 const double momSmear = 3. /180.*TMath::Pi();
141 const double momMagSmear = 0.1;
146 posM.SetX(gRandom->Gaus(posM.X(),posSmear));
147 posM.SetY(gRandom->Gaus(posM.Y(),posSmear));
148 posM.SetZ(gRandom->Gaus(posM.Z(),posSmear));
150 momM.SetPhi(gRandom->Gaus(mom.Phi(),momSmear));
151 momM.SetTheta(gRandom->Gaus(mom.Theta(),momSmear));
152 momM.SetMag(gRandom->Gaus(mom.Mag(), momMagSmear*mom.Mag()));
156 double resolution = 0.01;
157 for (
int i = 0; i < 3; ++i)
158 covM(i,i) = resolution*resolution;
159 for (
int i = 3; i < 6; ++i)
160 covM(i,i) = pow(resolution / nMeasurements / sqrt(3), 2);
172 TVectorD seedState(6);
173 TMatrixDSym seedCov(6);
179 std::vector<genfit::eMeasurementType> measurementTypes;
180 for (
unsigned int i = 0; i < nMeasurements; ++i)
186 for (
unsigned int i=0; i<measurementTypes.size(); ++i){
187 std::vector<genfit::AbsMeasurement*> measurements = measurementCreator.
create(measurementTypes[i], i*5.);
198 std::cerr<<
"Exception, next track"<<std::endl;
199 std::cerr << e.
what();
219 switch (iEvent % 5) {
223 fitTrack->
prune(
"FL");
226 fitTrack->
prune(
"W");
229 fitTrack->
prune(
"RC");
232 fitTrack->
prune(
"U");
253 fOut = TFile::Open(
FILENAME,
"READ");
254 fOut->GetObject(
"tResults", tResults);
255 TVectorD* pState = 0;
256 tResults->SetBranchAddress(
"stateFinal", &pState);
257 TMatrixDSym* pMatrix = 0;
258 tResults->SetBranchAddress(
"covFinal", &pMatrix);
260 tResults->SetBranchAddress(
"planeFinal", &plane);
261 tResults->SetBranchAddress(
"gfTrack", &fitTrack);
265 for (Long_t nEntry = 0; nEntry < tResults->GetEntries(); ++nEntry) {
266 tResults->GetEntry(nEntry);
283 std::cout <<
"stored track not equal, small differences can occur if some info has been pruned." << std::endl;
297 std::cerr << e.
what();
302 std::cout << nEvents - fail <<
" stored tracks are identical to fitted tracks, as far as tested." << std::endl;
303 std::cout << fail <<
" tracks were not identical to fitted tracks, as far as tested." << std::endl;
305 std::cout <<
"deleteing didn't segfault" << std::endl;