//_____________________________________________________________________________
///
/// \class FitStateFinal
///
/// FitStateFinal is the end of iterations - fitter stop when this state is
/// reached.
/// 
/// \author Sergei avva@fnal.gov
///

#include <string>

#include "Algorithm/AlgConfig.h"
#include "MessageService/MsgService.h"

#include "CandFitTrackSA/DataFT.h"
#include "CandFitTrackSA/MatrixCalculator.h"

#include "CandFitTrackSA/FitStateFactory.h"
#include "CandFitTrackSA/FitStateFinal.h"
#include "CandFitTrackSA/FitContext.h"

CVSID("$Id: FitStateFinal.cxx,v 1.2 2006/02/04 21:47:35 avva Exp $");

// The ID of class Line
static const std::string FINAL_FIT_STATE = "Final";

// Create an anonymous namespace
// to make the function invisible from other modules
namespace {

FitState* CreateFinalFS() { return new FitStateFinal; }

// register block
bool registered = FitStateFactory::Instance().RegisterFitState(
                                                    FINAL_FIT_STATE,
                                                            CreateFinalFS);
}  // namespace


///
/// Iterate method
///
void FitStateFinal::Iterate(FitContext& context) const
{
    if ( context.fTimesConverged != 0 ) {
        MSG("FitTrackSA",Msg::kInfo) << "Fit Successful!\n";
    } else {
        MSG("FitTrackSA",Msg::kInfo) << "Fit Failed!\n";        
    }
}

    
///
/// Name() - return name of the state 
///
const std::string& FitStateFinal::Name() const
{
    return FINAL_FIT_STATE;
}    
