#include <CkfTrackCandidateMakerBase.h>
Definition at line 27 of file CkfTrackCandidateMakerBase.h.
cms::CkfTrackCandidateMakerBase::CkfTrackCandidateMakerBase | ( | const edm::ParameterSet & | conf | ) | [explicit] |
Definition at line 43 of file CkfTrackCandidateMakerBase.cc.
References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), maxSeedsBeforeCleaning_, and theSeedLabel.
: conf_(conf), theTrackCandidateOutput(true), theTrajectoryOutput(false), useSplitting(conf.getParameter<bool>("useHitsSplitting")), doSeedingRegionRebuilding(conf.getParameter<bool>("doSeedingRegionRebuilding")), cleanTrajectoryAfterInOut(conf.getParameter<bool>("cleanTrajectoryAfterInOut")), theMaxNSeeds(conf.getParameter<unsigned int>("maxNSeeds")), theTrajectoryBuilderName(conf.getParameter<std::string>("TrajectoryBuilder")), theTrajectoryBuilder(0), theTrajectoryCleanerName(conf.getParameter<std::string>("TrajectoryCleaner")), theTrajectoryCleaner(0), theInitialState(0), theNavigationSchoolName(conf.getParameter<std::string>("NavigationSchool")), theNavigationSchool(0), theSeedCleaner(0), maxSeedsBeforeCleaning_(0) { //produces<TrackCandidateCollection>(); // old configuration totally descoped. // if (!conf.exists("src")) // theSeedLabel = InputTag(conf_.getParameter<std::string>("SeedProducer"),conf_.getParameter<std::string>("SeedLabel")); // else theSeedLabel= conf.getParameter<edm::InputTag>("src"); if ( conf.exists("maxSeedsBeforeCleaning") ) maxSeedsBeforeCleaning_=conf.getParameter<unsigned int>("maxSeedsBeforeCleaning"); }
cms::CkfTrackCandidateMakerBase::~CkfTrackCandidateMakerBase | ( | ) | [virtual] |
Definition at line 74 of file CkfTrackCandidateMakerBase.cc.
References theInitialState, and theSeedCleaner.
{ delete theInitialState; if (theSeedCleaner) delete theSeedCleaner; }
void cms::CkfTrackCandidateMakerBase::beginRunBase | ( | edm::Run & | r, |
edm::EventSetup const & | es | ||
) | [virtual] |
Definition at line 79 of file CkfTrackCandidateMakerBase.cc.
References conf_, Exception, edm::ParameterSet::getParameter(), and theSeedCleaner.
Referenced by cms::CkfTrackCandidateMaker::beginRun(), cms::CkfDebugTrackCandidateMaker::beginRun(), and cms::CkfTrajectoryMaker::beginRun().
{ std::string cleaner = conf_.getParameter<std::string>("RedundantSeedCleaner"); if (cleaner == "SeedCleanerByHitPosition") { theSeedCleaner = new SeedCleanerByHitPosition(); } else if (cleaner == "SeedCleanerBySharedInput") { theSeedCleaner = new SeedCleanerBySharedInput(); } else if (cleaner == "CachingSeedCleanerByHitPosition") { theSeedCleaner = new CachingSeedCleanerByHitPosition(); } else if (cleaner == "CachingSeedCleanerBySharedInput") { theSeedCleaner = new CachingSeedCleanerBySharedInput(); } else if (cleaner == "none") { theSeedCleaner = 0; } else { throw cms::Exception("RedundantSeedCleaner not found", cleaner); } }
virtual void cms::CkfTrackCandidateMakerBase::countSeedsDebugger | ( | ) | [inline, protected, virtual] |
Reimplemented in cms::CkfDebugTrackCandidateMaker.
Definition at line 72 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().
{;}
virtual void cms::CkfTrackCandidateMakerBase::deleteAssocDebugger | ( | ) | [inline, protected, virtual] |
Reimplemented in cms::CkfDebugTrackCandidateMaker.
Definition at line 73 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().
{;}
virtual TrajectorySeedCollection::const_iterator cms::CkfTrackCandidateMakerBase::lastSeed | ( | TrajectorySeedCollection const & | theSeedColl | ) | [inline, protected, virtual] |
Definition at line 70 of file CkfTrackCandidateMakerBase.h.
{return theSeedColl.end();}
virtual void cms::CkfTrackCandidateMakerBase::printHitsDebugger | ( | edm::Event & | e | ) | [inline, protected, virtual] |
Reimplemented in cms::CkfDebugTrackCandidateMaker.
Definition at line 71 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().
{;}
void cms::CkfTrackCandidateMakerBase::produceBase | ( | edm::Event & | e, |
const edm::EventSetup & | es | ||
) | [virtual] |
Definition at line 128 of file CkfTrackCandidateMakerBase.cc.
References RedundantSeedCleaner::add(), TrajectoryCleaner::clean(), cleanTrajectoryAfterInOut, countSeedsDebugger(), deleteAssocDebugger(), RedundantSeedCleaner::done(), doSeedingRegionRebuilding, PrintoutHelper::dumpCandidates(), edm::EventSetup::get(), edm::Event::getByLabel(), RedundantSeedCleaner::good(), RedundantSeedCleaner::init(), TransientInitialStateEstimator::innerState(), Trajectory::isValid(), TrajectoryStateOnSurface::isValid(), j, LogDebug, LogTrace, maxSeedsBeforeCleaning_, convertSQLitetoXML_cfg::output, TrajectoryStateTransform::persistentState(), printHitsDebugger(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), TrajectoryBuilder::rebuildSeedingRegion(), PrintoutHelper::regressionTest(), edm::OwnVector< T, P >::reserve(), TrajectoryBuilder::setEvent(), setEventSetup(), evf::utils::state, theInitialState, theMaxNSeeds, theNavigationSchool, theSeedCleaner, theSeedLabel, theTrackCandidateOutput, theTrajectoryBuilder, theTrajectoryCleaner, theTrajectoryOutput, patCandidatesForDimuonsSequences_cff::tracker, TrajectoryBuilder::trajectories(), TrajectoryBuilder::unset(), and useSplitting.
Referenced by cms::CkfTrackCandidateMaker::produce(), cms::CkfTrajectoryMaker::produce(), and cms::CkfDebugTrackCandidateMaker::produce().
{ // getting objects from the EventSetup setEventSetup( es ); // set the correct navigation NavigationSetter setter( *theNavigationSchool); // propagator edm::ESHandle<Propagator> thePropagator; es.get<TrackingComponentsRecord>().get("AnyDirectionAnalyticalPropagator", thePropagator); // method for Debugging printHitsDebugger(e); // Step A: set Event for the TrajectoryBuilder theTrajectoryBuilder->setEvent(e); // Step B: Retrieve seeds edm::Handle<View<TrajectorySeed> > collseed; e.getByLabel(theSeedLabel, collseed); // Step C: Create empty output collection std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection); std::auto_ptr<std::vector<Trajectory> > outputT (new std::vector<Trajectory>()); if ( (*collseed).size()>theMaxNSeeds ) { LogError("TooManySeeds")<<"Exceeded maximum numeber of seeds! theMaxNSeeds="<<theMaxNSeeds<<" nSeed="<<(*collseed).size(); if (theTrackCandidateOutput){ e.put(output);} if (theTrajectoryOutput){e.put(outputT);} theTrajectoryBuilder->unset(); return; } // Step D: Invoke the building algorithm if ((*collseed).size()>0){ unsigned int lastCleanResult=0; vector<Trajectory> rawResult; rawResult.reserve(collseed->size() * 4); if (theSeedCleaner) theSeedCleaner->init( &rawResult ); // method for debugging countSeedsDebugger(); vector<Trajectory> theTmpTrajectories; // Loop over seeds size_t collseed_size = collseed->size(); for (size_t j = 0; j < collseed_size; j++){ // Check if seed hits already used by another track if (theSeedCleaner && !theSeedCleaner->good( &((*collseed)[j])) ) { LogDebug("CkfTrackCandidateMakerBase")<<" Seed cleaning kills seed "<<j; continue; } // Build trajectory from seed outwards theTmpTrajectories.clear(); theTrajectoryBuilder->trajectories( (*collseed)[j], theTmpTrajectories ); LogDebug("CkfPattern") << "======== In-out trajectory building found " << theTmpTrajectories.size() << " trajectories from seed " << j << " ========"<<endl <<PrintoutHelper::dumpCandidates(theTmpTrajectories); if (cleanTrajectoryAfterInOut) { // Select the best trajectory from this seed (declare others invalid) theTrajectoryCleaner->clean(theTmpTrajectories); LogDebug("CkfPattern") << "======== In-out trajectory cleaning gave the following valid trajectories from seed " << j << " ========"<<endl << PrintoutHelper::dumpCandidates(theTmpTrajectories); } // Optionally continue building trajectory back through // seed and if possible further inwards. if (doSeedingRegionRebuilding) { theTrajectoryBuilder->rebuildSeedingRegion((*collseed)[j],theTmpTrajectories); LogDebug("CkfPattern") << "======== Out-in trajectory building found " << theTmpTrajectories.size() << " valid/invalid trajectories from seed " << j << " ========"<<endl <<PrintoutHelper::dumpCandidates(theTmpTrajectories); } // Select the best trajectory from this seed (after seed region rebuilding, can be more than one) theTrajectoryCleaner->clean(theTmpTrajectories); LogDebug("CkfPattern") << "======== Trajectory cleaning gave the following valid trajectories from seed " << j << " ========"<<endl <<PrintoutHelper::dumpCandidates(theTmpTrajectories); for(vector<Trajectory>::iterator it=theTmpTrajectories.begin(); it!=theTmpTrajectories.end(); it++){ if( it->isValid() ) { it->setSeedRef(collseed->refAt(j)); // Store trajectory rawResult.push_back(*it); // Tell seed cleaner which hits this trajectory used. //TO BE FIXED: this cut should be configurable via cfi file if (theSeedCleaner && it->foundHits()>3) theSeedCleaner->add( & (*it) ); //if (theSeedCleaner ) theSeedCleaner->add( & (*it) ); } } theTmpTrajectories.clear(); LogDebug("CkfPattern") << "rawResult trajectories found so far = " << rawResult.size(); if ( maxSeedsBeforeCleaning_ >0 && rawResult.size() > maxSeedsBeforeCleaning_+lastCleanResult) { theTrajectoryCleaner->clean(rawResult); rawResult.erase(std::remove_if(rawResult.begin(),rawResult.end(), std::not1(std::mem_fun_ref(&Trajectory::isValid))), rawResult.end()); lastCleanResult=rawResult.size(); } } // end of loop over seeds if (theSeedCleaner) theSeedCleaner->done(); // Step E: Clean the results to avoid duplicate tracks // Rejected ones just flagged as invalid. theTrajectoryCleaner->clean(rawResult); LogDebug("CkfPattern") << "======== Final cleaning of entire event found " << rawResult.size() << " valid/invalid trajectories ======="<<endl <<PrintoutHelper::dumpCandidates(rawResult); LogDebug("CkfPattern") << "removing invalid trajectories."; vector<Trajectory> & unsmoothedResult(rawResult); unsmoothedResult.erase(std::remove_if(unsmoothedResult.begin(),unsmoothedResult.end(), std::not1(std::mem_fun_ref(&Trajectory::isValid))), unsmoothedResult.end()); // for (vector<Trajectory>::const_iterator itraw = rawResult.begin(); // itraw != rawResult.end(); itraw++) { //if((*itraw).isValid()) unsmoothedResult.push_back( *itraw); //} //analyseCleanedTrajectories(unsmoothedResult); if (theTrackCandidateOutput){ // Step F: Convert to TrackCandidates output->reserve(unsmoothedResult.size()); for (vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) { Trajectory::RecHitContainer thits; //it->recHitsV(thits); LogDebug("CkfPattern") << "retrieving "<<(useSplitting?"splitted":"un-splitted")<<" hits from trajectory"; it->recHitsV(thits,useSplitting); OwnVector<TrackingRecHit> recHits; recHits.reserve(thits.size()); LogDebug("CkfPattern") << "cloning hits into new collection."; for (Trajectory::RecHitContainer::const_iterator hitIt = thits.begin(); hitIt != thits.end(); hitIt++) { recHits.push_back( (**hitIt).hit()->clone()); } LogDebug("CkfPattern") << "getting initial state."; const bool doBackFit = !doSeedingRegionRebuilding; std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState->innerState( *it , doBackFit); // temporary protection againt invalid initial states if (! initState.first.isValid() || initState.second == 0) { //cout << "invalid innerState, will not make TrackCandidate" << endl; continue; } PTrajectoryStateOnDet* state =0 ; if(useSplitting && (initState.second != thits.front()->det()) && thits.front()->det() ){ LogDebug("CkfPattern") << "propagating to hit front in case of splitting."; TrajectoryStateOnSurface propagated = thePropagator->propagate(initState.first,thits.front()->det()->surface()); if (!propagated.isValid()) continue; state = TrajectoryStateTransform().persistentState(propagated, thits.front()->det()->geographicalId().rawId()); } if(!state) state = TrajectoryStateTransform().persistentState( initState.first, initState.second->geographicalId().rawId()); LogDebug("CkfPattern") << "pushing a TrackCandidate."; output->push_back(TrackCandidate(recHits,it->seed(),*state,it->seedRef() ) ); delete state; } }//output trackcandidates edm::ESHandle<TrackerGeometry> tracker; es.get<TrackerDigiGeometryRecord>().get(tracker); LogTrace("CkfPattern|TrackingRegressionTest") << "========== CkfTrackCandidateMaker Info ==========" << "number of Seed: " << collseed->size()<<endl <<PrintoutHelper::regressionTest(*tracker,unsmoothedResult); if (theTrajectoryOutput){ outputT->swap(unsmoothedResult);} }// end of ((*collseed).size()>0) // method for debugging deleteAssocDebugger(); // Step G: write output to file if (theTrackCandidateOutput){ e.put(output);} if (theTrajectoryOutput){e.put(outputT);} //reset the MT. theTrajectoryBuilder->unset(); }
void cms::CkfTrackCandidateMakerBase::setEventSetup | ( | const edm::EventSetup & | es | ) | [private] |
Initialize EventSetup objects at each event.
Definition at line 97 of file CkfTrackCandidateMakerBase.cc.
References conf_, edm::EventSetup::get(), edm::ParameterSet::getParameter(), edm::ESHandle< T >::product(), TransientInitialStateEstimator::setEventSetup(), theGeomSearchTracker, theInitialState, theMagField, theNavigationSchool, theNavigationSchoolName, theTrajectoryBuilder, theTrajectoryBuilderName, theTrajectoryCleaner, and theTrajectoryCleanerName.
Referenced by produceBase().
{ //services es.get<TrackerRecoGeometryRecord>().get( theGeomSearchTracker ); es.get<IdealMagneticFieldRecord>().get( theMagField ); if (!theInitialState){ // constructor uses the EventSetup, it must be in the setEventSetup were it has a proper value. // get nested parameter set for the TransientInitialStateEstimator ParameterSet tise_params = conf_.getParameter<ParameterSet>("TransientInitialStateEstimatorParameters") ; theInitialState = new TransientInitialStateEstimator( es,tise_params); } theInitialState->setEventSetup( es ); edm::ESHandle<TrajectoryCleaner> trajectoryCleanerH; es.get<TrajectoryCleaner::Record>().get(theTrajectoryCleanerName, trajectoryCleanerH); theTrajectoryCleaner= trajectoryCleanerH.product(); edm::ESHandle<NavigationSchool> navigationSchoolH; es.get<NavigationSchoolRecord>().get(theNavigationSchoolName, navigationSchoolH); theNavigationSchool = navigationSchoolH.product(); // set the TrajectoryBuilder edm::ESHandle<TrajectoryBuilder> theTrajectoryBuilderHandle; es.get<CkfComponentsRecord>().get(theTrajectoryBuilderName,theTrajectoryBuilderHandle); theTrajectoryBuilder = theTrajectoryBuilderHandle.product(); }
bool cms::CkfTrackCandidateMakerBase::cleanTrajectoryAfterInOut [protected] |
Definition at line 46 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().
Definition at line 40 of file CkfTrackCandidateMakerBase.h.
Referenced by beginRunBase(), and setEventSetup().
bool cms::CkfTrackCandidateMakerBase::doSeedingRegionRebuilding [protected] |
Definition at line 45 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().
unsigned int cms::CkfTrackCandidateMakerBase::maxSeedsBeforeCleaning_ [protected] |
Definition at line 68 of file CkfTrackCandidateMakerBase.h.
Referenced by CkfTrackCandidateMakerBase(), and produceBase().
edm::ESHandle<GeometricSearchTracker> cms::CkfTrackCandidateMakerBase::theGeomSearchTracker [protected] |
Definition at line 59 of file CkfTrackCandidateMakerBase.h.
Referenced by setEventSetup().
Definition at line 56 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase(), setEventSetup(), and ~CkfTrackCandidateMakerBase().
Definition at line 58 of file CkfTrackCandidateMakerBase.h.
Referenced by setEventSetup().
unsigned int cms::CkfTrackCandidateMakerBase::theMaxNSeeds [protected] |
Definition at line 48 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().
const NavigationSchool* cms::CkfTrackCandidateMakerBase::theNavigationSchool [protected] |
Definition at line 62 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase(), and setEventSetup().
std::string cms::CkfTrackCandidateMakerBase::theNavigationSchoolName [protected] |
Definition at line 61 of file CkfTrackCandidateMakerBase.h.
Referenced by setEventSetup().
Definition at line 64 of file CkfTrackCandidateMakerBase.h.
Referenced by beginRunBase(), produceBase(), and ~CkfTrackCandidateMakerBase().
Definition at line 66 of file CkfTrackCandidateMakerBase.h.
Referenced by CkfTrackCandidateMakerBase(), and produceBase().
bool cms::CkfTrackCandidateMakerBase::theTrackCandidateOutput [protected] |
Definition at line 42 of file CkfTrackCandidateMakerBase.h.
Referenced by cms::CkfTrajectoryMaker::CkfTrajectoryMaker(), and produceBase().
const TrajectoryBuilder* cms::CkfTrackCandidateMakerBase::theTrajectoryBuilder [protected] |
Definition at line 51 of file CkfTrackCandidateMakerBase.h.
Referenced by cms::CkfDebugTrackCandidateMaker::initDebugger(), produceBase(), and setEventSetup().
std::string cms::CkfTrackCandidateMakerBase::theTrajectoryBuilderName [protected] |
Definition at line 50 of file CkfTrackCandidateMakerBase.h.
Referenced by setEventSetup().
const TrajectoryCleaner* cms::CkfTrackCandidateMakerBase::theTrajectoryCleaner [protected] |
Definition at line 54 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase(), and setEventSetup().
std::string cms::CkfTrackCandidateMakerBase::theTrajectoryCleanerName [protected] |
Definition at line 53 of file CkfTrackCandidateMakerBase.h.
Referenced by setEventSetup().
bool cms::CkfTrackCandidateMakerBase::theTrajectoryOutput [protected] |
Definition at line 43 of file CkfTrackCandidateMakerBase.h.
Referenced by cms::CkfTrajectoryMaker::CkfTrajectoryMaker(), and produceBase().
bool cms::CkfTrackCandidateMakerBase::useSplitting [protected] |
Definition at line 44 of file CkfTrackCandidateMakerBase.h.
Referenced by produceBase().