CMS 3D CMS Logo

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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginRun (const edm::Run &, const EventSetup &) override
 
 FlatEGunASCIIWriter (const edm::ParameterSet &)
 
 ~FlatEGunASCIIWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

Private Attributes

int fCurrentEvent
 
HepMC::GenEventfEvt
 
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::ParticleDataTablefPDGTable
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 33 of file FlatEGunASCIIWriter.h.

Constructor & Destructor Documentation

◆ FlatEGunASCIIWriter()

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

Definition at line 37 of file FlatEGunASCIIWriter.cc.

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

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

◆ ~FlatEGunASCIIWriter()

FlatEGunASCIIWriter::~FlatEGunASCIIWriter ( )
override

Definition at line 51 of file FlatEGunASCIIWriter.cc.

51  {
52  if (fEvt != nullptr)
53  delete fEvt;
54  if (fOutStream)
55  delete fOutStream;
56 }

References fEvt, and fOutStream.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 70 of file FlatEGunASCIIWriter.cc.

70  {
71  // clean up GenEvent memory : also deletes all vtx/part in it
72  //
73  if (fEvt != nullptr)
74  delete fEvt;
75 
76  // here re-create fEvt (memory)
77  fEvt = new HepMC::GenEvent();
78 
79  // now actualy, cook up the event from PDGTable and gun parameters
80  //
81  //HepMC::GenVertex* Vtx = new HepMC::GenVertex( CLHEP::HepLorentzVector(0.,0.,0.) );
82  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
83 
84  // loop over particles
85  //
86  for (unsigned int ip = 0; ip < fPartIDs.size(); ip++) {
87  double energy = CLHEP::RandFlat::shoot(fMinE, fMaxE);
88  double eta = CLHEP::RandFlat::shoot(fMinEta, fMaxEta);
89  double phi = CLHEP::RandFlat::shoot(fMinPhi, fMaxPhi);
90  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(fPartIDs[ip])));
91  double mass = PData->mass().value();
92  double mom2 = energy * energy - mass * mass;
93  double mom = 0.;
94  if (mom2 > 0.)
95  mom = sqrt(mom2);
96  double theta = 2. * atan(exp(-eta));
97  double px = mom * sin(theta) * cos(phi);
98  double py = mom * sin(theta) * sin(phi);
99  double pz = mom * cos(theta);
100  //CLHEP::Hep3Vector p(px,py,pz) ;
101  //HepMC::GenParticle* Part =
102  // new HepMC::GenParticle(CLHEP::HepLorentzVector(p,energy),fPartIDs[ip],1);
103  HepMC::FourVector p(px, py, pz, energy);
104  HepMC::GenParticle* Part = new HepMC::GenParticle(p, fPartIDs[ip], 1);
105  Vtx->add_particle_out(Part);
106  }
107  fEvt->add_vertex(Vtx);
108  fEvt->set_event_number(fCurrentEvent + 1);
109  fEvt->set_signal_process_id(20);
110 
111  // for testing purpose only
112  // fEvt->print() ;
113 
114  fOutStream->write_event(fEvt);
115 
116  fCurrentEvent++;
117 
118  return;
119 }

References funct::abs(), funct::cos(), HCALHighEnergyHPDFilter_cfi::energy, PVValHelper::eta, JetChargeProducer_cfi::exp, fCurrentEvent, fEvt, fMaxE, fMaxEta, fMaxPhi, fMinE, fMinEta, fMinPhi, fOutStream, fPartIDs, fPDGTable, GenParticle::GenParticle, EgHLTOffHistBins_cfi::mass, AlCaHLTBitMon_ParallelJobs::p, LHEGenericFilter_cfi::ParticleID, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), mathSSE::sqrt(), and theta().

◆ beginJob()

void FlatEGunASCIIWriter::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 60 of file FlatEGunASCIIWriter.cc.

60  {
61  fOutStream = new HepMC::IO_GenEvent(fOutFileName);
62  if (fOutStream->rdstate() == std::ios::failbit) {
63  throw cms::Exception("FileNotOpen", "FlatEGunASCIIWriter::beginJob()")
64  << "File " << fOutFileName << " was not open.\n";
65  }
66 
67  return;
68 }

References Exception, fOutFileName, and fOutStream.

◆ beginRun()

void FlatEGunASCIIWriter::beginRun ( const edm::Run r,
const EventSetup es 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file FlatEGunASCIIWriter.cc.

58 { es.getData(fPDGTable); }

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

Member Data Documentation

◆ fCurrentEvent

int edm::FlatEGunASCIIWriter::fCurrentEvent
private

Definition at line 65 of file FlatEGunASCIIWriter.h.

Referenced by analyze().

◆ fEvt

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

Definition at line 57 of file FlatEGunASCIIWriter.h.

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

◆ fMaxE

double edm::FlatEGunASCIIWriter::fMaxE
private

Definition at line 54 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fMaxEta

double edm::FlatEGunASCIIWriter::fMaxEta
private

Definition at line 50 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fMaxPhi

double edm::FlatEGunASCIIWriter::fMaxPhi
private

Definition at line 52 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fMinE

double edm::FlatEGunASCIIWriter::fMinE
private

Definition at line 53 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fMinEta

double edm::FlatEGunASCIIWriter::fMinEta
private

Definition at line 49 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fMinPhi

double edm::FlatEGunASCIIWriter::fMinPhi
private

Definition at line 51 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fOutFileName

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

Definition at line 62 of file FlatEGunASCIIWriter.h.

Referenced by beginJob().

◆ fOutStream

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

Definition at line 63 of file FlatEGunASCIIWriter.h.

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

◆ fPartIDs

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

Definition at line 48 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

◆ fPDGTable

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

Definition at line 60 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and beginRun().

edm::FlatEGunASCIIWriter::fMinE
double fMinE
Definition: FlatEGunASCIIWriter.h:53
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::FlatEGunASCIIWriter::fOutStream
HepMC::IO_GenEvent * fOutStream
Definition: FlatEGunASCIIWriter.h:63
edm::FlatEGunASCIIWriter::fOutFileName
std::string fOutFileName
Definition: FlatEGunASCIIWriter.h:62
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PVValHelper::eta
Definition: PVValidationHelpers.h:69
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
edm::FlatEGunASCIIWriter::fMinPhi
double fMinPhi
Definition: FlatEGunASCIIWriter.h:51
edm::FlatEGunASCIIWriter::fMaxPhi
double fMaxPhi
Definition: FlatEGunASCIIWriter.h:52
edm::ParameterSet
Definition: ParameterSet.h:36
PVValHelper::phi
Definition: PVValidationHelpers.h:68
edm::FlatEGunASCIIWriter::fPartIDs
std::vector< int > fPartIDs
Definition: FlatEGunASCIIWriter.h:48
edm::FlatEGunASCIIWriter::fMinEta
double fMinEta
Definition: FlatEGunASCIIWriter.h:49
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:113
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
edm::FlatEGunASCIIWriter::fEvt
HepMC::GenEvent * fEvt
Definition: FlatEGunASCIIWriter.h:57
edm::FlatEGunASCIIWriter::fPDGTable
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Definition: FlatEGunASCIIWriter.h:60
Exception
Definition: hltDiff.cc:246
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
edm::FlatEGunASCIIWriter::fMaxE
double fMaxE
Definition: FlatEGunASCIIWriter.h:54
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
LHEGenericFilter_cfi.ParticleID
ParticleID
Definition: LHEGenericFilter_cfi.py:6
edm::FlatEGunASCIIWriter::fMaxEta
double fMaxEta
Definition: FlatEGunASCIIWriter.h:50
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::FlatEGunASCIIWriter::fCurrentEvent
int fCurrentEvent
Definition: FlatEGunASCIIWriter.h:65