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 ()(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 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
 
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 35 of file CkfTrackCandidateMakerBase.h.

Member Typedef Documentation

Definition at line 81 of file CkfTrackCandidateMakerBase.h.

Definition at line 79 of file CkfTrackCandidateMakerBase.h.

Definition at line 80 of file CkfTrackCandidateMakerBase.h.

Constructor & Destructor Documentation

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

Definition at line 62 of file CkfTrackCandidateMakerBase.cc.

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

62  :
64  theTrajectoryOutput(false),
65  useSplitting(conf.getParameter<bool>("useHitsSplitting")),
66  doSeedingRegionRebuilding(conf.getParameter<bool>("doSeedingRegionRebuilding")),
67  cleanTrajectoryAfterInOut(conf.getParameter<bool>("cleanTrajectoryAfterInOut")),
68  reverseTrajectories(conf.existsAs<bool>("reverseTrajectories") && conf.getParameter<bool>("reverseTrajectories")),
69  theMaxNSeeds(conf.getParameter<unsigned int>("maxNSeeds")),
70  theTrajectoryBuilder(createBaseCkfTrajectoryBuilder(conf.getParameter<edm::ParameterSet>("TrajectoryBuilderPSet"), iC)),
71  theTrajectoryCleanerName(conf.getParameter<std::string>("TrajectoryCleaner")),
73  theInitialState(new TransientInitialStateEstimator(conf.getParameter<ParameterSet>("TransientInitialStateEstimatorParameters"))),
74  theMagFieldName(conf.exists("SimpleMagneticField") ? conf.getParameter<std::string>("SimpleMagneticField") : ""),
75  theNavigationSchoolName(conf.getParameter<std::string>("NavigationSchool")),
77  theSeedCleaner(0),
79  theMTELabel(iC.consumes<MeasurementTrackerEvent>(conf.getParameter<edm::InputTag>("MeasurementTrackerEvent"))),
80  skipClusters_(false),
81  phase2skipClusters_(false)
82  {
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 == "SeedCleanerByHitPosition") {
103  } else if (cleaner == "SeedCleanerBySharedInput") {
105  } else if (cleaner == "CachingSeedCleanerByHitPosition") {
107  } else if (cleaner == "CachingSeedCleanerBySharedInput") {
108  int numHitsForSeedCleaner = conf.existsAs<int>("numHitsForSeedCleaner") ?
109  conf.getParameter<int>("numHitsForSeedCleaner") : 4;
110  int onlyPixelHits = conf.existsAs<bool>("onlyPixelHitsForSeedCleaner") ?
111  conf.getParameter<bool>("onlyPixelHitsForSeedCleaner") : false;
112  theSeedCleaner = new CachingSeedCleanerBySharedInput(numHitsForSeedCleaner,onlyPixelHits);
113  } else if (cleaner == "none") {
114  theSeedCleaner = 0;
115  } else {
116  throw cms::Exception("RedundantSeedCleaner not found", cleaner);
117  }
118 #endif
119 
120 #ifdef VI_REPRODUCIBLE
121  std::cout << "CkfTrackCandidateMaker in reproducible setting" << std::endl;
122  assert(nullptr==theSeedCleaner);
123  assert(0>=maxSeedsBeforeCleaning_);
124 #endif
125 
126  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
edm::EDGetTokenT< StripClusterMask > maskStrips_
std::unique_ptr< TransientInitialStateEstimator > theInitialState
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelClusterMask
edm::EDGetTokenT< PixelClusterMask > maskPixels_
const TrajectoryCleaner * theTrajectoryCleaner
const NavigationSchool * theNavigationSchool
std::unique_ptr< BaseCkfTrajectoryBuilder > theTrajectoryBuilder
edm::EDGetTokenT< MeasurementTrackerEvent > theMTELabel
edm::EDGetTokenT< Phase2OTClusterMask > maskPhase2OTs_
edm::EDGetTokenT< edm::View< TrajectorySeed > > theSeedLabel
edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTClusterMask
edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > StripClusterMask
numHitsForSeedCleaner
these two parameters are relevant only for the CachingSeedCleanerBySharedInput
cms::CkfTrackCandidateMakerBase::~CkfTrackCandidateMakerBase ( )
virtual

Definition at line 130 of file CkfTrackCandidateMakerBase.cc.

References theSeedCleaner.

130  {
131  if (theSeedCleaner) delete theSeedCleaner;
132  }

Member Function Documentation

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

Definition at line 134 of file CkfTrackCandidateMakerBase.cc.

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

135  {
136  /* no op*/
137  }
virtual void cms::CkfTrackCandidateMakerBase::countSeedsDebugger ( )
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 89 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

89 {;}
virtual void cms::CkfTrackCandidateMakerBase::deleteAssocDebugger ( )
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 90 of file CkfTrackCandidateMakerBase.h.

References setEventSetup().

Referenced by produceBase().

90 {;}
virtual TrajectorySeedCollection::const_iterator cms::CkfTrackCandidateMakerBase::lastSeed ( TrajectorySeedCollection const &  theSeedColl)
inlineprotectedvirtual

Definition at line 87 of file CkfTrackCandidateMakerBase.h.

87 {return theSeedColl.end();}
virtual void cms::CkfTrackCandidateMakerBase::printHitsDebugger ( edm::Event e)
inlineprotectedvirtual

Reimplemented in cms::CkfDebugTrackCandidateMaker.

Definition at line 88 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

88 {;}
void cms::CkfTrackCandidateMakerBase::produceBase ( edm::Event e,
const edm::EventSetup es 
)
virtual

Definition at line 158 of file CkfTrackCandidateMakerBase.cc.

References a, RedundantSeedCleaner::add(), alongMomentum, b, TrajectoryCleaner::clean(), cleanTrajectoryAfterInOut, countSeedsDebugger(), data, deleteAssocDebugger(), TrackingRecHit::det(), RedundantSeedCleaner::done(), doSeedingRegionRebuilding, PrintoutHelper::dumpCandidates(), runEdmFileComparison::failed, Trajectory::foundHits(), edm::OwnVector< T, P >::front(), edm::EventSetup::get(), edm::Event::getByToken(), RedundantSeedCleaner::good(), hfClusterShapes_cfi::hits, i, cuy::ii, RedundantSeedCleaner::init(), edm::isNotFinite(), TrajectoryStateOnSurface::isValid(), Trajectory::isValid(), j, edm::RefToBase< T >::key(), CommonMethods::lock(), LogDebug, LogTrace, maskPhase2OTs_, maskPixels_, maskStrips_, maxSeedsBeforeCleaning_, eostools::move(), mutex, oppositeToMomentum, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), phase2skipClusters_, Trajectory::pop(), printHitsDebugger(), Propagator::propagate(), Trajectory::push(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), TrackingRecHit::rawId(), PrintoutHelper::regressionTest(), Trajectory::reserve(), reverseTrajectories, SurveyInfoScenario_cff::seed, Trajectory::seedRef(), setEventSetup(), Trajectory::setNLoops(), Trajectory::setSeedRef(), Trajectory::setStopReason(), edm::OwnVector< T, P >::size(), skipClusters_, GeomDet::surface(), theInitialState, theMaxNSeeds, theMTELabel, theSeedCleaner, theSeedLabel, theTrackCandidateOutput, theTrajectoryBuilder, theTrajectoryCleaner, theTrajectoryOutput, mixOne_simraw_on_sim_cfi::tracker, mitigatedMETSequence_cff::U, useSplitting, and heppy_batch::val.

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

159  {
160  // getting objects from the EventSetup
161  setEventSetup( es );
162 
163  // set the correct navigation
164  // NavigationSetter setter( *theNavigationSchool);
165 
166  // propagator
167  edm::ESHandle<Propagator> thePropagator;
168  es.get<TrackingComponentsRecord>().get("AnyDirectionAnalyticalPropagator",
169  thePropagator);
170 
171  // method for Debugging
173 
174  // Step A: set Event for the TrajectoryBuilder
176  e.getByToken(theMTELabel, data);
177 
178  std::unique_ptr<MeasurementTrackerEvent> dataWithMasks;
179  if (skipClusters_) {
181  e.getByToken(maskPixels_, pixelMask);
183  e.getByToken(maskStrips_, stripMask);
184  dataWithMasks = std::make_unique<MeasurementTrackerEvent>(*data, *stripMask, *pixelMask);
185  //std::cout << "Trajectory builder " << conf_.getParameter<std::string>("@module_label") << " created with masks " << std::endl;
186  theTrajectoryBuilder->setEvent(e, es, &*dataWithMasks);
187  } else if (phase2skipClusters_) {
188  //FIXME:just temporary solution for phase2!
190  e.getByToken(maskPixels_, pixelMask);
192  e.getByToken(maskPhase2OTs_, phase2OTMask);
193  dataWithMasks = std::make_unique<MeasurementTrackerEvent>(*data, *pixelMask, *phase2OTMask);
194  //std::cout << "Trajectory builder " << conf_.getParameter<std::string>("@module_label") << " created with phase2 masks " << std::endl;
195  theTrajectoryBuilder->setEvent(e, es, &*dataWithMasks);
196  } else {
197  //std::cout << "Trajectory builder " << conf_.getParameter<std::string>("@module_label") << " created without masks " << std::endl;
198  theTrajectoryBuilder->setEvent(e, es, &*data);
199  }
200  // TISE ES must be set here due to dependence on theTrajectoryBuilder
201  theInitialState->setEventSetup( es, static_cast<TkTransientTrackingRecHitBuilder const *>(theTrajectoryBuilder->hitBuilder())->cloner() );
202 
203  // Step B: Retrieve seeds
204 
206  e.getByToken(theSeedLabel, collseed);
207 
208  // Step C: Create empty output collection
209  auto output = std::make_unique<TrackCandidateCollection>();
210  auto outputT = std::make_unique<std::vector<Trajectory>>();
211 
212  if ( (*collseed).size()>theMaxNSeeds ) {
213  LogError("TooManySeeds")<<"Exceeded maximum numeber of seeds! theMaxNSeeds="<<theMaxNSeeds<<" nSeed="<<(*collseed).size();
215  if (theTrajectoryOutput){e.put(std::move(outputT));}
216  return;
217  }
218 
219  // Step D: Invoke the building algorithm
220  if ((*collseed).size()>0){
221 
222  unsigned int lastCleanResult=0;
223  std::vector<Trajectory> rawResult;
224  rawResult.reserve(collseed->size() * 4);
225 
226  if (theSeedCleaner) theSeedCleaner->init( &rawResult );
227 
228  // method for debugging
230 
231  // the mutex
232  std::mutex theMutex;
233  using Lock = std::unique_lock<std::mutex>;
234 
235  // Loop over seeds
236  size_t collseed_size = collseed->size();
237 
238  unsigned int indeces[collseed_size]; for (auto i=0U; i< collseed_size; ++i) indeces[i]=i;
239 
240 
241 
242 
243 #ifdef VI_SORTSEED
244  // std::random_shuffle(indeces,indeces+collseed_size);
245 
246  // here only for reference: does not seems to help
247 
248  auto const & seeds = *collseed;
249 
250 
251  float val[collseed_size];
252  for (auto i=0U; i< collseed_size; ++i)
253  { val[i] = seeds[i].startingState().pt();};
254  // { val[i] = std::abs((*seeds[i].recHits().first).surface()->eta());}
255 
256  /*
257  unsigned long long val[collseed_size];
258  for (auto i=0U; i< collseed_size; ++i) {
259  if (seeds[i].nHits()<2) { val[i]=0; continue;}
260  auto h = seeds[i].recHits().first;
261  auto const & hit = static_cast<BaseTrackerRecHit const&>(*h);
262  val[i] = hit.firstClusterRef().key();
263  if (++h != seeds[i].recHits().second) {
264  auto const & hit = static_cast<BaseTrackerRecHit const&>(*h);
265  val[i] |= (unsigned long long)(hit.firstClusterRef().key())<<32;
266  }
267  }
268  */
269  std::sort(indeces,indeces+collseed_size, [&](unsigned int i, unsigned int j){return val[i]<val[j];});
270 
271 
272  // std::cout << spt(indeces[0]) << ' ' << spt(indeces[collseed_size-1]) << std::endl;
273 #endif
274 
275  std::atomic<unsigned int> ntseed(0);
276  auto theLoop = [&](size_t ii) {
277  auto j = indeces[ii];
278 
279  ntseed++;
280 
281  // to be moved inside a par section (how with tbb??)
282  std::vector<Trajectory> theTmpTrajectories;
283 
284 
285  LogDebug("CkfPattern") << "======== Begin to look for trajectories from seed " << j << " ========\n";
286 
287  { Lock lock(theMutex);
288  // Check if seed hits already used by another track
289  if (theSeedCleaner && !theSeedCleaner->good( &((*collseed)[j])) ) {
290  LogDebug("CkfTrackCandidateMakerBase")<<" Seed cleaning kills seed "<<j;
291  return; // from the lambda!
292  }}
293 
294 
295  // Build trajectory from seed outwards
296  theTmpTrajectories.clear();
297  auto const & startTraj = theTrajectoryBuilder->buildTrajectories( (*collseed)[j], theTmpTrajectories, nullptr );
298 
299  LogDebug("CkfPattern") << "======== In-out trajectory building found " << theTmpTrajectories.size()
300  << " trajectories from seed " << j << " ========\n"
301  <<PrintoutHelper::dumpCandidates(theTmpTrajectories);
302 
304 
305  // Select the best trajectory from this seed (declare others invalid)
306  theTrajectoryCleaner->clean(theTmpTrajectories);
307 
308  LogDebug("CkfPattern") << "======== In-out trajectory cleaning gave the following " << theTmpTrajectories.size()
309  << " valid trajectories from seed "
310  << 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  }
324 
325 
326  // Select the best trajectory from this seed (after seed region rebuilding, can be more than one)
327  theTrajectoryCleaner->clean(theTmpTrajectories);
328 
329  LogDebug("CkfPattern") << "======== Trajectory cleaning gave the following " << theTmpTrajectories.size() << " valid trajectories from seed "
330  << j << " ========\n"
331  <<PrintoutHelper::dumpCandidates(theTmpTrajectories);
332 
333  { Lock lock(theMutex);
334  for(vector<Trajectory>::iterator it=theTmpTrajectories.begin();
335  it!=theTmpTrajectories.end(); it++){
336  if( it->isValid() ) {
337  it->setSeedRef(collseed->refAt(j));
338  // Store trajectory
339  rawResult.push_back(std::move(*it));
340  // Tell seed cleaner which hits this trajectory used.
341  //TO BE FIXED: this cut should be configurable via cfi file
342  if (theSeedCleaner && rawResult.back().foundHits()>3) theSeedCleaner->add( &rawResult.back() );
343  //if (theSeedCleaner ) theSeedCleaner->add( & (*it) );
344  }
345  }}
346 
347  theTmpTrajectories.clear();
348 
349  LogDebug("CkfPattern") << "rawResult trajectories found so far = " << rawResult.size();
350 
351  { Lock lock(theMutex);
352  if ( maxSeedsBeforeCleaning_ >0 && rawResult.size() > maxSeedsBeforeCleaning_+lastCleanResult) {
353  theTrajectoryCleaner->clean(rawResult);
354  rawResult.erase(std::remove_if(rawResult.begin()+lastCleanResult,rawResult.end(),
355  std::not1(std::mem_fun_ref(&Trajectory::isValid))),
356  rawResult.end());
357  lastCleanResult=rawResult.size();
358  }
359  }
360 
361  };
362  // end of loop over seeds
363 
364 
365 #ifdef VI_TBB
366  tbb::parallel_for(0UL,collseed_size,1UL,theLoop);
367 #else
368 #ifdef VI_OMP
369 #pragma omp parallel for schedule(dynamic,4)
370 #endif
371  for (size_t j = 0; j < collseed_size; j++){
372  theLoop(j);
373  }
374 #endif
375  assert(ntseed==collseed_size);
377 
378  // std::cout << "VICkfPattern " << "rawResult trajectories found = " << rawResult.size() << " in " << ntseed << " seeds " << collseed_size << std::endl;
379 
380 #ifdef VI_REPRODUCIBLE
381  // sort trajectory
382  std::sort(rawResult.begin(), rawResult.end(),[](const Trajectory & a, const Trajectory & b)
383  { return a.seedRef().key() < b.seedRef().key();});
384  //{ return a.chiSquared()*b.ndof() < b.chiSquared()*a.ndof();});
385 #endif
386 
387  // Step E: Clean the results to avoid duplicate tracks
388  // Rejected ones just flagged as invalid.
389  theTrajectoryCleaner->clean(rawResult);
390 
391  LogDebug("CkfPattern") << "======== Final cleaning of entire event found " << rawResult.size()
392  << " valid/invalid trajectories ======="<<endl
393  <<PrintoutHelper::dumpCandidates(rawResult);
394 
395  LogDebug("CkfPattern") << "removing invalid trajectories.";
396 
397  vector<Trajectory> & unsmoothedResult(rawResult);
398  unsmoothedResult.erase(std::remove_if(unsmoothedResult.begin(),unsmoothedResult.end(),
399  std::not1(std::mem_fun_ref(&Trajectory::isValid))),
400  unsmoothedResult.end());
401  unsmoothedResult.shrink_to_fit();
402  // If requested, reverse the trajectories creating a new 1-hit seed on the last measurement of the track
403  if (reverseTrajectories) {
404  for (auto it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
405  // reverse the trajectory only if it has valid hit on the last measurement (should happen)
406  if (it->lastMeasurement().updatedState().isValid() &&
407  it->lastMeasurement().recHit().get() != 0 &&
408  it->lastMeasurement().recHit()->isValid()) {
409  // I can't use reverse in place, because I want to change the seed
410  // 1) reverse propagation direction
411  PropagationDirection direction = it->direction();
412  if (direction == alongMomentum) direction = oppositeToMomentum;
413  else if (direction == oppositeToMomentum) direction = alongMomentum;
414  // 2) make a seed
415  TrajectoryStateOnSurface const & initState = it->lastMeasurement().updatedState();
416  auto initId = it->lastMeasurement().recHitR().rawId();
419  hits.push_back(it->lastMeasurement().recHit()->hit()->clone());
420  boost::shared_ptr<const TrajectorySeed> seed(new TrajectorySeed(state, std::move(hits), direction));
421  // 3) make a trajectory
422  Trajectory trajectory(seed, direction);
423  trajectory.setNLoops(it->nLoops());
424  trajectory.setSeedRef(it->seedRef());
425  trajectory.setStopReason(it->stopReason());
426  // 4) push states in reversed order
427  Trajectory::DataContainer &meas = it->measurements();
428  trajectory.reserve(meas.size());
429  for (auto itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
430  trajectory.push(std::move(*itmeas));
431  }
432  // replace
433  (*it)= std::move(trajectory);
434  } else {
435  edm::LogWarning("CkfPattern_InvalidLastMeasurement") << "Last measurement of the trajectory is invalid, cannot reverse it";
436  }
437  }
438  }
439 
440 
441  int viTotHits=0;
442 
444  // Step F: Convert to TrackCandidates
445  output->reserve(unsmoothedResult.size());
446  Traj2TrackHits t2t(theTrajectoryBuilder->hitBuilder(),true);
447 
448  for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin();
449  it != unsmoothedResult.end(); ++it) {
450 
451  LogDebug("CkfPattern") << "copying "<<(useSplitting?"splitted":"un-splitted")<<" hits from trajectory";
453  if(it->direction() != alongMomentum) LogDebug("CkfPattern") << "not along momentum... " << std::endl;
454  t2t(*it,recHits,useSplitting);
455 
456  viTotHits+=recHits.size();
457 
458 
459  LogDebug("CkfPattern") << "getting initial state.";
460  Trajectory trialTrajectory = (*it);
461  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState;
462  bool failed = false;
463 
464  do {
465  // Drop last hit if previous backFitter was not successful
466  if(failed) {
467  LogDebug("CkfPattern") << "removing last hit";
468  trialTrajectory.pop();
469  LogDebug("CkfPattern") << "hits remaining " << trialTrajectory.foundHits();
470  }
471 
472  // Get inner state
473  const bool doBackFit = (!doSeedingRegionRebuilding) & (!reverseTrajectories);
474  initState = theInitialState->innerState(trialTrajectory, doBackFit);
475 
476  // Check if that was successful
477  failed = (!initState.first.isValid()) || initState.second == nullptr || edm::isNotFinite(initState.first.globalPosition().x());
478  } while(failed && trialTrajectory.foundHits() > 3);
479 
480  if(failed) continue;
481 
482 
483 
484  PTrajectoryStateOnDet state;
485  if(useSplitting && (initState.second != recHits.front().det()) && recHits.front().det() ){
486  LogDebug("CkfPattern") << "propagating to hit front in case of splitting.";
487  TrajectoryStateOnSurface && propagated = thePropagator->propagate(initState.first,recHits.front().det()->surface());
488  if (!propagated.isValid()) continue;
490  recHits.front().rawId());
491  }
492  else state = trajectoryStateTransform::persistentState( initState.first,
493  initState.second->geographicalId().rawId());
494  LogDebug("CkfPattern") << "pushing a TrackCandidate.";
495  output->emplace_back(recHits,it->seed(),state,it->seedRef(),it->nLoops(), (uint8_t)it->stopReason());
496  }
497  }//output trackcandidates
498 
500  es.get<TrackerDigiGeometryRecord>().get(tracker);
501  LogTrace("CkfPattern|TrackingRegressionTest") << "========== CkfTrackCandidateMaker Info =========="
502  << "number of Seed: " << collseed->size()<<'\n'
503  <<PrintoutHelper::regressionTest(*tracker,unsmoothedResult);
504 
505  assert(viTotHits>=0); // just to use it...
506  // std::cout << "VICkfPattern result " << output->size() << " " << viTotHits << std::endl;
507 
508  if (theTrajectoryOutput){ outputT->swap(unsmoothedResult);}
509 
510  }// end of ((*collseed).size()>0)
511 
512  // method for debugging
514 
515  // Step G: write output to file
517  if (theTrajectoryOutput){e.put(std::move(outputT));}
518  }
#define LogDebug(id)
int foundHits() const
Definition: Trajectory.h:225
int i
Definition: DBlmapReader.cc:9
static std::string dumpCandidates(collection &candidates)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual void clean(TempTrajectoryContainer &) const
static boost::mutex mutex
Definition: LHEProxy.cc:11
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< StripClusterMask > maskStrips_
std::unique_ptr< TransientInitialStateEstimator > theInitialState
size_type size() const
Definition: OwnVector.h:264
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
virtual void printHitsDebugger(edm::Event &e)
PropagationDirection
virtual void done()=0
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
virtual void add(const Trajectory *traj)=0
Informs the cleaner that a new trajectory has been made, in case the cleaner keeps a local collection...
virtual bool good(const TrajectorySeed *seed)=0
Returns true if the seed is not overlapping with another trajectory.
static std::string regressionTest(const TrackerGeometry &tracker, std::vector< Trajectory > &unsmoothedResult)
void push_back(D *&d)
Definition: OwnVector.h:290
edm::EDGetTokenT< PixelClusterMask > maskPixels_
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:44
bool isNotFinite(T x)
Definition: isFinite.h:10
const TrajectoryCleaner * theTrajectoryCleaner
const GeomDet * det() const
size_t key() const
Definition: RefToBase.h:250
std::unique_ptr< BaseCkfTrajectoryBuilder > theTrajectoryBuilder
edm::EDGetTokenT< MeasurementTrackerEvent > theMTELabel
int j
Definition: DBlmapReader.cc:9
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:321
edm::EDGetTokenT< Phase2OTClusterMask > maskPhase2OTs_
#define LogTrace(id)
edm::EDGetTokenT< edm::View< TrajectorySeed > > theSeedLabel
ii
Definition: cuy.py:588
bool isValid() const
Definition: Trajectory.h:279
void pop()
Definition: Trajectory.cc:29
const T & get() const
Definition: EventSetup.h:56
double b
Definition: hdecay.h:120
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
void setEventSetup(const edm::EventSetup &es)
Initialize EventSetup objects at each event.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double a
Definition: hdecay.h:121
virtual void init(const std::vector< Trajectory > *vect)=0
Provides the cleaner a pointer to the vector where trajectories are stored, in case it does not want ...
reference front()
Definition: OwnVector.h:423
def move(src, dest)
Definition: eostools.py:510
id_type rawId() const
void cms::CkfTrackCandidateMakerBase::setEventSetup ( const edm::EventSetup es)
private

Initialize EventSetup objects at each event.

Definition at line 139 of file CkfTrackCandidateMakerBase.cc.

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

Referenced by deleteAssocDebugger(), and produceBase().

139  {
140 
141  //services
144  // edm::ESInputTag mfESInputTag(mfName);
145  // es.get<IdealMagneticFieldRecord>().get(mfESInputTag,theMagField );
146 
147  edm::ESHandle<TrajectoryCleaner> trajectoryCleanerH;
148  es.get<TrajectoryCleaner::Record>().get(theTrajectoryCleanerName, trajectoryCleanerH);
149  theTrajectoryCleaner= trajectoryCleanerH.product();
150 
151  edm::ESHandle<NavigationSchool> navigationSchoolH;
152  es.get<NavigationSchoolRecord>().get(theNavigationSchoolName, navigationSchoolH);
153  theNavigationSchool = navigationSchoolH.product();
154  theTrajectoryBuilder->setNavigationSchool(theNavigationSchool);
155  }
edm::ESHandle< GeometricSearchTracker > theGeomSearchTracker
const TrajectoryCleaner * theTrajectoryCleaner
const NavigationSchool * theNavigationSchool
std::unique_ptr< BaseCkfTrajectoryBuilder > theTrajectoryBuilder
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
edm::ESHandle< MagneticField > theMagField

Member Data Documentation

bool cms::CkfTrackCandidateMakerBase::cleanTrajectoryAfterInOut
protected

Definition at line 51 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

bool cms::CkfTrackCandidateMakerBase::doSeedingRegionRebuilding
protected

Definition at line 50 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

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

Definition at line 84 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

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

Definition at line 82 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

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

Definition at line 83 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

unsigned int cms::CkfTrackCandidateMakerBase::maxSeedsBeforeCleaning_
protected

Definition at line 72 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

bool cms::CkfTrackCandidateMakerBase::phase2skipClusters_
protected

Definition at line 78 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

bool cms::CkfTrackCandidateMakerBase::reverseTrajectories
protected

Definition at line 52 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

bool cms::CkfTrackCandidateMakerBase::skipClusters_
protected

Definition at line 77 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

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

Definition at line 65 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

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

Definition at line 61 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

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

Definition at line 64 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

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

Definition at line 63 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

unsigned int cms::CkfTrackCandidateMakerBase::theMaxNSeeds
protected

Definition at line 54 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

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

Definition at line 75 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

const NavigationSchool* cms::CkfTrackCandidateMakerBase::theNavigationSchool
protected

Definition at line 68 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

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

Definition at line 67 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

RedundantSeedCleaner* cms::CkfTrackCandidateMakerBase::theSeedCleaner
protected
edm::EDGetTokenT<edm::View<TrajectorySeed> > cms::CkfTrackCandidateMakerBase::theSeedLabel
protected

Definition at line 74 of file CkfTrackCandidateMakerBase.h.

Referenced by CkfTrackCandidateMakerBase(), and produceBase().

bool cms::CkfTrackCandidateMakerBase::theTrackCandidateOutput
protected

Definition at line 47 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

std::unique_ptr<BaseCkfTrajectoryBuilder> cms::CkfTrackCandidateMakerBase::theTrajectoryBuilder
protected
const TrajectoryCleaner* cms::CkfTrackCandidateMakerBase::theTrajectoryCleaner
protected

Definition at line 59 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase(), and setEventSetup().

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

Definition at line 58 of file CkfTrackCandidateMakerBase.h.

Referenced by setEventSetup().

bool cms::CkfTrackCandidateMakerBase::theTrajectoryOutput
protected

Definition at line 48 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().

bool cms::CkfTrackCandidateMakerBase::useSplitting
protected

Definition at line 49 of file CkfTrackCandidateMakerBase.h.

Referenced by produceBase().