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 > 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 &)
 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 
)
virtual

Put produced collections in the event.

Definition at line 19 of file KfTrackProducerBase.cc.

References reco::TrackExtraBase::add(), alongMomentum, TrackProducerBase< reco::Track >::clusterRemovalInfo_, TrajectoryStateOnSurface::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TrajectoryStateOnSurface::globalParameters(), i, customizeTrackingMonitorSeedNumber::idx, edm::ESHandleBase::isValid(), j, Trajectory::lastMeasurement(), LogDebug, LogTrace, GlobalTrajectoryParameters::momentum(), TrackProducerBase< reco::Track >::mteSrc_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), TrajectoryMeasurement::recHit(), Trajectory::recHits(), ClusterRemovalRefSetter::reKey(), TrackProducerBase< reco::Track >::rekeyClusterRefs_, TrackProducerBase< reco::Track >::rTracks_, Trajectory::seedRef(), reco::Track::setExtra(), reco::TrackBase::setHitPattern(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), lumiQTWidget::t, 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(), and TrackProducer::produce().

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

Member Data Documentation

bool KfTrackProducerBase::useSplitting
private

Definition at line 36 of file KfTrackProducerBase.h.

Referenced by putInEvt().