Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:49

0001 /*!
0002  *  \file       Fitter.h
0003  *  \brief      Fitter class handles setups for the fitting.
0004  *  \details    Fitter class handles setups for the fitting like Geometry, Fields, fitter choice, etc.
0005  *  \author     Haiwang Yu <yuhw@nmsu.edu>
0006  */
0007 
0008 #ifndef PHGENFIT_FITTER_H
0009 #define PHGENFIT_FITTER_H
0010 
0011 // needed, it crashes on Ubuntu using singularity with local cvmfs install
0012 // shared pointer later on uses this, forward declaration does not cut it
0013 #include <phgenfit/Track.h>
0014 
0015 #include <GenFit/EventDisplay.h>
0016 #include "GenFit/Exception.h"
0017 
0018 #include <string>
0019 
0020 // BOOST
0021 //#include<boost/make_shared.hpp>
0022 //
0023 //#define SMART(expr) boost::shared_ptr<expr>
0024 //#define NEW(expr) boost::make_shared<expr>
0025 
0026 class TGeoManager;
0027 class PHField;
0028 
0029 namespace genfit
0030 {
0031   class AbsKalmanFitter;
0032   class AbsBField;
0033 }  // namespace genfit
0034 
0035 namespace PHGenFit
0036 {
0037 
0038   class Fitter
0039   {
0040    public:
0041     enum FitterType
0042     {
0043       KalmanFitter,
0044       KalmanFitterRefTrack,
0045       DafSimple,
0046       DafRef
0047     };
0048     enum TrackRepType
0049     {
0050       RKTrackRep
0051     };
0052 
0053     //! Default constructor
0054     Fitter(const std::string& tgeo_file_name,
0055            const PHField* field,
0056            const std::string& fitter_choice = "KalmanFitterRefTrack",
0057            const std::string& track_rep_choice = "RKTrackRep",
0058            const bool doEventDisplay = false);
0059 
0060     Fitter(TGeoManager* tgeo_manager,
0061            genfit::AbsBField* fieldMap,
0062            const std::string& fitter_choice = "KalmanFitterRefTrack",
0063            const std::string& track_rep_choice = "RKTrackRep",
0064            const bool doEventDisplay = false);
0065 
0066     Fitter(TGeoManager* tgeo_manager,
0067            genfit::AbsBField* fieldMap,
0068            const PHGenFit::Fitter::FitterType& fitter_choice = PHGenFit::Fitter::KalmanFitter,
0069            const PHGenFit::Fitter::TrackRepType& track_rep_choice = PHGenFit::Fitter::RKTrackRep,
0070            const bool doEventDisplay = false);
0071 
0072     //! Default destructor
0073     ~Fitter();
0074     explicit Fitter(const Fitter&) = delete;
0075     Fitter& operator=(const Fitter&) = delete;
0076 
0077     static Fitter* getInstance(const std::string& tgeo_file_name,
0078                                const PHField* field,
0079                                const std::string& fitter_choice = "KalmanFitterRefTrack",
0080                                const std::string& track_rep_choice = "RKTrackRep",
0081                                const bool doEventDisplay = false);
0082 
0083     static Fitter* getInstance(TGeoManager* tgeo_manager,
0084                                const PHField* field,
0085                                const std::string& fitter_choice = "KalmanFitterRefTrack",
0086                                const std::string& track_rep_choice = "RKTrackRep",
0087                                const bool doEventDisplay = false);
0088 
0089     static Fitter* getInstance(TGeoManager* tgeo_manager,
0090                                const PHField* field,
0091                                const PHGenFit::Fitter::FitterType& fitter_choice = PHGenFit::Fitter::KalmanFitter,
0092                                const PHGenFit::Fitter::TrackRepType& track_rep_choice = PHGenFit::Fitter::RKTrackRep,
0093                                const bool doEventDisplay = false);
0094 
0095     int processTrack(PHGenFit::Track* track, const bool save_to_evt_disp = false);
0096 
0097     int displayEvent();
0098 
0099     bool is_do_Event_Display() const
0100     {
0101       return _doEventDisplay;
0102     }
0103 
0104     void set_do_Event_Display(bool doEventDisplay)
0105     {
0106       _doEventDisplay = doEventDisplay;
0107       if (!_display && _doEventDisplay)
0108         _display = genfit::EventDisplay::getInstance();
0109     }
0110 
0111     genfit::EventDisplay* getEventDisplay()
0112     {
0113       return _display;
0114     }
0115 
0116     int get_verbosity() const
0117     {
0118       return verbosity;
0119     }
0120 
0121     void set_verbosity(int v)
0122     {
0123       this->verbosity = v;
0124       if (verbosity >= 1)
0125         genfit::Exception::quiet(false);
0126       else
0127         genfit::Exception::quiet(true);
0128     }
0129 
0130    private:
0131     /*!
0132      * Verbose control:
0133      * -1: Silient
0134      * 0: Minimum
0135      * 1: Errors only
0136      * 2: Errors and Warnings
0137      * 3: Verbose mode, long term debugging
0138      */
0139     int verbosity;
0140 
0141     TGeoManager* _tgeo_manager;
0142 
0143     bool _doEventDisplay;
0144 
0145     genfit::EventDisplay* _display;
0146     genfit::AbsKalmanFitter* _fitter;
0147 
0148   };  // class Fitter
0149 
0150 }  // namespace PHGenFit
0151 
0152 #endif