CMS 3D CMS Logo

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

#include <FlatRandomEGunProducer.h>

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

Public Member Functions

 FlatRandomEGunProducer (const ParameterSet &pset)
 
void produce (Event &e, const EventSetup &es) override
 
 ~FlatRandomEGunProducer () 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 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double fMaxE
 
double fMinE
 

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 ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, 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)
 
- Protected Attributes inherited from edm::BaseFlatGunProducer
bool fAddAntiParticle
 
HepMC::GenEvent * fEvt
 
double fMaxEta
 
double fMaxPhi
 
double fMinEta
 
double fMinPhi
 
std::vector< int > fPartIDs
 
ESHandle< HepPDT::ParticleDataTablefPDGTable
 
int fVerbosity
 

Detailed Description

Definition at line 15 of file FlatRandomEGunProducer.h.

Constructor & Destructor Documentation

FlatRandomEGunProducer::FlatRandomEGunProducer ( const ParameterSet pset)

Definition at line 22 of file FlatRandomEGunProducer.cc.

References gather_cfg::cout, fMaxE, fMinE, and edm::ParameterSet::getParameter().

22  :
24 {
25 
26  ParameterSet defpset ;
27  // ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ;
28  ParameterSet pgun_params =
29  pset.getParameter<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  fMinE = pgun_params.getParameter<double>("MinE");
34  fMaxE = pgun_params.getParameter<double>("MaxE");
35 
36  produces<HepMCProduct>("unsmeared");
37  produces<GenEventInfoProduct>();
38 
39  cout << "Internal FlatRandomEGun is initialzed" << endl ;
40 // cout << "It is going to generate " << remainingEvents() << "events" << endl ;
41 
42 }
T getParameter(std::string const &) const
BaseFlatGunProducer(const ParameterSet &)
FlatRandomEGunProducer::~FlatRandomEGunProducer ( )
override

Definition at line 44 of file FlatRandomEGunProducer.cc.

45 {
46  // no need to cleanup fEvt since it's done in HepMCProduct
47 }

Member Function Documentation

void FlatRandomEGunProducer::produce ( Event e,
const EventSetup es 
)
override

Definition at line 49 of file FlatRandomEGunProducer.cc.

References funct::abs(), funct::cos(), gather_cfg::cout, PVValHelper::eta, edm::EventID::event(), JetChargeProducer_cfi::exp, edm::BaseFlatGunProducer::fAddAntiParticle, edm::BaseFlatGunProducer::fEvt, fMaxE, edm::BaseFlatGunProducer::fMaxEta, edm::BaseFlatGunProducer::fMaxPhi, fMinE, edm::BaseFlatGunProducer::fMinEta, edm::BaseFlatGunProducer::fMinPhi, edm::BaseFlatGunProducer::fPartIDs, edm::BaseFlatGunProducer::fPDGTable, edm::BaseFlatGunProducer::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, edm::Event::put(), funct::sin(), mathSSE::sqrt(), edm::Event::streamID(), and theta().

50 {
52  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
53 
54  if ( fVerbosity > 0 )
55  {
56  cout << " FlatRandomEGunProducer : Begin New Event Generation" << endl ;
57  }
58 
59  // event loop (well, another step in it...)
60 
61  // no need to clean up GenEvent memory - done in HepMCProduct
62 
63  // here re-create fEvt (memory)
64  //
65  fEvt = new HepMC::GenEvent() ;
66 
67  // now actualy, cook up the event from PDGTable and gun parameters
68  //
69 
70  // 1st, primary vertex
71  //
72  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
73 
74  // loop over particles
75  //
76  int barcode = 1;
77  for (unsigned int ip=0; ip<fPartIDs.size(); ip++)
78  {
79  double energy = CLHEP::RandFlat::shoot(engine, fMinE, fMaxE) ;
80  double eta = CLHEP::RandFlat::shoot(engine, fMinEta, fMaxEta) ;
81  double phi = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi) ;
82  int PartID = fPartIDs[ip] ;
83  const HepPDT::ParticleData*
84  PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
85  double mass = PData->mass().value() ;
86  double mom2 = energy*energy - mass*mass ;
87  double mom = 0. ;
88  if (mom2 > 0.)
89  {
90  mom = sqrt(mom2) ;
91  }
92  else
93  {
94  mom = 0. ;
95  }
96  double theta = 2.*atan(exp(-eta)) ;
97  double px = mom*sin(theta)*cos(phi) ;
98  double py = mom*sin(theta)*sin(phi) ;
99  double pz = mom*cos(theta) ;
100 
101  HepMC::FourVector p(px,py,pz,energy) ;
102  HepMC::GenParticle* Part =
103  new HepMC::GenParticle(p,PartID,1);
104  Part->suggest_barcode( barcode ) ;
105  barcode++ ;
106  Vtx->add_particle_out(Part);
107 
108  if ( fAddAntiParticle )
109  {
110  HepMC::FourVector ap(-px,-py,-pz,energy) ;
111  int APartID = -PartID ;
112  if ( PartID == 22 || PartID == 23 )
113  {
114  APartID = PartID ;
115  }
116  HepMC::GenParticle* APart =
117  new HepMC::GenParticle(ap,APartID,1);
118  APart->suggest_barcode( barcode ) ;
119  barcode++ ;
120  Vtx->add_particle_out(APart) ;
121  }
122 
123  }
124  fEvt->add_vertex(Vtx) ;
125  fEvt->set_event_number(e.id().event()) ;
126  fEvt->set_signal_process_id(20) ;
127 
128 
129  if ( fVerbosity > 0 )
130  {
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));
140 
141  if ( fVerbosity > 0 )
142  {
143  // for testing purpose only
144  //fEvt->print() ; // for some strange reason, it prints NO event info
145  // after it's been put into edm::Event...
146  cout << " FlatRandomEGunProducer : Event Generation Done " << endl;
147  }
148 }
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ESHandle< HepPDT::ParticleDataTable > fPDGTable
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
std::vector< int > fPartIDs
HepPDT::ParticleData ParticleData
edm::EventID id() const
Definition: EventBase.h:60
StreamID streamID() const
Definition: Event.h:96
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

double edm::FlatRandomEGunProducer::fMaxE
private

Definition at line 29 of file FlatRandomEGunProducer.h.

Referenced by FlatRandomEGunProducer(), and produce().

double edm::FlatRandomEGunProducer::fMinE
private

Definition at line 28 of file FlatRandomEGunProducer.h.

Referenced by FlatRandomEGunProducer(), and produce().