#ifndef ALGFITTRACKSA_H
#define ALGFITTRACKSA_H
//_____________________________________________________________________________
///
/// \class AlgFitTrackSA 
///
/// AlgFitTrackSA - iterative least squares track fitter.
/// This package provides an iterative least squares track fitter (as
/// described in NuMI-301 note). It works on candidate tracks produced
/// by a track finding (or track fitting) package.  
/// 
/// This fitter can be added to the job path by inserting 
/// "FitTrackSAListModule::Reco" job module.
/// 
/// Fit results are not saved in the standard ntuple, but can be 
/// saved in a NtpFitSA by adding the following job path (or adding 
/// to an existing path):
/// 
///   //Ntuple record has its own output file so needs its own output module
///   j.Path.Create("Ntp",
///                         "NtpFitSAModule::Reco " // create NtpStRecord
///                         "Output::Put ");
/// 
///   j.Path("Ntp").Mod("Output").Cmd("DefineStream NtpFitSA NtpFitSARecord");
///   j.Path("Ntp").Mod("Output").Set("Streams=NtpFitSA");
///   j.Path("Ntp").Mod("Output").Set("FileName=ntpSA.root");
///
/// \author Sergei avva@fnal.gov
///

#include "Algorithm/AlgBase.h"

class GeometryHelper;
class NtpFitSA;
class SwimSwimmer;
class TrackFilter;
class TrackSegmentMaker;
class TrackEstimator;
class TrackContext;

class AlgFitTrackSA : public AlgBase {

public:
    AlgFitTrackSA();

    ~AlgFitTrackSA();

    virtual void RunAlg(AlgConfig &ac, CandHandle &ch, CandContext &cx);

private:

    ///
    /// main fitting method
    ///
    NtpFitSA DoFit(const AlgConfig &ac, const TrackContext& trackContext);
    
    ///
    /// Determine if want to use this track for fitting 
    ///
    TrackFilter*    fFilter;
    
    ///
    /// (Optionally) split track into segments 
    ///
    TrackSegmentMaker*  fSegmentMaker;
    
    ///
    /// Initial estimation of the track parameters 
    ///
    TrackEstimator*       fEstimator;
    
    ///
    /// Particle swimmer  
    ///
    SwimSwimmer*    fSwimmer;    
    
    
    ClassDef(AlgFitTrackSA,0)    
}; // class AlgFitTrackSA

#endif // ALGFITTRACKSA_H
