Import Geant4 3.0.0 source tree
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
// ****************************************
|
||||
// * *
|
||||
// * BrachyDetectorConstruction.cc *
|
||||
// * *
|
||||
// ****************************************
|
||||
|
||||
#include "BrachyWaterBoxROGeometry.hh"
|
||||
#include "BrachyWaterBoxSD.hh"
|
||||
#include "BrachyDetectorConstruction.hh"
|
||||
|
||||
#include "G4CSGSolid.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4MaterialPropertyVector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4MaterialPropertiesTable.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4MaterialTable.hh"
|
||||
#include "G4Element.hh"
|
||||
#include "G4ElementTable.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
//....
|
||||
|
||||
BrachyDetectorConstruction::BrachyDetectorConstruction(G4String &SDName,G4int NumVoxelX,G4int NumVoxelZ) :
|
||||
m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ),m_BoxDimX(30*cm),m_BoxDimY(30*cm),m_BoxDimZ(30*cm)
|
||||
{
|
||||
m_SDName = SDName;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyDetectorConstruction::~BrachyDetectorConstruction()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
|
||||
{
|
||||
// Define required materials
|
||||
|
||||
G4double A; // atomic mass
|
||||
G4double Z; // atomic number
|
||||
G4double d; // density
|
||||
|
||||
// General elements
|
||||
|
||||
A = 1.01*g/mole;
|
||||
Z = 1;
|
||||
G4Element* elH = new G4Element ("Hydrogen","H",Z,A);
|
||||
|
||||
A = 14.01*g/mole;
|
||||
Z = 7;
|
||||
G4Element* elN = new G4Element("Nitrogen","N",Z,A);
|
||||
|
||||
A = 16.00*g/mole;
|
||||
Z = 8;
|
||||
G4Element* elO = new G4Element("Oxygen","O",Z,A);
|
||||
|
||||
// Elements for source capsule and cable
|
||||
|
||||
A = 54.94*g/mole;
|
||||
Z = 25;
|
||||
G4Element* elMn = new G4Element("Manganese","Mn",Z,A);
|
||||
|
||||
A = 28.09*g/mole;
|
||||
Z = 14;
|
||||
G4Element* elSi = new G4Element("Silicon","Si",Z,A);
|
||||
|
||||
A = 52.00*g/mole;
|
||||
Z = 24;
|
||||
G4Element* elCr = new G4Element("Chromium","Cr",Z,A);
|
||||
|
||||
A = 58.70*g/mole;
|
||||
Z = 28;
|
||||
G4Element* elNi = new G4Element("Nickel","Ni",Z,A);
|
||||
|
||||
A = 55.85*g/mole;
|
||||
Z = 26;
|
||||
G4Element* elFe = new G4Element("Iron","Fe",Z,A);
|
||||
|
||||
// Lead material
|
||||
A = 207.19*g/mole;
|
||||
Z = 82;
|
||||
d = 11.35*g/cm3;
|
||||
G4Material* matPb = new G4Material("Lead",Z,A,d);
|
||||
|
||||
// Air material
|
||||
d = 1.290*mg/cm3;
|
||||
G4Material* matAir = new G4Material("Air",d,2);
|
||||
matAir->AddElement(elN,0.7);
|
||||
matAir->AddElement(elO,0.3);
|
||||
|
||||
// Water
|
||||
d = 1.000*g/cm3;
|
||||
G4Material* matH2O = new G4Material("Water",d,2);
|
||||
matH2O->AddElement(elH,2);
|
||||
matH2O->AddElement(elO,1);
|
||||
|
||||
// Iridium (Medical Physics, Vol 25, No 10, Oct 1998)
|
||||
d = 22.42*g/cm3;
|
||||
A = 191.96260*g/mole ;
|
||||
Z = 77;
|
||||
G4Material* matIr192 = new G4Material("Iridium",Z,A,d);
|
||||
|
||||
// Stainless steel (Medical Physics, Vol 25, No 10, Oct 1998)
|
||||
d = 8.02*g/cm3 ;
|
||||
G4Material* matSteel = new G4Material("Stainless steel",d,5);
|
||||
matSteel->AddElement(elMn, 0.02);
|
||||
matSteel->AddElement(elSi, 0.01);
|
||||
matSteel->AddElement(elCr, 0.19);
|
||||
matSteel->AddElement(elNi, 0.10);
|
||||
matSteel->AddElement(elFe, 0.68);
|
||||
|
||||
// Volumes
|
||||
|
||||
// EXPERIMENTAL HALL (our world volume)
|
||||
G4double ExpHall_x = 4.0*m;
|
||||
G4double ExpHall_y = 4.0*m;
|
||||
G4double ExpHall_z = 4.0*m;
|
||||
|
||||
G4Box* ExpHall = new G4Box("ExpHall",ExpHall_x,ExpHall_y,ExpHall_z);
|
||||
G4LogicalVolume* ExpHallLog = new G4LogicalVolume(ExpHall,matAir,"ExpHallLog",0,0,0);
|
||||
G4VPhysicalVolume* ExpHallPhys = new G4PVPlacement(0,G4ThreeVector(),"ExpHallPhys",ExpHallLog,0,false,0);
|
||||
|
||||
// Water Box
|
||||
|
||||
G4Box* WaterBox = new G4Box("WaterBox",m_BoxDimX/2,m_BoxDimY/2,m_BoxDimZ/2);
|
||||
G4LogicalVolume* WaterBoxLog = new G4LogicalVolume(WaterBox,matH2O,"WaterBoxLog",0,0,0);
|
||||
G4VPhysicalVolume* WaterBoxPhys = new G4PVPlacement(0,G4ThreeVector(),WaterBoxLog,"WaterBoxPhys",ExpHallLog,false,0);
|
||||
|
||||
// Capsule main body
|
||||
|
||||
G4Tubs* Capsule = new G4Tubs("Capsule",0,0.55*mm,3.725*mm,0.*deg,360.*deg);
|
||||
G4LogicalVolume* CapsuleLog = new G4LogicalVolume(Capsule,matSteel,"CapsuleLog");
|
||||
G4VPhysicalVolume* CapsulePhys = new G4PVPlacement(0,G4ThreeVector(0,0,-1.975),CapsuleLog,"CapsulePhys",WaterBoxLog,false,0);
|
||||
|
||||
// Capsule tip
|
||||
|
||||
G4Sphere* CapsuleTip = new G4Sphere("CapsuleTip",0.*mm,0.55*mm,0.*deg,360.*deg,0.*deg,90.*deg);
|
||||
G4LogicalVolume* CapsuleTipLog = new G4LogicalVolume(CapsuleTip,matSteel,"CapsuleTipLog");
|
||||
G4VPhysicalVolume* CapsuleTipPhys = new G4PVPlacement(0,G4ThreeVector(0.,0.,1.75*mm),CapsuleTipLog,"CapsuleTipPhys",WaterBoxLog,false,0);
|
||||
|
||||
// Iridium core
|
||||
|
||||
G4Tubs* IridiumCore = new G4Tubs("IrCore",0,0.30*mm,1.75*mm,0.*deg,360.*deg);
|
||||
G4LogicalVolume* IridiumCoreLog = new G4LogicalVolume(IridiumCore,matIr192,"IridiumCoreLog");
|
||||
G4VPhysicalVolume* IridiumCorePhys = new G4PVPlacement(0,G4ThreeVector(),IridiumCoreLog,"IridiumCorePhys",CapsuleLog,false,0);
|
||||
|
||||
// Sensitive Detector and ReadOut geometry definition
|
||||
|
||||
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
|
||||
BrachyWaterBoxSD* pWaterBoxSD = new BrachyWaterBoxSD(m_SDName,m_NumVoxelX,m_NumVoxelZ);
|
||||
if(pWaterBoxSD)
|
||||
{
|
||||
G4String ROGeometryName = "WaterBoxROGeometry";
|
||||
BrachyWaterBoxROGeometry* pWaterBoxROGeometry = new BrachyWaterBoxROGeometry(ROGeometryName,m_BoxDimX,m_BoxDimZ,m_NumVoxelX,m_NumVoxelZ);
|
||||
pWaterBoxROGeometry->BuildROGeometry();
|
||||
pWaterBoxSD->SetROgeometry(pWaterBoxROGeometry);
|
||||
pSDManager->AddNewDetector(pWaterBoxSD);
|
||||
WaterBoxLog->SetSensitiveDetector(pWaterBoxSD);
|
||||
CapsuleLog->SetSensitiveDetector(pWaterBoxSD);
|
||||
CapsuleTipLog->SetSensitiveDetector(pWaterBoxSD);
|
||||
IridiumCoreLog->SetSensitiveDetector(pWaterBoxSD);
|
||||
}
|
||||
|
||||
return ExpHallPhys;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// *******************************
|
||||
// * *
|
||||
// * BrachyEventAction.cc *
|
||||
// * *
|
||||
// *******************************
|
||||
|
||||
#include "BrachyEventAction.hh"
|
||||
#include "BrachyWaterBoxHit.hh"
|
||||
#include "BrachyWaterBoxSD.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4VHitsCollection.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
//....
|
||||
|
||||
BrachyEventAction::BrachyEventAction(G4float *pVoxel,G4int NumVoxelX,G4int NumVoxelZ) :
|
||||
m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
|
||||
{
|
||||
m_HitsCollectionID = -1;
|
||||
m_pVoxel = pVoxel;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyEventAction::~BrachyEventAction()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyEventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
|
||||
if(m_HitsCollectionID == -1)
|
||||
m_HitsCollectionID = pSDManager->GetCollectionID("WaterBoxHitsCollection");
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyEventAction::EndOfEventAction(const G4Event* evt)
|
||||
{
|
||||
if(m_HitsCollectionID < 0)
|
||||
return;
|
||||
|
||||
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
|
||||
BrachyWaterBoxHitsCollection* CHC = NULL;
|
||||
|
||||
if(HCE)
|
||||
CHC = (BrachyWaterBoxHitsCollection*)(HCE->GetHC(m_HitsCollectionID));
|
||||
|
||||
if(CHC)
|
||||
{
|
||||
if(m_pVoxel)
|
||||
{
|
||||
// Fill voxel matrix with energy deposit data
|
||||
G4int HitCount = CHC->entries();
|
||||
for (G4int h=0; h<HitCount; h++)
|
||||
m_pVoxel[((*CHC)[h])->GetZID() + ((*CHC)[h])->GetXID()*m_NumVoxelX] += (*CHC)[h]->GetEdep();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// **********************************
|
||||
// * *
|
||||
// * BrachyPhysicsList.cc *
|
||||
// * *
|
||||
// **********************************
|
||||
|
||||
#include "BrachyPhysicsList.hh"
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleWithCuts.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
BrachyPhysicsList::BrachyPhysicsList(): G4VUserPhysicsList()
|
||||
{
|
||||
defaultCutValue = 1*mm;
|
||||
cutForGamma = defaultCutValue;
|
||||
cutForElectron = defaultCutValue;
|
||||
cutForPositron = defaultCutValue;
|
||||
|
||||
SetVerboseLevel(1);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
BrachyPhysicsList::~BrachyPhysicsList()
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::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();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::ConstructBosons()
|
||||
{
|
||||
// gamma
|
||||
G4Gamma::GammaDefinition();
|
||||
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::ConstructLeptons()
|
||||
{
|
||||
// leptons
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::ConstructProcess()
|
||||
{
|
||||
AddTransportation();
|
||||
ConstructEM();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
#include "G4MultipleScattering.hh"
|
||||
// gamma
|
||||
#include "G4LowEnergyRayleigh.hh"
|
||||
#include "G4LowEnergyPhotoElectric.hh"
|
||||
#include "G4LowEnergyCompton.hh"
|
||||
#include "G4LowEnergyGammaConversion.hh"
|
||||
// e-
|
||||
#include "G4LowEnergyIonisation.hh"
|
||||
#include "G4LowEnergyBremsstrahlung.hh"
|
||||
// e+
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::ConstructEM()
|
||||
{
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
//processes
|
||||
lowePhot = new G4LowEnergyPhotoElectric("LowEnPhotoElec");
|
||||
loweIon = new G4LowEnergyIonisation("LowEnergyIoni");
|
||||
loweBrem = new G4LowEnergyBremsstrahlung("LowEnBrem");
|
||||
|
||||
if (particleName == "gamma") {
|
||||
//gamma
|
||||
pmanager->AddDiscreteProcess(new G4LowEnergyRayleigh);
|
||||
pmanager->AddDiscreteProcess(lowePhot);
|
||||
pmanager->AddDiscreteProcess(new G4LowEnergyCompton);
|
||||
pmanager->AddDiscreteProcess(new G4LowEnergyGammaConversion);
|
||||
|
||||
} else if (particleName == "e-") {
|
||||
//electron
|
||||
pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);
|
||||
pmanager->AddProcess(loweIon, -1, 2,2);
|
||||
pmanager->AddProcess(loweBrem, -1,-1,3);
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1,-1,3);
|
||||
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetCuts()
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "BrachyPhysicsList::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(cutForPositron, "e+");
|
||||
|
||||
SetCutValueForOthers(defaultCutValue);
|
||||
|
||||
if (verboseLevel>0) DumpCutValuesTable();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetGammaLowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "BrachyPhysicsList::SetCuts:";
|
||||
G4cout << "Gamma cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
}
|
||||
|
||||
G4Gamma::SetEnergyRange(lowcut,1e5);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetElectronLowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
|
||||
G4cout << "BrachyPhysicsList::SetCuts:";
|
||||
G4cout << "Electron cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
|
||||
}
|
||||
|
||||
G4Electron::SetEnergyRange(lowcut,1e5);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetGELowLimit(G4double lowcut)
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "BrachyPhysicsList::SetCuts:";
|
||||
G4cout << "Gamma and Electron cut in energy: " << lowcut*MeV << " (MeV)" << G4endl;
|
||||
}
|
||||
|
||||
G4Gamma::SetEnergyRange(lowcut,1e5);
|
||||
G4Electron::SetEnergyRange(lowcut,1e5);
|
||||
G4Positron::SetEnergyRange(lowcut,1e5);
|
||||
|
||||
}
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetGammaCut(G4double val)
|
||||
{
|
||||
ResetCuts();
|
||||
cutForGamma = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetElectronCut(G4double val)
|
||||
{
|
||||
// ResetCuts();
|
||||
cutForElectron = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetPositronCut(G4double val)
|
||||
{
|
||||
// ResetCuts();
|
||||
cutForPositron = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetLowEnSecPhotCut(G4double cut){
|
||||
|
||||
G4cout<<"Low energy secondary photons cut is now set to: "<<cut*MeV<<" (MeV)"<<G4endl;
|
||||
G4cout<<"for processes LowEnergyPhotoElectric, LowEnergyBremsstrahlung, LowEnergyIonisation"<<G4endl;
|
||||
lowePhot->SetCutForLowEnSecPhotons(cut);
|
||||
loweIon->SetCutForLowEnSecPhotons(cut);
|
||||
loweBrem->SetCutForLowEnSecPhotons(cut);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void BrachyPhysicsList::SetLowEnSecElecCut(G4double cut){
|
||||
|
||||
G4cout<<"Low energy secondary electrons cut is now set to: "<<cut*MeV<<" (MeV)"<<G4endl;
|
||||
G4cout<<"for processes LowEnergyIonisation"<<G4endl;
|
||||
loweIon->SetCutForLowEnSecElectrons(cut);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// ********************************************
|
||||
// * *
|
||||
// * BrachyPrimaryGeneratorAction.cc *
|
||||
// * *
|
||||
// ********************************************
|
||||
|
||||
#include "BrachyPrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4RadioactiveDecay.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "globals.hh"
|
||||
#include <math.h>
|
||||
|
||||
//....
|
||||
|
||||
BrachyPrimaryGeneratorAction::BrachyPrimaryGeneratorAction()
|
||||
{
|
||||
// Generate a gamma particle with energy = Ir-192 mean energy
|
||||
G4int NumParticles = 1;
|
||||
G4double Energy = 0.356*MeV;
|
||||
|
||||
m_pParticleGun = new G4ParticleGun(NumParticles);
|
||||
if(m_pParticleGun)
|
||||
m_pParticleGun->SetParticleEnergy(Energy);
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyPrimaryGeneratorAction::~BrachyPrimaryGeneratorAction()
|
||||
{
|
||||
if(m_pParticleGun)
|
||||
delete m_pParticleGun;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4ParticleTable* pParticleTable = G4ParticleTable::GetParticleTable();
|
||||
G4String ParticleName = "gamma";
|
||||
G4ParticleDefinition* pParticle = pParticleTable->FindParticle(ParticleName);
|
||||
|
||||
m_pParticleGun->SetParticleDefinition(pParticle);
|
||||
|
||||
// Random generation of gamma source point inside the Iridium core cylinder(R=0.3*mm,h=3.5*mm)
|
||||
G4double radius = 0.3*mm;
|
||||
G4double x,y,z;
|
||||
do{
|
||||
x = (G4UniformRand()-0.5)*radius/0.5;
|
||||
y = (G4UniformRand()-0.5)*radius/0.5;
|
||||
}while(x*x+y*y > radius*radius);
|
||||
z = (G4UniformRand()-0.5)*1.75*mm/0.5;
|
||||
|
||||
G4ThreeVector position(x,y,z);
|
||||
m_pParticleGun->SetParticlePosition(position);
|
||||
|
||||
// Random generation of the impulse direction
|
||||
G4double a,b,c;
|
||||
G4double n;
|
||||
do{
|
||||
a = (G4UniformRand()-0.5)/0.5;
|
||||
b = (G4UniformRand()-0.5)/0.5;
|
||||
c = (G4UniformRand()-0.5)/0.5;
|
||||
n = a*a+b*b+c*c;
|
||||
}while(n > 1 || n == 0.0);
|
||||
n = sqrt(n);
|
||||
a /= n;
|
||||
b /= n;
|
||||
c /= n;
|
||||
|
||||
G4ThreeVector direction(a,b,c);
|
||||
m_pParticleGun->SetParticleMomentumDirection(direction);
|
||||
|
||||
m_pParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// ********************************
|
||||
// * *
|
||||
// * BrachyWaterBoxHit.cc *
|
||||
// * *
|
||||
// ********************************
|
||||
|
||||
#include "BrachyWaterBoxHit.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
G4Allocator<BrachyWaterBoxHit> BrachyWaterBoxHitAllocator;
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxHit::BrachyWaterBoxHit(G4LogicalVolume* logVol,G4int XID,G4int ZID)
|
||||
:m_pLogV(logVol),m_XID(XID),m_ZID(ZID)
|
||||
{
|
||||
m_Edep=0;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxHit::~BrachyWaterBoxHit()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxHit::BrachyWaterBoxHit(const BrachyWaterBoxHit &right)
|
||||
{
|
||||
m_XID = right.m_XID;
|
||||
m_ZID = right.m_ZID;
|
||||
m_Edep = right.m_Edep;
|
||||
m_Pos = right.m_Pos;
|
||||
m_Rot = right.m_Rot;
|
||||
m_pLogV = right.m_pLogV;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
const BrachyWaterBoxHit& BrachyWaterBoxHit::operator=(const BrachyWaterBoxHit &right)
|
||||
{
|
||||
m_XID = right.m_XID;
|
||||
m_ZID = right.m_ZID;
|
||||
m_Edep = right.m_Edep;
|
||||
m_Pos = right.m_Pos;
|
||||
m_Rot = right.m_Rot;
|
||||
m_pLogV = right.m_pLogV;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
int BrachyWaterBoxHit::operator==(const BrachyWaterBoxHit &right) const
|
||||
{
|
||||
return((m_XID==right.m_XID)&&(m_ZID==right.m_ZID));
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxHit::Draw()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxHit::Print()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// ************************************
|
||||
// * *
|
||||
// * BrachyWaterBoxROGeometry.cc *
|
||||
// * *
|
||||
// ************************************
|
||||
|
||||
#include "BrachyWaterBoxROGeometry.hh"
|
||||
#include "BrachyDummySD.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Material.hh"
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxROGeometry::BrachyWaterBoxROGeometry(G4String aString,G4double DetDimX,G4double DetDimZ,G4int NumVoxelX,G4int NumVoxelZ)
|
||||
: G4VReadOutGeometry(aString),m_DetDimX(DetDimX),m_DetDimZ(DetDimZ),m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxROGeometry::~BrachyWaterBoxROGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
G4VPhysicalVolume* BrachyWaterBoxROGeometry::Build()
|
||||
{
|
||||
// A dummy material is used to fill the volumes of the readout geometry.
|
||||
// (It will be allowed to set a NULL pointer in volumes of such virtual
|
||||
// division in future, since this material is irrelevant for tracking.)
|
||||
|
||||
G4Material* dummyMat = new G4Material(name="dummyMat", 1., 1.*g/mole, 1.*g/cm3);
|
||||
|
||||
// Slice thickness is the average of Voxel X and Z sizes
|
||||
G4double DetVoxel_y = (m_DetDimX/m_NumVoxelX+m_DetDimZ/m_NumVoxelZ)/2.0;
|
||||
|
||||
G4double ExpHall_x = 4.0*m;
|
||||
G4double ExpHall_y = 4.0*m;
|
||||
G4double ExpHall_z = 4.0*m;
|
||||
|
||||
G4double Det_x = m_DetDimX/2;
|
||||
G4double Det_y = DetVoxel_y;
|
||||
G4double Det_z = m_DetDimZ/2;
|
||||
|
||||
G4double DetVoxelX_x = Det_x/m_NumVoxelX;
|
||||
G4double DetVoxelX_y = DetVoxel_y;
|
||||
G4double DetVoxelX_z = Det_z;
|
||||
G4double DetVoxelX_dx = 2*DetVoxelX_x;
|
||||
|
||||
G4double DetVoxelZ_x = Det_x;
|
||||
G4double DetVoxelZ_y = DetVoxel_y;
|
||||
G4double DetVoxelZ_z = Det_z/m_NumVoxelZ;
|
||||
G4double DetVoxelZ_dz = 2*DetVoxelZ_z;
|
||||
|
||||
G4Box *ROExpHall = new G4Box("ROExpHall",ExpHall_x,ExpHall_y,ExpHall_z);
|
||||
G4LogicalVolume *ROExpHallLog = new G4LogicalVolume(ROExpHall,dummyMat,"ROExpHallLog",0,0,0);
|
||||
G4VPhysicalVolume *ROExpHallPhys = new G4PVPlacement(0,G4ThreeVector(),"ROExpHallPhys",ROExpHallLog,0,false,0);
|
||||
|
||||
G4Box *RODetector = new G4Box("RODetector", Det_x, Det_y, Det_z);
|
||||
G4LogicalVolume *RODetectorLog = new G4LogicalVolume(RODetector,dummyMat,"RODetectorLog",0,0,0);
|
||||
G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,G4ThreeVector(),"DetectorPhys",RODetectorLog,ROExpHallPhys,false,0);
|
||||
|
||||
// ReadOut Voxel division
|
||||
|
||||
// X division first...
|
||||
|
||||
G4Box *RODetectorXDivision = new G4Box("RODetectorXDivision",DetVoxelX_x,DetVoxelX_y,DetVoxelX_z);
|
||||
G4LogicalVolume *RODetectorXDivisionLog = new G4LogicalVolume(RODetectorXDivision,dummyMat,"RODetectorXDivisionLog",0,0,0);
|
||||
G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",RODetectorXDivisionLog,RODetectorPhys,kXAxis,m_NumVoxelX,DetVoxelX_dx);
|
||||
|
||||
// ...then Z division
|
||||
|
||||
G4Box *RODetectorZDivision = new G4Box("RODetectorZDivision",DetVoxelZ_x,DetVoxelZ_y,DetVoxelZ_z);
|
||||
G4LogicalVolume *RODetectorZDivisionLog = new G4LogicalVolume(RODetectorZDivision,dummyMat,"RODetectorZDivisionLog",0,0,0);
|
||||
G4VPhysicalVolume *RODetectorZDivisionPhys = new G4PVReplica("RODetectorZDivisionPhys",RODetectorZDivisionLog,RODetectorXDivisionPhys,kZAxis,m_NumVoxelZ,DetVoxelZ_dz);
|
||||
|
||||
BrachyDummySD *dummySD = new BrachyDummySD;
|
||||
RODetectorZDivisionLog->SetSensitiveDetector(dummySD);
|
||||
|
||||
return ROExpHallPhys;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// ********************************
|
||||
// * *
|
||||
// * BrachyWaterBoxSD.cc *
|
||||
// * *
|
||||
// ********************************
|
||||
|
||||
#include "BrachyWaterBoxSD.hh"
|
||||
#include "BrachyWaterBoxHit.hh"
|
||||
#include "BrachyDetectorConstruction.hh"
|
||||
|
||||
#include "G4Track.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxSD::BrachyWaterBoxSD(G4String name, G4int NumVoxelX, G4int NumVoxelZ)
|
||||
:G4VSensitiveDetector(name),m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
|
||||
{
|
||||
G4String HCname;
|
||||
collectionName.insert(HCname="WaterBoxHitsCollection");
|
||||
m_pVoxelID = new G4int[NumVoxelX*NumVoxelZ];
|
||||
m_pWaterBoxHitsCollection = NULL;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
BrachyWaterBoxSD::~BrachyWaterBoxSD()
|
||||
{
|
||||
delete[] m_pVoxelID;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxSD::Initialize(G4HCofThisEvent*HCE)
|
||||
{
|
||||
m_pWaterBoxHitsCollection = new BrachyWaterBoxHitsCollection(SensitiveDetectorName,collectionName[0]);
|
||||
|
||||
for(G4int k=0;k<m_NumVoxelZ;k++)
|
||||
for(G4int i=0;i<m_NumVoxelX;i++)
|
||||
m_pVoxelID[i+k*m_NumVoxelX] = -1;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
G4bool BrachyWaterBoxSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
|
||||
{
|
||||
if(!ROhist)
|
||||
return false;
|
||||
|
||||
if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() != "WaterBoxPhys")
|
||||
return false;
|
||||
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
if(edep==0.)
|
||||
return false;
|
||||
|
||||
G4VPhysicalVolume* physVol = ROhist->GetVolume();
|
||||
G4VPhysicalVolume* mothVol = ROhist->GetVolume(1);
|
||||
|
||||
// Read Voxel indexes: i is the x index, k is the z index
|
||||
G4int k = ROhist->GetReplicaNumber();
|
||||
G4int i = ROhist->GetReplicaNumber(1);
|
||||
|
||||
if(m_pVoxelID[i+k*m_NumVoxelX]==-1)
|
||||
{
|
||||
BrachyWaterBoxHit* WaterBoxHit = new BrachyWaterBoxHit(physVol->GetLogicalVolume(),i,k);
|
||||
|
||||
G4RotationMatrix rotM;
|
||||
if(physVol->GetObjectRotation())
|
||||
rotM = *(physVol->GetObjectRotation());
|
||||
|
||||
WaterBoxHit->SetEdep(edep);
|
||||
WaterBoxHit->SetPos(physVol->GetTranslation());
|
||||
WaterBoxHit->SetRot(rotM);
|
||||
|
||||
G4int VoxelID = m_pWaterBoxHitsCollection->insert(WaterBoxHit);
|
||||
m_pVoxelID[i+k*m_NumVoxelX] = VoxelID - 1;
|
||||
}
|
||||
else
|
||||
(*m_pWaterBoxHitsCollection)[m_pVoxelID[i+k*m_NumVoxelX]]->AddEdep(edep);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxSD::EndOfEvent(G4HCofThisEvent*HCE)
|
||||
{
|
||||
static G4int HCID = -1;
|
||||
if(HCID<0)
|
||||
{
|
||||
HCID = GetCollectionID(0);
|
||||
}
|
||||
HCE->AddHitsCollection(HCID,m_pWaterBoxHitsCollection);
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxSD::clear()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxSD::DrawAll()
|
||||
{
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
void BrachyWaterBoxSD::PrintAll()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user