33 conf.getParameter<edm::
ParameterSet>(
"trajectoryFilter"), iC)) {}
37 std::unique_ptr<TrajectoryFilter>
filter)
148 unsigned int& nCandPerSeed,
152 <<
"Asking to create trajectories to an un-initialized CkfTrajectoryBuilder.\nYou have to call clone(const "
153 "MeasurementTrackerEvent *data) and then call trajectories on it instead.\n";
176 candidates.push_back(startingTraj);
177 std::shared_ptr<const TrajectorySeed> sharedSeed(
new TrajectorySeed(seed));
184 unsigned int nIter = 1;
185 unsigned int nCands = 0;
186 unsigned int prevNewCandSize = 0;
194 while (!candidates.empty()) {
196 for (
auto traj = candidates.begin(); traj != candidates.end(); traj++) {
197 std::vector<TM> meas;
209 std::vector<TM>::const_iterator
last;
213 if (meas.front().recHit()->isValid()) {
214 last = find_if(meas.begin(), meas.end(), [](
auto const& meas) {
return !meas.recHit()->isValid(); });
219 for (
auto itm = meas.begin(); itm !=
last; itm++) {
225 std::push_heap(newCand.begin(), newCand.end(), trajCandLess);
236 nCands += newCand.size() - prevNewCandSize;
237 prevNewCandSize = newCand.size();
272 std::pop_heap(newCand.begin(), newCand.end(), trajCandLess);
290 std::sort_heap(newCand.begin(), newCand.end(), trajCandLess);
294 candidates.swap(newCand);
296 LogDebug(
"CkfPattern") << result.size() <<
" candidates after " << nIter++ <<
" CKF iteration: \n"
298 <<
" running candidates are: \n"
305 auto&& predictedState = tm.predictedState();
306 auto&&
hit = tm.recHit();
307 if (
hit->isValid()) {
311 traj.
emplace(predictedState,
hit, 0, tm.layer());
317 std::vector<TrajectoryMeasurement>&
result)
const {
320 std::pair<TSOS, std::vector<const DetLayer*> >&& stateAndLayers =
findStateAndLayers(seed, traj);
321 if (stateAndLayers.second.empty())
324 auto layerBegin = stateAndLayers.second.begin();
325 auto layerEnd = stateAndLayers.second.end();
326 LogDebug(
"CkfPattern") <<
"looping on " << stateAndLayers.second.size() <<
" layers.";
328 for (
auto il = layerBegin; il != layerEnd; il++) {
329 LogDebug(
"CkfPattern") <<
"looping on a layer in findCompatibleMeasurements.\n last layer: " << traj.
lastLayer()
330 <<
" current layer: " << (*il);
332 TSOS stateToUse = stateAndLayers.first;
335 LogDebug(
"CkfPattern") <<
" self propagating in findCompatibleMeasurements.\n from: \n" << stateToUse;
340 stateToUse = middle.
extrapolate(stateToUse, center, *fwdPropagator);
344 LogDebug(
"CkfPattern") <<
"to: " << stateToUse;
348 std::vector<TrajectoryMeasurement>&&
tmp =
349 layerMeasurements.measurements((**il), stateToUse, *fwdPropagator, *
theEstimator);
357 result.end() - invalidHits, std::make_move_iterator(tmp.begin()), std::make_move_iterator(tmp.end()));
364 if (result.size() > 1) {
368 LogDebug(
"CkfPattern") <<
"starting from:\n"
369 <<
"x: " << stateAndLayers.first.globalPosition() <<
"\n"
370 <<
"p: " << stateAndLayers.first.globalMomentum() <<
"\n"
374 bool afterInvalid =
false;
375 for (vector<TM>::const_iterator
i = result.begin();
i != result.end();
i++) {
376 if (!
i->recHit().isValid())
378 if (afterInvalid &&
i->recHit().isValid()) {
379 edm::LogError(
"CkfPattern") <<
"CkfTrajectoryBuilder error: valid hit after invalid!";
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
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
CkfTrajectoryBuilder(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
void addToResult(std::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
Log< level::Error, false > LogError
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
TrajectoryContainer trajectories(const TrajectorySeed &seed) const override
trajectories building starting from a seed
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
bool theIntermediateCleaning
const TransientTrackingRecHitBuilder * theTTRHBuilder
TempTrajectory buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, unsigned int &nCandPerSeed, const TrajectoryFilter *) const override
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.
T getParameter(std::string const &) const
void emplace(Args &&...args)
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
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