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

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 23 of file GroupedCkfTrajectoryBuilder.h.

Member Enumeration Documentation

Enumerator
work_MaxSize_ 

Definition at line 199 of file GroupedCkfTrajectoryBuilder.h.

199 { 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 61 of file GroupedCkfTrajectoryBuilder.cc.

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

69  :
70 
71 
73  updator, propagatorAlong,propagatorOpposite,
74  estimator, recHitBuilder, measurementTracker, filter, inOutFilter)
75 {
76  // fill data members from parameters (eventually data members could be dropped)
77  //
78  theMaxCand = conf.getParameter<int>("maxCand");
79 
80  theLostHitPenalty = conf.getParameter<double>("lostHitPenalty");
81  theFoundHitBonus = conf.getParameter<double>("foundHitBonus");
82  theIntermediateCleaning = conf.getParameter<bool>("intermediateCleaning");
83  theAlwaysUseInvalid = conf.getParameter<bool>("alwaysUseInvalidHits");
84  theLockHits = conf.getParameter<bool>("lockHits");
85  theBestHitOnly = conf.getParameter<bool>("bestHitOnly");
87  theRequireSeedHitsInRebuild = conf.getParameter<bool>("requireSeedHitsInRebuild");
88  theMinNrOfHitsForRebuild = max(0,conf.getParameter<int>("minNrOfHitsForRebuild"));
89 
90  /* ======= B.M. to be ported layer ===========
91  bool setOK = thePropagator->setMaxDirectionChange(1.6);
92  if (!setOK)
93  cout << "GroupedCkfTrajectoryBuilder WARNING: "
94  << "propagator does not support setMaxDirectionChange"
95  << endl;
96  // addStopCondition(theMinPtStopCondition);
97 
98  theConfigurableCondition = createAlgo<TrajectoryFilter>(componentConfig("StopCondition"));
99  ===================================== */
100 
101 }
T getParameter(std::string const &) const
BaseCkfTrajectoryBuilder(const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const MeasurementTracker *measurementTracker, const TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter=0)
const T & max(const T &a, const T &b)
virtual GroupedCkfTrajectoryBuilder::~GroupedCkfTrajectoryBuilder ( )
inlinevirtual

destructor

Definition at line 38 of file GroupedCkfTrajectoryBuilder.h.

38 {}
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 338 of file GroupedCkfTrajectoryBuilder.cc.

References BaseCkfTrajectoryBuilder::addToResult(), TransverseImpactPointExtrapolator::extrapolate(), BaseCkfTrajectoryBuilder::findStateAndLayers(), TempTrajectory::foundHits(), cmsutils::bqueue< T >::front(), TrajectoryStateOnSurface::isValid(), TempTrajectory::lastLayer(), LogDebug, TrackingRecHit::missing, TempTrajectory::push(), TrajectoryMeasurement::recHit(), TrajectorySegmentBuilder::segments(), cmsutils::bqueue< T >::size(), theAlwaysUseInvalid, theBestHitOnly, BaseCkfTrajectoryBuilder::theEstimator, BaseCkfTrajectoryBuilder::theForwardPropagator, BaseCkfTrajectoryBuilder::theLayerMeasurements, theLockHits, BaseCkfTrajectoryBuilder::theMeasurementTracker, BaseCkfTrajectoryBuilder::theUpdator, BaseCkfTrajectoryBuilder::toBeContinued(), whatIsTheNextStep(), and whatIsTheStateToUse().

Referenced by groupedLimitedCandidates().

344 {
345  std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers = findStateAndLayers(traj);
346  vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
347  vector<const DetLayer*>::iterator layerEnd = stateAndLayers.second.end();
348 
349  // if (nl.empty()) {
350  // addToResult(traj,result,inOut);
351  // return false;
352  // }
353 
354  LogDebug("CkfPattern")<<whatIsTheNextStep(traj, stateAndLayers);
355 
356  bool foundSegments(false);
357  bool foundNewCandidates(false);
358  for ( vector<const DetLayer*>::iterator il=layerBegin;
359  il!=layerEnd; il++) {
360 
361  TSOS stateToUse = stateAndLayers.first;
362  if ((*il)==traj.lastLayer())
363  {
364  LogDebug("CkfPattern")<<" self propagating in advanceOneLayer.\n from: \n"<<stateToUse;
365  //self navigation case
366  // go to a middle point first
368  GlobalPoint center(0,0,0);
369  stateToUse = middle.extrapolate(stateToUse, center, *theForwardPropagator);
370 
371  if (!stateToUse.isValid()) continue;
372  LogDebug("CkfPattern")<<"to: "<<stateToUse;
373  }
374 
377  **il,*propagator,
380 
381  LogDebug("CkfPattern")<<whatIsTheStateToUse(stateAndLayers.first,stateToUse,*il);
382 
383  TempTrajectoryContainer segments=
384  layerBuilder.segments(stateToUse);
385 
386  LogDebug("CkfPattern")<< "GCTB: number of segments = " << segments.size();
387 
388  if ( !segments.empty() ) foundSegments = true;
389 
390  for ( TempTrajectoryContainer::const_iterator is=segments.begin();
391  is!=segments.end(); is++ ) {
392  //
393  // assume "invalid hit only" segment is last in list
394  //
395  const TempTrajectory::DataContainer & measurements = is->measurements();
396  if ( !theAlwaysUseInvalid && is!=segments.begin() && measurements.size()==1 &&
397  (measurements.front().recHit()->getType() == TrackingRecHit::missing) ) break;
398  //
399  // create new candidate
400  //
401  TempTrajectory newTraj(traj);
402 
403  newTraj.push(*is);
404  //GIO// for ( vector<TM>::const_iterator im=measurements.begin();
405  //GIO// im!=measurements.end(); im++ ) newTraj.push(*im);
406  //if ( toBeContinued(newTraj,regionalCondition) ) { TOBE FIXED
407  if ( toBeContinued(newTraj, inOut) ) {
408  // Have added one more hit to track candidate
409 
410  LogDebug("CkfPattern")<<"GCTB: adding updated trajectory to candidates: inOut="<<inOut<<" hits="<<newTraj.foundHits();
411 
412  newCand.push_back(newTraj);
413  foundNewCandidates = true;
414  }
415  else {
416  // Have finished building this track. Check if it passes cuts.
417 
418  LogDebug("CkfPattern")<< "GCTB: adding completed trajectory to results if passes cuts: inOut="<<inOut<<" hits="<<newTraj.foundHits();
419 
420  addToResult(newTraj, result, inOut);
421  }
422  }
423  }
424 
425  if ( !foundSegments ){
426  LogDebug("CkfPattern")<< "GCTB: adding input trajectory to result";
427  addToResult(traj, result, inOut);
428  }
429  return foundNewCandidates;
430 }
#define LogDebug(id)
void addToResult(TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
const TrajectoryStateUpdator * theUpdator
ConstRecHitPointer recHit() const
std::string whatIsTheNextStep(TempTrajectory &traj, std::pair< TrajectoryStateOnSurface, std::vector< const DetLayer * > > &stateAndLayers)
const LayerMeasurements * theLayerMeasurements
tuple result
Definition: query.py:137
std::string whatIsTheStateToUse(TrajectoryStateOnSurface &initial, TrajectoryStateOnSurface &stateToUse, const DetLayer *l)
const MeasurementTracker * theMeasurementTracker
std::vector< TempTrajectory > TempTrajectoryContainer
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
StateAndLayers findStateAndLayers(const TempTrajectory &traj) const
size_type size() const
Definition: bqueue.h:143
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const Chi2MeasurementEstimatorBase * theEstimator
const Propagator * theForwardPropagator
virtual void GroupedCkfTrajectoryBuilder::analyseMeasurements ( const std::vector< TM > &  meas,
const Trajectory traj 
) const
inlineprotectedvirtual

Definition at line 93 of file GroupedCkfTrajectoryBuilder.h.

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

Definition at line 95 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().

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

Definition at line 91 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().

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

Definition at line 753 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(), oppositeDirection(), Trajectory::push(), Trajectory::recHits(), TrajectoryStateOnSurface::rescaleError(), Trajectory::seed(), TempTrajectory::seed(), cmsutils::bqueue< T >::size(), theMinNrOfHitsForRebuild, and TrajectoryMeasurement::updatedState().

Referenced by rebuildSeedingRegion().

757 {
758  //
759  // clear array of non-fitted hits
760  //
761  remainingHits.clear();
762  fittedTracks.clear();
763  //
764  // skip candidates which are not exceeding the seed size
765  // (e.g. Because no Tracker layers exist outside seeding region)
766  //
767  if ( candidate.measurements().size()<=nSeed ) {
768  fittedTracks.clear();
769  return;
770  }
771 
772  LogDebug("CkfPattern")<<"nSeed " << nSeed << endl
773  << "Old traj direction = " << candidate.direction() << endl
775 
776  //
777  // backward fit trajectory.
778  // (Will try to fit only hits outside the seeding region. However,
779  // if there are not enough of these, it will also use the seeding hits).
780  //
781  TempTrajectory::DataContainer oldMeasurements(candidate.measurements());
782 // int nOld(oldMeasurements.size());
783 // const unsigned int nHitAllMin(5);
784 // const unsigned int nHit2dMin(2);
785  unsigned int nHit(0); // number of valid hits after seeding region
786  //unsigned int nHit2d(0); // number of valid hits after seeding region with 2D info
787  // use all hits except the first n (from seed), but require minimum
788  // specified in configuration.
789  // Swapped over next two lines.
790  unsigned int nHitMin = max(candidate.foundHits()-nSeed,theMinNrOfHitsForRebuild);
791  // unsigned int nHitMin = oldMeasurements.size()-nSeed;
792  // we want to rebuild only if the number of VALID measurements excluding the seed measurements is higher than the cut
793  if (nHitMin<theMinNrOfHitsForRebuild){
794  fittedTracks.clear();
795  return;
796  }
797 
798  LogDebug("CkfPattern")/* << "nHitMin " << nHitMin*/ <<"Sizes: " << oldMeasurements.size() << " / ";
799  //
800  // create input trajectory for backward fit
801  //
802  Trajectory fwdTraj(candidate.seed(),oppositeDirection(candidate.direction()));
803  //const TrajectorySeed seed = TrajectorySeed(PTrajectoryStateOnDet(), TrajectorySeed::recHitContainer(), oppositeDirection(candidate.direction()));
804  //Trajectory fwdTraj(seed, oppositeDirection(candidate.direction()));
805  std::vector<const DetLayer*> bwdDetLayer;
806  for ( TempTrajectory::DataContainer::const_iterator im=oldMeasurements.rbegin();
807  im!=oldMeasurements.rend(); --im) {
808  const TrackingRecHit* hit = im->recHit()->hit();
809  //
810  // add hits until required number is reached
811  //
812  if ( nHit<nHitMin ){//|| nHit2d<theMinNrOf2dHitsForRebuild ) {
813  fwdTraj.push(*im);
814  bwdDetLayer.push_back(im->layer());
815  //
816  // count valid / 2D hits
817  //
818  if ( hit->isValid() ) {
819  nHit++;
820  //if ( hit.isMatched() ||
821  // hit.det().detUnits().front()->type().module()==pixel )
822  //nHit2d++;
823  }
824  }
825  //if (nHit==nHitMin) lastBwdDetLayer=im->layer();
826  //
827  // keep remaining (valid) hits for verification
828  //
829  else if ( hit->isValid() ) {
830  //std::cout << "Adding a remaining hit" << std::endl;
831  remainingHits.push_back(hit);
832  }
833  }
834  //
835  // Fit only if required number of valid hits can be used
836  //
837  if ( nHit<nHitMin ){ //|| nHit2d<theMinNrOf2dHitsForRebuild ) {
838  fittedTracks.clear();
839  return;
840  }
841  //
842  // Do the backward fit (important: start from scaled, not random cov. matrix!)
843  //
844  TrajectoryStateOnSurface firstTsos(fwdTraj.firstMeasurement().updatedState());
845  //cout << "firstTsos "<< firstTsos << endl;
846  firstTsos.rescaleError(10.);
847  //TrajectoryContainer bwdFitted(fitter.fit(fwdTraj.seed(),fwdTraj.recHits(),firstTsos));
848  TrajectoryContainer bwdFitted(fitter.fit(
850  fwdTraj.recHits(),firstTsos));
851  if (bwdFitted.size()){
852  LogDebug("CkfPattern")<<"Obtained " << bwdFitted.size() << " bwdFitted trajectories with measurement size " << bwdFitted.front().measurements().size();
853  TempTrajectory fitted(fwdTraj.seed(), fwdTraj.direction());
854  vector<TM> tmsbf = bwdFitted.front().measurements();
855  int iDetLayer=0;
856  //this is ugly but the TM in the fitted track do not contain the DetLayer.
857  //So we have to cache the detLayer pointers and replug them in.
858  //For the backward building it would be enaugh to cache the last DetLayer,
859  //but for the intermediary cleaning we need all
860  for ( vector<TM>::const_iterator im=tmsbf.begin();im!=tmsbf.end(); im++ ) {
861  fitted.push(TM( (*im).forwardPredictedState(),
862  (*im).backwardPredictedState(),
863  (*im).updatedState(),
864  (*im).recHit(),
865  (*im).estimate(),
866  bwdDetLayer[iDetLayer]));
867 
868  LogDebug("CkfPattern")<<PrintoutHelper::dumpMeasurement(*im);
869  iDetLayer++;
870  }
871 /*
872  TM lastMeas = bwdFitted.front().lastMeasurement();
873  fitted.pop();
874  fitted.push(TM(lastMeas.forwardPredictedState(),
875  lastMeas.backwardPredictedState(),
876  lastMeas.updatedState(),
877  lastMeas.recHit(),
878  lastMeas.estimate(),
879  lastBwdDetLayer));*/
880  fittedTracks.push_back(fitted);
881  }
882  //
883  // save result
884  //
885  //fittedTracks.swap(bwdFitted);
886  //cout << "Obtained " << fittedTracks.size() << " fittedTracks trajectories with measurement size " << fittedTracks.front().measurements().size() << endl;
887 }
#define LogDebug(id)
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
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
size_type size() const
Definition: bqueue.h:143
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 172 of file GroupedCkfTrajectoryBuilder.cc.

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

Referenced by trajectories().

175 {
176  //
177  // Build trajectory outwards from seed
178  //
179 
180  analyseSeed( seed);
181 
182  TempTrajectory startingTraj = createStartingTrajectory( seed);
183 
184  work_.clear();
185  const bool inOut = true;
186  groupedLimitedCandidates( startingTraj, regionalCondition, theForwardPropagator, inOut, work_);
187  if ( work_.empty() ) return ;
188 
189 
190 
191  /* rebuilding is de-coupled from standard building
192  //
193  // try to additional hits in the seeding region
194  //
195  if ( theMinNrOfHitsForRebuild>0 ) {
196  // reverse direction
197  //thePropagator->setPropagationDirection(oppositeDirection(seed.direction()));
198  // rebuild part of the trajectory
199  rebuildSeedingRegion(startingTraj,work);
200  }
201 
202  */
203 
204  result.reserve(work_.size());
205  for (TempTrajectoryContainer::const_iterator it = work_.begin(), ed = work_.end(); it != ed; ++it) {
206  result.push_back( it->toTrajectory() );
207  }
208 
209  work_.clear();
210  if (work_.capacity() > work_MaxSize_) { TempTrajectoryContainer().swap(work_); work_.reserve(work_MaxSize_/2); }
211 
213 
214  LogDebug("CkfPattern")<< "GroupedCkfTrajectoryBuilder: returning result of size " << result.size();
215 
216 }
#define LogDebug(id)
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
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 71 of file GroupedCkfTrajectoryBuilder.h.

References theChiSquareCut.

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

Definition at line 66 of file GroupedCkfTrajectoryBuilder.h.

References BaseCkfTrajectoryBuilder::theEstimator.

Referenced by rebuildSeedingRegion().

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

intermediate cleaning in the case of grouped measurements

recHitEqualByChannels(im1->recHit(),im2->recHit()) ) {

recHitEqualByChannels(im1->recHit(),im2->recHit()) ) {

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

435 {
436  //if (theTrajectories.empty()) return TrajectoryContainer();
437  //TrajectoryContainer result;
438  if (theTrajectories.empty()) return;
439  //RecHitEqualByChannels recHitEqualByChannels(false, false);
440  int firstLayerSize, secondLayerSize;
441  vector<const DetLayer*> firstLayers, secondLayers;
442 
443  for (TempTrajectoryContainer::iterator firstTraj=theTrajectories.begin();
444  firstTraj!=(theTrajectories.end()-1); firstTraj++) {
445 
446  if ( (!firstTraj->isValid()) ||
447  (!firstTraj->lastMeasurement().recHit()->isValid()) ) continue;
448  const TempTrajectory::DataContainer & firstMeasurements = firstTraj->measurements();
449  layers(firstMeasurements, firstLayers);
450  firstLayerSize = firstLayers.size();
451  if ( firstLayerSize<4 ) continue;
452 
453  for (TempTrajectoryContainer::iterator secondTraj=(firstTraj+1);
454  secondTraj!=theTrajectories.end(); secondTraj++) {
455 
456  if ( (!secondTraj->isValid()) ||
457  (!secondTraj->lastMeasurement().recHit()->isValid()) ) continue;
458  const TempTrajectory::DataContainer & secondMeasurements = secondTraj->measurements();
459  layers(secondMeasurements, secondLayers);
460  secondLayerSize = secondLayers.size();
461  //
462  // only candidates using the same last 3 layers are compared
463  //
464  if ( firstLayerSize!=secondLayerSize ) continue;
465  if ( firstLayers[0]!=secondLayers[0] ||
466  firstLayers[1]!=secondLayers[1] ||
467  firstLayers[2]!=secondLayers[2] ) continue;
468 
469  TempTrajectory::DataContainer::const_iterator im1 = firstMeasurements.rbegin();
470  TempTrajectory::DataContainer::const_iterator im2 = secondMeasurements.rbegin();
471  //
472  // check for identical hits in the last layer
473  //
474  bool unequal(false);
475  const DetLayer* layerPtr = firstLayers[0];
476  while ( im1!=firstMeasurements.rend()&&im2!=secondMeasurements.rend() ) {
477  if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr ) break;
478  if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
480  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some) ) {
481  unequal = true;
482  break;
483  }
484  --im1;
485  --im2;
486  }
487  if ( im1==firstMeasurements.rend() || im2==secondMeasurements.rend() ||
488  im1->layer()==layerPtr || im2->layer()==layerPtr || unequal ) continue;
489  //
490  // check for invalid hits in the layer -2
491  // compare only candidates with invalid / valid combination
492  //
493  layerPtr = firstLayers[1];
494  bool firstValid(true);
495  while ( im1!=firstMeasurements.rend()&&im1->layer()==layerPtr ) {
496  if ( !im1->recHit()->isValid() ) firstValid = false;
497  --im1;
498  }
499  bool secondValid(true);
500  while ( im2!=secondMeasurements.rend()&&im2->layer()==layerPtr ) {
501  if ( !im2->recHit()->isValid() ) secondValid = false;
502  --im2;
503  }
504  if ( !tkxor(firstValid,secondValid) ) continue;
505  //
506  // ask for identical hits in layer -3
507  //
508  unequal = false;
509  layerPtr = firstLayers[2];
510  while ( im1!=firstMeasurements.rend()&&im2!=secondMeasurements.rend() ) {
511  if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr ) break;
512  if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
514  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some) ) {
515  unequal = true;
516  break;
517  }
518  --im1;
519  --im2;
520  }
521  if ( im1==firstMeasurements.rend() || im2==secondMeasurements.rend() ||
522  im1->layer()==layerPtr || im2->layer()==layerPtr || unequal ) continue;
523 
524  if ( !firstValid ) {
525  firstTraj->invalidate();
526  break;
527  }
528  else {
529  secondTraj->invalidate();
530  break;
531  }
532  }
533  }
534 /*
535  for (TempTrajectoryContainer::const_iterator it = theTrajectories.begin();
536  it != theTrajectories.end(); it++) {
537  if(it->isValid()) result.push_back( *it);
538  }
539 
540  return result;
541 */
542  theTrajectories.erase(std::remove_if( theTrajectories.begin(),theTrajectories.end(),
543  std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
544  // boost::bind(&TempTrajectory::isValid,_1)),
545  theTrajectories.end());
546 }
const_iterator rend() const
Definition: bqueue.h:142
bool isValid() const
iterator rbegin()
Definition: bqueue.h:140
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 220 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().

225 {
226  unsigned int nIter=1;
227  TempTrajectoryContainer candidates;
228  TempTrajectoryContainer newCand;
229  candidates.push_back( startingTraj);
230 
231  while ( !candidates.empty()) {
232 
233  newCand.clear();
234  for (TempTrajectoryContainer::iterator traj=candidates.begin();
235  traj!=candidates.end(); traj++) {
236  if ( !advanceOneLayer(*traj, regionalCondition, propagator, inOut, newCand, result) ) {
237  LogDebug("CkfPattern")<< "GCTB: terminating after advanceOneLayer==false";
238  continue;
239  }
240 
241  LogDebug("CkfPattern")<<"newCand(1): after advanced one layer:\n"<<PrintoutHelper::dumpCandidates(newCand);
242 
243  if ((int)newCand.size() > theMaxCand) {
244  //ShowCand()(newCand);
245 
246  sort( newCand.begin(), newCand.end(), GroupedTrajCandLess(theLostHitPenalty,theFoundHitBonus));
247  newCand.erase( newCand.begin()+theMaxCand, newCand.end());
248  }
249  LogDebug("CkfPattern")<<"newCand(2): after removing extra candidates.\n"<<PrintoutHelper::dumpCandidates(newCand);
250  }
251 
252  LogDebug("CkfPattern") << "newCand.size() at end = " << newCand.size();
253 /*
254  if (theIntermediateCleaning) {
255  candidates.clear();
256  candidates = groupedIntermediaryClean(newCand);
257  } else {
258  candidates.swap(newCand);
259  }
260 */
262 #ifdef STANDARD_INTERMEDIARYCLEAN
264 #else
265  groupedIntermediaryClean(newCand);
266 #endif
267 
268  }
269  candidates.swap(newCand);
270 
271  LogDebug("CkfPattern") <<"candidates(3): "<<result.size()<<" candidates after "<<nIter++<<" groupedCKF iteration: \n"
273  <<"\n "<<candidates.size()<<" running candidates are: \n"
274  <<PrintoutHelper::dumpCandidates(candidates);
275  }
276 }
#define LogDebug(id)
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
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 549 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().

551 {
552  result.clear();
553 
554  if ( measurements.empty() ) return ;
555 
556  result.push_back(measurements.back().layer());
558  --ifirst;
560  im!=measurements.rend(); --im ) {
561  if ( im->layer()!=result.back() ) result.push_back(im->layer());
562  }
563 
564  for (vector<const DetLayer*>::const_iterator iter = result.begin(); iter != result.end(); iter++){
565  if (!*iter) edm::LogWarning("CkfPattern")<< "Warning: null det layer!! ";
566  }
567 }
const_iterator rend() const
Definition: bqueue.h:142
bool empty() const
Definition: bqueue.h:144
tuple result
Definition: query.py:137
const DetLayer * layer() const
iterator rbegin()
Definition: bqueue.h:140
float GroupedCkfTrajectoryBuilder::lostHitPenalty ( )
inline

Chi**2 Penalty for each lost hit.

Definition at line 78 of file GroupedCkfTrajectoryBuilder.h.

References theLostHitPenalty.

double GroupedCkfTrajectoryBuilder::mass ( )
inline

Mass hypothesis used for propagation.

Definition at line 87 of file GroupedCkfTrajectoryBuilder.h.

References theMass.

int GroupedCkfTrajectoryBuilder::maxCand ( )
inline

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

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

References alongMomentum, dir, and oppositeToMomentum.

Referenced by backwardFit().

157  {
158  if ( dir==alongMomentum ) return oppositeToMomentum;
159  else if ( dir==oppositeToMomentum ) return alongMomentum;
160  return dir;
161  }
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 84 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 146 of file GroupedCkfTrajectoryBuilder.cc.

References BaseCkfTrajectoryBuilder::createStartingTrajectory().

Referenced by rebuildSeedingRegion().

147  {
148  TempTrajectory startingTraj = createStartingTrajectory( seed);
150 
151  TrajectoryContainer final;
152 
153  work.reserve(result.size());
154  for (TrajectoryContainer::iterator traj=result.begin();
155  traj!=result.end(); ++traj) {
156  if(traj->isValid()) work.push_back(TempTrajectory(*traj));
157  }
158 
159  rebuildSeedingRegion(startingTraj,work);
160  final.reserve(work.size());
161 
162  for (TempTrajectoryContainer::iterator traj=work.begin();
163  traj!=work.end(); ++traj) {
164  final.push_back(traj->toTrajectory());
165  }
166 
167  result.swap(final);
168 
169 }
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 570 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().

572 {
573  //
574  // Rebuilding of trajectories. Candidates are taken from result,
575  // which will be replaced with the solutions after rebuild
576  // (assume vector::swap is more efficient than building new container)
577  //
578  LogDebug("CkfPattern")<< "Starting to rebuild " << result.size() << " tracks";
579  //
580  // Fitter (need to create it here since the propagation direction
581  // might change between different starting trajectories)
582  //
584  //
585  TempTrajectoryContainer reFitted;
586  TrajectorySeed::range rseedHits = startingTraj.seed().recHits();
587  std::vector<const TrackingRecHit*> seedHits;
588  //seedHits.insert(seedHits.end(), rseedHits.first, rseedHits.second);
589  //for (TrajectorySeed::recHitContainer::const_iterator iter = rseedHits.first; iter != rseedHits.second; iter++){
590  // seedHits.push_back(&*iter);
591  //}
592 
593  //unsigned int nSeed(seedHits.size());
594  unsigned int nSeed(rseedHits.second-rseedHits.first);
595  //seedHits.reserve(nSeed);
596  TempTrajectoryContainer rebuiltTrajectories;
597  for ( TempTrajectoryContainer::iterator it=result.begin();
598  it!=result.end(); it++ ) {
599  //
600  // skip candidates which are not exceeding the seed size
601  // (e.g. because no Tracker layers outside seeding region)
602  //
603 
604  if ( it->measurements().size()<=startingTraj.measurements().size() ) {
605  rebuiltTrajectories.push_back(*it);
606  LogDebug("CkfPattern")<< "RebuildSeedingRegion skipped as in-out trajectory does not exceed seed size.";
607  continue;
608  }
609  //
610  // Refit - keep existing trajectory in case fit is not possible
611  // or fails
612  //
613  backwardFit(*it,nSeed,fitter,reFitted,seedHits);
614  if ( reFitted.size()!=1 ) {
615  rebuiltTrajectories.push_back(*it);
616  LogDebug("CkfPattern")<< "RebuildSeedingRegion skipped as backward fit failed";
617  // << "after reFitted.size() " << reFitted.size();
618  continue;
619  }
620  //LogDebug("CkfPattern")<<"after reFitted.size() " << reFitted.size();
621  //
622  // Rebuild seeding part. In case it fails: keep initial trajectory
623  // (better to drop it??)
624  //
625  int nRebuilt =
626  rebuildSeedingRegion (seedHits,reFitted.front(),rebuiltTrajectories);
627 
628  if ( nRebuilt==0 ) it->invalidate(); // won't use original in-out track
629 
630  if ( nRebuilt<=0 ) rebuiltTrajectories.push_back(*it);
631 
632  }
633  //
634  // Replace input trajectories with new ones
635  //
636  result.swap(rebuiltTrajectories);
637  result.erase(std::remove_if( result.begin(),result.end(),
638  std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
639  result.end());
640 }
#define LogDebug(id)
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
size_type size() const
Definition: bqueue.h:143
int GroupedCkfTrajectoryBuilder::rebuildSeedingRegion ( const std::vector< const TrackingRecHit * > &  seedHits,
TempTrajectory candidate,
TempTrajectoryContainer result 
) const
private

Definition at line 643 of file GroupedCkfTrajectoryBuilder.cc.

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

646 {
647  //
648  // Starting from track found by in-out tracking phase, extrapolate it inwards through
649  // the seeding region if possible in towards smaller Tracker radii, searching for additional
650  // hits.
651  // The resulting trajectories are returned in result,
652  // the count is the return value.
653  //
654  TempTrajectoryContainer rebuiltTrajectories;
655 #ifdef DBG2_GCTB
656 /* const LayerFinderByDet layerFinder;
657  if ( !seedHits.empty() && seedHits.front().isValid() ) {
658  DetLayer* seedLayer = layerFinder(seedHits.front().det());
659  cout << "Seed hit at " << seedHits.front().globalPosition()
660  << " " << seedLayer << endl;
661  cout << "Started from "
662  << candidate.lastMeasurement().updatedState().globalPosition().perp() << " "
663  << candidate.lastMeasurement().updatedState().globalPosition().z() << endl;
664  pair<bool,TrajectoryStateOnSurface> layerComp(false,TrajectoryStateOnSurface());
665  if ( seedLayer ) layerComp =
666  seedLayer->compatible(candidate.lastMeasurement().updatedState(),
667  propagator(),estimator());
668  pair<bool,TrajectoryStateOnSurface> detComp =
669  seedHits.front().det().compatible(candidate.lastMeasurement().updatedState(),
670  propagator(),estimator());
671  cout << " layer compatibility = " << layerComp.first;
672  cout << " det compatibility = " << detComp.first;
673  if ( detComp.first ) {
674  cout << " estimate = "
675  << estimator().estimate(detComp.second,seedHits.front()).second ;
676  }
677  cout << endl;
678  }*/
679  cout << "Before backward building: #measurements = "
680  << candidate.measurements().size() ; //<< endl;;
681 #endif
682  //
683  // Use standard building with standard cuts. Maybe better to use different
684  // cuts from "forward" building (e.g. no check on nr. of invalid hits)?
685  //
686  const bool inOut = false;
687  groupedLimitedCandidates(candidate, (const TrajectoryFilter*)0, theBackwardPropagator, inOut, rebuiltTrajectories);
688 
689  LogDebug("CkfPattern")<<" After backward building: "<<PrintoutHelper::dumpCandidates(rebuiltTrajectories);
690 
691  //
692  // Check & count resulting candidates
693  //
694  int nrOfTrajectories(0);
695  bool orig_ok = false;
696  //const RecHitEqualByChannels recHitEqual(false,false);
697  //vector<TM> oldMeasurements(candidate.measurements());
698  for ( TempTrajectoryContainer::iterator it=rebuiltTrajectories.begin();
699  it!=rebuiltTrajectories.end(); it++ ) {
700 
701  TempTrajectory::DataContainer newMeasurements(it->measurements());
702  //
703  // Verify presence of seeding hits?
704  //
706  orig_ok = true;
707  // no hits found (and possibly some invalid hits discarded): drop track
708  if ( newMeasurements.size()<=candidate.measurements().size() ){
709  LogDebug("CkfPattern") << "newMeasurements.size()<=candidate.measurements().size()";
710  continue;
711  }
712  // verify presence of hits
713  //GIO//if ( !verifyHits(newMeasurements.begin()+candidate.measurements().size(),
714  //GIO// newMeasurements.end(),seedHits) ){
715  if ( !verifyHits(newMeasurements.rbegin(),
716  newMeasurements.size() - candidate.measurements().size(),
717  seedHits) ){
718  LogDebug("CkfPattern")<< "seed hits not found in rebuild";
719  continue;
720  }
721  }
722  //
723  // construct final trajectory in the right order
724  //
725  TempTrajectory reversedTrajectory(it->seed(),it->seed().direction());
726  for (TempTrajectory::DataContainer::const_iterator im=newMeasurements.rbegin(), ed = newMeasurements.rend();
727  im != ed; --im ) {
728  reversedTrajectory.push(*im);
729  }
730  // save & count result
731  result.push_back(reversedTrajectory);
732  nrOfTrajectories++;
733 
734  LogDebug("CkgPattern")<<"New traj direction = " << reversedTrajectory.direction()<<"\n"
735  <<PrintoutHelper::dumpMeasurements(reversedTrajectory.measurements());
736  }
737  // If nrOfTrajectories = 0 and orig_ok = true, this means that a track was actually found on the
738  // out-in step (meeting those requirements) but did not have the seed hits in it.
739  // In this case when we return we will go ahead and use the original in-out track.
740 
741  // If nrOfTrajectories = 0 and orig_ok = false, this means that the out-in step failed to
742  // find any track. Two cases are a technical failure in fitting the original seed hits or
743  // because the track did not meet the out-in criteria (which may be stronger than the out-in
744  // criteria). In this case we will NOT allow the original in-out track to be used.
745 
746  if ( (nrOfTrajectories == 0) && orig_ok ) {
747  nrOfTrajectories = -1;
748  }
749  return nrOfTrajectories;
750 }
#define LogDebug(id)
static std::string dumpCandidates(collection &candidates)
const Propagator * theBackwardPropagator
const DataContainer & measurements() const
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
tuple cout
Definition: gather_cfg.py:41
size_type size() const
Definition: bqueue.h:143
void push(const TrajectoryMeasurement &tm)
bool GroupedCkfTrajectoryBuilder::tkxor ( bool  a,
bool  b 
) const
inlineprivate

Definition at line 109 of file GroupedCkfTrajectoryBuilder.h.

References b.

Referenced by groupedIntermediaryClean().

109 {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 111 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories(), and runTheMatrix::ret.

112 {
114  ret.reserve(10);
115  buildTrajectories(seed, ret, 0);
116  return ret;
117 }
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 131 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories().

132 {
133  buildTrajectories(seed,ret,0);
134 }
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 120 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories(), and runTheMatrix::ret.

122 {
124  ret.reserve(10);
125  RegionalTrajectoryFilter regionalCondition(region);
126  buildTrajectories(seed, ret, &regionalCondition);
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 TrackingRegion region 
) const

trajectories building starting from a seed with a region

Definition at line 137 of file GroupedCkfTrajectoryBuilder.cc.

References buildTrajectories().

140 {
141  RegionalTrajectoryFilter regionalCondition(region);
142  buildTrajectories(seed,ret,&regionalCondition);
143 }
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 65 of file GroupedCkfTrajectoryBuilder.h.

References BaseCkfTrajectoryBuilder::theUpdator.

Referenced by rebuildSeedingRegion().

65 {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 890 of file GroupedCkfTrajectoryBuilder.cc.

References LogDebug, and TrackingRecHit::some.

Referenced by rebuildSeedingRegion().

893 {
894  //
895  // verify presence of the seeding hits
896  //
897  LogDebug("CkfPattern")<<"Checking for " << hits.size() << " hits in "
898  << maxDepth << " measurements" << endl;
899 
901  while (maxDepth > 0) { --maxDepth; --rend; }
902  for ( vector<const TrackingRecHit*>::const_iterator ir=hits.begin();
903  ir!=hits.end(); ir++ ) {
904  // assume that all seeding hits are valid!
905  bool foundHit(false);
906  for ( TempTrajectory::DataContainer::const_iterator im=rbegin; im!=rend; --im ) {
907  if ( im->recHit()->isValid() && (*ir)->sharesInput(im->recHit()->hit(), TrackingRecHit::some) ) {
908  foundHit = true;
909  break;
910  }
911  }
912  if ( !foundHit ) return false;
913  }
914  return true;
915 }
#define LogDebug(id)

Member Data Documentation

bool GroupedCkfTrajectoryBuilder::theAlwaysUseInvalid
private

Definition at line 184 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

bool GroupedCkfTrajectoryBuilder::theBestHitOnly
private

Use only best hit / group when building segments

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

Referenced by chiSquareCut().

TrajectoryFilter* GroupedCkfTrajectoryBuilder::theConfigurableCondition
private

Definition at line 165 of file GroupedCkfTrajectoryBuilder.h.

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

more measurements)

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

Referenced by GroupedCkfTrajectoryBuilder(), and groupedLimitedCandidates().

bool GroupedCkfTrajectoryBuilder::theLockHits
private

Lock hits when building segments in a layer

Definition at line 186 of file GroupedCkfTrajectoryBuilder.h.

Referenced by advanceOneLayer(), and GroupedCkfTrajectoryBuilder().

float GroupedCkfTrajectoryBuilder::theLostHitPenalty
private

Chi**2 Penalty for each lost hit.

Definition at line 178 of file GroupedCkfTrajectoryBuilder.h.

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

double GroupedCkfTrajectoryBuilder::theMass
private

Mass hypothesis used for propagation

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

Referenced by backwardFit(), and GroupedCkfTrajectoryBuilder().

double GroupedCkfTrajectoryBuilder::theptCut
private

ptCut

Definition at line 172 of file GroupedCkfTrajectoryBuilder.h.

Referenced by ptCut().

bool GroupedCkfTrajectoryBuilder::theRequireSeedHitsInRebuild
private

Only accept rebuilt trajectories if they contain the seed hits.

Definition at line 189 of file GroupedCkfTrajectoryBuilder.h.

Referenced by GroupedCkfTrajectoryBuilder(), and rebuildSeedingRegion().

TempTrajectoryContainer GroupedCkfTrajectoryBuilder::work_
mutableprivate

Definition at line 198 of file GroupedCkfTrajectoryBuilder.h.

Referenced by buildTrajectories().