35 conf.getParameter<edm::
ParameterSet>(
"trajectoryFilter"), iC)) {}
39 std::unique_ptr<TrajectoryFilter>
filter)
56 iDesc.
add<
int>(
"maxCand", 5);
57 iDesc.
add<
double>(
"lostHitPenalty", 30.);
58 iDesc.
add<
bool>(
"intermediateCleaning",
true);
59 iDesc.
add<
bool>(
"alwaysUseInvalidHits",
true);
162 unsigned int& nCandPerSeed,
166 <<
"Asking to create trajectories to an un-initialized CkfTrajectoryBuilder.\nYou have to call clone(const "
167 "MeasurementTrackerEvent *data) and then call trajectories on it instead.\n";
190 candidates.push_back(startingTraj);
191 std::shared_ptr<const TrajectorySeed> sharedSeed(
new TrajectorySeed(seed));
198 unsigned int nIter = 1;
199 unsigned int nCands = 0;
200 unsigned int prevNewCandSize = 0;
208 while (!candidates.empty()) {
210 for (
auto traj = candidates.begin(); traj != candidates.end(); traj++) {
211 std::vector<TM> meas;
223 std::vector<TM>::const_iterator
last;
227 if (meas.front().recHit()->isValid()) {
228 last = find_if(meas.begin(), meas.end(), [](
auto const& meas) {
return !meas.recHit()->isValid(); });
233 for (
auto itm = meas.begin(); itm !=
last; itm++) {
239 std::push_heap(newCand.begin(), newCand.end(), trajCandLess);
250 nCands += newCand.size() - prevNewCandSize;
251 prevNewCandSize = newCand.size();
286 std::pop_heap(newCand.begin(), newCand.end(), trajCandLess);
304 std::sort_heap(newCand.begin(), newCand.end(), trajCandLess);
308 candidates.swap(newCand);
310 LogDebug(
"CkfPattern") << result.size() <<
" candidates after " << nIter++ <<
" CKF iteration: \n"
312 <<
" running candidates are: \n"
319 auto&& predictedState = tm.predictedState();
320 auto&&
hit = tm.recHit();
321 if (
hit->isValid()) {
325 traj.
emplace(predictedState,
hit, 0, tm.layer());
331 std::vector<TrajectoryMeasurement>&
result)
const {
334 std::pair<TSOS, std::vector<const DetLayer*> >&& stateAndLayers =
findStateAndLayers(seed, traj);
335 if (stateAndLayers.second.empty())
338 auto layerBegin = stateAndLayers.second.begin();
339 auto layerEnd = stateAndLayers.second.end();
340 LogDebug(
"CkfPattern") <<
"looping on " << stateAndLayers.second.size() <<
" layers.";
342 for (
auto il = layerBegin; il != layerEnd; il++) {
343 LogDebug(
"CkfPattern") <<
"looping on a layer in findCompatibleMeasurements.\n last layer: " << traj.
lastLayer()
344 <<
" current layer: " << (*il);
346 TSOS stateToUse = stateAndLayers.first;
349 LogDebug(
"CkfPattern") <<
" self propagating in findCompatibleMeasurements.\n from: \n" << stateToUse;
354 stateToUse = middle.
extrapolate(stateToUse, center, *fwdPropagator);
358 LogDebug(
"CkfPattern") <<
"to: " << stateToUse;
362 std::vector<TrajectoryMeasurement>&&
tmp =
363 layerMeasurements.measurements((**il), stateToUse, *fwdPropagator, *
theEstimator);
371 result.end() - invalidHits, 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();
i != result.end();
i++) {
390 if (!
i->recHit().isValid())
392 if (afterInvalid &&
i->recHit().isValid()) {
393 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
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
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
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
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