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

TempTrajectory buildTrajectories (const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
 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)
void rebuildTrajectories (TempTrajectory const &startingTraj, const TrajectorySeed &, TrajectoryContainer &result) const
virtual TrajectoryContainer trajectories (const TrajectorySeed &seed) const
 trajectories building starting from a seed
virtual void trajectories (const TrajectorySeed &seed, TrajectoryContainer &ret) const
 trajectories building starting from a seed
 ~CkfTrajectoryBuilder ()

Protected Member Functions

virtual void findCompatibleMeasurements (const TrajectorySeed &seed, const TempTrajectory &traj, std::vector< TrajectoryMeasurement > &result) const
void limitedCandidates (const TrajectorySeed &seed, TempTrajectory &startingTraj, TrajectoryContainer &result) const
void limitedCandidates (const boost::shared_ptr< const TrajectorySeed > &sharedSeed, 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

TempTrajectory CkfTrajectoryBuilder::buildTrajectories ( const TrajectorySeed seed,
TrajectoryContainer ret,
const TrajectoryFilter  
) const [virtual]

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

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 153 of file CkfTrajectoryBuilder.cc.

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

Referenced by trajectories().

                                                                                       {
  
  TempTrajectory startingTraj = createStartingTrajectory( seed );
  
  limitedCandidates(seed, startingTraj, result);
  
  return startingTraj;

  /*
  //and remember what you just did
  if (theSharedSeedCheck)  rememberSeedAndTrajectories(seed,result);
  */
  
  // analyseResult(result);
}
void CkfTrajectoryBuilder::findCompatibleMeasurements ( const TrajectorySeed seed,
const TempTrajectory traj,
std::vector< TrajectoryMeasurement > &  result 
) const [protected, virtual]

Reimplemented in MuonCkfTrajectoryBuilder.

Definition at line 272 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 ( const boost::shared_ptr< const TrajectorySeed > &  sharedSeed,
TempTrajectoryContainer candidates,
TrajectoryContainer result 
) const [protected]

Definition at line 184 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 newCand; // = TrajectoryContainer();

 
  while ( !candidates.empty()) {

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

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

      if ( meas.empty()) {
        if ( qualityFilter( *traj)) addToResult(sharedSeed, *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(sharedSeed, 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::limitedCandidates ( const TrajectorySeed seed,
TempTrajectory startingTraj,
TrajectoryContainer result 
) const [protected]

Definition at line 174 of file CkfTrajectoryBuilder.cc.

Referenced by buildTrajectories().

{
  TempTrajectoryContainer candidates;
  candidates.push_back( startingTraj);
  boost::shared_ptr<const TrajectorySeed>  sharedSeed(new TrajectorySeed(seed));
  limitedCandidates(sharedSeed, candidates,result);
}
void CkfTrajectoryBuilder::rebuildTrajectories ( TempTrajectory const &  startingTraj,
const TrajectorySeed ,
TrajectoryContainer result 
) const [inline, virtual]

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 63 of file CkfTrajectoryBuilder.h.

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

trajectories building starting from a seed

Reimplemented from TrajectoryBuilder.

Definition at line 134 of file CkfTrajectoryBuilder.cc.

References buildTrajectories().

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

  buildTrajectories(seed, result,nullptr);
}
CkfTrajectoryBuilder::TrajectoryContainer CkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed) const [virtual]

trajectories building starting from a seed

Implements TrajectoryBuilder.

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 254 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 77 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

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

Definition at line 75 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

Chi**2 Penalty for each lost hit.

Definition at line 74 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 72 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().