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
TrackListCombiner Class Reference

#include <TrackListCombiner.h>

Inheritance diagram for TrackListCombiner:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 TrackListCombiner (const edm::ParameterSet &ps)
 
 ~TrackListCombiner ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::vector< std::string > trackProducers
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 11 of file TrackListCombiner.h.

Constructor & Destructor Documentation

TrackListCombiner::TrackListCombiner ( const edm::ParameterSet ps)
explicit

Definition at line 19 of file TrackListCombiner.cc.

References edm::ParameterSet::getParameter().

20 {
21  trackProducers = ps.getParameter<vector<string> >("trackProducers");
22 
23  produces<reco::TrackCollection>();
24  produces<reco::TrackExtraCollection>();
25  produces<TrackingRecHitCollection>();
26  produces<vector<Trajectory> >();
27  produces<TrajTrackAssociationCollection>();
28 }
T getParameter(std::string const &) const
std::vector< std::string > trackProducers
TrackListCombiner::~TrackListCombiner ( )

Definition at line 31 of file TrackListCombiner.cc.

32 {
33 }

Member Function Documentation

void TrackListCombiner::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 36 of file TrackListCombiner.cc.

References edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, edm::Event::getByLabel(), i, cmsHarvester::index, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), reco::TrackBase::iter1, reco::TrackBase::iter2, reco::TrackBase::iter3, edm::Ref< C, T, F >::key(), LogTrace, reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), edm::Event::put(), reco::Track::recHit(), reco::Track::recHitsSize(), reco::Track::seedDirection(), reco::Track::seedRef(), reco::TrackBase::setAlgorithm(), and reco::TrackBase::undefAlgorithm.

37 {
38  auto_ptr<reco::TrackCollection> recoTracks
40  auto_ptr<reco::TrackExtraCollection> recoTrackExtras
42  auto_ptr<TrackingRecHitCollection> recoHits
44  auto_ptr<vector<Trajectory> > recoTrajectories
45  (new vector<Trajectory>);
46  auto_ptr<TrajTrackAssociationCollection> recoTrajTrackMap
48 
49  LogTrace("MinBiasTracking")
50  << "[TrackListCombiner]";
51 
52  // Go through all track producers
53  int i = 1;
54  for(vector<string>::iterator trackProducer = trackProducers.begin();
55  trackProducer!= trackProducers.end();
56  trackProducer++, i++)
57  {
59  switch(i)
60  {
61  case 1: algo = reco::TrackBase::iter1; break;
62  case 2: algo = reco::TrackBase::iter2; break;
63  case 3: algo = reco::TrackBase::iter3; break;
64  default: algo = reco::TrackBase::undefAlgorithm;
65  }
66 
67  edm::Handle<vector<Trajectory> > theTrajectoryCollection;
69 
70  ev.getByLabel(*trackProducer, theTrajectoryCollection);
71  ev.getByLabel(*trackProducer, theAssoMap);
72 
73  LogTrace("MinBiasTracking")
74  << " [TrackListCombiner] " << *trackProducer
75  << " : " << theAssoMap->size();
76 
77 
78  // The track collection iterators
81  anAssociation = theAssoMap->begin();
82  lastAssociation = theAssoMap->end();
83 
84  // Build the map of correspondance between reco tracks and sim tracks
85  for ( ; anAssociation != lastAssociation; ++anAssociation )
86  {
87  edm::Ref<vector<Trajectory> > aTrajectoryRef = anAssociation->key;
88  reco::TrackRef aTrackRef = anAssociation->val;
89 
90  // A copy of the track
91  reco::Track aRecoTrack(*aTrackRef);
92 
93  // Set algorithm
94  aRecoTrack.setAlgorithm(algo);
95 
96  recoTracks->push_back(aRecoTrack);
97 
98  // A copy of the hits
99  unsigned nh = aRecoTrack.recHitsSize();
100  for(unsigned ih=0; ih<nh; ++ih)
101  {
102  TrackingRecHit *hit = aRecoTrack.recHit(ih)->clone();
103  recoHits->push_back(hit);
104  }
105 
106  // A copy of the trajectories
107  recoTrajectories->push_back(*aTrajectoryRef);
108 
109  }
110  }
111 
112  LogTrace("MinBiasTracking")
113  << " [TrackListCombiner] allTracks : " << recoTracks->size()
114  << "|" << recoTrajectories->size();
115 
116  // Save the tracking recHits
117  edm::OrphanHandle<TrackingRecHitCollection> theRecoHits = ev.put(recoHits);
118 
119  // Create the track extras and add the references to the rechits
120  unsigned hits = 0;
121  unsigned nTracks = recoTracks->size();
122  recoTrackExtras->reserve(nTracks); // To save some time at push_back
123  for(unsigned index = 0; index < nTracks; ++index )
124  {
125  reco::Track& aTrack = recoTracks->at(index);
126  reco::TrackExtra aTrackExtra(aTrack.outerPosition(),
127  aTrack.outerMomentum(),
128  aTrack.outerOk(),
129  aTrack.innerPosition(),
130  aTrack.innerMomentum(),
131  aTrack.innerOk(),
132  aTrack.outerStateCovariance(),
133  aTrack.outerDetId(),
134  aTrack.innerStateCovariance(),
135  aTrack.innerDetId(),
136  aTrack.seedDirection(),
137  aTrack.seedRef());
138 
139  unsigned nHits = aTrack.recHitsSize();
140  for ( unsigned int ih=0; ih<nHits; ++ih)
141  aTrackExtra.add(TrackingRecHitRef(theRecoHits,hits++));
142  recoTrackExtras->push_back(aTrackExtra);
143  }
144 
145  // Save the track extras
147  ev.put(recoTrackExtras);
148 
149  // Add the reference to the track extra in the tracks
150  for(unsigned index = 0; index<nTracks; ++index)
151  {
152  const reco::TrackExtraRef theTrackExtraRef(theRecoTrackExtras,index);
153  (recoTracks->at(index)).setExtra(theTrackExtraRef);
154  }
155 
156  // Save the tracks
157  edm::OrphanHandle<reco::TrackCollection> theRecoTracks = ev.put(recoTracks);
158 
159  // Save the trajectories
160  edm::OrphanHandle<vector<Trajectory> > theRecoTrajectories =
161  ev.put(recoTrajectories);
162 
163  // Create and set the trajectory/track association map
164  for(unsigned index = 0; index<nTracks; ++index)
165  {
166  edm::Ref<vector<Trajectory> > trajRef( theRecoTrajectories, index );
167  edm::Ref<reco::TrackCollection> tkRef( theRecoTracks, index );
168  recoTrajTrackMap->insert(trajRef,tkRef);
169  }
170 
171  // Save the association map
172  ev.put(recoTrajTrackMap);
173 }
int i
Definition: DBlmapReader.cc:9
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:69
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:40
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:47
TrackAlgorithm
track algorithm
Definition: TrackBase.h:80
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:42
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< std::string > trackProducers
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:51
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:59
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
edm::RefToBase< TrajectorySeed > seedRef() const
Definition: Track.h:112
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:49
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:38
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:53
key_type key() const
Accessor for product key.
Definition: Ref.h:266
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:45
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:105
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:61

Member Data Documentation

std::vector<std::string> TrackListCombiner::trackProducers
private

Definition at line 19 of file TrackListCombiner.h.