Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove improper call to edm::Ref constructor call #7463

Merged
merged 1 commit into from Jan 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions SimMuon/MCTruth/src/MuonAssociatorByHits.cc
Expand Up @@ -203,7 +203,7 @@ MuonAssociatorByHits::associateRecoToSim( const edm::RefToBaseVector<reco::Track
auto bareAssoc = helper_.associateRecoToSimIndices(tH, TPCollectionH, resources);
for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
outputCollection.insert(tC[it->first], std::make_pair(edm::Ref<TrackingParticleCollection>(TPCollectionH, itma->idx), itma->quality));
outputCollection.insert(tC[it->first], std::make_pair(TPCollectionH[itma->idx], itma->quality));
}
}

Expand Down Expand Up @@ -242,7 +242,7 @@ MuonAssociatorByHits::associateSimToReco( const edm::RefToBaseVector<reco::Track
auto bareAssoc = helper_.associateSimToRecoIndices(tH, TPCollectionH, resources);
for (auto it = bareAssoc.begin(), ed = bareAssoc.end(); it != ed; ++it) {
for (auto itma = it->second.begin(), edma = it->second.end(); itma != edma; ++itma) {
outputCollection.insert(edm::Ref<TrackingParticleCollection>(TPCollectionH, it->first),
outputCollection.insert(TPCollectionH[ it->first],
std::make_pair(tC[itma->idx], itma->quality));
}
}
Expand Down
4 changes: 2 additions & 2 deletions SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h
Expand Up @@ -82,10 +82,10 @@ class TrackAssociatorByHits : public TrackAssociatorBase {

int getShared(std::vector<SimHitIdpr>&,
std::vector<SimHitIdpr>&,
TrackingParticleCollection::const_iterator) const;
TrackingParticle const& ) const;

template<typename iter>
int getDoubleCount(iter,iter,TrackerHitAssociator*,TrackingParticleCollection::const_iterator) const;
int getDoubleCount(iter,iter,TrackerHitAssociator*,TrackingParticle const&) const;

private:
// ----- member data
Expand Down
38 changes: 21 additions & 17 deletions SimTracker/TrackAssociation/src/TrackAssociatorByChi2.cc
Expand Up @@ -128,10 +128,11 @@ RecoToSimCollection TrackAssociatorByChi2::associateRecoToSim(const edm::RefToBa

RecoToSimCollection outputCollection;

TrackingParticleCollection tPC;
//dereference the edm::Ref only once
std::vector<const TrackingParticle*> tPC;
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
tPC.push_back(&(*ref));
}

int tindex=0;
Expand All @@ -155,20 +156,21 @@ RecoToSimCollection TrackAssociatorByChi2::associateRecoToSim(const edm::RefToBa
recoTrackCovMatrix.Invert();

int tpindex =0;
for (TrackingParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
for (auto tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){

//skip tps with a very small pt
//if (sqrt(tp->momentum().perp2())<0.5) continue;
int charge = tp->charge();
//if (sqrt((*tp)->momentum().perp2())<0.5) continue;
int charge = (*tp)->charge();
if (charge==0) continue;
Basic3DVector<double> momAtVtx(tp->momentum().x(),tp->momentum().y(),tp->momentum().z());
Basic3DVector<double> vert=(Basic3DVector<double>) tp->vertex();
Basic3DVector<double> momAtVtx((*tp)->momentum().x(),(*tp)->momentum().y(),(*tp)->momentum().z());
Basic3DVector<double> vert=(Basic3DVector<double>) (*tp)->vertex();

double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);

if (chi2<chi2cut) {
//NOTE: tPCH and tPC have the same index for the same object
outputCollection.insert(tC[tindex],
std::make_pair(edm::Ref<TrackingParticleCollection>(tPCH, tpindex),
std::make_pair(tPCH[tpindex],
-chi2));//-chi2 because the Association Map is ordered using std::greater
}
}
Expand All @@ -188,26 +190,27 @@ SimToRecoCollection TrackAssociatorByChi2::associateSimToReco(const edm::RefToBa

SimToRecoCollection outputCollection;

TrackingParticleCollection tPC;
//dereference the edm::Ref only once
std::vector<const TrackingParticle*> tPC;
tPC.reserve(tPCH.size());
for(auto const& ref: tPCH) {
tPC.push_back(*ref);
tPC.push_back(&(*ref));
}

int tpindex =0;
for (TrackingParticleCollection::const_iterator tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){
for (auto tp=tPC.begin(); tp!=tPC.end(); tp++, ++tpindex){

//skip tps with a very small pt
//if (sqrt(tp->momentum().perp2())<0.5) continue;
int charge = tp->charge();
//if (sqrt((*tp)->momentum().perp2())<0.5) continue;
int charge = (*tp)->charge();
if (charge==0) continue;

LogDebug("TrackAssociator") << "=========LOOKING FOR ASSOCIATION===========" << "\n"
<< "TrackingParticle #"<<tpindex<<" with pt=" << sqrt(tp->momentum().perp2()) << "\n"
<< "TrackingParticle #"<<tpindex<<" with pt=" << sqrt((*tp)->momentum().perp2()) << "\n"
<< "===========================================" << "\n";

Basic3DVector<double> momAtVtx(tp->momentum().x(),tp->momentum().y(),tp->momentum().z());
Basic3DVector<double> vert(tp->vertex().x(),tp->vertex().y(),tp->vertex().z());
Basic3DVector<double> momAtVtx((*tp)->momentum().x(),(*tp)->momentum().y(),(*tp)->momentum().z());
Basic3DVector<double> vert((*tp)->vertex().x(),(*tp)->vertex().y(),(*tp)->vertex().z());

int tindex=0;
for (RefToBaseVector<reco::Track>::const_iterator rt=tC.begin(); rt!=tC.end(); rt++, tindex++){
Expand All @@ -226,7 +229,8 @@ SimToRecoCollection TrackAssociatorByChi2::associateSimToReco(const edm::RefToBa
double chi2 = getChi2(rParameters,recoTrackCovMatrix,momAtVtx,vert,charge,bs);

if (chi2<chi2cut) {
outputCollection.insert(edm::Ref<TrackingParticleCollection>(tPCH, tpindex),
//NOTE: tPCH and tPC have the same index for the same object
outputCollection.insert(tPCH[tpindex],
std::make_pair(tC[tindex],
-chi2));//-chi2 because the Association Map is ordered using std::greater
}
Expand Down