test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void produce (Event &e, const EventSetup &es) override
 
virtual ~FlatRandomEGunProducer ()
 
- 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
 
virtual ~BaseFlatGunProducer ()
 
- Public Member Functions inherited from edm::one::EDProducer< one::WatchRuns, EndRunProducer >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
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 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::ParticleDataTable
fPDGTable
 
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 &)
tuple cout
Definition: gather_cfg.py:145
FlatRandomEGunProducer::~FlatRandomEGunProducer ( )
virtual

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 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 49 of file FlatRandomEGunProducer.cc.

References funct::abs(), funct::cos(), gather_cfg::cout, relval_parameters_module::energy, eta, edm::EventID::event(), create_public_lumi_plots::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, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), edm::EventBase::id(), ResonanceBuilder::mass, AlCaHLTBitMon_ParallelJobs::p, phi(), 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  auto_ptr<HepMCProduct> BProduct(new HepMCProduct()) ;
135  BProduct->addHepMCData( fEvt );
136  e.put(BProduct, "unsmeared");
137 
138  auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
139  e.put(genEventInfo);
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
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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:59
StreamID streamID() const
Definition: Event.h:80
tuple cout
Definition: gather_cfg.py:145

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().