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 ()(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 ( bool  trajectoryInEvent,
bool  split 
)
inlineexplicit

Constructor.

Definition at line 20 of file KfTrackProducerBase.h.

References putInEvt().

Member Function Documentation

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 22 of file KfTrackProducerBase.cc.

References alongMomentum, reco::TrackBase::appendHitPattern(), 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::Track::setExtra(), reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), reco::TrackExtraBase::setTrajParams(), TrackProducerBase< reco::Track >::theSchool, HiIsolationCommonParameters_cff::track, TrackProducerBase< reco::Track >::trajectoryInEvent_, trajectoryToResiduals(), reco::TrackExtraBase::trajParams(), useSplitting, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

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

34 {
35 
38 
41  edm::Ref< std::vector<Trajectory> >::key_type iTjRef = 0;
42  std::map<unsigned int, unsigned int> tjTkMap;
43 
44  selTracks->reserve(algoResults.size());
45  selTrackExtras->reserve(algoResults.size());
46  if(trajectoryInEvent_) selTrajectories->reserve(algoResults.size());
47 
48  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
49  auto theTraj = (*i).trajectory;
50  (*indecesInput).push_back((*i).indexInput);
51  if(trajectoryInEvent_) {
52  selTrajectories->push_back(*theTraj);
53  iTjRef++;
54  }
55 
56 
57  auto theTrack = (*i).track;
58 
59  // Hits are going to be re-sorted along momentum few lines later.
60  // Therefore the direction stored in the TrackExtra
61  // has to be "alongMomentum" as well. Anyway, this direction can be differnt from the one of the orignal
62  // seed! The name seedDirection() for the Track's method (and the corresponding data member) is
63  // misleading and should be changed into something like "hitsDirection()". TO BE FIXED!
64 
66 
67  LogDebug("TrackProducer") << "In KfTrackProducerBase::putInEvt - seedDir=" << seedDir;
68 
69 
70  selTracks->push_back(std::move(*theTrack));
71  delete theTrack;
72  iTkRef++;
73 
74  // Store indices in local map (starts at 0)
75  if(trajectoryInEvent_) tjTkMap[iTjRef-1] = iTkRef-1;
76 
77  //sets the outermost and innermost TSOSs
78  TrajectoryStateOnSurface outertsos;
79  TrajectoryStateOnSurface innertsos;
80  unsigned int innerId, outerId;
81 
82  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
83  // This is consistent with innermost and outermost labels only for tracks from LHC collision
84  if (theTraj->direction() == alongMomentum) {
85  outertsos = theTraj->lastMeasurement().updatedState();
86  innertsos = theTraj->firstMeasurement().updatedState();
87  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
88  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
89  } else {
90  outertsos = theTraj->firstMeasurement().updatedState();
91  innertsos = theTraj->lastMeasurement().updatedState();
92  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
93  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
94  }
95  // ---
96  //build the TrackExtra
97  GlobalPoint v = outertsos.globalParameters().position();
98  GlobalVector p = outertsos.globalParameters().momentum();
99  math::XYZVector outmom( p.x(), p.y(), p.z() );
100  math::XYZPoint outpos( v.x(), v.y(), v.z() );
101  v = innertsos.globalParameters().position();
102  p = innertsos.globalParameters().momentum();
103  math::XYZVector inmom( p.x(), p.y(), p.z() );
104  math::XYZPoint inpos( v.x(), v.y(), v.z() );
105 
106  reco::TrackExtraRef teref= reco::TrackExtraRef ( rTrackExtras, idx ++ );
107  reco::Track & track = selTracks->back();
108  track.setExtra( teref );
109  //======= I want to set the second hitPattern here =============
110  if (theSchool.isValid())
111  {
113  evt.getByToken(mteSrc_, mte);
114  // NavigationSetter setter( *theSchool );
115  setSecondHitPattern(theTraj,track,prop,&*mte, ttopo);
116  }
117  //==============================================================
118 
119  selTrackExtras->push_back( reco::TrackExtra (outpos, outmom, true, inpos, inmom, true,
120  outertsos.curvilinearError(), outerId,
121  innertsos.curvilinearError(), innerId,
122  seedDir, theTraj->seedRef()));
123 
124  // FIXME will remove this obsolete config-param in a future PR
125  assert(!useSplitting);
126 
127  reco::TrackExtra & tx = selTrackExtras->back();
128  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
129  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
130  reco::TrackExtra::TrajParams trajParams;
132  Traj2TrackHits t2t;
133  auto ih = selHits->size();
134  t2t(*theTraj,*selHits,trajParams,chi2s);
135  auto ie = selHits->size();
136  tx.setHits(rHits,ih,ie-ih);
137  tx.setTrajParams(std::move(trajParams),std::move(chi2s));
138  assert(tx.trajParams().size()==tx.recHitsSize());
139  for (;ih<ie; ++ih) {
140  auto const & hit = (*selHits)[ih];
141  track.appendHitPattern(hit, *ttopo);
142  }
143 
144  // ----
145  tx.setResiduals(trajectoryToResiduals(*theTraj));
146 
147  delete theTraj;
148  }
149 
150  // Now we can re-set refs to hits, as they have already been cloned
151  if (rekeyClusterRefs_) {
153  for (TrackingRecHitCollection::iterator it = selHits->begin(), ed = selHits->end(); it != ed; ++it) {
154  refSetter.reKey(&*it);
155  }
156  }
157 
158  LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
159  LogTrace("TrackingRegressionTest") << "number of finalTracks: " << selTracks->size();
160  for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
161  LogTrace("TrackingRegressionTest") << "track's n valid and invalid hit, chi2, pt, eta : "
162  << it->found() << " , "
163  << it->lost() <<" , "
164  << it->normalizedChi2() << " , "
165  << it->pt() << " , "
166  << it->eta() ;
167  }
168  LogTrace("TrackingRegressionTest") << "=================================================";
169 
170  selTracks->shrink_to_fit();
171  selTrackExtras->shrink_to_fit();
172  selHits->shrink_to_fit();
173  indecesInput->shrink_to_fit();
174  if(BeforeOrAfter == 1){
175  rTracks_ = evt.put(std::move(selTracks), "beforeDAF" );
176  evt.put(std::move(selTrackExtras), "beforeDAF");
177  evt.put(std::move(indecesInput), "beforeDAF");
178  } else if (BeforeOrAfter == 2){
179  rTracks_ = evt.put(std::move(selTracks), "afterDAF" );
180  evt.put( std::move(selTrackExtras), "afterDAF" );
181  evt.put(std::move(indecesInput), "afterDAF");
182  } else {
183  rTracks_ = evt.put(std::move(selTracks) );
184  evt.put(std::move(selTrackExtras) );
185  evt.put(std::move(selHits) );
186  evt.put(std::move(indecesInput));
187  }
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();
197  i != tjTkMap.end(); i++ ) {
198  edm::Ref<std::vector<Trajectory> > trajRef( rTrajs, (*i).first );
199  edm::Ref<reco::TrackCollection> tkRef( rTracks_, (*i).second );
200  trajTrackMap->insert( edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
201  edm::Ref<reco::TrackCollection>( rTracks_, (*i).second ) );
202  }
203  evt.put( std::move(trajTrackMap) );
204  }
205 }
#define LogDebug(id)
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:169
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
std::vector< unsigned char > Chi2sFive
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
const CurvilinearTrajectoryError & curvilinearError() const
T y() const
Definition: PV3DBase.h:63
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:17
PropagationDirection
std::vector< LocalTrajectoryParameters > TrajParams
unsigned int recHitsSize() const
number of RecHits
TrajParams const & trajParams() const
T z() const
Definition: PV3DBase.h:64
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
#define LogTrace(id)
RefProd< PROD > getRefBeforePut()
Definition: Event.h:156
edm::EDGetTokenT< MeasurementTrackerEvent > mteSrc_
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
void setExtra(const TrackExtraRef &ref)
set reference to "extra" object
Definition: Track.h:184
const GlobalTrajectoryParameters & globalParameters() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::TrackResiduals trajectoryToResiduals(const Trajectory &trajectory)
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
Definition: TrackBase.h:456
edm::ESHandle< NavigationSchool > theSchool
bool isValid() const
Definition: ESHandle.h:47
edm::OrphanHandle< TrackCollection > rTracks_
T x() const
Definition: PV3DBase.h:62
def move(src, dest)
Definition: eostools.py:510
void setTrajParams(TrajParams tmps, Chi2sFive chi2s)
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:174

Member Data Documentation

bool KfTrackProducerBase::useSplitting
private

Definition at line 44 of file KfTrackProducerBase.h.

Referenced by putInEvt().