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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 FlatRandomEGunProducer (const ParameterSet &pset)
 
virtual void produce (Event &e, const EventSetup &es)
 
virtual ~FlatRandomEGunProducer ()
 
- Public Member Functions inherited from edm::BaseFlatGunProducer
 BaseFlatGunProducer (const ParameterSet &)
 
void beginRun (edm::Run &r, const edm::EventSetup &)
 
void endRun (edm::Run &r, const edm::EventSetup &)
 
virtual ~BaseFlatGunProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

double fMaxE
 
double fMinE
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 
- 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
 
CLHEP::HepRandomEngine & fRandomEngine
 
CLHEP::RandFlat * fRandomGenerator
 
int fVerbosity
 

Detailed Description

Definition at line 15 of file FlatRandomEGunProducer.h.

Constructor & Destructor Documentation

FlatRandomEGunProducer::FlatRandomEGunProducer ( const ParameterSet pset)

Definition at line 20 of file FlatRandomEGunProducer.cc.

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

20  :
22 {
23 
24  ParameterSet defpset ;
25  // ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ;
26  ParameterSet pgun_params =
27  pset.getParameter<ParameterSet>("PGunParameters") ;
28 
29  // doesn't seem necessary to check if pset is empty - if this
30  // is the case, default values will be taken for params
31  fMinE = pgun_params.getParameter<double>("MinE");
32  fMaxE = pgun_params.getParameter<double>("MaxE");
33 
34  produces<HepMCProduct>();
35  produces<GenEventInfoProduct>();
36 
37  cout << "Internal FlatRandomEGun is initialzed" << endl ;
38 // cout << "It is going to generate " << remainingEvents() << "events" << endl ;
39 
40 }
T getParameter(std::string const &) const
BaseFlatGunProducer(const ParameterSet &)
tuple cout
Definition: gather_cfg.py:41
FlatRandomEGunProducer::~FlatRandomEGunProducer ( )
virtual

Definition at line 42 of file FlatRandomEGunProducer.cc.

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

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 47 of file FlatRandomEGunProducer.cc.

References abs, funct::cos(), gather_cfg::cout, relval_parameters_module::energy, eta(), edm::EventID::event(), funct::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::fRandomGenerator, edm::BaseFlatGunProducer::fVerbosity, configurableAnalysis::GenParticle, edm::EventBase::id(), L1TEmulatorMonitor_cff::p, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, phi, edm::Event::put(), funct::sin(), mathSSE::sqrt(), and theta().

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

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