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 > 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< 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 >
using AlgoProductCollection = typename Base::AlgoProductCollection
 
using Base = AlgoProductTraits< reco::Track >
 
using TrackCollection = typename Base::TrackCollection
 
- Public Types inherited from AlgoProductTraits< reco::Track >
using AlgoProductCollection = std::vector< AlgoProduct >
 
using TrackCollection = std::vector< reco::Track >
 
- 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::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(), i, customizeTrackingMonitorSeedNumber::idx, edm::ESHandleBase::isValid(), LogDebug, LogTrace, GlobalTrajectoryParameters::momentum(), eostools::move(), TrackProducerBase< reco::Track >::mteSrc_, AlCaHLTBitMon_ParallelJobs::p, GlobalTrajectoryParameters::position(), edm::Event::put(), ClusterRemovalRefSetter::reKey(), TrackProducerBase< reco::Track >::rekeyClusterRefs_, TrackProducerBase< reco::Track >::rTracks_, reco::Track::setExtra(), reco::TrackExtraBase::setHits(), reco::TrackExtra::setResiduals(), TrackProducerBase< reco::Track >::setSecondHitPattern(), TrackProducerBase< reco::Track >::theSchool, TrackProducerBase< reco::Track >::trajectoryInEvent_, trajectoryToResiduals(), 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().

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 
125  reco::TrackExtra & tx = selTrackExtras->back();
126  // --- NOTA BENE: the convention is to sort hits and measurements "along the momentum".
127  // This is consistent with innermost and outermost labels only for tracks from LHC collisions
128  Traj2TrackHits t2t(hitBuilder,false);
129  auto ih = selHits->size();
130  t2t(*theTraj,*selHits,useSplitting);
131  auto ie = selHits->size();
132  tx.setHits(rHits,ih,ie-ih);
133  for (;ih<ie; ++ih) {
134  auto const & hit = (*selHits)[ih];
135  track.appendHitPattern(hit, *ttopo);
136  }
137 
138  // ----
139  tx.setResiduals(trajectoryToResiduals(*theTraj));
140 
141  delete theTraj;
142  }
143 
144  // Now we can re-set refs to hits, as they have already been cloned
145  if (rekeyClusterRefs_) {
147  for (TrackingRecHitCollection::iterator it = selHits->begin(), ed = selHits->end(); it != ed; ++it) {
148  refSetter.reKey(&*it);
149  }
150  }
151 
152  LogTrace("TrackingRegressionTest") << "========== TrackProducer Info ===================";
153  LogTrace("TrackingRegressionTest") << "number of finalTracks: " << selTracks->size();
154  for (reco::TrackCollection::const_iterator it = selTracks->begin(); it != selTracks->end(); it++) {
155  LogTrace("TrackingRegressionTest") << "track's n valid and invalid hit, chi2, pt, eta : "
156  << it->found() << " , "
157  << it->lost() <<" , "
158  << it->normalizedChi2() << " , "
159  << it->pt() << " , "
160  << it->eta() ;
161  }
162  LogTrace("TrackingRegressionTest") << "=================================================";
163 
164  selTracks->shrink_to_fit();
165  selTrackExtras->shrink_to_fit();
166  selHits->shrink_to_fit();
167  indecesInput->shrink_to_fit();
168  if(BeforeOrAfter == 1){
169  rTracks_ = evt.put(std::move(selTracks), "beforeDAF" );
170  evt.put(std::move(selTrackExtras), "beforeDAF");
171  evt.put(std::move(indecesInput), "beforeDAF");
172  } else if (BeforeOrAfter == 2){
173  rTracks_ = evt.put(std::move(selTracks), "afterDAF" );
174  evt.put( std::move(selTrackExtras), "afterDAF" );
175  evt.put(std::move(indecesInput), "afterDAF");
176  } else {
177  rTracks_ = evt.put(std::move(selTracks) );
178  evt.put(std::move(selTrackExtras) );
179  evt.put(std::move(selHits) );
180  evt.put(std::move(indecesInput));
181  }
182 
183 
184  if(trajectoryInEvent_ && BeforeOrAfter == 0) {
185  selTrajectories->shrink_to_fit();
186  edm::OrphanHandle<std::vector<Trajectory> > rTrajs = evt.put(std::move(selTrajectories));
187 
188  // Now Create traj<->tracks association map
189  std::unique_ptr<TrajTrackAssociationCollection> trajTrackMap( new TrajTrackAssociationCollection(rTrajs, rTracks_) );
190  for ( std::map<unsigned int, unsigned int>::iterator i = tjTkMap.begin();
191  i != tjTkMap.end(); i++ ) {
192  edm::Ref<std::vector<Trajectory> > trajRef( rTrajs, (*i).first );
193  edm::Ref<reco::TrackCollection> tkRef( rTracks_, (*i).second );
194  trajTrackMap->insert( edm::Ref<std::vector<Trajectory> >( rTrajs, (*i).first ),
195  edm::Ref<reco::TrackCollection>( rTracks_, (*i).second ) );
196  }
197  evt.put( std::move(trajTrackMap) );
198  }
199 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
T z() const
Definition: PV3DBase.h:64
def move
Definition: eostools.py:510
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
#define LogTrace(id)
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
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
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:455
edm::ESHandle< NavigationSchool > theSchool
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 44 of file KfTrackProducerBase.h.

Referenced by putInEvt().