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
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Attributes

bool fControlledByEta
 
double fDelta
 
double fEnMax
 
double fEnMin
 
double fEtaMax
 
double fEtaMin
 
bool fMaxEnSpread = false
 
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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, 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)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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

25  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
26  fControlledByEta = pgun_params.getParameter<bool>("ControlledByEta");
27  fEnMax = pgun_params.getParameter<double>("EnMax");
28  fEnMin = pgun_params.getParameter<double>("EnMin");
29  fMaxEnSpread = pgun_params.getParameter<bool>("MaxEnSpread");
30  if (fControlledByEta) {
31  fEtaMax = pgun_params.getParameter<double>("MaxEta");
32  fEtaMin = pgun_params.getParameter<double>("MinEta");
33  if (fEtaMax <= fEtaMin)
34  LogError("CloseByParticleGunProducer") << " Please fix MinEta and MaxEta values in the configuration";
35  } else {
36  fRMax = pgun_params.getParameter<double>("RMax");
37  fRMin = pgun_params.getParameter<double>("RMin");
38  if (fRMax <= fRMin)
39  LogError("CloseByParticleGunProducer") << " Please fix RMin and RMax values in the configuration";
40  }
41  fZMax = pgun_params.getParameter<double>("ZMax");
42  fZMin = pgun_params.getParameter<double>("ZMin");
43  fDelta = pgun_params.getParameter<double>("Delta");
44  fPhiMin = pgun_params.getParameter<double>("MinPhi");
45  fPhiMax = pgun_params.getParameter<double>("MaxPhi");
46  fPointing = pgun_params.getParameter<bool>("Pointing");
47  fOverlapping = pgun_params.getParameter<bool>("Overlapping");
48  fRandomShoot = pgun_params.getParameter<bool>("RandomShoot");
49  fNParticles = pgun_params.getParameter<int>("NParticles");
50  fPartIDs = pgun_params.getParameter<vector<int> >("PartID");
51 
52  produces<HepMCProduct>("unsmeared");
53  produces<GenEventInfoProduct>();
54 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Log< level::Error, false > LogError
BaseFlatGunProducer(const ParameterSet &)

◆ ~CloseByParticleGunProducer()

CloseByParticleGunProducer::~CloseByParticleGunProducer ( )
override

Definition at line 56 of file CloseByParticleGunProducer.cc.

56  {
57  // no need to cleanup GenEvent memory - done in HepMCProduct
58 }

Member Function Documentation

◆ produce()

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

Implements edm::one::EDProducerBase.

Definition at line 60 of file CloseByParticleGunProducer.cc.

References funct::abs(), HltBtagPostValidation_cff::c, funct::cos(), MillePedeFileConverter_cfg::e, HCALHighEnergyHPDFilter_cfi::energy, fControlledByEta, fDelta, fEnMax, fEnMin, fEtaMax, fEtaMin, edm::BaseFlatGunProducer::fEvt, fMaxEnSpread, 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, LogDebug, EgHLTOffHistBins_cfi::mass, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, LHEGenericFilter_cfi::ParticleID, genfragment_ptgun_cfg::PartID, partIdx(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), mathSSE::sqrt(), hgcalLayerClusters_cfi::timeOffset, and x.

60  {
62  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
63 
64  if (fVerbosity > 0) {
65  LogDebug("CloseByParticleGunProducer") << " CloseByParticleGunProducer : Begin New Event Generation" << endl;
66  }
67  fEvt = new HepMC::GenEvent();
68 
69  int barcode = 1;
70  unsigned int numParticles = fRandomShoot ? CLHEP::RandFlat::shoot(engine, 1, fNParticles) : fNParticles;
71 
72  double phi = CLHEP::RandFlat::shoot(engine, fPhiMin, fPhiMax);
73  double fZ = CLHEP::RandFlat::shoot(engine, fZMin, fZMax);
74  double fR;
75 
76  if (!fControlledByEta) {
77  fR = CLHEP::RandFlat::shoot(engine, fRMin, fRMax);
78  } else {
79  double fEta = CLHEP::RandFlat::shoot(engine, fEtaMin, fEtaMax);
80  fR = (fZ / sinh(fEta));
81  }
82 
83  double tmpPhi = phi;
84  double tmpR = fR;
85 
86  // Loop over particles
87  for (unsigned int ip = 0; ip < numParticles; ++ip) {
88  if (fOverlapping) {
89  fR = CLHEP::RandFlat::shoot(engine, tmpR - fDelta, tmpR + fDelta);
90  phi = CLHEP::RandFlat::shoot(engine, tmpPhi - fDelta / fR, tmpPhi + fDelta / fR);
91  } else
92  phi += fDelta / fR;
93 
94  double fEn;
95  if (numParticles > 1 && fMaxEnSpread)
96  fEn = fEnMin + ip * (fEnMax - fEnMin) / (numParticles - 1);
97  else
98  fEn = CLHEP::RandFlat::shoot(engine, fEnMin, fEnMax);
99 
100  int partIdx = CLHEP::RandFlat::shoot(engine, 0, fPartIDs.size());
101  int PartID = fPartIDs[partIdx];
102  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID)));
103  double mass = PData->mass().value();
104  double mom2 = fEn * fEn - mass * mass;
105  double mom = 0.;
106  if (mom2 > 0.) {
107  mom = sqrt(mom2);
108  }
109  double px = 0.;
110  double py = 0.;
111  double pz = mom;
112  double energy = fEn;
113 
114  // Compute Vertex Position
115  double x = fR * cos(phi);
116  double y = fR * sin(phi);
117  constexpr double c = 2.99792458e+1; // cm/ns
118  double timeOffset = sqrt(x * x + y * y + fZ * fZ) / c * ns * c_light;
119  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(x * cm, y * cm, fZ * cm, timeOffset));
120 
121  HepMC::FourVector p(px, py, pz, energy);
122  // If we are requested to be pointing to (0,0,0), correct the momentum direction
123  if (fPointing) {
124  math::XYZVector direction(x, y, fZ);
125  math::XYZVector momentum = direction.unit() * mom;
126  p.setX(momentum.x());
127  p.setY(momentum.y());
128  p.setZ(momentum.z());
129  }
131  Part->suggest_barcode(barcode);
132  barcode++;
133 
134  Vtx->add_particle_out(Part);
135 
136  if (fVerbosity > 0) {
137  Vtx->print();
138  Part->print();
139  }
140  fEvt->add_vertex(Vtx);
141  }
142 
143  fEvt->set_event_number(e.id().event());
144  fEvt->set_signal_process_id(20);
145 
146  if (fVerbosity > 0) {
147  fEvt->print();
148  }
149 
150  unique_ptr<HepMCProduct> BProduct(new HepMCProduct());
151  BProduct->addHepMCData(fEvt);
152  e.put(std::move(BProduct), "unsmeared");
153 
154  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
155  e.put(std::move(genEventInfo));
156 
157  if (fVerbosity > 0) {
158  LogDebug("CloseByParticleGunProducer") << " CloseByParticleGunProducer : Event Generation Done " << endl;
159  }
160 }
static unsigned int partIdx(const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ESHandle< HepPDT::ParticleDataTable > fPDGTable
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HepPDT::ParticleData ParticleData
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ fControlledByEta

bool edm::CloseByParticleGunProducer::fControlledByEta
protected

Definition at line 18 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fDelta

double edm::CloseByParticleGunProducer::fDelta
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fEnMax

double edm::CloseByParticleGunProducer::fEnMax
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fEnMin

double edm::CloseByParticleGunProducer::fEnMin
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fEtaMax

double edm::CloseByParticleGunProducer::fEtaMax
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fEtaMin

double edm::CloseByParticleGunProducer::fEtaMin
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fMaxEnSpread

bool edm::CloseByParticleGunProducer::fMaxEnSpread = false
protected

Definition at line 21 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fNParticles

int edm::CloseByParticleGunProducer::fNParticles
protected

Definition at line 20 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fOverlapping

bool edm::CloseByParticleGunProducer::fOverlapping = false
protected

Definition at line 23 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPartIDs

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

Definition at line 25 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPhiMax

double edm::CloseByParticleGunProducer::fPhiMax
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPhiMin

double edm::CloseByParticleGunProducer::fPhiMin
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fPointing

bool edm::CloseByParticleGunProducer::fPointing = false
protected

Definition at line 22 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fRandomShoot

bool edm::CloseByParticleGunProducer::fRandomShoot = false
protected

Definition at line 24 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fRMax

double edm::CloseByParticleGunProducer::fRMax
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fRMin

double edm::CloseByParticleGunProducer::fRMin
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fZMax

double edm::CloseByParticleGunProducer::fZMax
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().

◆ fZMin

double edm::CloseByParticleGunProducer::fZMin
protected

Definition at line 19 of file CloseByParticleGunProducer.h.

Referenced by CloseByParticleGunProducer(), and produce().