22 double R2SMatchedSimRatio,
23 double R2SMatchedRecoRatio,
24 double S2RMatchedSimRatio,
25 double S2RMatchedRecoRatio,
30 : productGetter_(productGetter),
31 R2SMatchedSimRatio_(R2SMatchedSimRatio),
32 R2SMatchedRecoRatio_(R2SMatchedRecoRatio),
33 S2RMatchedSimRatio_(S2RMatchedSimRatio),
34 S2RMatchedRecoRatio_(S2RMatchedRecoRatio),
36 trackQuality_(trackQuality),
37 trackRecoToSimAssociation_(trackRecoToSimAssociation),
38 trackSimToRecoAssociation_(trackSimToRecoAssociation) {}
48 std::map<TrackingVertexRef, std::pair<double, std::size_t>>
matches;
50 LogDebug(
"VertexAssociation") <<
"reco::VertexCollection size = " << recoVertexes->size()
51 <<
" ; TrackingVertexCollection size = " << trackingVertexes->size() << std::endl;
54 for (std::size_t recoIndex = 0; recoIndex < recoVertexes->size(); ++recoIndex) {
59 double recoDaughterWeight = 0.;
71 std::vector<std::pair<TrackingParticleRef, double>>
associations = (*trackRecoToSimAssociation_)[*recoDaughter];
74 for (std::vector<std::pair<TrackingParticleRef, double>>::const_iterator
association = associations.begin();
81 matches[trackingVertex].first += recoVertex->
trackWeight(*recoDaughter);
82 matches[trackingVertex].second++;
86 recoDaughterWeight += recoVertex->
trackWeight(*recoDaughter);
89 std::size_t assoIndex = 0;
93 match != matches.end();
97 double matchedDaughterWeight =
match->second.first;
98 std::size_t matchedDaughterCounter =
match->second.second;
101 std::size_t simDaughterCounter = 0;
104 simDaughter != trackingVertex->daughterTracks_end();
107 simDaughterCounter++;
110 if (simDaughterCounter < matchedDaughterCounter)
111 simDaughterCounter = matchedDaughterCounter;
117 double quality = (double)matchedDaughterWeight / recoDaughterWeight;
123 outputCollection.
insert(recoVertex, std::make_pair(trackingVertex, quality));
125 LogTrace(
"VertexAssociation") <<
"R2S: INDEX " << assoIndex <<
" ; SimDaughterCounter = " << simDaughterCounter
126 <<
" ; RecoDaughterWeight = " << recoDaughterWeight
127 <<
" ; MatchedDaughterCounter = " << matchedDaughterCounter
128 <<
" ; MatchedDaughterWeight = " << matchedDaughterWeight
135 LogTrace(
"VertexAssociation") <<
"\nRecoToSim OUTPUT COLLECTION: outputCollection.size() = " 136 << outputCollection.
size() << std::endl;
138 return outputCollection;
147 std::map<std::size_t, std::pair<double, std::size_t>>
matches;
150 for (std::size_t simIndex = 0; simIndex < trackingVertexes->size(); ++simIndex) {
155 std::size_t simDaughterCounter = 0;
159 simDaughter != trackingVertex->daughterTracks_end();
167 std::vector<std::pair<reco::TrackBaseRef, double>>
associations = (*trackSimToRecoAssociation_)[*simDaughter];
170 for (std::vector<std::pair<reco::TrackBaseRef, double>>::const_iterator
association = associations.begin();
175 for (std::size_t recoIndex = 0; recoIndex < recoVertexes->size(); ++recoIndex) {
182 if (recoDaughter->id() == recoTrack.
id() && recoDaughter->key() == recoTrack.
key()) {
183 matches[recoIndex].first += recoVertex->
trackWeight(*recoDaughter);
184 matches[recoIndex].second++;
191 simDaughterCounter++;
194 std::size_t assoIndex = 0;
197 for (
std::map<std::size_t, std::pair<double, std::size_t>>::const_iterator
match = matches.begin();
198 match != matches.end();
202 double matchedDaughterWeight =
match->second.first;
203 std::size_t matchedDaughterCounter =
match->second.second;
205 double recoDaughterWeight = 0.;
213 recoDaughterWeight += recoVertex->
trackWeight(*recoDaughter);
216 if (recoDaughterWeight < matchedDaughterWeight)
217 recoDaughterWeight = matchedDaughterWeight;
223 double quality = (double)matchedDaughterCounter / simDaughterCounter;
229 outputCollection.
insert(trackingVertex, std::make_pair(recoVertex, quality));
231 LogTrace(
"VertexAssociation") <<
"R2S: INDEX " << assoIndex <<
" ; SimDaughterCounter = " << simDaughterCounter
232 <<
" ; RecoDaughterWeight = " << recoDaughterWeight
233 <<
" ; MatchedDaughterCounter = " << matchedDaughterCounter
234 <<
" ; MatchedDaughterWeight = " << matchedDaughterWeight
241 LogTrace(
"VertexAssociation") <<
"SimToReco OUTPUT COLLECTION: outputCollection.size() = " << outputCollection.
size()
244 return outputCollection;
const TrackingParticleSelector * selector_
trackRef_iterator tracks_end() const
last iterator over tracks
TrackQuality
track quality
const double R2SMatchedSimRatio_
EDProductGetter const * productGetter(std::atomic< void const * > const &iCache)
const double S2RMatchedSimRatio_
size_type numberOfAssociations(const key_type &k) const
number of associations to a key
const double S2RMatchedRecoRatio_
const reco::RecoToSimCollection * trackRecoToSimAssociation_
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
const reco::TrackBase::TrackQuality trackQuality_
size_type size() const
map size
void insert(const key_type &k, const data_type &v)
insert an association
const double R2SMatchedRecoRatio_
const reco::SimToRecoCollection * trackSimToRecoAssociation_
VertexAssociatorByTracks(const edm::EDProductGetter *productGetter, double R2SMatchedSimRatio, double R2SMatchedRecoRatio, double S2RMatchedSimRatio, double S2RMatchedRecoRatio, const TrackingParticleSelector *selector, reco::TrackBase::TrackQuality trackQuality, const reco::RecoToSimCollection *trackRecoToSimAssociation, const reco::SimToRecoCollection *trackSimToRecoAssociation)
~VertexAssociatorByTracks() override
const edm::EDProductGetter * productGetter_
reco::VertexRecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Vertex >> &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const override
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
trackRef_iterator tracks_begin() const
first iterator over tracks
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
reco::VertexSimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Vertex >> &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const override