151 unsigned int& nCandPerSeed,
154 throw cms::Exception(
"LogicError") <<
"Asking to create trajectories to an un-initialized CkfTrajectoryBuilder.\nYou have to call clone(const MeasurementTrackerEvent *data) and then call trajectories on it instead.\n";
178 candidates.push_back( startingTraj);
179 boost::shared_ptr<const TrajectorySeed> sharedSeed(
new TrajectorySeed(seed));
187 unsigned int nIter=1;
188 unsigned int nCands=0;
189 unsigned int prevNewCandSize=0;
200 while ( !candidates.empty()) {
203 for (
auto traj=candidates.begin(); traj!=candidates.end(); traj++) {
204 std::vector<TM> meas;
218 std::vector<TM>::const_iterator
last;
221 if (meas.front().recHit()->isValid()) {
222 last = find_if( meas.begin(), meas.end(), [](
auto const& meas){
return !meas.recHit()->isValid(); });
224 else last = meas.end();
227 for(
auto itm = meas.begin(); itm !=
last; itm++) {
232 newCand.push_back(
std::move(newTraj)); std::push_heap(newCand.begin(),newCand.end(),trajCandLess);
244 nCands += newCand.size() - prevNewCandSize;
245 prevNewCandSize = newCand.size();
281 std::pop_heap(newCand.begin(),newCand.end(),trajCandLess);
299 std::sort_heap(newCand.begin(),newCand.end(),trajCandLess);
302 candidates.swap(newCand);
304 LogDebug(
"CkfPattern") <<result.size()<<
" candidates after "<<nIter++<<
" CKF iteration: \n" 306 <<
"\n "<<candidates.size()<<
" running candidates are: \n" 318 auto && predictedState = tm.predictedState();
319 auto &&
hit = tm.recHit();
320 if (
hit->isValid()) {
334 std::vector<TrajectoryMeasurement> &
result)
const 338 std::pair<TSOS,std::vector<const DetLayer*> > && stateAndLayers =
findStateAndLayers(seed,traj);
339 if (stateAndLayers.second.empty())
return;
341 auto layerBegin = stateAndLayers.second.begin();
342 auto layerEnd = stateAndLayers.second.end();
343 LogDebug(
"CkfPattern")<<
"looping on "<< stateAndLayers.second.size()<<
" layers.";
345 for (
auto il = layerBegin; il != layerEnd; il++) {
347 LogDebug(
"CkfPattern")<<
"looping on a layer in findCompatibleMeasurements.\n last layer: "<<traj.
lastLayer()<<
" current layer: "<<(*il);
349 TSOS stateToUse = stateAndLayers.first;
352 LogDebug(
"CkfPattern")<<
" self propagating in findCompatibleMeasurements.\n from: \n"<<stateToUse;
357 stateToUse = middle.
extrapolate(stateToUse, center, *fwdPropagator);
359 if (!stateToUse.
isValid())
continue;
360 LogDebug(
"CkfPattern")<<
"to: "<<stateToUse;
364 std::vector<TrajectoryMeasurement> &&
tmp = layerMeasurements.measurements((**il),stateToUse, *fwdPropagator, *
theEstimator);
367 if ( result.empty()) result.swap(tmp);
370 result.insert( result.end()-invalidHits,
371 std::make_move_iterator(tmp.begin()), std::make_move_iterator(tmp.end()));
378 if ( result.size() > 1) {
382 LogDebug(
"CkfPattern")<<
"starting from:\n" 383 <<
"x: "<<stateAndLayers.first.globalPosition()<<
"\n" 384 <<
"p: "<<stateAndLayers.first.globalMomentum()<<
"\n" 388 bool afterInvalid =
false;
389 for (vector<TM>::const_iterator
i=result.begin();
390 i!=result.end();
i++) {
391 if ( !
i->recHit().isValid()) afterInvalid =
true;
392 if (afterInvalid &&
i->recHit().isValid()) {
393 edm::LogError(
"CkfPattern") <<
"CkfTrajectoryBuilder error: valid hit after invalid!" ;
T getParameter(std::string const &) const
static std::string dumpCandidates(collection &candidates)
std::vector< Trajectory > TrajectoryContainer
bool theAlwaysUseInvalidHits
bool empty() const
True if trajectory has no measurements.
const Propagator * forwardPropagator(const TrajectorySeed &seed) const
TrajectoryContainer trajectories(const TrajectorySeed &seed) const override
trajectories building starting from a seed
CkfTrajectoryBuilder(const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
virtual bool analyzeMeasurementsDebugger(Trajectory &traj, const std::vector< TrajectoryMeasurement > &meas, const MeasurementTrackerEvent *theMeasurementTracker, const Propagator *theForwardPropagator, const Chi2MeasurementEstimatorBase *theEstimator, const TransientTrackingRecHitBuilder *theTTRHBuilder) const
const TrajectoryStateUpdator * theUpdator
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
bool theIntermediateCleaning
const TransientTrackingRecHitBuilder * theTTRHBuilder
void addToResult(boost::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
StateAndLayers findStateAndLayers(const TrajectorySeed &seed, const TempTrajectory &traj) const
const MeasurementTrackerEvent * theMeasurementTracker
unsigned int limitedCandidates(const TrajectorySeed &seed, TempTrajectory &startingTraj, TrajectoryContainer &result) const
std::vector< TempTrajectory > TempTrajectoryContainer
float chiSquared() const
Value of the raw Chi2 of the trajectory, not normalised to the N.D.F.
std::vector< std::vector< double > > tmp
void emplace(Args &&...args)
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
TempTrajectory buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, unsigned int &nCandPerSeed, const TrajectoryFilter *) const override
virtual void findCompatibleMeasurements(const TrajectorySeed &seed, const TempTrajectory &traj, std::vector< TrajectoryMeasurement > &result) const
void updateTrajectory(TempTrajectory &traj, TM &&tm) const
void setEvent_(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
int theMaxCand
set Event for the internal MeasurementTracker data member
std::vector< Trajectory > TrajectoryContainer
const Chi2MeasurementEstimatorBase * theEstimator
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const