CMS 3D CMS Logo

KFTrajectoryFitter Class Reference

A Kalman track fit that splits matched RecHits into individual components before fitting them. More...

#include <TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h>

Inheritance diagram for KFTrajectoryFitter:

TrajectoryFitter KFSplittingFitter

List of all members.

Public Member Functions

virtual KFTrajectoryFitterclone () 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
 KFTrajectoryFitter (const Propagator *aPropagator, const TrajectoryStateUpdator *aUpdator, const MeasurementEstimator *aEstimator, int minHits=3)
 KFTrajectoryFitter (const Propagator &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, int minHits=3)
const Propagatorpropagator () const
const TrajectoryStateUpdatorupdator () const
virtual ~KFTrajectoryFitter ()

Private Types

typedef FreeTrajectoryState FTS
typedef TrajectoryMeasurement TM
typedef TrajectoryStateOnSurface TSOS

Private Attributes

int minHits_
const MeasurementEstimatortheEstimator
PropagatorthePropagator
const TrajectoryStateUpdatortheUpdator


Detailed Description

A Kalman track fit that splits matched RecHits into individual components before fitting them.

A Standard Kalman fit.

Ported from ORCA

Date
2007/05/09 14:17:57
Revision
1.6
Author:
todorov, cerati
Ported from ORCA

Date
2007/10/08 22:22:50
Revision
1.7
Author:
todorov, cerati

Definition at line 21 of file KFTrajectoryFitter.h.


Member Typedef Documentation

typedef FreeTrajectoryState KFTrajectoryFitter::FTS [private]

Reimplemented in KFSplittingFitter.

Definition at line 26 of file KFTrajectoryFitter.h.

typedef TrajectoryMeasurement KFTrajectoryFitter::TM [private]

Reimplemented in KFSplittingFitter.

Definition at line 27 of file KFTrajectoryFitter.h.

typedef TrajectoryStateOnSurface KFTrajectoryFitter::TSOS [private]

Reimplemented in KFSplittingFitter.

Definition at line 25 of file KFTrajectoryFitter.h.


Constructor & Destructor Documentation

KFTrajectoryFitter::KFTrajectoryFitter ( const Propagator aPropagator,
const TrajectoryStateUpdator aUpdator,
const MeasurementEstimator aEstimator,
int  minHits = 3 
) [inline]

Definition at line 32 of file KFTrajectoryFitter.h.

Referenced by clone().

00035                                       :
00036     thePropagator(aPropagator.clone()),
00037     theUpdator(aUpdator.clone()),
00038     theEstimator(aEstimator.clone()),
00039     minHits_(minHits){}
  

KFTrajectoryFitter::KFTrajectoryFitter ( const Propagator aPropagator,
const TrajectoryStateUpdator aUpdator,
const MeasurementEstimator aEstimator,
int  minHits = 3 
) [inline]

Definition at line 41 of file KFTrajectoryFitter.h.

00044                                       : 
00045     thePropagator(aPropagator->clone()),
00046     theUpdator(aUpdator->clone()),
00047     theEstimator(aEstimator->clone()),
00048     minHits_(minHits) {}

KFTrajectoryFitter::~KFTrajectoryFitter (  )  [virtual]

Definition at line 17 of file KFTrajectoryFitter.cc.

References theEstimator, thePropagator, and theUpdator.

00017                                         {
00018 
00019   delete thePropagator;
00020   delete theUpdator;
00021   delete theEstimator;
00022 
00023 }


Member Function Documentation

virtual KFTrajectoryFitter* KFTrajectoryFitter::clone ( void   )  const [inline, virtual]

Implements TrajectoryFitter.

Reimplemented in KFSplittingFitter.

Definition at line 64 of file KFTrajectoryFitter.h.

References KFTrajectoryFitter(), theEstimator, thePropagator, and theUpdator.

00065   {
00066     return new KFTrajectoryFitter(thePropagator,theUpdator,theEstimator);
00067   }

const MeasurementEstimator* KFTrajectoryFitter::estimator ( void   )  const [inline]

Definition at line 62 of file KFTrajectoryFitter.h.

References theEstimator.

Referenced by KFSplittingFitter::clone(), and fit().

00062 {return theEstimator;}

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

Reimplemented in KFSplittingFitter.

Definition at line 45 of file KFTrajectoryFitter.cc.

References alongMomentum, TransientTrackingRecHit::clone(), MuonSubdetId::CSC, DetId::det(), TrajectorySeed::direction(), MuonSubdetId::DT, estimator(), Exception, Trajectory::foundHits(), TrackingRecHit::geographicalId(), TransientTrackingRecHit::globalPosition(), int, TrackingRecHit::isValid(), TrajectoryStateOnSurface::isValid(), j, TrackingRecHit::localPosition(), TrackingRecHit::localPositionError(), LogDebug, LogTrace, minHits_, DetId::Muon, oppositeToMomentum, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, GloballyPositioned< T >::position(), Propagator::propagate(), Propagator::propagationDirection(), Trajectory::push(), DetId::rawId(), Trajectory::reserve(), GloballyPositioned< T >::rotation(), MuonSubdetId::RPC, edm::second(), Propagator::setPropagationDirection(), DetId::subdetId(), TransientTrackingRecHit::surface(), StripSubdetector::TEC, thePropagator, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, DetId::Tracker, TrajectoryStateUpdator::update(), updator(), and PV3DBase< T, PVType, FrameType >::z().

00048 {
00049   if(hits.empty()) return std::vector<Trajectory>();
00050 
00051   if (aSeed.direction() == alongMomentum) {
00052     thePropagator->setPropagationDirection(alongMomentum);
00053   } else if (aSeed.direction() == oppositeToMomentum){
00054     thePropagator->setPropagationDirection(oppositeToMomentum);
00055   } else {
00056     throw cms::Exception("KFTrajectoryFitter","TrajectorySeed::direction() requested but not set");
00057   }
00058 
00059   LogDebug("TrackFitters")
00060     <<" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
00061     <<" KFTrajectoryFitter::fit starting with " << hits.size() <<" HITS";
00062   
00063   for (unsigned int j=0;j<hits.size();j++) { 
00064     if (hits[j]->det()) 
00065       LogTrace("TrackFitters") << "hit #:" << j+1 << " rawId=" << hits[j]->det()->geographicalId().rawId() 
00066                                << " validity=" << hits[j]->isValid();
00067     else
00068       LogTrace("TrackFitters") << "hit #:" << j+1 << " Hit with no Det information";
00069   }
00070   LogTrace("TrackFitters") << " INITIAL STATE "<< firstPredTsos;
00071 
00072   std::vector<Trajectory> ret(1, Trajectory(aSeed, thePropagator->propagationDirection()));
00073   Trajectory & myTraj = ret.front();
00074   myTraj.reserve(hits.size());
00075 
00076   TSOS predTsos(firstPredTsos);
00077   TSOS currTsos;
00078 
00079   int hitcounter = 1;
00080   for(RecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ++ihit, ++hitcounter) {
00081 
00082     const TransientTrackingRecHit & hit = (**ihit);
00083 
00084     if (hit.isValid() == false && hit.surface() == 0) {
00085       LogDebug("TrackFitters")<< " Error: invalid hit with no GeomDet attached .... skipping";
00086       continue;
00087     }
00088 
00089     if (hit.isValid()) {
00090       LogTrace("TrackFitters")
00091         << " ----------------- HIT #" << hitcounter << " (VALID)-----------------------\n"
00092         << "  HIT IS AT R   " << hit.globalPosition().perp() << "\n"
00093         << "  HIT IS AT Z   " << hit.globalPosition().z() << "\n"
00094         << "  HIT IS AT Phi " << hit.globalPosition().phi() << "\n"
00095         << "  HIT IS AT Loc " << hit.localPosition() << "\n"
00096         << "  WITH LocError " << hit.localPositionError() << "\n"
00097         << "  HIT IS AT Glo " << hit.globalPosition() << "\n"
00098         << "SURFACE POSITION" << "\n"
00099         << hit.surface()->position()<<"\n"
00100         << "SURFACE ROTATION" << "\n"
00101         << hit.surface()->rotation();
00102       
00103       DetId hitId = hit.geographicalId();
00104 
00105       LogTrace("TrackFitters") << " hit det=" << hitId.rawId();
00106       
00107       if(hitId.det() == DetId::Tracker) {
00108         if (hitId.subdetId() == StripSubdetector::TIB )  
00109           LogTrace("TrackFitters") << " I am TIB " << TIBDetId(hitId).layer();
00110         else if (hitId.subdetId() == StripSubdetector::TOB ) 
00111           LogTrace("TrackFitters") << " I am TOB " << TOBDetId(hitId).layer();
00112         else if (hitId.subdetId() == StripSubdetector::TEC ) 
00113           LogTrace("TrackFitters") << " I am TEC " << TECDetId(hitId).wheel();
00114         else if (hitId.subdetId() == StripSubdetector::TID ) 
00115           LogTrace("TrackFitters") << " I am TID " << TIDDetId(hitId).wheel();
00116         else if (hitId.subdetId() == StripSubdetector::TID ) 
00117           LogTrace("TrackFitters") << " I am TID " << TIDDetId(hitId).wheel();
00118         else if (hitId.subdetId() == (int) PixelSubdetector::PixelBarrel ) 
00119           LogTrace("TrackFitters") << " I am PixBar " << PXBDetId(hitId).layer();
00120         else if (hitId.subdetId() == (int) PixelSubdetector::PixelEndcap )
00121           LogTrace("TrackFitters") << " I am PixFwd " << PXFDetId(hitId).disk();
00122         else 
00123           LogTrace("TrackFitters") << " UNKNOWN TRACKER HIT TYPE ";
00124       }
00125       else if(hitId.det() == DetId::Muon) {
00126         if(hitId.subdetId() == MuonSubdetId::DT)
00127           LogTrace("TrackFitters") << " I am DT " << DTWireId(hitId);
00128         else if (hitId.subdetId() == MuonSubdetId::CSC )
00129           LogTrace("TrackFitters") << " I am CSC " << CSCDetId(hitId);
00130         else if (hitId.subdetId() == MuonSubdetId::RPC )
00131           LogTrace("TrackFitters") << " I am RPC " << RPCDetId(hitId);
00132         else 
00133           LogTrace("TrackFitters") << " UNKNOWN MUON HIT TYPE ";
00134       }
00135       else
00136         LogTrace("TrackFitters") << " UNKNOWN HIT TYPE ";
00137       
00138     } else {
00139       LogTrace("TrackFitters")
00140         << " ----------------- INVALID HIT #" << hitcounter << " -----------------------";      
00141     }
00142     
00143 
00144     if ( hitcounter != 1) //no propagation needed for the first hit
00145       predTsos = thePropagator->propagate( currTsos, *(hit.surface()) );
00146     
00147     if(!predTsos.isValid()) {
00148       LogDebug("TrackFitters") 
00149         << "SOMETHING WRONG !" << "\n"
00150         << "KFTrajectoryFitter: predicted tsos not valid!\n" 
00151         << "current TSOS: " << currTsos << "\n";
00152 
00153       if(hit.surface()) LogTrace("TrackFitters") << "next Surface: " << hit.surface()->position() << "\n";
00154 
00155       if( myTraj.foundHits() >= minHits_ ) {
00156         LogDebug("TrackFitters") << " breaking trajectory" << "\n";
00157         break;      
00158       } else {        
00159         LogDebug("TrackFitters") << " killing trajectory" << "\n";       
00160         return std::vector<Trajectory>();
00161       }
00162     }
00163     
00164     if(hit.isValid()) {
00165       //update
00166       LogTrace("TrackFitters") << "THE HIT IS VALID: updating hit with predTsos";
00167       TransientTrackingRecHit::RecHitPointer preciseHit = hit.clone(predTsos);
00168 
00169       if (preciseHit->isValid() == false){
00170         LogTrace("TrackFitters") << "THE Precise HIT IS NOT VALID: using currTsos = predTsos" << "\n";
00171         currTsos = predTsos;
00172         myTraj.push(TM(predTsos, *ihit ));//why no estimate? if the hit is valid it should contribute to chi2...
00173 
00174       }else{
00175         LogTrace("TrackFitters") << "THE Precise HIT IS VALID: updating currTsos" << "\n";
00176         currTsos = updator()->update(predTsos, *preciseHit);
00177         myTraj.push(TM(predTsos, currTsos, preciseHit,
00178                        estimator()->estimate(predTsos, *preciseHit).second));
00179 
00180       }
00181     } else {
00182       //no update
00183       LogDebug("TrackFitters") << "THE HIT IS NOT VALID: using currTsos" << "\n";
00184       currTsos = predTsos;
00185       myTraj.push(TM(predTsos, *ihit));
00186     }
00187 
00188     LogTrace("TrackFitters")
00189       << "predTsos !" << "\n"
00190       << predTsos << "\n"
00191       <<"currTsos !" << "\n"
00192       << currTsos;
00193   }  
00194   LogDebug("TrackFitters") << "Found 1 trajectory with " << myTraj.foundHits() << " valid hits\n";
00195   
00196   return ret;
00197 }

std::vector< Trajectory > KFTrajectoryFitter::fit ( const TrajectorySeed aSeed,
const RecHitContainer hits 
) const [virtual]

Definition at line 36 of file KFTrajectoryFitter.cc.

References Exception.

00037                                                                                   {
00038 
00039   throw cms::Exception("TrackFitters", 
00040                        "KFTrajectoryFitter::fit(TrajectorySeed, <TransientTrackingRecHit>) not implemented"); 
00041 
00042   return std::vector<Trajectory>();
00043 }

std::vector< Trajectory > KFTrajectoryFitter::fit ( const Trajectory aTraj  )  const [virtual]

Implements TrajectoryFitter.

Reimplemented in KFSplittingFitter.

Definition at line 26 of file KFTrajectoryFitter.cc.

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

Referenced by KFSplittingFitter::fit().

00026                                                                            {
00027 
00028   if(aTraj.empty()) return std::vector<Trajectory>();
00029  
00030   TM firstTM = aTraj.firstMeasurement();
00031   TSOS firstTsos = TrajectoryStateWithArbitraryError()(firstTM.updatedState());
00032   
00033   return fit(aTraj.seed(), aTraj.recHits(), firstTsos);
00034 }

const Propagator* KFTrajectoryFitter::propagator ( void   )  const [inline]

Definition at line 60 of file KFTrajectoryFitter.h.

References thePropagator.

Referenced by KFSplittingFitter::clone(), and KalmanAlignmentAlgorithm::initializeAlignmentSetups().

00060 {return thePropagator;}

const TrajectoryStateUpdator* KFTrajectoryFitter::updator (  )  const [inline]

Definition at line 61 of file KFTrajectoryFitter.h.

References theUpdator.

Referenced by KFSplittingFitter::clone(), fit(), and KalmanAlignmentAlgorithm::initializeAlignmentSetups().

00061 {return theUpdator;}


Member Data Documentation

int KFTrajectoryFitter::minHits_ [private]

Definition at line 74 of file KFTrajectoryFitter.h.

Referenced by fit().

const MeasurementEstimator* KFTrajectoryFitter::theEstimator [private]

Definition at line 73 of file KFTrajectoryFitter.h.

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

Propagator* KFTrajectoryFitter::thePropagator [private]

Definition at line 71 of file KFTrajectoryFitter.h.

Referenced by clone(), fit(), propagator(), and ~KFTrajectoryFitter().

const TrajectoryStateUpdator* KFTrajectoryFitter::theUpdator [private]

Definition at line 72 of file KFTrajectoryFitter.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:18 2009 for CMSSW by  doxygen 1.5.4