CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
CkfTrajectoryBuilder Class Reference

#include <CkfTrajectoryBuilder.h>

Inheritance diagram for CkfTrajectoryBuilder:
BaseCkfTrajectoryBuilder TrajectoryBuilder CkfDebugTrajectoryBuilder MuonCkfTrajectoryBuilder

Public Types

typedef std::vector
< TempTrajectory
TempTrajectoryContainer
 
typedef std::vector< TrajectoryTrajectoryContainer
 
- Public Types inherited from BaseCkfTrajectoryBuilder
typedef std::vector
< TempTrajectory
TempTrajectoryContainer
 
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef
TrajectoryContainer::iterator 
TrajectoryIterator
 
- Public Types inherited from TrajectoryBuilder
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef
TrajectoryContainer::iterator 
TrajectoryIterator
 

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 More...
 
virtual void trajectories (const TrajectorySeed &seed, TrajectoryContainer &ret) const
 trajectories building starting from a seed More...
 
 ~CkfTrajectoryBuilder ()
 
- Public Member Functions inherited from BaseCkfTrajectoryBuilder
 BaseCkfTrajectoryBuilder (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, const TrajectoryFilter *inOutFilter=0)
 
virtual void setDebugger (CkfDebugger *dbg) const
 
virtual void setEvent (const edm::Event &event) const
 
virtual void unset () const
 
virtual ~BaseCkfTrajectoryBuilder ()
 
- Public Member Functions inherited from TrajectoryBuilder
virtual void rebuildSeedingRegion (const TrajectorySeed &, TrajectoryContainer &result) const
 
virtual ~TrajectoryBuilder ()
 

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 Member Functions inherited from BaseCkfTrajectoryBuilder
void addToResult (boost::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
 
void addToResult (TempTrajectory const &traj, TempTrajectoryContainer &result, bool inOut=false) const
 
virtual bool analyzeMeasurementsDebugger (Trajectory &traj, const std::vector< TrajectoryMeasurement > &meas, const MeasurementTracker *theMeasurementTracker, const Propagator *theForwardPropagator, const Chi2MeasurementEstimatorBase *theEstimator, const TransientTrackingRecHitBuilder *theTTRHBuilder) const
 
virtual bool analyzeMeasurementsDebugger (TempTrajectory &traj, const std::vector< TrajectoryMeasurement > &meas, const MeasurementTracker *theMeasurementTracker, const Propagator *theForwardPropagator, const Chi2MeasurementEstimatorBase *theEstimator, const TransientTrackingRecHitBuilder *theTTRHBuilder) const
 
TempTrajectory createStartingTrajectory (const TrajectorySeed &seed) const
 
virtual void fillSeedHistoDebugger (std::vector< TrajectoryMeasurement >::iterator begin, std::vector< TrajectoryMeasurement >::iterator end) const
 
StateAndLayers findStateAndLayers (const TrajectorySeed &seed, const TempTrajectory &traj) const
 
StateAndLayers findStateAndLayers (const TempTrajectory &traj) const
 
void moveToResult (TempTrajectory &&traj, TempTrajectoryContainer &result, bool inOut=false) const
 
bool qualityFilter (const TempTrajectory &traj, bool inOut=false) const
 
bool toBeContinued (TempTrajectory &traj, bool inOut=false) const
 

Protected Attributes

bool theAlwaysUseInvalidHits
 
bool theIntermediateCleaning
 
float theLostHitPenalty
 
int theMaxCand
 set Event for the internal MeasurementTracker data member More...
 
- Protected Attributes inherited from BaseCkfTrajectoryBuilder
const PropagatortheBackwardPropagator
 
const
Chi2MeasurementEstimatorBase
theEstimator
 
const PropagatortheForwardPropagator
 
const LayerMeasurementstheLayerMeasurements
 
const MeasurementTrackertheMeasurementTracker
 
const PropagatorthePropagatorAlong
 
const PropagatorthePropagatorOpposite
 
const
TransientTrackingRecHitBuilder
theTTRHBuilder
 
const TrajectoryStateUpdatortheUpdator
 

Additional Inherited Members

- Protected Types inherited from BaseCkfTrajectoryBuilder
typedef FreeTrajectoryState FTS
 
typedef std::pair< TSOS,
std::vector< const DetLayer * > > 
StateAndLayers
 
typedef TrajectoryMeasurement TM
 
typedef TrajectoryStateOnSurface TSOS
 

Detailed Description

Definition at line 34 of file CkfTrajectoryBuilder.h.

Member Typedef Documentation

Definition at line 39 of file CkfTrajectoryBuilder.h.

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.

40  :
41 
43  updator, propagatorAlong,propagatorOpposite,
44  estimator, recHitBuilder, measurementTracker,filter)
45 {
46  theMaxCand = conf.getParameter<int>("maxCand");
47  theLostHitPenalty = conf.getParameter<double>("lostHitPenalty");
48  theIntermediateCleaning = conf.getParameter<bool>("intermediateCleaning");
49  theAlwaysUseInvalidHits = conf.getParameter<bool>("alwaysUseInvalidHits");
50  /*
51  theSharedSeedCheck = conf.getParameter<bool>("SharedSeedCheck");
52  std::stringstream ss;
53  ss<<"CkfTrajectoryBuilder_"<<conf.getParameter<std::string>("ComponentName")<<"_"<<this;
54  theUniqueName = ss.str();
55  LogDebug("CkfPattern")<<"my unique name is: "<<theUniqueName;
56  */
57 }
T getParameter(std::string const &) const
BaseCkfTrajectoryBuilder(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, const TrajectoryFilter *inOutFilter=0)
int theMaxCand
set Event for the internal MeasurementTracker data member
CkfTrajectoryBuilder::~CkfTrajectoryBuilder ( )
inline

Definition at line 50 of file CkfTrajectoryBuilder.h.

50 {}

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().

155  {
156 
157  TempTrajectory startingTraj = createStartingTrajectory( seed );
158 
161  limitedCandidates(seed, startingTraj, result);
162 
163  return startingTraj;
164 
165  /*
166  //and remember what you just did
167  if (theSharedSeedCheck) rememberSeedAndTrajectories(seed,result);
168  */
169 
170  // analyseResult(result);
171 }
tuple result
Definition: query.py:137
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
void limitedCandidates(const TrajectorySeed &seed, TempTrajectory &startingTraj, TrajectoryContainer &result) const
void CkfTrajectoryBuilder::findCompatibleMeasurements ( const TrajectorySeed seed,
const TempTrajectory traj,
std::vector< TrajectoryMeasurement > &  result 
) const
protectedvirtual

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().

275 {
276  int invalidHits = 0;
277  std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers = findStateAndLayers(traj);
278  if (stateAndLayers.second.empty()) return;
279 
280  vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
281  vector<const DetLayer*>::iterator layerEnd = stateAndLayers.second.end();
282  LogDebug("CkfPattern")<<"looping on "<< stateAndLayers.second.size()<<" layers.";
283  for (vector<const DetLayer*>::iterator il = layerBegin;
284  il != layerEnd; il++) {
285 
286  LogDebug("CkfPattern")<<"looping on a layer in findCompatibleMeasurements.\n last layer: "<<traj.lastLayer()<<" current layer: "<<(*il);
287 
288  TSOS stateToUse = stateAndLayers.first;
289  if ((*il)==traj.lastLayer())
290  {
291  LogDebug("CkfPattern")<<" self propagating in findCompatibleMeasurements.\n from: \n"<<stateToUse;
292  //self navigation case
293  // go to a middle point first
295  GlobalPoint center(0,0,0);
296  stateToUse = middle.extrapolate(stateToUse, center, *theForwardPropagator);
297 
298  if (!stateToUse.isValid()) continue;
299  LogDebug("CkfPattern")<<"to: "<<stateToUse;
300  }
301 
302  vector<TrajectoryMeasurement> tmp = theLayerMeasurements->measurements((**il),stateToUse, *theForwardPropagator, *theEstimator);
303 
304  if ( !tmp.empty()) {
305  if ( result.empty()) result = tmp;
306  else {
307  // keep one dummy TM at the end, skip the others
308  result.insert( result.end()-invalidHits, tmp.begin(), tmp.end());
309  }
310  invalidHits++;
311  }
312  }
313 
314  // sort the final result, keep dummy measurements at the end
315  if ( result.size() > 1) {
316  sort( result.begin(), result.end()-invalidHits, TrajMeasLessEstim());
317  }
318 
319  LogDebug("CkfPattern")<<"starting from:\n"
320  <<"x: "<<stateAndLayers.first.globalPosition()<<"\n"
321  <<"p: "<<stateAndLayers.first.globalMomentum()<<"\n"
323 
324 #ifdef DEBUG_INVALID
325  bool afterInvalid = false;
326  for (vector<TM>::const_iterator i=result.begin();
327  i!=result.end(); i++) {
328  if ( ! i->recHit().isValid()) afterInvalid = true;
329  if (afterInvalid && i->recHit().isValid()) {
330  edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: valid hit after invalid!" ;
331  }
332  }
333 #endif
334 
335  //analyseMeasurements( result, traj);
336 
337 }
#define LogDebug(id)
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
int i
Definition: DBlmapReader.cc:9
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
const LayerMeasurements * theLayerMeasurements
tuple result
Definition: query.py:137
StateAndLayers findStateAndLayers(const TrajectorySeed &seed, const TempTrajectory &traj) const
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const Chi2MeasurementEstimatorBase * theEstimator
const Propagator * theForwardPropagator
void CkfTrajectoryBuilder::limitedCandidates ( const TrajectorySeed seed,
TempTrajectory startingTraj,
TrajectoryContainer result 
) const
protected

Definition at line 174 of file CkfTrajectoryBuilder.cc.

Referenced by buildTrajectories().

176 {
177  TempTrajectoryContainer candidates;
178  candidates.push_back( startingTraj);
179  boost::shared_ptr<const TrajectorySeed> sharedSeed(new TrajectorySeed(seed));
180  limitedCandidates(sharedSeed, candidates,result);
181 }
std::vector< TempTrajectory > TempTrajectoryContainer
tuple result
Definition: query.py:137
void limitedCandidates(const TrajectorySeed &seed, TempTrajectory &startingTraj, TrajectoryContainer &result) const
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(), IntermediateTrajectoryCleaner::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().

186 {
187  unsigned int nIter=1;
188  TempTrajectoryContainer newCand; // = TrajectoryContainer();
189 
190 
191  while ( !candidates.empty()) {
192 
193  newCand.clear();
194  for (TempTrajectoryContainer::iterator traj=candidates.begin();
195  traj!=candidates.end(); traj++) {
196  std::vector<TM> meas;
197  findCompatibleMeasurements(*sharedSeed, *traj, meas);
198 
199  // --- method for debugging
200  if(!analyzeMeasurementsDebugger(*traj,meas,
203  theTTRHBuilder)) return;
204  // ---
205 
206  if ( meas.empty()) {
207  if ( qualityFilter( *traj)) addToResult(sharedSeed, *traj, result);
208  }
209  else {
210  std::vector<TM>::const_iterator last;
211  if ( theAlwaysUseInvalidHits) last = meas.end();
212  else {
213  if (meas.front().recHit()->isValid()) {
214  last = find_if( meas.begin(), meas.end(), RecHitIsInvalid());
215  }
216  else last = meas.end();
217  }
218 
219  for( std::vector<TM>::const_iterator itm = meas.begin();
220  itm != last; itm++) {
221  TempTrajectory newTraj = *traj;
222  updateTrajectory( newTraj, *itm);
223 
224  if ( toBeContinued(newTraj)) {
225  newCand.push_back(newTraj);
226  }
227  else {
228  if ( qualityFilter(newTraj)) addToResult(sharedSeed, newTraj, result);
230  }
231  }
232  }
233 
234  if ((int)newCand.size() > theMaxCand) {
235  sort( newCand.begin(), newCand.end(), TrajCandLess<TempTrajectory>(theLostHitPenalty));
236  newCand.erase( newCand.begin()+theMaxCand, newCand.end());
237  }
238  }
239 
241 
242  candidates.swap(newCand);
243 
244  LogDebug("CkfPattern") <<result.size()<<" candidates after "<<nIter++<<" CKF iteration: \n"
246  <<"\n "<<candidates.size()<<" running candidates are: \n"
247  <<PrintoutHelper::dumpCandidates(candidates);
248 
249  }
250 }
#define LogDebug(id)
static std::string dumpCandidates(collection &candidates)
static void clean(TempTrajectoryContainer &tracks)
virtual bool analyzeMeasurementsDebugger(Trajectory &traj, const std::vector< TrajectoryMeasurement > &meas, const MeasurementTracker *theMeasurementTracker, const Propagator *theForwardPropagator, const Chi2MeasurementEstimatorBase *theEstimator, const TransientTrackingRecHitBuilder *theTTRHBuilder) const
std::vector< TempTrajectory > TempTrajectoryContainer
bool qualityFilter(const TempTrajectory &traj, bool inOut=false) const
const TransientTrackingRecHitBuilder * theTTRHBuilder
tuple result
Definition: query.py:137
void addToResult(boost::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
void updateTrajectory(TempTrajectory &traj, const TM &tm) const
const MeasurementTracker * theMeasurementTracker
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
virtual void findCompatibleMeasurements(const TrajectorySeed &seed, const TempTrajectory &traj, std::vector< TrajectoryMeasurement > &result) const
int theMaxCand
set Event for the internal MeasurementTracker data member
const Chi2MeasurementEstimatorBase * theEstimator
const Propagator * theForwardPropagator
void CkfTrajectoryBuilder::rebuildTrajectories ( TempTrajectory const &  startingTraj,
const TrajectorySeed ,
TrajectoryContainer result 
) const
inlinevirtual

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 63 of file CkfTrajectoryBuilder.h.

64  {}
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.

68 {
70  result.reserve(5);
71  trajectories(seed, result);
72  return result;
73 }
std::vector< Trajectory > TrajectoryContainer
tuple result
Definition: query.py:137
virtual TrajectoryContainer trajectories(const TrajectorySeed &seed) const
trajectories building starting from a seed
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().

135 {
136  // analyseSeed( seed);
137  /*
138  if (theSharedSeedCheck){
139  TempTrajectoryContainer candidates;
140  if (seedAlreadyUsed(seed,candidates))
141  {
142  //start with those candidates already made before
143  limitedCandidates(candidates,result);
144  //and quit
145  return;
146  }
147  }
148  */
149 
150  buildTrajectories(seed, result,nullptr);
151 }
TempTrajectory buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
tuple result
Definition: query.py:137
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().

256 {
257  TSOS predictedState = tm.predictedState();
258  TM::ConstRecHitPointer hit = tm.recHit();
259 
260  if ( hit->isValid()) {
261  TM tmp = TM( predictedState, theUpdator->update( predictedState, *hit),
262  hit, tm.estimate(), tm.layer());
263  traj.push(tmp );
264  }
265  else {
266  traj.push( TM( predictedState, hit, 0, tm.layer()));
267  }
268 }
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const =0
const TrajectoryStateUpdator * theUpdator
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void push(const TrajectoryMeasurement &tm)

Member Data Documentation

bool CkfTrajectoryBuilder::theAlwaysUseInvalidHits
protected

Definition at line 77 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

bool CkfTrajectoryBuilder::theIntermediateCleaning
protected

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

Definition at line 75 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

float CkfTrajectoryBuilder::theLostHitPenalty
protected

Chi**2 Penalty for each lost hit.

Definition at line 74 of file CkfTrajectoryBuilder.h.

Referenced by CkfTrajectoryBuilder(), and limitedCandidates().

int CkfTrajectoryBuilder::theMaxCand
protected

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().