50 theTrackCandidateOutput(
true),
51 theTrajectoryOutput(
false),
52 useSplitting(conf.getParameter<bool>(
"useHitsSplitting")),
53 doSeedingRegionRebuilding(conf.getParameter<bool>(
"doSeedingRegionRebuilding")),
54 cleanTrajectoryAfterInOut(conf.getParameter<bool>(
"cleanTrajectoryAfterInOut")),
55 reverseTrajectories(conf.existsAs<bool>(
"reverseTrajectories") && conf.getParameter<bool>(
"reverseTrajectories")),
56 theMaxNSeeds(conf.getParameter<unsigned int>(
"maxNSeeds")),
57 theTrajectoryBuilderName(conf.getParameter<std::
string>(
"TrajectoryBuilder")),
58 theTrajectoryBuilder(0),
59 theTrajectoryCleanerName(conf.getParameter<std::
string>(
"TrajectoryCleaner")),
60 theTrajectoryCleaner(0),
62 theNavigationSchoolName(conf.getParameter<std::
string>(
"NavigationSchool")),
63 theNavigationSchool(0),
65 maxSeedsBeforeCleaning_(0),
75 if ( conf.
exists(
"maxSeedsBeforeCleaning") )
86 if (cleaner ==
"SeedCleanerByHitPosition") {
88 }
else if (cleaner ==
"SeedCleanerBySharedInput") {
90 }
else if (cleaner ==
"CachingSeedCleanerByHitPosition") {
92 }
else if (cleaner ==
"CachingSeedCleanerBySharedInput") {
93 int numHitsForSeedCleaner =
conf_.
existsAs<
int>(
"numHitsForSeedCleaner") ?
95 int onlyPixelHits =
conf_.
existsAs<
bool>(
"onlyPixelHitsForSeedCleaner") ?
98 }
else if (cleaner ==
"none") {
175 std::auto_ptr<BaseCkfTrajectoryBuilder> trajectoryBuilder;
176 std::auto_ptr<MeasurementTrackerEvent> dataWithMasks;
180 if (data->isStripRegional()) {
203 std::auto_ptr<std::vector<Trajectory> > outputT (
new std::vector<Trajectory>());
206 LogError(
"TooManySeeds")<<
"Exceeded maximum numeber of seeds! theMaxNSeeds="<<
theMaxNSeeds<<
" nSeed="<<(*collseed).size();
213 if ((*collseed).size()>0){
215 unsigned int lastCleanResult=0;
216 vector<Trajectory> rawResult;
217 rawResult.reserve(collseed->size() * 4);
224 vector<Trajectory> theTmpTrajectories;
227 size_t collseed_size = collseed->size();
228 for (
size_t j = 0;
j < collseed_size;
j++){
230 LogDebug(
"CkfPattern") <<
"======== Begin to look for trajectories from seed " <<
j <<
" ========"<<endl;
234 LogDebug(
"CkfTrackCandidateMakerBase")<<
" Seed cleaning kills seed "<<
j;
239 theTmpTrajectories.clear();
240 auto const & startTraj = trajectoryBuilder->buildTrajectories( (*collseed)[j], theTmpTrajectories,
nullptr );
243 LogDebug(
"CkfPattern") <<
"======== In-out trajectory building found " << theTmpTrajectories.size()
244 <<
" trajectories from seed " << j <<
" ========"<<endl
252 LogDebug(
"CkfPattern") <<
"======== In-out trajectory cleaning gave the following valid trajectories from seed "
253 << j <<
" ========"<<endl
261 trajectoryBuilder->rebuildTrajectories(startTraj,(*collseed)[j],theTmpTrajectories);
263 LogDebug(
"CkfPattern") <<
"======== Out-in trajectory building found " << theTmpTrajectories.size()
264 <<
" valid/invalid trajectories from seed " << j <<
" ========"<<endl
272 LogDebug(
"CkfPattern") <<
"======== Trajectory cleaning gave the following valid trajectories from seed "
273 << j <<
" ========"<<endl
276 for(vector<Trajectory>::iterator it=theTmpTrajectories.begin();
277 it!=theTmpTrajectories.end(); it++){
278 if( it->isValid() ) {
279 it->setSeedRef(collseed->refAt(j));
281 rawResult.push_back(*it);
289 theTmpTrajectories.clear();
291 LogDebug(
"CkfPattern") <<
"rawResult trajectories found so far = " << rawResult.size();
295 rawResult.erase(std::remove_if(rawResult.begin(),rawResult.end(),
298 lastCleanResult=rawResult.size();
310 LogDebug(
"CkfPattern") <<
"======== Final cleaning of entire event found " << rawResult.size()
311 <<
" valid/invalid trajectories ======="<<endl
314 LogDebug(
"CkfPattern") <<
"removing invalid trajectories.";
316 vector<Trajectory> & unsmoothedResult(rawResult);
317 unsmoothedResult.erase(std::remove_if(unsmoothedResult.begin(),unsmoothedResult.end(),
319 unsmoothedResult.end());
323 vector<Trajectory> reversed;
324 reversed.reserve(unsmoothedResult.size());
325 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
327 if (it->lastMeasurement().updatedState().isValid() &&
328 it->lastMeasurement().recHit().get() != 0 &&
329 it->lastMeasurement().recHit()->isValid()) {
337 DetId initDetId = it->lastMeasurement().recHit()->geographicalId();
340 hits.
push_back(*it->lastMeasurement().recHit()->hit());
341 boost::shared_ptr<const TrajectorySeed> seed(
new TrajectorySeed(state, hits, direction));
348 for (Trajectory::DataContainer::const_reverse_iterator itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
349 trajectory.
push(*itmeas);
351 reversed.push_back(trajectory);
353 edm::LogWarning(
"CkfPattern_InvalidLastMeasurement") <<
"Last measurement of the trajectory is invalid, cannot reverse it";
354 reversed.push_back(*it);
357 unsmoothedResult.swap(reversed);
369 output->reserve(unsmoothedResult.size());
370 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin();
371 it != unsmoothedResult.end(); ++it) {
375 LogDebug(
"CkfPattern") <<
"retrieving "<<(
useSplitting?
"splitted":
"un-splitted")<<
" hits from trajectory";
379 LogDebug(
"CkfPattern") <<
"cloning hits into new collection.";
380 for (Trajectory::RecHitContainer::const_iterator hitIt = thits.begin();
381 hitIt != thits.end(); ++hitIt) {
382 recHits.
push_back( (**hitIt).hit()->clone());
385 LogDebug(
"CkfPattern") <<
"getting initial state.";
387 std::pair<TrajectoryStateOnSurface, const GeomDet*> initState =
391 if (! initState.first.isValid() || initState.second == 0 ||
edm::isNotFinite(initState.first.globalPosition().x())) {
397 if(
useSplitting && (initState.second != thits.front()->det()) && thits.front()->det() ){
398 LogDebug(
"CkfPattern") <<
"propagating to hit front in case of splitting.";
400 if (!propagated.
isValid())
continue;
402 thits.front()->det()->geographicalId().rawId());
405 initState.second->geographicalId().rawId());
406 LogDebug(
"CkfPattern") <<
"pushing a TrackCandidate.";
407 output->push_back(
TrackCandidate(recHits,it->seed(),state,it->seedRef(),it->nLoops() ) );
413 LogTrace(
"CkfPattern|TrackingRegressionTest") <<
"========== CkfTrackCandidateMaker Info =========="
414 <<
"number of Seed: " << collseed->size()<<endl
virtual ~CkfTrackCandidateMakerBase()
T getParameter(std::string const &) const
virtual void deleteAssocDebugger()
static std::string dumpCandidates(collection &candidates)
void setEventSetup(const edm::EventSetup &es)
Call this at each event until this object will come from the EventSetup as it should.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
const BaseCkfTrajectoryBuilder * theTrajectoryBuilder
bool theTrackCandidateOutput
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< StripClusterMask > maskStrips_
std::vector< TrackCandidate > TrackCandidateCollection
void setNLoops(signed char value)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
tuple MeasurementTrackerEvent
virtual void printHitsDebugger(edm::Event &e)
edm::ESHandle< GeometricSearchTracker > theGeomSearchTracker
virtual void done()=0
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.
unsigned int theMaxNSeeds
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.
uint32_t rawId() const
get the raw id
static std::string regressionTest(const TrackerGeometry &tracker, std::vector< Trajectory > &unsmoothedResult)
edm::EDGetTokenT< PixelClusterMask > maskPixels_
std::vector< TrajectoryMeasurement > DataContainer
const TrajectoryCleaner * theTrajectoryCleaner
const NavigationSchool * theNavigationSchool
std::string theNavigationSchoolName
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void produceBase(edm::Event &e, const edm::EventSetup &es)
virtual void clean(TrajectoryContainer &) const
edm::EDGetTokenT< MeasurementTrackerEvent > theMTELabel
unsigned int maxSeedsBeforeCleaning_
edm::EDGetTokenT< edm::View< TrajectorySeed > > theSeedLabel
std::string theTrajectoryCleanerName
ConstRecHitContainer RecHitContainer
T const * product() const
bool doSeedingRegionRebuilding
TransientInitialStateEstimator * theInitialState
void setSeedRef(const edm::RefToBase< TrajectorySeed > &seedRef)
void setEventSetup(const edm::EventSetup &es)
Initialize EventSetup objects at each event.
std::string theTrajectoryBuilderName
virtual void beginRunBase(edm::Run const &, edm::EventSetup const &es)
char data[epos_bytes_allocation]
edm::EDGetTokenT< StripClusterLazyMask > maskStripsLazy_
virtual BaseCkfTrajectoryBuilder * clone(const MeasurementTrackerEvent *data) const =0
volatile std::atomic< bool > shutdown_flag false
virtual void countSeedsDebugger()
void push(const TrajectoryMeasurement &tm)
std::pair< TrajectoryStateOnSurface, const GeomDet * > innerState(const Trajectory &traj, bool doBackFit=true) const
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 ...
bool cleanTrajectoryAfterInOut
RedundantSeedCleaner * theSeedCleaner
edm::ESHandle< MagneticField > theMagField