//_____________________________________________________________________________
///
/// \class TrackEstimatorRange 
///
/// Set initial value of track momentum to Prange, values of u, v, du/dz, 
/// dv/dz from simple estimates.
///
/// \author Sergei avva@fnal.gov
///

#include "TVectorD.h"

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

#include "CandFitTrackSA/ConstFT.h"
#include "CandFitTrackSA/DataFT.h"
#include "CandFitTrackSA/FitContext.h"
#include "CandFitTrackSA/TracerSA.h"
#include "CandFitTrackSA/TrackEstimatorRange.h"
#include "CandFitTrackSA/TrackContext.h"

CVSID("$Id: TrackEstimatorRange.cxx,v 1.2 2006/02/07 23:04:44 rhatcher Exp $");

using namespace ConstFT;

///
/// ctor
///
TrackEstimatorRange::TrackEstimatorRange()
{
    TracerSA trace("TrackEstimatorRange::TrackEstimatorRange()");
}

///
/// dtor
///
TrackEstimatorRange::~TrackEstimatorRange()
{
    TracerSA trace("TrackEstimatorRange::~TrackEstimatorRange()");
}

///
/// set initial track parameters (changes its argument FitContext)
///
TVectorD TrackEstimatorRange::EstimateTrackParams(FitContext& fitContext) const
{
    TracerSA trace("TrackEstimatorRange::EstimateTrackParams"
                                                "(FitContext& fitContext)");
    
    TVectorD fitEstimate(NTrackParams);
    //const DataFT* data = fitContext.GetData();
    
    fitEstimate(kU) = fitContext.fData.GetUlin(0);
    fitEstimate(kdUdZ) = fitContext.fData.GetDudzlin(0);
    fitEstimate(kV) = fitContext.fData.GetVlin(0);
    fitEstimate(kdVdZ) = fitContext.fData.GetDvdzlin(0);
    // estimate 10% higher than Prange to make sure swimmer 
    // swims through the whole track
    fitEstimate(kQoverP) = -1./(fitContext.GetPrange()*1.1);
    
    return fitEstimate;
}        
        
///
/// read configuration parameters from AlgConfig
///
void TrackEstimatorRange::Config(const AlgConfig& /*ac*/)
{
    TracerSA trace("TrackEstimatorRange::Config(const AlgConfig&)");
}

