CMS 3D CMS Logo

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

#include <FlatRandomEThetaGunProducer.h>

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

Public Member Functions

 FlatRandomEThetaGunProducer (const ParameterSet &)
 
 ~FlatRandomEThetaGunProducer () 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 fMaxE
 
double fMinE
 
- 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 FlatRandomEThetaGunProducer.h.

Constructor & Destructor Documentation

FlatRandomEThetaGunProducer::FlatRandomEThetaGunProducer ( const ParameterSet pset)

Definition at line 22 of file FlatRandomEThetaGunProducer.cc.

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

22  :
24 
25  edm::ParameterSet defpset ;
26  edm::ParameterSet pgun_params =
27  pset.getParameter<edm::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>("unsmeared");
35  produces<GenEventInfoProduct>();
36 
37 // edm::LogInfo("FlatThetaGun") << "Internal FlatRandomEThetaGun is initialzed"
38 // << "\nIt is going to generate "
39 // << remainingEvents() << " events";
40 }
T getParameter(std::string const &) const
FlatBaseThetaGunProducer(const ParameterSet &)
FlatRandomEThetaGunProducer::~FlatRandomEThetaGunProducer ( )
override

Definition at line 42 of file FlatRandomEThetaGunProducer.cc.

42 {}

Member Function Documentation

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

Definition at line 44 of file FlatRandomEThetaGunProducer.cc.

References funct::abs(), funct::cos(), edm::EventID::event(), edm::FlatBaseThetaGunProducer::fAddAntiParticle, edm::FlatBaseThetaGunProducer::fEvt, fMaxE, edm::FlatBaseThetaGunProducer::fMaxPhi, edm::FlatBaseThetaGunProducer::fMaxTheta, fMinE, edm::FlatBaseThetaGunProducer::fMinPhi, edm::FlatBaseThetaGunProducer::fMinTheta, edm::FlatBaseThetaGunProducer::fPartIDs, edm::FlatBaseThetaGunProducer::fPDGTable, edm::FlatBaseThetaGunProducer::fVerbosity, particlelevel_cff::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), edm::EventBase::id(), LogDebug, 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 
46  if ( fVerbosity > 0 ) {
47  LogDebug("FlatThetaGun") << "FlatRandomEThetaGunProducer : Begin New Event Generation";
48  }
49 
51  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
52 
53  // event loop (well, another step in it...)
54 
55  // no need to clean up GenEvent memory - done in HepMCProduct
56 
57  // here re-create fEvt (memory)
58  //
59  fEvt = new HepMC::GenEvent() ;
60 
61  // now actualy, cook up the event from PDGTable and gun parameters
62  //
63 
64  // 1st, primary vertex
65  //
66  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
67 
68  // loop over particles
69  //
70  int barcode = 1;
71  for (unsigned int ip=0; ip<fPartIDs.size(); ip++) {
72  double energy = CLHEP::RandFlat::shoot(engine, fMinE, fMaxE);
73  double theta = CLHEP::RandFlat::shoot(engine, fMinTheta, fMaxTheta);
74  double phi = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi);
75  int PartID = fPartIDs[ip] ;
76  const HepPDT::ParticleData*
77  PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
78  double mass = PData->mass().value() ;
79  double mom2 = energy*energy - mass*mass ;
80  double mom = (mom2 > 0. ? std::sqrt(mom2) : 0.);
81  double px = mom*sin(theta)*cos(phi) ;
82  double py = mom*sin(theta)*sin(phi) ;
83  double pz = mom*cos(theta) ;
84 
85  HepMC::FourVector p(px,py,pz,energy) ;
86  HepMC::GenParticle* Part = new HepMC::GenParticle(p,PartID,1);
87  Part->suggest_barcode( barcode ) ;
88  barcode++ ;
89  Vtx->add_particle_out(Part);
90 
91  if ( fAddAntiParticle ) {
92  HepMC::FourVector ap(-px,-py,-pz,energy) ;
93  int APartID = -PartID ;
94  if ( PartID == 22 || PartID == 23 ) {
95  APartID = PartID ;
96  }
97  HepMC::GenParticle* APart = new HepMC::GenParticle(ap,APartID,1);
98  APart->suggest_barcode( barcode ) ;
99  barcode++ ;
100  Vtx->add_particle_out(APart) ;
101  }
102 
103  }
104  fEvt->add_vertex(Vtx) ;
105  fEvt->set_event_number(e.id().event()) ;
106  fEvt->set_signal_process_id(20) ;
107 
108 
109  if ( fVerbosity > 0 ) {
110  fEvt->print() ;
111  }
112 
113  std::unique_ptr<HepMCProduct> BProduct(new HepMCProduct()) ;
114  BProduct->addHepMCData( fEvt );
115  e.put(std::move(BProduct), "unsmeared");
116 
117  std::unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
119 
120  if ( fVerbosity > 0 ) {
121  LogDebug("FlatThetaGun") << "FlatRandomEThetaGunProducer : Event Generation Done";
122  }
123 }
#define LogDebug(id)
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::FlatRandomEThetaGunProducer::fMaxE
protected

Definition at line 23 of file FlatRandomEThetaGunProducer.h.

Referenced by FlatRandomEThetaGunProducer(), and produce().

double edm::FlatRandomEThetaGunProducer::fMinE
protected

Definition at line 22 of file FlatRandomEThetaGunProducer.h.

Referenced by FlatRandomEThetaGunProducer(), and produce().