CMS 3D CMS Logo

OutInConversionTrackFinder.cc
Go to the documentation of this file.
2 //
5 //
7 //
8 
12 
13 //
15 //
17 //
19 
21  const BaseCkfTrajectoryBuilder* trajectoryBuilder)
22  : ConversionTrackFinder(conf, trajectoryBuilder) {
24 
25  // get the seed cleaner
26  std::string cleaner = conf.getParameter<std::string>("OutInRedundantSeedCleaner");
27  if (cleaner == "CachingSeedCleanerBySharedInput") {
29  } else if (cleaner == "none") {
30  theSeedCleaner_ = nullptr;
31  } else {
32  throw cms::Exception("OutInRedundantSeedCleaner not found, please use CachingSeedCleanerBySharedInput or none",
33  cleaner);
34  }
35 }
36 
38  delete theTrajectoryCleaner_;
39  if (theSeedCleaner_)
40  delete theSeedCleaner_;
41 }
42 
43 std::vector<Trajectory> OutInConversionTrackFinder::tracks(const TrajectorySeedCollection& outInSeeds,
44  TrackCandidateCollection& output_p) const {
45  // std::cout << "OutInConversionTrackFinder::tracks getting " << outInSeeds.size() << " Out-In seeds " << "\n";;
46 
47  std::vector<Trajectory> tmpO;
48  tmpO.erase(tmpO.begin(), tmpO.end());
49 
50  std::vector<Trajectory> result;
51  result.erase(result.begin(), result.end());
52 
53  std::vector<Trajectory> rawResult;
54  if (theSeedCleaner_)
55  theSeedCleaner_->init(&rawResult);
56 
58  /*
59  for(TrajectorySeedCollection::const_iterator iSeed=outInSeeds.begin(); iSeed!=outInSeeds.end();iSeed++){
60  DetId tmpId = DetId( iSeed->startingState().detId());
61  const GeomDet* tmpDet = theMeasurementTracker_->geomTracker()->idToDet( tmpId );
62  GlobalVector gv = tmpDet->surface().toGlobal( iSeed->startingState().parameters().momentum() );
63 
64  LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::tracks hits in the seed " << iSeed->nHits() << "\n";
65  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";
66 
67  TrajectorySeed::range hitRange = iSeed->recHits();
68  for (TrajectorySeed::const_iterator ihit = hitRange.first; ihit != hitRange.second; ihit++) {
69 
70  if ( ihit->isValid() ) {
71 
72  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" ;
73 
74  }
75  }
76  }
77 
78  */
79 
80  int goodSeed = 0;
81  std::vector<Trajectory> theTmpTrajectories;
82  for (TrajectorySeedCollection::const_iterator iSeed = outInSeeds.begin(); iSeed != outInSeeds.end(); iSeed++) {
83  theTmpTrajectories.clear();
84 
85  if (!theSeedCleaner_ || theSeedCleaner_->good(&(*iSeed))) {
86  goodSeed++;
87 
88  DetId tmpId = DetId(iSeed->startingState().detId());
89  const GeomDet* tmpDet = theMeasurementTracker_->geomTracker()->idToDet(tmpId);
90  GlobalVector gv = tmpDet->surface().toGlobal(iSeed->startingState().parameters().momentum());
91 
92  // std::cout << " OutInConversionTrackFinder::tracks hits in the seed " << iSeed->nHits() << "\n";
93  LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::tracks seed starting state position "
94  << iSeed->startingState().parameters().position() << " momentum "
95  << iSeed->startingState().parameters().momentum() << " charge "
96  << iSeed->startingState().parameters().charge() << " R " << gv.perp()
97  << " eta " << gv.eta() << " phi " << gv.phi() << "\n";
98 
99  theCkfTrajectoryBuilder_->trajectories(*iSeed, theTmpTrajectories);
100 
101  LogDebug("OutInConversionTrackFinder")
102  << "OutInConversionTrackFinder::track returned " << theTmpTrajectories.size() << " trajectories"
103  << "\n";
104 
105  theTrajectoryCleaner_->clean(theTmpTrajectories);
106 
107  for (std::vector<Trajectory>::const_iterator it = theTmpTrajectories.begin(); it != theTmpTrajectories.end();
108  it++) {
109  if (it->isValid()) {
110  rawResult.push_back(*it);
111  if (theSeedCleaner_)
112  theSeedCleaner_->add(&(*it));
113  }
114  }
115  }
116  } // end loop over the seeds
117  LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::track Good seeds " << goodSeed << "\n";
118  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder::track rawResult size after cleaning "
119  << rawResult.size() << "\n";
120 
121  if (theSeedCleaner_)
123 
124  std::vector<Trajectory> unsmoothedResult;
125  theTrajectoryCleaner_->clean(rawResult);
126 
127  for (std::vector<Trajectory>::const_iterator itraw = rawResult.begin(); itraw != rawResult.end(); itraw++) {
128  if ((*itraw).isValid()) {
129  tmpO.push_back(*itraw);
130  LogDebug("OutInConversionTrackFinder") << " rawResult num hits " << (*itraw).foundHits() << "\n";
131  }
132  }
133 
134  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size()
135  << " before sorting "
136  << "\n";
137  // for (std::vector<Trajectory>::const_iterator it =tmpO.begin(); it != tmpO.end(); it++) {
138  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO num of hits " << (*it).foundHits() << " before ordering " << "\n";
139  // }
140 
141  precomputed_value_sort(tmpO.begin(), tmpO.end(), ExtractNumOfHits());
142 
143  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO after sorting "
144  << "\n";
145  // for (std::vector<Trajectory>::const_iterator it =tmpO.begin(); it != tmpO.end(); it++) {
146  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO num of hits " << (*it).foundHits() << "\n";
147  // }
148 
149  for (int i = tmpO.size() - 1; i >= 0; i--) {
150  unsmoothedResult.push_back(tmpO[i]);
151  }
152  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder unsmoothedResult size "
153  << unsmoothedResult.size() << "\n";
154 
155  // for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
156  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder unsmoothedResult after reordering " <<(*it).foundHits() << "\n";
157  // }
158 
159  // Check if the inner state is valid
160  tmpO.clear();
161  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size()
162  << " after clearing "
163  << "\n";
164  for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
165  if (!it->isValid())
166  continue;
167 
168  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState(*it);
169  // LogDebug("OutInConversionTrackFinder") << " Initial state parameters " << initState.first << "\n";
170 
171  // temporary protection againt invalid initial states
172  if (!initState.first.isValid() || initState.second == nullptr) {
173  LogDebug("OutInConversionTrackFinder") << "invalid innerState, will not make TrackCandidate"
174  << "\n";
175  ;
176  continue;
177  }
178  tmpO.push_back(*it);
179  }
180 
181  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size() << " after filling "
182  << "\n";
183  if (!tmpO.empty()) {
184  std::vector<Trajectory>::iterator it = tmpO.begin();
185 
186  // only send out the two best tracks
187  result.push_back(*it);
188  if (tmpO.size() > 1)
189  result.push_back(*(++it));
190  }
191 
192  // for (std::vector<Trajectory>::const_iterator it =result.begin(); it != result.end(); it++) {
193  // LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder Result num of hits " << (*it).foundHits() << "\n";
194  //}
195 
196  // Convert to TrackCandidates and fill in the output_p
198  for (std::vector<Trajectory>::const_iterator it = result.begin(); it != result.end(); it++) {
200  if (it->direction() == alongMomentum)
201  LogDebug("OutInConversionTrackFinder") << "OutInConv along momentum... " << std::endl;
202  t2t(*it, recHits, useSplitHits_);
203 
204  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState(*it);
205 
206  assert(initState.second == recHits.front().det());
207 
208  // temporary protection againt invalid initial states
209  if (!initState.first.isValid() || initState.second == nullptr) {
210  LogDebug("OutInConversionTrackFinder") << "invalid innerState, will not make TrackCandidate" << std::endl;
211  continue;
212  }
213 
215  if (useSplitHits_ && (initState.second != recHits.front().det()) && recHits.front().det()) {
216  TrajectoryStateOnSurface propagated =
217  thePropagator_->propagate(initState.first, recHits.front().det()->surface());
218  if (!propagated.isValid())
219  continue;
220  state = trajectoryStateTransform::persistentState(propagated, recHits.front().rawId());
221  } else
222  state = trajectoryStateTransform::persistentState(initState.first, initState.second->geographicalId().rawId());
223 
224  LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder Number of hits for the track candidate "
225  << recHits.size() << " TSOS charge " << initState.first.charge() << "\n";
226 
227  output_p.push_back(TrackCandidate(recHits, it->seed(), state));
228  }
229 
230  // std::cout << " Returning " << result.size() << "Out In Trajectories " << "\n";
231 
232  return result;
233 }
Vector3DBase
Definition: Vector3DBase.h:8
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
TrajectoryCleanerBySharedHits
Definition: TrajectoryCleanerBySharedHits.h:15
BaseCkfTrajectoryBuilder
Definition: BaseCkfTrajectoryBuilder.h:53
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
TrajectorySeedCollection
std::vector< TrajectorySeed > TrajectorySeedCollection
Definition: TrajectorySeedCollection.h:6
TrajectoryCleanerBySharedHits.h
ConversionTrackFinder::useSplitHits_
bool useSplitHits_
Definition: ConversionTrackFinder.h:56
ConversionTrackFinder
Definition: ConversionTrackFinder.h:31
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
OutInConversionTrackFinder.h
cms::cuda::assert
assert(be >=bs)
precomputed_value_sort.h
TransientInitialStateEstimator.h
TrajectoryCleanerBySharedHits::clean
void clean(TrajectoryPointerContainer &) const override
Definition: TrajectoryCleanerBySharedHits.cc:42
OutInConversionTrackFinder::tracks
std::vector< Trajectory > tracks(const TrajectorySeedCollection &seeds, TrackCandidateCollection &candidates) const override
Definition: OutInConversionTrackFinder.cc:43
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
OutInConversionTrackFinder::OutInConversionTrackFinder
OutInConversionTrackFinder(const edm::ParameterSet &config, const BaseCkfTrajectoryBuilder *trajectoryBuilder)
Definition: OutInConversionTrackFinder.cc:20
ConversionTrackFinder::theMeasurementTracker_
const MeasurementTracker * theMeasurementTracker_
Definition: ConversionTrackFinder.h:47
ConversionTrackFinder::thePropagator_
edm::ESHandle< Propagator > thePropagator_
Definition: ConversionTrackFinder.h:54
BaseCkfTrajectoryBuilder::hitBuilder
const TransientTrackingRecHitBuilder * hitBuilder() const
Definition: BaseCkfTrajectoryBuilder.h:104
Traj2TrackHits.h
ConversionTrackFinder::ExtractNumOfHits
Definition: ConversionTrackFinder.h:58
CachingSeedCleanerBySharedInput
Definition: CachingSeedCleanerBySharedInput.h:8
MeasurementTracker::geomTracker
const TrackerGeometry * geomTracker() const
Definition: MeasurementTracker.h:36
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
ConversionTrackFinder::theInitialState_
std::unique_ptr< TransientInitialStateEstimator > theInitialState_
Definition: ConversionTrackFinder.h:50
OutInConversionTrackFinder::~OutInConversionTrackFinder
~OutInConversionTrackFinder() override
Definition: OutInConversionTrackFinder.cc:37
RedundantSeedCleaner::done
virtual void done()=0
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.
CachingSeedCleanerBySharedInput.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
TrackCandidateCollection
std::vector< TrackCandidate > TrackCandidateCollection
Definition: TrackCandidateCollection.h:7
TrackCandidate
Definition: TrackCandidate.h:24
Traj2TrackHits
Definition: Traj2TrackHits.h:16
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RedundantSeedCleaner::good
virtual bool good(const TrajectorySeed *seed)=0
Returns true if the seed is not overlapping with another trajectory.
ConversionTrackFinder::theCkfTrajectoryBuilder_
const BaseCkfTrajectoryBuilder * theCkfTrajectoryBuilder_
Definition: ConversionTrackFinder.h:48
RedundantSeedCleaner::add
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...
TrajectoryBuilder::trajectories
virtual TrajectoryContainer trajectories(const TrajectorySeed &) const =0
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
Exception
Definition: hltDiff.cc:245
RedundantSeedCleaner::init
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 ...
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateTransform.h
mps_fire.result
result
Definition: mps_fire.py:311
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
ParameterSet.h
OwnVector.h
OutInConversionTrackFinder::theTrajectoryCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_
Definition: OutInConversionTrackFinder.h:40
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
alongMomentum
Definition: PropagationDirection.h:4
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
edm::OwnVector< TrackingRecHit >
OutInConversionTrackFinder::theSeedCleaner_
RedundantSeedCleaner * theSeedCleaner_
Definition: OutInConversionTrackFinder.h:41