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 *, 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< 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, 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 ()
 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,
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(), 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().

32 {
33 
36 
39  edm::Ref< std::vector<Trajectory> >::key_type iTjRef = 0;
40  std::map<unsigned int, unsigned int> tjTkMap;
41 
42  selTracks->reserve(algoResults.size());
43  selTrackExtras->reserve(algoResults.size());
44  if(trajectoryInEvent_) selTrajectories->reserve(algoResults.size());
45 
46  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
47  Trajectory * theTraj = (*i).first;
48  if(trajectoryInEvent_) {
49  selTrajectories->push_back(*theTraj);
50  iTjRef++;
51  }
52 
53 
54  reco::Track * theTrack = (*i).second.first;
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 
67  selTracks->push_back(std::move(*theTrack));
68  delete theTrack;
69  iTkRef++;
70 
71  // Store indices in local map (starts at 0)
72  if(trajectoryInEvent_) 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())
108  {
110  evt.getByToken(mteSrc_, mte);
111  // NavigationSetter setter( *theSchool );
112  setSecondHitPattern(theTraj,track,prop,&*mte, ttopo);
113  }
114  //==============================================================
115 
116  selTrackExtras->push_back( reco::TrackExtra (outpos, outmom, true, inpos, inmom, true,
117  outertsos.curvilinearError(), outerId,
118  innertsos.curvilinearError(), innerId,
119  seedDir, theTraj->seedRef()));
120 
121 
122  reco::TrackExtra & tx = selTrackExtras->back();
123  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
124  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
125  Traj2TrackHits t2t(hitBuilder,false);
126  auto ih = selHits->size();
127  t2t(*theTraj,*selHits,useSplitting);
128  auto ie = selHits->size();
129  tx.setHits(rHits,ih,ie-ih);
130  for (;ih<ie; ++ih) {
131  auto const & hit = (*selHits)[ih];
132  track.appendHitPattern(hit, *ttopo);
133  }
134 
135  // ----
136  tx.setResiduals(trajectoryToResiduals(*theTraj));
137 
138  delete theTraj;
139  }
140 
141  // Now we can re-set refs to hits, as they have already been cloned
142  if (rekeyClusterRefs_) {
144  for (TrackingRecHitCollection::iterator it = selHits->begin(), ed = selHits->end(); it != ed; ++it) {
145  refSetter.reKey(&*it);
146  }
147  }
148 
149  LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
150  LogTrace("TrackingRegressionTest") << "number of finalTracks: " << selTracks->size();
151  for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
152  LogTrace("TrackingRegressionTest") << "track's n valid and invalid hit, chi2, pt, eta : "
153  << it->found() << " , "
154  << it->lost() <<" , "
155  << it->normalizedChi2() << " , "
156  << it->pt() << " , "
157  << it->eta() ;
158  }
159  LogTrace("TrackingRegressionTest") << "=================================================";
160 
161  selTracks->shrink_to_fit();
162  selTrackExtras->shrink_to_fit();
163  selHits->shrink_to_fit();
164  if(BeforeOrAfter == 1){
165  rTracks_ = evt.put( selTracks, "beforeDAF" );
166  evt.put( selTrackExtras , "beforeDAF");
167  } else if (BeforeOrAfter == 2){
168  rTracks_ = evt.put( selTracks, "afterDAF" );
169  evt.put( selTrackExtras, "afterDAF" );
170  } else {
171  rTracks_ = evt.put( selTracks );
172  evt.put( selTrackExtras );
173  evt.put( selHits );
174  }
175 
176 
177  if(trajectoryInEvent_ && BeforeOrAfter == 0) {
178  selTrajectories->shrink_to_fit();
179  edm::OrphanHandle<std::vector<Trajectory> > rTrajs = evt.put(selTrajectories);
180 
181  // Now Create traj<->tracks association map
182  std::auto_ptr<TrajTrackAssociationCollection> trajTrackMap( new TrajTrackAssociationCollection(rTrajs, rTracks_) );
183  for ( std::map<unsigned int, unsigned int>::iterator i = tjTkMap.begin();
184  i != tjTkMap.end(); i++ ) {
185  edm::Ref<std::vector<Trajectory> > trajRef( rTrajs, (*i).first );
186  edm::Ref<reco::TrackCollection> tkRef( rTracks_, (*i).second );
187  trajTrackMap->insert( edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
188  edm::Ref<reco::TrackCollection>( rTracks_, (*i).second ) );
189  }
190  evt.put( trajTrackMap );
191  }
192 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
ConstRecHitPointer const & recHit() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
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
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
T z() const
Definition: PV3DBase.h:64
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:140
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...
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
Definition: TrackBase.h:447
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:168
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:179

Member Data Documentation

bool KfTrackProducerBase::useSplitting
private

Definition at line 42 of file KfTrackProducerBase.h.

Referenced by putInEvt().