CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

CkfTrajectoryBuilder Class Reference

#include <CkfTrajectoryBuilder.h>

Inheritance diagram for CkfTrajectoryBuilder:
BaseCkfTrajectoryBuilder TrajectoryBuilder CkfDebugTrajectoryBuilder MuonCkfTrajectoryBuilder

List of all members.

Public Types

typedef std::vector
< TempTrajectory
TempTrajectoryContainer
typedef std::vector< TrajectoryTrajectoryContainer

Public Member Functions

 CkfTrajectoryBuilder (const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *recHitBuilder, const MeasurementTracker *measurementTracker, const TrajectoryFilter *filter)
virtual void trajectories (const TrajectorySeed &seed, TrajectoryContainer &ret) const
 trajectories building starting from a seed
virtual TrajectoryContainer trajectories (const TrajectorySeed &seed) const
 trajectories building starting from a seed
 ~CkfTrajectoryBuilder ()

Protected Member Functions

virtual void findCompatibleMeasurements (const TempTrajectory &traj, std::vector< TrajectoryMeasurement > &result) const
void limitedCandidates (TempTrajectory &startingTraj, TrajectoryContainer &result) const
void limitedCandidates (TempTrajectoryContainer &candidates, TrajectoryContainer &result) const
void updateTrajectory (TempTrajectory &traj, const TM &tm) const

Protected Attributes

bool theAlwaysUseInvalidHits
bool theIntermediateCleaning
float theLostHitPenalty
int theMaxCand
 set Event for the internal MeasurementTracker data member

Detailed Description

Definition at line 34 of file CkfTrajectoryBuilder.h.


Member Typedef Documentation

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 39 of file CkfTrajectoryBuilder.h.

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 38 of file CkfTrajectoryBuilder.h.


Constructor & Destructor Documentation

CkfTrajectoryBuilder::CkfTrajectoryBuilder ( const edm::ParameterSet conf,
const TrajectoryStateUpdator updator,
const Propagator propagatorAlong,
const Propagator propagatorOpposite,
const Chi2MeasurementEstimatorBase estimator,
const TransientTrackingRecHitBuilder recHitBuilder,
const MeasurementTracker *  measurementTracker,
const TrajectoryFilter filter 
)

Definition at line 33 of file CkfTrajectoryBuilder.cc.

References edm::ParameterSet::getParameter(), theAlwaysUseInvalidHits, theIntermediateCleaning, theLostHitPenalty, and theMaxCand.

                                                                    :

    BaseCkfTrajectoryBuilder(conf,
                             updator, propagatorAlong,propagatorOpposite,
                             estimator, recHitBuilder, measurementTracker,filter)
{
  theMaxCand              = conf.getParameter<int>("maxCand");
  theLostHitPenalty       = conf.getParameter<double>("lostHitPenalty");
  theIntermediateCleaning = conf.getParameter<bool>("intermediateCleaning");
  theAlwaysUseInvalidHits = conf.getParameter<bool>("alwaysUseInvalidHits");
  /*
    theSharedSeedCheck = conf.getParameter<bool>("SharedSeedCheck");
    std::stringstream ss;
    ss<<"CkfTrajectoryBuilder_"<<conf.getParameter<std::string>("ComponentName")<<"_"<<this;
    theUniqueName = ss.str();
    LogDebug("CkfPattern")<<"my unique name is: "<<theUniqueName;
  */
}
CkfTrajectoryBuilder::~CkfTrajectoryBuilder ( ) [inline]

Definition at line 50 of file CkfTrajectoryBuilder.h.

{}

Member Function Documentation

void CkfTrajectoryBuilder::findCompatibleMeasurements ( const TempTrajectory traj,
std::vector< TrajectoryMeasurement > &  result 
) const [protected, virtual]

Reimplemented in MuonCkfTrajectoryBuilder.

Definition at line 263 of file CkfTrajectoryBuilder.cc.

References PrintoutHelper::dumpMeasurements(), TransverseImpactPointExtrapolator::extrapolate(), BaseCkfTrajectoryBuilder::findStateAndLayers(), i, TrajectoryStateOnSurface::isValid(), TempTrajectory::lastLayer(), LogDebug, LayerMeasurements::measurements(), python::multivaluedict::sort(), BaseCkfTrajectoryBuilder::theEstimator, BaseCkfTrajectoryBuilder::theForwardPropagator, BaseCkfTrajectoryBuilder::theLayerMeasurements, and tmp.

Referenced by limitedCandidates().

{
  int invalidHits = 0;
  std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers = findStateAndLayers(traj);
  if (stateAndLayers.second.empty()) return;

  vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
  vector<const DetLayer*>::iterator layerEnd  = stateAndLayers.second.end();
  LogDebug("CkfPattern")<<"looping on "<< stateAndLayers.second.size()<<" layers.";
  for (vector<const DetLayer*>::iterator il = layerBegin; 
       il != layerEnd; il++) {

    LogDebug("CkfPattern")<<"looping on a layer in findCompatibleMeasurements.\n last layer: "<<traj.lastLayer()<<" current layer: "<<(*il);

    TSOS stateToUse = stateAndLayers.first;
    if ((*il)==traj.lastLayer())
      {
        LogDebug("CkfPattern")<<" self propagating in findCompatibleMeasurements.\n from: \n"<<stateToUse;
        //self navigation case
        // go to a middle point first
        TransverseImpactPointExtrapolator middle;
        GlobalPoint center(0,0,0);
        stateToUse = middle.extrapolate(stateToUse, center, *theForwardPropagator);
        
        if (!stateToUse.isValid()) continue;
        LogDebug("CkfPattern")<<"to: "<<stateToUse;
      }
    
    vector<TrajectoryMeasurement> tmp = theLayerMeasurements->measurements((**il),stateToUse, *theForwardPropagator, *theEstimator);
    
    if ( !tmp.empty()) {
      if ( result.empty()) result = tmp;
      else {
        // keep one dummy TM at the end, skip the others
        result.insert( result.end()-invalidHits, tmp.begin(), tmp.end());
      }
      invalidHits++;
    }
  }

  // sort the final result, keep dummy measurements at the end
  if ( result.size() > 1) {
    sort( result.begin(), result.end()-invalidHits, TrajMeasLessEstim());
  }

  LogDebug("CkfPattern")<<"starting from:\n"
                        <<"x: "<<stateAndLayers.first.globalPosition()<<"\n"
                        <<"p: "<<stateAndLayers.first.globalMomentum()<<"\n"
                        <<PrintoutHelper::dumpMeasurements(result);

#ifdef DEBUG_INVALID
  bool afterInvalid = false;
  for (vector<TM>::const_iterator i=result.begin();
       i!=result.end(); i++) {
    if ( ! i->recHit().isValid()) afterInvalid = true;
    if (afterInvalid && i->recHit().isValid()) {
      edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: valid hit after invalid!" ;
    }
  }
#endif

  //analyseMeasurements( result, traj);

}
void CkfTrajectoryBuilder::limitedCandidates ( TempTrajectory startingTraj,
TrajectoryContainer result 
) const [protected]

Definition at line 165 of file CkfTrajectoryBuilder.cc.

Referenced by trajectories().

{
  TempTrajectoryContainer candidates;
  candidates.push_back( startingTraj);
  limitedCandidates(candidates,result);
}
void CkfTrajectoryBuilder::limitedCandidates ( TempTrajectoryContainer candidates,
TrajectoryContainer result 
) const [protected]

Definition at line 174 of file CkfTrajectoryBuilder.cc.

References BaseCkfTrajectoryBuilder::addToResult(), BaseCkfTrajectoryBuilder::analyzeMeasurementsDebugger(), clean, PrintoutHelper::dumpCandidates(), findCompatibleMeasurements(), prof2calltree::last, LogDebug, BaseCkfTrajectoryBuilder::qualityFilter(), python::multivaluedict::sort(), theAlwaysUseInvalidHits, BaseCkfTrajectoryBuilder::theEstimator, BaseCkfTrajectoryBuilder::theForwardPropagator, theIntermediateCleaning, theLostHitPenalty, theMaxCand, BaseCkfTrajectoryBuilder::theMeasurementTracker, BaseCkfTrajectoryBuilder::theTTRHBuilder, BaseCkfTrajectoryBuilder::toBeContinued(), and updateTrajectory().

{
  unsigned int nIter=1;
  //  TempTrajectoryContainer candidates; // = TrajectoryContainer();
  TempTrajectoryContainer newCand; // = TrajectoryContainer();
  //  candidates.push_back( startingTraj);

  while ( !candidates.empty()) {

    newCand.clear();
    for (TempTrajectoryContainer::iterator traj=candidates.begin();
         traj!=candidates.end(); traj++) {
      std::vector<TM> meas;
      findCompatibleMeasurements(*traj, meas);

      // --- method for debugging
      if(!analyzeMeasurementsDebugger(*traj,meas,
                                      theMeasurementTracker,
                                      theForwardPropagator,theEstimator,
                                      theTTRHBuilder)) return;
      // ---

      if ( meas.empty()) {
        if ( qualityFilter( *traj)) addToResult( *traj, result);
      }
      else {
        std::vector<TM>::const_iterator last;
        if ( theAlwaysUseInvalidHits) last = meas.end();
        else {
          if (meas.front().recHit()->isValid()) {
            last = find_if( meas.begin(), meas.end(), RecHitIsInvalid());
          }
          else last = meas.end();
        }

        for( std::vector<TM>::const_iterator itm = meas.begin(); 
             itm != last; itm++) {
          TempTrajectory newTraj = *traj;
          updateTrajectory( newTraj, *itm);

          if ( toBeContinued(newTraj)) {
            newCand.push_back(newTraj);
          }
          else {
            if ( qualityFilter(newTraj)) addToResult( newTraj, result);
          }
        }
      }

      if ((int)newCand.size() > theMaxCand) {
        sort( newCand.begin(), newCand.end(), TrajCandLess<TempTrajectory>(theLostHitPenalty));
        newCand.erase( newCand.begin()+theMaxCand, newCand.end());
      }
    }

    if (theIntermediateCleaning) IntermediateTrajectoryCleaner::clean(newCand);

    candidates.swap(newCand);
    
    LogDebug("CkfPattern") <<result.size()<<" candidates after "<<nIter++<<" CKF iteration: \n"
                           <<PrintoutHelper::dumpCandidates(result)
                           <<"\n "<<candidates.size()<<" running candidates are: \n"
                           <<PrintoutHelper::dumpCandidates(candidates);

  }
}
void CkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed,
CkfTrajectoryBuilder::TrajectoryContainer result 
) const [virtual]

trajectories building starting from a seed

limitedCandidates( startingTraj, regionalCondition, result); FIXME: restore regionalCondition

Reimplemented from TrajectoryBuilder.

Definition at line 134 of file CkfTrajectoryBuilder.cc.

References BaseCkfTrajectoryBuilder::createStartingTrajectory(), and limitedCandidates().

{  
  // analyseSeed( seed);
  /*
    if (theSharedSeedCheck){
    TempTrajectoryContainer candidates;
    if (seedAlreadyUsed(seed,candidates))
    {
    //start with those candidates already made before
    limitedCandidates(candidates,result);
    //and quit
    return;
    }
    }
  */

  TempTrajectory startingTraj = createStartingTrajectory( seed );

  limitedCandidates( startingTraj, result);

  /*
    //and remember what you just did
    if (theSharedSeedCheck)  rememberSeedAndTrajectories(seed,result);
  */

  // analyseResult(result);
}
CkfTrajectoryBuilder::TrajectoryContainer CkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed) const [virtual]

trajectories building starting from a seed

Implements BaseCkfTrajectoryBuilder.

Definition at line 67 of file CkfTrajectoryBuilder.cc.

References query::result.

{  
  TrajectoryContainer result;
  result.reserve(5);
  trajectories(seed, result);
  return result;
}
void CkfTrajectoryBuilder::updateTrajectory ( TempTrajectory traj,
const TM tm 
) const [protected]

Definition at line 245 of file CkfTrajectoryBuilder.cc.

References TrajectoryMeasurement::estimate(), TrajectoryMeasurement::layer(), TrajectoryMeasurement::predictedState(), TempTrajectory::push(), TrajectoryMeasurement::recHit(), BaseCkfTrajectoryBuilder::theUpdator, tmp, and TrajectoryStateUpdator::update().

Referenced by limitedCandidates().

{
  TSOS predictedState = tm.predictedState();
  TM::ConstRecHitPointer hit = tm.recHit();
 
  if ( hit->isValid()) {
    TM tmp = TM( predictedState, theUpdator->update( predictedState, *hit),
                 hit, tm.estimate(), tm.layer()); 
    traj.push(tmp );
  }
  else {
    traj.push( TM( predictedState, hit, 0, tm.layer()));
  }
}

Member Data Documentation

Definition at line 68 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

Tells whether an intermediary cleaning stage should take place during TB.

Definition at line 66 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

Chi**2 Penalty for each lost hit.

Definition at line 65 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

set Event for the internal MeasurementTracker data member

Maximum number of trajectory candidates to propagate to the next layer.

Definition at line 63 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().