57 theTrackCandidateOutput(
true),
58 theTrajectoryOutput(
false),
59 useSplitting(conf.getParameter<bool>(
"useHitsSplitting")),
60 doSeedingRegionRebuilding(conf.getParameter<bool>(
"doSeedingRegionRebuilding")),
61 cleanTrajectoryAfterInOut(conf.getParameter<bool>(
"cleanTrajectoryAfterInOut")),
62 reverseTrajectories(conf.existsAs<bool>(
"reverseTrajectories") && conf.getParameter<bool>(
"reverseTrajectories")),
63 theMaxNSeeds(conf.getParameter<unsigned int>(
"maxNSeeds")),
64 theTrajectoryBuilder(createBaseCkfTrajectoryBuilder(conf.getParameter<edm::
ParameterSet>(
"TrajectoryBuilderPSet"), iC)),
65 theTrajectoryCleanerName(conf.getParameter<std::
string>(
"TrajectoryCleaner")),
66 theTrajectoryCleaner(0),
68 theMagFieldName(conf.exists(
"SimpleMagneticField") ? conf.getParameter<std::
string>(
"SimpleMagneticField") :
""),
69 theNavigationSchoolName(conf.getParameter<std::
string>(
"NavigationSchool")),
70 theNavigationSchool(0),
72 maxSeedsBeforeCleaning_(0),
82 if ( conf.
exists(
"maxSeedsBeforeCleaning") )
92 if (cleaner ==
"SeedCleanerByHitPosition") {
94 }
else if (cleaner ==
"SeedCleanerBySharedInput") {
96 }
else if (cleaner ==
"CachingSeedCleanerByHitPosition") {
98 }
else if (cleaner ==
"CachingSeedCleanerBySharedInput") {
99 int numHitsForSeedCleaner = conf.
existsAs<
int>(
"numHitsForSeedCleaner") ?
101 int onlyPixelHits = conf.
existsAs<
bool>(
"onlyPixelHitsForSeedCleaner") ?
102 conf.
getParameter<
bool>(
"onlyPixelHitsForSeedCleaner") :
false;
104 }
else if (cleaner ==
"none") {
163 std::auto_ptr<MeasurementTrackerEvent> dataWithMasks;
186 std::auto_ptr<std::vector<Trajectory> > outputT (
new std::vector<Trajectory>());
189 LogError(
"TooManySeeds")<<
"Exceeded maximum numeber of seeds! theMaxNSeeds="<<
theMaxNSeeds<<
" nSeed="<<(*collseed).size();
196 if ((*collseed).size()>0){
198 unsigned int lastCleanResult=0;
199 vector<Trajectory> rawResult;
200 rawResult.reserve(collseed->size() * 4);
207 vector<Trajectory> theTmpTrajectories;
210 size_t collseed_size = collseed->size();
211 for (
size_t j = 0;
j < collseed_size;
j++){
213 LogDebug(
"CkfPattern") <<
"======== Begin to look for trajectories from seed " <<
j <<
" ========"<<endl;
217 LogDebug(
"CkfTrackCandidateMakerBase")<<
" Seed cleaning kills seed "<<
j;
222 theTmpTrajectories.clear();
223 auto const & startTraj =
theTrajectoryBuilder->buildTrajectories( (*collseed)[j], theTmpTrajectories,
nullptr );
226 LogDebug(
"CkfPattern") <<
"======== In-out trajectory building found " << theTmpTrajectories.size()
227 <<
" trajectories from seed " << j <<
" ========"<<endl
235 LogDebug(
"CkfPattern") <<
"======== In-out trajectory cleaning gave the following valid trajectories from seed "
236 << j <<
" ========"<<endl
246 LogDebug(
"CkfPattern") <<
"======== Out-in trajectory building found " << theTmpTrajectories.size()
247 <<
" valid/invalid trajectories from seed " << j <<
" ========"<<endl
255 LogDebug(
"CkfPattern") <<
"======== Trajectory cleaning gave the following valid trajectories from seed "
256 << j <<
" ========"<<endl
259 for(vector<Trajectory>::iterator it=theTmpTrajectories.begin();
260 it!=theTmpTrajectories.end(); it++){
261 if( it->isValid() ) {
262 it->setSeedRef(collseed->refAt(j));
264 rawResult.push_back(std::move(*it));
272 theTmpTrajectories.clear();
274 LogDebug(
"CkfPattern") <<
"rawResult trajectories found so far = " << rawResult.size();
278 rawResult.erase(std::remove_if(rawResult.begin()+lastCleanResult,rawResult.end(),
281 lastCleanResult=rawResult.size();
296 LogDebug(
"CkfPattern") <<
"======== Final cleaning of entire event found " << rawResult.size()
297 <<
" valid/invalid trajectories ======="<<endl
300 LogDebug(
"CkfPattern") <<
"removing invalid trajectories.";
302 vector<Trajectory> & unsmoothedResult(rawResult);
303 unsmoothedResult.erase(std::remove_if(unsmoothedResult.begin(),unsmoothedResult.end(),
305 unsmoothedResult.end());
309 for (
auto it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
311 if (it->lastMeasurement().updatedState().isValid() &&
312 it->lastMeasurement().recHit().get() != 0 &&
313 it->lastMeasurement().recHit()->isValid()) {
321 auto initId = it->lastMeasurement().recHitR().rawId();
324 hits.
push_back(it->lastMeasurement().recHit()->hit()->clone());
325 boost::shared_ptr<const TrajectorySeed>
seed(
new TrajectorySeed(state, std::move(hits), direction));
332 for (
auto itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
333 trajectory.
push(std::move(*itmeas));
336 (*it)= std::move(trajectory);
338 edm::LogWarning(
"CkfPattern_InvalidLastMeasurement") <<
"Last measurement of the trajectory is invalid, cannot reverse it";
348 output->reserve(unsmoothedResult.size());
351 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin();
352 it != unsmoothedResult.end(); ++it) {
354 LogDebug(
"CkfPattern") <<
"copying "<<(
useSplitting?
"splitted":
"un-splitted")<<
" hits from trajectory";
356 if(it->direction() !=
alongMomentum)
LogDebug(
"CkfPattern") <<
"not along momentum... " << std::endl;
359 viTotHits+=recHits.
size();
361 LogDebug(
"CkfPattern") <<
"getting initial state.";
363 std::pair<TrajectoryStateOnSurface, const GeomDet*> && initState =
theInitialState->innerState( *it , doBackFit);
366 if ( !initState.first.isValid() || initState.second ==
nullptr ||
edm::isNotFinite(initState.first.globalPosition().x())) {
373 LogDebug(
"CkfPattern") <<
"propagating to hit front in case of splitting.";
375 if (!propagated.
isValid())
continue;
380 initState.second->geographicalId().rawId());
381 LogDebug(
"CkfPattern") <<
"pushing a TrackCandidate.";
382 output->emplace_back(recHits,it->seed(),state,it->seedRef(),it->nLoops());
388 LogTrace(
"CkfPattern|TrackingRegressionTest") <<
"========== CkfTrackCandidateMaker Info =========="
389 <<
"number of Seed: " << collseed->size()<<endl
392 assert(viTotHits>=0);
virtual ~CkfTrackCandidateMakerBase()
T getParameter(std::string const &) const
virtual void deleteAssocDebugger()
static std::string dumpCandidates(collection &candidates)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
bool theTrackCandidateOutput
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< StripClusterMask > maskStrips_
std::vector< TrackCandidate > TrackCandidateCollection
std::unique_ptr< TransientInitialStateEstimator > theInitialState
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.
const Plane & surface() const
The nominal surface of the GeomDet.
const std::string theMagFieldName
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.
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.
const GeomDet * det() const
virtual void produceBase(edm::Event &e, const edm::EventSetup &es)
std::unique_ptr< BaseCkfTrajectoryBuilder > theTrajectoryBuilder
virtual void clean(TrajectoryContainer &) const
edm::EDGetTokenT< MeasurementTrackerEvent > theMTELabel
unsigned int maxSeedsBeforeCleaning_
edm::EDGetTokenT< edm::View< TrajectorySeed > > theSeedLabel
std::string theTrajectoryCleanerName
T const * product() const
bool doSeedingRegionRebuilding
void setSeedRef(const edm::RefToBase< TrajectorySeed > &seedRef)
void setEventSetup(const edm::EventSetup &es)
Initialize EventSetup objects at each event.
virtual void beginRunBase(edm::Run const &, edm::EventSetup const &es)
char data[epos_bytes_allocation]
volatile std::atomic< bool > shutdown_flag false
virtual void countSeedsDebugger()
void push(const TrajectoryMeasurement &tm)
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
T get(const Candidate &c)
RedundantSeedCleaner * theSeedCleaner
edm::ESHandle< MagneticField > theMagField