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

avoid copies of GenEvent and optimizing random number usage in DIGI step #8451

Merged
merged 1 commit into from Mar 28, 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
3 changes: 1 addition & 2 deletions SimCalorimetry/CaloSimAlgos/src/CaloHitResponse.cc
Expand Up @@ -204,8 +204,7 @@ double CaloHitResponse::analogSignalAmplitude(const DetId & detId, float energy,
double npe = scl * energy * parameters.simHitToPhotoelectrons(detId);
// do we need to doPoisson statistics for the photoelectrons?
if(parameters.doPhotostatistics()) {
CLHEP::RandPoissonQ randPoissonQ(*engine, npe);
npe = randPoissonQ.fire();
npe = CLHEP::RandPoissonQ::shoot(engine,npe);
}
if(thePECorrection) npe = thePECorrection->correctPE(detId, npe, engine);
return npe;
Expand Down
18 changes: 6 additions & 12 deletions SimGeneral/PileupInformation/plugins/PileupVertexAccumulator.cc
Expand Up @@ -75,9 +75,8 @@ namespace cms

mixMod.produces<PileupVertexContent>().setBranchAlias(alias);

const edm::InputTag Mtag("generator");

iC.consumes<edm::HepMCProduct>(Mtag);
Mtag_=edm::InputTag("generator");
iC.consumes<edm::HepMCProduct>(Mtag_);
}

PileupVertexAccumulator::~PileupVertexAccumulator(){
Expand All @@ -98,21 +97,16 @@ namespace cms

void
PileupVertexAccumulator::accumulate(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
edm::Handle<edm::HepMCProduct> MCevt;
const edm::InputTag Mtag("generator");
iEvent.getByLabel(Mtag, MCevt);

// don't do anything for hard-scatter signal events
}

void
PileupVertexAccumulator::accumulate(PileUpEventPrincipal const& iEvent, edm::EventSetup const& iSetup, edm::StreamID const& streamID) {

edm::Handle<edm::HepMCProduct> MCevt;
const edm::InputTag Mtag("generator");
iEvent.getByLabel(Mtag, MCevt);
iEvent.getByLabel(Mtag_, MCevt);

HepMC::GenEvent * myGenEvent = new HepMC::GenEvent(*(MCevt->GetEvent()));
const HepMC::GenEvent *myGenEvent = MCevt->GetEvent();

double pthat = myGenEvent->event_scale();
float pt_hat = float(pthat);
Expand All @@ -129,12 +123,12 @@ namespace cms
if(viter!=vend){
// The origin vertex (turn it to cm's from GenEvent mm's)
HepMC::GenVertex* v = *viter;
float zpos = v->position().z()/10.;
float zpos = v->position().z()*0.1;

z_posns_.push_back(zpos);
}

delete myGenEvent;
// delete myGenEvent;

}

Expand Down
Expand Up @@ -20,6 +20,7 @@
#include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "FWCore/Utilities/interface/InputTag.h"

namespace edm {
class ConsumesCollector;
Expand Down Expand Up @@ -53,6 +54,8 @@ namespace cms {
private:
std::vector<float> pT_Hats_;
std::vector<float> z_posns_;
edm::InputTag Mtag_;

};
}

Expand Down
12 changes: 4 additions & 8 deletions SimTracker/Common/src/SiG4UniversalFluctuation.cc
Expand Up @@ -230,17 +230,15 @@ double SiG4UniversalFluctuation::SampleFluctuations(const double momentum,
siga=sqrt(a1) ;
p1 = max(0., CLHEP::RandGaussQ::shoot(engine, a1, siga) + 0.5);
} else {
CLHEP::RandPoissonQ randPoissonQ(*engine, a1);
p1 = double(randPoissonQ.fire());
p1 = double(CLHEP::RandPoissonQ::shoot(engine,a1));
}

// excitation type 2
if (a2>alim) {
siga=sqrt(a2) ;
p2 = max(0., CLHEP::RandGaussQ::shoot(engine, a2, siga) + 0.5);
} else {
CLHEP::RandPoissonQ randPoissonQ(*engine, a2);
p2 = double(randPoissonQ.fire());
p2 = double(CLHEP::RandPoissonQ::shoot(engine,a2));
}

loss = p1*e1Fluct+p2*e2Fluct;
Expand All @@ -259,8 +257,7 @@ double SiG4UniversalFluctuation::SampleFluctuations(const double momentum,
siga=sqrt(a3) ;
p3 = max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
} else {
CLHEP::RandPoissonQ randPoissonQ(*engine, a3);
p3 = double(randPoissonQ.fire());
p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
}
double lossc = 0.;
if (p3 > 0) {
Expand Down Expand Up @@ -302,8 +299,7 @@ double SiG4UniversalFluctuation::SampleFluctuations(const double momentum,
siga=sqrt(a3);
p3 = max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
} else {
CLHEP::RandPoissonQ randPoissonQ(*engine, a3);
p3 = double(randPoissonQ.fire());
p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
}
if (p3 > 0.) {
double w = (tmax-e0)/tmax;
Expand Down