CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
OutInConversionTrackFinder Class Reference

#include <OutInConversionTrackFinder.h>

Inheritance diagram for OutInConversionTrackFinder:
ConversionTrackFinder

Public Member Functions

 OutInConversionTrackFinder (const edm::ParameterSet &config, const BaseCkfTrajectoryBuilder *trajectoryBuilder, edm::ConsumesCollector iC)
 
std::vector< Trajectorytracks (const TrajectorySeedCollection &seeds, TrackCandidateCollection &candidates) const override
 
 ~OutInConversionTrackFinder () override
 
- Public Member Functions inherited from ConversionTrackFinder
 ConversionTrackFinder (const edm::ParameterSet &config, const BaseCkfTrajectoryBuilder *trajectoryBuilder, edm::ConsumesCollector iC)
 
void setEventSetup (const edm::EventSetup &es)
 Initialize EventSetup objects at each event. More...
 
virtual ~ConversionTrackFinder ()
 

Private Attributes

RedundantSeedCleanertheSeedCleaner_
 
TrajectoryCleanerBySharedHitstheTrajectoryCleaner_
 

Additional Inherited Members

- Protected Attributes inherited from ConversionTrackFinder
const BaseCkfTrajectoryBuildertheCkfTrajectoryBuilder_
 
std::unique_ptr< TransientInitialStateEstimatortheInitialState_
 
const MeasurementTrackertheMeasurementTracker_
 
std::string theMeasurementTrackerName_
 
edm::ESGetToken< MeasurementTracker, CkfComponentsRecordtheMeasurementTrackerToken_
 
const MagneticFieldtheMF_
 
edm::ESHandle< PropagatorthePropagator_
 
edm::ESGetToken< Propagator, TrackerDigiGeometryRecordthePropagatorToken_
 
const TrackerGeometrytheTrackerGeom_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtheTrackerGeomToken_
 
KFUpdatortheUpdator_
 
bool useSplitHits_
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 30 of file OutInConversionTrackFinder.h.

Constructor & Destructor Documentation

◆ OutInConversionTrackFinder()

OutInConversionTrackFinder::OutInConversionTrackFinder ( const edm::ParameterSet config,
const BaseCkfTrajectoryBuilder trajectoryBuilder,
edm::ConsumesCollector  iC 
)

Definition at line 20 of file OutInConversionTrackFinder.cc.

References Exception, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theSeedCleaner_, and theTrajectoryCleaner_.

23  : ConversionTrackFinder(conf, trajectoryBuilder, iC) {
25 
26  // get the seed cleaner
27  std::string cleaner = conf.getParameter<std::string>("OutInRedundantSeedCleaner");
28  if (cleaner == "CachingSeedCleanerBySharedInput") {
30  } else if (cleaner == "none") {
31  theSeedCleaner_ = nullptr;
32  } else {
33  throw cms::Exception("OutInRedundantSeedCleaner not found, please use CachingSeedCleanerBySharedInput or none",
34  cleaner);
35  }
36 }
RedundantSeedCleaner * theSeedCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_
ConversionTrackFinder(const edm::ParameterSet &config, const BaseCkfTrajectoryBuilder *trajectoryBuilder, edm::ConsumesCollector iC)

◆ ~OutInConversionTrackFinder()

OutInConversionTrackFinder::~OutInConversionTrackFinder ( )
override

Definition at line 38 of file OutInConversionTrackFinder.cc.

References theSeedCleaner_, and theTrajectoryCleaner_.

38  {
39  delete theTrajectoryCleaner_;
40  if (theSeedCleaner_)
41  delete theSeedCleaner_;
42 }
RedundantSeedCleaner * theSeedCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_

Member Function Documentation

◆ tracks()

std::vector< Trajectory > OutInConversionTrackFinder::tracks ( const TrajectorySeedCollection seeds,
TrackCandidateCollection candidates 
) const
overridevirtual

Implements ConversionTrackFinder.

Definition at line 44 of file OutInConversionTrackFinder.cc.

References RedundantSeedCleaner::add(), alongMomentum, cms::cuda::assert(), TrajectoryCleanerBySharedHits::clean(), RedundantSeedCleaner::done(), PV3DBase< T, PVType, FrameType >::eta(), MeasurementTracker::geomTracker(), RedundantSeedCleaner::good(), BaseCkfTrajectoryBuilder::hitBuilder(), mps_fire::i, TrackerGeometry::idToDet(), RedundantSeedCleaner::init(), TrajectoryStateOnSurface::isValid(), LogDebug, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), PV3DBase< T, PVType, FrameType >::phi(), precomputed_value_sort(), Propagator::propagate(), FastTrackerRecHitMaskProducer_cfi::recHits, mps_fire::result, ConversionTrackFinder::theCkfTrajectoryBuilder_, ConversionTrackFinder::theInitialState_, ConversionTrackFinder::theMeasurementTracker_, ConversionTrackFinder::thePropagator_, theSeedCleaner_, theTrajectoryCleaner_, TrajectoryBuilder::trajectories(), and ConversionTrackFinder::useSplitHits_.

Referenced by ConversionTrackCandidateProducer::buildCollections().

45  {
46  // std::cout << "OutInConversionTrackFinder::tracks getting " << outInSeeds.size() << " Out-In seeds " << "\n";;
47 
48  std::vector<Trajectory> tmpO;
49  tmpO.erase(tmpO.begin(), tmpO.end());
50 
51  std::vector<Trajectory> result;
52  result.erase(result.begin(), result.end());
53 
54  std::vector<Trajectory> rawResult;
55  if (theSeedCleaner_)
56  theSeedCleaner_->init(&rawResult);
57 
59  /*
60  for(TrajectorySeedCollection::const_iterator iSeed=outInSeeds.begin(); iSeed!=outInSeeds.end();iSeed++){
61  DetId tmpId = DetId( iSeed->startingState().detId());
62  const GeomDet* tmpDet = theMeasurementTracker_->geomTracker()->idToDet( tmpId );
63  GlobalVector gv = tmpDet->surface().toGlobal( iSeed->startingState().parameters().momentum() );
64 
65  LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::tracks hits in the seed " << iSeed->nHits() << "\n";
66  LogDebug("OutInConversionTrackFinder")<< " OutInConversionTrackFinder::tracks seed starting state position " << iSeed->startingState().parameters().position() << " momentum " << iSeed->startingState().parameters().momentum() << " charge " << iSeed->startingState().parameters().charge() << " R " << gv.perp() << " eta " << gv.eta() << " phi " << gv.phi() << "\n";
67 
68  TrajectorySeed::range hitRange = iSeed->recHits();
69  for (TrajectorySeed::const_iterator ihit = hitRange.first; ihit != hitRange.second; ihit++) {
70 
71  if ( ihit->isValid() ) {
72 
73  LogDebug("OutInConversionTrackFinder") << " Valid hit global position " << theMeasurementTracker_->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()) << " R " << theMeasurementTracker_->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()).perp() << " phi " << theMeasurementTracker_->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()).phi() << " eta " << theMeasurementTracker_->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()).eta() << "\n" ;
74 
75  }
76  }
77  }
78 
79  */
80 
81  int goodSeed = 0;
82  std::vector<Trajectory> theTmpTrajectories;
83  for (TrajectorySeedCollection::const_iterator iSeed = outInSeeds.begin(); iSeed != outInSeeds.end(); iSeed++) {
84  theTmpTrajectories.clear();
85 
86  if (!theSeedCleaner_ || theSeedCleaner_->good(&(*iSeed))) {
87  goodSeed++;
88 
89  DetId tmpId = DetId(iSeed->startingState().detId());
90  const GeomDet* tmpDet = theMeasurementTracker_->geomTracker()->idToDet(tmpId);
91  GlobalVector gv = tmpDet->surface().toGlobal(iSeed->startingState().parameters().momentum());
92 
93  // std::cout << " OutInConversionTrackFinder::tracks hits in the seed " << iSeed->nHits() << "\n";
94  LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::tracks seed starting state position "
95  << iSeed->startingState().parameters().position() << " momentum "
96  << iSeed->startingState().parameters().momentum() << " charge "
97  << iSeed->startingState().parameters().charge() << " R " << gv.perp()
98  << " eta " << gv.eta() << " phi " << gv.phi() << "\n";
99 
100  theCkfTrajectoryBuilder_->trajectories(*iSeed, theTmpTrajectories);
101 
102  LogDebug("OutInConversionTrackFinder")
103  << "OutInConversionTrackFinder::track returned " << theTmpTrajectories.size() << " trajectories"
104  << "\n";
105 
106  theTrajectoryCleaner_->clean(theTmpTrajectories);
107 
108  for (std::vector<Trajectory>::const_iterator it = theTmpTrajectories.begin(); it != theTmpTrajectories.end();
109  it++) {
110  if (it->isValid()) {
111  rawResult.push_back(*it);
112  if (theSeedCleaner_)
113  theSeedCleaner_->add(&(*it));
114  }
115  }
116  }
117  } // end loop over the seeds
118  LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::track Good seeds " << goodSeed << "\n";
119  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder::track rawResult size after cleaning "
120  << rawResult.size() << "\n";
121 
122  if (theSeedCleaner_)
124 
125  std::vector<Trajectory> unsmoothedResult;
126  theTrajectoryCleaner_->clean(rawResult);
127 
128  for (std::vector<Trajectory>::const_iterator itraw = rawResult.begin(); itraw != rawResult.end(); itraw++) {
129  if ((*itraw).isValid()) {
130  tmpO.push_back(*itraw);
131  LogDebug("OutInConversionTrackFinder") << " rawResult num hits " << (*itraw).foundHits() << "\n";
132  }
133  }
134 
135  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size()
136  << " before sorting "
137  << "\n";
138  // for (std::vector<Trajectory>::const_iterator it =tmpO.begin(); it != tmpO.end(); it++) {
139  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO num of hits " << (*it).foundHits() << " before ordering " << "\n";
140  // }
141 
142  precomputed_value_sort(tmpO.begin(), tmpO.end(), ExtractNumOfHits());
143 
144  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO after sorting "
145  << "\n";
146  // for (std::vector<Trajectory>::const_iterator it =tmpO.begin(); it != tmpO.end(); it++) {
147  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO num of hits " << (*it).foundHits() << "\n";
148  // }
149 
150  for (int i = tmpO.size() - 1; i >= 0; i--) {
151  unsmoothedResult.push_back(tmpO[i]);
152  }
153  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder unsmoothedResult size "
154  << unsmoothedResult.size() << "\n";
155 
156  // for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
157  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder unsmoothedResult after reordering " <<(*it).foundHits() << "\n";
158  // }
159 
160  // Check if the inner state is valid
161  tmpO.clear();
162  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size()
163  << " after clearing "
164  << "\n";
165  for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
166  if (!it->isValid())
167  continue;
168 
169  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState(*it);
170  // LogDebug("OutInConversionTrackFinder") << " Initial state parameters " << initState.first << "\n";
171 
172  // temporary protection againt invalid initial states
173  if (!initState.first.isValid() || initState.second == nullptr) {
174  LogDebug("OutInConversionTrackFinder") << "invalid innerState, will not make TrackCandidate"
175  << "\n";
176  ;
177  continue;
178  }
179  tmpO.push_back(*it);
180  }
181 
182  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size() << " after filling "
183  << "\n";
184  if (!tmpO.empty()) {
185  std::vector<Trajectory>::iterator it = tmpO.begin();
186 
187  // only send out the two best tracks
188  result.push_back(*it);
189  if (tmpO.size() > 1)
190  result.push_back(*(++it));
191  }
192 
193  // for (std::vector<Trajectory>::const_iterator it =result.begin(); it != result.end(); it++) {
194  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder Result num of hits " << (*it).foundHits() << "\n";
195  //}
196 
197  // Convert to TrackCandidates and fill in the output_p
199  for (std::vector<Trajectory>::const_iterator it = result.begin(); it != result.end(); it++) {
201  if (it->direction() == alongMomentum)
202  LogDebug("OutInConversionTrackFinder") << "OutInConv along momentum... " << std::endl;
203  t2t(*it, recHits, useSplitHits_);
204 
205  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState(*it);
206 
207  assert(initState.second == recHits.front().det());
208 
209  // temporary protection againt invalid initial states
210  if (!initState.first.isValid() || initState.second == nullptr) {
211  LogDebug("OutInConversionTrackFinder") << "invalid innerState, will not make TrackCandidate" << std::endl;
212  continue;
213  }
214 
216  if (useSplitHits_ && (initState.second != recHits.front().det()) && recHits.front().det()) {
217  TrajectoryStateOnSurface propagated =
218  thePropagator_->propagate(initState.first, recHits.front().det()->surface());
219  if (!propagated.isValid())
220  continue;
221  state = trajectoryStateTransform::persistentState(propagated, recHits.front().rawId());
222  } else
223  state = trajectoryStateTransform::persistentState(initState.first, initState.second->geographicalId().rawId());
224 
225  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder Number of hits for the track candidate "
226  << recHits.size() << " TSOS charge " << initState.first.charge() << "\n";
227 
228  output_p.push_back(TrackCandidate(recHits, it->seed(), state));
229  }
230 
231  // std::cout << " Returning " << result.size() << "Out In Trajectories " << "\n";
232 
233  return result;
234 }
T perp() const
Definition: PV3DBase.h:69
edm::ESHandle< Propagator > thePropagator_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
std::unique_ptr< TransientInitialStateEstimator > theInitialState_
virtual void done()=0
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.
assert(be >=bs)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
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.
void clean(TrajectoryPointerContainer &) const override
const TrackerGeometry * geomTracker() const
const TrackerGeomDet * idToDet(DetId) const override
virtual TrajectoryContainer trajectories(const TrajectorySeed &) const =0
Definition: DetId.h:17
const TransientTrackingRecHitBuilder * hitBuilder() const
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
RedundantSeedCleaner * theSeedCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_
const MeasurementTracker * theMeasurementTracker_
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 ...
#define LogDebug(id)
const BaseCkfTrajectoryBuilder * theCkfTrajectoryBuilder_

Member Data Documentation

◆ theSeedCleaner_

RedundantSeedCleaner* OutInConversionTrackFinder::theSeedCleaner_
private

◆ theTrajectoryCleaner_

TrajectoryCleanerBySharedHits* OutInConversionTrackFinder::theTrajectoryCleaner_
private