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 | Static Private Member Functions | Private Attributes
GroupedCkfTrajectoryBuilder Class Reference

#include <GroupedCkfTrajectoryBuilder.h>

Inheritance diagram for GroupedCkfTrajectoryBuilder:
BaseCkfTrajectoryBuilder TrajectoryBuilder

Public Member Functions

TempTrajectory buildTrajectories (const TrajectorySeed &seed, TrajectoryContainer &ret, const TrajectoryFilter *) const
 common part of both public trajectory building methods More...
 
double chiSquareCut ()
 
virtual
GroupedCkfTrajectoryBuilder
clone (const MeasurementTrackerEvent *data) const
 
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 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
 
void rebuildTrajectories (TempTrajectory const &startingTraj, 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 TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter=0)
 
 BaseCkfTrajectoryBuilder (const BaseCkfTrajectoryBuilder &other)=default
 
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 (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 MeasurementTrackerEvent *theMeasurementTracker, const Propagator *theForwardPropagator, const Chi2MeasurementEstimatorBase *theEstimator, const TransientTrackingRecHitBuilder *theTTRHBuilder) const
 
virtual bool analyzeMeasurementsDebugger (TempTrajectory &traj, const std::vector< TrajectoryMeasurement > &meas, const MeasurementTrackerEvent *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
 
void setData (const MeasurementTrackerEvent *data)
 
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 dso_internal
 
TempTrajectory backwardFit (TempTrajectory &candidate, unsigned int nSeed, const TrajectoryFitter &fitter, std::vector< const TrackingRecHit * > &remainingHits) const dso_internal
 
void groupedIntermediaryClean (TempTrajectoryContainer &theTrajectories) const dso_internal
 intermediate cleaning in the case of grouped measurements More...
 
void groupedLimitedCandidates (TempTrajectory const &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const dso_internal
 
void rebuildSeedingRegion (const TrajectorySeed &seed, TempTrajectory const &startingTraj, TempTrajectoryContainer &result) const dso_internal
 try to find additional hits in seeding region More...
 
int rebuildSeedingRegion (const TrajectorySeed &seed, const std::vector< const TrackingRecHit * > &seedHits, TempTrajectory &candidate, TempTrajectoryContainer &result) const dso_internal
 
bool tkxor (bool a, bool b) const dso_internal
 
bool verifyHits (TempTrajectory::DataContainer::const_iterator rbegin, size_t maxDepth, const std::vector< const TrackingRecHit * > &hits) const dso_internal
 Verifies presence of a RecHits in a range of TrajectoryMeasurements. More...
 

Static Private Member Functions

static PropagationDirection oppositeDirection (PropagationDirection dir)
 change of propagation direction More...
 

Private Attributes

float maxDPhiForLooperReconstruction
 
float maxPt2ForLooperReconstruction
 
bool theAlwaysUseInvalid
 
bool theBestHitOnly
 
double theChiSquareCut
 
TrajectoryFiltertheConfigurableCondition
 
float theFoundHitBonus
 
bool theIntermediateCleaning
 
bool theKeepOriginalIfRebuildFails
 
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 MeasurementTrackerEventtheMeasurementTracker
 
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 213 of file GroupedCkfTrajectoryBuilder.h.

213 { 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 TrajectoryFilter filter,
const TrajectoryFilter inOutFilter 
)

constructor from ParameterSet

Definition at line 111 of file GroupedCkfTrajectoryBuilder.cc.

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

Referenced by clone().

118  :
119 
120 
122  updator, propagatorAlong,propagatorOpposite,
123  estimator, recHitBuilder, filter, inOutFilter)
124 {
125  // fill data members from parameters (eventually data members could be dropped)
126  //
127  theMaxCand = conf.getParameter<int>("maxCand");
128 
129  theLostHitPenalty = conf.getParameter<double>("lostHitPenalty");
130  theFoundHitBonus = conf.getParameter<double>("foundHitBonus");
131  theIntermediateCleaning = conf.getParameter<bool>("intermediateCleaning");
132  theAlwaysUseInvalid = conf.getParameter<bool>("alwaysUseInvalidHits");
133  theLockHits = conf.getParameter<bool>("lockHits");
134  theBestHitOnly = conf.getParameter<bool>("bestHitOnly");
136  theRequireSeedHitsInRebuild = conf.getParameter<bool>("requireSeedHitsInRebuild");
137  theKeepOriginalIfRebuildFails = conf.getParameter<bool>("keepOriginalIfRebuildFails");
138  theMinNrOfHitsForRebuild = max(0,conf.getParameter<int>("minNrOfHitsForRebuild"));
139  maxPt2ForLooperReconstruction = conf.existsAs<double>("maxPtForLooperReconstruction") ?
140  conf.getParameter<double>("maxPtForLooperReconstruction") : 0;
142  maxDPhiForLooperReconstruction = conf.existsAs<double>("maxDPhiForLooperReconstruction") ?
143  conf.getParameter<double>("maxDPhiForLooperReconstruction") : 2.0;
144 
145 
146  /* ======= B.M. to be ported layer ===========
147  bool setOK = thePropagator->setMaxDirectionChange(1.6);
148  if (!setOK)
149  cout << "GroupedCkfTrajectoryBuilder WARNING: "
150  << "propagator does not support setMaxDirectionChange"
151  << endl;
152  // addStopCondition(theMinPtStopCondition);
153 
154  theConfigurableCondition = createAlgo<TrajectoryFilter>(componentConfig("StopCondition"));
155  ===================================== */
156 
157 }
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:184
const T & max(const T &a, const T &b)
BaseCkfTrajectoryBuilder(const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter=0)
virtual GroupedCkfTrajectoryBuilder::~GroupedCkfTrajectoryBuilder ( )
inlinevirtual

destructor

Definition at line 40 of file GroupedCkfTrajectoryBuilder.h.

40 {}

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 427 of file GroupedCkfTrajectoryBuilder.cc.

References funct::abs(), BaseCkfTrajectoryBuilder::addToResult(), PV3DBase< T, PVType, FrameType >::basicVector(), TransverseImpactPointExtrapolator::extrapolate(), f, BaseCkfTrajectoryBuilder::findStateAndLayers(), TempTrajectory::foundHits(), cmsutils::bqueue< T >::front(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TempTrajectory::incrementLoops(), TrajectoryStateOnSurface::isValid(), TempTrajectory::join(), TempTrajectory::lastLayer(), Bounds::length(), DetLayer::location(), LogDebug, maxDPhiForLooperReconstruction, maxPt2ForLooperReconstruction, TempTrajectory::measurements(), MeasurementTrackerEvent::measurementTracker(), TrackingRecHit::missing, BaseCkfTrajectoryBuilder::moveToResult(), PV3DBase< T, PVType, FrameType >::phi(), Propagator::propagationDirection(), cmsutils::bqueue< T >::rbegin(), TrajectoryMeasurement::recHit(), rejected(), cmsutils::bqueue< T >::rend(), TempTrajectory::setDPhiCacheForLoopersReconstruction(), cmsutils::bqueue< T >::size(), BarrelDetLayer::specificSurface(), filterCSVwithJSON::target, theAlwaysUseInvalid, theBestHitOnly, BaseCkfTrajectoryBuilder::theEstimator, BaseCkfTrajectoryBuilder::theForwardPropagator, theLockHits, BaseCkfTrajectoryBuilder::theMeasurementTracker, BaseCkfTrajectoryBuilder::theUpdator, BaseCkfTrajectoryBuilder::toBeContinued(), TrajectoryStateOnSurface::transverseCurvature(), unlikely, and PV3DBase< T, PVType, FrameType >::z().

Referenced by groupedLimitedCandidates().

433 {
434  std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers = findStateAndLayers(traj);
435 
436 
438  if(
439  //stateAndLayers.second.size()==0 &&
440  traj.lastLayer()->location()==0) {
441  float pt2 = stateAndLayers.first.globalMomentum().perp2();
443  pt2>(0.3f*0.3f)
444  )
445  stateAndLayers.second.push_back(traj.lastLayer());
446  }
447  }
448 
449  vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
450  vector<const DetLayer*>::iterator layerEnd = stateAndLayers.second.end();
451 
452  // if (nl.empty()) {
453  // addToResult(traj,result,inOut);
454  // return false;
455  // }
456 
457 #ifdef EDM_ML_DEBUG
458  LogDebug("CkfPattern")<<whatIsTheNextStep(traj, stateAndLayers);
459 #endif
460 
461  bool foundSegments(false);
462  bool foundNewCandidates(false);
463  for ( vector<const DetLayer*>::iterator il=layerBegin;
464  il!=layerEnd; il++) {
465 
466  TSOS stateToUse = stateAndLayers.first;
467 
468  double dPhiCacheForLoopersReconstruction(0);
469  if unlikely((*il)==traj.lastLayer()){
470 
472  // ------ For loopers reconstruction
473  //cout<<" self propagating in advanceOneLayer (for loopers) \n";
474  const BarrelDetLayer* sbdl = dynamic_cast<const BarrelDetLayer*>(traj.lastLayer());
475  if(sbdl){
476  HelixBarrelCylinderCrossing cylinderCrossing(stateToUse.globalPosition(),
477  stateToUse.globalMomentum(),
478  stateToUse.transverseCurvature(),
479  propagator->propagationDirection(),
480  sbdl->specificSurface());
481  if(!cylinderCrossing.hasSolution()) continue;
482  GlobalPoint starting = stateToUse.globalPosition();
483  GlobalPoint target1 = cylinderCrossing.position1();
484  GlobalPoint target2 = cylinderCrossing.position2();
485 
486  GlobalPoint farther = fabs(starting.phi()-target1.phi()) > fabs(starting.phi()-target2.phi()) ?
487  target1 : target2;
488 
489  const Bounds& bounds( sbdl->specificSurface().bounds());
490  float length = 0.5f*bounds.length();
491 
492  /*
493  cout << "starting: " << starting << endl;
494  cout << "target1: " << target1 << endl;
495  cout << "target2: " << target2 << endl;
496  cout << "dphi: " << (target1.phi()-target2.phi()) << endl;
497  cout << "length: " << length << endl;
498  */
499 
500  /*
501  float deltaZ = bounds.thickness()/2.f/fabs(tan(stateToUse.globalDirection().theta()) ) ;
502  if(stateToUse.hasError())
503  deltaZ += 3*sqrt(stateToUse.cartesianError().position().czz());
504  if( fabs(farther.z()) > length + deltaZ ) continue;
505  */
506  if(fabs(farther.z())*0.95f>length) continue;
507 
508  Geom::Phi<float> tmpDphi = target1.phi()-target2.phi();
509  if(std::abs(tmpDphi)>maxDPhiForLooperReconstruction) continue;
510  GlobalPoint target(0.5f*(target1.basicVector()+target2.basicVector()));
511  //cout << "target: " << target << endl;
512 
513 
514 
516  stateToUse = extrapolator.extrapolate(stateToUse, target, *propagator);
517  if (!stateToUse.isValid()) continue; //SK: consider trying the original? probably not
518 
519  //dPhiCacheForLoopersReconstruction = fabs(target1.phi()-target2.phi())*2.;
520  dPhiCacheForLoopersReconstruction = std::abs(tmpDphi);
521  traj.incrementLoops();
522  }else{ // not barrel
523  continue;
524  }
525  }else{ // loopers not requested (why else???)
526  // ------ For cosmics reconstruction
527  LogDebug("CkfPattern")<<" self propagating in advanceOneLayer.\n from: \n"<<stateToUse;
528  //self navigation case
529  // go to a middle point first
531  GlobalPoint center(0,0,0);
532  stateToUse = middle.extrapolate(stateToUse, center, *theForwardPropagator);
533 
534  if (!stateToUse.isValid()) continue;
535  LogDebug("CkfPattern")<<"to: "<<stateToUse;
536  }
537  } // last layer...
538 
539  //unsigned int maxCandidates = theMaxCand > 21 ? theMaxCand*2 : 42; //limit the number of returned segments
541  TrajectorySegmentBuilder layerBuilder(&layerMeasurements,
542  **il,*propagator,
545 
546 #ifdef EDM_ML_DEBUG
547  LogDebug("CkfPattern")<<whatIsTheStateToUse(stateAndLayers.first,stateToUse,*il);
548 #endif
549 
550  TempTrajectoryContainer segments=
551  layerBuilder.segments(stateToUse);
552 
553  LogDebug("CkfPattern")<< "GCTB: number of segments = " << segments.size();
554 
555  if ( !segments.empty() ) foundSegments = true;
556 
557  for ( TempTrajectoryContainer::iterator is=segments.begin();
558  is!=segments.end(); is++ ) {
559  //
560  // assume "invalid hit only" segment is last in list
561  //
562  const TempTrajectory::DataContainer & measurements = is->measurements();
563  if ( !theAlwaysUseInvalid && is!=segments.begin() && measurements.size()==1 &&
564  (measurements.front().recHit()->getType() == TrackingRecHit::missing) ) break;
565 
566 
567  //---- avoid to add the same hits more than once in the trajectory ----
568  bool toBeRejected(false);
569  for(const TempTrajectory::DataContainer::const_iterator revIt = measurements.rbegin();
570  revIt!=measurements.rend(); --revIt){
571  // int tmpCounter(0);
572  for(const TempTrajectory::DataContainer::const_iterator newTrajMeasIt = traj.measurements().rbegin();
573  newTrajMeasIt != traj.measurements().rend(); --newTrajMeasIt){
574  //if(tmpCounter==2) break;
575  if(revIt->recHitR().geographicalId()==newTrajMeasIt->recHitR().geographicalId()
576  && (revIt->recHitR().geographicalId() != DetId(0)) ){
577  toBeRejected=true;
578  goto rejected; //break; // see http://stackoverflow.com/questions/1257744/can-i-use-break-to-exit-multiple-nested-for-loops
579  }
580  // tmpCounter++;
581  }
582  }
583 
584  rejected:; // http://xkcd.com/292/
585  if(toBeRejected){
586  /*cout << "WARNING: neglect candidate because it contains the same hit twice \n";
587  cout << "-- discarded track's pt,eta,#found: "
588  << traj.lastMeasurement().updatedState().globalMomentum().perp() << " , "
589  << traj.lastMeasurement().updatedState().globalMomentum().eta() << " , "
590  << traj.foundHits() << "\n";
591  */
592  traj.setDPhiCacheForLoopersReconstruction(dPhiCacheForLoopersReconstruction);
593  continue; //Are we sure about this????
594  }
595  // ------------------------
596 
597  //
598  // create new candidate
599  //
600  TempTrajectory newTraj(traj);
601  traj.setDPhiCacheForLoopersReconstruction(dPhiCacheForLoopersReconstruction);
602  newTraj.join(*is);
603 
604  //std::cout << "DEBUG: newTraj after push found,lost: "
605  // << newTraj.foundHits() << " , "
606  // << newTraj.lostHits() << " , "
607  // << newTraj.measurements().size() << std::endl;
608 
609 
610 
611  //GIO// for ( vector<TM>::const_iterator im=measurements.begin();
612  //GIO// im!=measurements.end(); im++ ) newTraj.push(*im);
613  //if ( toBeContinued(newTraj,regionalCondition) ) { TOBE FIXED
614  if ( toBeContinued(newTraj, inOut) ) {
615  // Have added one more hit to track candidate
616 
617  LogDebug("CkfPattern")<<"GCTB: adding updated trajectory to candidates: inOut="<<inOut<<" hits="<<newTraj.foundHits();
618 
619  newCand.push_back(std::move(newTraj));
620  foundNewCandidates = true;
621  }
622  else {
623  // Have finished building this track. Check if it passes cuts.
624 
625  LogDebug("CkfPattern")<< "GCTB: adding completed trajectory to results if passes cuts: inOut="<<inOut<<" hits="<<newTraj.foundHits();
626 
627  moveToResult(std::move(newTraj), result, inOut);
628  }
629  } // loop over segs
630  } // loop over layers
631 
632  if ( !foundSegments ){
633  LogDebug("CkfPattern")<< "GCTB: adding input trajectory to result";
634  addToResult(traj, result, inOut);
635  }
636  return foundNewCandidates;
637 }
#define LogDebug(id)
const_iterator rend() const
Definition: bqueue.h:164
virtual float length() const =0
ConstRecHitPointer const & recHit() const
virtual Location location() const =0
Which part of the detector (barrel, endcap)
const DataContainer & measurements() const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const TrajectoryStateUpdator * theUpdator
GlobalPoint globalPosition() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is rejected(acceptEvent retursns false).There are 3 relevant cases of types of criteria
virtual PropagationDirection propagationDirection() const GCC11_FINAL
Definition: Propagator.h:145
const T & front() const
Definition: bqueue.h:159
#define unlikely(x)
Definition: Likely.h:21
void setDPhiCacheForLoopersReconstruction(float dphi)
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
void addToResult(boost::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
const MeasurementTracker & measurementTracker() const
const_iterator rbegin() const
Definition: bqueue.h:163
StateAndLayers findStateAndLayers(const TrajectorySeed &seed, const TempTrajectory &traj) const
const MeasurementTrackerEvent * theMeasurementTracker
Definition: DetId.h:18
std::vector< TempTrajectory > TempTrajectoryContainer
void moveToResult(TempTrajectory &&traj, TempTrajectoryContainer &result, bool inOut=false) const
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
size_type size() const
Definition: bqueue.h:167
Definition: Bounds.h:22
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
virtual const BoundCylinder & specificSurface() const GCC11_FINAL
Extension of the interface.
const Chi2MeasurementEstimatorBase * theEstimator
const Propagator * theForwardPropagator
virtual void GroupedCkfTrajectoryBuilder::analyseMeasurements ( const std::vector< TM > &  meas,
const Trajectory traj 
) const
inlineprotectedvirtual

Definition at line 108 of file GroupedCkfTrajectoryBuilder.h.

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

Definition at line 110 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().

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

Definition at line 106 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().

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

Definition at line 981 of file GroupedCkfTrajectoryBuilder.cc.

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

Referenced by rebuildSeedingRegion().

984 {
985  //
986  // clear array of non-fitted hits
987  //
988  remainingHits.clear();
989  //
990  // skip candidates which are not exceeding the seed size
991  // (e.g. Because no Tracker layers exist outside seeding region)
992  //
993  if unlikely( candidate.measurements().size()<=nSeed ) return TempTrajectory();
994 
995  LogDebug("CkfPattern")<<"nSeed " << nSeed << endl
996  << "Old traj direction = " << candidate.direction() << endl
998 
999  //
1000  // backward fit trajectory.
1001  // (Will try to fit only hits outside the seeding region. However,
1002  // if there are not enough of these, it will also use the seeding hits).
1003  //
1004  // const unsigned int nHitAllMin(5);
1005  // const unsigned int nHit2dMin(2);
1006  unsigned int nHit(0); // number of valid hits after seeding region
1007  //unsigned int nHit2d(0); // number of valid hits after seeding region with 2D info
1008  // use all hits except the first n (from seed), but require minimum
1009  // specified in configuration.
1010  // Swapped over next two lines.
1011  unsigned int nHitMin = std::max(candidate.foundHits()-nSeed,theMinNrOfHitsForRebuild);
1012  // unsigned int nHitMin = oldMeasurements.size()-nSeed;
1013  // we want to rebuild only if the number of VALID measurements excluding the seed measurements is higher than the cut
1015 
1016  LogDebug("CkfPattern")/* << "nHitMin " << nHitMin*/ <<"Sizes: " << candidate.measurements().size() << " / ";
1017  //
1018  // create input trajectory for backward fit
1019  //
1020  Trajectory fwdTraj(oppositeDirection(candidate.direction()));
1021  fwdTraj.setNLoops(candidate.nLoops());
1022  //const TrajectorySeed seed = TrajectorySeed(PTrajectoryStateOnDet(), TrajectorySeed::recHitContainer(), oppositeDirection(candidate.direction()));
1023  //Trajectory fwdTraj(seed, oppositeDirection(candidate.direction()));
1024 
1025  const DetLayer* bwdDetLayer[candidate.measurements().size()];
1026  int nl=0;
1027  for ( auto const & tm : candidate.measurements() ) {
1028  const TrackingRecHit* hit = tm.recHitR().hit();
1029  //
1030  // add hits until required number is reached
1031  //
1032  if ( nHit<nHitMin ){//|| nHit2d<theMinNrOf2dHitsForRebuild ) {
1033  fwdTraj.push(tm);
1034  bwdDetLayer[nl++]=tm.layer();
1035  //
1036  // count valid / 2D hits
1037  //
1038  if likely( hit->isValid() ) {
1039  nHit++;
1040  //if ( hit.isMatched() ||
1041  // hit.det().detUnits().front()->type().module()==pixel )
1042  //nHit2d++;
1043  }
1044  }
1045  //if (nHit==nHitMin) lastBwdDetLayer=im->layer();
1046  //
1047  // keep remaining (valid) hits for verification
1048  //
1049  else if ( hit->isValid() ) {
1050  //std::cout << "Adding a remaining hit" << std::endl;
1051  remainingHits.push_back(hit);
1052  }
1053  }
1054  //
1055  // Fit only if required number of valid hits can be used
1056  //
1057  if unlikely( nHit<nHitMin ) return TempTrajectory();
1058 
1059  //
1060  // Do the backward fit (important: start from scaled, not random cov. matrix!)
1061  //
1062  TrajectoryStateOnSurface firstTsos(fwdTraj.firstMeasurement().updatedState());
1063  //cout << "firstTsos "<< firstTsos << endl;
1064  firstTsos.rescaleError(10.);
1065  //TrajectoryContainer bwdFitted(fitter.fit(fwdTraj.seed(),fwdTraj.recHits(),firstTsos));
1066  Trajectory && bwdFitted = fitter.fitOne(TrajectorySeed(PTrajectoryStateOnDet(), TrajectorySeed::recHitContainer(), oppositeDirection(candidate.direction())),
1067  fwdTraj.recHits(),firstTsos);
1068  if unlikely(!bwdFitted.isValid()) return TempTrajectory();
1069 
1070 
1071  LogDebug("CkfPattern")<<"Obtained bwdFitted trajectory with measurement size " << bwdFitted.measurements().size();
1072  TempTrajectory fitted(fwdTraj.direction());
1073  fitted.setNLoops(fwdTraj.nLoops());
1074  vector<TM> const & tmsbf = bwdFitted.measurements();
1075  int iDetLayer=0;
1076  //this is ugly but the TM in the fitted track do not contain the DetLayer.
1077  //So we have to cache the detLayer pointers and replug them in.
1078  //For the backward building it would be enaugh to cache the last DetLayer,
1079  //but for the intermediary cleaning we need all
1080  for ( vector<TM>::const_iterator im=tmsbf.begin();im!=tmsbf.end(); im++ ) {
1081  fitted.emplace( (*im).forwardPredictedState(),
1082  (*im).backwardPredictedState(),
1083  (*im).updatedState(),
1084  (*im).recHit(),
1085  (*im).estimate(),
1086  bwdDetLayer[iDetLayer]
1087  );
1088 
1089  LogDebug("CkfPattern")<<PrintoutHelper::dumpMeasurement(*im);
1090  iDetLayer++;
1091  }
1092  /*
1093  TM lastMeas = bwdFitted.front().lastMeasurement();
1094  fitted.pop();
1095  fitted.push(TM(lastMeas.forwardPredictedState(),
1096  lastMeas.backwardPredictedState(),
1097  lastMeas.updatedState(),
1098  lastMeas.recHit(),
1099  lastMeas.estimate(),
1100  lastBwdDetLayer));
1101  */
1102 
1103 
1104  return fitted;
1105 }
#define LogDebug(id)
const DataContainer & measurements() const
int foundHits() const
obsolete name, use measurements() instead.
static std::string dumpMeasurement(const TrajectoryMeasurement &tm)
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
#define unlikely(x)
Definition: Likely.h:21
PropagationDirection direction() const
const T & max(const T &a, const T &b)
static PropagationDirection oppositeDirection(PropagationDirection dir)
change of propagation direction
#define end
Definition: vmac.h:37
bool isValid() const
string const
Definition: compareJSON.py:14
return(e1-e2)*(e1-e2)+dp *dp
#define likely(x)
Definition: Likely.h:20
#define begin
Definition: vmac.h:30
if(dp >Float(M_PI)) dp-
size_type size() const
Definition: bqueue.h:167
tuple size
Write out results.
TempTrajectory GroupedCkfTrajectoryBuilder::buildTrajectories ( const TrajectorySeed seed,
GroupedCkfTrajectoryBuilder::TrajectoryContainer result,
const TrajectoryFilter regionalCondition 
) const
virtual

common part of both public trajectory building methods

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 251 of file GroupedCkfTrajectoryBuilder.cc.

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

Referenced by trajectories().

254 {
255  if (theMeasurementTracker == 0) {
256  throw cms::Exception("LogicError") << "Asking to create trajectories to an un-initialized GroupedCkfTrajectoryBuilder.\nYou have to call clone(const MeasurementTrackerEvent *data) and then call trajectories on it instead.\n";
257  }
258 
259  statCount.seed();
260  //
261  // Build trajectory outwards from seed
262  //
263 
264  analyseSeed( seed);
265 
266  TempTrajectory const & startingTraj = createStartingTrajectory( seed);
267 
268  work_.clear();
269  const bool inOut = true;
270  groupedLimitedCandidates( startingTraj, regionalCondition, theForwardPropagator, inOut, work_);
271  if ( work_.empty() ) return startingTraj;
272 
273 
274 
275  /* rebuilding is de-coupled from standard building
276  //
277  // try to additional hits in the seeding region
278  //
279  if ( theMinNrOfHitsForRebuild>0 ) {
280  // reverse direction
281  //thePropagator->setPropagationDirection(oppositeDirection(seed.direction()));
282  // rebuild part of the trajectory
283  rebuildSeedingRegion(startingTraj,work);
284  }
285 
286  */
287  boost::shared_ptr<const TrajectorySeed> pseed(new TrajectorySeed(seed));
288  result.reserve(work_.size());
289  for (TempTrajectoryContainer::const_iterator it = work_.begin(), ed = work_.end(); it != ed; ++it) {
290  result.push_back( it->toTrajectory() ); result.back().setSharedSeed(pseed);
291  }
292 
293  work_.clear();
294  if (work_.capacity() > work_MaxSize_) { TempTrajectoryContainer().swap(work_); work_.reserve(work_MaxSize_/2); }
295 
297 
298  LogDebug("CkfPattern")<< "GroupedCkfTrajectoryBuilder: returning result of size " << result.size();
299  statCount.traj(result.size());
300 
301 
302  return startingTraj;
303 
304 }
#define LogDebug(id)
virtual void analyseSeed(const TrajectorySeed &seed) const
virtual void analyseResult(const TrajectoryContainer &result) const
void groupedLimitedCandidates(TempTrajectory const &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const dso_internal
tuple result
Definition: query.py:137
const MeasurementTrackerEvent * theMeasurementTracker
std::vector< TempTrajectory > TempTrajectoryContainer
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 86 of file GroupedCkfTrajectoryBuilder.h.

References theChiSquareCut.

GroupedCkfTrajectoryBuilder * GroupedCkfTrajectoryBuilder::clone ( const MeasurementTrackerEvent data) const
virtual

Implements BaseCkfTrajectoryBuilder.

Definition at line 167 of file GroupedCkfTrajectoryBuilder.cc.

References GroupedCkfTrajectoryBuilder(), run_regression::ret, and BaseCkfTrajectoryBuilder::setData().

167  {
169  ret->setData(data);
170  return ret;
171 }
GroupedCkfTrajectoryBuilder(const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter)
constructor from ParameterSet
void setData(const MeasurementTrackerEvent *data)
const Chi2MeasurementEstimatorBase& GroupedCkfTrajectoryBuilder::estimator ( void  ) const
inline

Definition at line 81 of file GroupedCkfTrajectoryBuilder.h.

References BaseCkfTrajectoryBuilder::theEstimator.

Referenced by rebuildSeedingRegion().

81 {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 672 of file GroupedCkfTrajectoryBuilder.cc.

References lumiContext::fill, ecalTPGAnalyzer_cfg::firstValid, TempTrajectory::isValid(), TempTrajectory::lastMeasurement(), LayerTriplets::layers(), cmsutils::bqueue< T >::rbegin(), TrajectoryMeasurement::recHitR(), cmsutils::bqueue< T >::rend(), TrackingRecHit::some, and tkxor().

Referenced by groupedLimitedCandidates().

673 {
674  //if (theTrajectories.empty()) return TrajectoryContainer();
675  //TrajectoryContainer result;
676  if (theTrajectories.empty()) return;
677  //RecHitEqualByChannels recHitEqualByChannels(false, false);
678  LayersInTraj layers[theTrajectories.size()];
679  int ntraj=0;
680  for ( auto & t : theTrajectories) {
681  if ( t.isValid() && t.lastMeasurement().recHitR().isValid() )
682  layers[ntraj++].fill(t);
683  }
684 
685  if (ntraj<2) return;
686 
687  for (int ifirst=0; ifirst!=ntraj-1; ++ifirst) {
688  auto firstTraj = layers[ifirst].traj;
689  if (!firstTraj->isValid()) continue;
690  const TempTrajectory::DataContainer & firstMeasurements = firstTraj->measurements();
691 
692  int firstLayerSize = layers[ifirst].tot;
693  if ( firstLayerSize<4 ) continue;
694  auto const & firstLayers = layers[ifirst].layers;
695 
696  for (int isecond= ifirst+1; isecond!=ntraj; ++isecond) {
697  auto secondTraj = layers[isecond].traj;
698  if (!secondTraj->isValid()) continue;
699 
700  const TempTrajectory::DataContainer & secondMeasurements = secondTraj->measurements();
701 
702  int secondLayerSize = layers[isecond].tot;
703  //
704  // only candidates using the same last 3 layers are compared
705  //
706  if ( firstLayerSize!=secondLayerSize ) continue; // V.I. why equal???
707  auto const & secondLayers = layers[isecond].layers;
708  if ( firstLayers[0]!=secondLayers[0] ||
709  firstLayers[1]!=secondLayers[1] ||
710  firstLayers[2]!=secondLayers[2] ) continue;
711 
712  TempTrajectory::DataContainer::const_iterator im1 = firstMeasurements.rbegin();
713  TempTrajectory::DataContainer::const_iterator im2 = secondMeasurements.rbegin();
714  //
715  // check for identical hits in the last layer
716  //
717  bool unequal(false);
718  const DetLayer* layerPtr = firstLayers[0];
719  while ( im1!=firstMeasurements.rend()&&im2!=secondMeasurements.rend() ) {
720  if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr ) break;
721  if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
722  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some) ) {
724  unequal = true;
725  break;
726  }
727  --im1;
728  --im2;
729  }
730  if ( im1==firstMeasurements.rend() || im2==secondMeasurements.rend() ||
731  im1->layer()==layerPtr || im2->layer()==layerPtr || unequal ) continue;
732  //
733  // check for invalid hits in the layer -2
734  // compare only candidates with invalid / valid combination
735  //
736  layerPtr = firstLayers[1];
737  bool firstValid(true);
738  while ( im1!=firstMeasurements.rend()&&im1->layer()==layerPtr ) {
739  if ( !im1->recHit()->isValid() ) firstValid = false;
740  --im1;
741  }
742  bool secondValid(true);
743  while ( im2!=secondMeasurements.rend()&&im2->layer()==layerPtr ) {
744  if ( !im2->recHit()->isValid() ) secondValid = false;
745  --im2;
746  }
747  if ( !tkxor(firstValid,secondValid) ) continue;
748  //
749  // ask for identical hits in layer -3
750  //
751  unequal = false;
752  layerPtr = firstLayers[2];
753  while ( im1!=firstMeasurements.rend()&&im2!=secondMeasurements.rend() ) {
754  if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr ) break;
755  if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
756  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some) ) {
758  unequal = true;
759  break;
760  }
761  --im1;
762  --im2;
763  }
764  if ( im1==firstMeasurements.rend() || im2==secondMeasurements.rend() ||
765  im1->layer()==layerPtr || im2->layer()==layerPtr || unequal ) continue;
766 
767  if ( !firstValid ) {
768  firstTraj->invalidate();
769  break;
770  }
771  else {
772  secondTraj->invalidate(); // V.I. why break?
773  break;
774  }
775  } // second
776  } // first
777 /*
778  for (TempTrajectoryContainer::const_iterator it = theTrajectories.begin();
779  it != theTrajectories.end(); it++) {
780  if(it->isValid()) result.push_back( *it);
781  }
782 
783  return result;
784 */
785  theTrajectories.erase(std::remove_if( theTrajectories.begin(),theTrajectories.end(),
786  std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
787  // boost::bind(&TempTrajectory::isValid,_1)),
788  theTrajectories.end());
789 }
const_iterator rend() const
Definition: bqueue.h:164
string fill
Definition: lumiContext.py:319
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
bool tkxor(bool a, bool b) const dso_internal
const_iterator rbegin() const
Definition: bqueue.h:163
bool isValid() const
void GroupedCkfTrajectoryBuilder::groupedLimitedCandidates ( TempTrajectory const &  startingTraj,
const TrajectoryFilter regionalCondition,
const Propagator propagator,
bool  inOut,
TempTrajectoryContainer result 
) const
private

Definition at line 308 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().

313 {
314  unsigned int nIter=1;
315  TempTrajectoryContainer candidates;
316  TempTrajectoryContainer newCand;
317  candidates.push_back( startingTraj);
318 
319  while ( !candidates.empty()) {
320 
321  newCand.clear();
322  for (TempTrajectoryContainer::iterator traj=candidates.begin();
323  traj!=candidates.end(); traj++) {
324  if ( !advanceOneLayer(*traj, regionalCondition, propagator, inOut, newCand, result) ) {
325  LogDebug("CkfPattern")<< "GCTB: terminating after advanceOneLayer==false";
326  continue;
327  }
328 
329  LogDebug("CkfPattern")<<"newCand(1): after advanced one layer:\n"<<PrintoutHelper::dumpCandidates(newCand);
330 
331  if ((int)newCand.size() > theMaxCand) {
332  //ShowCand()(newCand);
333 
334  sort( newCand.begin(), newCand.end(), GroupedTrajCandLess(theLostHitPenalty,theFoundHitBonus));
335  newCand.erase( newCand.begin()+theMaxCand, newCand.end());
336  }
337  LogDebug("CkfPattern")<<"newCand(2): after removing extra candidates.\n"<<PrintoutHelper::dumpCandidates(newCand);
338  }
339 
340  LogDebug("CkfPattern") << "newCand.size() at end = " << newCand.size();
341 /*
342  if (theIntermediateCleaning) {
343  candidates.clear();
344  candidates = groupedIntermediaryClean(newCand);
345  } else {
346  candidates.swap(newCand);
347  }
348 */
350 #ifdef STANDARD_INTERMEDIARYCLEAN
352 #else
353  groupedIntermediaryClean(newCand);
354 #endif
355 
356  }
357  candidates.swap(newCand);
358 
359  LogDebug("CkfPattern") <<"candidates(3): "<<result.size()<<" candidates after "<<nIter++<<" groupedCKF iteration: \n"
361  <<"\n "<<candidates.size()<<" running candidates are: \n"
362  <<PrintoutHelper::dumpCandidates(candidates);
363  }
364 }
#define LogDebug(id)
static std::string dumpCandidates(collection &candidates)
void groupedIntermediaryClean(TempTrajectoryContainer &theTrajectories) const dso_internal
intermediate cleaning in the case of grouped measurements
static void clean(TempTrajectoryContainer &tracks)
bool advanceOneLayer(TempTrajectory &traj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &newCand, TempTrajectoryContainer &result) const dso_internal
tuple result
Definition: query.py:137
std::vector< TempTrajectory > TempTrajectoryContainer
float GroupedCkfTrajectoryBuilder::lostHitPenalty ( )
inline

Chi**2 Penalty for each lost hit.

Definition at line 93 of file GroupedCkfTrajectoryBuilder.h.

References theLostHitPenalty.

double GroupedCkfTrajectoryBuilder::mass ( )
inline

Mass hypothesis used for propagation.

Definition at line 102 of file GroupedCkfTrajectoryBuilder.h.

References theMass.

int GroupedCkfTrajectoryBuilder::maxCand ( )
inline

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

Definition at line 89 of file GroupedCkfTrajectoryBuilder.h.

References theMaxCand.

static PropagationDirection GroupedCkfTrajectoryBuilder::oppositeDirection ( PropagationDirection  dir)
inlinestaticprivate

change of propagation direction

Definition at line 164 of file GroupedCkfTrajectoryBuilder.h.

References alongMomentum, dir, and oppositeToMomentum.

Referenced by backwardFit().

164  {
165  if ( dir==alongMomentum ) return oppositeToMomentum;
166  if ( dir==oppositeToMomentum ) return alongMomentum;
167  return dir;
168  }
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 99 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 209 of file GroupedCkfTrajectoryBuilder.cc.

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

Referenced by rebuildSeedingRegion(), and rebuildTrajectories().

210  {
211  TempTrajectory const & startingTraj = createStartingTrajectory( seed);
212  rebuildTrajectories(startingTraj,seed,result);
213 
214 }
void rebuildTrajectories(TempTrajectory const &startingTraj, const TrajectorySeed &, TrajectoryContainer &result) const
tuple result
Definition: query.py:137
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
void GroupedCkfTrajectoryBuilder::rebuildSeedingRegion ( const TrajectorySeed seed,
TempTrajectory const &  startingTraj,
TempTrajectoryContainer result 
) const
private

try to find additional hits in seeding region

Definition at line 793 of file GroupedCkfTrajectoryBuilder.cc.

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

796 {
797  //
798  // Rebuilding of trajectories. Candidates are taken from result,
799  // which will be replaced with the solutions after rebuild
800  // (assume vector::swap is more efficient than building new container)
801  //
802  LogDebug("CkfPattern")<< "Starting to rebuild " << result.size() << " tracks";
803  //
804  // Fitter (need to create it here since the propagation direction
805  // might change between different starting trajectories)
806  //
808  //
809  TrajectorySeed::range rseedHits = seed.recHits();
810  std::vector<const TrackingRecHit*> seedHits;
811  //seedHits.insert(seedHits.end(), rseedHits.first, rseedHits.second);
812  //for (TrajectorySeed::recHitContainer::const_iterator iter = rseedHits.first; iter != rseedHits.second; iter++){
813  // seedHits.push_back(&*iter);
814  //}
815 
816  //unsigned int nSeed(seedHits.size());
817  unsigned int nSeed(rseedHits.second-rseedHits.first);
818  //seedHits.reserve(nSeed);
819  TempTrajectoryContainer rebuiltTrajectories;
820 
821  for ( TempTrajectoryContainer::iterator it=result.begin();
822  it!=result.end(); it++ ) {
823  //
824  // skip candidates which are not exceeding the seed size
825  // (e.g. because no Tracker layers outside seeding region)
826  //
827 
828  if ( it->measurements().size()<=startingTraj.measurements().size() ) {
829  rebuiltTrajectories.push_back(std::move(*it));
830  LogDebug("CkfPattern")<< "RebuildSeedingRegion skipped as in-out trajectory does not exceed seed size.";
831  continue;
832  }
833  //
834  // Refit - keep existing trajectory in case fit is not possible
835  // or fails
836  //
837 
838  auto && reFitted = backwardFit(*it,nSeed,fitter,seedHits);
839  if unlikely( !reFitted.isValid() ) {
840  rebuiltTrajectories.push_back(std::move(*it));
841  LogDebug("CkfPattern")<< "RebuildSeedingRegion skipped as backward fit failed";
842  // << "after reFitted.size() " << reFitted.size();
843  continue;
844  }
845  //LogDebug("CkfPattern")<<"after reFitted.size() " << reFitted.size();
846  //
847  // Rebuild seeding part. In case it fails: keep initial trajectory
848  // (better to drop it??)
849  //
850  int nRebuilt =
851  rebuildSeedingRegion (seed, seedHits,reFitted,rebuiltTrajectories);
852 
853  if ( nRebuilt==0 && !theKeepOriginalIfRebuildFails ) it->invalidate(); // won't use original in-out track
854 
855  if ( nRebuilt<0 ) rebuiltTrajectories.push_back(std::move(*it));
856 
857  }
858  //
859  // Replace input trajectories with new ones
860  //
861  result.swap(rebuiltTrajectories);
862  result.erase(std::remove_if( result.begin(),result.end(),
863  std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
864  result.end());
865 }
#define LogDebug(id)
const Propagator * theBackwardPropagator
#define unlikely(x)
Definition: Likely.h:21
tuple result
Definition: query.py:137
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
TempTrajectory backwardFit(TempTrajectory &candidate, unsigned int nSeed, const TrajectoryFitter &fitter, std::vector< const TrackingRecHit * > &remainingHits) const dso_internal
const TrajectoryStateUpdator & updator() const
int GroupedCkfTrajectoryBuilder::rebuildSeedingRegion ( const TrajectorySeed seed,
const std::vector< const TrackingRecHit * > &  seedHits,
TempTrajectory candidate,
TempTrajectoryContainer result 
) const
private

Definition at line 868 of file GroupedCkfTrajectoryBuilder.cc.

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

872 {
873  //
874  // Starting from track found by in-out tracking phase, extrapolate it inwards through
875  // the seeding region if possible in towards smaller Tracker radii, searching for additional
876  // hits.
877  // The resulting trajectories are returned in result,
878  // the count is the return value.
879  //
880  TempTrajectoryContainer rebuiltTrajectories;
881 #ifdef DBG2_GCTB
882 /* const LayerFinderByDet layerFinder;
883  if ( !seedHits.empty() && seedHits.front().isValid() ) {
884  DetLayer* seedLayer = layerFinder(seedHits.front().det());
885  cout << "Seed hit at " << seedHits.front().globalPosition()
886  << " " << seedLayer << endl;
887  cout << "Started from "
888  << candidate.lastMeasurement().updatedState().globalPosition().perp() << " "
889  << candidate.lastMeasurement().updatedState().globalPosition().z() << endl;
890  pair<bool,TrajectoryStateOnSurface> layerComp(false,TrajectoryStateOnSurface());
891  if ( seedLayer ) layerComp =
892  seedLayer->compatible(candidate.lastMeasurement().updatedState(),
893  propagator(),estimator());
894  pair<bool,TrajectoryStateOnSurface> detComp =
895  seedHits.front().det().compatible(candidate.lastMeasurement().updatedState(),
896  propagator(),estimator());
897  cout << " layer compatibility = " << layerComp.first;
898  cout << " det compatibility = " << detComp.first;
899  if ( detComp.first ) {
900  cout << " estimate = "
901  << estimator().estimate(detComp.second,seedHits.front()).second ;
902  }
903  cout << endl;
904  }*/
905  cout << "Before backward building: #measurements = "
906  << candidate.measurements().size() ; //<< endl;;
907 #endif
908  //
909  // Use standard building with standard cuts. Maybe better to use different
910  // cuts from "forward" building (e.g. no check on nr. of invalid hits)?
911  //
912  const bool inOut = false;
913  groupedLimitedCandidates(candidate, (const TrajectoryFilter*)0, theBackwardPropagator, inOut, rebuiltTrajectories);
914 
915  LogDebug("CkfPattern")<<" After backward building: "<<PrintoutHelper::dumpCandidates(rebuiltTrajectories);
916 
917  //
918  // Check & count resulting candidates
919  //
920  int nrOfTrajectories(0);
921  bool orig_ok = false;
922  //const RecHitEqualByChannels recHitEqual(false,false);
923  //vector<TM> oldMeasurements(candidate.measurements());
924  for ( TempTrajectoryContainer::iterator it=rebuiltTrajectories.begin();
925  it!=rebuiltTrajectories.end(); it++ ) {
926 
927  TempTrajectory::DataContainer newMeasurements(it->measurements());
928  //
929  // Verify presence of seeding hits?
930  //
932  orig_ok = true;
933  // no hits found (and possibly some invalid hits discarded): drop track
934  if ( newMeasurements.size()<=candidate.measurements().size() ){
935  LogDebug("CkfPattern") << "newMeasurements.size()<=candidate.measurements().size()";
936  continue;
937  }
938  // verify presence of hits
939  //GIO//if ( !verifyHits(newMeasurements.begin()+candidate.measurements().size(),
940  //GIO// newMeasurements.end(),seedHits) ){
941  if ( !verifyHits(newMeasurements.rbegin(),
942  newMeasurements.size() - candidate.measurements().size(),
943  seedHits) ){
944  LogDebug("CkfPattern")<< "seed hits not found in rebuild";
945  continue;
946  }
947  }
948  //
949  // construct final trajectory in the right order
950  //
951  // save & count result
952  nrOfTrajectories++;
953  result.emplace_back(seed.direction());
954  TempTrajectory & reversedTrajectory = result.back();
955  reversedTrajectory.setNLoops(it->nLoops());
956  for (TempTrajectory::DataContainer::const_iterator im=newMeasurements.rbegin(), ed = newMeasurements.rend();
957  im != ed; --im ) {
958  reversedTrajectory.push(*im);
959  }
960 
961  LogDebug("CkgPattern")<<"New traj direction = " << reversedTrajectory.direction()<<"\n"
962  <<PrintoutHelper::dumpMeasurements(reversedTrajectory.measurements());
963  } // rebuiltTrajectories
964 
965  // If nrOfTrajectories = 0 and orig_ok = true, this means that a track was actually found on the
966  // out-in step (meeting those requirements) but did not have the seed hits in it.
967  // In this case when we return we will go ahead and use the original in-out track.
968 
969  // If nrOfTrajectories = 0 and orig_ok = false, this means that the out-in step failed to
970  // find any track. Two cases are a technical failure in fitting the original seed hits or
971  // because the track did not meet the out-in criteria (which may be stronger than the out-in
972  // criteria). In this case we will NOT allow the original in-out track to be used.
973 
974  if ( (nrOfTrajectories == 0) && orig_ok ) {
975  nrOfTrajectories = -1;
976  }
977  return nrOfTrajectories;
978 }
#define LogDebug(id)
PropagationDirection direction() const
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)
bool verifyHits(TempTrajectory::DataContainer::const_iterator rbegin, size_t maxDepth, const std::vector< const TrackingRecHit * > &hits) const dso_internal
Verifies presence of a RecHits in a range of TrajectoryMeasurements.
PropagationDirection direction() const
void groupedLimitedCandidates(TempTrajectory const &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const dso_internal
tuple result
Definition: query.py:137
std::vector< TempTrajectory > TempTrajectoryContainer
tuple cout
Definition: gather_cfg.py:121
size_type size() const
Definition: bqueue.h:167
void push(const TrajectoryMeasurement &tm)
void GroupedCkfTrajectoryBuilder::rebuildTrajectories ( TempTrajectory const &  startingTraj,
const TrajectorySeed seed,
TrajectoryContainer result 
) const
virtual

Reimplemented from BaseCkfTrajectoryBuilder.

Definition at line 217 of file GroupedCkfTrajectoryBuilder.cc.

References rebuildSeedingRegion().

Referenced by rebuildSeedingRegion().

218  {
220 
221  TrajectoryContainer final;
222 
223  work.reserve(result.size());
224  for (TrajectoryContainer::iterator traj=result.begin();
225  traj!=result.end(); ++traj) {
226  if(traj->isValid()) work.push_back(TempTrajectory(*traj));
227  }
228 
229  rebuildSeedingRegion(seed,startingTraj,work);
230  final.reserve(work.size());
231 
232  // better the seed to be always the same...
233  boost::shared_ptr<const TrajectorySeed> sharedSeed;
234  if (result.empty())
235  sharedSeed.reset(new TrajectorySeed(seed));
236  else sharedSeed = result.front().sharedSeed();
237 
238 
239  for (TempTrajectoryContainer::iterator traj=work.begin();
240  traj!=work.end(); ++traj) {
241  final.push_back(traj->toTrajectory()); final.back().setSharedSeed(sharedSeed);
242  }
243 
244  result.swap(final);
245 
246  statCount.rebuilt(result.size());
247 
248 }
tuple result
Definition: query.py:137
void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const
std::vector< TempTrajectory > TempTrajectoryContainer
std::vector< Trajectory > TrajectoryContainer
bool GroupedCkfTrajectoryBuilder::tkxor ( bool  a,
bool  b 
) const
inlineprivate

Definition at line 120 of file GroupedCkfTrajectoryBuilder.h.

References a, and b.

Referenced by groupedIntermediaryClean().

120 {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 TrajectoryBuilder.

Definition at line 174 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories(), and run_regression::ret.

175 {
177  ret.reserve(10);
178  buildTrajectories(seed, ret, 0);
179  return ret;
180 }
TempTrajectory buildTrajectories(const TrajectorySeed &seed, 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 194 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories().

195 {
196  buildTrajectories(seed,ret,0);
197 }
TempTrajectory buildTrajectories(const TrajectorySeed &seed, 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 183 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories(), and run_regression::ret.

185 {
187  ret.reserve(10);
188  RegionalTrajectoryFilter regionalCondition(region);
189  buildTrajectories(seed, ret, &regionalCondition);
190  return ret;
191 }
TempTrajectory buildTrajectories(const TrajectorySeed &seed, 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 200 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories().

203 {
204  RegionalTrajectoryFilter regionalCondition(region);
205  buildTrajectories(seed,ret,&regionalCondition);
206 }
TempTrajectory buildTrajectories(const TrajectorySeed &seed, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
const TrajectoryStateUpdator& GroupedCkfTrajectoryBuilder::updator ( ) const
inline

Definition at line 80 of file GroupedCkfTrajectoryBuilder.h.

References BaseCkfTrajectoryBuilder::theUpdator.

Referenced by rebuildSeedingRegion().

80 {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 1108 of file GroupedCkfTrajectoryBuilder.cc.

References LogDebug, and TrackingRecHit::some.

Referenced by rebuildSeedingRegion().

1111 {
1112  //
1113  // verify presence of the seeding hits
1114  //
1115  LogDebug("CkfPattern")<<"Checking for " << hits.size() << " hits in "
1116  << maxDepth << " measurements" << endl;
1117 
1119  while (maxDepth > 0) { --maxDepth; --rend; }
1120  for ( vector<const TrackingRecHit*>::const_iterator ir=hits.begin();
1121  ir!=hits.end(); ir++ ) {
1122  // assume that all seeding hits are valid!
1123  bool foundHit(false);
1124  for ( TempTrajectory::DataContainer::const_iterator im=rbegin; im!=rend; --im ) {
1125  if ( im->recHit()->isValid() && (*ir)->sharesInput(im->recHit()->hit(), TrackingRecHit::some) ) {
1126  foundHit = true;
1127  break;
1128  }
1129  }
1130  if ( !foundHit ) return false;
1131  }
1132  return true;
1133 }
#define LogDebug(id)

Member Data Documentation

float GroupedCkfTrajectoryBuilder::maxDPhiForLooperReconstruction
private

Definition at line 210 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

float GroupedCkfTrajectoryBuilder::maxPt2ForLooperReconstruction
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 208 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

bool GroupedCkfTrajectoryBuilder::theAlwaysUseInvalid
private

Definition at line 191 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

bool GroupedCkfTrajectoryBuilder::theBestHitOnly
private

Use only best hit / group when building segments

Definition at line 194 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 177 of file GroupedCkfTrajectoryBuilder.h.

Referenced by chiSquareCut().

TrajectoryFilter* GroupedCkfTrajectoryBuilder::theConfigurableCondition
private

Definition at line 172 of file GroupedCkfTrajectoryBuilder.h.

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

more measurements)

Definition at line 186 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 188 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and groupedLimitedCandidates().

bool GroupedCkfTrajectoryBuilder::theKeepOriginalIfRebuildFails
private

Keep original trajectory if rebuilding fails.

Definition at line 203 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and rebuildSeedingRegion().

bool GroupedCkfTrajectoryBuilder::theLockHits
private

Lock hits when building segments in a layer

Definition at line 193 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

float GroupedCkfTrajectoryBuilder::theLostHitPenalty
private

Chi**2 Penalty for each lost hit.

Definition at line 185 of file GroupedCkfTrajectoryBuilder.h.

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

double GroupedCkfTrajectoryBuilder::theMass
private

Mass hypothesis used for propagation

Definition at line 181 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 183 of file GroupedCkfTrajectoryBuilder.h.

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

unsigned int GroupedCkfTrajectoryBuilder::theMinNrOf2dHitsForRebuild
private

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

Definition at line 201 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 198 of file GroupedCkfTrajectoryBuilder.h.

Referenced by backwardFit(), and GroupedCkfTrajectoryBuilder().

double GroupedCkfTrajectoryBuilder::theptCut
private

ptCut

Definition at line 179 of file GroupedCkfTrajectoryBuilder.h.

Referenced by ptCut().

bool GroupedCkfTrajectoryBuilder::theRequireSeedHitsInRebuild
private

Only accept rebuilt trajectories if they contain the seed hits.

Definition at line 196 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and rebuildSeedingRegion().

TempTrajectoryContainer GroupedCkfTrajectoryBuilder::work_
mutableprivate

Definition at line 212 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().