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

#include <FlatEGunASCIIWriter.h>

Inheritance diagram for edm::FlatEGunASCIIWriter:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (edm::Run &, const EventSetup &)
 
 FlatEGunASCIIWriter (const edm::ParameterSet &)
 
virtual ~FlatEGunASCIIWriter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

int fCurrentEvent
 
HepMC::GenEvent * fEvt
 
double fMaxE
 
double fMaxEta
 
double fMaxPhi
 
double fMinE
 
double fMinEta
 
double fMinPhi
 
std::string fOutFileName
 
HepMC::IO_GenEvent * fOutStream
 
std::vector< int > fPartIDs
 
ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 35 of file FlatEGunASCIIWriter.h.

Constructor & Destructor Documentation

FlatEGunASCIIWriter::FlatEGunASCIIWriter ( const edm::ParameterSet pset)
explicit

Definition at line 37 of file FlatEGunASCIIWriter.cc.

References fMaxE, fMaxEta, fMaxPhi, fMinE, fMinEta, fMinPhi, fPartIDs, and edm::ParameterSet::getParameter().

38  : fEvt(0),
39  fOutFileName( pset.getUntrackedParameter<string>("OutFileName","FlatEGunHepMC.dat") ),
40  fCurrentEvent(0)
41 {
42 
43  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ;
44  fPartIDs = pgun_params.getParameter< vector<int> >("PartID");
45  fMinEta = pgun_params.getParameter<double>("MinEta");
46  fMaxEta = pgun_params.getParameter<double>("MaxEta");
47  fMinPhi = pgun_params.getParameter<double>("MinPhi");
48  fMaxPhi = pgun_params.getParameter<double>("MaxPhi");
49  fMinE = pgun_params.getParameter<double>("MinE");
50  fMaxE = pgun_params.getParameter<double>("MaxE");
51 
52 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > fPartIDs
FlatEGunASCIIWriter::~FlatEGunASCIIWriter ( )
virtual

Definition at line 54 of file FlatEGunASCIIWriter.cc.

References fEvt, fOutStream, and NULL.

55 {
56 
57  if ( fEvt != NULL ) delete fEvt ;
58  if( fOutStream) delete fOutStream;
59 
60 }
#define NULL
Definition: scimark2.h:8
HepMC::IO_GenEvent * fOutStream

Member Function Documentation

void FlatEGunASCIIWriter::analyze ( const edm::Event ,
const edm::EventSetup  
)
virtual

Implements edm::EDAnalyzer.

Definition at line 81 of file FlatEGunASCIIWriter.cc.

References abs, funct::cos(), relval_parameters_module::energy, eta(), create_public_lumi_plots::exp, fCurrentEvent, fEvt, fMaxE, fMaxEta, fMaxPhi, fMinE, fMinEta, fMinPhi, fOutStream, fPartIDs, fPDGTable, configurableAnalysis::GenParticle, scaleCards::mass, NULL, AlCaHLTBitMon_ParallelJobs::p, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, phi, hitfit::return, funct::sin(), mathSSE::sqrt(), and theta().

83 {
84 
85  // clean up GenEvent memory : also deletes all vtx/part in it
86  //
87  if ( fEvt != NULL ) delete fEvt ;
88 
89  // here re-create fEvt (memory)
90  fEvt = new HepMC::GenEvent() ;
91 
92  // now actualy, cook up the event from PDGTable and gun parameters
93  //
94  //HepMC::GenVertex* Vtx = new HepMC::GenVertex( CLHEP::HepLorentzVector(0.,0.,0.) );
95  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.) );
96 
97  // loop over particles
98  //
99  for ( unsigned int ip=0; ip<fPartIDs.size(); ip++ )
100  {
101  double energy = CLHEP::RandFlat::shoot( fMinE, fMaxE ) ;
102  double eta = CLHEP::RandFlat::shoot( fMinEta, fMaxEta ) ;
103  double phi = CLHEP::RandFlat::shoot( fMinPhi, fMaxPhi ) ;
104  const HepPDT::ParticleData*
105  PData = fPDGTable->particle(HepPDT::ParticleID(abs(fPartIDs[ip]))) ;
106  double mass = PData->mass().value() ;
107  double mom2 = energy*energy - mass*mass ;
108  double mom = 0. ;
109  if ( mom2 > 0. ) mom = sqrt(mom2) ;
110  double theta = 2.*atan(exp(-eta)) ;
111  double px = mom*sin(theta)*cos(phi) ;
112  double py = mom*sin(theta)*sin(phi) ;
113  double pz = mom*cos(theta) ;
114  //CLHEP::Hep3Vector p(px,py,pz) ;
115  //HepMC::GenParticle* Part =
116  // new HepMC::GenParticle(CLHEP::HepLorentzVector(p,energy),fPartIDs[ip],1);
117  HepMC::FourVector p(px,py,pz,energy);
118  HepMC::GenParticle* Part =
119  new HepMC::GenParticle(p,fPartIDs[ip],1);
120  Vtx->add_particle_out(Part);
121  }
122  fEvt->add_vertex( Vtx ) ;
123  fEvt->set_event_number( fCurrentEvent+1 ) ;
124  fEvt->set_signal_process_id(20) ;
125 
126  // for testing purpose only
127  // fEvt->print() ;
128 
129  fOutStream->write_event( fEvt );
130 
131  fCurrentEvent++ ;
132 
133  return ;
134 
135 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
std::vector< int > fPartIDs
T eta() const
ESHandle< HepPDT::ParticleDataTable > fPDGTable
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
HepPDT::ParticleData ParticleData
HepMC::IO_GenEvent * fOutStream
tuple mass
Definition: scaleCards.py:27
Definition: DDAxes.h:10
void FlatEGunASCIIWriter::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file FlatEGunASCIIWriter.cc.

References edm::hlt::Exception, fOutFileName, fOutStream, and hitfit::return.

70 {
71  fOutStream = new HepMC::IO_GenEvent( fOutFileName.c_str() );
72  if ( fOutStream->rdstate() == std::ios::failbit ) {
73  throw cms::Exception("FileNotOpen", "FlatEGunASCIIWriter::beginJob()")
74  << "File " << fOutFileName << " was not open.\n";
75  }
76 
77  return ;
78 
79 }
HepMC::IO_GenEvent * fOutStream
void FlatEGunASCIIWriter::beginRun ( edm::Run r,
const EventSetup es 
)
virtual

Definition at line 62 of file FlatEGunASCIIWriter.cc.

References fPDGTable, and edm::EventSetup::getData().

63 {
64 
65  es.getData( fPDGTable );
66 
67 }
void getData(T &iHolder) const
Definition: EventSetup.h:67
ESHandle< HepPDT::ParticleDataTable > fPDGTable

Member Data Documentation

int edm::FlatEGunASCIIWriter::fCurrentEvent
private

Definition at line 73 of file FlatEGunASCIIWriter.h.

Referenced by analyze().

HepMC::GenEvent* edm::FlatEGunASCIIWriter::fEvt
private

Definition at line 64 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and ~FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxE
private

Definition at line 61 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxEta
private

Definition at line 57 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxPhi
private

Definition at line 59 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinE
private

Definition at line 60 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinEta
private

Definition at line 56 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinPhi
private

Definition at line 58 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

std::string edm::FlatEGunASCIIWriter::fOutFileName
private

Definition at line 70 of file FlatEGunASCIIWriter.h.

Referenced by beginJob().

HepMC::IO_GenEvent* edm::FlatEGunASCIIWriter::fOutStream
private

Definition at line 71 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), beginJob(), and ~FlatEGunASCIIWriter().

std::vector<int> edm::FlatEGunASCIIWriter::fPartIDs
private

Definition at line 55 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

ESHandle<HepPDT::ParticleDataTable> edm::FlatEGunASCIIWriter::fPDGTable
private

Definition at line 68 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and beginRun().