CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
edm::FlatRandomEGunSource Class Reference

#include <FlatRandomEGunSource.h>

Inheritance diagram for edm::FlatRandomEGunSource:
edm::BaseFlatGunSource edm::GeneratedInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 FlatRandomEGunSource (const ParameterSet &, const InputSourceDescription &)
 
virtual ~FlatRandomEGunSource ()
 
- Public Member Functions inherited from edm::BaseFlatGunSource
 BaseFlatGunSource (const ParameterSet &, const InputSourceDescription &)
 
void beginRun (edm::Run &r, const edm::EventSetup &)
 
virtual ~BaseFlatGunSource ()
 
- Public Member Functions inherited from edm::GeneratedInputSource
 GeneratedInputSource (ParameterSet const &pset, InputSourceDescription const &desc)
 
virtual ~GeneratedInputSource ()
 
- Public Member Functions inherited from edm::ConfigurableInputSource
 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ConfigurableInputSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp, bool cleaningUpAfterException)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi (bool merge, HistoryAppender &historyAppender)
 Read next luminosity block. More...
 
void readAndCacheRun (bool merge, HistoryAppender &historyAppender)
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Protected Attributes

double fMaxE
 
double fMinE
 
- Protected Attributes inherited from edm::BaseFlatGunSource
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
 

Private Member Functions

virtual bool produce (Event &e)
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ConfigurableInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ConfigurableInputSource
void reallyReadEvent ()
 
void setEventNumber (EventNumber_t e)
 
void setTime (TimeValue_t t)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipaleventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Definition at line 15 of file FlatRandomEGunSource.h.

Constructor & Destructor Documentation

FlatRandomEGunSource::FlatRandomEGunSource ( const ParameterSet pset,
const InputSourceDescription desc 
)

Definition at line 19 of file FlatRandomEGunSource.cc.

References gather_cfg::cout, fMaxE, fMinE, edm::ParameterSet::getUntrackedParameter(), and edm::InputSource::remainingEvents().

20  :
21  BaseFlatGunSource(pset, desc)
22 {
23 
24  ParameterSet defpset ;
25  // ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ;
26  ParameterSet pgun_params =
27  pset.getUntrackedParameter<ParameterSet>("PGunParameters",defpset) ;
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.getUntrackedParameter<double>("MinE",0.99);
32  fMaxE = pgun_params.getUntrackedParameter<double>("MaxE",1.01);
33 
34  produces<HepMCProduct>();
35 
36  cout << "Internal FlatRandomEGun is initialzed" << endl ;
37  cout << "It is going to generate " << remainingEvents() << "events" << endl ;
38 
39 }
T getUntrackedParameter(std::string const &, T const &) const
BaseFlatGunSource(const ParameterSet &, const InputSourceDescription &)
int remainingEvents() const
Definition: InputSource.h:170
tuple cout
Definition: gather_cfg.py:121
FlatRandomEGunSource::~FlatRandomEGunSource ( )
virtual

Definition at line 41 of file FlatRandomEGunSource.cc.

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

Member Function Documentation

bool FlatRandomEGunSource::produce ( Event e)
privatevirtual

Implements edm::ConfigurableInputSource.

Definition at line 46 of file FlatRandomEGunSource.cc.

References abs, funct::cos(), gather_cfg::cout, relval_parameters_module::energy, eta(), edm::ConfigurableInputSource::event(), create_public_lumi_plots::exp, edm::BaseFlatGunSource::fAddAntiParticle, edm::BaseFlatGunSource::fEvt, fMaxE, edm::BaseFlatGunSource::fMaxEta, edm::BaseFlatGunSource::fMaxPhi, fMinE, edm::BaseFlatGunSource::fMinEta, edm::BaseFlatGunSource::fMinPhi, edm::BaseFlatGunSource::fPartIDs, edm::BaseFlatGunSource::fPDGTable, edm::BaseFlatGunSource::fRandomGenerator, edm::BaseFlatGunSource::fVerbosity, configurableAnalysis::GenParticle, scaleCards::mass, AlCaHLTBitMon_ParallelJobs::p, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, phi, edm::Event::put(), funct::sin(), mathSSE::sqrt(), and theta().

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

Member Data Documentation

double edm::FlatRandomEGunSource::fMaxE
protected

Definition at line 31 of file FlatRandomEGunSource.h.

Referenced by FlatRandomEGunSource(), and produce().

double edm::FlatRandomEGunSource::fMinE
protected

Definition at line 30 of file FlatRandomEGunSource.h.

Referenced by FlatRandomEGunSource(), and produce().