14 #include <TGeoManager.h>
18 #include <GenFit/AbsKalmanFitter.h>
19 #include <GenFit/DAF.h>
20 #include <GenFit/EventDisplay.h>
21 #include <GenFit/FieldManager.h>
22 #include <GenFit/FitStatus.h>
23 #include <GenFit/KalmanFitter.h>
24 #include <GenFit/KalmanFitterRefTrack.h>
25 #include <GenFit/MaterialEffects.h>
26 #include <GenFit/TGeoMaterialInterface.h>
30 #include <genfitexp/Field.h>
36 namespace genfit {
class AbsTrackRep; }
38 #define LogDEBUG(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
39 #define LogERROR(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
40 #define LogWARNING(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
45 const std::string& tgeo_file_name,
47 const std::string& fitter_choice,
49 const bool doEventDisplay)
51 , _doEventDisplay(doEventDisplay)
54 TGeoManager::Import(tgeo_file_name.data());
59 genfit::FieldManager::getInstance()->init(
61 genfit::MaterialEffects::getInstance()->init(
62 new genfit::TGeoMaterialInterface());
66 _display = genfit::EventDisplay::getInstance();
71 if (fitter_choice.compare(
"KalmanFitterRefTrack") == 0)
72 _fitter =
new genfit::KalmanFitterRefTrack();
73 else if (fitter_choice.compare(
"KalmanFitter") == 0)
74 _fitter =
new genfit::KalmanFitter();
75 else if (fitter_choice.compare(
"DafSimple") == 0)
76 _fitter =
new genfit::DAF(
false);
77 else if (fitter_choice.compare(
"DafRef") == 0)
78 _fitter =
new genfit::DAF(
true);
80 _fitter =
new genfit::KalmanFitter();
82 genfit::Exception::quiet(
true);
97 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 00, 0)
100 fitTrack->checkConsistency();
102 catch (genfit::Exception&
e)
106 std::cerr <<
"genfit::Track::checkConsistency() failed!" << std::endl;
107 std::cerr << e.what();
112 if (!fitTrack->checkConsistency())
120 _fitter->processTrack(fitTrack);
122 catch (genfit::Exception& e)
126 std::cerr <<
"PHGenFit::Fitter::processTrack::Exception: \n";
127 std::cerr << e.what();
128 std::cerr <<
"Exception, next track" << std::endl;
132 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 00, 0)
135 fitTrack->checkConsistency();
137 catch (genfit::Exception& e)
141 std::cerr <<
"genfit::Track::checkConsistency() failed!" << std::endl;
142 std::cerr << e.what();
148 if (!fitTrack->checkConsistency())
154 genfit::AbsTrackRep* rep = fitTrack->getCardinalRep();
155 if (!fitTrack->getFitStatus(rep)->isFitConverged())
157 if (
verbosity >= 2)
LogWARNING(
"Track could not be fitted successfully! Fit is not converged!");
169 const std::string& fitter_choice,
const std::string& track_rep_choice,
170 const bool doEventDisplay)
172 TGeoManager* tgeo_manager = TGeoManager::Import(tgeo_file_name.data(),
"Default");
181 return new Fitter(tgeo_manager, fieldMap, fitter_choice, track_rep_choice, doEventDisplay);
187 const bool doEventDisplay)
189 , _tgeo_manager(tgeo_manager)
190 , _doEventDisplay(doEventDisplay)
192 genfit::FieldManager::getInstance()->init(
194 genfit::MaterialEffects::getInstance()->init(
195 new genfit::TGeoMaterialInterface());
199 _display = genfit::EventDisplay::getInstance();
205 _fitter =
new genfit::KalmanFitter();
207 _fitter =
new genfit::KalmanFitterRefTrack();
209 _fitter =
new genfit::DAF(
false);
211 _fitter =
new genfit::DAF(
true);
215 LogERROR(
"This fitter not implemented!");
221 const std::string& fitter_choice,
const std::string& track_rep_choice,
222 const bool doEventDisplay)
232 return new Fitter(tgeo_manager, fieldMap, fitter_choice, track_rep_choice, doEventDisplay);
236 const std::string& fitter_choice,
const std::string& ,
237 const bool doEventDisplay)
239 , _tgeo_manager(tgeo_manager)
240 , _doEventDisplay(doEventDisplay)
242 genfit::FieldManager::getInstance()->init(
244 genfit::MaterialEffects::getInstance()->init(
245 new genfit::TGeoMaterialInterface());
249 _display = genfit::EventDisplay::getInstance();
254 if (fitter_choice.compare(
"KalmanFitterRefTrack") == 0)
255 _fitter =
new genfit::KalmanFitterRefTrack();
256 else if (fitter_choice.compare(
"KalmanFitter") == 0)
257 _fitter =
new genfit::KalmanFitter();
258 else if (fitter_choice.compare(
"DafSimple") == 0)
259 _fitter =
new genfit::DAF(
false);
260 else if (fitter_choice.compare(
"DafRef") == 0)
261 _fitter =
new genfit::DAF(
true);
265 LogERROR(
"This fitter not implemented!");
274 LogERROR(
"No genfit::EventDisplay found!");
283 const bool doEventDisplay)
294 return new Fitter(tgeo_manager, fieldMap, fitter_choice, track_rep_choice, doEventDisplay);