47 theTrackCandidateOutput(
true),
48 theTrajectoryOutput(
false),
49 useSplitting(conf.getParameter<bool>(
"useHitsSplitting")),
50 doSeedingRegionRebuilding(conf.getParameter<bool>(
"doSeedingRegionRebuilding")),
51 cleanTrajectoryAfterInOut(conf.getParameter<bool>(
"cleanTrajectoryAfterInOut")),
52 reverseTrajectories(conf.existsAs<bool>(
"reverseTrajectories") && conf.getParameter<bool>(
"reverseTrajectories")),
53 theMaxNSeeds(conf.getParameter<unsigned int>(
"maxNSeeds")),
54 theTrajectoryBuilderName(conf.getParameter<std::
string>(
"TrajectoryBuilder")),
55 theTrajectoryBuilder(0),
56 theTrajectoryCleanerName(conf.getParameter<std::
string>(
"TrajectoryCleaner")),
57 theTrajectoryCleaner(0),
59 theNavigationSchoolName(conf.getParameter<std::
string>(
"NavigationSchool")),
60 theNavigationSchool(0),
62 maxSeedsBeforeCleaning_(0)
70 if ( conf.
exists(
"maxSeedsBeforeCleaning") )
74 if (cleaner ==
"SeedCleanerByHitPosition") {
76 }
else if (cleaner ==
"SeedCleanerBySharedInput") {
78 }
else if (cleaner ==
"CachingSeedCleanerByHitPosition") {
80 }
else if (cleaner ==
"CachingSeedCleanerBySharedInput") {
81 int numHitsForSeedCleaner =
conf_.
existsAs<
int>(
"numHitsForSeedCleaner") ?
83 int onlyPixelHits =
conf_.
existsAs<
bool>(
"onlyPixelHitsForSeedCleaner") ?
86 }
else if (cleaner ==
"none") {
164 std::auto_ptr<std::vector<Trajectory> > outputT (
new std::vector<Trajectory>());
167 LogError(
"TooManySeeds")<<
"Exceeded maximum numeber of seeds! theMaxNSeeds="<<
theMaxNSeeds<<
" nSeed="<<(*collseed).size();
175 if ((*collseed).size()>0){
177 unsigned int lastCleanResult=0;
178 vector<Trajectory> rawResult;
179 rawResult.reserve(collseed->size() * 4);
186 vector<Trajectory> theTmpTrajectories;
189 size_t collseed_size = collseed->size();
190 for (
size_t j = 0;
j < collseed_size;
j++){
194 LogDebug(
"CkfTrackCandidateMakerBase")<<
" Seed cleaning kills seed "<<
j;
199 theTmpTrajectories.clear();
203 LogDebug(
"CkfPattern") <<
"======== In-out trajectory building found " << theTmpTrajectories.size()
204 <<
" trajectories from seed " << j <<
" ========"<<endl
212 LogDebug(
"CkfPattern") <<
"======== In-out trajectory cleaning gave the following valid trajectories from seed "
213 << j <<
" ========"<<endl
223 LogDebug(
"CkfPattern") <<
"======== Out-in trajectory building found " << theTmpTrajectories.size()
224 <<
" valid/invalid trajectories from seed " << j <<
" ========"<<endl
232 LogDebug(
"CkfPattern") <<
"======== Trajectory cleaning gave the following valid trajectories from seed "
233 << j <<
" ========"<<endl
236 for(vector<Trajectory>::iterator it=theTmpTrajectories.begin();
237 it!=theTmpTrajectories.end(); it++){
238 if( it->isValid() ) {
239 it->setSeedRef(collseed->refAt(j));
241 rawResult.push_back(*it);
249 theTmpTrajectories.clear();
251 LogDebug(
"CkfPattern") <<
"rawResult trajectories found so far = " << rawResult.size();
255 rawResult.erase(std::remove_if(rawResult.begin(),rawResult.end(),
258 lastCleanResult=rawResult.size();
270 LogDebug(
"CkfPattern") <<
"======== Final cleaning of entire event found " << rawResult.size()
271 <<
" valid/invalid trajectories ======="<<endl
274 LogDebug(
"CkfPattern") <<
"removing invalid trajectories.";
276 vector<Trajectory> & unsmoothedResult(rawResult);
277 unsmoothedResult.erase(std::remove_if(unsmoothedResult.begin(),unsmoothedResult.end(),
279 unsmoothedResult.end());
283 vector<Trajectory> reversed;
284 reversed.reserve(unsmoothedResult.size());
285 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
287 if (it->lastMeasurement().updatedState().isValid() &&
288 it->lastMeasurement().recHit().get() != 0 &&
289 it->lastMeasurement().recHit()->isValid()) {
297 DetId initDetId = it->lastMeasurement().recHit()->geographicalId();
300 hits.
push_back(*it->lastMeasurement().recHit()->hit());
301 boost::shared_ptr<const TrajectorySeed> seed(
new TrajectorySeed(state, hits, direction));
308 for (Trajectory::DataContainer::const_reverse_iterator itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
309 trajectory.
push(*itmeas);
311 reversed.push_back(trajectory);
313 edm::LogWarning(
"CkfPattern_InvalidLastMeasurement") <<
"Last measurement of the trajectory is invalid, cannot reverse it";
314 reversed.push_back(*it);
317 unsmoothedResult.swap(reversed);
329 output->reserve(unsmoothedResult.size());
330 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin();
331 it != unsmoothedResult.end(); ++it) {
335 LogDebug(
"CkfPattern") <<
"retrieving "<<(
useSplitting?
"splitted":
"un-splitted")<<
" hits from trajectory";
339 LogDebug(
"CkfPattern") <<
"cloning hits into new collection.";
340 for (Trajectory::RecHitContainer::const_iterator hitIt = thits.begin();
341 hitIt != thits.end(); ++hitIt) {
342 recHits.
push_back( (**hitIt).hit()->clone());
345 LogDebug(
"CkfPattern") <<
"getting initial state.";
347 std::pair<TrajectoryStateOnSurface, const GeomDet*> initState =
351 if (! initState.first.isValid() || initState.second == 0 ||
edm::isNotFinite(initState.first.globalPosition().x())) {
357 if(
useSplitting && (initState.second != thits.front()->det()) && thits.front()->det() ){
358 LogDebug(
"CkfPattern") <<
"propagating to hit front in case of splitting.";
360 if (!propagated.
isValid())
continue;
362 thits.front()->det()->geographicalId().rawId());
365 initState.second->geographicalId().rawId());
366 LogDebug(
"CkfPattern") <<
"pushing a TrackCandidate.";
373 LogTrace(
"CkfPattern|TrackingRegressionTest") <<
"========== CkfTrackCandidateMaker Info =========="
374 <<
"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
virtual void setEvent(const edm::Event &event) const
bool theTrackCandidateOutput
std::vector< TrackCandidate > TrackCandidateCollection
void setNLoops(signed char value)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
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)
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 rebuildTrajectories(TempTrajectory const &startingTraj, const TrajectorySeed &seed, TrajectoryContainer &result) const
virtual void unset() const
virtual void clean(TrajectoryContainer &) const
unsigned int maxSeedsBeforeCleaning_
virtual TempTrajectory buildTrajectories(const TrajectorySeed &seed, TrajectoryContainer &ret, const TrajectoryFilter *) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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)
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
edm::InputTag theSeedLabel
RedundantSeedCleaner * theSeedCleaner
edm::ESHandle< MagneticField > theMagField