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)
 
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)
 
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_
 
const MagneticFieldtheMF_
 
edm::ESHandle< PropagatorthePropagator_
 
const TrackerGeometrytheTrackerGeom_
 
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 ( const edm::ParameterSet config,
const BaseCkfTrajectoryBuilder trajectoryBuilder 
)

Definition at line 22 of file OutInConversionTrackFinder.cc.

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

22  : ConversionTrackFinder( conf, trajectoryBuilder )
23 {
24 
25 
27 
28  // get the seed cleaner
29  std::string cleaner = conf.getParameter<std::string>("OutInRedundantSeedCleaner");
30  if (cleaner == "CachingSeedCleanerBySharedInput") {
32  } else if (cleaner == "none") {
33  theSeedCleaner_ = nullptr;
34  } else {
35  throw cms::Exception("OutInRedundantSeedCleaner not found, please use CachingSeedCleanerBySharedInput or none", cleaner);
36  }
37 
38 
39 
40 
41 
42 }
ConversionTrackFinder(const edm::ParameterSet &config, const BaseCkfTrajectoryBuilder *trajectoryBuilder)
RedundantSeedCleaner * theSeedCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_
OutInConversionTrackFinder::~OutInConversionTrackFinder ( )
override

Definition at line 47 of file OutInConversionTrackFinder.cc.

References theSeedCleaner_, and theTrajectoryCleaner_.

47  {
48 
49  delete theTrajectoryCleaner_;
50  if (theSeedCleaner_) delete theSeedCleaner_;
51 
52 }
RedundantSeedCleaner * theSeedCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_

Member Function Documentation

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

Implements ConversionTrackFinder.

Definition at line 55 of file OutInConversionTrackFinder.cc.

References RedundantSeedCleaner::add(), alongMomentum, TrajectoryCleanerBySharedHits::clean(), TrackingRecHit::det(), RedundantSeedCleaner::done(), PV3DBase< T, PVType, FrameType >::eta(), edm::OwnVector< T, P >::front(), MeasurementTracker::geomTracker(), RedundantSeedCleaner::good(), BaseCkfTrajectoryBuilder::hitBuilder(), mps_fire::i, TrackingGeometry::idToDet(), RedundantSeedCleaner::init(), TrajectoryStateOnSurface::isValid(), LogDebug, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), PV3DBase< T, PVType, FrameType >::phi(), precomputed_value_sort(), Propagator::propagate(), TrackingRecHit::rawId(), mps_fire::result, edm::OwnVector< T, P >::size(), GeomDet::surface(), ConversionTrackFinder::theCkfTrajectoryBuilder_, ConversionTrackFinder::theInitialState_, ConversionTrackFinder::theMeasurementTracker_, ConversionTrackFinder::thePropagator_, theSeedCleaner_, theTrajectoryCleaner_, TrajectoryBuilder::trajectories(), and ConversionTrackFinder::useSplitHits_.

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

Member Data Documentation

RedundantSeedCleaner* OutInConversionTrackFinder::theSeedCleaner_
private
TrajectoryCleanerBySharedHits* OutInConversionTrackFinder::theTrajectoryCleaner_
private