22 double R2SMatchedSimRatio,
23 double R2SMatchedRecoRatio,
24 double S2RMatchedSimRatio,
25 double S2RMatchedRecoRatio,
31 R2SMatchedSimRatio_(R2SMatchedSimRatio),
32 R2SMatchedRecoRatio_(R2SMatchedRecoRatio),
33 S2RMatchedSimRatio_(S2RMatchedSimRatio),
34 S2RMatchedRecoRatio_(S2RMatchedRecoRatio),
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];
82 matches[trackingVertex].second++;
86 recoDaughterWeight +=
recoVertex->trackWeight(*recoDaughter);
89 std::size_t assoIndex = 0;
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;
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];
175 for (std::size_t recoIndex = 0; recoIndex < recoVertexes->size(); ++recoIndex) {
182 if (recoDaughter->id() == recoTrack.
id() && recoDaughter->key() == recoTrack.
key()) {
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();
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;
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_
TrackQuality
track quality
const double R2SMatchedSimRatio_
const double S2RMatchedSimRatio_
reco::VertexSimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Vertex >> &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const override
size_type size() const
map size
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
const double S2RMatchedRecoRatio_
const reco::RecoToSimCollection * trackRecoToSimAssociation_
const reco::TrackBase::TrackQuality trackQuality_
size_type numberOfAssociations(const key_type &k) const
number of associations to a key
void insert(const key_type &k, const data_type &v)
insert an association
const double R2SMatchedRecoRatio_
const reco::SimToRecoCollection * trackSimToRecoAssociation_
reco::VertexRecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Vertex >> &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const override
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_
EDProductGetter const * productGetter(std::atomic< void const *> const &iCache)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>