CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Member Functions
edm::CloseByParticleGunProducer Class Reference

#include <CloseByParticleGunProducer.h>

Inheritance diagram for edm::CloseByParticleGunProducer:
edm::BaseFlatGunProducer edm::one::EDProducer< one::WatchRuns, EndRunProducer > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CloseByParticleGunProducer (const ParameterSet &)
 
 ~CloseByParticleGunProducer () override
 
- Public Member Functions inherited from edm::BaseFlatGunProducer
 BaseFlatGunProducer (const ParameterSet &)
 
void beginRun (const edm::Run &r, const edm::EventSetup &) override
 
void endRun (edm::Run const &r, const edm::EventSetup &) override
 
void endRunProduce (edm::Run &r, const edm::EventSetup &) override
 
 ~BaseFlatGunProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< one::WatchRuns, EndRunProducer >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Attributes

double fDelta
 
double fEnMax
 
double fEnMin
 
int fNParticles
 
bool fOverlapping = false
 
std::vector< int > fPartIDs
 
double fPhiMax
 
double fPhiMin
 
bool fPointing = false
 
bool fRandomShoot = false
 
double fRMax
 
double fRMin
 
double fZMax
 
double fZMin
 
- Protected Attributes inherited from edm::BaseFlatGunProducer
bool fAddAntiParticle
 
HepMC::GenEventfEvt
 
double fMaxEta
 
double fMaxPhi
 
double fMinEta
 
double fMinPhi
 
std::vector< int > fPartIDs
 
ESHandle< HepPDT::ParticleDataTablefPDGTable
 
int fVerbosity
 

Private Member Functions

void produce (Event &e, const EventSetup &es) override
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 8 of file CloseByParticleGunProducer.h.

Constructor & Destructor Documentation

◆ CloseByParticleGunProducer()

CloseByParticleGunProducer::CloseByParticleGunProducer ( const ParameterSet pset)

Definition at line 24 of file CloseByParticleGunProducer.cc.

25  ParameterSet defpset;
26  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
27 
28  fEnMax = pgun_params.getParameter<double>("EnMax");
29  fEnMin = pgun_params.getParameter<double>("EnMin");
30  fRMax = pgun_params.getParameter<double>("RMax");
31  fRMin = pgun_params.getParameter<double>("RMin");
32  fZMax = pgun_params.getParameter<double>("ZMax");
33  fZMin = pgun_params.getParameter<double>("ZMin");
34  fDelta = pgun_params.getParameter<double>("Delta");
35  fPhiMin = pgun_params.getParameter<double>("MinPhi");
36  fPhiMax = pgun_params.getParameter<double>("MaxPhi");
37  fPointing = pgun_params.getParameter<bool>("Pointing");
38  fOverlapping = pgun_params.getParameter<bool>("Overlapping");
39  fRandomShoot = pgun_params.getParameter<bool>("RandomShoot");
40  fNParticles = pgun_params.getParameter<int>("NParticles");
41  fPartIDs = pgun_params.getParameter<vector<int> >("PartID");
42 
43  produces<HepMCProduct>("unsmeared");
44  produces<GenEventInfoProduct>();
45 }

References fDelta, fEnMax, fEnMin, fNParticles, fOverlapping, fPartIDs, fPhiMax, fPhiMin, fPointing, fRandomShoot, fRMax, fRMin, fZMax, fZMin, edm::ParameterSet::getParameter(), and muonDTDigis_cfi::pset.

◆ ~CloseByParticleGunProducer()

CloseByParticleGunProducer::~CloseByParticleGunProducer ( )
override

Definition at line 47 of file CloseByParticleGunProducer.cc.

47  {
48  // no need to cleanup GenEvent memory - done in HepMCProduct
49 }

Member Function Documentation

◆ produce()

void CloseByParticleGunProducer::produce ( Event e,
const EventSetup es 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 51 of file CloseByParticleGunProducer.cc.

51  {
53  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
54 
55  if (fVerbosity > 0) {
56  LogDebug("CloseByParticleGunProducer") << " CloseByParticleGunProducer : Begin New Event Generation" << endl;
57  }
58  fEvt = new HepMC::GenEvent();
59 
60  // loop over particles
61  //
62  int barcode = 1;
63  int numParticles = fRandomShoot ? CLHEP::RandFlat::shoot(engine, 1, fNParticles) : fNParticles;
64  std::vector<int> particles;
65 
66  for (int i = 0; i < numParticles; i++) {
67  int partIdx = CLHEP::RandFlat::shoot(engine, 0, fPartIDs.size());
68  particles.push_back(fPartIDs[partIdx]);
69  }
70 
71  double phi = CLHEP::RandFlat::shoot(engine, fPhiMin, fPhiMax);
72  double fR = CLHEP::RandFlat::shoot(engine, fRMin, fRMax);
73  double fZ = CLHEP::RandFlat::shoot(engine, fZMin, fZMax);
74  double tmpPhi = phi;
75  double tmpR = fR;
76 
77  for (unsigned int ip = 0; ip < particles.size(); ++ip) {
78  if (fOverlapping) {
79  fR = CLHEP::RandFlat::shoot(engine, tmpR - fDelta, tmpR + fDelta);
80  phi = CLHEP::RandFlat::shoot(engine, tmpPhi - fDelta / fR, tmpPhi + fDelta / fR);
81  } else
82  phi += fDelta / fR;
83 
84  double fEn = CLHEP::RandFlat::shoot(engine, fEnMin, fEnMax);
85  int PartID = particles[ip];
86  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID)));
87  double mass = PData->mass().value();
88  double mom2 = fEn * fEn - mass * mass;
89  double mom = 0.;
90  if (mom2 > 0.) {
91  mom = sqrt(mom2);
92  }
93  double px = 0.;
94  double py = 0.;
95  double pz = mom;
96  double energy = fEn;
97 
98  // Compute Vertex Position
99  double x = fR * cos(phi);
100  double y = fR * sin(phi);
101  constexpr double c = 2.99792458e+1; // cm/ns
102  double timeOffset = sqrt(x * x + y * y + fZ * fZ) / c * ns * c_light;
103  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(x * cm, y * cm, fZ * cm, timeOffset));
104 
105  HepMC::FourVector p(px, py, pz, energy);
106  // If we are requested to be pointing to (0,0,0), correct the momentum direction
107  if (fPointing) {
108  math::XYZVector direction(x, y, fZ);
109  math::XYZVector momentum = direction.unit() * mom;
110  p.setX(momentum.x());
111  p.setY(momentum.y());
112  p.setZ(momentum.z());
113  }
115  Part->suggest_barcode(barcode);
116  barcode++;
117 
118  Vtx->add_particle_out(Part);
119 
120  if (fVerbosity > 0) {
121  Vtx->print();
122  Part->print();
123  }
124  fEvt->add_vertex(Vtx);
125  }
126 
127  fEvt->set_event_number(e.id().event());
128  fEvt->set_signal_process_id(20);
129 
130  if (fVerbosity > 0) {
131  fEvt->print();
132  }
133 
134  unique_ptr<HepMCProduct> BProduct(new HepMCProduct());
135  BProduct->addHepMCData(fEvt);
136  e.put(std::move(BProduct), "unsmeared");
137 
138  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
139  e.put(std::move(genEventInfo));
140 
141  if (fVerbosity > 0) {
142  LogDebug("CloseByParticleGunProducer") << " CloseByParticleGunProducer : Event Generation Done " << endl;
143  }
144 
145  particles.clear();
146 }

References funct::abs(), HltBtagPostValidation_cff::c, funct::cos(), MillePedeFileConverter_cfg::e, HCALHighEnergyHPDFilter_cfi::energy, fDelta, fEnMax, fEnMin, edm::BaseFlatGunProducer::fEvt, fNParticles, fOverlapping, fPartIDs, edm::BaseFlatGunProducer::fPDGTable, fPhiMax, fPhiMin, fPointing, hydjet2DefaultParameters_cff::fR, fRandomShoot, fRMax, fRMin, edm::BaseFlatGunProducer::fVerbosity, fZMax, fZMin, genParticles2HepMC_cfi::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), ZgammaFilter_cfi::HepMCProduct, mps_fire::i, LogDebug, EgHLTOffHistBins_cfi::mass, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, LHEGenericFilter_cfi::ParticleID, ecalTrigSettings_cff::particles, genfragment_ptgun_cfg::PartID, partIdx(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), mathSSE::sqrt(), and CalibratedDigis_cfi::timeOffset.

Member Data Documentation

◆ fDelta

double edm::CloseByParticleGunProducer::fDelta
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fEnMax

double edm::CloseByParticleGunProducer::fEnMax
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fEnMin

double edm::CloseByParticleGunProducer::fEnMin
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fNParticles

int edm::CloseByParticleGunProducer::fNParticles
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fOverlapping

bool edm::CloseByParticleGunProducer::fOverlapping = false
protected

Definition at line 21 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPartIDs

std::vector<int> edm::CloseByParticleGunProducer::fPartIDs
protected

Definition at line 23 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPhiMax

double edm::CloseByParticleGunProducer::fPhiMax
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPhiMin

double edm::CloseByParticleGunProducer::fPhiMin
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPointing

bool edm::CloseByParticleGunProducer::fPointing = false
protected

Definition at line 20 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fRandomShoot

bool edm::CloseByParticleGunProducer::fRandomShoot = false
protected

Definition at line 22 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fRMax

double edm::CloseByParticleGunProducer::fRMax
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fRMin

double edm::CloseByParticleGunProducer::fRMin
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fZMax

double edm::CloseByParticleGunProducer::fZMax
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fZMin

double edm::CloseByParticleGunProducer::fZMin
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

GenEventInfoProduct
Definition: GenEventInfoProduct.h:17
DDAxes::y
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
mps_fire.i
i
Definition: mps_fire.py:355
edm::CloseByParticleGunProducer::fOverlapping
bool fOverlapping
Definition: CloseByParticleGunProducer.h:21
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::CloseByParticleGunProducer::fDelta
double fDelta
Definition: CloseByParticleGunProducer.h:18
edm::BaseFlatGunProducer::fEvt
HepMC::GenEvent * fEvt
Definition: BaseFlatGunProducer.h:48
ZgammaFilter_cfi.HepMCProduct
HepMCProduct
Definition: ZgammaFilter_cfi.py:9
edm::CloseByParticleGunProducer::fPhiMin
double fPhiMin
Definition: CloseByParticleGunProducer.h:18
hydjet2DefaultParameters_cff.fR
fR
Definition: hydjet2DefaultParameters_cff.py:14
DDAxes::x
edm::CloseByParticleGunProducer::fPhiMax
double fPhiMax
Definition: CloseByParticleGunProducer.h:18
edm::CloseByParticleGunProducer::fRMin
double fRMin
Definition: CloseByParticleGunProducer.h:18
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
edm::CloseByParticleGunProducer::fNParticles
int fNParticles
Definition: CloseByParticleGunProducer.h:19
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
edm::BaseFlatGunProducer::BaseFlatGunProducer
BaseFlatGunProducer(const ParameterSet &)
Definition: BaseFlatGunProducer.cc:29
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
partIdx
static unsigned int partIdx(const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
Definition: InputGenJetsParticleSelector.cc:120
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::CloseByParticleGunProducer::fPartIDs
std::vector< int > fPartIDs
Definition: CloseByParticleGunProducer.h:23
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
edm::CloseByParticleGunProducer::fRMax
double fRMax
Definition: CloseByParticleGunProducer.h:18
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
edm::Service< edm::RandomNumberGenerator >
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
genfragment_ptgun_cfg.PartID
PartID
Definition: genfragment_ptgun_cfg.py:6
edm::BaseFlatGunProducer::fPDGTable
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Definition: BaseFlatGunProducer.h:57
edm::CloseByParticleGunProducer::fEnMin
double fEnMin
Definition: CloseByParticleGunProducer.h:18
edm::CloseByParticleGunProducer::fZMax
double fZMax
Definition: CloseByParticleGunProducer.h:18
DDAxes::phi
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
edm::CloseByParticleGunProducer::fZMin
double fZMin
Definition: CloseByParticleGunProducer.h:18
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::CloseByParticleGunProducer::fPointing
bool fPointing
Definition: CloseByParticleGunProducer.h:20
genParticles2HepMC_cfi.genEventInfo
genEventInfo
Definition: genParticles2HepMC_cfi.py:6
CalibratedDigis_cfi.timeOffset
timeOffset
Definition: CalibratedDigis_cfi.py:22
edm::CloseByParticleGunProducer::fRandomShoot
bool fRandomShoot
Definition: CloseByParticleGunProducer.h:22
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
edm::BaseFlatGunProducer::fVerbosity
int fVerbosity
Definition: BaseFlatGunProducer.h:59
edm::CloseByParticleGunProducer::fEnMax
double fEnMax
Definition: CloseByParticleGunProducer.h:18
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LHEGenericFilter_cfi.ParticleID
ParticleID
Definition: LHEGenericFilter_cfi.py:6
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37