emitter representation

This commit is contained in:
AndreaRigoni
2026-03-19 13:57:10 +00:00
parent ca5f576b99
commit 1e6e3ae4f4
9 changed files with 261 additions and 9 deletions

View File

@@ -29,14 +29,14 @@ EmitterPrimary::EmitterPrimary()
// Configuriamo le proprietà iniziali della particella
fParticleGun->SetParticleDefinition(particle);
// Impostiamo la direzione della quantità di moto (es. lungo l'asse Z)
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., -1.));
// Impostiamo l'energia cinetica a 1 GeV
fParticleGun->SetParticleEnergy(1.0 * GeV);
// Impostiamo la posizione di partenza (origine)
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., 10. * m));
// Initial position and direction through AffineTransform
// 10m on Z axis, pointing towards origin
this->SetPosition(Vector3f(0, 0, 10000.0));
// Default orientation is identity (pointing along -Z if we rotate the puppet accordingly)
// But fParticleGun defaults are set here and overridden in GeneratePrimaries
}
EmitterPrimary::~EmitterPrimary() {
@@ -45,9 +45,14 @@ EmitterPrimary::~EmitterPrimary() {
}
void EmitterPrimary::GeneratePrimaries(G4Event *anEvent) {
// Questo metodo viene invocato all'inizio di ogni evento.
// Qui potresti anche aggiungere una randomizzazione della posizione o
// dell'energia.
// Use position and direction from AffineTransform
Vector3f pos = this->GetPosition();
// Assume default direction is along the -Z axis of the local frame
Vector4f dir4 = this->GetWorldMatrix() * Vector4f(0, 0, -1, 0);
Vector3f dir = dir4.head<3>().normalized();
fParticleGun->SetParticlePosition(G4ThreeVector(pos(0), pos(1), pos(2)));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(dir(0), dir(1), dir(2)));
fParticleGun->GeneratePrimaryVertex(anEvent);
}