CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
TrackListCombiner Class Reference

#include <TrackListCombiner.h>

Inheritance diagram for TrackListCombiner:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  Tags
 

Public Member Functions

void produce (edm::StreamID, edm::Event &ev, const edm::EventSetup &es) const override
 
 TrackListCombiner (const edm::ParameterSet &ps)
 
 ~TrackListCombiner () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::vector< TagstrackProducers
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
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 14 of file TrackListCombiner.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file TrackListCombiner.cc.

References edm::ParameterSet::getParameter(), parseEventContent::prod, AlCaHLTBitMon_QueryRunRegistry::string, and preDuplicateMergingDisplacedTracks_cfi::trackProducers.

17 {
18  for(const std::string& prod: ps.getParameter<vector<string> >("trackProducers")) {
19  trackProducers.emplace_back(consumes<vector<Trajectory>>(prod),
20  consumes<TrajTrackAssociationCollection>(prod));
21  }
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
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< Tags > trackProducers
TrackListCombiner::~TrackListCombiner ( )
override

Definition at line 31 of file TrackListCombiner.cc.

32 {
33 }

Member Function Documentation

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

Definition at line 36 of file TrackListCombiner.cc.

References patPFMETCorrections_cff::algo, edm::AssociationMap< Tag >::begin(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, reco::TrackBase::detachedTripletStep, edm::AssociationMap< Tag >::end(), edm::Event::getByToken(), hfClusterShapes_cfi::hits, mps_fire::i, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), edm::Ref< C, T, F >::key(), tablePrinter::labels, LogTrace, reco::TrackBase::lowPtTripletStep, edm::ProductLabels::module, eostools::move(), nTracks(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), reco::TrackBase::pixelPairStep, edm::Event::put(), reco::Track::recHit(), reco::Track::recHitsSize(), reco::Track::seedDirection(), reco::Track::seedRef(), reco::TrackBase::setAlgorithm(), edm::AssociationMap< Tag >::size(), findElectronsInSiStrips_cfi::trackProducer, preDuplicateMergingDisplacedTracks_cfi::trackProducers, and reco::TrackBase::undefAlgorithm.

37 {
38  auto recoTracks = std::make_unique<reco::TrackCollection>();
39  auto recoTrackExtras = std::make_unique<reco::TrackExtraCollection>();
40  auto recoHits = std::make_unique<TrackingRecHitCollection>();
41  auto recoTrajectories = std::make_unique<vector<Trajectory>>();
42  auto recoTrajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
43 
44  LogTrace("MinBiasTracking")
45  << "[TrackListCombiner]";
46 
47  // Go through all track producers
48  int i = 1;
49  for(auto trackProducer = trackProducers.begin();
51  trackProducer++, i++)
52  {
54  switch(i)
55  {
56  case 1: algo = reco::TrackBase::lowPtTripletStep; break;
57  case 2: algo = reco::TrackBase::pixelPairStep; break;
58  case 3: algo = reco::TrackBase::detachedTripletStep; break;
59  default: algo = reco::TrackBase::undefAlgorithm;
60  }
61 
62  edm::Handle<vector<Trajectory> > theTrajectoryCollection;
64 
65  ev.getByToken(trackProducer->trajectory, theTrajectoryCollection);
66  ev.getByToken(trackProducer->assoMap, theAssoMap);
67 
68 #ifdef EDM_ML_DEBUG
70  labelsForToken(trackProducer->trajectory, labels);
71 
72  LogTrace("MinBiasTracking")
73  << " [TrackListCombiner] " << labels.module
74  << " : " << theAssoMap->size();
75 #endif
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(std::move(recoHits));
118 
119  edm::RefProd<TrackingRecHitCollection> theRecoHitsProd(theRecoHits);
120  // Create the track extras and add the references to the rechits
121  unsigned hits = 0;
122  unsigned nTracks = recoTracks->size();
123  recoTrackExtras->reserve(nTracks); // To save some time at push_back
124  for(unsigned index = 0; index < nTracks; ++index )
125  {
126  reco::Track& aTrack = recoTracks->at(index);
127  reco::TrackExtra aTrackExtra(aTrack.outerPosition(),
128  aTrack.outerMomentum(),
129  aTrack.outerOk(),
130  aTrack.innerPosition(),
131  aTrack.innerMomentum(),
132  aTrack.innerOk(),
133  aTrack.outerStateCovariance(),
134  aTrack.outerDetId(),
135  aTrack.innerStateCovariance(),
136  aTrack.innerDetId(),
137  aTrack.seedDirection(),
138  aTrack.seedRef());
139 
140  unsigned nHits = aTrack.recHitsSize();
141  aTrackExtra.setHits(theRecoHitsProd,hits,nHits);
142  hits +=nHits;
143 
144  recoTrackExtras->push_back(aTrackExtra);
145  }
146 
147  // Save the track extras
149  ev.put(std::move(recoTrackExtras));
150 
151  // Add the reference to the track extra in the tracks
152  for(unsigned index = 0; index<nTracks; ++index)
153  {
154  const reco::TrackExtraRef theTrackExtraRef(theRecoTrackExtras,index);
155  (recoTracks->at(index)).setExtra(theTrackExtraRef);
156  }
157 
158  // Save the tracks
159  edm::OrphanHandle<reco::TrackCollection> theRecoTracks = ev.put(std::move(recoTracks));
160 
161  // Save the trajectories
162  edm::OrphanHandle<vector<Trajectory> > theRecoTrajectories =
163  ev.put(std::move(recoTrajectories));
164 
165  // Create and set the trajectory/track association map
166  for(unsigned index = 0; index<nTracks; ++index)
167  {
168  edm::Ref<vector<Trajectory> > trajRef( theRecoTrajectories, index );
169  edm::Ref<reco::TrackCollection> tkRef( theRecoTracks, index );
170  recoTrajTrackMap->insert(trajRef,tkRef);
171  }
172 
173  // Save the association map
174  ev.put(std::move(recoTrajTrackMap));
175 }
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:215
const unsigned int nTracks(const reco::Vertex &sv)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:121
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:52
key_type key() const
Accessor for product key.
Definition: Ref.h:265
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:67
TrackAlgorithm
track algorithm
Definition: TrackBase.h:99
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:57
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:77
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:96
char const * module
Definition: ProductLabels.h:5
#define LogTrace(id)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:72
size_type size() const
map size
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:47
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:206
std::vector< Tags > trackProducers
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:82
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:62
const_iterator begin() const
first iterator over the map (read only)
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:101
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 28 of file TrackListCombiner.h.