CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

GsfTrajectoryFitter Class Reference

#include <GsfTrajectoryFitter.h>

Inheritance diagram for GsfTrajectoryFitter:
TrajectoryFitter

List of all members.

Public Member Functions

virtual GsfTrajectoryFitterclone () const
const MeasurementEstimatorestimator () const
virtual std::vector< Trajectoryfit (const TrajectorySeed &aSeed, const RecHitContainer &hits, const TSOS &firstPredTsos) const
virtual std::vector< Trajectoryfit (const TrajectorySeed &aSeed, const RecHitContainer &hits) const
virtual std::vector< Trajectoryfit (const Trajectory &aTraj) const
 GsfTrajectoryFitter (const Propagator &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &aMerger, const DetLayerGeometry *detLayerGeometry=0)
const MultiTrajectoryStateMergermerger () const
const Propagatorpropagator () const
const TrajectoryStateUpdatorupdator () const
virtual ~GsfTrajectoryFitter ()

Private Types

typedef TrajectoryMeasurement TM
typedef TrajectoryStateOnSurface TSOS

Private Attributes

const DetLayerGeometry dummyGeometry
const MeasurementEstimatortheEstimator
const DetLayerGeometrytheGeometry
const MultiTrajectoryStateMergertheMerger
const PropagatorthePropagator
bool theTiming
const TrajectoryStateUpdatortheUpdator

Detailed Description

A GSF fitter, similar to KFTrajectoryFitter.

Definition at line 20 of file GsfTrajectoryFitter.h.


Member Typedef Documentation

Definition at line 24 of file GsfTrajectoryFitter.h.

Definition at line 23 of file GsfTrajectoryFitter.h.


Constructor & Destructor Documentation

GsfTrajectoryFitter::GsfTrajectoryFitter ( const Propagator aPropagator,
const TrajectoryStateUpdator aUpdator,
const MeasurementEstimator aEstimator,
const MultiTrajectoryStateMerger aMerger,
const DetLayerGeometry detLayerGeometry = 0 
)

Constructor with explicit components for propagation, update, chi2 calculation, merging and flag for merging before / after the update (i.e. fully configured)

Definition at line 12 of file GsfTrajectoryFitter.cc.

References dummyGeometry, and theGeometry.

Referenced by clone().

                                                                                   :
  thePropagator(aPropagator.clone()),
  theUpdator(aUpdator.clone()),
  theEstimator(aEstimator.clone()),
  theMerger(aMerger.clone()),
  theGeometry(detLayerGeometry)
{
  if(!theGeometry) theGeometry = &dummyGeometry;
  //   static SimpleConfigurable<bool> timeConf(false,"GsfTrajectoryFitter:activateTiming");
  //   theTiming = timeConf.value();
}
GsfTrajectoryFitter::~GsfTrajectoryFitter ( ) [virtual]

Definition at line 28 of file GsfTrajectoryFitter.cc.

References theEstimator, theMerger, thePropagator, and theUpdator.

                                          {
  delete thePropagator;
  delete theUpdator;
  delete theEstimator;
  delete theMerger;
}

Member Function Documentation

virtual GsfTrajectoryFitter* GsfTrajectoryFitter::clone ( void  ) const [inline, virtual]
const MeasurementEstimator* GsfTrajectoryFitter::estimator ( void  ) const [inline]

Definition at line 48 of file GsfTrajectoryFitter.h.

References theEstimator.

Referenced by fit().

{return theEstimator;}
std::vector< Trajectory > GsfTrajectoryFitter::fit ( const TrajectorySeed aSeed,
const RecHitContainer hits 
) const [virtual]

Implements TrajectoryFitter.

Definition at line 45 of file GsfTrajectoryFitter.cc.

                                                                                    {

  edm::LogError("GsfTrajectoryFitter") 
    << "GsfTrajectoryFitter::fit(TrajectorySeed, vector<RecHit>) not implemented";

  return std::vector<Trajectory>();
}
std::vector< Trajectory > GsfTrajectoryFitter::fit ( const TrajectorySeed aSeed,
const RecHitContainer hits,
const TSOS firstPredTsos 
) const [virtual]

!! no invalid hits on cylinders anymore??

Implements TrajectoryFitter.

Definition at line 54 of file GsfTrajectoryFitter.cc.

References MeasurementEstimator::estimate(), estimator(), Trajectory::foundHits(), DetLayerGeometry::idToLayer(), TrajectoryStateOnSurface::isValid(), LogDebug, MultiTrajectoryStateMerger::merge(), merger(), Propagator::propagate(), propagator(), Trajectory::push(), edm::second(), TrajectoryStateOnSurface::surface(), theGeometry, TrajectoryStateUpdator::update(), and updator().

                                                                                  {

  //   static TimingReport::Item* propTimer =
  //     &(*TimingReport::current())[string("GsfTrajectoryFitter:propagation")];
  //   propTimer->switchCPU(false);
  //   if ( !theTiming )  propTimer->switchOn(false);
  //   static TimingReport::Item* updateTimer =
  //     &(*TimingReport::current())[string("GsfTrajectoryFitter:update")];
  //   updateTimer->switchCPU(false);
  //   if ( !theTiming )  updateTimer->switchOn(false);

  if(hits.empty()) return std::vector<Trajectory>();

  Trajectory myTraj(aSeed, propagator()->propagationDirection());

  TSOS predTsos(firstPredTsos);
  if(!predTsos.isValid()) {
    edm::LogInfo("GsfTrajectoryFitter") 
      << "GsfTrajectoryFitter: predicted tsos of first measurement not valid!";
    return std::vector<Trajectory>();
  } 

  TSOS currTsos;
  if(hits.front()->isValid()) {
    //update
    TransientTrackingRecHit::RecHitPointer preciseHit = hits.front()->clone(predTsos);
    {
      //       TimeMe t(*updateTimer,false);
      currTsos = updator()->update(predTsos, *preciseHit);
    }
    if (!predTsos.isValid() || !currTsos.isValid()){
      edm::LogError("InvalidState")<<"first hit";
      return std::vector<Trajectory>();
    }
    myTraj.push(TM(predTsos, currTsos, preciseHit, 0., theGeometry->idToLayer(preciseHit->geographicalId() )),
                estimator()->estimate(predTsos, *preciseHit).second);
  } else {
    currTsos = predTsos;
    if (!predTsos.isValid()){
      edm::LogError("InvalidState")<<"first invalid hit";
      return std::vector<Trajectory>();
    }
    myTraj.push(TM(predTsos, *hits.begin(),0., theGeometry->idToLayer((*hits.begin())->geographicalId()) ));
  }
  
  for(RecHitContainer::const_iterator ihit = hits.begin() + 1; 
      ihit != hits.end(); ihit++) {    
    //
    // temporary protection copied from KFTrajectoryFitter.
    //
    if ((**ihit).isValid() == false && (**ihit).det() == 0) {
      LogDebug("GsfTrajectoryFitter") << " Error: invalid hit with no GeomDet attached .... skipping";
      continue;
    }

    //     //
    //     // check type of surface in case of invalid hit
    //     // (in this version only propagations to planes are
    //     // supported for multi trajectory states)
    //     //
    //     if ( !(**ihit).isValid() ) {
    //       const BoundPlane* plane = 
    //  dynamic_cast<const BoundPlane*>(&(**ihit).det().surface());
    //       //
    //       // no plane: insert invalid measurement
    //       //
    //       if ( plane==0 ) {
    //  myTraj.push(TM(TrajectoryStateOnSurface(),&(**ihit)));
    //  continue;
    //       }
    //     }
    {
      //       TimeMe t(*propTimer,false);
      predTsos = propagator()->propagate(currTsos,
                                         (**ihit).det()->surface());
    }
    if(!predTsos.isValid()) {
      if ( myTraj.foundHits()>=3 ) {
        edm::LogInfo("GsfTrajectoryFitter") 
          << "GsfTrajectoryFitter: predicted tsos not valid! \n"
          << "Returning trajectory with " << myTraj.foundHits() << " found hits.";
        return std::vector<Trajectory>(1,myTraj);
      }
      else {
      edm::LogInfo("GsfTrajectoryFitter") 
        << "GsfTrajectoryFitter: predicted tsos not valid after " << myTraj.foundHits()
        << " hits, discarding candidate!";
        return std::vector<Trajectory>();
      }
    }
    if ( merger() ) predTsos = merger()->merge(predTsos);
    
    if((**ihit).isValid()) {
      //update
      TransientTrackingRecHit::RecHitPointer preciseHit = (**ihit).clone(predTsos);
      {
        //      TimeMe t(*updateTimer,false);
        currTsos = updator()->update(predTsos, *preciseHit);
      }
      if (!predTsos.isValid() || !currTsos.isValid()){
        edm::LogError("InvalidState")<<"inside hit";
        return std::vector<Trajectory>();
      }
      myTraj.push(TM(predTsos, currTsos, preciseHit,
                     estimator()->estimate(predTsos, *preciseHit).second,
                     theGeometry->idToLayer(preciseHit->geographicalId() )));
    } else {
      currTsos = predTsos;
      if (!predTsos.isValid()){
      edm::LogError("InvalidState")<<"inside invalid hit";
      return std::vector<Trajectory>();
      }
      myTraj.push(TM(predTsos, *ihit,0., theGeometry->idToLayer( (*ihit)->geographicalId()) ));
    }
  }
  return std::vector<Trajectory>(1, myTraj);
}
std::vector< Trajectory > GsfTrajectoryFitter::fit ( const Trajectory aTraj) const [virtual]

Implements TrajectoryFitter.

Definition at line 35 of file GsfTrajectoryFitter.cc.

References Trajectory::empty(), Trajectory::firstMeasurement(), Trajectory::recHits(), Trajectory::seed(), and TrajectoryMeasurement::updatedState().

{  
  if(aTraj.empty()) return std::vector<Trajectory>();
 
  TM firstTM = aTraj.firstMeasurement();
  TSOS firstTsos = TrajectoryStateWithArbitraryError()(firstTM.updatedState());
  
  return fit(aTraj.seed(), aTraj.recHits(), firstTsos);
}
const MultiTrajectoryStateMerger* GsfTrajectoryFitter::merger ( ) const [inline]

Definition at line 49 of file GsfTrajectoryFitter.h.

References theMerger.

Referenced by fit().

{return theMerger;}
const Propagator* GsfTrajectoryFitter::propagator ( void  ) const [inline]

Definition at line 46 of file GsfTrajectoryFitter.h.

References thePropagator.

Referenced by fit().

{return thePropagator;}
const TrajectoryStateUpdator* GsfTrajectoryFitter::updator ( ) const [inline]

Definition at line 47 of file GsfTrajectoryFitter.h.

References theUpdator.

Referenced by fit().

{return theUpdator;}

Member Data Documentation

Definition at line 61 of file GsfTrajectoryFitter.h.

Referenced by GsfTrajectoryFitter().

Definition at line 59 of file GsfTrajectoryFitter.h.

Referenced by clone(), estimator(), and ~GsfTrajectoryFitter().

Definition at line 62 of file GsfTrajectoryFitter.h.

Referenced by clone(), fit(), and GsfTrajectoryFitter().

Definition at line 60 of file GsfTrajectoryFitter.h.

Referenced by clone(), merger(), and ~GsfTrajectoryFitter().

Definition at line 57 of file GsfTrajectoryFitter.h.

Referenced by clone(), propagator(), and ~GsfTrajectoryFitter().

Definition at line 64 of file GsfTrajectoryFitter.h.

Definition at line 58 of file GsfTrajectoryFitter.h.

Referenced by clone(), updator(), and ~GsfTrajectoryFitter().