CMS 3D CMS Logo

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

#include <KfTrackProducerBase.h>

Inheritance diagram for KfTrackProducerBase:
TrackProducerBase< reco::Track > AlgoProductTraits< reco::Track > DAFTrackProducer TrackProducer TrackRefitter

Public Member Functions

 KfTrackProducerBase (bool trajectoryInEvent, bool split)
 Constructor. More...
 
virtual void putInEvt (edm::Event &, const Propagator *prop, const MeasurementTracker *measTk, std::unique_ptr< TrackingRecHitCollection > &, std::unique_ptr< reco::TrackCollection > &, std::unique_ptr< reco::TrackExtraCollection > &, std::unique_ptr< std::vector< Trajectory > > &, std::unique_ptr< std::vector< int > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, const TrackerTopology *ttopo, int BeforeOrAfter=0)
 Put produced collections in the event. More...
 
- Public Member Functions inherited from TrackProducerBase< reco::Track >
const edm::ParameterSetgetConf () const
 
virtual void getFromES (const edm::EventSetup &, edm::ESHandle< TrackerGeometry > &, edm::ESHandle< MagneticField > &, edm::ESHandle< TrajectoryFitter > &, edm::ESHandle< Propagator > &, edm::ESHandle< MeasurementTracker > &, edm::ESHandle< TransientTrackingRecHitBuilder > &)
 Get needed services from the Event Setup. More...
 
virtual void getFromEvt (edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
 Get TrackCandidateCollection from the Event (needed by TrackProducer) More...
 
virtual void getFromEvt (edm::Event &, edm::Handle< TrackView > &, reco::BeamSpot &)
 Get TrackCollection from the Event (needed by TrackRefitter) More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)=0
 Method where the procduction take place. To be implemented in concrete classes. More...
 
void setAlias (std::string alias)
 set the aliases of produced collections More...
 
void setClusterRemovalInfo (const edm::InputTag &clusterRemovalInfo)
 Sets the information on cluster removal, and turns it on. More...
 
void setConf (const edm::ParameterSet &conf)
 Set parameter set. More...
 
void setSecondHitPattern (Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
 
void setSrc (const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
 set label of source collection More...
 
 TrackProducerBase (bool trajectoryInEvent=false)
 Constructor. More...
 
virtual ~TrackProducerBase () noexcept(false)
 Destructor. More...
 

Private Attributes

bool useSplitting
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::Track >
using AlgoProductCollection = typename Base::AlgoProductCollection
 
using Base = AlgoProductTraits< reco::Track >
 
using TrackCollection = typename Base::TrackCollection
 
using TrackView = typename Base::TrackView
 
- Public Types inherited from AlgoProductTraits< reco::Track >
using AlgoProductCollection = std::vector< AlgoProduct >
 
using TrackCollection = std::vector< reco::Track >
 
using TrackView = edm::View< reco::Track >
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::EDGetTokenT< reco::BeamSpotbsSrc_
 
edm::InputTag clusterRemovalInfo_
 
edm::ParameterSet conf_
 
edm::EDGetTokenT< MeasurementTrackerEventmteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle< TrackCollectionrTracks_
 
edm::EDGetToken src_
 
edm::ESHandle< NavigationSchooltheSchool
 
bool trajectoryInEvent_
 

Detailed Description

Produce Tracks from TrackCandidates

Author
cerati

Definition at line 16 of file KfTrackProducerBase.h.

Constructor & Destructor Documentation

◆ KfTrackProducerBase()

KfTrackProducerBase::KfTrackProducerBase ( bool  trajectoryInEvent,
bool  split 
)
inlineexplicit

Constructor.

Definition at line 19 of file KfTrackProducerBase.h.

20  : TrackProducerBase<reco::Track>(trajectoryInEvent), useSplitting(split) {}

Member Function Documentation

◆ putInEvt()

void KfTrackProducerBase::putInEvt ( edm::Event evt,
const Propagator prop,
const MeasurementTracker measTk,
std::unique_ptr< TrackingRecHitCollection > &  selHits,
std::unique_ptr< reco::TrackCollection > &  selTracks,
std::unique_ptr< reco::TrackExtraCollection > &  selTrackExtras,
std::unique_ptr< std::vector< Trajectory > > &  selTrajectories,
std::unique_ptr< std::vector< int > > &  indecesInput,
AlgoProductCollection algoResults,
TransientTrackingRecHitBuilder const *  hitBuilder,
const TrackerTopology ttopo,
int  BeforeOrAfter = 0 
)
virtual

Put produced collections in the event.

Definition at line 21 of file KfTrackProducerBase.cc.

32  {
35 
38  edm::Ref<std::vector<Trajectory> >::key_type iTjRef = 0;
39  std::map<unsigned int, unsigned int> tjTkMap;
40 
41  selTracks->reserve(algoResults.size());
42  selTrackExtras->reserve(algoResults.size());
44  selTrajectories->reserve(algoResults.size());
45 
46  for (AlgoProductCollection::iterator i = algoResults.begin(); i != algoResults.end(); i++) {
47  auto theTraj = (*i).trajectory;
48  (*indecesInput).push_back((*i).indexInput);
49  if (trajectoryInEvent_) {
50  selTrajectories->push_back(*theTraj);
51  iTjRef++;
52  }
53 
54  auto theTrack = (*i).track;
55 
56  // Hits are going to be re-sorted along momentum few lines later.
57  // Therefore the direction stored in the TrackExtra
58  // has to be "alongMomentum" as well. Anyway, this direction can be differnt from the one of the orignal
59  // seed! The name seedDirection() for the Track's method (and the corresponding data member) is
60  // misleading and should be changed into something like "hitsDirection()". TO BE FIXED!
61 
63 
64  LogDebug("TrackProducer") << "In KfTrackProducerBase::putInEvt - seedDir=" << seedDir;
65 
66  selTracks->push_back(std::move(*theTrack));
67  delete theTrack;
68  iTkRef++;
69 
70  // Store indices in local map (starts at 0)
72  tjTkMap[iTjRef - 1] = iTkRef - 1;
73 
74  //sets the outermost and innermost TSOSs
75  TrajectoryStateOnSurface outertsos;
76  TrajectoryStateOnSurface innertsos;
77  unsigned int innerId, outerId;
78 
79  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
80  // This is consistent with innermost and outermost labels only for tracks from LHC collision
81  if (theTraj->direction() == alongMomentum) {
82  outertsos = theTraj->lastMeasurement().updatedState();
83  innertsos = theTraj->firstMeasurement().updatedState();
84  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
85  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
86  } else {
87  outertsos = theTraj->firstMeasurement().updatedState();
88  innertsos = theTraj->lastMeasurement().updatedState();
89  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
90  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
91  }
92  // ---
93  //build the TrackExtra
94  GlobalPoint v = outertsos.globalParameters().position();
95  GlobalVector p = outertsos.globalParameters().momentum();
96  math::XYZVector outmom(p.x(), p.y(), p.z());
97  math::XYZPoint outpos(v.x(), v.y(), v.z());
98  v = innertsos.globalParameters().position();
99  p = innertsos.globalParameters().momentum();
100  math::XYZVector inmom(p.x(), p.y(), p.z());
101  math::XYZPoint inpos(v.x(), v.y(), v.z());
102 
103  reco::TrackExtraRef teref = reco::TrackExtraRef(rTrackExtras, idx++);
104  reco::Track& track = selTracks->back();
105  track.setExtra(teref);
106  //======= I want to set the second hitPattern here =============
107  if (theSchool.isValid()) {
109  evt.getByToken(mteSrc_, mte);
110  // NavigationSetter setter( *theSchool );
111  setSecondHitPattern(theTraj, track, prop, &*mte, ttopo);
112  }
113  //==============================================================
114 
115  selTrackExtras->push_back(reco::TrackExtra(outpos,
116  outmom,
117  true,
118  inpos,
119  inmom,
120  true,
121  outertsos.curvilinearError(),
122  outerId,
123  innertsos.curvilinearError(),
124  innerId,
125  seedDir,
126  theTraj->seedRef()));
127 
128  // FIXME will remove this obsolete config-param in a future PR
130 
131  reco::TrackExtra& tx = selTrackExtras->back();
132  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
133  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
134  reco::TrackExtra::TrajParams trajParams;
136  Traj2TrackHits t2t;
137  auto ih = selHits->size();
138  t2t(*theTraj, *selHits, trajParams, chi2s);
139  auto ie = selHits->size();
140  tx.setHits(rHits, ih, ie - ih);
141  tx.setTrajParams(std::move(trajParams), std::move(chi2s));
142  assert(tx.trajParams().size() == tx.recHitsSize());
143  for (; ih < ie; ++ih) {
144  auto const& hit = (*selHits)[ih];
145  track.appendHitPattern(hit, *ttopo);
146  }
147 
148  // ----
149  tx.setResiduals(trajectoryToResiduals(*theTraj));
150 
151  delete theTraj;
152  }
153 
154  // Now we can re-set refs to hits, as they have already been cloned
155  if (rekeyClusterRefs_) {
157  for (TrackingRecHitCollection::iterator it = selHits->begin(), ed = selHits->end(); it != ed; ++it) {
158  refSetter.reKey(&*it);
159  }
160  }
161 
162  LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
163  LogTrace("TrackingRegressionTest") << "number of finalTracks: " << selTracks->size();
164  for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
165  LogTrace("TrackingRegressionTest") << "track's n valid and invalid hit, chi2, pt, eta : " << it->found() << " , "
166  << it->lost() << " , " << it->normalizedChi2() << " , " << it->pt() << " , "
167  << it->eta();
168  }
169  LogTrace("TrackingRegressionTest") << "=================================================";
170 
171  selTracks->shrink_to_fit();
172  selTrackExtras->shrink_to_fit();
173  selHits->shrink_to_fit();
174  indecesInput->shrink_to_fit();
175  if (BeforeOrAfter == 1) {
176  rTracks_ = evt.put(std::move(selTracks), "beforeDAF");
177  evt.put(std::move(selTrackExtras), "beforeDAF");
178  evt.put(std::move(indecesInput), "beforeDAF");
179  } else if (BeforeOrAfter == 2) {
180  rTracks_ = evt.put(std::move(selTracks), "afterDAF");
181  evt.put(std::move(selTrackExtras), "afterDAF");
182  evt.put(std::move(indecesInput), "afterDAF");
183  } else {
184  rTracks_ = evt.put(std::move(selTracks));
185  evt.put(std::move(selTrackExtras));
186  evt.put(std::move(selHits));
187  evt.put(std::move(indecesInput));
188  }
189 
190  if (trajectoryInEvent_ && BeforeOrAfter == 0) {
191  selTrajectories->shrink_to_fit();
192  edm::OrphanHandle<std::vector<Trajectory> > rTrajs = evt.put(std::move(selTrajectories));
193 
194  // Now Create traj<->tracks association map
195  std::unique_ptr<TrajTrackAssociationCollection> trajTrackMap(new TrajTrackAssociationCollection(rTrajs, rTracks_));
196  for (std::map<unsigned int, unsigned int>::iterator i = tjTkMap.begin(); i != tjTkMap.end(); i++) {
197  edm::Ref<std::vector<Trajectory> > trajRef(rTrajs, (*i).first);
198  edm::Ref<reco::TrackCollection> tkRef(rTracks_, (*i).second);
199  trajTrackMap->insert(edm::Ref<std::vector<Trajectory> >(rTrajs, (*i).first),
201  }
202  evt.put(std::move(trajTrackMap));
203  }
204 }

References alongMomentum, cms::cuda::assert(), TrackProducerBase< reco::Track >::clusterRemovalInfo_, TrajectoryStateOnSurface::curvilinearError(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), mps_fire::i, training_settings::idx, edm::ESHandleBase::isValid(), LogDebug, LogTrace, GlobalTrajectoryParameters::momentum(), eostools::move(), TrackProducerBase< reco::Track >::mteSrc_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), reco::TrackExtraBase::recHitsSize(), ClusterRemovalRefSetter::reKey(), TrackProducerBase< reco::Track >::rekeyClusterRefs_, TrackProducerBase< reco::Track >::rTracks_, reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), reco::TrackExtraBase::setTrajParams(), TrackProducerBase< reco::Track >::theSchool, HLT_2018_cff::track, TrackProducerBase< reco::Track >::trajectoryInEvent_, trajectoryToResiduals(), reco::TrackExtraBase::trajParams(), useSplitting, and findQualityFiles::v.

Referenced by TrackRefitter::produce(), TrackProducer::produce(), and DAFTrackProducer::produce().

Member Data Documentation

◆ useSplitting

bool KfTrackProducerBase::useSplitting
private

Definition at line 42 of file KfTrackProducerBase.h.

Referenced by putInEvt().

Vector3DBase
Definition: Vector3DBase.h:8
edm::RefProd< TrackingRecHitCollection >
edm::Event::getRefBeforePut
RefProd< PROD > getRefBeforePut()
Definition: Event.h:157
KfTrackProducerBase::useSplitting
bool useSplitting
Definition: KfTrackProducerBase.h:42
mps_fire.i
i
Definition: mps_fire.py:355
TrackProducerBase< reco::Track >::rTracks_
edm::OrphanHandle< TrackCollection > rTracks_
Definition: TrackProducerBase.h:109
GlobalTrajectoryParameters::position
GlobalPoint position() const
Definition: GlobalTrajectoryParameters.h:60
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cms::cuda::assert
assert(be >=bs)
cms::dd::split
std::vector< std::string_view > split(std::string_view, const char *)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TrackProducerBase< reco::Track >::setSecondHitPattern
void setSecondHitPattern(Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
edm::Handle< MeasurementTrackerEvent >
training_settings.idx
idx
Definition: training_settings.py:16
edm::Ref
Definition: AssociativeIterator.h:58
reco::TrackExtra
Definition: TrackExtra.h:26
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
ClusterRemovalRefSetter
Definition: ClusterRemovalRefSetter.h:21
reco::Track
Definition: Track.h:27
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Point3DBase< float, GlobalTag >
GlobalTrajectoryParameters::momentum
GlobalVector momentum() const
Definition: GlobalTrajectoryParameters.h:65
reco::TrackExtraBase::setTrajParams
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)
Definition: TrackExtraBase.h:36
reco::TrackExtra::setResiduals
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:132
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Traj2TrackHits
Definition: Traj2TrackHits.h:16
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::TrackExtraRef
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
reco::TrackExtraBase::trajParams
TrajParams const & trajParams() const
Definition: TrackExtraBase.h:76
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
trajectoryToResiduals
reco::TrackResiduals trajectoryToResiduals(const Trajectory &trajectory)
Definition: TrajectoryToResiduals.cc:7
TrackProducerBase< reco::Track >::trajectoryInEvent_
bool trajectoryInEvent_
Definition: TrackProducerBase.h:108
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
edm::Ref::key_type
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
reco::TrackExtraBase::setHits
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
Definition: TrackExtraBase.h:30
reco::TrackExtraBase::recHitsSize
unsigned int recHitsSize() const
number of RecHits
Definition: TrackExtraBase.h:44
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
reco::TrackExtraBase::Chi2sFive
std::vector< unsigned char > Chi2sFive
Definition: TrackExtraBase.h:25
TrackProducerBase< reco::Track >::mteSrc_
edm::EDGetTokenT< MeasurementTrackerEvent > mteSrc_
Definition: TrackProducerBase.h:111
TrajectoryStateOnSurface::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: TrajectoryStateOnSurface.h:72
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TrajTrackAssociationCollection
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
Definition: TrajTrackAssociation.h:9
TrackProducerBase< reco::Track >::rekeyClusterRefs_
bool rekeyClusterRefs_
Definition: TrackProducerBase.h:113
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
TrajectoryStateOnSurface::globalParameters
const GlobalTrajectoryParameters & globalParameters() const
Definition: TrajectoryStateOnSurface.h:64
TrackProducerBase< reco::Track >
reco::TrackExtraBase::TrajParams
std::vector< LocalTrajectoryParameters > TrajParams
Definition: TrackExtraBase.h:24
alongMomentum
Definition: PropagationDirection.h:4
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
TrackProducerBase< reco::Track >::clusterRemovalInfo_
edm::InputTag clusterRemovalInfo_
Definition: TrackProducerBase.h:114
TrackProducerBase< reco::Track >::theSchool
edm::ESHandle< NavigationSchool > theSchool
Definition: TrackProducerBase.h:116