Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file g3tog4/clGeometry/src/G3toG4DetectorConstruction.cc
/// \brief Implementation of the G3toG4DetectorConstruction class
//
// $Id: G3toG4DetectorConstruction.cc,v 1.5 2006-06-29 17:20:15 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//--------------------------------------------------------------------------
// G3toG4DetectorConstruction. Most the work is Done in
@@ -34,94 +36,101 @@
// inFile
//--------------------------------------------------------------------------
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
#include "G3toG4DetectorConstruction.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4SystemOfUnits.hh"
G3toG4DetectorConstruction::G3toG4DetectorConstruction(G4String inFile){
_inFile = inFile;
G4cout << "Instantiated G3toG4DetectorConstruction using call list file \""
<< _inFile << "\"" << G4endl;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G3toG4DetectorConstruction::G3toG4DetectorConstruction(G4String inFile)
: G4VUserDetectorConstruction(),
fInFile(inFile)
{
G4cout << "Instantiated G3toG4DetectorConstruction using call list file \""
<< fInFile << "\"" << G4endl;
}
G3toG4DetectorConstruction::~G3toG4DetectorConstruction(){
// G4cout << "Deleted G3toG4DetectorConstruction..." << G4endl;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G3toG4DetectorConstruction::~G3toG4DetectorConstruction()
{
// G4cout << "Deleted G3toG4DetectorConstruction..." << G4endl;
}
G4VPhysicalVolume*
G3toG4DetectorConstruction::Construct(){
_lv = G4BuildGeom(_inFile);
//_lv = SimpleConstruct();
if (_lv != 0) {
_pv = new G4PVPlacement(0, G4ThreeVector(), _lv, _lv->GetName(), 0,
false, 0);
G4cout << "Top-level G3toG4 logical volume " << _lv->GetName() << " "
<< *(_lv -> GetVisAttributes()) << G4endl;
} else
G4cerr << "creation of logical mother failed !!!" << G4endl;
return _pv;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* G3toG4DetectorConstruction::Construct()
{
G4LogicalVolume* lv = G4BuildGeom(fInFile);
//G4LogicalVolume* lv = SimpleConstruct();
if ( lv ) {
G4VPhysicalVolume* pv
= new G4PVPlacement(0, G4ThreeVector(), lv, lv->GetName(), 0, false, 0);
G4cout << "Top-level G3toG4 logical volume " << lv->GetName() << " "
<< *(lv -> GetVisAttributes()) << G4endl;
return pv;
}
G4cerr << "creation of logical mother failed !!!" << G4endl;
return 0;
}
G4LogicalVolume*
G3toG4DetectorConstruction::SimpleConstruct(){
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LogicalVolume* G3toG4DetectorConstruction::SimpleConstruct()
{
G4String name, symbol; //a=mass of a mole;
G4double a, z, density, fractionmass; //z=mean number of protons;
G4int ncomponents; //iz=number of protons in an isotope;
// n=number of nucleons in an isotope;
a = 14.01*g/mole;
G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
G4Element* eN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
a = 16.00*g/mole;
G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
G4Element* eO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
//
// define a material from elements. case 2: mixture by fractional mass
//
density = 1.290*mg/cm3;
G4Material* Air = new G4Material(name="Air" , density, ncomponents=2);
Air->AddElement(N, fractionmass=0.7);
Air->AddElement(O, fractionmass=0.3);
G4VSolid* Mother = new G4Box("TestMother", //its name
100*cm, 100*cm, 100*cm); //its size
G4Material* air = new G4Material(name="Air" , density, ncomponents=2);
air->AddElement(eN, fractionmass=0.7);
air->AddElement(eO, fractionmass=0.3);
G4VSolid* mother = new G4Box("TestMother", //its name
100*cm, 100*cm, 100*cm); //its size
G4VSolid* Daughter = new G4Box("TestDaughter", 50*cm, 20*cm, 10*cm);
G4VSolid* daughter = new G4Box("TestDaughter", 50*cm, 20*cm, 10*cm);
G4LogicalVolume* logicMother = new G4LogicalVolume(Mother, //its solid
Air, //its material
"LTestMother");//its name
G4LogicalVolume* logicMother = new G4LogicalVolume(mother, //its solid
air, //its material
"LTestMother");//its name
G4LogicalVolume* logicDaughter = new G4LogicalVolume(Daughter, //its solid
Air, //its material
"LTestDaughter");
G4LogicalVolume* logicDaughter = new G4LogicalVolume(daughter, //its solid
air, //its material
"LTestDaughter");
// G4VPhysicalVolume* physiDaughter =
new G4PVPlacement(0,
G4ThreeVector(),
logicDaughter,
"PTestDaughter",
logicMother,
false,0);
new G4PVPlacement(0,
G4ThreeVector(),
logicDaughter,
"PTestDaughter",
logicMother,
false,0);
//
// Visualization attributes
//
logicMother->SetVisAttributes (G4VisAttributes::Invisible);
G4VisAttributes* DaughterVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
DaughterVisAtt->SetVisibility(true);
logicDaughter->SetVisAttributes(DaughterVisAtt);
G4VisAttributes* daughterVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
daughterVisAtt->SetVisibility(true);
logicDaughter->SetVisAttributes(daughterVisAtt);
return logicMother;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -1,82 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G3toG4EventAction.cc,v 1.6 2010-06-06 04:57:51 perl Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4ios.hh"
#include "G3toG4EventAction.hh"
#include "G3toG4EventActionMessenger.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4TrajectoryContainer.hh"
#include "G4UImanager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G3toG4EventAction::G3toG4EventAction()
: drawFlag("all"),eventMessenger(NULL)
{
eventMessenger = new G3toG4EventActionMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G3toG4EventAction::~G3toG4EventAction()
{
delete eventMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4EventAction::BeginOfEventAction(const G4Event*)
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4EventAction::EndOfEventAction(const G4Event* Ev)
{
G4cout << ">>> Event " << Ev->GetEventID() << G4endl;
G4TrajectoryContainer * trajectoryContainer = Ev->GetTrajectoryContainer();
G4int n_trajectories = 0;
if(trajectoryContainer){
n_trajectories = trajectoryContainer->entries();
}
G4cout << " " << n_trajectories
<< " trajectories stored in this event." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1,71 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G3toG4EventActionMessenger.cc,v 1.4 2006-06-29 17:20:21 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G3toG4EventActionMessenger.hh"
#include "G3toG4EventAction.hh"
#include "G4UIcmdWithAString.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G3toG4EventActionMessenger::G3toG4EventActionMessenger(G3toG4EventAction* EvAct)
:eventAction(EvAct)
{
DrawCmd = new G4UIcmdWithAString("/event/draw",this);
DrawCmd->SetGuidance("Draw the tracks in the event");
DrawCmd->SetGuidance(" Choice : none, charged, all (default)");
DrawCmd->SetParameterName("choice",true);
DrawCmd->SetDefaultValue("all");
DrawCmd->SetCandidates("none charged all");
DrawCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G3toG4EventActionMessenger::~G3toG4EventActionMessenger()
{
delete DrawCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4EventActionMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{
if(command == DrawCmd)
{eventAction->SetDrawFlag(newValue);}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1,306 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G3toG4PhysicsList.cc,v 1.7 2010-08-16 08:23:41 kurasige Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G3toG4PhysicsList.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4LossTableManager.hh"
#include "G4Material.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G3toG4PhysicsList::G3toG4PhysicsList(): G4VUserPhysicsList()
{
currentDefaultCut = defaultCutValue = 2.0*mm;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForProton = defaultCutValue;
SetVerboseLevel(1);
G4LossTableManager::Instance()->SetVerbose(1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G3toG4PhysicsList::~G3toG4PhysicsList()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
ConstructBosons();
ConstructLeptons();
ConstructMesons();
ConstructBaryons();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructBosons()
{
// pseudo-particles
G4Geantino::GeantinoDefinition();
G4ChargedGeantino::ChargedGeantinoDefinition();
// gamma
G4Gamma::GammaDefinition();
// optical photon
G4OpticalPhoton::OpticalPhotonDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructLeptons()
{
// leptons
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4MuonPlus::MuonPlusDefinition();
G4MuonMinus::MuonMinusDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructMesons()
{
// mesons
G4PionPlus::PionPlusDefinition();
G4PionMinus::PionMinusDefinition();
G4PionZero::PionZeroDefinition();
G4Eta::EtaDefinition();
G4EtaPrime::EtaPrimeDefinition();
G4KaonPlus::KaonPlusDefinition();
G4KaonMinus::KaonMinusDefinition();
G4KaonZero::KaonZeroDefinition();
G4AntiKaonZero::AntiKaonZeroDefinition();
G4KaonZeroLong::KaonZeroLongDefinition();
G4KaonZeroShort::KaonZeroShortDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructBaryons()
{
// barions
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructProcess()
{
AddTransportation();
ConstructEM();
ConstructGeneral();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4eMultipleScattering.hh"
#include "G4MuMultipleScattering.hh"
#include "G4hMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hIonisation.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
//gamma
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
pmanager->AddDiscreteProcess(new G4ComptonScattering());
pmanager->AddDiscreteProcess(new G4GammaConversion());
} else if (particleName == "e-") {
//electron
pmanager->AddProcess(new G4eMultipleScattering(),-1, 1,1);
pmanager->AddProcess(new G4eIonisation(), -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung(), -1, 3,3);
} else if (particleName == "e+") {
//positron
pmanager->AddProcess(new G4eMultipleScattering(),-1, 1,1);
pmanager->AddProcess(new G4eIonisation(), -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung(), -1, 3,3);
pmanager->AddProcess(new G4eplusAnnihilation(), 0,-1,4);
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
//muon
pmanager->AddProcess(new G4MuMultipleScattering(),-1, 1,1);
pmanager->AddProcess(new G4MuIonisation(), -1, 2,2);
pmanager->AddProcess(new G4MuBremsstrahlung(), -1, 3,3);
pmanager->AddProcess(new G4MuPairProduction(), -1, 4,4);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddProcess(new G4hMultipleScattering(),-1,1,1);
pmanager->AddProcess(new G4hIonisation(), -1,2,2);
}
}
}
#include "G4Decay.hh"
void G3toG4PhysicsList::ConstructGeneral()
{
// Add Decay Process
G4Decay* theDecayProcess = new G4Decay();
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theDecayProcess->IsApplicable(*particle)) {
pmanager ->AddProcess(theDecayProcess);
// set ordering for PostStepDoIt and AtRestDoIt
pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::SetCuts()
{
// reactualise cutValues
if (currentDefaultCut != defaultCutValue)
{
if(cutForGamma == currentDefaultCut) cutForGamma = defaultCutValue;
if(cutForElectron == currentDefaultCut) cutForElectron = defaultCutValue;
currentDefaultCut = defaultCutValue;
}
if (verboseLevel >0){
G4cout << "G3toG4PhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
}
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForElectron, "e+");
if (verboseLevel>0) DumpCutValuesTable();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G3toG4PhysicsList::SetCutForGamma(G4double cut)
{
ResetCuts();
cutForGamma = cut;
}
void G3toG4PhysicsList::SetCutForElectron(G4double cut)
{
ResetCuts();
cutForElectron = cut;
}
void G3toG4PhysicsList::SetCutForProton(G4double cut)
{
ResetCuts();
cutForProton = cut;
}
G4double G3toG4PhysicsList::GetCutForGamma() const
{
return cutForGamma;
}
G4double G3toG4PhysicsList::GetCutForElectron() const
{
return cutForElectron;
}
G4double G3toG4PhysicsList::GetCutForProton() const
{
return cutForGamma;
}
@@ -1,95 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G3toG4PrimaryGeneratorAction.cc,v 1.5 2006-06-29 17:20:26 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
#include "Randomize.hh"
#include "G3toG4PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
G3toG4PrimaryGeneratorAction::G3toG4PrimaryGeneratorAction(){
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="chargedgeantino");
particleGun->SetParticleDefinition(particle);
G4ThreeVector direction(0, 0, 1);
particleGun->SetParticleMomentumDirection(direction.unit());
particleGun->SetParticleEnergy(1.*GeV);
particleGun->SetParticlePosition(G4ThreeVector(0.*cm, 0.*cm,0.*cm));
}
G3toG4PrimaryGeneratorAction::~G3toG4PrimaryGeneratorAction(){
delete particleGun;
}
void
G3toG4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent){
//G4ThreeVector direction = GetRandomDirection();
//particleGun->SetParticleMomentumDirection( direction.unit() ) ;
G4cout << ">>>>>>>> Primary direction: "
<< particleGun->GetParticleMomentumDirection() << G4endl;
particleGun->GeneratePrimaryVertex(anEvent);
}
G4ThreeVector
G3toG4PrimaryGeneratorAction::GetRandomDirection() {
G4ThreeVector retval;
G4double CosTheta;
G4double SinTheta;
G4double Phi;
G4double SinPhi;
G4double CosPhi;
G4double rand;
rand = G4UniformRand();
CosTheta = 2.0*rand -1.0;
SinTheta = std::sqrt (1.-CosTheta*CosTheta);
rand = G4UniformRand();
Phi = twopi*rand;
SinPhi = std::sin (Phi);
CosPhi = std::cos (Phi);
retval.setX(SinTheta*CosPhi);
retval.setY(SinTheta*SinPhi);
retval.setZ(CosTheta);
return retval;
}
@@ -1,57 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G3toG4RunAction.cc,v 1.4 2006-06-29 17:20:29 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "G4ios.hh"
#include "G3toG4RunAction.hh"
#include "G4Run.hh"
#include "G4VVisManager.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
G3toG4RunAction::G3toG4RunAction(){
runIDcounter = 0;
}
G3toG4RunAction::~G3toG4RunAction(){;}
void G3toG4RunAction::BeginOfRunAction(const G4Run* aRun){
((G4Run *)(aRun))->SetRunID(runIDcounter++);
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
G4UImanager* UI = G4UImanager::GetUIpointer();
if (G4VVisManager::GetConcreteInstance()) {
UI->ApplyCommand("/vis~/clear/view");
UI->ApplyCommand("/vis~/draw/current");
}
}
void G3toG4RunAction::EndOfRunAction(const G4Run*){;}