CMS 3D CMS Logo

TrackListCombiner.cc
Go to the documentation of this file.
1 #include "TrackListCombiner.h"
2 
6 
8 
12 
13 using namespace std;
14 
15 /*****************************************************************************/
17  for (const std::string& prod : ps.getParameter<vector<string>>("trackProducers")) {
18  trackProducers.emplace_back(consumes<vector<Trajectory>>(prod), consumes<TrajTrackAssociationCollection>(prod));
19  }
20 
21  produces<reco::TrackCollection>();
22  produces<reco::TrackExtraCollection>();
23  produces<TrackingRecHitCollection>();
24  produces<vector<Trajectory>>();
25  produces<TrajTrackAssociationCollection>();
26 }
27 
28 /*****************************************************************************/
30 
31 /*****************************************************************************/
33  auto recoTracks = std::make_unique<reco::TrackCollection>();
34  auto recoTrackExtras = std::make_unique<reco::TrackExtraCollection>();
35  auto recoHits = std::make_unique<TrackingRecHitCollection>();
36  auto recoTrajectories = std::make_unique<vector<Trajectory>>();
37  auto recoTrajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
38 
39  LogTrace("MinBiasTracking") << "[TrackListCombiner]";
40 
41  // Go through all track producers
42  int i = 1;
43  for (auto trackProducer = trackProducers.begin(); trackProducer != trackProducers.end(); trackProducer++, i++) {
45  switch (i) {
46  case 1:
48  break;
49  case 2:
51  break;
52  case 3:
54  break;
55  default:
57  }
58 
59  edm::Handle<vector<Trajectory>> theTrajectoryCollection;
61 
62  ev.getByToken(trackProducer->trajectory, theTrajectoryCollection);
63  ev.getByToken(trackProducer->assoMap, theAssoMap);
64 
65 #ifdef EDM_ML_DEBUG
67  labelsForToken(trackProducer->trajectory, labels);
68 
69  LogTrace("MinBiasTracking") << " [TrackListCombiner] " << labels.module << " : " << theAssoMap->size();
70 #endif
71 
72  // The track collection iterators
75  anAssociation = theAssoMap->begin();
76  lastAssociation = theAssoMap->end();
77 
78  // Build the map of correspondance between reco tracks and sim tracks
79  for (; anAssociation != lastAssociation; ++anAssociation) {
80  edm::Ref<vector<Trajectory>> aTrajectoryRef = anAssociation->key;
81  reco::TrackRef aTrackRef = anAssociation->val;
82 
83  // A copy of the track
84  reco::Track aRecoTrack(*aTrackRef);
85 
86  // Set algorithm
87  aRecoTrack.setAlgorithm(algo);
88 
89  recoTracks->push_back(aRecoTrack);
90 
91  // A copy of the hits
92  unsigned nh = aRecoTrack.recHitsSize();
93  for (unsigned ih = 0; ih < nh; ++ih) {
94  TrackingRecHit* hit = aRecoTrack.recHit(ih)->clone();
95  recoHits->push_back(hit);
96  }
97 
98  // A copy of the trajectories
99  recoTrajectories->push_back(*aTrajectoryRef);
100  }
101  }
102 
103  LogTrace("MinBiasTracking") << " [TrackListCombiner] allTracks : " << recoTracks->size() << "|"
104  << recoTrajectories->size();
105 
106  // Save the tracking recHits
107  edm::OrphanHandle<TrackingRecHitCollection> theRecoHits = ev.put(std::move(recoHits));
108 
109  edm::RefProd<TrackingRecHitCollection> theRecoHitsProd(theRecoHits);
110  // Create the track extras and add the references to the rechits
111  unsigned hits = 0;
112  unsigned nTracks = recoTracks->size();
113  recoTrackExtras->reserve(nTracks); // To save some time at push_back
114  for (unsigned index = 0; index < nTracks; ++index) {
115  reco::Track& aTrack = recoTracks->at(index);
116  reco::TrackExtra aTrackExtra(aTrack.outerPosition(),
117  aTrack.outerMomentum(),
118  aTrack.outerOk(),
119  aTrack.innerPosition(),
120  aTrack.innerMomentum(),
121  aTrack.innerOk(),
122  aTrack.outerStateCovariance(),
123  aTrack.outerDetId(),
124  aTrack.innerStateCovariance(),
125  aTrack.innerDetId(),
126  aTrack.seedDirection(),
127  aTrack.seedRef());
128 
129  unsigned nHits = aTrack.recHitsSize();
130  aTrackExtra.setHits(theRecoHitsProd, hits, nHits);
131  hits += nHits;
132 
133  recoTrackExtras->push_back(aTrackExtra);
134  }
135 
136  // Save the track extras
137  edm::OrphanHandle<reco::TrackExtraCollection> theRecoTrackExtras = ev.put(std::move(recoTrackExtras));
138 
139  // Add the reference to the track extra in the tracks
140  for (unsigned index = 0; index < nTracks; ++index) {
141  const reco::TrackExtraRef theTrackExtraRef(theRecoTrackExtras, index);
142  (recoTracks->at(index)).setExtra(theTrackExtraRef);
143  }
144 
145  // Save the tracks
146  edm::OrphanHandle<reco::TrackCollection> theRecoTracks = ev.put(std::move(recoTracks));
147 
148  // Save the trajectories
149  edm::OrphanHandle<vector<Trajectory>> theRecoTrajectories = ev.put(std::move(recoTrajectories));
150 
151  // Create and set the trajectory/track association map
152  for (unsigned index = 0; index < nTracks; ++index) {
153  edm::Ref<vector<Trajectory>> trajRef(theRecoTrajectories, index);
154  edm::Ref<reco::TrackCollection> tkRef(theRecoTracks, index);
155  recoTrajTrackMap->insert(trajRef, tkRef);
156  }
157 
158  // Save the association map
159  ev.put(std::move(recoTrajTrackMap));
160 }
reco::Track::outerPosition
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
reco::Track::outerMomentum
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
edm::RefProd< TrackingRecHitCollection >
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::StreamID
Definition: StreamID.h:30
TrackExtra.h
reco::Track::outerStateCovariance
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
reco::Track::outerDetId
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
L1TCSCTF_cfi.trackProducer
trackProducer
Run2: False; Run1: True.
Definition: L1TCSCTF_cfi.py:12
reco::TrackBase::TrackAlgorithm
TrackAlgorithm
track algorithm
Definition: TrackBase.h:89
reco::TrackBase::lowPtTripletStep
Definition: TrackBase.h:95
reco::Track::outerOk
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
BeamSpotPI::nTracks
Definition: BeamSpotPayloadInspectorHelper.h:42
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref
Definition: AssociativeIterator.h:58
reco::Track::innerStateCovariance
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
reco::Track::innerOk
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
reco::TrackExtra
Definition: TrackExtra.h:26
cmsdt::algo
algo
Definition: constants.h:171
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
reco::Track::innerMomentum
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
reco::Track::recHitsSize
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits).
Definition: Track.h:97
Track.h
TrackFwd.h
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
reco::Track
Definition: Track.h:27
TrackListCombiner.h
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
reco::Track::seedDirection
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
Definition: Track.h:148
edm::ParameterSet
Definition: ParameterSet.h:47
edm::AssociationMap::size
size_type size() const
map size
Definition: AssociationMap.h:162
Event.h
reco::TrackBase::detachedTripletStep
Definition: TrackBase.h:97
reco::TrackBase::undefAlgorithm
Definition: TrackBase.h:90
reco::Track::innerPosition
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
reco::Track::innerDetId
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
edm::EventSetup
Definition: EventSetup.h:58
TrackListCombiner::TrackListCombiner
TrackListCombiner(const edm::ParameterSet &ps)
Definition: TrackListCombiner.cc:16
reco::Track::recHit
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:94
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackListCombiner::~TrackListCombiner
~TrackListCombiner() override
Definition: TrackListCombiner.cc:29
reco::TrackBase::pixelPairStep
Definition: TrackBase.h:96
reco::TrackBase::setAlgorithm
void setAlgorithm(const TrackAlgorithm a)
Track algorithm.
Definition: TrackBase.h:832
TrackingRecHit
Definition: TrackingRecHit.h:21
cms::cuda::nh
uint32_t nh
Definition: HistoContainer.h:11
HLT_FULL_cff.trackProducers
trackProducers
Definition: HLT_FULL_cff.py:87877
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
reco::Track::seedRef
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:155
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
edm::AssociationMap::begin
const_iterator begin() const
first iterator over the map (read only)
Definition: AssociationMap.h:169
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
TrackListCombiner::produce
void produce(edm::StreamID, edm::Event &ev, const edm::EventSetup &es) const override
Definition: TrackListCombiner.cc:32
ParameterSet.h
edm::Event
Definition: Event.h:73
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::ProductLabels
Definition: ProductLabels.h:4