Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HadDecayGenerator Class Reference

#include <G4HadDecayGenerator.hh>

+ Inheritance diagram for G4HadDecayGenerator:

Public Types

enum  Algorithm { NONE =0 , Kopylov =1 , GENBOD =2 , NBody =3 }
 

Public Member Functions

 G4HadDecayGenerator (Algorithm alg=Kopylov, G4int verbose=0)
 
 G4HadDecayGenerator (G4VHadDecayAlgorithm *alg, G4int verbose=0)
 
virtual ~G4HadDecayGenerator ()
 
void SetVerboseLevel (G4int verbose)
 
const G4StringGetAlgorithmName () const
 
G4bool Generate (G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
 
G4bool Generate (const G4ParticleDefinition *initialPD, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
 
G4bool Generate (const G4LorentzVector &initialState, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)
 

Protected Member Functions

G4bool GenerateOneBody (G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState) const
 
void ReportInvalidAlgorithm (Algorithm alg) const
 
void ReportMissingAlgorithm () const
 
void UseAlgorithm (G4VHadDecayAlgorithm *alg)
 

Protected Attributes

G4int verboseLevel
 
G4VHadDecayAlgorithmtheAlgorithm
 

Detailed Description

Definition at line 49 of file G4HadDecayGenerator.hh.

Member Enumeration Documentation

◆ Algorithm

Constructor & Destructor Documentation

◆ G4HadDecayGenerator() [1/2]

G4HadDecayGenerator::G4HadDecayGenerator ( Algorithm  alg = Kopylov,
G4int  verbose = 0 
)

Definition at line 55 of file G4HadDecayGenerator.cc.

56 : verboseLevel(verbose), theAlgorithm(0) {
57 switch (alg) {
61 case NONE: theAlgorithm = 0; break; // User may explicitly set no algorithm
62 default: ReportInvalidAlgorithm(alg);
63 }
64
65 if (verboseLevel) {
66 G4cout << " >>> G4HadDecayGenerator";
67 if (theAlgorithm) G4cout << " using " << theAlgorithm->GetName();
68 G4cout << G4endl;
69 }
70}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VHadDecayAlgorithm * theAlgorithm
void ReportInvalidAlgorithm(Algorithm alg) const
const G4String & GetName() const

◆ G4HadDecayGenerator() [2/2]

G4HadDecayGenerator::G4HadDecayGenerator ( G4VHadDecayAlgorithm alg,
G4int  verbose = 0 
)

Definition at line 72 of file G4HadDecayGenerator.cc.

74 : verboseLevel(verbose), theAlgorithm(alg) {
75 if (verboseLevel) {
76 G4cout << " >>> G4HadDecayGenerator";
77 if (theAlgorithm) G4cout << " using " << theAlgorithm->GetName();
78 G4cout << G4endl;
79 }
80}

◆ ~G4HadDecayGenerator()

G4HadDecayGenerator::~G4HadDecayGenerator ( )
virtual

Definition at line 82 of file G4HadDecayGenerator.cc.

82 {
83 delete theAlgorithm;
84 theAlgorithm = 0;
85}

Member Function Documentation

◆ Generate() [1/3]

G4bool G4HadDecayGenerator::Generate ( const G4LorentzVector initialState,
const std::vector< G4double > &  masses,
std::vector< G4LorentzVector > &  finalState 
)

Definition at line 150 of file G4HadDecayGenerator.cc.

152 {
153 if (verboseLevel)
154 G4cout << " >>> G4HadDecayGenerator::Generate (frame)" << G4endl;
155
156 G4bool good = Generate(initialState.m(), masses, finalState);
157 if (good) {
158 G4ThreeVector bv = initialState.boostVector();
159 for (size_t i=0; i<finalState.size(); i++) {
160 finalState[i].boost(bv);
161 }
162 }
163
164 return good;
165}
bool G4bool
Definition: G4Types.hh:86
Hep3Vector boostVector() const
G4bool Generate(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)

◆ Generate() [2/3]

G4bool G4HadDecayGenerator::Generate ( const G4ParticleDefinition initialPD,
const std::vector< G4double > &  masses,
std::vector< G4LorentzVector > &  finalState 
)

Definition at line 138 of file G4HadDecayGenerator.cc.

140 {
141 if (verboseLevel)
142 G4cout << " >>> G4HadDecayGenerator::Generate (particle)" << G4endl;
143
144 return (initialPD && Generate(initialPD->GetPDGMass(), masses, finalState));
145}

◆ Generate() [3/3]

G4bool G4HadDecayGenerator::Generate ( G4double  initialMass,
const std::vector< G4double > &  masses,
std::vector< G4LorentzVector > &  finalState 
)

Definition at line 120 of file G4HadDecayGenerator.cc.

122 {
123 if (verboseLevel)
124 G4cout << " >>> G4HadDecayGenerator::Generate (mass)" << G4endl;
125
127
128 if (masses.size() == 1U)
129 return GenerateOneBody(initialMass, masses, finalState);
130
131 theAlgorithm->Generate(initialMass, masses, finalState);
132 return !finalState.empty(); // Generator failure returns empty state
133}
void ReportMissingAlgorithm() const
G4bool GenerateOneBody(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState) const
void Generate(G4double initialMass, const std::vector< G4double > &masses, std::vector< G4LorentzVector > &finalState)

Referenced by Generate().

◆ GenerateOneBody()

G4bool G4HadDecayGenerator::GenerateOneBody ( G4double  initialMass,
const std::vector< G4double > &  masses,
std::vector< G4LorentzVector > &  finalState 
) const
protected

Definition at line 170 of file G4HadDecayGenerator.cc.

173 {
174 if (verboseLevel>1)
175 G4cout << " >>> G4HadDecayGenerator::GenerateOneBody" << G4endl;
176
177 // Initialization and sanity checks
178 finalState.clear();
179
180 if (masses.size() != 1U) return false; // Should not have been called
181 if (std::fabs(initialMass-masses[0]) > eV) return false;
182
183 if (verboseLevel>2) G4cout << " finalState mass = " << masses[0] << G4endl;
184
185 finalState.push_back(G4LorentzVector(0.,0.,0.,masses[0]));
186 return true;
187}
CLHEP::HepLorentzVector G4LorentzVector

Referenced by Generate().

◆ GetAlgorithmName()

const G4String & G4HadDecayGenerator::GetAlgorithmName ( ) const

Definition at line 111 of file G4HadDecayGenerator.cc.

111 {
112 static const G4String& none = "NONE";
113 return (theAlgorithm ? theAlgorithm->GetName() : none);
114}

◆ ReportInvalidAlgorithm()

void G4HadDecayGenerator::ReportInvalidAlgorithm ( Algorithm  alg) const
protected

Definition at line 90 of file G4HadDecayGenerator.cc.

90 {
91 if (verboseLevel)
92 G4cerr << "G4HadDecayGenerator: bad algorithm code " << alg << G4endl;
93
94 throw G4HadronicException(__FILE__, __LINE__, "Invalid algorithm code");
95}
G4GLOB_DLL std::ostream G4cerr

Referenced by G4HadDecayGenerator().

◆ ReportMissingAlgorithm()

void G4HadDecayGenerator::ReportMissingAlgorithm ( ) const
protected

Definition at line 97 of file G4HadDecayGenerator.cc.

97 {
98 if (verboseLevel)
99 G4cerr << "G4HadDecayGenerator: no algorithm specified" << G4endl;
100
101 throw G4HadronicException(__FILE__, __LINE__, "Null algorithm pointer");
102}

Referenced by Generate().

◆ SetVerboseLevel()

void G4HadDecayGenerator::SetVerboseLevel ( G4int  verbose)

Definition at line 106 of file G4HadDecayGenerator.cc.

106 {
107 verboseLevel = verbose;
109}
virtual void SetVerboseLevel(G4int verbose)

◆ UseAlgorithm()

void G4HadDecayGenerator::UseAlgorithm ( G4VHadDecayAlgorithm alg)
inlineprotected

Definition at line 100 of file G4HadDecayGenerator.hh.

100{ theAlgorithm = alg; }

Member Data Documentation

◆ theAlgorithm

◆ verboseLevel


The documentation for this class was generated from the following files: