163 std::unique_ptr<MeasurementTrackerEvent> dataWithMasks;
169 dataWithMasks = std::make_unique<MeasurementTrackerEvent>(*
data, *stripMask, *pixelMask);
178 dataWithMasks = std::make_unique<MeasurementTrackerEvent>(*
data, *pixelMask, *phase2OTMask);
187 es, static_cast<TkTransientTrackingRecHitBuilder const*>(
theTrajectoryBuilder->hitBuilder())->cloner());
195 auto output = std::make_unique<TrackCandidateCollection>();
196 auto outputT = std::make_unique<std::vector<Trajectory>>();
197 auto outputSeedStopInfos = std::make_unique<std::vector<SeedStopInfo>>(collseed->size());
201 <<
" nSeed=" << (*collseed).size();
213 if (!(*collseed).empty()) {
214 unsigned int lastCleanResult = 0;
215 std::vector<Trajectory> rawResult;
216 rawResult.reserve(collseed->size() * 4);
226 using Lock = std::unique_lock<std::mutex>;
229 size_t collseed_size = collseed->size();
231 unsigned int indeces[collseed_size];
232 for (
auto i = 0
U;
i < collseed_size; ++
i)
240 auto const&
seeds = *collseed;
242 float val[collseed_size];
243 for (
auto i = 0
U;
i < collseed_size; ++
i) {
261 std::sort(indeces, indeces + collseed_size, [&](
unsigned int i,
unsigned int j) {
return val[
i] <
val[
j]; });
266 std::atomic<unsigned int> ntseed(0);
267 auto theLoop = [&](
size_t ii) {
268 auto j = indeces[
ii];
273 std::vector<Trajectory> theTmpTrajectories;
275 LogDebug(
"CkfPattern") <<
"======== Begin to look for trajectories from seed " <<
j <<
" ========\n";
281 LogDebug(
"CkfTrackCandidateMakerBase") <<
" Seed cleaning kills seed " <<
j;
288 theTmpTrajectories.clear();
289 unsigned int nCandPerSeed = 0;
290 auto const& startTraj =
294 (*outputSeedStopInfos)[
j].setCandidatesPerSeed(nCandPerSeed);
295 if (theTmpTrajectories.empty()) {
301 LogDebug(
"CkfPattern") <<
"======== In-out trajectory building found " << theTmpTrajectories.size()
302 <<
" trajectories from seed " <<
j <<
" ========\n"
309 LogDebug(
"CkfPattern") <<
"======== In-out trajectory cleaning gave the following "
310 << theTmpTrajectories.size() <<
" valid trajectories from seed " <<
j <<
" ========\n"
320 LogDebug(
"CkfPattern") <<
"======== Out-in trajectory building found " << theTmpTrajectories.size()
321 <<
" valid/invalid trajectories from seed " <<
j <<
" ========\n"
323 if (theTmpTrajectories.empty()) {
333 LogDebug(
"CkfPattern") <<
"======== Trajectory cleaning gave the following " << theTmpTrajectories.size()
334 <<
" valid trajectories from seed " <<
j <<
" ========\n"
339 for (vector<Trajectory>::iterator it = theTmpTrajectories.begin(); it != theTmpTrajectories.end(); it++) {
341 it->setSeedRef(collseed->refAt(
j));
354 theTmpTrajectories.clear();
356 LogDebug(
"CkfPattern") <<
"rawResult trajectories found so far = " << rawResult.size();
363 std::remove_if(rawResult.begin() + lastCleanResult, rawResult.end(), std::not_fn(&
Trajectory::isValid)),
365 lastCleanResult = rawResult.size();
372 tbb::parallel_for(0UL, collseed_size, 1UL, theLoop);
375 #pragma omp parallel for schedule(dynamic, 4)
377 for (
size_t j = 0;
j < collseed_size;
j++) {
381 assert(ntseed == collseed_size);
387 #ifdef VI_REPRODUCIBLE
390 return a.seedRef().key() <
b.seedRef().key();
399 LogDebug(
"CkfPattern") <<
"======== Final cleaning of entire event found " << rawResult.size()
400 <<
" valid/invalid trajectories =======" << endl
403 LogDebug(
"CkfPattern") <<
"removing invalid trajectories.";
406 for (
const auto& traj : rawResult) {
407 if (!traj.isValid()) {
408 const auto seedIndex = traj.seedRef().key();
415 vector<Trajectory>& unsmoothedResult(rawResult);
416 unsmoothedResult.erase(
417 std::remove_if(unsmoothedResult.begin(), unsmoothedResult.end(), std::not_fn(&
Trajectory::isValid)),
418 unsmoothedResult.end());
419 unsmoothedResult.shrink_to_fit();
422 for (
auto it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
424 if (it->lastMeasurement().updatedState().isValid() && it->lastMeasurement().recHit().get() !=
nullptr &&
425 it->lastMeasurement().recHit()->isValid()) {
435 auto initId = it->lastMeasurement().recHitR().rawId();
438 hits.push_back(it->lastMeasurement().recHit()->hit()->clone());
442 trajectory.setSeedRef(it->seedRef());
443 trajectory.setStopReason(it->stopReason());
446 trajectory.reserve(meas.size());
447 for (
auto itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
454 <<
"Last measurement of the trajectory is invalid, cannot reverse it";
463 output->reserve(unsmoothedResult.size());
466 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); ++it) {
468 <<
" hits from trajectory";
471 LogDebug(
"CkfPattern") <<
"not along momentum... " << std::endl;
476 LogDebug(
"CkfPattern") <<
"getting initial state.";
478 std::pair<TrajectoryStateOnSurface, const GeomDet*> initState;
484 LogDebug(
"CkfPattern") <<
"removing last hit";
485 trialTrajectory.
pop();
494 failed = (!initState.first.isValid()) || initState.second ==
nullptr ||
499 const auto seedIndex = it->seedRef().key();
506 LogDebug(
"CkfPattern") <<
"propagating to hit front in case of splitting.";
508 thePropagator->
propagate(initState.first,
recHits.front().det()->surface());
515 LogDebug(
"CkfPattern") <<
"pushing a TrackCandidate.";
516 output->emplace_back(
recHits, it->seed(),
state, it->seedRef(), it->nLoops(), (uint8_t)it->stopReason());
522 LogTrace(
"CkfPattern|TrackingRegressionTest") <<
"========== CkfTrackCandidateMaker Info =========="
523 <<
"number of Seed: " << collseed->size() <<
'\n'
530 outputT->swap(unsmoothedResult);