49 #ifdef STANDARD_INTERMEDIARYCLEAN
79 updator, propagatorAlong,propagatorOpposite,
80 estimator, recHitBuilder, measurementTracker, filter, inOutFilter)
96 conf.
getParameter<
double>(
"maxPtForLooperReconstruction") : 0;
98 conf.
getParameter<
double>(
"maxDPhiForLooperReconstruction") : 2.0;
164 work.reserve(result.size());
165 for (TrajectoryContainer::iterator traj=result.begin();
166 traj!=result.end(); ++traj) {
171 final.reserve(work.size());
173 for (TempTrajectoryContainer::iterator traj=work.begin();
174 traj!=work.end(); ++traj) {
175 final.push_back(traj->toTrajectory());
196 const bool inOut =
true;
198 if (
work_.empty() )
return ;
215 result.reserve(
work_.size());
216 for (TempTrajectoryContainer::const_iterator it =
work_.begin(), ed =
work_.end(); it != ed; ++it) {
217 result.push_back( it->toTrajectory() );
225 LogDebug(
"CkfPattern")<<
"GroupedCkfTrajectoryBuilder: returning result of size " << result.size();
237 unsigned int nIter=1;
240 candidates.push_back( startingTraj);
242 while ( !candidates.empty()) {
245 for (TempTrajectoryContainer::iterator traj=candidates.begin();
246 traj!=candidates.end(); traj++) {
247 if ( !
advanceOneLayer(*traj, regionalCondition, propagator, inOut, newCand, result) ) {
248 LogDebug(
"CkfPattern")<<
"GCTB: terminating after advanceOneLayer==false";
258 newCand.erase( newCand.begin()+
theMaxCand, newCand.end());
263 LogDebug(
"CkfPattern") <<
"newCand.size() at end = " << newCand.size();
273 #ifdef STANDARD_INTERMEDIARYCLEAN
280 candidates.swap(newCand);
282 LogDebug(
"CkfPattern") <<
"candidates(3): "<<result.size()<<
" candidates after "<<nIter++<<
" groupedCKF iteration: \n"
284 <<
"\n "<<candidates.size()<<
" running candidates are: \n"
290 std::stringstream buffer;
291 vector<const DetLayer*> & nl = stateAndLayers.second;
305 buffer <<
"Trying to go to";
306 for ( vector<const DetLayer*>::iterator il=nl.begin();
320 std::stringstream buffer;
321 buffer <<
"GCTB: starting from "
325 <<
" , pt / phi / pz /charge = "
330 <<
" for layer at "<< l << endl;
331 buffer <<
" errors:";
356 std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers =
findStateAndLayers(traj);
362 stateAndLayers.first.globalMomentum().perp()>0.3)
363 stateAndLayers.second.push_back(traj.
lastLayer());
366 vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
367 vector<const DetLayer*>::iterator layerEnd = stateAndLayers.second.end();
374 LogDebug(
"CkfPattern")<<whatIsTheNextStep(traj, stateAndLayers);
376 bool foundSegments(
false);
377 bool foundNewCandidates(
false);
378 for ( vector<const DetLayer*>::iterator il=layerBegin;
379 il!=layerEnd; il++) {
381 TSOS stateToUse = stateAndLayers.first;
383 double dPhiCacheForLoopersReconstruction(0);
395 if(!cylinderCrossing.hasSolution())
continue;
397 GlobalPoint target1 = cylinderCrossing.position1();
398 GlobalPoint target2 = cylinderCrossing.position2();
404 float length = bounds.
length() / 2.f;
420 if(fabs(farther.
z())*0.95>length)
continue;
425 (target1.
y()+target2.
y())/2,
426 (target1.
z()+target2.
z())/2);
433 stateToUse = extrapolator.
extrapolate(stateToUse, target, *propagator);
434 if (!stateToUse.
isValid())
continue;
437 dPhiCacheForLoopersReconstruction = fabs(tmpDphi);
444 LogDebug(
"CkfPattern")<<
" self propagating in advanceOneLayer.\n from: \n"<<stateToUse;
451 if (!stateToUse.
isValid())
continue;
452 LogDebug(
"CkfPattern")<<
"to: "<<stateToUse;
468 LogDebug(
"CkfPattern")<<
"GCTB: number of segments = " << segments.size();
470 if ( !segments.empty() ) foundSegments =
true;
472 for ( TempTrajectoryContainer::const_iterator is=segments.begin();
473 is!=segments.end(); is++ ) {
487 bool toBeRejected(
false);
489 revIt!=measurements.
rend(); --revIt){
494 if(revIt->recHit()->geographicalId()==newTrajMeasIt->recHit()->geographicalId()){
527 LogDebug(
"CkfPattern")<<
"GCTB: adding updated trajectory to candidates: inOut="<<inOut<<
" hits="<<newTraj.
foundHits();
529 newCand.push_back(newTraj);
530 foundNewCandidates =
true;
535 LogDebug(
"CkfPattern")<<
"GCTB: adding completed trajectory to results if passes cuts: inOut="<<inOut<<
" hits="<<newTraj.
foundHits();
542 if ( !foundSegments ){
543 LogDebug(
"CkfPattern")<<
"GCTB: adding input trajectory to result";
546 return foundNewCandidates;
555 if (theTrajectories.empty())
return;
557 int firstLayerSize, secondLayerSize;
558 vector<const DetLayer*> firstLayers, secondLayers;
560 for (TempTrajectoryContainer::iterator firstTraj=theTrajectories.begin();
561 firstTraj!=(theTrajectories.end()-1); firstTraj++) {
563 if ( (!firstTraj->isValid()) ||
564 (!firstTraj->lastMeasurement().recHit()->isValid()) )
continue;
566 layers(firstMeasurements, firstLayers);
567 firstLayerSize = firstLayers.size();
568 if ( firstLayerSize<4 )
continue;
570 for (TempTrajectoryContainer::iterator secondTraj=(firstTraj+1);
571 secondTraj!=theTrajectories.end(); secondTraj++) {
573 if ( (!secondTraj->isValid()) ||
574 (!secondTraj->lastMeasurement().recHit()->isValid()) )
continue;
576 layers(secondMeasurements, secondLayers);
577 secondLayerSize = secondLayers.size();
581 if ( firstLayerSize!=secondLayerSize )
continue;
582 if ( firstLayers[0]!=secondLayers[0] ||
583 firstLayers[1]!=secondLayers[1] ||
584 firstLayers[2]!=secondLayers[2] )
continue;
592 const DetLayer* layerPtr = firstLayers[0];
593 while ( im1!=firstMeasurements.
rend()&&im2!=secondMeasurements.
rend() ) {
594 if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr )
break;
595 if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
604 if ( im1==firstMeasurements.
rend() || im2==secondMeasurements.
rend() ||
605 im1->layer()==layerPtr || im2->layer()==layerPtr || unequal )
continue;
610 layerPtr = firstLayers[1];
612 while ( im1!=firstMeasurements.
rend()&&im1->layer()==layerPtr ) {
613 if ( !im1->recHit()->isValid() ) firstValid =
false;
616 bool secondValid(
true);
617 while ( im2!=secondMeasurements.
rend()&&im2->layer()==layerPtr ) {
618 if ( !im2->recHit()->isValid() ) secondValid =
false;
621 if ( !
tkxor(firstValid,secondValid) )
continue;
626 layerPtr = firstLayers[2];
627 while ( im1!=firstMeasurements.
rend()&&im2!=secondMeasurements.
rend() ) {
628 if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr )
break;
629 if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
638 if ( im1==firstMeasurements.
rend() || im2==secondMeasurements.
rend() ||
639 im1->layer()==layerPtr || im2->layer()==layerPtr || unequal )
continue;
642 firstTraj->invalidate();
646 secondTraj->invalidate();
659 theTrajectories.erase(std::remove_if( theTrajectories.begin(),theTrajectories.end(),
662 theTrajectories.end());
667 vector<const DetLayer*> &
result)
const
671 if ( measurements.
empty() )
return ;
673 result.push_back(measurements.
back().
layer());
677 im!=measurements.
rend(); --im ) {
678 if ( im->layer()!=result.back() ) result.push_back(im->layer());
681 for (vector<const DetLayer*>::const_iterator iter = result.begin(); iter != result.end(); iter++){
682 if (!*iter)
edm::LogWarning(
"CkfPattern")<<
"Warning: null det layer!! ";
695 LogDebug(
"CkfPattern")<<
"Starting to rebuild " << result.size() <<
" tracks";
704 std::vector<const TrackingRecHit*> seedHits;
711 unsigned int nSeed(rseedHits.second-rseedHits.first);
714 for ( TempTrajectoryContainer::iterator it=result.begin();
715 it!=result.end(); it++ ) {
722 rebuiltTrajectories.push_back(*it);
723 LogDebug(
"CkfPattern")<<
"RebuildSeedingRegion skipped as in-out trajectory does not exceed seed size.";
732 if ( reFitted.size()!=1 ) {
733 rebuiltTrajectories.push_back(*it);
734 LogDebug(
"CkfPattern")<<
"RebuildSeedingRegion skipped as backward fit failed";
746 if ( nRebuilt==0 ) it->invalidate();
748 if ( nRebuilt<=0 ) rebuiltTrajectories.push_back(*it);
754 result.swap(rebuiltTrajectories);
755 result.erase(std::remove_if( result.begin(),result.end(),
797 cout <<
"Before backward building: #measurements = "
804 const bool inOut =
false;
812 int nrOfTrajectories(0);
813 bool orig_ok =
false;
816 for ( TempTrajectoryContainer::iterator it=rebuiltTrajectories.begin();
817 it!=rebuiltTrajectories.end(); it++ ) {
827 LogDebug(
"CkfPattern") <<
"newMeasurements.size()<=candidate.measurements().size()";
836 LogDebug(
"CkfPattern")<<
"seed hits not found in rebuild";
843 TempTrajectory reversedTrajectory(it->seed(),it->seed().direction());
844 reversedTrajectory.
setNLoops(it->nLoops());
847 reversedTrajectory.push(*im);
850 result.push_back(reversedTrajectory);
853 LogDebug(
"CkgPattern")<<
"New traj direction = " << reversedTrajectory.direction()<<
"\n"
865 if ( (nrOfTrajectories == 0) && orig_ok ) {
866 nrOfTrajectories = -1;
868 return nrOfTrajectories;
875 std::vector<const TrackingRecHit*>& remainingHits)
const
880 remainingHits.clear();
881 fittedTracks.clear();
887 fittedTracks.clear();
891 LogDebug(
"CkfPattern")<<
"nSeed " << nSeed << endl
892 <<
"Old traj direction = " << candidate.
direction() << endl
904 unsigned int nHit(0);
913 fittedTracks.clear();
917 LogDebug(
"CkfPattern") <<
"Sizes: " << oldMeasurements.size() <<
" / ";
925 std::vector<const DetLayer*> bwdDetLayer;
927 im!=oldMeasurements.rend(); --im) {
934 bwdDetLayer.push_back(im->layer());
951 remainingHits.push_back(hit);
958 fittedTracks.clear();
971 if (bwdFitted.size()){
972 LogDebug(
"CkfPattern")<<
"Obtained " << bwdFitted.size() <<
" bwdFitted trajectories with measurement size " << bwdFitted.front().measurements().size();
975 vector<TM> tmsbf = bwdFitted.front().measurements();
981 for ( vector<TM>::const_iterator im=tmsbf.begin();im!=tmsbf.end(); im++ ) {
982 fitted.push(
TM( (*im).forwardPredictedState(),
983 (*im).backwardPredictedState(),
984 (*im).updatedState(),
987 bwdDetLayer[iDetLayer]));
1001 fittedTracks.push_back(fitted);
1013 const std::vector<const TrackingRecHit*>& hits)
const
1018 LogDebug(
"CkfPattern")<<
"Checking for " << hits.size() <<
" hits in "
1019 << maxDepth <<
" measurements" << endl;
1022 while (maxDepth > 0) { --maxDepth; --rend; }
1023 for ( vector<const TrackingRecHit*>::const_iterator ir=hits.begin();
1024 ir!=hits.end(); ir++ ) {
1026 bool foundHit(
false);
1028 if ( im->recHit()->isValid() && (*ir)->sharesInput(im->recHit()->hit(),
TrackingRecHit::some) ) {
1033 if ( !foundHit )
return false;
void rescaleError(double factor)
T getParameter(std::string const &) const
const TrajectorySeed & seed() const
Access to the seed used to reconstruct the Trajectory.
const_iterator rend() const
static std::string dumpCandidates(collection &candidates)
TempTrajectoryContainer work_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
virtual float length() const =0
virtual PropagationDirection propagationDirection() const
const Propagator * theBackwardPropagator
TrackCharge charge() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
virtual Location location() const =0
Which part of the detector (barrel, endcap)
TrajectoryContainer trajectories(const TrajectorySeed &) const
set Event for the internal MeasurementTracker data member
const CurvilinearTrajectoryError & curvilinearError() const
void addToResult(TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
PropagationDirection oppositeDirection(PropagationDirection dir) const
change of propagation direction
const DataContainer & measurements() 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
Geom::Phi< T > phi() const
void setNLoops(signed char value)
void setNLoops(signed char value)
const TrajectoryStateUpdator * theUpdator
virtual void analyseSeed(const TrajectorySeed &seed) const
GlobalPoint globalPosition() const
ConstRecHitPointer recHit() const
int foundHits() const
obsolete name, use measurements() instead.
TempTrajectoryContainer segments(const TSOS startingState)
new segments within layer
float maxDPhiForLooperReconstruction
static std::string dumpMeasurement(const TrajectoryMeasurement &tm)
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
unsigned int theMinNrOf2dHitsForRebuild
signed char nLoops() const
ConstRecHitContainer recHits(bool splitting=false) const
PropagationDirection const & direction() const
const LayerMeasurements * theLayerMeasurements
PropagationDirection direction() const
void setDPhiCacheForLoopersReconstruction(float dphi)
virtual void analyseResult(const TrajectoryContainer &result) const
void groupedLimitedCandidates(TempTrajectory &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const
Scalar radius() const
Radius of the cylinder.
const T & max(const T &a, const T &b)
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.
void groupedIntermediaryClean(TempTrajectoryContainer &theTrajectories) const
intermediate cleaning in the case of grouped measurements
virtual const BoundDisk & specificSurface() const
void backwardFit(TempTrajectory &candidate, unsigned int nSeed, const TrajectoryFitter &fitter, TempTrajectoryContainer &fittedTracks, std::vector< const TrackingRecHit * > &remainingHits) const
const Chi2MeasurementEstimatorBase & estimator() const
std::string whatIsTheStateToUse(TrajectoryStateOnSurface &initial, TrajectoryStateOnSurface &stateToUse, const DetLayer *l)
std::pair< const_iterator, const_iterator > range
void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const
const DetLayer * layer() const
void buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
bool advanceOneLayer(TempTrajectory &traj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &newCand, TempTrajectoryContainer &result) const
TrajectoryStateOnSurface updatedState() const
const Bounds & bounds() const
const MeasurementTracker * theMeasurementTracker
TrajectoryMeasurement const & firstMeasurement() const
unsigned int theMinNrOfHitsForRebuild
std::vector< TempTrajectory > TempTrajectoryContainer
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
const TrajectoryStateUpdator & updator() const
virtual std::vector< Trajectory > fit(const Trajectory &) const =0
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
bool tkxor(bool a, bool b) const
StateAndLayers findStateAndLayers(const TempTrajectory &traj) const
bool theIntermediateCleaning
bool theRequireSeedHitsInRebuild
float maxPtForLooperReconstruction
signed char nLoops() const
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const PositionType & position() const
void push(const TrajectoryMeasurement &tm)
std::vector< Trajectory > TrajectoryContainer
void layers(const TempTrajectory::DataContainer &measurements, std::vector< const DetLayer * > &fillme) const
const Chi2MeasurementEstimatorBase * theEstimator
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
void push(const TrajectoryMeasurement &tm)
double transverseCurvature() const
const Propagator * theForwardPropagator