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 &, 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 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(), 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::TrackBase::setHitPattern(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), edmStreamStallGrapher::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().

30 {
31 
34 
38  edm::Ref< std::vector<Trajectory> >::key_type iTjRef = 0;
39  std::map<unsigned int, unsigned int> tjTkMap;
40 
41  for(AlgoProductCollection::iterator i=algoResults.begin(); i!=algoResults.end();i++){
42  Trajectory * theTraj = (*i).first;
43  if(trajectoryInEvent_) {
44  selTrajectories->push_back(*theTraj);
45  iTjRef++;
46  }
47 
48 
49  reco::Track * theTrack = (*i).second.first;
50 
51  // Hits are going to be re-sorted along momentum few lines later.
52  // Therefore the direction stored in the TrackExtra
53  // has to be "alongMomentum" as well. Anyway, this direction can be differnt from the one of the orignal
54  // seed! The name seedDirection() for the Track's method (and the corresponding data member) is
55  // misleading and should be changed into something like "hitsDirection()". TO BE FIXED!
57 
58  LogDebug("TrackProducer") << "In KfTrackProducerBase::putInEvt - seedDir=" << seedDir;
59 
60  reco::Track t = * theTrack;
61  selTracks->push_back( t );
62  iTkRef++;
63 
64  // Store indices in local map (starts at 0)
65  if(trajectoryInEvent_) tjTkMap[iTjRef-1] = iTkRef-1;
66 
67  //sets the outermost and innermost TSOSs
68  TrajectoryStateOnSurface outertsos;
69  TrajectoryStateOnSurface innertsos;
70  unsigned int innerId, outerId;
71 
72  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
73  // This is consistent with innermost and outermost labels only for tracks from LHC collision
74  if (theTraj->direction() == alongMomentum) {
75  outertsos = theTraj->lastMeasurement().updatedState();
76  innertsos = theTraj->firstMeasurement().updatedState();
77  outerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
78  innerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
79  } else {
80  outertsos = theTraj->firstMeasurement().updatedState();
81  innertsos = theTraj->lastMeasurement().updatedState();
82  outerId = theTraj->firstMeasurement().recHit()->geographicalId().rawId();
83  innerId = theTraj->lastMeasurement().recHit()->geographicalId().rawId();
84  }
85  // ---
86  //build the TrackExtra
87  GlobalPoint v = outertsos.globalParameters().position();
88  GlobalVector p = outertsos.globalParameters().momentum();
89  math::XYZVector outmom( p.x(), p.y(), p.z() );
90  math::XYZPoint outpos( v.x(), v.y(), v.z() );
91  v = innertsos.globalParameters().position();
92  p = innertsos.globalParameters().momentum();
93  math::XYZVector inmom( p.x(), p.y(), p.z() );
94  math::XYZPoint inpos( v.x(), v.y(), v.z() );
95 
96  reco::TrackExtraRef teref= reco::TrackExtraRef ( rTrackExtras, idx ++ );
97  reco::Track & track = selTracks->back();
98  track.setExtra( teref );
99 
100  //======= I want to set the second hitPattern here =============
101  if (theSchool.isValid())
102  {
104  evt.getByToken(mteSrc_, mte);
105  // NavigationSetter setter( *theSchool );
106  setSecondHitPattern(theTraj,track,prop,&*mte);
107  }
108  //==============================================================
109 
110  selTrackExtras->push_back( reco::TrackExtra (outpos, outmom, true, inpos, inmom, true,
111  outertsos.curvilinearError(), outerId,
112  innertsos.curvilinearError(), innerId,
113  seedDir, theTraj->seedRef()));
114 
115 
116  reco::TrackExtra & tx = selTrackExtras->back();
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  Traj2TrackHits t2t(hitBuilder,false);
120  auto ih = selHits->size();
121  assert(ih==hidx);
122  t2t(*theTraj,*selHits,useSplitting);
123  auto ie = selHits->size();
124  size_t il = 0;
125  for (;ih<ie; ++ih) {
126  auto const & hit = (*selHits)[ih];
127  track.setHitPattern( hit, il ++ );
128  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
129  }
130 
131  /*
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  size_t ih = 0;
135  TrajectoryFitter::RecHitContainer transHits; theTraj->recHitsV(transHits, useSplitting);
136  if (theTraj->direction() == alongMomentum) {
137  for( TrajectoryFitter::RecHitContainer::const_iterator j = transHits.begin();
138  j != transHits.end(); j ++ ) {
139  if ((**j).hit()!=0){
140  TrackingRecHit * hit = (**j).hit()->clone();
141  track.setHitPattern( * hit, ih ++ );
142  selHits->push_back( hit );
143  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
144  }
145  }
146  }else{
147  for( TrajectoryFitter::RecHitContainer::const_iterator j = transHits.end()-1;
148  j != transHits.begin()-1; --j ) {
149  if ((**j).hit()!=0){
150  TrackingRecHit * hit = (**j).hit()->clone();
151  track.setHitPattern( * hit, ih ++ );
152  selHits->push_back( hit );
153  tx.add( TrackingRecHitRef( rHits, hidx ++ ) );
154  }
155  }
156  }
157  */
158 
159  // ----
160  tx.setResiduals(trajectoryToResiduals(*theTraj));
161 
162  delete theTrack;
163  delete theTraj;
164  }
165 
166  // Now we can re-set refs to hits, as they have already been cloned
167  if (rekeyClusterRefs_) {
169  for (TrackingRecHitCollection::iterator it = selHits->begin(), ed = selHits->end(); it != ed; ++it) {
170  refSetter.reKey(&*it);
171  }
172  }
173 
174  LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
175  LogTrace("TrackingRegressionTest") << "number of finalTracks: " << selTracks->size();
176  for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
177  LogTrace("TrackingRegressionTest") << "track's n valid and invalid hit, chi2, pt, eta : "
178  << it->found() << " , "
179  << it->lost() <<" , "
180  << it->normalizedChi2() << " , "
181  << it->pt() << " , "
182  << it->eta() ;
183  }
184  LogTrace("TrackingRegressionTest") << "=================================================";
185 
186 
187  rTracks_ = evt.put( selTracks );
188  evt.put( selTrackExtras );
189  evt.put( selHits );
190 
191  if(trajectoryInEvent_) {
192  edm::OrphanHandle<std::vector<Trajectory> > rTrajs = evt.put(selTrajectories);
193 
194  // Now Create traj<->tracks association map
195  std::auto_ptr<TrajTrackAssociationCollection> trajTrackMap( new TrajTrackAssociationCollection() );
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( trajTrackMap );
204  }
205 }
#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
PropagationDirection const & direction() const
Definition: Trajectory.cc:118
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:181
void setSecondHitPattern(Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk)
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:128
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:95
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...
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
void setResiduals(const TrackResiduals &r)
set the residuals
Definition: TrackExtra.h:131

Member Data Documentation

bool KfTrackProducerBase::useSplitting
private

Definition at line 36 of file KfTrackProducerBase.h.

Referenced by putInEvt().