Skip to content

Commit

Permalink
Merge pull request #36554 from waredjeb/CloseByParticleGun_flatEta
Browse files Browse the repository at this point in the history
[HGCAL] Closeby Particle gun - uniform eta generation
  • Loading branch information
cmsbuild committed Jan 28, 2022
2 parents 630c72a + b28d61a commit 789ec14
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_E_Front_120um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_E_Front_200um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_E_Front_300um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_H_Coarse_300um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_H_Coarse_Scint_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_H_Fine_120um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_H_Fine_200um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
1 change: 1 addition & 0 deletions Configuration/Generator/python/CE_H_Fine_300um_cfi.py
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
Expand Up @@ -2,6 +2,7 @@

generator = cms.EDProducer("CloseByParticleGunProducer",
PGunParameters = cms.PSet(PartID = cms.vint32(22),
ControlledByEta = cms.bool(False),
EnMin = cms.double(25.),
EnMax = cms.double(200.),
MaxEnSpread = cms.bool(False),
Expand Down
3 changes: 2 additions & 1 deletion IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h
Expand Up @@ -15,7 +15,8 @@ namespace edm {

protected:
// data members
double fEnMin, fEnMax, fRMin, fRMax, fZMin, fZMax, fDelta, fPhiMin, fPhiMax;
bool fControlledByEta;
double fEnMin, fEnMax, fEtaMin, fEtaMax, fRMin, fRMax, fZMin, fZMax, fDelta, fPhiMin, fPhiMax;
int fNParticles;
bool fMaxEnSpread = false;
bool fPointing = false;
Expand Down
29 changes: 23 additions & 6 deletions IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc
Expand Up @@ -22,14 +22,22 @@ using namespace edm;
using namespace std;

CloseByParticleGunProducer::CloseByParticleGunProducer(const ParameterSet& pset) : BaseFlatGunProducer(pset) {
ParameterSet defpset;
ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");

fControlledByEta = pgun_params.getParameter<bool>("ControlledByEta");
fEnMax = pgun_params.getParameter<double>("EnMax");
fEnMin = pgun_params.getParameter<double>("EnMin");
fMaxEnSpread = pgun_params.getParameter<bool>("MaxEnSpread");
fRMax = pgun_params.getParameter<double>("RMax");
fRMin = pgun_params.getParameter<double>("RMin");
if (fControlledByEta) {
fEtaMax = pgun_params.getParameter<double>("MaxEta");
fEtaMin = pgun_params.getParameter<double>("MinEta");
if (fEtaMax <= fEtaMin)
LogError("CloseByParticleGunProducer") << " Please fix MinEta and MaxEta values in the configuration";
} else {
fRMax = pgun_params.getParameter<double>("RMax");
fRMin = pgun_params.getParameter<double>("RMin");
if (fRMax <= fRMin)
LogError("CloseByParticleGunProducer") << " Please fix RMin and RMax values in the configuration";
}
fZMax = pgun_params.getParameter<double>("ZMax");
fZMin = pgun_params.getParameter<double>("ZMin");
fDelta = pgun_params.getParameter<double>("Delta");
Expand Down Expand Up @@ -62,8 +70,16 @@ void CloseByParticleGunProducer::produce(Event& e, const EventSetup& es) {
unsigned int numParticles = fRandomShoot ? CLHEP::RandFlat::shoot(engine, 1, fNParticles) : fNParticles;

double phi = CLHEP::RandFlat::shoot(engine, fPhiMin, fPhiMax);
double fR = CLHEP::RandFlat::shoot(engine, fRMin, fRMax);
double fZ = CLHEP::RandFlat::shoot(engine, fZMin, fZMax);
double fR;

if (!fControlledByEta) {
fR = CLHEP::RandFlat::shoot(engine, fRMin, fRMax);
} else {
double fEta = CLHEP::RandFlat::shoot(engine, fEtaMin, fEtaMax);
fR = (fZ / sinh(fEta));
}

double tmpPhi = phi;
double tmpR = fR;

Expand All @@ -81,7 +97,8 @@ void CloseByParticleGunProducer::produce(Event& e, const EventSetup& es) {
else
fEn = CLHEP::RandFlat::shoot(engine, fEnMin, fEnMax);

int PartID = CLHEP::RandFlat::shoot(engine, 0, fPartIDs.size());
int partIdx = CLHEP::RandFlat::shoot(engine, 0, fPartIDs.size());
int PartID = fPartIDs[partIdx];
const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID)));
double mass = PData->mass().value();
double mom2 = fEn * fEn - mass * mass;
Expand Down

0 comments on commit 789ec14

Please sign in to comment.