CMS 3D CMS Logo

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

#include <GroupedCkfTrajectoryBuilder.h>

Inheritance diagram for GroupedCkfTrajectoryBuilder:
BaseCkfTrajectoryBuilder TrajectoryBuilder

Public Member Functions

double chiSquareCut ()
 
const
Chi2MeasurementEstimatorBase
estimator () const
 
 GroupedCkfTrajectoryBuilder (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)
 constructor from ParameterSet More...
 
float lostHitPenalty ()
 
double mass ()
 Mass hypothesis used for propagation. More...
 
int maxCand ()
 
double ptCut ()
 Pt cut. More...
 
void rebuildSeedingRegion (const TrajectorySeed &, TrajectoryContainer &result) const
 
TrajectoryContainer trajectories (const TrajectorySeed &) const
 set Event for the internal MeasurementTracker data member More...
 
void trajectories (const TrajectorySeed &, TrajectoryContainer &ret) const
 trajectories building starting from a seed, return in an already allocated vector More...
 
TrajectoryContainer trajectories (const TrajectorySeed &, const TrackingRegion &) const
 trajectories building starting from a seed with a region More...
 
void trajectories (const TrajectorySeed &, TrajectoryContainer &ret, const TrackingRegion &) const
 trajectories building starting from a seed with a region More...
 
const TrajectoryStateUpdatorupdator () const
 
virtual ~GroupedCkfTrajectoryBuilder ()
 destructor More...
 
- 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 ~TrajectoryBuilder ()
 

Protected Member Functions

virtual void analyseMeasurements (const std::vector< TM > &meas, const Trajectory &traj) const
 
virtual void analyseResult (const TrajectoryContainer &result) const
 
virtual void analyseSeed (const TrajectorySeed &seed) const
 
- Protected Member Functions inherited from BaseCkfTrajectoryBuilder
void addToResult (TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
 
void addToResult (TempTrajectory &traj, TempTrajectoryContainer &result, bool inOut=false) const
 
virtual bool analyzeMeasurementsDebugger (Trajectory &traj, std::vector< TrajectoryMeasurement > meas, const MeasurementTracker *theMeasurementTracker, const Propagator *theForwardPropagator, const Chi2MeasurementEstimatorBase *theEstimator, const TransientTrackingRecHitBuilder *theTTRHBuilder) const
 
virtual bool analyzeMeasurementsDebugger (TempTrajectory &traj, 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 TempTrajectory &traj) const
 
bool qualityFilter (const TempTrajectory &traj, bool inOut=false) const
 
bool toBeContinued (TempTrajectory &traj, bool inOut=false) const
 

Private Types

enum  work_MaxSize_Size_ { work_MaxSize_ = 50 }
 

Private Member Functions

bool advanceOneLayer (TempTrajectory &traj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &newCand, TempTrajectoryContainer &result) const
 
void backwardFit (TempTrajectory &candidate, unsigned int nSeed, const TrajectoryFitter &fitter, TempTrajectoryContainer &fittedTracks, std::vector< const TrackingRecHit * > &remainingHits) const
 
void buildTrajectories (const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
 common part of both public trajectory building methods More...
 
 GroupedCkfTrajectoryBuilder (const GroupedCkfTrajectoryBuilder &)
 no copy constructor More...
 
void groupedIntermediaryClean (TempTrajectoryContainer &theTrajectories) const
 intermediate cleaning in the case of grouped measurements More...
 
void groupedLimitedCandidates (TempTrajectory &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const
 
void layers (const TempTrajectory::DataContainer &measurements, std::vector< const DetLayer * > &fillme) const
 
GroupedCkfTrajectoryBuilderoperator= (const GroupedCkfTrajectoryBuilder &)
 no assignment operator More...
 
PropagationDirection oppositeDirection (PropagationDirection dir) const
 change of propagation direction More...
 
void rebuildSeedingRegion (TempTrajectory &startingTraj, TempTrajectoryContainer &result) const
 try to find additional hits in seeding region More...
 
int rebuildSeedingRegion (const std::vector< const TrackingRecHit * > &seedHits, TempTrajectory &candidate, TempTrajectoryContainer &result) const
 
bool tkxor (bool a, bool b) const
 
bool verifyHits (TempTrajectory::DataContainer::const_iterator rbegin, size_t maxDepth, const std::vector< const TrackingRecHit * > &hits) const
 Verifies presence of a RecHits in a range of TrajectoryMeasurements. More...
 

Private Attributes

float maxDPhiForLooperReconstruction
 
float maxPtForLooperReconstruction
 
bool theAlwaysUseInvalid
 
bool theBestHitOnly
 
double theChiSquareCut
 
TrajectoryFiltertheConfigurableCondition
 
float theFoundHitBonus
 
bool theIntermediateCleaning
 
bool theLockHits
 
float theLostHitPenalty
 
double theMass
 
int theMaxCand
 
unsigned int theMinNrOf2dHitsForRebuild
 
unsigned int theMinNrOfHitsForRebuild
 
double theptCut
 
bool theRequireSeedHitsInRebuild
 
TempTrajectoryContainer work_
 

Additional Inherited Members

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

Detailed Description

A highly configurable trajectory builder that allows full exploration of the combinatorial tree of possible continuations, and provides efficient ways of trimming the combinatorial tree.

Definition at line 24 of file GroupedCkfTrajectoryBuilder.h.

Member Enumeration Documentation

Enumerator
work_MaxSize_ 

Definition at line 205 of file GroupedCkfTrajectoryBuilder.h.

205 { work_MaxSize_ = 50 }; // if it grows above this number, it is forced to resize to half this amount when cleared

Constructor & Destructor Documentation

GroupedCkfTrajectoryBuilder::GroupedCkfTrajectoryBuilder ( 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 
)

constructor from ParameterSet

Definition at line 67 of file GroupedCkfTrajectoryBuilder.cc.

References edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), max(), maxDPhiForLooperReconstruction, maxPtForLooperReconstruction, theAlwaysUseInvalid, theBestHitOnly, theFoundHitBonus, theIntermediateCleaning, theLockHits, theLostHitPenalty, theMaxCand, theMinNrOf2dHitsForRebuild, theMinNrOfHitsForRebuild, and theRequireSeedHitsInRebuild.

75  :
76 
77 
79  updator, propagatorAlong,propagatorOpposite,
80  estimator, recHitBuilder, measurementTracker, filter, inOutFilter)
81 {
82  // fill data members from parameters (eventually data members could be dropped)
83  //
84  theMaxCand = conf.getParameter<int>("maxCand");
85 
86  theLostHitPenalty = conf.getParameter<double>("lostHitPenalty");
87  theFoundHitBonus = conf.getParameter<double>("foundHitBonus");
88  theIntermediateCleaning = conf.getParameter<bool>("intermediateCleaning");
89  theAlwaysUseInvalid = conf.getParameter<bool>("alwaysUseInvalidHits");
90  theLockHits = conf.getParameter<bool>("lockHits");
91  theBestHitOnly = conf.getParameter<bool>("bestHitOnly");
93  theRequireSeedHitsInRebuild = conf.getParameter<bool>("requireSeedHitsInRebuild");
94  theMinNrOfHitsForRebuild = max(0,conf.getParameter<int>("minNrOfHitsForRebuild"));
95  maxPtForLooperReconstruction = conf.existsAs<double>("maxPtForLooperReconstruction") ?
96  conf.getParameter<double>("maxPtForLooperReconstruction") : 0;
97  maxDPhiForLooperReconstruction = conf.existsAs<double>("maxDPhiForLooperReconstruction") ?
98  conf.getParameter<double>("maxDPhiForLooperReconstruction") : 2.0;
99 
100 
101  /* ======= B.M. to be ported layer ===========
102  bool setOK = thePropagator->setMaxDirectionChange(1.6);
103  if (!setOK)
104  cout << "GroupedCkfTrajectoryBuilder WARNING: "
105  << "propagator does not support setMaxDirectionChange"
106  << endl;
107  // addStopCondition(theMinPtStopCondition);
108 
109  theConfigurableCondition = createAlgo<TrajectoryFilter>(componentConfig("StopCondition"));
110  ===================================== */
111 
112 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:187
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)
const T & max(const T &a, const T &b)
virtual GroupedCkfTrajectoryBuilder::~GroupedCkfTrajectoryBuilder ( )
inlinevirtual

destructor

Definition at line 39 of file GroupedCkfTrajectoryBuilder.h.

39 {}
GroupedCkfTrajectoryBuilder::GroupedCkfTrajectoryBuilder ( const GroupedCkfTrajectoryBuilder )
private

no copy constructor

Member Function Documentation

bool GroupedCkfTrajectoryBuilder::advanceOneLayer ( TempTrajectory traj,
const TrajectoryFilter regionalCondition,
const Propagator propagator,
bool  inOut,
TempTrajectoryContainer newCand,
TempTrajectoryContainer result 
) const
private

Definition at line 349 of file GroupedCkfTrajectoryBuilder.cc.

References BaseCkfTrajectoryBuilder::addToResult(), BoundSurface::bounds(), TransverseImpactPointExtrapolator::extrapolate(), BaseCkfTrajectoryBuilder::findStateAndLayers(), TempTrajectory::foundHits(), cmsutils::bqueue< T >::front(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TempTrajectory::incrementLoops(), TrajectoryStateOnSurface::isValid(), TempTrajectory::lastLayer(), Bounds::length(), DetLayer::location(), LogDebug, maxDPhiForLooperReconstruction, maxPtForLooperReconstruction, TempTrajectory::measurements(), TrackingRecHit::missing, PV3DBase< T, PVType, FrameType >::phi(), Propagator::propagationDirection(), TempTrajectory::push(), cmsutils::bqueue< T >::rbegin(), TrajectoryMeasurement::recHit(), cmsutils::bqueue< T >::rend(), TrajectorySegmentBuilder::segments(), TempTrajectory::setDPhiCacheForLoopersReconstruction(), cmsutils::bqueue< T >::size(), BarrelDetLayer::specificSurface(), filterCSVwithJSON::target, theAlwaysUseInvalid, theBestHitOnly, BaseCkfTrajectoryBuilder::theEstimator, BaseCkfTrajectoryBuilder::theForwardPropagator, BaseCkfTrajectoryBuilder::theLayerMeasurements, theLockHits, theMaxCand, BaseCkfTrajectoryBuilder::theMeasurementTracker, BaseCkfTrajectoryBuilder::theUpdator, BaseCkfTrajectoryBuilder::toBeContinued(), TrajectoryStateOnSurface::transverseCurvature(), whatIsTheStateToUse(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by groupedLimitedCandidates().

355 {
356  std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers = findStateAndLayers(traj);
358  if(
359  //stateAndLayers.second.size()==0 &&
360  traj.lastLayer()->location()==0 &&
361  stateAndLayers.first.globalMomentum().perp()<maxPtForLooperReconstruction &&
362  stateAndLayers.first.globalMomentum().perp()>0.3)
363  stateAndLayers.second.push_back(traj.lastLayer());
364  }
365 
366  vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
367  vector<const DetLayer*>::iterator layerEnd = stateAndLayers.second.end();
368 
369  // if (nl.empty()) {
370  // addToResult(traj,result,inOut);
371  // return false;
372  // }
373 
374  LogDebug("CkfPattern")<<whatIsTheNextStep(traj, stateAndLayers);
375 
376  bool foundSegments(false);
377  bool foundNewCandidates(false);
378  for ( vector<const DetLayer*>::iterator il=layerBegin;
379  il!=layerEnd; il++) {
380 
381  TSOS stateToUse = stateAndLayers.first;
382 
383  double dPhiCacheForLoopersReconstruction(0);
384  if ((*il)==traj.lastLayer()){
386  // ------ For loopers reconstruction
387  //cout<<" self propagating in advanceOneLayer (for loopers) \n";
388  const BarrelDetLayer* sbdl = dynamic_cast<const BarrelDetLayer*>(traj.lastLayer());
389  if(sbdl){
390  HelixBarrelCylinderCrossing cylinderCrossing(stateToUse.globalPosition(),
391  stateToUse.globalMomentum(),
392  stateToUse.transverseCurvature(),
393  propagator->propagationDirection(),
394  sbdl->specificSurface());
395  if(!cylinderCrossing.hasSolution()) continue;
396  GlobalPoint starting = stateToUse.globalPosition();
397  GlobalPoint target1 = cylinderCrossing.position1();
398  GlobalPoint target2 = cylinderCrossing.position2();
399 
400  GlobalPoint farther = fabs(starting.phi()-target1.phi()) > fabs(starting.phi()-target2.phi()) ?
401  target1 : target2;
402 
403  const Bounds& bounds( sbdl->specificSurface().bounds());
404  float length = bounds.length() / 2.f;
405 
406  /*
407  cout << "starting: " << starting << endl;
408  cout << "target1: " << target1 << endl;
409  cout << "target2: " << target2 << endl;
410  cout << "dphi: " << (target1.phi()-target2.phi()) << endl;
411  cout << "length: " << length << endl;
412  */
413 
414  /*
415  float deltaZ = bounds.thickness()/2.f/fabs(tan(stateToUse.globalDirection().theta()) ) ;
416  if(stateToUse.hasError())
417  deltaZ += 3*sqrt(stateToUse.cartesianError().position().czz());
418  if( fabs(farther.z()) > length + deltaZ ) continue;
419  */
420  if(fabs(farther.z())*0.95>length) continue;
421 
422  Geom::Phi<double> tmpDphi = target1.phi()-target2.phi();
423  if(fabs(tmpDphi)>maxDPhiForLooperReconstruction) continue;
424  GlobalPoint target((target1.x()+target2.x())/2,
425  (target1.y()+target2.y())/2,
426  (target1.z()+target2.z())/2);
427 
428  //cout << "target: " << target << endl;
429 
430 
431 
433  stateToUse = extrapolator.extrapolate(stateToUse, target, *propagator);
434  if (!stateToUse.isValid()) continue; //SK: consider trying the original? probably not
435 
436  //dPhiCacheForLoopersReconstruction = fabs(target1.phi()-target2.phi())*2.;
437  dPhiCacheForLoopersReconstruction = fabs(tmpDphi);
438  traj.incrementLoops();
439  }else{
440  continue;
441  }
442  }else{
443  // ------ For cosmics reconstruction
444  LogDebug("CkfPattern")<<" self propagating in advanceOneLayer.\n from: \n"<<stateToUse;
445  //self navigation case
446  // go to a middle point first
448  GlobalPoint center(0,0,0);
449  stateToUse = middle.extrapolate(stateToUse, center, *theForwardPropagator);
450 
451  if (!stateToUse.isValid()) continue;
452  LogDebug("CkfPattern")<<"to: "<<stateToUse;
453  }
454  }
455 
456  unsigned int maxCandidates = theMaxCand > 21 ? theMaxCand*2 : 42; //limit the number of returned segments
459  **il,*propagator,
461  theLockHits,theBestHitOnly, maxCandidates);
462 
463  LogDebug("CkfPattern")<<whatIsTheStateToUse(stateAndLayers.first,stateToUse,*il);
464 
465  TempTrajectoryContainer segments=
466  layerBuilder.segments(stateToUse);
467 
468  LogDebug("CkfPattern")<< "GCTB: number of segments = " << segments.size();
469 
470  if ( !segments.empty() ) foundSegments = true;
471 
472  for ( TempTrajectoryContainer::const_iterator is=segments.begin();
473  is!=segments.end(); is++ ) {
474  //
475  // assume "invalid hit only" segment is last in list
476  //
477  const TempTrajectory::DataContainer & measurements = is->measurements();
478  if ( !theAlwaysUseInvalid && is!=segments.begin() && measurements.size()==1 &&
479  (measurements.front().recHit()->getType() == TrackingRecHit::missing) ) break;
480  //
481  // create new candidate
482  //
483  TempTrajectory newTraj(traj);
484  traj.setDPhiCacheForLoopersReconstruction(dPhiCacheForLoopersReconstruction);
485 
486  //---- avoid to add the same hits more than once in the trajectory ----
487  bool toBeRejected(false);
488  for(const TempTrajectory::DataContainer::const_iterator revIt = measurements.rbegin();
489  revIt!=measurements.rend(); --revIt){
490  int tmpCounter(0);
491  for(const TempTrajectory::DataContainer::const_iterator newTrajMeasIt = newTraj.measurements().rbegin();
492  newTrajMeasIt != newTraj.measurements().rend(); --newTrajMeasIt){
493  //if(tmpCounter==2) break;
494  if(revIt->recHit()->geographicalId()==newTrajMeasIt->recHit()->geographicalId()){
495  toBeRejected=true;
496  break;
497  }
498  tmpCounter++;
499  }
500  }
501 
502  if(!toBeRejected){
503  //newTraj.push(*is);
504  //std::cout << "DEBUG: newTraj after push found,lost: "
505  // << newTraj.foundHits() << " , "
506  // << newTraj.lostHits() << " , "
507  // << newTraj.measurements().size() << std::endl;
508  }else{
509  /*cout << "WARNING: neglect candidate because it contains the same hit twice \n";
510  cout << "-- discarded track's pt,eta,#found: "
511  << newTraj.lastMeasurement().updatedState().globalMomentum().perp() << " , "
512  << newTraj.lastMeasurement().updatedState().globalMomentum().eta() << " , "
513  << newTraj.foundHits() << "\n";
514  */
515  continue; //Are we sure about this????
516  }
517  // ------------------------
518 
519 
520  newTraj.push(*is);
521  //GIO// for ( vector<TM>::const_iterator im=measurements.begin();
522  //GIO// im!=measurements.end(); im++ ) newTraj.push(*im);
523  //if ( toBeContinued(newTraj,regionalCondition) ) { TOBE FIXED
524  if ( toBeContinued(newTraj, inOut) ) {
525  // Have added one more hit to track candidate
526 
527  LogDebug("CkfPattern")<<"GCTB: adding updated trajectory to candidates: inOut="<<inOut<<" hits="<<newTraj.foundHits();
528 
529  newCand.push_back(newTraj);
530  foundNewCandidates = true;
531  }
532  else {
533  // Have finished building this track. Check if it passes cuts.
534 
535  LogDebug("CkfPattern")<< "GCTB: adding completed trajectory to results if passes cuts: inOut="<<inOut<<" hits="<<newTraj.foundHits();
536 
537  addToResult(newTraj, result, inOut);
538  }
539  }
540  }
541 
542  if ( !foundSegments ){
543  LogDebug("CkfPattern")<< "GCTB: adding input trajectory to result";
544  addToResult(traj, result, inOut);
545  }
546  return foundNewCandidates;
547 }
const_iterator rend() const
Definition: bqueue.h:145
virtual float length() const =0
virtual PropagationDirection propagationDirection() const
Definition: Propagator.h:143
virtual Location location() const =0
Which part of the detector (barrel, endcap)
void addToResult(TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
const TrajectoryStateUpdator * theUpdator
GlobalPoint globalPosition() const
ConstRecHitPointer recHit() const
const LayerMeasurements * theLayerMeasurements
void setDPhiCacheForLoopersReconstruction(float dphi)
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
std::string whatIsTheStateToUse(TrajectoryStateOnSurface &initial, TrajectoryStateOnSurface &stateToUse, const DetLayer *l)
const Bounds & bounds() const
Definition: BoundSurface.h:89
const MeasurementTracker * theMeasurementTracker
std::vector< TempTrajectory > TempTrajectoryContainer
iterator rbegin()
Definition: bqueue.h:143
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
GlobalVector globalMomentum() const
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
#define LogDebug(id)
StateAndLayers findStateAndLayers(const TempTrajectory &traj) const
size_type size() const
Definition: bqueue.h:146
Definition: Bounds.h:18
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
T x() const
Definition: PV3DBase.h:61
Definition: Phi.h:20
const Chi2MeasurementEstimatorBase * theEstimator
const Propagator * theForwardPropagator
virtual void GroupedCkfTrajectoryBuilder::analyseMeasurements ( const std::vector< TM > &  meas,
const Trajectory traj 
) const
inlineprotectedvirtual

Definition at line 94 of file GroupedCkfTrajectoryBuilder.h.

95  {}
virtual void GroupedCkfTrajectoryBuilder::analyseResult ( const TrajectoryContainer result) const
inlineprotectedvirtual

Definition at line 96 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().

96 {}
virtual void GroupedCkfTrajectoryBuilder::analyseSeed ( const TrajectorySeed seed) const
inlineprotectedvirtual

Definition at line 92 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().

92 {}
void GroupedCkfTrajectoryBuilder::backwardFit ( TempTrajectory candidate,
unsigned int  nSeed,
const TrajectoryFitter fitter,
TempTrajectoryContainer fittedTracks,
std::vector< const TrackingRecHit * > &  remainingHits 
) const
private

Definition at line 872 of file GroupedCkfTrajectoryBuilder.cc.

References Trajectory::direction(), TempTrajectory::direction(), PrintoutHelper::dumpMeasurement(), PrintoutHelper::dumpMeasurements(), Trajectory::firstMeasurement(), TrajectoryFitter::fit(), TempTrajectory::foundHits(), TrackingRecHit::isValid(), LogDebug, max(), TempTrajectory::measurements(), TempTrajectory::nLoops(), Trajectory::nLoops(), oppositeDirection(), Trajectory::push(), Trajectory::recHits(), TrajectoryStateOnSurface::rescaleError(), Trajectory::seed(), TempTrajectory::seed(), TempTrajectory::setNLoops(), Trajectory::setNLoops(), cmsutils::bqueue< T >::size(), theMinNrOfHitsForRebuild, and TrajectoryMeasurement::updatedState().

Referenced by rebuildSeedingRegion().

876 {
877  //
878  // clear array of non-fitted hits
879  //
880  remainingHits.clear();
881  fittedTracks.clear();
882  //
883  // skip candidates which are not exceeding the seed size
884  // (e.g. Because no Tracker layers exist outside seeding region)
885  //
886  if ( candidate.measurements().size()<=nSeed ) {
887  fittedTracks.clear();
888  return;
889  }
890 
891  LogDebug("CkfPattern")<<"nSeed " << nSeed << endl
892  << "Old traj direction = " << candidate.direction() << endl
894 
895  //
896  // backward fit trajectory.
897  // (Will try to fit only hits outside the seeding region. However,
898  // if there are not enough of these, it will also use the seeding hits).
899  //
900  TempTrajectory::DataContainer oldMeasurements(candidate.measurements());
901 // int nOld(oldMeasurements.size());
902 // const unsigned int nHitAllMin(5);
903 // const unsigned int nHit2dMin(2);
904  unsigned int nHit(0); // number of valid hits after seeding region
905  //unsigned int nHit2d(0); // number of valid hits after seeding region with 2D info
906  // use all hits except the first n (from seed), but require minimum
907  // specified in configuration.
908  // Swapped over next two lines.
909  unsigned int nHitMin = max(candidate.foundHits()-nSeed,theMinNrOfHitsForRebuild);
910  // unsigned int nHitMin = oldMeasurements.size()-nSeed;
911  // we want to rebuild only if the number of VALID measurements excluding the seed measurements is higher than the cut
912  if (nHitMin<theMinNrOfHitsForRebuild){
913  fittedTracks.clear();
914  return;
915  }
916 
917  LogDebug("CkfPattern")/* << "nHitMin " << nHitMin*/ <<"Sizes: " << oldMeasurements.size() << " / ";
918  //
919  // create input trajectory for backward fit
920  //
921  Trajectory fwdTraj(candidate.seed(),oppositeDirection(candidate.direction()));
922  fwdTraj.setNLoops(candidate.nLoops());
923  //const TrajectorySeed seed = TrajectorySeed(PTrajectoryStateOnDet(), TrajectorySeed::recHitContainer(), oppositeDirection(candidate.direction()));
924  //Trajectory fwdTraj(seed, oppositeDirection(candidate.direction()));
925  std::vector<const DetLayer*> bwdDetLayer;
926  for ( TempTrajectory::DataContainer::const_iterator im=oldMeasurements.rbegin();
927  im!=oldMeasurements.rend(); --im) {
928  const TrackingRecHit* hit = im->recHit()->hit();
929  //
930  // add hits until required number is reached
931  //
932  if ( nHit<nHitMin ){//|| nHit2d<theMinNrOf2dHitsForRebuild ) {
933  fwdTraj.push(*im);
934  bwdDetLayer.push_back(im->layer());
935  //
936  // count valid / 2D hits
937  //
938  if ( hit->isValid() ) {
939  nHit++;
940  //if ( hit.isMatched() ||
941  // hit.det().detUnits().front()->type().module()==pixel )
942  //nHit2d++;
943  }
944  }
945  //if (nHit==nHitMin) lastBwdDetLayer=im->layer();
946  //
947  // keep remaining (valid) hits for verification
948  //
949  else if ( hit->isValid() ) {
950  //std::cout << "Adding a remaining hit" << std::endl;
951  remainingHits.push_back(hit);
952  }
953  }
954  //
955  // Fit only if required number of valid hits can be used
956  //
957  if ( nHit<nHitMin ){ //|| nHit2d<theMinNrOf2dHitsForRebuild ) {
958  fittedTracks.clear();
959  return;
960  }
961  //
962  // Do the backward fit (important: start from scaled, not random cov. matrix!)
963  //
964  TrajectoryStateOnSurface firstTsos(fwdTraj.firstMeasurement().updatedState());
965  //cout << "firstTsos "<< firstTsos << endl;
966  firstTsos.rescaleError(10.);
967  //TrajectoryContainer bwdFitted(fitter.fit(fwdTraj.seed(),fwdTraj.recHits(),firstTsos));
968  TrajectoryContainer bwdFitted(fitter.fit(
970  fwdTraj.recHits(),firstTsos));
971  if (bwdFitted.size()){
972  LogDebug("CkfPattern")<<"Obtained " << bwdFitted.size() << " bwdFitted trajectories with measurement size " << bwdFitted.front().measurements().size();
973  TempTrajectory fitted(fwdTraj.seed(), fwdTraj.direction());
974  fitted.setNLoops(fwdTraj.nLoops());
975  vector<TM> tmsbf = bwdFitted.front().measurements();
976  int iDetLayer=0;
977  //this is ugly but the TM in the fitted track do not contain the DetLayer.
978  //So we have to cache the detLayer pointers and replug them in.
979  //For the backward building it would be enaugh to cache the last DetLayer,
980  //but for the intermediary cleaning we need all
981  for ( vector<TM>::const_iterator im=tmsbf.begin();im!=tmsbf.end(); im++ ) {
982  fitted.push(TM( (*im).forwardPredictedState(),
983  (*im).backwardPredictedState(),
984  (*im).updatedState(),
985  (*im).recHit(),
986  (*im).estimate(),
987  bwdDetLayer[iDetLayer]));
988 
989  LogDebug("CkfPattern")<<PrintoutHelper::dumpMeasurement(*im);
990  iDetLayer++;
991  }
992 /*
993  TM lastMeas = bwdFitted.front().lastMeasurement();
994  fitted.pop();
995  fitted.push(TM(lastMeas.forwardPredictedState(),
996  lastMeas.backwardPredictedState(),
997  lastMeas.updatedState(),
998  lastMeas.recHit(),
999  lastMeas.estimate(),
1000  lastBwdDetLayer));*/
1001  fittedTracks.push_back(fitted);
1002  }
1003  //
1004  // save result
1005  //
1006  //fittedTracks.swap(bwdFitted);
1007  //cout << "Obtained " << fittedTracks.size() << " fittedTracks trajectories with measurement size " << fittedTracks.front().measurements().size() << endl;
1008 }
const TrajectorySeed & seed() const
Access to the seed used to reconstruct the Trajectory.
PropagationDirection oppositeDirection(PropagationDirection dir) const
change of propagation direction
const DataContainer & measurements() const
void setNLoops(signed char value)
int foundHits() const
obsolete name, use measurements() instead.
static std::string dumpMeasurement(const TrajectoryMeasurement &tm)
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
PropagationDirection direction() const
const T & max(const T &a, const T &b)
range recHits() const
bool isValid() const
virtual std::vector< Trajectory > fit(const Trajectory &) const =0
#define LogDebug(id)
size_type size() const
Definition: bqueue.h:146
signed char nLoops() const
std::vector< Trajectory > TrajectoryContainer
void GroupedCkfTrajectoryBuilder::buildTrajectories ( const TrajectorySeed seed,
GroupedCkfTrajectoryBuilder::TrajectoryContainer result,
const TrajectoryFilter regionalCondition 
) const
private

common part of both public trajectory building methods

Definition at line 183 of file GroupedCkfTrajectoryBuilder.cc.

References analyseResult(), analyseSeed(), BaseCkfTrajectoryBuilder::createStartingTrajectory(), groupedLimitedCandidates(), LogDebug, BaseCkfTrajectoryBuilder::theForwardPropagator, work_, and work_MaxSize_.

Referenced by trajectories().

186 {
187  //
188  // Build trajectory outwards from seed
189  //
190 
191  analyseSeed( seed);
192 
193  TempTrajectory startingTraj = createStartingTrajectory( seed);
194 
195  work_.clear();
196  const bool inOut = true;
197  groupedLimitedCandidates( startingTraj, regionalCondition, theForwardPropagator, inOut, work_);
198  if ( work_.empty() ) return ;
199 
200 
201 
202  /* rebuilding is de-coupled from standard building
203  //
204  // try to additional hits in the seeding region
205  //
206  if ( theMinNrOfHitsForRebuild>0 ) {
207  // reverse direction
208  //thePropagator->setPropagationDirection(oppositeDirection(seed.direction()));
209  // rebuild part of the trajectory
210  rebuildSeedingRegion(startingTraj,work);
211  }
212 
213  */
214 
215  result.reserve(work_.size());
216  for (TempTrajectoryContainer::const_iterator it = work_.begin(), ed = work_.end(); it != ed; ++it) {
217  result.push_back( it->toTrajectory() );
218  }
219 
220  work_.clear();
221  if (work_.capacity() > work_MaxSize_) { TempTrajectoryContainer().swap(work_); work_.reserve(work_MaxSize_/2); }
222 
224 
225  LogDebug("CkfPattern")<< "GroupedCkfTrajectoryBuilder: returning result of size " << result.size();
226 
227 }
virtual void analyseSeed(const TrajectorySeed &seed) const
virtual void analyseResult(const TrajectoryContainer &result) const
void groupedLimitedCandidates(TempTrajectory &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const
tuple result
Definition: query.py:137
std::vector< TempTrajectory > TempTrajectoryContainer
#define LogDebug(id)
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
const Propagator * theForwardPropagator
double GroupedCkfTrajectoryBuilder::chiSquareCut ( )
inline

Chi**2 Cut on the new Trajectory Measurements to consider

Definition at line 72 of file GroupedCkfTrajectoryBuilder.h.

References theChiSquareCut.

const Chi2MeasurementEstimatorBase& GroupedCkfTrajectoryBuilder::estimator ( void  ) const
inline

Definition at line 67 of file GroupedCkfTrajectoryBuilder.h.

References BaseCkfTrajectoryBuilder::theEstimator.

Referenced by rebuildSeedingRegion().

67 {return *theEstimator;}
const Chi2MeasurementEstimatorBase * theEstimator
void GroupedCkfTrajectoryBuilder::groupedIntermediaryClean ( TempTrajectoryContainer theTrajectories) const
private

intermediate cleaning in the case of grouped measurements

im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::all) ) {

im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::all) ) {

Definition at line 551 of file GroupedCkfTrajectoryBuilder.cc.

References ecalTPGAnalyzer_cfg::firstValid, TempTrajectory::isValid(), layers(), cmsutils::bqueue< T >::rbegin(), cmsutils::bqueue< T >::rend(), TrackingRecHit::some, and tkxor().

Referenced by groupedLimitedCandidates().

552 {
553  //if (theTrajectories.empty()) return TrajectoryContainer();
554  //TrajectoryContainer result;
555  if (theTrajectories.empty()) return;
556  //RecHitEqualByChannels recHitEqualByChannels(false, false);
557  int firstLayerSize, secondLayerSize;
558  vector<const DetLayer*> firstLayers, secondLayers;
559 
560  for (TempTrajectoryContainer::iterator firstTraj=theTrajectories.begin();
561  firstTraj!=(theTrajectories.end()-1); firstTraj++) {
562 
563  if ( (!firstTraj->isValid()) ||
564  (!firstTraj->lastMeasurement().recHit()->isValid()) ) continue;
565  const TempTrajectory::DataContainer & firstMeasurements = firstTraj->measurements();
566  layers(firstMeasurements, firstLayers);
567  firstLayerSize = firstLayers.size();
568  if ( firstLayerSize<4 ) continue;
569 
570  for (TempTrajectoryContainer::iterator secondTraj=(firstTraj+1);
571  secondTraj!=theTrajectories.end(); secondTraj++) {
572 
573  if ( (!secondTraj->isValid()) ||
574  (!secondTraj->lastMeasurement().recHit()->isValid()) ) continue;
575  const TempTrajectory::DataContainer & secondMeasurements = secondTraj->measurements();
576  layers(secondMeasurements, secondLayers);
577  secondLayerSize = secondLayers.size();
578  //
579  // only candidates using the same last 3 layers are compared
580  //
581  if ( firstLayerSize!=secondLayerSize ) continue;
582  if ( firstLayers[0]!=secondLayers[0] ||
583  firstLayers[1]!=secondLayers[1] ||
584  firstLayers[2]!=secondLayers[2] ) continue;
585 
586  TempTrajectory::DataContainer::const_iterator im1 = firstMeasurements.rbegin();
587  TempTrajectory::DataContainer::const_iterator im2 = secondMeasurements.rbegin();
588  //
589  // check for identical hits in the last layer
590  //
591  bool unequal(false);
592  const DetLayer* layerPtr = firstLayers[0];
593  while ( im1!=firstMeasurements.rend()&&im2!=secondMeasurements.rend() ) {
594  if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr ) break;
595  if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
596  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some) ) {
598  unequal = true;
599  break;
600  }
601  --im1;
602  --im2;
603  }
604  if ( im1==firstMeasurements.rend() || im2==secondMeasurements.rend() ||
605  im1->layer()==layerPtr || im2->layer()==layerPtr || unequal ) continue;
606  //
607  // check for invalid hits in the layer -2
608  // compare only candidates with invalid / valid combination
609  //
610  layerPtr = firstLayers[1];
611  bool firstValid(true);
612  while ( im1!=firstMeasurements.rend()&&im1->layer()==layerPtr ) {
613  if ( !im1->recHit()->isValid() ) firstValid = false;
614  --im1;
615  }
616  bool secondValid(true);
617  while ( im2!=secondMeasurements.rend()&&im2->layer()==layerPtr ) {
618  if ( !im2->recHit()->isValid() ) secondValid = false;
619  --im2;
620  }
621  if ( !tkxor(firstValid,secondValid) ) continue;
622  //
623  // ask for identical hits in layer -3
624  //
625  unequal = false;
626  layerPtr = firstLayers[2];
627  while ( im1!=firstMeasurements.rend()&&im2!=secondMeasurements.rend() ) {
628  if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr ) break;
629  if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
630  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some) ) {
632  unequal = true;
633  break;
634  }
635  --im1;
636  --im2;
637  }
638  if ( im1==firstMeasurements.rend() || im2==secondMeasurements.rend() ||
639  im1->layer()==layerPtr || im2->layer()==layerPtr || unequal ) continue;
640 
641  if ( !firstValid ) {
642  firstTraj->invalidate();
643  break;
644  }
645  else {
646  secondTraj->invalidate();
647  break;
648  }
649  }
650  }
651 /*
652  for (TempTrajectoryContainer::const_iterator it = theTrajectories.begin();
653  it != theTrajectories.end(); it++) {
654  if(it->isValid()) result.push_back( *it);
655  }
656 
657  return result;
658 */
659  theTrajectories.erase(std::remove_if( theTrajectories.begin(),theTrajectories.end(),
660  std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
661  // boost::bind(&TempTrajectory::isValid,_1)),
662  theTrajectories.end());
663 }
const_iterator rend() const
Definition: bqueue.h:145
bool isValid() const
iterator rbegin()
Definition: bqueue.h:143
bool tkxor(bool a, bool b) const
void layers(const TempTrajectory::DataContainer &measurements, std::vector< const DetLayer * > &fillme) const
void GroupedCkfTrajectoryBuilder::groupedLimitedCandidates ( TempTrajectory startingTraj,
const TrajectoryFilter regionalCondition,
const Propagator propagator,
bool  inOut,
TempTrajectoryContainer result 
) const
private

Definition at line 231 of file GroupedCkfTrajectoryBuilder.cc.

References advanceOneLayer(), IntermediateTrajectoryCleaner::clean(), PrintoutHelper::dumpCandidates(), groupedIntermediaryClean(), LogDebug, python.multivaluedict::sort(), theFoundHitBonus, theIntermediateCleaning, theLostHitPenalty, and theMaxCand.

Referenced by buildTrajectories(), and rebuildSeedingRegion().

236 {
237  unsigned int nIter=1;
238  TempTrajectoryContainer candidates;
239  TempTrajectoryContainer newCand;
240  candidates.push_back( startingTraj);
241 
242  while ( !candidates.empty()) {
243 
244  newCand.clear();
245  for (TempTrajectoryContainer::iterator traj=candidates.begin();
246  traj!=candidates.end(); traj++) {
247  if ( !advanceOneLayer(*traj, regionalCondition, propagator, inOut, newCand, result) ) {
248  LogDebug("CkfPattern")<< "GCTB: terminating after advanceOneLayer==false";
249  continue;
250  }
251 
252  LogDebug("CkfPattern")<<"newCand(1): after advanced one layer:\n"<<PrintoutHelper::dumpCandidates(newCand);
253 
254  if ((int)newCand.size() > theMaxCand) {
255  //ShowCand()(newCand);
256 
257  sort( newCand.begin(), newCand.end(), GroupedTrajCandLess(theLostHitPenalty,theFoundHitBonus));
258  newCand.erase( newCand.begin()+theMaxCand, newCand.end());
259  }
260  LogDebug("CkfPattern")<<"newCand(2): after removing extra candidates.\n"<<PrintoutHelper::dumpCandidates(newCand);
261  }
262 
263  LogDebug("CkfPattern") << "newCand.size() at end = " << newCand.size();
264 /*
265  if (theIntermediateCleaning) {
266  candidates.clear();
267  candidates = groupedIntermediaryClean(newCand);
268  } else {
269  candidates.swap(newCand);
270  }
271 */
273 #ifdef STANDARD_INTERMEDIARYCLEAN
275 #else
276  groupedIntermediaryClean(newCand);
277 #endif
278 
279  }
280  candidates.swap(newCand);
281 
282  LogDebug("CkfPattern") <<"candidates(3): "<<result.size()<<" candidates after "<<nIter++<<" groupedCKF iteration: \n"
284  <<"\n "<<candidates.size()<<" running candidates are: \n"
285  <<PrintoutHelper::dumpCandidates(candidates);
286  }
287 }
static std::string dumpCandidates(collection &candidates)
static void clean(TempTrajectoryContainer &tracks)
void groupedIntermediaryClean(TempTrajectoryContainer &theTrajectories) const
intermediate cleaning in the case of grouped measurements
tuple result
Definition: query.py:137
bool advanceOneLayer(TempTrajectory &traj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &newCand, TempTrajectoryContainer &result) const
std::vector< TempTrajectory > TempTrajectoryContainer
#define LogDebug(id)
void GroupedCkfTrajectoryBuilder::layers ( const TempTrajectory::DataContainer measurements,
std::vector< const DetLayer * > &  fillme 
) const
private

fills in a list of layers from a container of TrajectoryMeasurements the "fillme" vector is cleared beforehand.

Definition at line 666 of file GroupedCkfTrajectoryBuilder.cc.

References cmsutils::bqueue< T >::back(), cmsutils::bqueue< T >::empty(), TrajectoryMeasurement::layer(), cmsutils::bqueue< T >::rbegin(), and cmsutils::bqueue< T >::rend().

Referenced by groupedIntermediaryClean().

668 {
669  result.clear();
670 
671  if ( measurements.empty() ) return ;
672 
673  result.push_back(measurements.back().layer());
675  --ifirst;
677  im!=measurements.rend(); --im ) {
678  if ( im->layer()!=result.back() ) result.push_back(im->layer());
679  }
680 
681  for (vector<const DetLayer*>::const_iterator iter = result.begin(); iter != result.end(); iter++){
682  if (!*iter) edm::LogWarning("CkfPattern")<< "Warning: null det layer!! ";
683  }
684 }
const_iterator rend() const
Definition: bqueue.h:145
bool empty() const
Definition: bqueue.h:147
tuple result
Definition: query.py:137
const DetLayer * layer() const
iterator rbegin()
Definition: bqueue.h:143
float GroupedCkfTrajectoryBuilder::lostHitPenalty ( )
inline

Chi**2 Penalty for each lost hit.

Definition at line 79 of file GroupedCkfTrajectoryBuilder.h.

References theLostHitPenalty.

double GroupedCkfTrajectoryBuilder::mass ( )
inline

Mass hypothesis used for propagation.

Definition at line 88 of file GroupedCkfTrajectoryBuilder.h.

References theMass.

int GroupedCkfTrajectoryBuilder::maxCand ( )
inline

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

Definition at line 75 of file GroupedCkfTrajectoryBuilder.h.

References theMaxCand.

GroupedCkfTrajectoryBuilder& GroupedCkfTrajectoryBuilder::operator= ( const GroupedCkfTrajectoryBuilder )
private

no assignment operator

PropagationDirection GroupedCkfTrajectoryBuilder::oppositeDirection ( PropagationDirection  dir) const
inlineprivate

change of propagation direction

Definition at line 158 of file GroupedCkfTrajectoryBuilder.h.

References alongMomentum, dir, and oppositeToMomentum.

Referenced by backwardFit().

158  {
159  if ( dir==alongMomentum ) return oppositeToMomentum;
160  else if ( dir==oppositeToMomentum ) return alongMomentum;
161  return dir;
162  }
dbl *** dir
Definition: mlp_gen.cc:35
double GroupedCkfTrajectoryBuilder::ptCut ( )
inline

Pt cut.

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

Definition at line 85 of file GroupedCkfTrajectoryBuilder.h.

References theptCut.

void GroupedCkfTrajectoryBuilder::rebuildSeedingRegion ( const TrajectorySeed seed,
TrajectoryContainer result 
) const
virtual

trajectories re-building in the seeding region. It looks for additional measurements in the seeding region of the intial trajectories. Only valid trajectories are returned. Invalid ones are dropped from the input collection.

Reimplemented from TrajectoryBuilder.

Definition at line 157 of file GroupedCkfTrajectoryBuilder.cc.

References BaseCkfTrajectoryBuilder::createStartingTrajectory().

Referenced by rebuildSeedingRegion().

158  {
159  TempTrajectory startingTraj = createStartingTrajectory( seed);
161 
162  TrajectoryContainer final;
163 
164  work.reserve(result.size());
165  for (TrajectoryContainer::iterator traj=result.begin();
166  traj!=result.end(); ++traj) {
167  if(traj->isValid()) work.push_back(TempTrajectory(*traj));
168  }
169 
170  rebuildSeedingRegion(startingTraj,work);
171  final.reserve(work.size());
172 
173  for (TempTrajectoryContainer::iterator traj=work.begin();
174  traj!=work.end(); ++traj) {
175  final.push_back(traj->toTrajectory());
176  }
177 
178  result.swap(final);
179 
180 }
tuple result
Definition: query.py:137
void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const
std::vector< TempTrajectory > TempTrajectoryContainer
std::vector< Trajectory > TrajectoryContainer
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
void GroupedCkfTrajectoryBuilder::rebuildSeedingRegion ( TempTrajectory startingTraj,
TempTrajectoryContainer result 
) const
private

try to find additional hits in seeding region

Definition at line 687 of file GroupedCkfTrajectoryBuilder.cc.

References backwardFit(), estimator(), TempTrajectory::isValid(), LogDebug, TempTrajectory::measurements(), rebuildSeedingRegion(), TrajectorySeed::recHits(), TempTrajectory::seed(), cmsutils::bqueue< T >::size(), BaseCkfTrajectoryBuilder::theBackwardPropagator, and updator().

689 {
690  //
691  // Rebuilding of trajectories. Candidates are taken from result,
692  // which will be replaced with the solutions after rebuild
693  // (assume vector::swap is more efficient than building new container)
694  //
695  LogDebug("CkfPattern")<< "Starting to rebuild " << result.size() << " tracks";
696  //
697  // Fitter (need to create it here since the propagation direction
698  // might change between different starting trajectories)
699  //
701  //
702  TempTrajectoryContainer reFitted;
703  TrajectorySeed::range rseedHits = startingTraj.seed().recHits();
704  std::vector<const TrackingRecHit*> seedHits;
705  //seedHits.insert(seedHits.end(), rseedHits.first, rseedHits.second);
706  //for (TrajectorySeed::recHitContainer::const_iterator iter = rseedHits.first; iter != rseedHits.second; iter++){
707  // seedHits.push_back(&*iter);
708  //}
709 
710  //unsigned int nSeed(seedHits.size());
711  unsigned int nSeed(rseedHits.second-rseedHits.first);
712  //seedHits.reserve(nSeed);
713  TempTrajectoryContainer rebuiltTrajectories;
714  for ( TempTrajectoryContainer::iterator it=result.begin();
715  it!=result.end(); it++ ) {
716  //
717  // skip candidates which are not exceeding the seed size
718  // (e.g. because no Tracker layers outside seeding region)
719  //
720 
721  if ( it->measurements().size()<=startingTraj.measurements().size() ) {
722  rebuiltTrajectories.push_back(*it);
723  LogDebug("CkfPattern")<< "RebuildSeedingRegion skipped as in-out trajectory does not exceed seed size.";
724  continue;
725  }
726  //
727  // Refit - keep existing trajectory in case fit is not possible
728  // or fails
729  //
730 
731  backwardFit(*it,nSeed,fitter,reFitted,seedHits);
732  if ( reFitted.size()!=1 ) {
733  rebuiltTrajectories.push_back(*it);
734  LogDebug("CkfPattern")<< "RebuildSeedingRegion skipped as backward fit failed";
735  // << "after reFitted.size() " << reFitted.size();
736  continue;
737  }
738  //LogDebug("CkfPattern")<<"after reFitted.size() " << reFitted.size();
739  //
740  // Rebuild seeding part. In case it fails: keep initial trajectory
741  // (better to drop it??)
742  //
743  int nRebuilt =
744  rebuildSeedingRegion (seedHits,reFitted.front(),rebuiltTrajectories);
745 
746  if ( nRebuilt==0 ) it->invalidate(); // won't use original in-out track
747 
748  if ( nRebuilt<=0 ) rebuiltTrajectories.push_back(*it);
749 
750  }
751  //
752  // Replace input trajectories with new ones
753  //
754  result.swap(rebuiltTrajectories);
755  result.erase(std::remove_if( result.begin(),result.end(),
756  std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
757  result.end());
758 }
const TrajectorySeed & seed() const
Access to the seed used to reconstruct the Trajectory.
const Propagator * theBackwardPropagator
const DataContainer & measurements() const
tuple result
Definition: query.py:137
void backwardFit(TempTrajectory &candidate, unsigned int nSeed, const TrajectoryFitter &fitter, TempTrajectoryContainer &fittedTracks, std::vector< const TrackingRecHit * > &remainingHits) const
const Chi2MeasurementEstimatorBase & estimator() const
std::pair< const_iterator, const_iterator > range
void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const
bool isValid() const
std::vector< TempTrajectory > TempTrajectoryContainer
range recHits() const
const TrajectoryStateUpdator & updator() const
#define LogDebug(id)
size_type size() const
Definition: bqueue.h:146
int GroupedCkfTrajectoryBuilder::rebuildSeedingRegion ( const std::vector< const TrackingRecHit * > &  seedHits,
TempTrajectory candidate,
TempTrajectoryContainer result 
) const
private

Definition at line 761 of file GroupedCkfTrajectoryBuilder.cc.

References gather_cfg::cout, PrintoutHelper::dumpCandidates(), PrintoutHelper::dumpMeasurements(), groupedLimitedCandidates(), LogDebug, TempTrajectory::measurements(), TempTrajectory::setNLoops(), cmsutils::bqueue< T >::size(), BaseCkfTrajectoryBuilder::theBackwardPropagator, theRequireSeedHitsInRebuild, and verifyHits().

764 {
765  //
766  // Starting from track found by in-out tracking phase, extrapolate it inwards through
767  // the seeding region if possible in towards smaller Tracker radii, searching for additional
768  // hits.
769  // The resulting trajectories are returned in result,
770  // the count is the return value.
771  //
772  TempTrajectoryContainer rebuiltTrajectories;
773 #ifdef DBG2_GCTB
774 /* const LayerFinderByDet layerFinder;
775  if ( !seedHits.empty() && seedHits.front().isValid() ) {
776  DetLayer* seedLayer = layerFinder(seedHits.front().det());
777  cout << "Seed hit at " << seedHits.front().globalPosition()
778  << " " << seedLayer << endl;
779  cout << "Started from "
780  << candidate.lastMeasurement().updatedState().globalPosition().perp() << " "
781  << candidate.lastMeasurement().updatedState().globalPosition().z() << endl;
782  pair<bool,TrajectoryStateOnSurface> layerComp(false,TrajectoryStateOnSurface());
783  if ( seedLayer ) layerComp =
784  seedLayer->compatible(candidate.lastMeasurement().updatedState(),
785  propagator(),estimator());
786  pair<bool,TrajectoryStateOnSurface> detComp =
787  seedHits.front().det().compatible(candidate.lastMeasurement().updatedState(),
788  propagator(),estimator());
789  cout << " layer compatibility = " << layerComp.first;
790  cout << " det compatibility = " << detComp.first;
791  if ( detComp.first ) {
792  cout << " estimate = "
793  << estimator().estimate(detComp.second,seedHits.front()).second ;
794  }
795  cout << endl;
796  }*/
797  cout << "Before backward building: #measurements = "
798  << candidate.measurements().size() ; //<< endl;;
799 #endif
800  //
801  // Use standard building with standard cuts. Maybe better to use different
802  // cuts from "forward" building (e.g. no check on nr. of invalid hits)?
803  //
804  const bool inOut = false;
805  groupedLimitedCandidates(candidate, (const TrajectoryFilter*)0, theBackwardPropagator, inOut, rebuiltTrajectories);
806 
807  LogDebug("CkfPattern")<<" After backward building: "<<PrintoutHelper::dumpCandidates(rebuiltTrajectories);
808 
809  //
810  // Check & count resulting candidates
811  //
812  int nrOfTrajectories(0);
813  bool orig_ok = false;
814  //const RecHitEqualByChannels recHitEqual(false,false);
815  //vector<TM> oldMeasurements(candidate.measurements());
816  for ( TempTrajectoryContainer::iterator it=rebuiltTrajectories.begin();
817  it!=rebuiltTrajectories.end(); it++ ) {
818 
819  TempTrajectory::DataContainer newMeasurements(it->measurements());
820  //
821  // Verify presence of seeding hits?
822  //
824  orig_ok = true;
825  // no hits found (and possibly some invalid hits discarded): drop track
826  if ( newMeasurements.size()<=candidate.measurements().size() ){
827  LogDebug("CkfPattern") << "newMeasurements.size()<=candidate.measurements().size()";
828  continue;
829  }
830  // verify presence of hits
831  //GIO//if ( !verifyHits(newMeasurements.begin()+candidate.measurements().size(),
832  //GIO// newMeasurements.end(),seedHits) ){
833  if ( !verifyHits(newMeasurements.rbegin(),
834  newMeasurements.size() - candidate.measurements().size(),
835  seedHits) ){
836  LogDebug("CkfPattern")<< "seed hits not found in rebuild";
837  continue;
838  }
839  }
840  //
841  // construct final trajectory in the right order
842  //
843  TempTrajectory reversedTrajectory(it->seed(),it->seed().direction());
844  reversedTrajectory.setNLoops(it->nLoops());
845  for (TempTrajectory::DataContainer::const_iterator im=newMeasurements.rbegin(), ed = newMeasurements.rend();
846  im != ed; --im ) {
847  reversedTrajectory.push(*im);
848  }
849  // save & count result
850  result.push_back(reversedTrajectory);
851  nrOfTrajectories++;
852 
853  LogDebug("CkgPattern")<<"New traj direction = " << reversedTrajectory.direction()<<"\n"
854  <<PrintoutHelper::dumpMeasurements(reversedTrajectory.measurements());
855  }
856  // If nrOfTrajectories = 0 and orig_ok = true, this means that a track was actually found on the
857  // out-in step (meeting those requirements) but did not have the seed hits in it.
858  // In this case when we return we will go ahead and use the original in-out track.
859 
860  // If nrOfTrajectories = 0 and orig_ok = false, this means that the out-in step failed to
861  // find any track. Two cases are a technical failure in fitting the original seed hits or
862  // because the track did not meet the out-in criteria (which may be stronger than the out-in
863  // criteria). In this case we will NOT allow the original in-out track to be used.
864 
865  if ( (nrOfTrajectories == 0) && orig_ok ) {
866  nrOfTrajectories = -1;
867  }
868  return nrOfTrajectories;
869 }
static std::string dumpCandidates(collection &candidates)
const Propagator * theBackwardPropagator
const DataContainer & measurements() const
void setNLoops(signed char value)
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
void groupedLimitedCandidates(TempTrajectory &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const
bool verifyHits(TempTrajectory::DataContainer::const_iterator rbegin, size_t maxDepth, const std::vector< const TrackingRecHit * > &hits) const
Verifies presence of a RecHits in a range of TrajectoryMeasurements.
tuple result
Definition: query.py:137
std::vector< TempTrajectory > TempTrajectoryContainer
#define LogDebug(id)
tuple cout
Definition: gather_cfg.py:121
size_type size() const
Definition: bqueue.h:146
bool GroupedCkfTrajectoryBuilder::tkxor ( bool  a,
bool  b 
) const
inlineprivate

Definition at line 110 of file GroupedCkfTrajectoryBuilder.h.

References b.

Referenced by groupedIntermediaryClean().

110 {return (a||b) && !(a&&b);}
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
GroupedCkfTrajectoryBuilder::TrajectoryContainer GroupedCkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed) const
virtual

set Event for the internal MeasurementTracker data member

trajectories building starting from a seed

Implements BaseCkfTrajectoryBuilder.

Definition at line 122 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories(), and run_regression::ret.

123 {
125  ret.reserve(10);
126  buildTrajectories(seed, ret, 0);
127  return ret;
128 }
void buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
std::vector< Trajectory > TrajectoryContainer
void GroupedCkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed,
GroupedCkfTrajectoryBuilder::TrajectoryContainer ret 
) const
virtual

trajectories building starting from a seed, return in an already allocated vector

Reimplemented from TrajectoryBuilder.

Definition at line 142 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories().

143 {
144  buildTrajectories(seed,ret,0);
145 }
void buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
GroupedCkfTrajectoryBuilder::TrajectoryContainer GroupedCkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed,
const TrackingRegion region 
) const

trajectories building starting from a seed with a region

Definition at line 131 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories(), and run_regression::ret.

133 {
135  ret.reserve(10);
136  RegionalTrajectoryFilter regionalCondition(region);
137  buildTrajectories(seed, ret, &regionalCondition);
138  return ret;
139 }
void buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
std::vector< Trajectory > TrajectoryContainer
void GroupedCkfTrajectoryBuilder::trajectories ( const TrajectorySeed seed,
GroupedCkfTrajectoryBuilder::TrajectoryContainer ret,
const TrackingRegion region 
) const

trajectories building starting from a seed with a region

Definition at line 148 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories().

151 {
152  RegionalTrajectoryFilter regionalCondition(region);
153  buildTrajectories(seed,ret,&regionalCondition);
154 }
void buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
const TrajectoryStateUpdator& GroupedCkfTrajectoryBuilder::updator ( ) const
inline

Definition at line 66 of file GroupedCkfTrajectoryBuilder.h.

References BaseCkfTrajectoryBuilder::theUpdator.

Referenced by rebuildSeedingRegion().

66 {return *theUpdator;}
const TrajectoryStateUpdator * theUpdator
bool GroupedCkfTrajectoryBuilder::verifyHits ( TempTrajectory::DataContainer::const_iterator  rbegin,
size_t  maxDepth,
const std::vector< const TrackingRecHit * > &  hits 
) const
private

Verifies presence of a RecHits in a range of TrajectoryMeasurements.

Definition at line 1011 of file GroupedCkfTrajectoryBuilder.cc.

References LogDebug, and TrackingRecHit::some.

Referenced by rebuildSeedingRegion().

1014 {
1015  //
1016  // verify presence of the seeding hits
1017  //
1018  LogDebug("CkfPattern")<<"Checking for " << hits.size() << " hits in "
1019  << maxDepth << " measurements" << endl;
1020 
1022  while (maxDepth > 0) { --maxDepth; --rend; }
1023  for ( vector<const TrackingRecHit*>::const_iterator ir=hits.begin();
1024  ir!=hits.end(); ir++ ) {
1025  // assume that all seeding hits are valid!
1026  bool foundHit(false);
1027  for ( TempTrajectory::DataContainer::const_iterator im=rbegin; im!=rend; --im ) {
1028  if ( im->recHit()->isValid() && (*ir)->sharesInput(im->recHit()->hit(), TrackingRecHit::some) ) {
1029  foundHit = true;
1030  break;
1031  }
1032  }
1033  if ( !foundHit ) return false;
1034  }
1035  return true;
1036 }
#define LogDebug(id)

Member Data Documentation

float GroupedCkfTrajectoryBuilder::maxDPhiForLooperReconstruction
private

Definition at line 202 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

float GroupedCkfTrajectoryBuilder::maxPtForLooperReconstruction
private

If the value is greater than zero, the reconstructions for looper is turned on for candidates with pt greater than maxPtForLooperReconstruction

Definition at line 200 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

bool GroupedCkfTrajectoryBuilder::theAlwaysUseInvalid
private

Definition at line 185 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

bool GroupedCkfTrajectoryBuilder::theBestHitOnly
private

Use only best hit / group when building segments

Definition at line 188 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

double GroupedCkfTrajectoryBuilder::theChiSquareCut
private

Chi**2 Cut on the new Trajectory Measurements to consider

Definition at line 171 of file GroupedCkfTrajectoryBuilder.h.

Referenced by chiSquareCut().

TrajectoryFilter* GroupedCkfTrajectoryBuilder::theConfigurableCondition
private

Definition at line 166 of file GroupedCkfTrajectoryBuilder.h.

float GroupedCkfTrajectoryBuilder::theFoundHitBonus
private
            Chi**2 bonus for each found hit (favours candidates with

more measurements)

Definition at line 180 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and groupedLimitedCandidates().

bool GroupedCkfTrajectoryBuilder::theIntermediateCleaning
private

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

Definition at line 182 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and groupedLimitedCandidates().

bool GroupedCkfTrajectoryBuilder::theLockHits
private

Lock hits when building segments in a layer

Definition at line 187 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

float GroupedCkfTrajectoryBuilder::theLostHitPenalty
private

Chi**2 Penalty for each lost hit.

Definition at line 179 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), groupedLimitedCandidates(), and lostHitPenalty().

double GroupedCkfTrajectoryBuilder::theMass
private

Mass hypothesis used for propagation

Definition at line 175 of file GroupedCkfTrajectoryBuilder.h.

Referenced by mass().

int GroupedCkfTrajectoryBuilder::theMaxCand
private
    Maximum number of trajectory candidates 

to propagate to the next layer.

Definition at line 177 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), GroupedCkfTrajectoryBuilder(), groupedLimitedCandidates(), and maxCand().

unsigned int GroupedCkfTrajectoryBuilder::theMinNrOf2dHitsForRebuild
private

Minimum nr. of non-seed 2D hits required for rebuild.

Definition at line 195 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder().

unsigned int GroupedCkfTrajectoryBuilder::theMinNrOfHitsForRebuild
private

Minimum nr. of non-seed hits required for rebuild. If ==0 the seeding part will remain untouched.

Definition at line 192 of file GroupedCkfTrajectoryBuilder.h.

Referenced by backwardFit(), and GroupedCkfTrajectoryBuilder().

double GroupedCkfTrajectoryBuilder::theptCut
private

ptCut

Definition at line 173 of file GroupedCkfTrajectoryBuilder.h.

Referenced by ptCut().

bool GroupedCkfTrajectoryBuilder::theRequireSeedHitsInRebuild
private

Only accept rebuilt trajectories if they contain the seed hits.

Definition at line 190 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and rebuildSeedingRegion().

TempTrajectoryContainer GroupedCkfTrajectoryBuilder::work_
mutableprivate

Definition at line 204 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().