CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void produce (edm::StreamID, edm::Event &ev, const edm::EventSetup &es) const override
 
 TrackListCombiner (const edm::ParameterSet &ps)
 
 ~TrackListCombiner ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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< TagstrackProducers
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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 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, and AlCaHLTBitMon_QueryRunRegistry::string.

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 ( )

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
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 36 of file TrackListCombiner.cc.

References ecalcalib_dqm_sourceclient-live_cfg::algo, edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, reco::TrackBase::detachedTripletStep, edm::Event::getByToken(), i, cmsHarvester::index, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), edm::Ref< C, T, F >::key(), HLT_25ns14e33_v1_cff::labels, LogTrace, reco::TrackBase::lowPtTripletStep, edm::ProductLabels::module, 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(), HLT_25ns14e33_v1_cff::trackProducer, 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(auto trackProducer = trackProducers.begin();
56  trackProducer++, i++)
57  {
59  switch(i)
60  {
61  case 1: algo = reco::TrackBase::lowPtTripletStep; break;
62  case 2: algo = reco::TrackBase::pixelPairStep; break;
63  case 3: algo = reco::TrackBase::detachedTripletStep; break;
64  default: algo = reco::TrackBase::undefAlgorithm;
65  }
66 
67  edm::Handle<vector<Trajectory> > theTrajectoryCollection;
69 
70  ev.getByToken(trackProducer->trajectory, theTrajectoryCollection);
71  ev.getByToken(trackProducer->assoMap, theAssoMap);
72 
73 #ifdef EDM_ML_DEBUG
75  labelsForToken(trackProducer->trajectory_, labels);
76 
77  LogTrace("MinBiasTracking")
78  << " [TrackListCombiner] " << labels.module
79  << " : " << theAssoMap->size();
80 #endif
81 
82 
83  // The track collection iterators
86  anAssociation = theAssoMap->begin();
87  lastAssociation = theAssoMap->end();
88 
89  // Build the map of correspondance between reco tracks and sim tracks
90  for ( ; anAssociation != lastAssociation; ++anAssociation )
91  {
92  edm::Ref<vector<Trajectory> > aTrajectoryRef = anAssociation->key;
93  reco::TrackRef aTrackRef = anAssociation->val;
94 
95  // A copy of the track
96  reco::Track aRecoTrack(*aTrackRef);
97 
98  // Set algorithm
99  aRecoTrack.setAlgorithm(algo);
100 
101  recoTracks->push_back(aRecoTrack);
102 
103  // A copy of the hits
104  unsigned nh = aRecoTrack.recHitsSize();
105  for(unsigned ih=0; ih<nh; ++ih)
106  {
107  TrackingRecHit *hit = aRecoTrack.recHit(ih)->clone();
108  recoHits->push_back(hit);
109  }
110 
111  // A copy of the trajectories
112  recoTrajectories->push_back(*aTrajectoryRef);
113 
114  }
115  }
116 
117  LogTrace("MinBiasTracking")
118  << " [TrackListCombiner] allTracks : " << recoTracks->size()
119  << "|" << recoTrajectories->size();
120 
121  // Save the tracking recHits
122  edm::OrphanHandle<TrackingRecHitCollection> theRecoHits = ev.put(recoHits);
123 
124  edm::RefProd<TrackingRecHitCollection> theRecoHitsProd(theRecoHits);
125  // Create the track extras and add the references to the rechits
126  unsigned hits = 0;
127  unsigned nTracks = recoTracks->size();
128  recoTrackExtras->reserve(nTracks); // To save some time at push_back
129  for(unsigned index = 0; index < nTracks; ++index )
130  {
131  reco::Track& aTrack = recoTracks->at(index);
132  reco::TrackExtra aTrackExtra(aTrack.outerPosition(),
133  aTrack.outerMomentum(),
134  aTrack.outerOk(),
135  aTrack.innerPosition(),
136  aTrack.innerMomentum(),
137  aTrack.innerOk(),
138  aTrack.outerStateCovariance(),
139  aTrack.outerDetId(),
140  aTrack.innerStateCovariance(),
141  aTrack.innerDetId(),
142  aTrack.seedDirection(),
143  aTrack.seedRef());
144 
145  unsigned nHits = aTrack.recHitsSize();
146  aTrackExtra.setHits(theRecoHitsProd,hits,nHits);
147  hits +=nHits;
148 
149  recoTrackExtras->push_back(aTrackExtra);
150  }
151 
152  // Save the track extras
154  ev.put(recoTrackExtras);
155 
156  // Add the reference to the track extra in the tracks
157  for(unsigned index = 0; index<nTracks; ++index)
158  {
159  const reco::TrackExtraRef theTrackExtraRef(theRecoTrackExtras,index);
160  (recoTracks->at(index)).setExtra(theTrackExtraRef);
161  }
162 
163  // Save the tracks
164  edm::OrphanHandle<reco::TrackCollection> theRecoTracks = ev.put(recoTracks);
165 
166  // Save the trajectories
167  edm::OrphanHandle<vector<Trajectory> > theRecoTrajectories =
168  ev.put(recoTrajectories);
169 
170  // Create and set the trajectory/track association map
171  for(unsigned index = 0; index<nTracks; ++index)
172  {
173  edm::Ref<vector<Trajectory> > trajRef( theRecoTrajectories, index );
174  edm::Ref<reco::TrackCollection> tkRef( theRecoTracks, index );
175  recoTrajTrackMap->insert(trajRef,tkRef);
176  }
177 
178  // Save the association map
179  ev.put(recoTrajTrackMap);
180 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:50
key_type key() const
Accessor for product key.
Definition: Ref.h:264
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
TrackAlgorithm
track algorithm
Definition: TrackBase.h:99
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:75
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:94
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > > TrajTrackAssociationCollection
char const * module
Definition: ProductLabels.h:5
#define LogTrace(id)
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
edm::RefToBase< TrajectorySeed > seedRef() const
Definition: Track.h:213
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:45
std::vector< Tags > trackProducers
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:80
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:204
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:99

Member Data Documentation

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

Definition at line 28 of file TrackListCombiner.h.