CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | 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...
 
void initTrackProducerBase (const edm::ParameterSet &conf, edm::ConsumesCollector cc, const edm::EDGetToken &src)
 Call this method in inheriting class' constructor. 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 setSecondHitPattern (Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
 
 TrackProducerBase (bool trajectoryInEvent=false)
 Constructor. More...
 
virtual ~TrackProducerBase () noexcept(false)
 Destructor. More...
 

Protected Member Functions

void setClusterRemovalInfo (const edm::InputTag &clusterRemovalInfo)
 Sets the information on cluster removal, and turns it on. More...
 

Protected Attributes

edm::InputTag clusterRemovalInfo_
 
bool rekeyClusterRefs_
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::EDGetTokenT< reco::BeamSpotbsSrc_
 
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordbuilderSrc_
 
edm::ParameterSet conf_
 
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::RecordfitterSrc_
 
edm::ESGetToken< MeasurementTracker, CkfComponentsRecordmeasTkSrc_
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmfSrc_
 
edm::EDGetTokenT< MeasurementTrackerEventmteSrc_
 
edm::ESGetToken< Propagator, TrackingComponentsRecordpropagatorSrc_
 
edm::OrphanHandle< TrackCollectionrTracks_
 
edm::ESGetToken< NavigationSchool, NavigationSchoolRecordschoolSrc_
 
edm::EDGetToken src_
 
edm::ESHandle< NavigationSchooltheSchool
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackGeomSrc_
 
bool trajectoryInEvent_
 
bool useSchool_
 

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 >
 

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

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.

References alongMomentum, cms::cuda::assert(), clusterRemovalInfo_, TrajectoryStateOnSurface::curvilinearError(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), mps_fire::i, heavyIonCSV_trainingSettings::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(), rekeyClusterRefs_, TrackProducerBase< reco::Track >::rTracks_, reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), reco::TrackExtraBase::setTrajParams(), TrackProducerBase< reco::Track >::theSchool, HLT_2023v12_cff::track, TrackProducerBase< reco::Track >::trajectoryInEvent_, trajectoryToResiduals(), reco::TrackExtraBase::trajParams(), useSplitting, and findQualityFiles::v.

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

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 }
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
TrajParams const & trajParams() const
std::vector< unsigned char > Chi2sFive
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
unsigned int recHitsSize() const
number of RecHits
const GlobalTrajectoryParameters & globalParameters() const
void setSecondHitPattern(Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
PropagationDirection
assert(be >=bs)
#define LogTrace(id)
std::vector< LocalTrajectoryParameters > TrajParams
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
edm::InputTag clusterRemovalInfo_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
bool isValid() const
Definition: ESHandle.h:44
edm::EDGetTokenT< MeasurementTrackerEvent > mteSrc_
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
const CurvilinearTrajectoryError & curvilinearError() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::TrackResiduals trajectoryToResiduals(const Trajectory &trajectory)
edm::ESHandle< NavigationSchool > theSchool
edm::OrphanHandle< TrackCollection > rTracks_
def move(src, dest)
Definition: eostools.py:511
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)
#define LogDebug(id)
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:132

◆ setClusterRemovalInfo()

void KfTrackProducerBase::setClusterRemovalInfo ( const edm::InputTag clusterRemovalInfo)
inlineprotected

Sets the information on cluster removal, and turns it on.

Definition at line 43 of file KfTrackProducerBase.h.

References HLT_2023v12_cff::clusterRemovalInfo, clusterRemovalInfo_, and rekeyClusterRefs_.

Referenced by TrackProducer::TrackProducer().

Member Data Documentation

◆ clusterRemovalInfo_

edm::InputTag KfTrackProducerBase::clusterRemovalInfo_
protected

Definition at line 49 of file KfTrackProducerBase.h.

Referenced by putInEvt(), and setClusterRemovalInfo().

◆ rekeyClusterRefs_

bool KfTrackProducerBase::rekeyClusterRefs_
protected

Definition at line 48 of file KfTrackProducerBase.h.

Referenced by putInEvt(), and setClusterRemovalInfo().

◆ useSplitting

bool KfTrackProducerBase::useSplitting
private

Definition at line 52 of file KfTrackProducerBase.h.

Referenced by putInEvt().