Skip to content

Commit

Permalink
save 50MB (35pu one thread) by not copying stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlange6 committed Feb 10, 2017
1 parent 8b8e202 commit 2dbc3b3
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions Validation/RecoEgamma/plugins/TkConvValidator.cc
Expand Up @@ -146,9 +146,9 @@ TkConvValidator::TkConvValidator( const edm::ParameterSet& pset )
edm::InputTag("tpSelecForEfficiency"));
tpSelForFake_Token_ = consumes<TrackingParticleRefVector> (
edm::InputTag("tpSelecForFakeRate"));
hepMC_Token_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
genjets_Token_ = consumes<reco::GenJetCollection>(
edm::InputTag("ak4GenJets"));
//hepMC_Token_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
//genjets_Token_ = consumes<reco::GenJetCollection>(
// edm::InputTag("ak4GenJets"));

trackAssociator_Token_ = consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag("trackAssociatorByHitsForConversionValidation"));
}
Expand Down Expand Up @@ -886,41 +886,42 @@ void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup

//////////////////// Get the MC truth
//get simtrack info
std::vector<SimTrack> theSimTracks;
std::vector<SimVertex> theSimVertices;
//std::vector<SimTrack> theSimTracks;
//std::vector<SimVertex> theSimVertices;

edm::Handle<SimTrackContainer> SimTk;
edm::Handle<SimVertexContainer> SimVtx;
e.getByToken(g4_simTk_Token_, SimTk);
e.getByToken(g4_simVtx_Token_, SimVtx);

bool useTP = parameters_.getParameter<bool>("useTP");
TrackingParticleRefVector tpForEfficiency;
TrackingParticleRefVector tpForFakeRate;
TrackingParticleRefVector dummy;
edm::Handle<TrackingParticleRefVector> TPHandleForEff;
edm::Handle<TrackingParticleRefVector> TPHandleForFakeRate;
if (useTP) {
e.getByToken(tpSelForEff_Token_, TPHandleForEff);
tpForEfficiency = *(TPHandleForEff.product());
e.getByToken(tpSelForFake_Token_, TPHandleForFakeRate);
tpForFakeRate = *(TPHandleForFakeRate.product());
}

const TrackingParticleRefVector &tpForEfficiency= useTP? *(TPHandleForEff.product()) : dummy;
const TrackingParticleRefVector &tpForFakeRate= useTP? *(TPHandleForFakeRate.product()):dummy;

const std::vector<SimTrack> &theSimTracks= *SimTk;
const std::vector<SimVertex> &theSimVertices= *SimVtx;

theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
//theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
//theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks, theSimVertices);

edm::Handle<edm::HepMCProduct> hepMC;
e.getByToken(hepMC_Token_, hepMC);
//edm::Handle<edm::HepMCProduct> hepMC;
//e.getByToken(hepMC_Token_, hepMC);
// const HepMC::GenEvent *myGenEvent = hepMC->GetEvent(); // unused


// get generated jets
edm::Handle<reco::GenJetCollection> GenJetsHandle;
e.getByToken(genjets_Token_, GenJetsHandle);
reco::GenJetCollection genJetCollection = *(GenJetsHandle.product());
//edm::Handle<reco::GenJetCollection> GenJetsHandle;
//e.getByToken(genjets_Token_, GenJetsHandle);
//const reco::GenJetCollection &genJetCollection = *(GenJetsHandle.product());

ConversionHitChecker hitChecker;

Expand Down Expand Up @@ -969,7 +970,7 @@ void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup
theConvTP_.clear();
// std::cout << " TkConvValidator TrackingParticles TrackingParticleCollection size "<< trackingParticles.size() << "\n";
//duplicated TP collections for two associations
for(TrackingParticleRef tp: tpForEfficiency) {
for(const TrackingParticleRef tp: tpForEfficiency) {
if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
Expand Down Expand Up @@ -1424,13 +1425,11 @@ void TkConvValidator::analyze( const edm::Event& e, const edm::EventSetup& esup


theConvTP_.clear();
for(TrackingParticleRef tp: tpForFakeRate) {
for(const TrackingParticleRef tp: tpForFakeRate) {
if ( fabs( tp->vx() - (*mcPho).vertex().x() ) < 0.0001 &&
fabs( tp->vy() - (*mcPho).vertex().y() ) < 0.0001 &&
fabs( tp->vz() - (*mcPho).vertex().z() ) < 0.0001) {
theConvTP_.push_back( tp );


}
}

Expand Down

0 comments on commit 2dbc3b3

Please sign in to comment.