CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
KfTrackProducerBase Class Reference

#include <KfTrackProducerBase.h>

Inheritance diagram for KfTrackProducerBase:
TrackProducerBase< 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::auto_ptr< TrackingRecHitCollection > &, std::auto_ptr< reco::TrackCollection > &, std::auto_ptr< reco::TrackExtraCollection > &, std::auto_ptr< std::vector< Trajectory > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *)
 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< TrackCollection > &, 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)
 
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 ()
 Destructor. More...
 

Private Attributes

bool useSplitting
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::Track >
typedef std::pair< Trajectory
*, std::pair< reco::Track
*, PropagationDirection > > 
AlgoProduct
 
typedef std::vector< AlgoProductAlgoProductCollection
 
typedef std::vector< reco::TrackTrackCollection
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::EDGetTokenT< reco::BeamSpotbsSrc_
 
edm::InputTag clusterRemovalInfo_
 
edm::EDGetTokenT
< MeasurementTrackerEvent
mteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle
< TrackCollection
rTracks_
 
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.

Member Function Documentation

void KfTrackProducerBase::putInEvt ( edm::Event evt,
const Propagator prop,
const MeasurementTracker measTk,
std::auto_ptr< TrackingRecHitCollection > &  selHits,
std::auto_ptr< reco::TrackCollection > &  selTracks,
std::auto_ptr< reco::TrackExtraCollection > &  selTrackExtras,
std::auto_ptr< std::vector< Trajectory > > &  selTrajectories,
AlgoProductCollection algoResults,
TransientTrackingRecHitBuilder const *  hitBuilder 
)
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(), Trajectory::direction(), Trajectory::firstMeasurement(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), i, customizeTrackingMonitorSeedNumber::idx, edm::ESHandleBase::isValid(), Trajectory::lastMeasurement(), LogDebug, LogTrace, GlobalTrajectoryParameters::momentum(), TrackProducerBase< reco::Track >::mteSrc_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), TrajectoryMeasurement::recHit(), ClusterRemovalRefSetter::reKey(), TrackProducerBase< reco::Track >::rekeyClusterRefs_, TrackProducerBase< reco::Track >::rTracks_, Trajectory::seedRef(), reco::Track::setExtra(), reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), TrackProducerBase< reco::Track >::theSchool, TrackProducerBase< reco::Track >::trajectoryInEvent_, trajectoryToResiduals(), TrajectoryMeasurement::updatedState(), useSplitting, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

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

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

Member Data Documentation

bool KfTrackProducerBase::useSplitting
private

Definition at line 36 of file KfTrackProducerBase.h.

Referenced by putInEvt().