CMS 3D CMS Logo

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

#include <GaussRandomPThetaGunProducer.h>

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

Public Member Functions

 GaussRandomPThetaGunProducer (const ParameterSet &)
 
 ~GaussRandomPThetaGunProducer () override
 
- Public Member Functions inherited from edm::FlatBaseThetaGunProducer
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endRun (const edm::Run &r, const edm::EventSetup &) override
 
void endRunProduce (edm::Run &r, const edm::EventSetup &) override
 
 FlatBaseThetaGunProducer (const ParameterSet &)
 
 ~FlatBaseThetaGunProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< one::WatchRuns, EndRunProducer >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
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)
 
 ~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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 fMeanP
 
double fMeanTheta
 
double fSigmaP
 
double fSigmaTheta
 
- Protected Attributes inherited from edm::FlatBaseThetaGunProducer
bool fAddAntiParticle
 
HepMC::GenEventfEvt
 
double fMaxPhi
 
double fMaxTheta
 
double fMinPhi
 
double fMinTheta
 
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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 8 of file GaussRandomPThetaGunProducer.h.

Constructor & Destructor Documentation

GaussRandomPThetaGunProducer::GaussRandomPThetaGunProducer ( const ParameterSet pset)

Definition at line 25 of file GaussRandomPThetaGunProducer.cc.

References edm::FlatBaseThetaGunProducer::fMaxTheta, fMeanP, fMeanTheta, edm::FlatBaseThetaGunProducer::fMinTheta, fSigmaP, fSigmaTheta, and edm::ParameterSet::getParameter().

25  : FlatBaseThetaGunProducer(pset) {
26 
27  edm::ParameterSet defpset ;
28  edm::ParameterSet pgun_params =
29  pset.getParameter<edm::ParameterSet>("PGunParameters") ;
30 
31  // doesn't seem necessary to check if pset is empty - if this
32  // is the case, default values will be taken for params
33  fMeanP = pgun_params.getParameter<double>("MeanP");
34  fSigmaP = pgun_params.getParameter<double>("SigmaP");
35  fMeanTheta = 0.5 * (fMinTheta + fMaxTheta);
36  fSigmaTheta = 0.5 * (fMaxTheta - fMinTheta);
37 
38  produces<HepMCProduct>("unsmeared");
39  produces<GenEventInfoProduct>();
40 }
T getParameter(std::string const &) const
FlatBaseThetaGunProducer(const ParameterSet &)
GaussRandomPThetaGunProducer::~GaussRandomPThetaGunProducer ( )
override

Definition at line 42 of file GaussRandomPThetaGunProducer.cc.

42 {}

Member Function Documentation

void GaussRandomPThetaGunProducer::produce ( edm::Event e,
const EventSetup es 
)
overrideprivate

Definition at line 44 of file GaussRandomPThetaGunProducer.cc.

References funct::abs(), funct::cos(), gather_cfg::cout, edm::EventID::event(), edm::FlatBaseThetaGunProducer::fAddAntiParticle, edm::FlatBaseThetaGunProducer::fEvt, edm::FlatBaseThetaGunProducer::fMaxPhi, fMeanP, fMeanTheta, edm::FlatBaseThetaGunProducer::fMinPhi, edm::FlatBaseThetaGunProducer::fPartIDs, edm::FlatBaseThetaGunProducer::fPDGTable, fSigmaP, fSigmaTheta, edm::FlatBaseThetaGunProducer::fVerbosity, particlelevel_cff::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), edm::EventBase::id(), ResonanceBuilder::mass, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, source_particleGun_cfi::ParticleID, CastorDigiValidation::PartID, phi, edm::Event::put(), funct::sin(), mathSSE::sqrt(), edm::Event::streamID(), and theta().

44  {
45 #ifdef DebugLog
46  if ( fVerbosity >= 0 )
47  std::cout << "GaussRandomPThetaGunProducer : Begin New Event Generation\n";
48 #endif
50  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
51 
52  // event loop (well, another step in it...)
53 
54  // no need to clean up GenEvent memory - done in HepMCProduct
55 
56  // here re-create fEvt (memory)
57  //
58  fEvt = new HepMC::GenEvent() ;
59 
60  // now actualy, cook up the event from PDGTable and gun parameters
61  //
62 
63  // 1st, primary vertex
64  //
65  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
66 
67  // loop over particles
68  //
69  int barcode = 1;
70  for (unsigned int ip=0; ip<fPartIDs.size(); ip++) {
71  double mom = CLHEP::RandGaussQ::shoot(engine, fMeanP, fSigmaP);
72  double theta = CLHEP::RandGaussQ::shoot(engine, fMeanTheta, fSigmaTheta);
73  double phi = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi);
74  int PartID = fPartIDs[ip] ;
75  const HepPDT::ParticleData*
76  PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
77  double mass = PData->mass().value() ;
78  double energy = sqrt(mom*mom + mass*mass) ;
79  double px = mom*sin(theta)*cos(phi) ;
80  double py = mom*sin(theta)*sin(phi) ;
81  double pz = mom*cos(theta) ;
82 
83  HepMC::FourVector p(px,py,pz,energy) ;
84  HepMC::GenParticle* Part = new HepMC::GenParticle(p,PartID,1);
85  Part->suggest_barcode( barcode ) ;
86  barcode++ ;
87  Vtx->add_particle_out(Part);
88 
89  if ( fAddAntiParticle ) {
90  HepMC::FourVector ap(-px,-py,-pz,energy) ;
91  int APartID = -PartID ;
92  if ( PartID == 22 || PartID == 23 ) {
93  APartID = PartID ;
94  }
95  HepMC::GenParticle* APart = new HepMC::GenParticle(ap,APartID,1);
96  APart->suggest_barcode( barcode ) ;
97  barcode++ ;
98  Vtx->add_particle_out(APart) ;
99  }
100 
101  }
102  fEvt->add_vertex(Vtx) ;
103  fEvt->set_event_number(e.id().event()) ;
104  fEvt->set_signal_process_id(20) ;
105 
106 
107 #ifdef DebugLog
108  if ( fVerbosity >= 0 ) fEvt->print() ;
109 #endif
110 
111  std::unique_ptr<HepMCProduct> BProduct(new HepMCProduct()) ;
112  BProduct->addHepMCData( fEvt );
113  e.put(std::move(BProduct), "unsmeared");
114 
115  std::unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
117 
118 #ifdef DebugLog
119  if ( fVerbosity >= 0 )
120  std::cout << "GaussRandomPThetaGunProducer : Event Generation Done\n";
121 #endif
122 }
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Geom::Theta< T > theta() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
T sqrt(T t)
Definition: SSEVec.h:18
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
edm::EventID id() const
Definition: EventBase.h:59
StreamID streamID() const
Definition: Event.h:95
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

double edm::GaussRandomPThetaGunProducer::fMeanP
protected

Definition at line 22 of file GaussRandomPThetaGunProducer.h.

Referenced by GaussRandomPThetaGunProducer(), and produce().

double edm::GaussRandomPThetaGunProducer::fMeanTheta
protected

Definition at line 24 of file GaussRandomPThetaGunProducer.h.

Referenced by GaussRandomPThetaGunProducer(), and produce().

double edm::GaussRandomPThetaGunProducer::fSigmaP
protected

Definition at line 23 of file GaussRandomPThetaGunProducer.h.

Referenced by GaussRandomPThetaGunProducer(), and produce().

double edm::GaussRandomPThetaGunProducer::fSigmaTheta
protected

Definition at line 25 of file GaussRandomPThetaGunProducer.h.

Referenced by GaussRandomPThetaGunProducer(), and produce().