CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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

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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::ParticleDataTable
fPDGTable
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 33 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(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 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > fPartIDs
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
FlatEGunASCIIWriter::~FlatEGunASCIIWriter ( )
override

Definition at line 51 of file FlatEGunASCIIWriter.cc.

References fEvt, and fOutStream.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 70 of file FlatEGunASCIIWriter.cc.

References funct::abs(), funct::cos(), relval_parameters_module::energy, PVValHelper::eta, funct::exp(), fCurrentEvent, fEvt, fMaxE, fMaxEta, fMaxPhi, fMinE, fMinEta, fMinPhi, fOutStream, fPartIDs, fPDGTable, GenParticle::GenParticle, ResonanceBuilder::mass, AlCaHLTBitMon_ParallelJobs::p, funct::sin(), mathSSE::sqrt(), and theta().

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 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
std::vector< int > fPartIDs
ESHandle< HepPDT::ParticleDataTable > fPDGTable
T sqrt(T t)
Definition: SSEVec.h:19
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
void FlatEGunASCIIWriter::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 60 of file FlatEGunASCIIWriter.cc.

References Exception, fOutFileName, and fOutStream.

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 }
HepMC::IO_GenEvent * fOutStream
void FlatEGunASCIIWriter::beginRun ( const edm::Run r,
const EventSetup es 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file FlatEGunASCIIWriter.cc.

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

58 { es.getData(fPDGTable); }
ESHandle< HepPDT::ParticleDataTable > fPDGTable
bool getData(T &iHolder) const
Definition: EventSetup.h:128

Member Data Documentation

int edm::FlatEGunASCIIWriter::fCurrentEvent
private

Definition at line 65 of file FlatEGunASCIIWriter.h.

Referenced by analyze().

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

Definition at line 57 of file FlatEGunASCIIWriter.h.

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

double edm::FlatEGunASCIIWriter::fMaxE
private

Definition at line 54 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxEta
private

Definition at line 50 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMaxPhi
private

Definition at line 52 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinE
private

Definition at line 53 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinEta
private

Definition at line 49 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

double edm::FlatEGunASCIIWriter::fMinPhi
private

Definition at line 51 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

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

Definition at line 62 of file FlatEGunASCIIWriter.h.

Referenced by beginJob().

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

Definition at line 63 of file FlatEGunASCIIWriter.h.

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

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

Definition at line 48 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and FlatEGunASCIIWriter().

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

Definition at line 60 of file FlatEGunASCIIWriter.h.

Referenced by analyze(), and beginRun().