111 if (definition ==
nullptr)
117 if (verbosityLevel > 1)
119 G4cout <<
" NumberOfParticlesToBeGenerated: "
120 << NumberOfParticlesToBeGenerated <<
G4endl;
123 part_prop_t& pp = ParticleProperties.Get();
126 pp.position = posGenerator->GenerateOne();
131 for (
G4int i=0; i<NumberOfParticlesToBeGenerated; ++i)
134 pp.momentum_direction = angGenerator->GenerateOne();
137 pp.energy = eneGenerator->GenerateOne(definition);
139 if (verbosityLevel >= 2)
141 G4cout <<
"Creating primaries and assigning to vertex" <<
G4endl;
146 G4double mass = definition->GetPDGMass();
148 particle->SetKineticEnergy(pp.energy );
149 particle->SetMass( mass );
150 particle->SetMomentumDirection( pp.momentum_direction );
151 particle->SetCharge( charge );
152 particle->SetPolarization(polarization.x(),
155 if (verbosityLevel > 1)
157 G4cout <<
"Particle name: " << definition->GetParticleName() <<
G4endl;
160 G4cout <<
" Direction: " << pp.momentum_direction <<
G4endl;
165 G4double weight = eneGenerator->GetWeight()*biasRndm->GetBiasWeight();
167 if(eneGenerator->IfApplyEnergyWeight())
169 weight *= eneGenerator->GetArbEneWeight(pp.energy);
174 particle->SetWeight(weight);
175 vertex->SetPrimary(particle);
182 if (verbosityLevel > 1)
G4ThreeVector G4ParticleMomentum
G4double GetPDGCharge() const
void GeneratePrimaryVertex(G4Event *evt) override
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
~G4SingleParticleSource() override