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::FlatRandomPtGunProducer Class Reference

#include <FlatRandomPtGunProducer.h>

Inheritance diagram for edm::FlatRandomPtGunProducer:
edm::BaseFlatGunProducer edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 FlatRandomPtGunProducer (const ParameterSet &pset)
 
virtual void produce (Event &e, const EventSetup &es)
 
virtual ~FlatRandomPtGunProducer ()
 
- 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 fMaxPt
 
double fMinPt
 

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 FlatRandomPtGunProducer.h.

Constructor & Destructor Documentation

FlatRandomPtGunProducer::FlatRandomPtGunProducer ( const ParameterSet pset)

Definition at line 21 of file FlatRandomPtGunProducer.cc.

References fMaxPt, fMinPt, and edm::ParameterSet::getParameter().

21  :
23 {
24 
25 
26  ParameterSet defpset ;
27  ParameterSet pgun_params =
28  pset.getParameter<ParameterSet>("PGunParameters") ;
29 
30  fMinPt = pgun_params.getParameter<double>("MinPt");
31  fMaxPt = pgun_params.getParameter<double>("MaxPt");
32 
33  produces<HepMCProduct>();
34  produces<GenEventInfoProduct>();
35 }
T getParameter(std::string const &) const
BaseFlatGunProducer(const ParameterSet &)
FlatRandomPtGunProducer::~FlatRandomPtGunProducer ( )
virtual

Definition at line 37 of file FlatRandomPtGunProducer.cc.

38 {
39  // no need to cleanup GenEvent memory - done in HepMCProduct
40 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 42 of file FlatRandomPtGunProducer.cc.

References abs, funct::cos(), gather_cfg::cout, relval_parameters_module::energy, eta(), edm::EventID::event(), funct::exp(), edm::BaseFlatGunProducer::fAddAntiParticle, edm::BaseFlatGunProducer::fEvt, edm::BaseFlatGunProducer::fMaxEta, edm::BaseFlatGunProducer::fMaxPhi, fMaxPt, edm::BaseFlatGunProducer::fMinEta, edm::BaseFlatGunProducer::fMinPhi, fMinPt, 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().

43 {
44 
45  if ( fVerbosity > 0 )
46  {
47  cout << " FlatRandomPtGunProducer : Begin New Event Generation" << endl ;
48  }
49  // event loop (well, another step in it...)
50 
51  // no need to clean up GenEvent memory - done in HepMCProduct
52  //
53 
54  // here re-create fEvt (memory)
55  //
56  fEvt = new HepMC::GenEvent() ;
57 
58  // now actualy, cook up the event from PDGTable and gun parameters
59  //
60  // 1st, primary vertex
61  //
62  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
63 
64  // loop over particles
65  //
66  int barcode = 1 ;
67  for (unsigned int ip=0; ip<fPartIDs.size(); ++ip)
68  {
69 
70  double pt = fRandomGenerator->fire(fMinPt, fMaxPt) ;
71  double eta = fRandomGenerator->fire(fMinEta, fMaxEta) ;
72  double phi = fRandomGenerator->fire(fMinPhi, fMaxPhi) ;
73  int PartID = fPartIDs[ip] ;
74  const HepPDT::ParticleData*
75  PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
76  double mass = PData->mass().value() ;
77  double theta = 2.*atan(exp(-eta)) ;
78  double mom = pt/sin(theta) ;
79  double px = pt*cos(phi) ;
80  double py = pt*sin(phi) ;
81  double pz = mom*cos(theta) ;
82  double energy2= mom*mom + mass*mass ;
83  double energy = sqrt(energy2) ;
84  HepMC::FourVector p(px,py,pz,energy) ;
85  HepMC::GenParticle* Part =
86  new HepMC::GenParticle(p,PartID,1);
87  Part->suggest_barcode( barcode ) ;
88  barcode++ ;
89  Vtx->add_particle_out(Part);
90 
91  if ( fAddAntiParticle )
92  {
93  HepMC::FourVector ap(-px,-py,-pz,energy) ;
94  int APartID = -PartID ;
95  if ( PartID == 22 || PartID == 23 )
96  {
97  APartID = PartID ;
98  }
99  HepMC::GenParticle* APart =
100  new HepMC::GenParticle(ap,APartID,1);
101  APart->suggest_barcode( barcode ) ;
102  barcode++ ;
103  Vtx->add_particle_out(APart) ;
104  }
105 
106  }
107 
108  fEvt->add_vertex(Vtx) ;
109  fEvt->set_event_number(e.id().event()) ;
110  fEvt->set_signal_process_id(20) ;
111 
112  if ( fVerbosity > 0 )
113  {
114  fEvt->print() ;
115  }
116 
117  auto_ptr<HepMCProduct> BProduct(new HepMCProduct()) ;
118  BProduct->addHepMCData( fEvt );
119  e.put(BProduct);
120 
121  auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
122  e.put(genEventInfo);
123 
124  if ( fVerbosity > 0 )
125  {
126  // for testing purpose only
127  // fEvt->print() ; // prints empty info after it's made into edm::Event
128  cout << " FlatRandomPtGunProducer : Event Generation Done " << endl;
129  }
130 }
EventNumber_t event() const
Definition: EventID.h:44
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
#define abs(x)
Definition: mlp_lapack.h:159
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::FlatRandomPtGunProducer::fMaxPt
private

Definition at line 29 of file FlatRandomPtGunProducer.h.

Referenced by FlatRandomPtGunProducer(), and produce().

double edm::FlatRandomPtGunProducer::fMinPt
private

Definition at line 28 of file FlatRandomPtGunProducer.h.

Referenced by FlatRandomPtGunProducer(), and produce().