CMS 3D CMS Logo

InOutConversionTrackFinder.cc
Go to the documentation of this file.
2 //
4 
5 //
8 //
13 //
15 //
17 
18 #include <sstream>
19 
21  const BaseCkfTrajectoryBuilder* trajectoryBuilder)
22  : ConversionTrackFinder(conf, trajectoryBuilder) {
24 
25  // get the seed cleaner
26  std::string cleaner = conf.getParameter<std::string>("InOutRedundantSeedCleaner");
27  if (cleaner == "CachingSeedCleanerBySharedInput") {
29  } else if (cleaner == "none") {
30  theSeedCleaner_ = nullptr;
31  } else {
32  throw cms::Exception("InOutRedundantSeedCleaner 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> InOutConversionTrackFinder::tracks(const TrajectorySeedCollection& inOutSeeds,
44  TrackCandidateCollection& output_p) const {
45  // std::cout << " InOutConversionTrackFinder::tracks getting " << inOutSeeds.size() << " In-Out 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 
57  // Loop over the seeds
58  int goodSeed = 0;
59  for (TrajectorySeedCollection::const_iterator iSeed = inOutSeeds.begin(); iSeed != inOutSeeds.end(); iSeed++) {
60  if (!theSeedCleaner_ || theSeedCleaner_->good(&(*iSeed))) {
61  goodSeed++;
62 
63  LogDebug("InOutConversionTrackFinder")
64  << " InOutConversionTrackFinder::tracks hits in the seed " << iSeed->nHits() << "\n";
65  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder::tracks seed starting state position "
66  << iSeed->startingState().parameters().position() << " momentum "
67  << iSeed->startingState().parameters().momentum() << " charge "
68  << iSeed->startingState().parameters().charge() << "\n";
69  LogDebug("InOutConversionTrackFinder")
70  << " InOutConversionTrackFinder::tracks seed starting state para, vector "
71  << iSeed->startingState().parameters().vector() << "\n";
72 
73  std::vector<Trajectory> theTmpTrajectories;
74 
75  theTmpTrajectories = theCkfTrajectoryBuilder_->trajectories(*iSeed);
76 
77  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder::track returned "
78  << theTmpTrajectories.size() << " trajectories for this seed "
79  << "\n";
80 
81  theTrajectoryCleaner_->clean(theTmpTrajectories);
82 
83  for (std::vector<Trajectory>::const_iterator it = theTmpTrajectories.begin(); it != theTmpTrajectories.end();
84  it++) {
85  if (it->isValid()) {
86  rawResult.push_back(*it);
87  if (theSeedCleaner_)
88  theSeedCleaner_->add(&(*it));
89  }
90  }
91  }
92  } // end loop over the seeds
93 
94  LogDebug("InOutConversionTrackFinder") << "InOutConversionTrackFinder::track Good seeds " << goodSeed << "\n";
95  LogDebug("InOutConversionTrackFinder") << "InOutConversionTrackFinder::track rawResult size after cleaning "
96  << rawResult.size() << "\n";
97 
98  if (theSeedCleaner_)
100 
101  std::vector<Trajectory> unsmoothedResult;
102  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder::track Start second cleaning "
103  << "\n";
104  theTrajectoryCleaner_->clean(rawResult);
105  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder::track rawResult size after cleaning "
106  << rawResult.size() << "\n";
107 
108  int tra = 0;
109  for (std::vector<Trajectory>::const_iterator itraw = rawResult.begin(); itraw != rawResult.end(); itraw++) {
110  tra++;
111  LogDebug("InOutConversionTrackFinder")
112  << " InOutConversionTrackFinder looping of rawResult after cleaning " << tra << "\n";
113  if ((*itraw).isValid()) {
114  // unsmoothedResult.push_back( *itraw);
115  tmpO.push_back(*itraw);
116  LogDebug("InOutConversionTrackFinder")
117  << " InOutConversionTrackFinder::track rawResult num of valid recHits per trajectory " << (*itraw).foundHits()
118  << "\n";
119  }
120  }
121 
122  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder tmpO size " << tmpO.size()
123  << " before sorting "
124  << "\n";
125  // for (std::vector<Trajectory>::const_iterator it =tmpO.begin(); it != tmpO.end(); it++) {
126  // LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder tmpO num of hits " << (*it).foundHits() << " before ordering " << "\n";
127  //}
128 
129  precomputed_value_sort(tmpO.begin(), tmpO.end(), ExtractNumOfHits());
130 
131  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder tmpO after sorting "
132  << "\n";
133  // for (std::vector<Trajectory>::const_iterator it =tmpO.begin(); it != tmpO.end(); it++) {
134  // LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder tmpO num of hits " << (*it).foundHits() << "\n";
135  // }
136 
137  for (int i = tmpO.size() - 1; i >= 0; i--) {
138  unsmoothedResult.push_back(tmpO[i]);
139  }
140  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder unsmoothedResult size "
141  << unsmoothedResult.size() << "\n";
142 
143  // for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
144  // LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder unsmoothedResult after reordering " <<(*it).foundHits() << "\n";
145  // }
146 
147  // Convert to TrackCandidates and fill in the output_p
149  for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
151  if (it->direction() != alongMomentum)
152  LogDebug("InOutConversionTrackFinder") << "InOutConv not along momentum... " << std::endl;
153 
154  t2t(*it, recHits, useSplitHits_);
155 
156  std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState(*it);
157 
158  // temporary protection againt invalid initial states
159  if ((!initState.first.isValid()) | (initState.second == nullptr)) {
160  LogDebug("InOutConversionTrackFinder") << "invalid innerState, will not make TrackCandidate" << std::endl;
161  continue;
162  }
163 
165  if (useSplitHits_ && (initState.second != recHits.front().det()) && recHits.front().det()) {
166  TrajectoryStateOnSurface propagated =
167  thePropagator_->propagate(initState.first, recHits.front().det()->surface());
168  if (!propagated.isValid())
169  continue;
170  state = trajectoryStateTransform::persistentState(propagated, recHits.front().rawId());
171  } else
172  state = trajectoryStateTransform::persistentState(initState.first, initState.second->geographicalId().rawId());
173 
174  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder::track Making the result: seed position "
175  << it->seed().startingState().parameters().position() << " seed momentum "
176  << it->seed().startingState().parameters().momentum() << " charge "
177  << it->seed().startingState().parameters().charge() << "\n";
178  LogDebug("InOutConversionTrackFinder")
179  << " InOutConversionTrackFinder::track TSOS charge " << initState.first.charge() << "\n";
180 
181  LogDebug("InOutConversionTrackFinder")
182  << " InOutConversionTrackFinder::track PTrajectoryStateOnDet* state position "
183  << state.parameters().position() << " momentum " << state.parameters().momentum() << " charge "
184  << state.parameters().charge() << "\n";
185 
186  result.push_back(*it);
187  output_p.push_back(TrackCandidate(recHits, it->seed(), state));
188  }
189  // assert(result.size()==output_p.size());
190  LogDebug("InOutConversionTrackFinder") << " InOutConversionTrackFinder::track Returning " << result.size()
191  << " valid In Out Trajectories "
192  << "\n";
193  return result;
194 }
InOutConversionTrackFinder::tracks
std::vector< Trajectory > tracks(const TrajectorySeedCollection &seeds, TrackCandidateCollection &candidate) const override
Definition: InOutConversionTrackFinder.cc:43
TrajectoryCleanerBySharedHits
Definition: TrajectoryCleanerBySharedHits.h:15
BaseCkfTrajectoryBuilder
Definition: BaseCkfTrajectoryBuilder.h:53
mps_fire.i
i
Definition: mps_fire.py:428
InOutConversionTrackFinder.h
MessageLogger.h
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
InOutConversionTrackFinder::~InOutConversionTrackFinder
~InOutConversionTrackFinder() override
Definition: InOutConversionTrackFinder.cc:37
precomputed_value_sort.h
TransientInitialStateEstimator.h
TrajectoryCleanerBySharedHits::clean
void clean(TrajectoryPointerContainer &) const override
Definition: TrajectoryCleanerBySharedHits.cc:42
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrajectoryBuilder.h
InOutConversionTrackFinder::theTrajectoryCleaner_
TrajectoryCleanerBySharedHits * theTrajectoryCleaner_
Definition: InOutConversionTrackFinder.h:37
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
ConversionTrackFinder::theInitialState_
std::unique_ptr< TransientInitialStateEstimator > theInitialState_
Definition: ConversionTrackFinder.h:50
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
InOutConversionTrackFinder::theSeedCleaner_
RedundantSeedCleaner * theSeedCleaner_
Definition: InOutConversionTrackFinder.h:38
TrackCandidateCollection
std::vector< TrackCandidate > TrackCandidateCollection
Definition: TrackCandidateCollection.h:7
TrackCandidate
Definition: TrackCandidate.h:24
Traj2TrackHits
Definition: Traj2TrackHits.h:16
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
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 ...
InOutConversionTrackFinder::InOutConversionTrackFinder
InOutConversionTrackFinder(const edm::ParameterSet &config, const BaseCkfTrajectoryBuilder *trajectoryBuilder)
Definition: InOutConversionTrackFinder.cc:20
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
OwnVector.h
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
edm::OwnVector< TrackingRecHit >