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)
51 std::map<TrackingVertexRef,std::pair<double, std::size_t> >
matches;
53 LogDebug(
"VertexAssociation") <<
"reco::VertexCollection size = " << recoVertexes->size()
54 <<
" ; TrackingVertexCollection size = " << trackingVertexes->size() << std::endl;
57 for (std::size_t recoIndex = 0; recoIndex < recoVertexes->size(); ++recoIndex)
63 double recoDaughterWeight = 0.;
78 std::vector<std::pair<TrackingParticleRef,double> > associations = (*trackRecoToSimAssociation_)[*recoDaughter];
82 std::vector<std::pair<TrackingParticleRef,double> >::const_iterator association = associations.begin();
83 association != associations.end();
90 matches[trackingVertex].first += recoVertex->
trackWeight(*recoDaughter);
91 matches[trackingVertex].second++;
95 recoDaughterWeight += recoVertex->
trackWeight(*recoDaughter);
98 std::size_t assoIndex = 0;
103 match != matches.end();
109 double matchedDaughterWeight =
match->second.first;
110 std::size_t matchedDaughterCounter =
match->second.second;
113 std::size_t simDaughterCounter = 0;
117 simDaughter != trackingVertex->daughterTracks_end();
120 if ( (*
selector_)(**simDaughter) ) simDaughterCounter++;
123 if ( simDaughterCounter < matchedDaughterCounter )
124 simDaughterCounter = matchedDaughterCounter;
129 double quality = (double)matchedDaughterWeight/recoDaughterWeight;
134 outputCollection.
insert(recoVertex, std::make_pair(trackingVertex, quality));
136 LogTrace(
"VertexAssociation") <<
"R2S: INDEX " << assoIndex
137 <<
" ; SimDaughterCounter = " << simDaughterCounter
138 <<
" ; RecoDaughterWeight = " << recoDaughterWeight
139 <<
" ; MatchedDaughterCounter = " << matchedDaughterCounter
140 <<
" ; MatchedDaughterWeight = " << matchedDaughterWeight
147 LogTrace(
"VertexAssociation") <<
"\nRecoToSim OUTPUT COLLECTION: outputCollection.size() = " << outputCollection.
size() << std::endl;
149 return outputCollection;
162 std::map<std::size_t,std::pair<double, std::size_t> >
matches;
165 for (std::size_t simIndex = 0; simIndex < trackingVertexes->size(); ++simIndex)
171 std::size_t simDaughterCounter = 0;
176 simDaughter != trackingVertex->daughterTracks_end();
181 if ( !(*
selector_)(**simDaughter) )
continue;
186 std::vector<std::pair<reco::TrackBaseRef, double> > associations = (*trackSimToRecoAssociation_)[*simDaughter];
190 std::vector<std::pair<reco::TrackBaseRef,double> >::const_iterator association = associations.begin();
191 association != associations.end();
197 for (std::size_t recoIndex = 0; recoIndex < recoVertexes->size(); ++recoIndex)
209 recoDaughter->id() == recoTrack.
id() &&
210 recoDaughter->key() == recoTrack.
key()
213 matches[recoIndex].first += recoVertex->
trackWeight(*recoDaughter);
214 matches[recoIndex].second++;
221 simDaughterCounter++;
224 std::size_t assoIndex = 0;
228 std::map<std::size_t,std::pair<double,std::size_t> >::const_iterator
match = matches.begin();
229 match != matches.end();
235 double matchedDaughterWeight =
match->second.first;
236 std::size_t matchedDaughterCounter =
match->second.second;
238 double recoDaughterWeight = 0.;
247 recoDaughterWeight += recoVertex->
trackWeight(*recoDaughter);
250 if ( recoDaughterWeight < matchedDaughterWeight )
251 recoDaughterWeight = matchedDaughterWeight;
256 double quality = (double)matchedDaughterCounter/simDaughterCounter;
261 outputCollection.
insert(trackingVertex, std::make_pair(recoVertex, quality));
263 LogTrace(
"VertexAssociation") <<
"R2S: INDEX " << assoIndex
264 <<
" ; SimDaughterCounter = " << simDaughterCounter
265 <<
" ; RecoDaughterWeight = " << recoDaughterWeight
266 <<
" ; MatchedDaughterCounter = " << matchedDaughterCounter
267 <<
" ; MatchedDaughterWeight = " << matchedDaughterWeight
274 LogTrace(
"VertexAssociation") <<
"SimToReco OUTPUT COLLECTION: outputCollection.size() = " << outputCollection.
size() << std::endl;
276 return outputCollection;
const TrackingParticleSelector * selector_
trackRef_iterator tracks_end() const
last iterator over tracks
TrackQuality
track quality
virtual reco::VertexRecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections
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)
const edm::EDProductGetter * productGetter_
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
~VertexAssociatorByTracks()
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
virtual reco::VertexSimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections