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 edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &, const EventSetup &) override
 
 FlatEGunASCIIWriter (const edm::ParameterSet &)
 
virtual ~FlatEGunASCIIWriter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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::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 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 34 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  
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 81 of file FlatEGunASCIIWriter.cc.

References funct::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, NULL, AlCaHLTBitMon_ParallelJobs::p, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, phi, reco::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 NULL
Definition: scimark2.h:8
std::vector< int > fPartIDs
T eta() const
ESHandle< HepPDT::ParticleDataTable > fPDGTable
T sqrt(T t)
Definition: SSEVec.h:48
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
HepMC::IO_GenEvent * fOutStream
return(e1-e2)*(e1-e2)+dp *dp
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 reco::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
return(e1-e2)*(e1-e2)+dp *dp
void FlatEGunASCIIWriter::beginRun ( const edm::Run r,
const EventSetup es 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

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 72 of file FlatEGunASCIIWriter.h.

Referenced by analyze().

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

Definition at line 63 of file FlatEGunASCIIWriter.h.

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

double edm::FlatEGunASCIIWriter::fMaxE
private

Definition at line 60 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxEta
private

Definition at line 56 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxPhi
private

Definition at line 58 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinE
private

Definition at line 59 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinEta
private

Definition at line 55 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinPhi
private

Definition at line 57 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

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

Definition at line 69 of file FlatEGunASCIIWriter.h.

Referenced by beginJob().

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

Definition at line 70 of file FlatEGunASCIIWriter.h.

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

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

Definition at line 54 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

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

Definition at line 67 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and beginRun().