Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization()
:G4VUserActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
// Needed for merging of analysis ROOT files
SetUserAction(new RunAction());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
SetUserAction(new PrimaryGeneratorAction());
auto runAction= new RunAction();
SetUserAction(runAction);
SetUserAction(new EventAction());
SetUserAction(new SteppingAction(runAction));
}
@@ -0,0 +1,229 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "CellParameterisation.hh"
#include "G4Material.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CellParameterisation *CellParameterisation::gInstance = nullptr;
CellParameterisation::CellParameterisation
(G4String fileName,
G4Material *RedMat, G4Material *GreenMat, G4Material *BlueMat,
G4double shiftX, G4double shiftY, G4double shiftZ
)
:fRedMaterial(RedMat), fGreenMaterial(GreenMat), fBlueMaterial(BlueMat),
fShiftX(shiftX), fShiftY(shiftY), fShiftZ(shiftZ)
{
Initialize(fileName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CellParameterisation::Initialize(const G4String &fileName)
{
G4int ncols, l, mat;
G4int pixelX, pixelY, pixelZ;
G4double x, y, z, den1, den2, den3;
ncols = 0;
l = 0;
// Read phantom
FILE *fMap;
fMap = fopen(fileName, "r");
fRedMass = 0;
fGreenMass = 0;
fBlueMass = 0;
ncols = fscanf(fMap, "%d %d %d %d", &fPhantomTotalPixels, &fRedTotalPixels, &fGreenTotalPixels,
&fBlueTotalPixels);
ncols = fscanf(fMap, "%lf %lf %lf %s", &fSizeRealX, &fSizeRealY, &fSizeRealZ, &fRealUnit);
ncols = fscanf(fMap, "%lf %lf %lf %s", &fDimCellBoxX, &fDimCellBoxY, &fDimCellBoxZ, &fRealUnit);
fMapCell = new G4ThreeVector[fPhantomTotalPixels]; //geant4 coordinates space
fMapCellPxl = new G4ThreeVector[fPhantomTotalPixels]; //voxel space
fMapCellOriginal = new G4ThreeVector[fPhantomTotalPixels]; //original coordinates space
fMaterial = new G4int[fPhantomTotalPixels];
fDimCellBoxX = fDimCellBoxX * um;
fDimCellBoxY = fDimCellBoxY * um;
fDimCellBoxZ = fDimCellBoxZ * um;
den1 = fRedMaterial->GetDensity();
den2 = fGreenMaterial->GetDensity();
den3 = fBlueMaterial->GetDensity();
fOffsetX = -fSizeRealX / 2 *um;
fOffsetY = -fSizeRealY / 2 *um;
fOffsetZ = -fSizeRealZ / 2 *um;
G4cout << G4endl;
G4cout << " #########################################################################" << G4endl;
G4cout << " Phantom placement and density " << G4endl;
G4cout << " #########################################################################" << G4endl;
G4cout << G4endl;
G4cout << " ==========> Phantom origin - X (um) = " << (fOffsetX + fShiftX)/um << G4endl;
G4cout << " ==========> Phantom origin - Y (um) = " << (fOffsetY + fShiftY)/um << G4endl;
G4cout << " ==========> Phantom origin - Z (um) = " << (fOffsetZ + fShiftZ)/um << G4endl;
G4cout << G4endl;
G4cout << " ==========> Red density (g/cm3) = " << den1/(g/cm3) << G4endl;
G4cout << " ==========> Green density (g/cm3) = " << den2/(g/cm3) << G4endl;
G4cout << " ==========> Blue density (g/cm3) = " << den3/(g/cm3) << G4endl;
G4cout << G4endl;
G4cout << " #########################################################################" << G4endl;
G4cout << G4endl;
while (1)
{
ncols = fscanf(fMap, "%lf %lf %lf %d", &x, &y, &z, &mat);
if (ncols < 0) break;
G4ThreeVector v( x*um + fOffsetX + fShiftX, // phantom shift
-(y*um + fOffsetY + fShiftY),
z*um + fOffsetZ + fShiftZ );
// Pixel coordinates
pixelX = (x*um)/fDimCellBoxX;
pixelY = (y*um)/fDimCellBoxY;
pixelZ = (z*um)/fDimCellBoxZ;
G4ThreeVector w(pixelX, pixelY, pixelZ);
G4ThreeVector v_original(x*um, y*um, z*um);
fMapCell[l] = v;
fMapCellPxl[l] = w;
fMapCellOriginal[l] = v_original;
fMaterial[l] = mat;
if (mat == 1){
fRedMass += den1 * fDimCellBoxX * fDimCellBoxY * fDimCellBoxZ;
}
else if (mat == 2){
fGreenMass += den2 * fDimCellBoxX * fDimCellBoxY * fDimCellBoxZ;
}
else if (mat == 3){
fBlueMass += den3 * fDimCellBoxX * fDimCellBoxY * fDimCellBoxZ;
}
l++;
}
fclose(fMap);
fRedAttributes = new G4VisAttributes;
fRedAttributes->SetColour(G4Colour(1, 0, 0));
fRedAttributes->SetForceSolid(false);
fGreenAttributes = new G4VisAttributes;
fGreenAttributes->SetColour(G4Colour(0, 1, 0));
fGreenAttributes->SetForceSolid(false);
fBlueAttributes = new G4VisAttributes;
fBlueAttributes->SetColour(G4Colour(0, 0, 1));
fBlueAttributes->SetForceSolid(false);
gInstance = this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CellParameterisation::~CellParameterisation()
{
delete[] fMapCell;
delete[] fMapCellPxl;
delete[] fMaterial;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void CellParameterisation::ComputeTransformation
(const G4int copyNo, G4VPhysicalVolume *physVol) const
{
if(fMapCell == nullptr)
{
G4ExceptionDescription ex;
ex<< "fMapCell == nullptr ";
G4Exception("CellParameterisation::ComputeTransformation",
"CellParameterisation001",
FatalException,
ex);
}
else
{
G4ThreeVector
origin(fMapCell[copyNo].x(), fMapCell[copyNo].y(), fMapCell[copyNo].z());
physVol->SetTranslation(origin);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material *
CellParameterisation::ComputeMaterial(const G4int copyNo,
G4VPhysicalVolume *physVol,
const G4VTouchable *)
{
if (fMaterial[copyNo] == 3) // fMaterial 3 is blue
{
physVol->SetName("physicalMat3");
physVol->GetLogicalVolume()->SetVisAttributes(fBlueAttributes);
return fBlueMaterial;
}
else if (fMaterial[copyNo] == 2) // fMaterial 2 is green
{
physVol->SetName("physicalMat2");
physVol->GetLogicalVolume()->SetVisAttributes(fGreenAttributes);
return fGreenMaterial;
}
else if (fMaterial[copyNo] == 1) // fMaterial 1 is red
{
physVol->SetName("physicalMat1");
physVol->GetLogicalVolume()->SetVisAttributes(fRedAttributes);
return fRedMaterial;
}
return physVol->GetLogicalVolume()->GetMaterial();
}
@@ -0,0 +1,367 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4PhysicalConstants.hh"
#include "G4NistManager.hh"
#include "G4ProductionCuts.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:G4VUserDetectorConstruction()
{
fDetectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VPhysicalVolume *DetectorConstruction::Construct()
{
DefineMaterials();
return ConstructLine();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DetectorConstruction::DefineMaterials()
{
G4String name, symbol;
// Water and air are defined from NIST material database
G4NistManager *man = G4NistManager::Instance();
G4Material *H2O = man->FindOrBuildMaterial("G4_WATER");
G4Material *Air = man->FindOrBuildMaterial("G4_AIR");
fDefaultMaterial = Air;
fPhantomMaterial = H2O; // material is not relevant
// it will be changed by the ComputeMaterial
// method of the CellParameterisation
// Default materials
if (fMediumMaterial == nullptr) {fMediumMaterial = H2O;}
if (fRedMaterial == nullptr) {fRedMaterial = H2O;}
if (fGreenMaterial == nullptr) {fGreenMaterial = H2O;}
if (fBlueMaterial == nullptr) {fBlueMaterial = H2O;}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VPhysicalVolume *DetectorConstruction::ConstructLine() {
//*************
// World volume
//*************
fSolidWorld = new G4Box("World", //its name
fWorldSizeXY / 2, fWorldSizeXY / 2, fWorldSizeZ / 2); //its size
fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
fDefaultMaterial, //its material
"World"); //its name
fPhysiWorld = new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(), //at (0,0,0)
"World", //its name
fLogicWorld, //its logical volume
nullptr, //its mother volume
false, //no boolean operation
0); //copy number
//********************
// Cell culture medium
//********************
fSolidMedium = new G4Box("Medium", fMediumSizeXY / 2, fMediumSizeXY / 2, fMediumSizeZ / 2);
fLogicMedium = new G4LogicalVolume(fSolidMedium, fMediumMaterial, "Medium");
fPhysiMedium = new G4PVPlacement(nullptr,
G4ThreeVector(0, 0, 0),
"Medium",
fLogicMedium,
fPhysiWorld,
false,
0);
// ************
// Cell phantom
// ************
// The cell phantom is placed in the middle of the parent volume (fLogicMedium here)
fPhantomParam = new CellParameterisation
(fPhantomFileName, fRedMaterial, fGreenMaterial, fBlueMaterial, fShiftX, fShiftY, fShiftZ);
fSolidPhantom = new G4Box("Phantom",
fPhantomParam->GetPixelSizeX() / 2,
fPhantomParam->GetPixelSizeY() / 2,
fPhantomParam->GetPixelSizeZ() / 2);
fLogicPhantom = new G4LogicalVolume(fSolidPhantom,
fPhantomMaterial, // material is not relevant,
// it will be changed by the
// ComputeMaterial method
// of the CellParameterisation
"Phantom",
nullptr,
nullptr,
nullptr);
fPhysiPhantom = new G4PVParameterised(
"Phantom", // name
fLogicPhantom, // logical volume
fLogicMedium, // mother logical volume
kUndefined, // kUndefined: three-dimensional optimization
fPhantomParam->GetPhantomTotalPixels(), // number of voxels
fPhantomParam, // the parametrisation
false);
G4cout << " #########################################################################" << G4endl;
G4cout << " Phantom information " << G4endl;
G4cout << " #########################################################################" << G4endl;
G4cout << G4endl;
G4cout << " ==========> The phantom contains " << fPhantomParam->GetPhantomTotalPixels()
<< " voxels " << G4endl;
G4cout << " ==========> Voxel size X (um) = " << fPhantomParam->GetPixelSizeX()/um << G4endl;
G4cout << " ==========> Voxel size Y (um) = " << fPhantomParam->GetPixelSizeY()/um << G4endl;
G4cout << " ==========> Voxel size Z (um) = " << fPhantomParam->GetPixelSizeZ()/um << G4endl;
G4cout << G4endl;
G4cout << " ==========> Number of red voxels = "
<< fPhantomParam->GetRedTotalPixels() << G4endl;
G4cout << " ==========> Number of green voxels = "
<< fPhantomParam->GetGreenTotalPixels() << G4endl;
G4cout << " ==========> Number of blue voxels = "
<< fPhantomParam->GetBlueTotalPixels() << G4endl;
G4cout << G4endl;
G4cout << " ==========> Tolal mass of red voxels (kg) = "
<< fPhantomParam->GetRedMass() / kg << G4endl;
G4cout << " ==========> Tolal mass of green voxels (kg) = "
<< fPhantomParam->GetGreenMass() / kg << G4endl;
G4cout << " ==========> Tolal mass of blue voxels (kg) = "
<< fPhantomParam->GetBlueMass() / kg << G4endl;
G4cout << G4endl;
G4cout << " #########################################################################" << G4endl;
G4cout << G4endl;
// USER LIMITS ON STEP LENGTH
// fLogicWorld->SetUserLimits(new G4UserLimits(100 * mm));
// fLogicPhantom->SetUserLimits(new G4UserLimits(0.5 * micrometer));
// fLogicMedium->SetUserLimits(new G4UserLimits(1 * micrometer));
// Create a phantom G4Region and add logical volume
fPhantomRegion = new G4Region("phantomRegion");
G4ProductionCuts* cuts = new G4ProductionCuts();
G4double defCut = 1*nanometer;
cuts->SetProductionCut(defCut,"gamma");
cuts->SetProductionCut(defCut,"e-");
cuts->SetProductionCut(defCut,"e+");
cuts->SetProductionCut(defCut,"proton");
fPhantomRegion->SetProductionCuts(cuts);
fPhantomRegion->AddRootLogicalVolume(fLogicMedium);
return fPhysiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetTargetMaterial(const G4String& mat)
{
if (G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat))
{
if (material && mat != "G4_WATER")
{
fMediumMaterial = material;
G4cout << " #########################################################################"
<< G4endl;
G4cout << " Cell culture medium material "
<< G4endl;
G4cout << fMediumMaterial << G4endl;
G4cout << " #########################################################################"
<< G4endl;
G4cout << G4endl;
}
}
else
{
G4cout << G4endl;
G4cout << "WARNING: material \"" << mat << "\" doesn't exist in NIST elements/materials"
<< G4endl;
G4cout << " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]"
<< G4endl;
G4cout << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetRedDensity(const G4double& value)
{
fDensityRed = value;
if (fDensityRed != 1.0)
{
G4NistManager *man = G4NistManager::Instance();
G4Material * H2O_red = man->BuildMaterialWithNewDensity("G4_WATER_red","G4_WATER",
fDensityRed);
fRedMaterial = H2O_red;
}
else
{
G4NistManager *man = G4NistManager::Instance();
fRedMaterial = man->FindOrBuildMaterial("G4_WATER");
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetGreenDensity(const G4double& value)
{
fDensityGreen = value;
if (fDensityGreen != 1.0)
{
G4NistManager *man = G4NistManager::Instance();
G4Material * H2O_green = man->BuildMaterialWithNewDensity("G4_WATER_green","G4_WATER",
fDensityGreen);
fGreenMaterial = H2O_green;
}
else
{
G4NistManager *man = G4NistManager::Instance();
fGreenMaterial = man->FindOrBuildMaterial("G4_WATER");
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetBlueDensity(const G4double& value)
{
fDensityBlue = value;
if (fDensityBlue != 1.0)
{
G4NistManager *man = G4NistManager::Instance();
G4Material * H2O_blue = man->BuildMaterialWithNewDensity("G4_WATER_blue","G4_WATER",
fDensityBlue);
fBlueMaterial = H2O_blue;
}
else
{
G4NistManager *man = G4NistManager::Instance();
fBlueMaterial = man->FindOrBuildMaterial("G4_WATER");
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetShiftX(const G4double& value)
{
fShiftX = value;
G4cout << "... setting phantom shift: X = " << fShiftX/um << " um" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetShiftY(const G4double& value)
{
fShiftY = value;
G4cout << "... setting phantom shift: Y = " << fShiftY/um << " um" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetShiftZ(const G4double& value)
{
fShiftZ = value;
G4cout << "... setting phantom shift: Y = " << fShiftZ/um << " um" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetMediumSizeXY(const G4double& value)
{
fMediumSizeXY = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetMediumSizeZ(const G4double& value)
{
fMediumSizeZ = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldSizeXY(const G4double& value)
{
fWorldSizeXY = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldSizeZ(const G4double& value)
{
fWorldSizeZ = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetPhantomFileName(const G4String& phantomName)
{
fPhantomFileName = phantomName;
G4cout << " #########################################################################"
<< G4endl;
G4cout << " Loading cell phantom from file: "
<< fPhantomFileName << G4endl;
G4cout << " #########################################################################"
<< G4endl;
G4cout << G4endl;
}
@@ -0,0 +1,197 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * det)
:G4UImessenger(), fDetector(det)
{
fPhantomDir = new G4UIdirectory("/phantom/");
fPhantomDir->SetGuidance(" Cell phantom settings");
fNameCmd = new G4UIcmdWithAString("/phantom/fileName",this);
fNameCmd->SetGuidance("Select phantom file name");
fNameCmd->SetParameterName("fileName",true);
fNameCmd->SetDefaultValue("phantom.dat");
fNameCmd->AvailableForStates(G4State_PreInit);
fMatCmd = new G4UIcmdWithAString("/phantom/mediumMat",this);
fMatCmd->SetGuidance("Select material for the phantom medium");
fMatCmd->SetParameterName("mediumMat",true);
fMatCmd->AvailableForStates(G4State_PreInit);
fDenRedCmd = new G4UIcmdWithADoubleAndUnit("/phantom/redDen",this);
fDenRedCmd->SetGuidance("Select density for the red volume");
fDenRedCmd->SetParameterName("redDen",true);
fDenRedCmd->SetDefaultValue(1.);
fDenRedCmd->SetDefaultUnit("g/cm3");
fDenRedCmd->AvailableForStates(G4State_PreInit);
fDenGreenCmd = new G4UIcmdWithADoubleAndUnit("/phantom/greenDen",this);
fDenGreenCmd->SetGuidance("Select density for the green volume");
fDenGreenCmd->SetParameterName("greenDen",true);
fDenGreenCmd->SetDefaultValue(1.);
fDenGreenCmd->SetDefaultUnit("g/cm3");
fDenGreenCmd->AvailableForStates(G4State_PreInit);
fDenBlueCmd = new G4UIcmdWithADoubleAndUnit("/phantom/blueDen",this);
fDenBlueCmd->SetGuidance("Select density for the blue volume");
fDenBlueCmd->SetParameterName("blueDen",true);
fDenBlueCmd->SetDefaultValue(1.);
fDenBlueCmd->SetDefaultUnit("g/cm3");
fDenBlueCmd->AvailableForStates(G4State_PreInit);
fShiftXCmd = new G4UIcmdWithADoubleAndUnit("/phantom/shiftX",this);
fShiftXCmd->SetGuidance("Set phantom X shift");
fShiftXCmd->SetParameterName("shiftX",true);
fShiftXCmd->SetDefaultValue(0.);
fShiftXCmd->SetDefaultUnit("um");
fShiftXCmd->AvailableForStates(G4State_PreInit);
fShiftYCmd = new G4UIcmdWithADoubleAndUnit("/phantom/shiftY",this);
fShiftYCmd->SetGuidance("Set phantom Y shift");
fShiftYCmd->SetParameterName("shiftY",true);
fShiftYCmd->SetDefaultValue(0.);
fShiftYCmd->SetDefaultUnit("um");
fShiftYCmd->AvailableForStates(G4State_PreInit);
fShiftZCmd = new G4UIcmdWithADoubleAndUnit("/phantom/shiftZ",this);
fShiftZCmd->SetGuidance("Set phantom Z shift");
fShiftZCmd->SetParameterName("shiftZ",true);
fShiftZCmd->SetDefaultValue(0.);
fShiftZCmd->SetDefaultUnit("um");
fShiftZCmd->AvailableForStates(G4State_PreInit);
fMediumSizeXYCmd = new G4UIcmdWithADoubleAndUnit("/phantom/mediumSizeXY",this);
fMediumSizeXYCmd->SetGuidance("Set cellular medium size XY");
fMediumSizeXYCmd->SetParameterName("mediumSizeXY",false);
fMediumSizeXYCmd->SetDefaultUnit("um");
fMediumSizeXYCmd->AvailableForStates(G4State_PreInit);
fMediumSizeZCmd = new G4UIcmdWithADoubleAndUnit("/phantom/mediumSizeZ",this);
fMediumSizeZCmd->SetGuidance("Set cellular medium size Z");
fMediumSizeZCmd->SetParameterName("mediumSizeZ",false);
fMediumSizeZCmd->SetDefaultUnit("um");
fMediumSizeZCmd->AvailableForStates(G4State_PreInit);
fWorldDir = new G4UIdirectory("/world/");
fWorldDir->SetGuidance(" World volume settings");
fWorldSizeXYCmd = new G4UIcmdWithADoubleAndUnit("/world/sizeXY",this);
fWorldSizeXYCmd->SetGuidance("Set world size XY");
fWorldSizeXYCmd->SetParameterName("sizeXY",false);
fWorldSizeXYCmd->SetDefaultUnit("um");
fWorldSizeXYCmd->AvailableForStates(G4State_PreInit);
fWorldSizeZCmd = new G4UIcmdWithADoubleAndUnit("/world/sizeZ",this);
fWorldSizeZCmd->SetGuidance("Set world size Z");
fWorldSizeZCmd->SetParameterName("sizeZ",false);
fWorldSizeZCmd->SetDefaultUnit("um");
fWorldSizeZCmd->AvailableForStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete fWorldDir;
delete fPhantomDir;
delete fNameCmd;
delete fMatCmd;
delete fDenRedCmd;
delete fDenGreenCmd;
delete fDenBlueCmd;
delete fShiftXCmd;
delete fShiftYCmd;
delete fShiftZCmd;
delete fMediumSizeXYCmd;
delete fMediumSizeZCmd;
delete fWorldSizeXYCmd;
delete fWorldSizeZCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == fMatCmd ) {
fDetector->SetTargetMaterial(newValue);
}
else if(command == fDenRedCmd) {
fDetector->SetRedDensity(fDenRedCmd->GetNewDoubleValue(newValue));
}
else if(command == fDenGreenCmd) {
fDetector->SetGreenDensity(fDenGreenCmd->GetNewDoubleValue(newValue));
}
else if(command == fDenBlueCmd) {
fDetector->SetBlueDensity(fDenBlueCmd->GetNewDoubleValue(newValue));
}
else if (command == fShiftXCmd) {
fDetector->SetShiftX(fShiftXCmd->GetNewDoubleValue(newValue));
}
else if (command == fShiftYCmd) {
fDetector->SetShiftY(fShiftYCmd->GetNewDoubleValue(newValue));
}
else if (command == fShiftZCmd) {
fDetector->SetShiftZ(fShiftZCmd->GetNewDoubleValue(newValue));
}
else if (command == fMediumSizeXYCmd) {
fDetector->SetMediumSizeXY(fMediumSizeXYCmd->GetNewDoubleValue(newValue));
}
else if (command == fMediumSizeZCmd) {
fDetector->SetMediumSizeZ(fMediumSizeZCmd->GetNewDoubleValue(newValue));
}
else if (command == fWorldSizeXYCmd) {
fDetector->SetWorldSizeXY(fWorldSizeXYCmd->GetNewDoubleValue(newValue));
}
else if (command == fWorldSizeZCmd) {
fDetector->SetWorldSizeZ(fWorldSizeZCmd->GetNewDoubleValue(newValue));
}
else if(command == fNameCmd) {
fDetector->SetPhantomFileName(newValue);
}
}
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "EventAction.hh"
#include "G4Event.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
EventAction::EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
EventAction::~EventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void EventAction::BeginOfEventAction(const G4Event *)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void EventAction::EndOfEventAction(const G4Event *)
{}
@@ -0,0 +1,80 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "PhysicsList.hh"
#include "G4SystemOfUnits.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4EmDNAPhysics_option2.hh"
#include "G4DecayPhysics.hh"
#include "G4RadioactiveDecayPhysics.hh"
#include "G4PhysicsConstructorRegistry.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicsConstructor* GetPhysicsConstructor(const G4String& name)
{
return G4PhysicsConstructorRegistry::Instance()->GetPhysicsConstructor(name);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList():G4VModularPhysicsList()
{
defaultCutValue = 1. * nm;
SetVerboseLevel(0);
RegisterPhysics(new G4EmStandardPhysics_option4());
//RegisterPhysics(new G4EmDNAPhysics_option2());
//RegisterPhysics(new G4DecayPhysics());
//RegisterPhysics(new G4RadioactiveDecayPhysics());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCuts()
{
SetCutsWithDefault();
}
@@ -0,0 +1,74 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "PrimaryGeneratorAction.hh"
#include <G4GeneralParticleSource.hh>
#include "G4ParticleTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction()
:G4VUserPrimaryGeneratorAction()
{
fGPS = new G4GeneralParticleSource();
G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle("proton");
fGPS->SetParticleDefinition(particle);
fGPS->GetCurrentSource()->GetEneDist()->SetMonoEnergy(6 * MeV);
fGPS->GetCurrentSource()->GetAngDist()->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
fGPS->GetCurrentSource()->GetPosDist()->SetCentreCoords(G4ThreeVector(0., 0., -1. * mm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete fGPS;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
fGPS->GeneratePrimaryVertex(anEvent);
}
@@ -0,0 +1,200 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "RunAction.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
RunAction::RunAction()
:G4UserRunAction()
{
auto man = G4AnalysisManager::Instance();
man->SetDefaultFileType("root");
man->SetNtupleMerging(true);
man->SetFirstNtupleId(1);
// Create 1st ntuple (id = 1)
man->CreateNtuple("ntuple1", "RED");
man->CreateNtupleDColumn("x");
man->CreateNtupleDColumn("y");
man->CreateNtupleDColumn("z");
man->CreateNtupleDColumn("energy");
man->CreateNtupleDColumn("dose");
man->CreateNtupleIColumn("voxelID");
man->FinishNtuple();
// Create 2nd ntuple (id = 2)
man->CreateNtuple("ntuple2", "GREEN");
man->CreateNtupleDColumn("x");
man->CreateNtupleDColumn("y");
man->CreateNtupleDColumn("z");
man->CreateNtupleDColumn("energy");
man->CreateNtupleDColumn("dose");
man->CreateNtupleIColumn("voxelID");
man->FinishNtuple();
// Create 3rd ntuple (id = 3)
man->CreateNtuple("ntuple3", "BLUE");
man->CreateNtupleDColumn("x");
man->CreateNtupleDColumn("y");
man->CreateNtupleDColumn("z");
man->CreateNtupleDColumn("energy");
man->CreateNtupleDColumn("dose");
man->CreateNtupleIColumn("voxelID");
man->FinishNtuple();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
RunAction::~RunAction()
{
delete[] fVoxelEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void RunAction::BeginOfRunAction(const G4Run *)
{
// Analysis manager
auto man = G4AnalysisManager::Instance();
man->OpenFile("phantom");
// Access phantom singleton
fMyPhantomParam = CellParameterisation::Instance();
fNbVoxels = fMyPhantomParam->GetPhantomTotalPixels();
// Allocates the array receiving the energy per voxel
fVoxelEnergy = new G4double[fNbVoxels];
// Initialisation of the energy array
for (G4int i = 0; i < fNbVoxels; i++) fVoxelEnergy[i] = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void RunAction::EndOfRunAction(const G4Run * /*aRun*/)
{
auto man = G4AnalysisManager::Instance();
G4double X, Y, Z;
// Total mass of voxel
G4double redMassTot=0.;
G4double greenMassTot=0.;
G4double blueMassTot=0.;
redMassTot = fMyPhantomParam->GetRedMass();
greenMassTot = fMyPhantomParam->GetGreenMass();
blueMassTot = fMyPhantomParam->GetBlueMass();
// (Optional) Numbers of voxel
//G4double redVox=0;
//G4double greenVox=0;
//G4double blueVox=0;
//redVox = fMyPhantomParam->GetRedTotalPixels();
//greenVox = fMyPhantomParam->GetGreenTotalPixels();
//blueVox = fMyPhantomParam->GetBlueTotalPixels();
// (Optional) Single voxel mass
//G4double redMass=0.;
//G4double greenMass=0.;
//G4double blueMass=0.;
//redMass = redMassTot/redVox;
//greenMass = greenMassTot/greenVox;
//blueMass = blueMassTot/blueVox;
// Save x, y, z and energy for every voxel having absorbed an energy above 0.
// Energy is in keV
// Dose is in Gy
for (G4int i = 0; i < fMyPhantomParam->GetPhantomTotalPixels(); i++)
{
if (fVoxelEnergy[i] > 0.)
{
X = (fMyPhantomParam->GetVoxelThreeVectorOriginal(i).x()) / um;
Y = (fMyPhantomParam->GetVoxelThreeVectorOriginal(i).y()) / um;
Z = (fMyPhantomParam->GetVoxelThreeVectorOriginal(i).z()) / um;
if (fMyPhantomParam->GetMaterial(i) == 1)
{
man->FillNtupleDColumn(1,0,X);
man->FillNtupleDColumn(1,1,Y);
man->FillNtupleDColumn(1,2,Z);
man->FillNtupleDColumn(1,3,fVoxelEnergy[i]/keV);
man->FillNtupleDColumn(1,4,((fVoxelEnergy[i]/joule)/(redMassTot/kg)));
man->FillNtupleIColumn(1,5,i);
man->AddNtupleRow(1);
}
else if (fMyPhantomParam->GetMaterial(i) == 2)
{
man->FillNtupleDColumn(2,0,X);
man->FillNtupleDColumn(2,1,Y);
man->FillNtupleDColumn(2,2,Z);
man->FillNtupleDColumn(2,3,fVoxelEnergy[i]/keV);
man->FillNtupleDColumn(2,4,((fVoxelEnergy[i]/joule)/(greenMassTot/kg)));
man->FillNtupleIColumn(2,5,i);
man->AddNtupleRow(2);
}
else if (fMyPhantomParam->GetMaterial(i) == 3)
{
man->FillNtupleDColumn(3,0,X);
man->FillNtupleDColumn(3,1,Y);
man->FillNtupleDColumn(3,2,Z);
man->FillNtupleDColumn(3,3,fVoxelEnergy[i]/keV);
man->FillNtupleDColumn(3,4,((fVoxelEnergy[i]/joule)/(blueMassTot/kg)));
man->FillNtupleIColumn(3,5,i);
man->AddNtupleRow(3);
}
}
}
// Save histograms
man->Write();
man->CloseFile();
// Complete clean-up
man->Clear();
}
@@ -0,0 +1,84 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------------------
// MONTE CARLO SIMULATION OF REALISTIC GEOMETRY FROM MICROSCOPES IMAGES
//
// Authors and contributors:
// P. Barberet, S. Incerti, N. H. Tran, L. Morelli
//
// University of Bordeaux, CNRS, LP2i, UMR5797, Gradignan, France
//
// If you use this code, please cite the following publication:
// P. Barberet et al.,
// "Monte-Carlo dosimetry on a realistic cell monolayer
// geometry exposed to alpha particles."
// Ph. Barberet et al 2012 Phys. Med. Biol. 57 2189
// doi: 110.1088/0031-9155/57/8/2189
// --------------------------------------------------------------------------------
#include "SteppingAction.hh"
#include "G4SteppingManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
SteppingAction::SteppingAction(RunAction* runAction)
:G4UserSteppingAction(), fRunAction(runAction)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
// ********************************************************************************
// Avoid string comparison to extract material (1, 2 or 3) whic causes issues in MT
// ********************************************************************************
fMyPhantomParam = CellParameterisation::Instance();
const G4StepPoint* preStep = aStep->GetPreStepPoint();
G4int preReplicaNumber = preStep->GetTouchableHandle()->GetReplicaNumber();
G4int voxelMaterial = fMyPhantomParam->GetMaterial(preReplicaNumber);
// The absorbed energy is added to the "voxel energy" array in RunAction
// Added protection to make sure Replica Number has been identified
if (aStep->GetTotalEnergyDeposit()>0. && preReplicaNumber>0)
{
if (voxelMaterial == 1)
{
fRunAction->AddDoseBox(preReplicaNumber, aStep->GetTotalEnergyDeposit());
}
else if (voxelMaterial == 2)
{
fRunAction->AddDoseBox(preReplicaNumber, aStep->GetTotalEnergyDeposit());
}
else if (voxelMaterial == 3)
{
fRunAction->AddDoseBox(preReplicaNumber, aStep->GetTotalEnergyDeposit());
}
}
}