CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions
cms::CkfTrackCandidateMakerBase Class Reference

#include <CkfTrackCandidateMakerBase.h>

Inheritance diagram for cms::CkfTrackCandidateMakerBase:
cms::CkfDebugTrackCandidateMaker cms::CkfTrackCandidateMaker cms::CkfTrajectoryMaker

Public Member Functions

virtual void beginRunBase (edm::Run const &, edm::EventSetup const &es)
 
 CkfTrackCandidateMakerBase (const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
 
virtual void produceBase (edm::Event &e, const edm::EventSetup &es)
 
virtual ~CkfTrackCandidateMakerBase () noexcept(false)
 

Protected Types

typedef edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTClusterMask
 
typedef edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelClusterMask
 
typedef edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > StripClusterMask
 

Protected Member Functions

virtual void countSeedsDebugger ()
 
virtual void deleteAssocDebugger ()
 
virtual TrajectorySeedCollection::const_iterator lastSeed (TrajectorySeedCollection const &theSeedColl)
 
virtual void printHitsDebugger (edm::Event &e)
 

Protected Attributes

bool cleanTrajectoryAfterInOut
 
bool doSeedingRegionRebuilding
 
edm::EDGetTokenT< Phase2OTClusterMaskmaskPhase2OTs_
 
edm::EDGetTokenT< PixelClusterMaskmaskPixels_
 
edm::EDGetTokenT< StripClusterMaskmaskStrips_
 
unsigned int maxSeedsBeforeCleaning_
 
bool phase2skipClusters_
 
bool produceSeedStopReasons_
 
bool reverseTrajectories
 
bool skipClusters_
 
edm::ESHandle< GeometricSearchTrackertheGeomSearchTracker
 
std::unique_ptr< TransientInitialStateEstimatortheInitialState
 
edm::ESHandle< MagneticFieldtheMagField
 
const std::string theMagFieldName
 
unsigned int theMaxNSeeds
 
edm::EDGetTokenT< MeasurementTrackerEventtheMTELabel
 
const NavigationSchooltheNavigationSchool
 
std::string theNavigationSchoolName
 
std::unique_ptr< RedundantSeedCleanertheSeedCleaner
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > theSeedLabel
 
bool theTrackCandidateOutput
 
std::unique_ptr< BaseCkfTrajectoryBuildertheTrajectoryBuilder
 
const TrajectoryCleanertheTrajectoryCleaner
 
std::string theTrajectoryCleanerName
 
bool theTrajectoryOutput
 
bool useSplitting
 

Private Member Functions

void setEventSetup (const edm::EventSetup &es)
 Initialize EventSetup objects at each event. More...
 

Detailed Description

Definition at line 34 of file CkfTrackCandidateMakerBase.h.

Member Typedef Documentation

◆ Phase2OTClusterMask

Definition at line 80 of file CkfTrackCandidateMakerBase.h.

◆ PixelClusterMask

Definition at line 78 of file CkfTrackCandidateMakerBase.h.

◆ StripClusterMask

Definition at line 79 of file CkfTrackCandidateMakerBase.h.

Constructor & Destructor Documentation

◆ CkfTrackCandidateMakerBase()

cms::CkfTrackCandidateMakerBase::CkfTrackCandidateMakerBase ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC 
)
explicit

Definition at line 60 of file CkfTrackCandidateMakerBase.cc.

62  theTrajectoryOutput(false),
63  useSplitting(conf.getParameter<bool>("useHitsSplitting")),
64  doSeedingRegionRebuilding(conf.getParameter<bool>("doSeedingRegionRebuilding")),
65  cleanTrajectoryAfterInOut(conf.getParameter<bool>("cleanTrajectoryAfterInOut")),
66  reverseTrajectories(conf.existsAs<bool>("reverseTrajectories") &&
67  conf.getParameter<bool>("reverseTrajectories")),
68  theMaxNSeeds(conf.getParameter<unsigned int>("maxNSeeds")),
70  createBaseCkfTrajectoryBuilder(conf.getParameter<edm::ParameterSet>("TrajectoryBuilderPSet"), iC)),
71  theTrajectoryCleanerName(conf.getParameter<std::string>("TrajectoryCleaner")),
72  theTrajectoryCleaner(nullptr),
73  theInitialState(std::make_unique<TransientInitialStateEstimator>(
74  conf.getParameter<ParameterSet>("TransientInitialStateEstimatorParameters"))),
75  theMagFieldName(conf.exists("SimpleMagneticField") ? conf.getParameter<std::string>("SimpleMagneticField")
76  : ""),
77  theNavigationSchoolName(conf.getParameter<std::string>("NavigationSchool")),
78  theNavigationSchool(nullptr),
80  theMTELabel(iC.consumes<MeasurementTrackerEvent>(conf.getParameter<edm::InputTag>("MeasurementTrackerEvent"))),
81  skipClusters_(false),
82  phase2skipClusters_(false) {
84 #ifndef VI_REPRODUCIBLE
85  if (conf.exists("maxSeedsBeforeCleaning"))
86  maxSeedsBeforeCleaning_ = conf.getParameter<unsigned int>("maxSeedsBeforeCleaning");
87 #endif
88  if (conf.existsAs<edm::InputTag>("clustersToSkip")) {
89  skipClusters_ = true;
90  maskPixels_ = iC.consumes<PixelClusterMask>(conf.getParameter<edm::InputTag>("clustersToSkip"));
91  maskStrips_ = iC.consumes<StripClusterMask>(conf.getParameter<edm::InputTag>("clustersToSkip"));
92  }
93  //FIXME:: just temporary solution for phase2!
94  if (conf.existsAs<edm::InputTag>("phase2clustersToSkip")) {
95  phase2skipClusters_ = true;
96  maskPixels_ = iC.consumes<PixelClusterMask>(conf.getParameter<edm::InputTag>("phase2clustersToSkip"));
97  maskPhase2OTs_ = iC.consumes<Phase2OTClusterMask>(conf.getParameter<edm::InputTag>("phase2clustersToSkip"));
98  }
99 #ifndef VI_REPRODUCIBLE
100  std::string cleaner = conf.getParameter<std::string>("RedundantSeedCleaner");
101  if (cleaner == "CachingSeedCleanerBySharedInput") {
103  conf.existsAs<int>("numHitsForSeedCleaner") ? conf.getParameter<int>("numHitsForSeedCleaner") : 4;
104  int onlyPixelHits = conf.existsAs<bool>("onlyPixelHitsForSeedCleaner")
105  ? conf.getParameter<bool>("onlyPixelHitsForSeedCleaner")
106  : false;
107  theSeedCleaner = std::make_unique<CachingSeedCleanerBySharedInput>(numHitsForSeedCleaner, onlyPixelHits);
108  } else if (cleaner != "none") {
109  throw cms::Exception("RedundantSeedCleaner not found, please use CachingSeedCleanerBySharedInput ro none",
110  cleaner);
111  }
112 #endif
113 
114 #ifdef VI_REPRODUCIBLE
115  std::cout << "CkfTrackCandidateMaker in reproducible setting" << std::endl;
116  assert(nullptr == theSeedCleaner);
118 #endif
119  }

References cms::cuda::assert(), gather_cfg::cout, Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), maskPhase2OTs_, maskPixels_, maskStrips_, maxSeedsBeforeCleaning_, highPtTripletStepTrackCandidates_cfi::numHitsForSeedCleaner, phase2skipClusters_, skipClusters_, AlCaHLTBitMon_QueryRunRegistry::string, theSeedCleaner, and theSeedLabel.

◆ ~CkfTrackCandidateMakerBase()

cms::CkfTrackCandidateMakerBase::~CkfTrackCandidateMakerBase ( )
virtualnoexcept

Definition at line 122 of file CkfTrackCandidateMakerBase.cc.

122 {}

Member Function Documentation

◆ beginRunBase()

void cms::CkfTrackCandidateMakerBase::beginRunBase ( edm::Run const &  r,
edm::EventSetup const &  es 
)
virtual

Definition at line 124 of file CkfTrackCandidateMakerBase.cc.

124  { /* no op*/
125  }

Referenced by cms::CkfDebugTrackCandidateMaker::beginRun().

◆ countSeedsDebugger()

virtual void cms::CkfTrackCandidateMakerBase::countSeedsDebugger ( )
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 90 of file CkfTrackCandidateMakerBase.h.

90 { ; }

Referenced by produceBase().

◆ deleteAssocDebugger()

virtual void cms::CkfTrackCandidateMakerBase::deleteAssocDebugger ( )
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 91 of file CkfTrackCandidateMakerBase.h.

91 { ; }

Referenced by produceBase().

◆ lastSeed()

virtual TrajectorySeedCollection::const_iterator cms::CkfTrackCandidateMakerBase::lastSeed ( TrajectorySeedCollection const &  theSeedColl)
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 86 of file CkfTrackCandidateMakerBase.h.

86  {
87  return theSeedColl.end();
88  }

◆ printHitsDebugger()

virtual void cms::CkfTrackCandidateMakerBase::printHitsDebugger ( edm::Event e)
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 89 of file CkfTrackCandidateMakerBase.h.

89 { ; }

Referenced by produceBase().

◆ produceBase()

void cms::CkfTrackCandidateMakerBase::produceBase ( edm::Event e,
const edm::EventSetup es 
)
virtual

Definition at line 145 of file CkfTrackCandidateMakerBase.cc.

145  {
146  // getting objects from the EventSetup
147  setEventSetup(es);
148 
149  // set the correct navigation
150  // NavigationSetter setter( *theNavigationSchool);
151 
152  // propagator
153  edm::ESHandle<Propagator> thePropagator;
154  es.get<TrackingComponentsRecord>().get("AnyDirectionAnalyticalPropagator", thePropagator);
155 
156  // method for Debugging
158 
159  // Step A: set Event for the TrajectoryBuilder
161  e.getByToken(theMTELabel, data);
162 
163  std::unique_ptr<MeasurementTrackerEvent> dataWithMasks;
164  if (skipClusters_) {
166  e.getByToken(maskPixels_, pixelMask);
168  e.getByToken(maskStrips_, stripMask);
169  dataWithMasks = std::make_unique<MeasurementTrackerEvent>(*data, *stripMask, *pixelMask);
170  //std::cout << "Trajectory builder " << conf_.getParameter<std::string>("@module_label") << " created with masks " << std::endl;
171  theTrajectoryBuilder->setEvent(e, es, &*dataWithMasks);
172  } else if (phase2skipClusters_) {
173  //FIXME:just temporary solution for phase2!
175  e.getByToken(maskPixels_, pixelMask);
177  e.getByToken(maskPhase2OTs_, phase2OTMask);
178  dataWithMasks = std::make_unique<MeasurementTrackerEvent>(*data, *pixelMask, *phase2OTMask);
179  //std::cout << "Trajectory builder " << conf_.getParameter<std::string>("@module_label") << " created with phase2 masks " << std::endl;
180  theTrajectoryBuilder->setEvent(e, es, &*dataWithMasks);
181  } else {
182  //std::cout << "Trajectory builder " << conf_.getParameter<std::string>("@module_label") << " created without masks " << std::endl;
183  theTrajectoryBuilder->setEvent(e, es, &*data);
184  }
185  // TISE ES must be set here due to dependence on theTrajectoryBuilder
186  theInitialState->setEventSetup(
187  es, static_cast<TkTransientTrackingRecHitBuilder const*>(theTrajectoryBuilder->hitBuilder())->cloner());
188 
189  // Step B: Retrieve seeds
190 
192  e.getByToken(theSeedLabel, collseed);
193 
194  // Step C: Create empty output collection
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());
198 
199  if ((*collseed).size() > theMaxNSeeds) {
200  LogError("TooManySeeds") << "Exceeded maximum numeber of seeds! theMaxNSeeds=" << theMaxNSeeds
201  << " nSeed=" << (*collseed).size();
203  e.put(std::move(output));
204  }
205  if (theTrajectoryOutput) {
206  e.put(std::move(outputT));
207  }
208  e.put(std::move(outputSeedStopInfos));
209  return;
210  }
211 
212  // Step D: Invoke the building algorithm
213  if (!(*collseed).empty()) {
214  unsigned int lastCleanResult = 0;
215  std::vector<Trajectory> rawResult;
216  rawResult.reserve(collseed->size() * 4);
217 
218  if (theSeedCleaner)
219  theSeedCleaner->init(&rawResult);
220 
221  // method for debugging
223 
224  // the mutex
225  std::mutex theMutex;
226  using Lock = std::unique_lock<std::mutex>;
227 
228  // Loop over seeds
229  size_t collseed_size = collseed->size();
230 
231  unsigned int indeces[collseed_size];
232  for (auto i = 0U; i < collseed_size; ++i)
233  indeces[i] = i;
234 
235 #ifdef VI_SORTSEED
236  // std::random_shuffle(indeces,indeces+collseed_size);
237 
238  // here only for reference: does not seems to help
239 
240  auto const& seeds = *collseed;
241 
242  float val[collseed_size];
243  for (auto i = 0U; i < collseed_size; ++i) {
244  val[i] = seeds[i].startingState().pt();
245  };
246  // { val[i] = std::abs((*seeds[i].recHits().first).surface()->eta());}
247 
248  /*
249  unsigned long long val[collseed_size];
250  for (auto i=0U; i< collseed_size; ++i) {
251  if (seeds[i].nHits()<2) { val[i]=0; continue;}
252  auto h = seeds[i].recHits().first;
253  auto const & hit = static_cast<BaseTrackerRecHit const&>(*h);
254  val[i] = hit.firstClusterRef().key();
255  if (++h != seeds[i].recHits().second) {
256  auto const & hit = static_cast<BaseTrackerRecHit const&>(*h);
257  val[i] |= (unsigned long long)(hit.firstClusterRef().key())<<32;
258  }
259  }
260  */
261  std::sort(indeces, indeces + collseed_size, [&](unsigned int i, unsigned int j) { return val[i] < val[j]; });
262 
263  // std::cout << spt(indeces[0]) << ' ' << spt(indeces[collseed_size-1]) << std::endl;
264 #endif
265 
266  std::atomic<unsigned int> ntseed(0);
267  auto theLoop = [&](size_t ii) {
268  auto j = indeces[ii];
269 
270  ntseed++;
271 
272  // to be moved inside a par section (how with tbb??)
273  std::vector<Trajectory> theTmpTrajectories;
274 
275  LogDebug("CkfPattern") << "======== Begin to look for trajectories from seed " << j << " ========\n";
276 
277  {
278  Lock lock(theMutex);
279  // Check if seed hits already used by another track
280  if (theSeedCleaner && !theSeedCleaner->good(&((*collseed)[j]))) {
281  LogDebug("CkfTrackCandidateMakerBase") << " Seed cleaning kills seed " << j;
282  (*outputSeedStopInfos)[j].setStopReason(SeedStopReason::SEED_CLEANING);
283  return; // from the lambda!
284  }
285  }
286 
287  // Build trajectory from seed outwards
288  theTmpTrajectories.clear();
289  unsigned int nCandPerSeed = 0;
290  auto const& startTraj =
291  theTrajectoryBuilder->buildTrajectories((*collseed)[j], theTmpTrajectories, nCandPerSeed, nullptr);
292  {
293  Lock lock(theMutex);
294  (*outputSeedStopInfos)[j].setCandidatesPerSeed(nCandPerSeed);
295  if (theTmpTrajectories.empty()) {
296  (*outputSeedStopInfos)[j].setStopReason(SeedStopReason::NO_TRAJECTORY);
297  return; // from the lambda!
298  }
299  }
300 
301  LogDebug("CkfPattern") << "======== In-out trajectory building found " << theTmpTrajectories.size()
302  << " trajectories from seed " << j << " ========\n"
303  << PrintoutHelper::dumpCandidates(theTmpTrajectories);
304 
306  // Select the best trajectory from this seed (declare others invalid)
307  theTrajectoryCleaner->clean(theTmpTrajectories);
308 
309  LogDebug("CkfPattern") << "======== In-out trajectory cleaning gave the following "
310  << theTmpTrajectories.size() << " valid trajectories from seed " << j << " ========\n"
311  << PrintoutHelper::dumpCandidates(theTmpTrajectories);
312  }
313 
314  // Optionally continue building trajectory back through
315  // seed and if possible further inwards.
316 
318  theTrajectoryBuilder->rebuildTrajectories(startTraj, (*collseed)[j], theTmpTrajectories);
319 
320  LogDebug("CkfPattern") << "======== Out-in trajectory building found " << theTmpTrajectories.size()
321  << " valid/invalid trajectories from seed " << j << " ========\n"
322  << PrintoutHelper::dumpCandidates(theTmpTrajectories);
323  if (theTmpTrajectories.empty()) {
324  Lock lock(theMutex);
325  (*outputSeedStopInfos)[j].setStopReason(SeedStopReason::SEED_REGION_REBUILD);
326  return;
327  }
328  }
329 
330  // Select the best trajectory from this seed (after seed region rebuilding, can be more than one)
331  theTrajectoryCleaner->clean(theTmpTrajectories);
332 
333  LogDebug("CkfPattern") << "======== Trajectory cleaning gave the following " << theTmpTrajectories.size()
334  << " valid trajectories from seed " << j << " ========\n"
335  << PrintoutHelper::dumpCandidates(theTmpTrajectories);
336 
337  {
338  Lock lock(theMutex);
339  for (vector<Trajectory>::iterator it = theTmpTrajectories.begin(); it != theTmpTrajectories.end(); it++) {
340  if (it->isValid()) {
341  it->setSeedRef(collseed->refAt(j));
342  (*outputSeedStopInfos)[j].setStopReason(SeedStopReason::NOT_STOPPED);
343  // Store trajectory
344  rawResult.push_back(std::move(*it));
345  // Tell seed cleaner which hits this trajectory used.
346  //TO BE FIXED: this cut should be configurable via cfi file
347  if (theSeedCleaner && rawResult.back().foundHits() > 3)
348  theSeedCleaner->add(&rawResult.back());
349  //if (theSeedCleaner ) theSeedCleaner->add( & (*it) );
350  }
351  }
352  }
353 
354  theTmpTrajectories.clear();
355 
356  LogDebug("CkfPattern") << "rawResult trajectories found so far = " << rawResult.size();
357 
358  {
359  Lock lock(theMutex);
360  if (maxSeedsBeforeCleaning_ > 0 && rawResult.size() > maxSeedsBeforeCleaning_ + lastCleanResult) {
361  theTrajectoryCleaner->clean(rawResult);
362  rawResult.erase(
363  std::remove_if(rawResult.begin() + lastCleanResult, rawResult.end(), std::not_fn(&Trajectory::isValid)),
364  rawResult.end());
365  lastCleanResult = rawResult.size();
366  }
367  }
368  };
369  // end of loop over seeds
370 
371 #ifdef VI_TBB
372  tbb::parallel_for(0UL, collseed_size, 1UL, theLoop);
373 #else
374 #ifdef VI_OMP
375 #pragma omp parallel for schedule(dynamic, 4)
376 #endif
377  for (size_t j = 0; j < collseed_size; j++) {
378  theLoop(j);
379  }
380 #endif
381  assert(ntseed == collseed_size);
382  if (theSeedCleaner)
383  theSeedCleaner->done();
384 
385  // std::cout << "VICkfPattern " << "rawResult trajectories found = " << rawResult.size() << " in " << ntseed << " seeds " << collseed_size << std::endl;
386 
387 #ifdef VI_REPRODUCIBLE
388  // sort trajectory
389  std::sort(rawResult.begin(), rawResult.end(), [](const Trajectory& a, const Trajectory& b) {
390  return a.seedRef().key() < b.seedRef().key();
391  });
392  //{ return a.chiSquared()*b.ndof() < b.chiSquared()*a.ndof();});
393 #endif
394 
395  // Step E: Clean the results to avoid duplicate tracks
396  // Rejected ones just flagged as invalid.
397  theTrajectoryCleaner->clean(rawResult);
398 
399  LogDebug("CkfPattern") << "======== Final cleaning of entire event found " << rawResult.size()
400  << " valid/invalid trajectories =======" << endl
401  << PrintoutHelper::dumpCandidates(rawResult);
402 
403  LogDebug("CkfPattern") << "removing invalid trajectories.";
404 
405  // Assuming here that theLoop() gives at most one Trajectory per seed
406  for (const auto& traj : rawResult) {
407  if (!traj.isValid()) {
408  const auto seedIndex = traj.seedRef().key();
409  if ((*outputSeedStopInfos)[seedIndex].stopReason() == SeedStopReason::NOT_STOPPED) {
410  (*outputSeedStopInfos)[seedIndex].setStopReason(SeedStopReason::FINAL_CLEAN);
411  }
412  }
413  }
414 
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();
420  // If requested, reverse the trajectories creating a new 1-hit seed on the last measurement of the track
421  if (reverseTrajectories) {
422  for (auto it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
423  // reverse the trajectory only if it has valid hit on the last measurement (should happen)
424  if (it->lastMeasurement().updatedState().isValid() && it->lastMeasurement().recHit().get() != nullptr &&
425  it->lastMeasurement().recHit()->isValid()) {
426  // I can't use reverse in place, because I want to change the seed
427  // 1) reverse propagation direction
428  PropagationDirection direction = it->direction();
429  if (direction == alongMomentum)
430  direction = oppositeToMomentum;
431  else if (direction == oppositeToMomentum)
432  direction = alongMomentum;
433  // 2) make a seed
434  TrajectoryStateOnSurface const& initState = it->lastMeasurement().updatedState();
435  auto initId = it->lastMeasurement().recHitR().rawId();
438  hits.push_back(it->lastMeasurement().recHit()->hit()->clone());
439  std::shared_ptr<const TrajectorySeed> seed(new TrajectorySeed(state, std::move(hits), direction));
440  // 3) make a trajectory
441  Trajectory trajectory(seed, direction);
442  trajectory.setNLoops(it->nLoops());
443  trajectory.setSeedRef(it->seedRef());
444  trajectory.setStopReason(it->stopReason());
445  // 4) push states in reversed order
446  Trajectory::DataContainer& meas = it->measurements();
447  trajectory.reserve(meas.size());
448  for (auto itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
449  trajectory.push(std::move(*itmeas));
450  }
451  // replace
452  (*it) = std::move(trajectory);
453  } else {
454  edm::LogWarning("CkfPattern_InvalidLastMeasurement")
455  << "Last measurement of the trajectory is invalid, cannot reverse it";
456  }
457  }
458  }
459 
460  int viTotHits = 0;
461 
463  // Step F: Convert to TrackCandidates
464  output->reserve(unsmoothedResult.size());
465  Traj2TrackHits t2t(theTrajectoryBuilder->hitBuilder(), true);
466 
467  for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); ++it) {
468  LogDebug("CkfPattern") << "copying " << (useSplitting ? "splitted" : "un-splitted")
469  << " hits from trajectory";
471  if (it->direction() != alongMomentum)
472  LogDebug("CkfPattern") << "not along momentum... " << std::endl;
473  t2t(*it, recHits, useSplitting);
474 
475  viTotHits += recHits.size();
476 
477  LogDebug("CkfPattern") << "getting initial state.";
478  Trajectory trialTrajectory = (*it);
479  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState;
480  bool failed = false;
481 
482  do {
483  // Drop last hit if previous backFitter was not successful
484  if (failed) {
485  LogDebug("CkfPattern") << "removing last hit";
486  trialTrajectory.pop();
487  LogDebug("CkfPattern") << "hits remaining " << trialTrajectory.foundHits();
488  }
489 
490  // Get inner state
491  const bool doBackFit = (!doSeedingRegionRebuilding) & (!reverseTrajectories);
492  initState = theInitialState->innerState(trialTrajectory, doBackFit);
493 
494  // Check if that was successful
495  failed = (!initState.first.isValid()) || initState.second == nullptr ||
496  edm::isNotFinite(initState.first.globalPosition().x());
497  } while (failed && trialTrajectory.foundHits() > 3);
498 
499  if (failed) {
500  const auto seedIndex = it->seedRef().key();
501  (*outputSeedStopInfos)[seedIndex].setStopReason(SeedStopReason::SMOOTHING_FAILED);
502  continue;
503  }
504 
505  PTrajectoryStateOnDet state;
506  if (useSplitting && (initState.second != recHits.front().det()) && recHits.front().det()) {
507  LogDebug("CkfPattern") << "propagating to hit front in case of splitting.";
508  TrajectoryStateOnSurface&& propagated =
509  thePropagator->propagate(initState.first, recHits.front().det()->surface());
510  if (!propagated.isValid())
511  continue;
512  state = trajectoryStateTransform::persistentState(propagated, recHits.front().rawId());
513  } else
514  state =
515  trajectoryStateTransform::persistentState(initState.first, initState.second->geographicalId().rawId());
516  LogDebug("CkfPattern") << "pushing a TrackCandidate.";
517  output->emplace_back(recHits, it->seed(), state, it->seedRef(), it->nLoops(), (uint8_t)it->stopReason());
518  }
519  } //output trackcandidates
520 
523  LogTrace("CkfPattern|TrackingRegressionTest") << "========== CkfTrackCandidateMaker Info =========="
524  << "number of Seed: " << collseed->size() << '\n'
525  << PrintoutHelper::regressionTest(*tracker, unsmoothedResult);
526 
527  assert(viTotHits >= 0); // just to use it...
528  // std::cout << "VICkfPattern result " << output->size() << " " << viTotHits << std::endl;
529 
530  if (theTrajectoryOutput) {
531  outputT->swap(unsmoothedResult);
532  }
533 
534  } // end of ((*collseed).size()>0)
535 
536  // method for debugging
538 
539  // Step G: write output to file
541  e.put(std::move(output));
542  }
543  if (theTrajectoryOutput) {
544  e.put(std::move(outputT));
545  }
546  e.put(std::move(outputSeedStopInfos));
547  }

References a, alongMomentum, cms::cuda::assert(), b, TrajectoryCleaner::clean(), cleanTrajectoryAfterInOut, countSeedsDebugger(), data, deleteAssocDebugger(), doSeedingRegionRebuilding, PrintoutHelper::dumpCandidates(), MillePedeFileConverter_cfg::e, runEdmFileComparison::failed, FINAL_CLEAN, Trajectory::foundHits(), edm::EventSetup::get(), get, hfClusterShapes_cfi::hits, mps_fire::i, cuy::ii, edm::isNotFinite(), TrajectoryStateOnSurface::isValid(), Trajectory::isValid(), dqmiolumiharvest::j, CommonMethods::lock(), LogDebug, LogTrace, maskPhase2OTs_, maskPixels_, maskStrips_, maxSeedsBeforeCleaning_, eostools::move(), mutex, NO_TRAJECTORY, NOT_STOPPED, oppositeToMomentum, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), phase2skipClusters_, Trajectory::pop(), printHitsDebugger(), Propagator::propagate(), Trajectory::push(), FastTrackerRecHitMaskProducer_cfi::recHits, PrintoutHelper::regressionTest(), Trajectory::reserve(), reverseTrajectories, SurveyInfoScenario_cff::seed, SEED_CLEANING, SEED_REGION_REBUILD, InitialStep_cff::seeds, setEventSetup(), Trajectory::setNLoops(), Trajectory::setSeedRef(), Trajectory::setStopReason(), skipClusters_, SMOOTHING_FAILED, theInitialState, theMaxNSeeds, theMTELabel, theSeedCleaner, theSeedLabel, theTrackCandidateOutput, theTrajectoryBuilder, theTrajectoryCleaner, theTrajectoryOutput, PbPb_ZMuSkimMuonDPG_cff::tracker, mitigatedMETSequence_cff::U, useSplitting, and heppy_batch::val.

Referenced by cms::CkfDebugTrackCandidateMaker::produce().

◆ setEventSetup()

void cms::CkfTrackCandidateMakerBase::setEventSetup ( const edm::EventSetup es)
private

Initialize EventSetup objects at each event.

Definition at line 127 of file CkfTrackCandidateMakerBase.cc.

127  {
128  //services
131  // edm::ESInputTag mfESInputTag(mfName);
132  // es.get<IdealMagneticFieldRecord>().get(mfESInputTag,theMagField );
133 
134  edm::ESHandle<TrajectoryCleaner> trajectoryCleanerH;
135  es.get<TrajectoryCleaner::Record>().get(theTrajectoryCleanerName, trajectoryCleanerH);
136  theTrajectoryCleaner = trajectoryCleanerH.product();
137 
138  edm::ESHandle<NavigationSchool> navigationSchoolH;
139  es.get<NavigationSchoolRecord>().get(theNavigationSchoolName, navigationSchoolH);
140  theNavigationSchool = navigationSchoolH.product();
141  theTrajectoryBuilder->setNavigationSchool(theNavigationSchool);
142  }

References edm::EventSetup::get(), get, edm::ESHandle< T >::product(), theGeomSearchTracker, theMagField, theMagFieldName, theNavigationSchool, theNavigationSchoolName, theTrajectoryBuilder, theTrajectoryCleaner, and theTrajectoryCleanerName.

Referenced by produceBase().

Member Data Documentation

◆ cleanTrajectoryAfterInOut

bool cms::CkfTrackCandidateMakerBase::cleanTrajectoryAfterInOut
protected

Definition at line 49 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ doSeedingRegionRebuilding

bool cms::CkfTrackCandidateMakerBase::doSeedingRegionRebuilding
protected

Definition at line 48 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ maskPhase2OTs_

edm::EDGetTokenT<Phase2OTClusterMask> cms::CkfTrackCandidateMakerBase::maskPhase2OTs_
protected

Definition at line 83 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ maskPixels_

edm::EDGetTokenT<PixelClusterMask> cms::CkfTrackCandidateMakerBase::maskPixels_
protected

Definition at line 81 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ maskStrips_

edm::EDGetTokenT<StripClusterMask> cms::CkfTrackCandidateMakerBase::maskStrips_
protected

Definition at line 82 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ maxSeedsBeforeCleaning_

unsigned int cms::CkfTrackCandidateMakerBase::maxSeedsBeforeCleaning_
protected

Definition at line 71 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ phase2skipClusters_

bool cms::CkfTrackCandidateMakerBase::phase2skipClusters_
protected

Definition at line 77 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ produceSeedStopReasons_

bool cms::CkfTrackCandidateMakerBase::produceSeedStopReasons_
protected

Definition at line 51 of file CkfTrackCandidateMakerBase.h.

◆ reverseTrajectories

bool cms::CkfTrackCandidateMakerBase::reverseTrajectories
protected

Definition at line 50 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ skipClusters_

bool cms::CkfTrackCandidateMakerBase::skipClusters_
protected

Definition at line 76 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ theGeomSearchTracker

edm::ESHandle<GeometricSearchTracker> cms::CkfTrackCandidateMakerBase::theGeomSearchTracker
protected

Definition at line 64 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

◆ theInitialState

std::unique_ptr<TransientInitialStateEstimator> cms::CkfTrackCandidateMakerBase::theInitialState
protected

Definition at line 60 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ theMagField

edm::ESHandle<MagneticField> cms::CkfTrackCandidateMakerBase::theMagField
protected

Definition at line 63 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

◆ theMagFieldName

const std::string cms::CkfTrackCandidateMakerBase::theMagFieldName
protected

Definition at line 62 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

◆ theMaxNSeeds

unsigned int cms::CkfTrackCandidateMakerBase::theMaxNSeeds
protected

Definition at line 53 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ theMTELabel

edm::EDGetTokenT<MeasurementTrackerEvent> cms::CkfTrackCandidateMakerBase::theMTELabel
protected

Definition at line 74 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ theNavigationSchool

const NavigationSchool* cms::CkfTrackCandidateMakerBase::theNavigationSchool
protected

Definition at line 67 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

◆ theNavigationSchoolName

std::string cms::CkfTrackCandidateMakerBase::theNavigationSchoolName
protected

Definition at line 66 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

◆ theSeedCleaner

std::unique_ptr<RedundantSeedCleaner> cms::CkfTrackCandidateMakerBase::theSeedCleaner
protected

Definition at line 69 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ theSeedLabel

edm::EDGetTokenT<edm::View<TrajectorySeed> > cms::CkfTrackCandidateMakerBase::theSeedLabel
protected

Definition at line 73 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

◆ theTrackCandidateOutput

bool cms::CkfTrackCandidateMakerBase::theTrackCandidateOutput
protected

Definition at line 45 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ theTrajectoryBuilder

std::unique_ptr<BaseCkfTrajectoryBuilder> cms::CkfTrackCandidateMakerBase::theTrajectoryBuilder
protected

◆ theTrajectoryCleaner

const TrajectoryCleaner* cms::CkfTrackCandidateMakerBase::theTrajectoryCleaner
protected

Definition at line 58 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase(), and setEventSetup().

◆ theTrajectoryCleanerName

std::string cms::CkfTrackCandidateMakerBase::theTrajectoryCleanerName
protected

Definition at line 57 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

◆ theTrajectoryOutput

bool cms::CkfTrackCandidateMakerBase::theTrajectoryOutput
protected

Definition at line 46 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

◆ useSplitting

bool cms::CkfTrackCandidateMakerBase::useSplitting
protected

Definition at line 47 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
cms::CkfTrackCandidateMakerBase::theGeomSearchTracker
edm::ESHandle< GeometricSearchTracker > theGeomSearchTracker
Definition: CkfTrackCandidateMakerBase.h:64
NavigationSchoolRecord
Definition: NavigationSchoolRecord.h:12
mps_fire.i
i
Definition: mps_fire.py:355
PrintoutHelper::dumpCandidates
static std::string dumpCandidates(collection &candidates)
Definition: PrintoutHelper.h:69
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
cms::CkfTrackCandidateMakerBase::PixelClusterMask
edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelClusterMask
Definition: CkfTrackCandidateMakerBase.h:78
SeedStopReason::NO_TRAJECTORY
cms::CkfTrackCandidateMakerBase::reverseTrajectories
bool reverseTrajectories
Definition: CkfTrackCandidateMakerBase.h:50
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
cms::CkfTrackCandidateMakerBase::theMagFieldName
const std::string theMagFieldName
Definition: CkfTrackCandidateMakerBase.h:62
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
cms::CkfTrackCandidateMakerBase::theMaxNSeeds
unsigned int theMaxNSeeds
Definition: CkfTrackCandidateMakerBase.h:53
cms::CkfTrackCandidateMakerBase::theSeedCleaner
std::unique_ptr< RedundantSeedCleaner > theSeedCleaner
Definition: CkfTrackCandidateMakerBase.h:69
PrintoutHelper::regressionTest
static std::string regressionTest(const TrackerGeometry &tracker, std::vector< Trajectory > &unsmoothedResult)
Definition: PrintoutHelper.cc:75
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::CkfTrackCandidateMakerBase::theTrajectoryOutput
bool theTrajectoryOutput
Definition: CkfTrackCandidateMakerBase.h:46
runEdmFileComparison.failed
failed
Definition: runEdmFileComparison.py:225
SeedStopReason::FINAL_CLEAN
cms::CkfTrackCandidateMakerBase::maskPixels_
edm::EDGetTokenT< PixelClusterMask > maskPixels_
Definition: CkfTrackCandidateMakerBase.h:81
oppositeToMomentum
Definition: PropagationDirection.h:4
cms::cuda::assert
assert(be >=bs)
cms::CkfTrackCandidateMakerBase::theMagField
edm::ESHandle< MagneticField > theMagField
Definition: CkfTrackCandidateMakerBase.h:63
cms::CkfTrackCandidateMakerBase::theTrajectoryCleaner
const TrajectoryCleaner * theTrajectoryCleaner
Definition: CkfTrackCandidateMakerBase.h:58
TrackerRecoGeometryRecord
Definition: TrackerRecoGeometryRecord.h:11
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
Trajectory::foundHits
int foundHits() const
Definition: Trajectory.h:206
TrajectoryCleaner::clean
virtual void clean(TempTrajectoryContainer &) const
Definition: TrajectoryCleaner.cc:5
cms::CkfTrackCandidateMakerBase::skipClusters_
bool skipClusters_
Definition: CkfTrackCandidateMakerBase.h:76
edm::Handle< MeasurementTrackerEvent >
cms::CkfTrackCandidateMakerBase::theTrajectoryBuilder
std::unique_ptr< BaseCkfTrajectoryBuilder > theTrajectoryBuilder
Definition: CkfTrackCandidateMakerBase.h:55
cms::CkfTrackCandidateMakerBase::theMTELabel
edm::EDGetTokenT< MeasurementTrackerEvent > theMTELabel
Definition: CkfTrackCandidateMakerBase.h:74
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
SeedStopReason::NOT_STOPPED
cms::CkfTrackCandidateMakerBase::useSplitting
bool useSplitting
Definition: CkfTrackCandidateMakerBase.h:47
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
cms::CkfTrackCandidateMakerBase::theTrackCandidateOutput
bool theTrackCandidateOutput
Definition: CkfTrackCandidateMakerBase.h:45
cms::CkfTrackCandidateMakerBase::maskStrips_
edm::EDGetTokenT< StripClusterMask > maskStrips_
Definition: CkfTrackCandidateMakerBase.h:82
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
cms::CkfTrackCandidateMakerBase::theSeedLabel
edm::EDGetTokenT< edm::View< TrajectorySeed > > theSeedLabel
Definition: CkfTrackCandidateMakerBase.h:73
Trajectory::DataContainer
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:40
cms::CkfTrackCandidateMakerBase::theInitialState
std::unique_ptr< TransientInitialStateEstimator > theInitialState
Definition: CkfTrackCandidateMakerBase.h:60
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< Propagator >
cms::CkfTrackCandidateMakerBase::Phase2OTClusterMask
edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTClusterMask
Definition: CkfTrackCandidateMakerBase.h:80
cms::CkfTrackCandidateMakerBase::printHitsDebugger
virtual void printHitsDebugger(edm::Event &e)
Definition: CkfTrackCandidateMakerBase.h:89
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
mutex
static boost::mutex mutex
Definition: Proxy.cc:9
b
double b
Definition: hdecay.h:118
cms::CkfTrackCandidateMakerBase::theTrajectoryCleanerName
std::string theTrajectoryCleanerName
Definition: CkfTrackCandidateMakerBase.h:57
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
highPtTripletStepTrackCandidates_cfi.numHitsForSeedCleaner
numHitsForSeedCleaner
Definition: highPtTripletStepTrackCandidates_cfi.py:22
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::LogWarning
Definition: MessageLogger.h:141
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:232
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
edm::View
Definition: CaloClusterFwd.h:14
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
a
double a
Definition: hdecay.h:119
cms::CkfTrackCandidateMakerBase::setEventSetup
void setEventSetup(const edm::EventSetup &es)
Initialize EventSetup objects at each event.
Definition: CkfTrackCandidateMakerBase.cc:127
CommonMethods.lock
def lock()
Definition: CommonMethods.py:82
Traj2TrackHits
Definition: Traj2TrackHits.h:16
SeedStopReason::SEED_REGION_REBUILD
cms::CkfTrackCandidateMakerBase::theNavigationSchool
const NavigationSchool * theNavigationSchool
Definition: CkfTrackCandidateMakerBase.h:67
cms::CkfTrackCandidateMakerBase::theNavigationSchoolName
std::string theNavigationSchoolName
Definition: CkfTrackCandidateMakerBase.h:66
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
Trajectory::pop
void pop()
Definition: Trajectory.cc:30
get
#define get
cms::CkfTrackCandidateMakerBase::countSeedsDebugger
virtual void countSeedsDebugger()
Definition: CkfTrackCandidateMakerBase.h:90
cms::CkfTrackCandidateMakerBase::phase2skipClusters_
bool phase2skipClusters_
Definition: CkfTrackCandidateMakerBase.h:77
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
cms::CkfTrackCandidateMakerBase::cleanTrajectoryAfterInOut
bool cleanTrajectoryAfterInOut
Definition: CkfTrackCandidateMakerBase.h:49
cms::CkfTrackCandidateMakerBase::StripClusterMask
edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > StripClusterMask
Definition: CkfTrackCandidateMakerBase.h:79
cms::CkfTrackCandidateMakerBase::maxSeedsBeforeCleaning_
unsigned int maxSeedsBeforeCleaning_
Definition: CkfTrackCandidateMakerBase.h:71
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
Trajectory
Definition: Trajectory.h:38
Exception
Definition: hltDiff.cc:246
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
cms::CkfTrackCandidateMakerBase::maskPhase2OTs_
edm::EDGetTokenT< Phase2OTClusterMask > maskPhase2OTs_
Definition: CkfTrackCandidateMakerBase.h:83
cms::CkfTrackCandidateMakerBase::deleteAssocDebugger
virtual void deleteAssocDebugger()
Definition: CkfTrackCandidateMakerBase.h:91
TrajectorySeed
Definition: TrajectorySeed.h:17
SeedStopReason::SMOOTHING_FAILED
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cms::CkfTrackCandidateMakerBase::doSeedingRegionRebuilding
bool doSeedingRegionRebuilding
Definition: CkfTrackCandidateMakerBase.h:48
cuy.ii
ii
Definition: cuy.py:590
edm::InputTag
Definition: InputTag.h:15
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
edm::OwnVector< TrackingRecHit >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HLTSiStripMonitoring_cff.MeasurementTrackerEvent
MeasurementTrackerEvent
Definition: HLTSiStripMonitoring_cff.py:224
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12
SeedStopReason::SEED_CLEANING