46 theTrackCandidateOutput(
true),
47 theTrajectoryOutput(
false),
48 useSplitting(conf.getParameter<bool>(
"useHitsSplitting")),
49 doSeedingRegionRebuilding(conf.getParameter<bool>(
"doSeedingRegionRebuilding")),
50 cleanTrajectoryAfterInOut(conf.getParameter<bool>(
"cleanTrajectoryAfterInOut")),
51 reverseTrajectories(conf.existsAs<bool>(
"reverseTrajectories") && conf.getParameter<bool>(
"reverseTrajectories")),
52 theMaxNSeeds(conf.getParameter<unsigned int>(
"maxNSeeds")),
53 theTrajectoryBuilderName(conf.getParameter<std::string>(
"TrajectoryBuilder")),
54 theTrajectoryBuilder(0),
55 theTrajectoryCleanerName(conf.getParameter<std::string>(
"TrajectoryCleaner")),
56 theTrajectoryCleaner(0),
58 theNavigationSchoolName(conf.getParameter<std::string>(
"NavigationSchool")),
59 theNavigationSchool(0),
61 maxSeedsBeforeCleaning_(0)
69 if ( conf.
exists(
"maxSeedsBeforeCleaning") )
84 if (cleaner ==
"SeedCleanerByHitPosition") {
86 }
else if (cleaner ==
"SeedCleanerBySharedInput") {
88 }
else if (cleaner ==
"CachingSeedCleanerByHitPosition") {
90 }
else if (cleaner ==
"CachingSeedCleanerBySharedInput") {
91 int numHitsForSeedCleaner =
conf_.
existsAs<
int>(
"numHitsForSeedCleaner") ?
93 int onlyPixelHits =
conf_.
existsAs<
bool>(
"onlyPixelHitsForSeedCleaner") ?
96 }
else if (cleaner ==
"none") {
160 std::auto_ptr<std::vector<Trajectory> > outputT (
new std::vector<Trajectory>());
163 LogError(
"TooManySeeds")<<
"Exceeded maximum numeber of seeds! theMaxNSeeds="<<
theMaxNSeeds<<
" nSeed="<<(*collseed).size();
171 if ((*collseed).size()>0){
173 unsigned int lastCleanResult=0;
174 vector<Trajectory> rawResult;
175 rawResult.reserve(collseed->size() * 4);
182 vector<Trajectory> theTmpTrajectories;
185 size_t collseed_size = collseed->size();
186 for (
size_t j = 0;
j < collseed_size;
j++){
190 LogDebug(
"CkfTrackCandidateMakerBase")<<
" Seed cleaning kills seed "<<
j;
195 theTmpTrajectories.clear();
199 LogDebug(
"CkfPattern") <<
"======== In-out trajectory building found " << theTmpTrajectories.size()
200 <<
" trajectories from seed " << j <<
" ========"<<endl
208 LogDebug(
"CkfPattern") <<
"======== In-out trajectory cleaning gave the following valid trajectories from seed "
209 << j <<
" ========"<<endl
219 LogDebug(
"CkfPattern") <<
"======== Out-in trajectory building found " << theTmpTrajectories.size()
220 <<
" valid/invalid trajectories from seed " << j <<
" ========"<<endl
228 LogDebug(
"CkfPattern") <<
"======== Trajectory cleaning gave the following valid trajectories from seed "
229 << j <<
" ========"<<endl
232 for(vector<Trajectory>::iterator it=theTmpTrajectories.begin();
233 it!=theTmpTrajectories.end(); it++){
234 if( it->isValid() ) {
235 it->setSeedRef(collseed->refAt(j));
237 rawResult.push_back(*it);
245 theTmpTrajectories.clear();
247 LogDebug(
"CkfPattern") <<
"rawResult trajectories found so far = " << rawResult.size();
251 rawResult.erase(std::remove_if(rawResult.begin(),rawResult.end(),
254 lastCleanResult=rawResult.size();
266 LogDebug(
"CkfPattern") <<
"======== Final cleaning of entire event found " << rawResult.size()
267 <<
" valid/invalid trajectories ======="<<endl
270 LogDebug(
"CkfPattern") <<
"removing invalid trajectories.";
272 vector<Trajectory> & unsmoothedResult(rawResult);
273 unsmoothedResult.erase(std::remove_if(unsmoothedResult.begin(),unsmoothedResult.end(),
275 unsmoothedResult.end());
279 vector<Trajectory> reversed;
280 reversed.reserve(unsmoothedResult.size());
281 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin(), ed = unsmoothedResult.end(); it != ed; ++it) {
283 if (it->lastMeasurement().updatedState().isValid() &&
284 it->lastMeasurement().recHit().get() != 0 &&
285 it->lastMeasurement().recHit()->isValid()) {
293 DetId initDetId = it->lastMeasurement().recHit()->geographicalId();
296 hits.
push_back(*it->lastMeasurement().recHit()->hit());
297 boost::shared_ptr<const TrajectorySeed> seed(
new TrajectorySeed(state, hits, direction));
304 for (Trajectory::DataContainer::const_reverse_iterator itmeas = meas.rbegin(), endmeas = meas.rend(); itmeas != endmeas; ++itmeas) {
305 trajectory.
push(*itmeas);
307 reversed.push_back(trajectory);
309 edm::LogWarning(
"CkfPattern_InvalidLastMeasurement") <<
"Last measurement of the trajectory is invalid, cannot reverse it";
310 reversed.push_back(*it);
313 unsmoothedResult.swap(reversed);
325 output->reserve(unsmoothedResult.size());
326 for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin();
327 it != unsmoothedResult.end(); ++it) {
331 LogDebug(
"CkfPattern") <<
"retrieving "<<(
useSplitting?
"splitted":
"un-splitted")<<
" hits from trajectory";
335 LogDebug(
"CkfPattern") <<
"cloning hits into new collection.";
336 for (Trajectory::RecHitContainer::const_iterator hitIt = thits.begin();
337 hitIt != thits.end(); ++hitIt) {
338 recHits.
push_back( (**hitIt).hit()->clone());
341 LogDebug(
"CkfPattern") <<
"getting initial state.";
343 std::pair<TrajectoryStateOnSurface, const GeomDet*> initState =
347 if (! initState.first.isValid() || initState.second == 0 ||
std::isnan(initState.first.globalPosition().x())) {
353 if(
useSplitting && (initState.second != thits.front()->det()) && thits.front()->det() ){
354 LogDebug(
"CkfPattern") <<
"propagating to hit front in case of splitting.";
356 if (!propagated.
isValid())
continue;
358 thits.front()->det()->geographicalId().rawId());
361 initState.second->geographicalId().rawId());
362 LogDebug(
"CkfPattern") <<
"pushing a TrackCandidate.";
369 LogTrace(
"CkfPattern|TrackingRegressionTest") <<
"========== CkfTrackCandidateMaker Info =========="
370 <<
"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
bool theTrackCandidateOutput
virtual void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const
const TrajectoryBuilder * theTrajectoryBuilder
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 clean(TrajectoryContainer &) const
unsigned int maxSeedsBeforeCleaning_
virtual void unset() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual TrajectoryContainer trajectories(const TrajectorySeed &) const =0
virtual void beginRunBase(edm::Run &, edm::EventSetup const &es)
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 countSeedsDebugger()
virtual void setEvent(const edm::Event &event) const =0
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