Import Geant4 9.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:46:55 +02:00
parent 89a9605df1
commit b1eb5424d2
10957 changed files with 888481 additions and 160139 deletions
@@ -1,198 +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. *
// ********************************************************************
//
// Code developed by:
// S.Guatelli
//
// *******************************
// * *
// * BrachyAnalysisManager.cc *
// * *
// *******************************
//
// $Id: BrachyAnalysisManager.cc,v 1.22 2009/11/12 10:32:59 pandola Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
#ifdef G4ANALYSIS_USE
#include <stdlib.h>
#include <fstream>
#include "BrachyAnalysisManager.hh"
#include "G4ios.hh"
#include "AIDA/IHistogram1D.h"
#include "AIDA/IHistogram2D.h"
#include "AIDA/IManagedObject.h"
#include "AIDA/IAnalysisFactory.h"
#include "AIDA/IHistogramFactory.h"
#include "AIDA/ITupleFactory.h"
#include "AIDA/ITreeFactory.h"
#include "AIDA/ITree.h"
#include "AIDA/ITuple.h"
BrachyAnalysisManager* BrachyAnalysisManager::instance = 0;
BrachyAnalysisManager::BrachyAnalysisManager() :
aFact(0), theTree(0), histFact(0), tupFact(0), h1(0),
h2(0), h3(0), ntuple(0)
{
// Instantiate the factories
// The factories manage the analysis objects
aFact = AIDA_createAnalysisFactory();
AIDA::ITreeFactory *treeFact = aFact -> createTreeFactory();
// Definition of the output file
G4String fileName = "brachytherapy.root";
theTree = treeFact -> create(fileName,"ROOT",false, true);
delete treeFact;
}
BrachyAnalysisManager::~BrachyAnalysisManager()
{
delete tupFact;
tupFact = 0;
delete histFact;
histFact = 0;
delete theTree;
histFact = 0;
delete aFact;
aFact = 0;
}
BrachyAnalysisManager* BrachyAnalysisManager::getInstance()
{
if (instance == 0) instance = new BrachyAnalysisManager;
return instance;
}
void BrachyAnalysisManager::book()
{
// Instantiate the histogram and ntuple factories
histFact = aFact -> createHistogramFactory( *theTree );
tupFact = aFact -> createTupleFactory ( *theTree );
// Creating a 2D histogram
// Energy deposit in the plane containing the source
h1 = histFact -> createHistogram2D("10","Energy, pos", //histoID,histo name
300 ,-150.,150., //bins'number,xmin,xmax
300,-150.,150.); //bins'number,ymin,ymax
//creating a 1D histograms
// Histogram containing the initial energy (MeV) of the photons delivered by the radioactive core
h2 = histFact -> createHistogram1D("20","Initial Energy", //histoID, histo name
1000,0.,1.); //bins' number, xmin, xmax
// Histogram containing the energy deposit in the plane containing the source, along the axis
// perpendicular to the source main axis
h3 = histFact -> createHistogram1D("30","Energy deposit Distribution",
300,-150.,150.); //bins' number, xmin, xmax
//defining the ntuple columns' name
std::string columnNames = "double energy, x , y , z ";
std::string options = "";
//creating a ntuple
if (tupFact) ntuple = tupFact -> create("1","1",columnNames, options);
// check for non-zero ...
if (ntuple) G4cout<<"The Ntuple is non-zero"<<G4endl;
}
void BrachyAnalysisManager::FillNtupleWithEnergy(G4double xx,
G4double yy,
G4double zz,
G4double en)
{
if (ntuple == 0)
{
G4cout << "AAAAAAAGH..... The Ntuple is 0" << G4endl;
return;
}
// Fill the ntuple
G4int indexX = ntuple -> findColumn( "x" );
G4int indexY = ntuple -> findColumn( "y" );
G4int indexZ = ntuple -> findColumn( "z" );
G4int indexEnergy = ntuple -> findColumn( "energy" );
ntuple -> fill(indexEnergy, en);// method: fill ( int column, double value )
ntuple -> fill(indexX, xx);
ntuple -> fill(indexY, yy);
ntuple -> fill(indexZ, zz);
ntuple->addRow();
}
void BrachyAnalysisManager::FillHistogramWithEnergy(G4double x,
G4double z,
G4double energyDeposit)
{
// 2DHistogram: energy deposit in a voxel which center is fixed in position (x,z)
h1 -> fill(x,z,energyDeposit);
}
void BrachyAnalysisManager::PrimaryParticleEnergySpectrum(G4double primaryParticleEnergy)
{
// 1DHistogram: energy spectrum of primary particles
h2 -> fill(primaryParticleEnergy);
return;
}
void BrachyAnalysisManager::DoseDistribution(G4double x,G4double energy)
{
// 1DHistogram: energy spectrum of primary particles
h3 -> fill(x, energy);
}
void BrachyAnalysisManager::finish()
{
// write all histograms to file ...
theTree -> commit();
// close (will again commit) ...
theTree -> close();
}
#endif
@@ -55,13 +55,11 @@
#include "BrachyFactoryLeipzig.hh"
#include "BrachyFactoryIr.hh"
#include "BrachyFactoryI.hh"
#include "BrachyPhantomROGeometry.hh"
#include "BrachyPhantomSD.hh"
#include "BrachyDetectorMessenger.hh"
#include "BrachyDetectorConstruction.hh"
BrachyDetectorConstruction::BrachyDetectorConstruction(G4String &SDName)
: detectorChoice(0), phantomSD(0), phantomROGeometry(0), factory(0),
BrachyDetectorConstruction::BrachyDetectorConstruction()
: detectorChoice(0), factory(0),
World(0), WorldLog(0), WorldPhys(0),
Phantom(0), PhantomLog(0), PhantomPhys(0),
phantomAbsorberMaterial(0)
@@ -70,23 +68,12 @@ BrachyDetectorConstruction::BrachyDetectorConstruction(G4String &SDName)
phantomSizeX = 15.*cm ;
phantomSizeY = 15.*cm;
phantomSizeZ = 15.*cm;
// Define the number of voxels the phantom is subdivided along the
// three axis
// Each voxel is 1 mm wide
numberOfVoxelsAlongX = 300;
numberOfVoxelsAlongY = 300;
numberOfVoxelsAlongZ = 300;
ComputeDimVoxel();
// Define the sizes of the World volume contaning the phantom
// Define the sizes of the World volume containing the phantom
worldSizeX = 4.0*m;
worldSizeY = 4.0*m;
worldSizeZ = 4.0*m;
sensitiveDetectorName = SDName;
// Define the messenger of the Detector component
// It is possible to modify geometrical parameters through UI
detectorMessenger = new BrachyDetectorMessenger(this);
@@ -104,7 +91,6 @@ BrachyDetectorConstruction::~BrachyDetectorConstruction()
delete pMaterial;
delete factory;
delete detectorMessenger;
if (phantomROGeometry) delete phantomROGeometry;
}
G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
@@ -115,10 +101,7 @@ G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
ConstructPhantom();
// Model the source in the phantom
factory -> CreateSource(PhantomPhys); //Build the source inside the phantom
// Define the sensitive volume: phantom
ConstructSensitiveDetector();
factory -> CreateSource(PhantomPhys);
return WorldPhys;
}
@@ -185,8 +168,6 @@ void BrachyDetectorConstruction::ConstructPhantom()
G4Material* air = pMaterial -> GetMat("Air") ;
G4Material* water = pMaterial -> GetMat("Water");
ComputeDimVoxel();
// World volume
World = new G4Box("World",worldSizeX,worldSizeY,worldSizeZ);
WorldLog = new G4LogicalVolume(World,air,"WorldLog",0,0,0);
@@ -216,29 +197,6 @@ void BrachyDetectorConstruction::ConstructPhantom()
PhantomLog -> SetVisAttributes(simpleBoxVisAtt);
}
void BrachyDetectorConstruction::ConstructSensitiveDetector()
// Sensitive Detector and ReadOut geometry definition
{
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
if(!phantomSD)
{
phantomSD = new BrachyPhantomSD(sensitiveDetectorName);
G4String ROGeometryName = "PhantomROGeometry";
phantomROGeometry = new BrachyPhantomROGeometry(ROGeometryName,
phantomSizeX,
phantomSizeY,
phantomSizeZ,
numberOfVoxelsAlongX,
numberOfVoxelsAlongY,
numberOfVoxelsAlongZ);
phantomROGeometry -> BuildROGeometry();
phantomSD -> SetROgeometry(phantomROGeometry);
pSDManager -> AddNewDetector(phantomSD);
PhantomLog -> SetSensitiveDetector(phantomSD);
}
}
void BrachyDetectorConstruction::PrintDetectorParameters()
{
@@ -251,11 +209,6 @@ void BrachyDetectorConstruction::PrintDetectorParameters()
<< " cm * "
<< phantomSizeZ *2./cm
<< " cm" << G4endl
<< "number of Voxel: "
<< numberOfVoxelsAlongX <<G4endl
<< "Voxel size: "
<< dimVoxel * 2/mm
<< "mm" << G4endl
<< "The phantom is made of "
<< phantomAbsorberMaterial -> GetName() <<G4endl
<< "the source is at the center of the phantom" << G4endl
@@ -36,8 +36,8 @@
// * *
// ****************************************
//
// $Id: BrachyDetectorConstructionI.cc,v 1.9 2006/06/29 15:48:11 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyDetectorConstructionI.cc,v 1.9 2006-06-29 15:48:11 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
#include "BrachyDetectorConstructionI.hh"
@@ -37,8 +37,8 @@
// * *
// ****************************************
//
// $Id: BrachyDetectorConstructionIr.cc,v 1.10 2006/06/29 15:48:13 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyDetectorConstructionIr.cc,v 1.10 2006-06-29 15:48:13 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
#include "BrachyDetectorConstructionIr.hh"
@@ -38,8 +38,8 @@
// *******************************************
//
//
// $Id: BrachyDetectorConstructionLeipzig.cc,v 1.10 2006/06/29 15:48:16 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyDetectorConstructionLeipzig.cc,v 1.10 2006-06-29 15:48:16 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
@@ -34,8 +34,8 @@
// *********************************
//
//
// $Id: BrachyDetectorMessenger.cc,v 1.12 2006/06/29 15:48:18 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyDetectorMessenger.cc,v 1.12 2006-06-29 15:48:18 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//
@@ -34,8 +34,8 @@
// * *
// *******************************
//
// $Id: BrachyFactory.cc,v 1.7 2006/06/29 15:48:23 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyFactory.cc,v 1.7 2006-06-29 15:48:23 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// Factory of brachytherapic sources
//
@@ -32,8 +32,8 @@
// * *
// *******************************
//
// $Id: BrachyFactoryI.cc,v 1.6 2006/06/29 15:48:26 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyFactoryI.cc,v 1.6 2006-06-29 15:48:26 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "BrachyFactoryI.hh"
#include "BrachyPrimaryGeneratorActionI.hh"
@@ -32,8 +32,8 @@
// * *
// *******************************
//
// $Id: BrachyFactoryIr.cc,v 1.6 2006/06/29 15:48:29 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyFactoryIr.cc,v 1.6 2006-06-29 15:48:29 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
#include "BrachyFactoryIr.hh"
@@ -32,8 +32,8 @@
// * *
// *******************************
//
// $Id: BrachyFactoryLeipzig.cc,v 1.6 2006/06/29 15:48:31 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyFactoryLeipzig.cc,v 1.6 2006-06-29 15:48:31 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
@@ -32,8 +32,8 @@
// * *
// *******************************
//
// $Id: BrachyMaterial.cc,v 1.7 2006/06/29 15:48:33 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyMaterial.cc,v 1.7 2006-06-29 15:48:33 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "G4MaterialPropertiesTable.hh"
@@ -1,191 +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. *
// ********************************************************************
//
//
// Code developed by:
// S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano, S.Guatelli
//
// ************************************
// * *
// * BrachyPhantomROGeometry.cc *
// * *
// ************************************
//
// $Id: BrachyPhantomROGeometry.cc,v 1.11 2006/06/29 15:48:36 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
#include "BrachyPhantomROGeometry.hh"
#include "BrachyDummySD.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4Box.hh"
#include "G4ThreeVector.hh"
#include "G4Material.hh"
BrachyPhantomROGeometry::BrachyPhantomROGeometry(G4String aString,
G4double phantomDimX,
G4double phantomDimY,
G4double phantomDimZ,
G4int numberOfVoxelsX,
G4int numberOfVoxelsY,
G4int numberOfVoxelsZ):
G4VReadOutGeometry(aString),
phantomSizeX(phantomDimX),
phantomSizeY(phantomDimY),
phantomSizeZ(phantomDimZ),
numberOfVoxelsAlongX(numberOfVoxelsX),
numberOfVoxelsAlongY(numberOfVoxelsY),
numberOfVoxelsAlongZ(numberOfVoxelsZ)
{
}
BrachyPhantomROGeometry::~BrachyPhantomROGeometry()
{
}
G4VPhysicalVolume* BrachyPhantomROGeometry::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);
G4double worldSizeX = 4.0*m;
G4double worldSizeY = 4.0*m;
G4double worldSizeZ = 4.0*m;
G4double halfPhantomSizeX = phantomSizeX;
G4double halfPhantomSizeZ = phantomSizeZ;
G4double halfPhantomSizeY = phantomSizeY;
// variables for x division ...
G4double halfVoxelSize = halfPhantomSizeX/numberOfVoxelsAlongX;
G4double halfSize = halfPhantomSizeZ;
G4double voxelThickness = 2*halfVoxelSize;
// world volume of ROGeometry ...
G4Box *ROWorld = new G4Box("ROWorld",
worldSizeX,
worldSizeY,
worldSizeZ);
G4LogicalVolume *ROWorldLog = new G4LogicalVolume(ROWorld,
dummyMat,
"ROWorldLog",
0,0,0);
G4VPhysicalVolume *ROWorldPhys = new G4PVPlacement(0,
G4ThreeVector(),
"ROWorldPhys",
ROWorldLog,
0,false,0);
// Phantom ROGeometry ...
G4Box *ROPhantom = new G4Box("ROPhantom",
halfPhantomSizeX,
halfPhantomSizeY,
halfPhantomSizeZ);
G4LogicalVolume *ROPhantomLog = new G4LogicalVolume(ROPhantom,
dummyMat,
"ROPhantomLog",
0,0,0);
G4VPhysicalVolume *ROPhantomPhys = new G4PVPlacement(0,
G4ThreeVector(),
"PhantomPhys",
ROPhantomLog,
ROWorldPhys,
false,0);
// ROGeometry: Voxel division
// X division first...
G4Box *ROPhantomXDivision = new G4Box("ROPhantomXDivision",
halfVoxelSize,
halfSize,
halfSize);
G4LogicalVolume *ROPhantomXDivisionLog = new G4LogicalVolume(ROPhantomXDivision,
dummyMat,
"ROPhantomXDivisionLog",
0,0,0);
G4VPhysicalVolume *ROPhantomXDivisionPhys = new G4PVReplica("ROPhantomXDivisionPhys",
ROPhantomXDivisionLog,
ROPhantomPhys,
kXAxis,
numberOfVoxelsAlongX,
voxelThickness);
// ...then Z division
G4Box *ROPhantomZDivision = new G4Box("ROPhantomZDivision",
halfVoxelSize,
halfSize,
halfVoxelSize);
G4LogicalVolume *ROPhantomZDivisionLog = new G4LogicalVolume(ROPhantomZDivision,
dummyMat,
"ROPhantomZDivisionLog",
0,0,0);
G4VPhysicalVolume *ROPhantomZDivisionPhys = new G4PVReplica("ROPhantomZDivisionPhys",
ROPhantomZDivisionLog,
ROPhantomXDivisionPhys,
kZAxis,
numberOfVoxelsAlongZ,
voxelThickness);
// ...then Y division
G4Box *ROPhantomYDivision = new G4Box("ROPhantomYDivision",
halfVoxelSize,
halfVoxelSize,
halfVoxelSize);
G4LogicalVolume *ROPhantomYDivisionLog = new G4LogicalVolume(ROPhantomYDivision,
dummyMat,
"ROPhantomYDivisionLog",
0,0,0);
ROPhantomYDivisionPhys = new G4PVReplica("ROPhantomYDivisionPhys",
ROPhantomYDivisionLog,
ROPhantomZDivisionPhys,
kYAxis,
numberOfVoxelsAlongY,
voxelThickness);
BrachyDummySD *dummySD = new BrachyDummySD;
ROPhantomYDivisionLog -> SetSensitiveDetector(dummySD);
return ROWorldPhys;
}
@@ -1,145 +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. *
// ********************************************************************
//
//
// Code developed by:
// S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano, S.Guatelli
//
// ********************************
// * *
// * BrachyPhantomSD.cc *
// * *
// ********************************
//
// $Id: BrachyPhantomSD.cc,v 1.14 2009/02/23 17:34:26 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
#include "BrachyPhantomSD.hh"
#ifdef G4ANALYSIS_USE
#include "BrachyAnalysisManager.hh"
#endif
#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"
BrachyPhantomSD::BrachyPhantomSD(G4String name):G4VSensitiveDetector(name)
{
}
BrachyPhantomSD::~BrachyPhantomSD()
{
}
void BrachyPhantomSD::Initialize(G4HCofThisEvent*)
{
}
G4bool BrachyPhantomSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
{
//
// The energy deposit of the hits is stored in histograms and ntuples
//
if(!ROhist)
return false;
// Check the volume
if(aStep -> GetPreStepPoint() -> GetPhysicalVolume() ->
GetName() != "PhantomPhys")
return false;
G4double energyDeposit = aStep -> GetTotalEnergyDeposit();
// Check that the energy deposit is not null
if(energyDeposit == 0.)
return false;
if(energyDeposit != 0)
{
// Read Voxel indexes:
// i is the x index,
// j is the y index
// k is the z index
G4int j = ROhist -> GetReplicaNumber();
G4int k = ROhist -> GetReplicaNumber(1);
G4int i = ROhist -> GetReplicaNumber(2);
G4int numberOfVoxel = 300;
G4double voxelWidth = 1. *mm;
// Retrieve the coordinates of the center of the voxel where
// the energy deposit is located
x = ( - numberOfVoxel + 1+ 2*i )* voxelWidth/2;
y = ( - numberOfVoxel + 1+ 2*j )* voxelWidth/2;
z = ( - numberOfVoxel + 1+ 2*k )* voxelWidth/2;
#ifdef G4ANALYSIS_USE
BrachyAnalysisManager* analysis =
BrachyAnalysisManager::getInstance();
// Fill the ntuple with position and energy deposit in the phantom
analysis -> FillNtupleWithEnergy(x,y,z,energyDeposit/MeV);
if (y < 0.8 * mm && y > -0.8 * mm)
{
// Fill a 2D histogram with the energy deposit in the plane
// containing the source
analysis -> FillHistogramWithEnergy(x,z,energyDeposit/MeV);
// Fill 1D histogram with the energy deposit
// along the axis perpendicular to the main axis of the source
if (z < 0.8 * mm && z > -0.8 * mm)
analysis -> DoseDistribution(x,energyDeposit/MeV);
}
#endif
}
return true;
}
void BrachyPhantomSD::EndOfEvent(G4HCofThisEvent*)
{
}
void BrachyPhantomSD::clear()
{
}
void BrachyPhantomSD::DrawAll()
{
}
void BrachyPhantomSD::PrintAll()
{
}
@@ -35,8 +35,8 @@
// * *
// **********************************
//
// $Id: BrachyPhysicsList.cc,v 1.15 2010/11/24 15:56:19 cirrone Exp $
// GEANT4 tag $Name: geant4-09-04 $
// $Id: BrachyPhysicsList.cc,v 1.15 2010-11-24 15:56:19 cirrone Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "BrachyPhysicsList.hh"
@@ -37,14 +37,11 @@
// * *
// ********************************************
//
// $Id: BrachyPrimaryGeneratorAction.cc,v 1.19 2009/02/23 17:34:26 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: BrachyPrimaryGeneratorAction.cc,v 1.19 2009-02-23 17:34:26 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "globals.hh"
#include "BrachyPrimaryGeneratorAction.hh"
#ifdef G4ANALYSIS_USE
#include "BrachyAnalysisManager.hh"
#endif
#include "G4ParticleTable.hh"
#include "Randomize.hh"
#include "G4Event.hh"
@@ -37,15 +37,10 @@
// * *
// ********************************************
//
// $Id: BrachyPrimaryGeneratorActionI.cc,v 1.10 2006/06/29 15:48:48 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyPrimaryGeneratorActionI.cc,v 1.10 2006-06-29 15:48:48 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "BrachyPrimaryGeneratorActionI.hh"
#ifdef G4ANALYSIS_USE
#include "BrachyAnalysisManager.hh"
#endif
#include "globals.hh"
#include "G4ParticleTable.hh"
#include "Randomize.hh"
@@ -76,10 +71,6 @@ BrachyPrimaryGeneratorActionI::~BrachyPrimaryGeneratorActionI()
void BrachyPrimaryGeneratorActionI::GeneratePrimaries(G4Event* anEvent)
{
#ifdef G4ANALYSIS_USE
BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
#endif
// Define the primary particle type
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String ParticleName = "gamma";
@@ -134,11 +125,6 @@ void BrachyPrimaryGeneratorActionI::GeneratePrimaries(G4Event* anEvent)
particleGun -> SetParticleEnergy(primaryParticleEnergy);
// Fill 1D histogram with gamma energy spectrum ...
#ifdef G4ANALYSIS_USE
analysis -> PrimaryParticleEnergySpectrum(primaryParticleEnergy);
#endif
// generate primary particle
particleGun->GeneratePrimaryVertex(anEvent);
}
@@ -37,15 +37,10 @@
// * *
// ********************************************
//
// $Id: BrachyPrimaryGeneratorActionIr.cc,v 1.11 2006/06/29 15:48:51 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyPrimaryGeneratorActionIr.cc,v 1.11 2006-06-29 15:48:51 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "BrachyPrimaryGeneratorActionIr.hh"
#ifdef G4ANALYSIS_USE
#include "BrachyAnalysisManager.hh"
#endif
#include "globals.hh"
#include "G4ParticleTable.hh"
#include "Randomize.hh"
@@ -69,9 +64,6 @@ BrachyPrimaryGeneratorActionIr::~BrachyPrimaryGeneratorActionIr()
void BrachyPrimaryGeneratorActionIr::GeneratePrimaries(G4Event* anEvent)
{
#ifdef G4ANALYSIS_USE
BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
#endif
// Define primary particle type
G4ParticleTable* pParticleTable = G4ParticleTable::GetParticleTable();
@@ -113,11 +105,7 @@ void BrachyPrimaryGeneratorActionIr::GeneratePrimaries(G4Event* anEvent)
primaryParticleEnergy = 356.*keV;
particleGun->SetParticleEnergy(primaryParticleEnergy);
//1D Histogram of primary particle energy ...
#ifdef G4ANALYSIS_USE
analysis -> PrimaryParticleEnergySpectrum(primaryParticleEnergy);
#endif
// Generate a primary particle
particleGun -> GeneratePrimaryVertex(anEvent);
}
@@ -34,8 +34,8 @@
// *****************************************
//
//
// $Id: BrachyPrimaryGeneratorMessenger.cc,v 1.3 2006/06/29 15:48:54 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyPrimaryGeneratorMessenger.cc,v 1.3 2006-06-29 15:48:54 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//
@@ -38,48 +38,32 @@
// * *
// *******************************
//
// $Id: BrachyRunAction.cc,v 1.18 2006/06/29 15:48:57 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: BrachyRunAction.cc,v 1.18 2006-06-29 15:48:57 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
#include "BrachyRunAction.hh"
#ifdef G4ANALYSIS_USE
#include "BrachyAnalysisManager.hh"
#endif
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "BrachyRunAction.hh"
BrachyRunAction::BrachyRunAction()
{
}
{}
BrachyRunAction::~BrachyRunAction()
{
}
{}
void BrachyRunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun -> GetRunID() << " start." << G4endl;
#ifdef G4ANALYSIS_USE
G4int runNb = aRun -> GetRunID();
if (runNb == 0)
{
BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
analysis->book();
}
else { G4cout << "The results of Run:"<< runNb << " are summed to the" <<
" results of the previous Run in brachytherapy.hbk" << G4endl;}
#endif
}
void BrachyRunAction::EndOfRunAction(const G4Run* aRun)
{
G4cout << "number of events = " << aRun->GetNumberOfEvent() << G4endl;
{
G4cout << "number of events = " << aRun->GetNumberOfEvent() << G4endl;
}
@@ -0,0 +1,160 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
/*
// Code developed by:
// S.Guatelli, susanna@uow.edu.au
//
Original code from geant4/examples/extended/runAndEvent/RE03, by M. Asai
*/
#include "BrachyUserScoreWriter.hh"
#include "BrachyAnalysis.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4VScoringMesh.hh"
#include <map>
#include <fstream>
// The default output is
// voxelX, voxelY, voxelZ, edep
// The BrachyUserScoreWriter allows to change the format of the output file.
// in the specific case:
// xx (mm) yy(mm) zz(mm) edep(keV)
// The same information is stored in a ntuple, in the
// brachytherapy.root file
BrachyUserScoreWriter::BrachyUserScoreWriter(): G4VScoreWriter()
{;}
BrachyUserScoreWriter::~BrachyUserScoreWriter()
{;}
void BrachyUserScoreWriter::DumpQuantityToFile(G4String & psName, G4String & fileName, G4String & option)
{
if(verboseLevel > 0) {
G4cout << "BrachyUserScorer-defined DumpQuantityToFile() method is invoked."
<< G4endl; }
// change the option string into lowercase to the case-insensitive.
G4String opt = option;
std::transform(opt.begin(), opt.end(), opt.begin(), (int (*)(int))(tolower));
// confirm the option
if(opt.size() == 0) opt = "csv";
// open the file
std::ofstream ofile(fileName);
if(!ofile) {
G4cerr << "ERROR : DumpToFile : File open error -> "
<< fileName << G4endl;
return;
}
ofile << "# mesh name: " << fScoringMesh->GetWorldName() << G4endl;
// retrieve the map
MeshScoreMap fSMap = fScoringMesh -> GetScoreMap();
MeshScoreMap::const_iterator msMapItr = fSMap.find(psName);
if(msMapItr == fSMap.end()) {
G4cerr << "ERROR : DumpToFile : Unknown quantity, \""
<< psName << "\"." << G4endl;
return;
}
std::map<G4int, G4double*> * score = msMapItr -> second-> GetMap();
ofile << "# primitive scorer name: " << msMapItr -> first << G4endl;
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
//
// Open a ROOT output file
//
analysisManager -> OpenFile("brachytherapy");
//
// Creating ntuple
//
analysisManager -> CreateNtuple("EnergyDeposition", "Edep(keV) in the phantom");
analysisManager -> CreateNtupleDColumn("xx");
analysisManager -> CreateNtupleDColumn("yy");
analysisManager -> CreateNtupleDColumn("zz");
analysisManager -> CreateNtupleDColumn("edep");
analysisManager -> FinishNtuple();
//
// Write quantity in the ASCII output file and in brachytherapy.root
//
ofile << std::setprecision(16); // for double value with 8 bytes
for(int x = 0; x < fNMeshSegments[0]; x++) {
for(int y = 0; y < fNMeshSegments[1]; y++) {
for(int z = 0; z < fNMeshSegments[2]; z++) {
G4int numberOfVoxel = fNMeshSegments[0];
// If the voxel width is changed in the macro file,
// the voxel width variable must be updated
G4double voxelWidth = 1. *mm;
//
G4double xx = ( - numberOfVoxel + 1+ 2*x )* voxelWidth/2;
G4double yy = ( - numberOfVoxel + 1+ 2*y )* voxelWidth/2;
G4double zz = ( - numberOfVoxel + 1+ 2*z )* voxelWidth/2;
G4int idx = GetIndex(x, y, z);
std::map<G4int, G4double*>::iterator value = score -> find(idx);
if (value != score -> end())
{
// Print in the ASCII output file the information
ofile << xx << " " << yy << " " << zz <<" " <<*(value->second)/keV << G4endl;
// Save the same information in the output analysis file
analysisManager = G4AnalysisManager::Instance();
analysisManager -> FillNtupleDColumn(0, xx);
analysisManager -> FillNtupleDColumn(1, yy);
analysisManager -> FillNtupleDColumn(2, zz);
analysisManager -> FillNtupleDColumn(3, *(value->second)/keV);
analysisManager -> AddNtupleRow();
}
}
}
}
ofile << std::setprecision(6);
// Close the output ASCII file
ofile.close();
// Close the output brachytherapy.root
analysisManager -> Write();
analysisManager -> CloseFile();
}