Import Geant4 10.5.0 source tree
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
|
||||
#ifndef Analysis_h
|
||||
#define Analysis_h 1
|
||||
|
||||
//#include "g4root.hh"
|
||||
#include "g4csv.hh"
|
||||
//#include "g4xml.hh"
|
||||
|
||||
#endif
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class HadrontherapyAnalysisManager; ///< Provides SetanalysisFileName()
|
||||
class HadrontherapyAnalysis; ///< Provides SetanalysisFileName()
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithABool;
|
||||
|
||||
@@ -49,7 +49,7 @@ class G4UIcmdWithABool;
|
||||
class HadrontherapyAnalysisFileMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
HadrontherapyAnalysisFileMessenger(HadrontherapyAnalysisManager*);
|
||||
HadrontherapyAnalysisFileMessenger(HadrontherapyAnalysis*);
|
||||
~HadrontherapyAnalysisFileMessenger();
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* @return is void
|
||||
*/
|
||||
void SetNewValue(G4UIcommand* command, G4String newValue);
|
||||
HadrontherapyAnalysisManager* AnalysisManager; ///< handle to AnalysisManager
|
||||
HadrontherapyAnalysis* AnalysisManager; ///< handle to AnalysisManager
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -45,157 +45,167 @@ class HadrontherapyDetectorSD;
|
||||
class HadrontherapyMatrix;
|
||||
class HadrontherapyLet;
|
||||
|
||||
class HadrontherapyDetectorConstruction
|
||||
class HadrontherapyDetectorConstruction
|
||||
{
|
||||
public:
|
||||
|
||||
HadrontherapyDetectorConstruction(G4VPhysicalVolume*);
|
||||
|
||||
~HadrontherapyDetectorConstruction();
|
||||
|
||||
|
||||
HadrontherapyDetectorConstruction(G4VPhysicalVolume*);
|
||||
|
||||
~HadrontherapyDetectorConstruction();
|
||||
|
||||
public:
|
||||
static HadrontherapyDetectorConstruction* GetInstance();
|
||||
void InitializeDetectorROGeometry(HadrontherapyDetectorROGeometry*,
|
||||
G4ThreeVector detectorToWorldPosition);
|
||||
G4VPhysicalVolume* motherPhys;
|
||||
HadrontherapyDetectorSD* detectorSD; // Pointer to sensitive detector
|
||||
static HadrontherapyDetectorConstruction* GetInstance();
|
||||
void InitializeDetectorROGeometry(HadrontherapyDetectorROGeometry*,
|
||||
G4ThreeVector detectorToWorldPosition);
|
||||
G4VPhysicalVolume* motherPhys;
|
||||
HadrontherapyDetectorSD* detectorSD; // Pointer to sensitive detector
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void ConstructPhantom();
|
||||
void ConstructDetector();
|
||||
void ParametersCheck();
|
||||
void CheckOverlaps();
|
||||
|
||||
public:
|
||||
// Get detector position relative to WORLD
|
||||
inline G4ThreeVector GetDetectorToWorldPosition()
|
||||
{
|
||||
return phantomPosition + detectorPosition;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Get displacement between phantom and detector by detector position (center of), phantom (center of) and detector sizes
|
||||
inline G4ThreeVector GetDetectorToPhantomPosition()
|
||||
{
|
||||
return G4ThreeVector(phantomSizeX/2 - detectorSizeX/2 + detectorPosition.getX(),
|
||||
phantomSizeY/2 - detectorSizeY/2 + detectorPosition.getY(),
|
||||
phantomSizeZ/2 - detectorSizeZ/2 + detectorPosition.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate (and set) detector position by displacement, phantom and detector sizes
|
||||
inline void SetDetectorPosition()
|
||||
{
|
||||
// Adjust detector position
|
||||
detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX/2 + detectorSizeX/2);
|
||||
detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY/2 + detectorSizeY/2);
|
||||
detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ/2 + detectorSizeZ/2);
|
||||
|
||||
//////////////////////////
|
||||
void VirtualLayer(G4bool Varbool);
|
||||
G4bool NewSource;
|
||||
void SetVirtualLayerPosition(G4ThreeVector);
|
||||
G4ThreeVector VirtualLayerPosition;
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Check whether detector is inside phantom
|
||||
inline bool IsInside(G4double detectorX,
|
||||
G4double detectorY,
|
||||
G4double detectorZ,
|
||||
G4double phantomX,
|
||||
G4double phantomY,
|
||||
G4double phantomZ,
|
||||
G4ThreeVector pos)
|
||||
{
|
||||
// Dimensions check... X Y and Z
|
||||
// Firstly check what dimension we are modifying
|
||||
{
|
||||
if (detectorX > phantomX)
|
||||
{
|
||||
G4cout << "Error: Detector X dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( (phantomX - detectorX) < pos.getX())
|
||||
{
|
||||
G4cout << "Error: X dimension doesn't fit with detector to phantom relative position" << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (detectorY > phantomY)
|
||||
{
|
||||
G4cout << "Error: Detector Y dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( (phantomY - detectorY) < pos.getY())
|
||||
{
|
||||
G4cout << "Error: Y dimension doesn't fit with detector to phantom relative position" << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (detectorZ > phantomZ)
|
||||
{
|
||||
G4cout << "Error: Detector Z dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( (phantomZ - detectorZ) < pos.getZ())
|
||||
{
|
||||
G4cout << "Error: Z dimension doesn't fit with detector to phantom relative position" << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4bool SetPhantomMaterial(G4String material);
|
||||
void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ);
|
||||
void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ);
|
||||
void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ);
|
||||
void SetPhantomPosition(G4ThreeVector);
|
||||
void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition);
|
||||
void UpdateGeometry();
|
||||
void PrintParameters();
|
||||
G4LogicalVolume* GetDetectorLogicalVolume(){ return detectorLogicalVolume;}
|
||||
|
||||
//////////////////////////
|
||||
private:
|
||||
static HadrontherapyDetectorConstruction* instance;
|
||||
HadrontherapyDetectorMessenger* detectorMessenger;
|
||||
|
||||
G4VisAttributes* skyBlue;
|
||||
G4VisAttributes* red;
|
||||
|
||||
HadrontherapyDetectorROGeometry* detectorROGeometry; // Pointer to ROGeometry
|
||||
HadrontherapyMatrix* matrix;
|
||||
HadrontherapyLet* let;
|
||||
|
||||
G4Box *phantom , *detector;
|
||||
G4LogicalVolume *phantomLogicalVolume, *detectorLogicalVolume;
|
||||
G4VPhysicalVolume *phantomPhysicalVolume, *detectorPhysicalVolume;
|
||||
|
||||
G4double phantomSizeX;
|
||||
G4double phantomSizeY;
|
||||
G4double phantomSizeZ;
|
||||
|
||||
G4double detectorSizeX;
|
||||
G4double detectorSizeY;
|
||||
G4double detectorSizeZ;
|
||||
|
||||
G4ThreeVector phantomPosition, detectorPosition, detectorToPhantomPosition; // phantom center, detector center, detector to phantom relative position
|
||||
|
||||
G4double sizeOfVoxelAlongX;
|
||||
G4double sizeOfVoxelAlongY;
|
||||
G4double sizeOfVoxelAlongZ;
|
||||
|
||||
G4int numberOfVoxelsAlongX;
|
||||
G4int numberOfVoxelsAlongY;
|
||||
G4int numberOfVoxelsAlongZ;
|
||||
|
||||
G4double volumeOfVoxel, massOfVoxel;
|
||||
|
||||
G4Material *phantomMaterial, *detectorMaterial;
|
||||
G4Region* aRegion;
|
||||
|
||||
void ConstructPhantom();
|
||||
void ConstructDetector();
|
||||
void ParametersCheck();
|
||||
void CheckOverlaps();
|
||||
|
||||
public:
|
||||
// Get detector position relative to WORLD
|
||||
inline G4ThreeVector GetDetectorToWorldPosition()
|
||||
{
|
||||
return phantomPosition + detectorPosition;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Get displacement between phantom and detector by detector position (center of), phantom (center of) and detector sizes
|
||||
inline G4ThreeVector GetDetectorToPhantomPosition()
|
||||
{
|
||||
return G4ThreeVector(phantomSizeX/2 - detectorSizeX/2 + detectorPosition.getX(),
|
||||
phantomSizeY/2 - detectorSizeY/2 + detectorPosition.getY(),
|
||||
phantomSizeZ/2 - detectorSizeZ/2 + detectorPosition.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate (and set) detector position by displacement, phantom and detector sizes
|
||||
inline void SetDetectorPosition()
|
||||
{
|
||||
// Adjust detector position
|
||||
detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX/2 + detectorSizeX/2);
|
||||
detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY/2 + detectorSizeY/2);
|
||||
detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ/2 + detectorSizeZ/2);
|
||||
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Check whether detector is inside phantom
|
||||
inline bool IsInside(G4double detectorX,
|
||||
G4double detectorY,
|
||||
G4double detectorZ,
|
||||
G4double phantomX,
|
||||
G4double phantomY,
|
||||
G4double phantomZ,
|
||||
G4ThreeVector pos)
|
||||
{
|
||||
// Dimensions check... X Y and Z
|
||||
// Firstly check what dimension we are modifying
|
||||
{
|
||||
if (detectorX > phantomX)
|
||||
{
|
||||
G4cout << "Error: Detector X dimension must be smaller or equal to the correspondent of the phantom" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( (phantomX - detectorX) < pos.getX())
|
||||
{
|
||||
G4cout << "Error: X dimension doesn't fit with detector to phantom relative position" << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (detectorY > phantomY)
|
||||
{
|
||||
G4cout << "Error: Detector Y dimension must be smaller or equal to the correspondent of the phantom" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( (phantomY - detectorY) < pos.getY())
|
||||
{
|
||||
G4cout << "Error: Y dimension doesn't fit with detector to phantom relative position" << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (detectorZ > phantomZ)
|
||||
{
|
||||
G4cout << "Error: Detector Z dimension must be smaller or equal to the correspondent of the phantom" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if ( (phantomZ - detectorZ) < pos.getZ())
|
||||
{
|
||||
G4cout << "Error: Z dimension doesn't fit with detector to phantom relative position" << G4endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4bool SetPhantomMaterial(G4String material);
|
||||
void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ);
|
||||
void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ);
|
||||
void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ);
|
||||
void SetPhantomPosition(G4ThreeVector);
|
||||
void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition);
|
||||
void UpdateGeometry();
|
||||
void PrintParameters();
|
||||
G4LogicalVolume* GetDetectorLogicalVolume(){ return detectorLogicalVolume;}
|
||||
|
||||
private:
|
||||
static HadrontherapyDetectorConstruction* instance;
|
||||
HadrontherapyDetectorMessenger* detectorMessenger;
|
||||
|
||||
G4VisAttributes* skyBlue;
|
||||
G4VisAttributes* red;
|
||||
|
||||
HadrontherapyDetectorROGeometry* detectorROGeometry; // Pointer to ROGeometry
|
||||
HadrontherapyMatrix* matrix;
|
||||
HadrontherapyLet* let;
|
||||
|
||||
G4Box *phantom , *detector;
|
||||
G4LogicalVolume *phantomLogicalVolume, *detectorLogicalVolume;
|
||||
G4VPhysicalVolume *phantomPhysicalVolume, *detectorPhysicalVolume;
|
||||
|
||||
G4Box* solidVirtualLayer;
|
||||
G4LogicalVolume* logicVirtualLayer;
|
||||
G4VPhysicalVolume* physVirtualLayer;
|
||||
|
||||
G4double phantomSizeX;
|
||||
G4double phantomSizeY;
|
||||
G4double phantomSizeZ;
|
||||
|
||||
G4double detectorSizeX;
|
||||
G4double detectorSizeY;
|
||||
G4double detectorSizeZ;
|
||||
|
||||
G4ThreeVector phantomPosition, detectorPosition, detectorToPhantomPosition; // phantom center, detector center, detector to phantom relative position
|
||||
|
||||
G4double sizeOfVoxelAlongX;
|
||||
G4double sizeOfVoxelAlongY;
|
||||
G4double sizeOfVoxelAlongZ;
|
||||
|
||||
G4int numberOfVoxelsAlongX;
|
||||
G4int numberOfVoxelsAlongY;
|
||||
G4int numberOfVoxelsAlongZ;
|
||||
|
||||
G4double volumeOfVoxel, massOfVoxel;
|
||||
|
||||
G4Material *phantomMaterial, *detectorMaterial;
|
||||
G4Region* aRegion;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -35,34 +35,38 @@
|
||||
class HadrontherapyDetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWith3VectorAndUnit;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithABool;
|
||||
|
||||
class HadrontherapyDetectorMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* );
|
||||
~HadrontherapyDetectorMessenger();
|
||||
HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* );
|
||||
~HadrontherapyDetectorMessenger();
|
||||
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
|
||||
private:
|
||||
|
||||
// Pointer to the phantom/detector
|
||||
HadrontherapyDetectorConstruction* hadrontherapyDetector;
|
||||
|
||||
G4UIdirectory *changeThePhantomDir, *changeTheDetectorDir;
|
||||
|
||||
G4UIcmdWithoutParameter *updateCmd;
|
||||
G4UIcmdWithAString *changeThePhantomMaterialCmd;
|
||||
G4UIcmdWith3VectorAndUnit *changeThePhantomSizeCmd,
|
||||
*changeThePhantomPositionCmd,
|
||||
*changeTheDetectorSizeCmd,
|
||||
|
||||
// Pointer to the phantom/detector
|
||||
HadrontherapyDetectorConstruction* hadrontherapyDetector;
|
||||
|
||||
G4UIdirectory *changeThePhantomDir, *changeTheDetectorDir;
|
||||
|
||||
G4UIcmdWithoutParameter *updateCmd;
|
||||
G4UIcmdWithAString *changeThePhantomMaterialCmd;
|
||||
G4UIcmdWith3VectorAndUnit *changeThePhantomSizeCmd,
|
||||
*changeThePhantomPositionCmd,
|
||||
*changeTheDetectorSizeCmd,
|
||||
*changeTheDetectorToPhantomPositionCmd,
|
||||
*changeTheDetectorVoxelCmd;
|
||||
|
||||
|
||||
*changeTheDetectorVoxelCmd,
|
||||
*VirtualLayerPosition;
|
||||
|
||||
G4UIcmdWithABool *VirtualLayer;
|
||||
G4UIdirectory* changeTheSource;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,19 +38,20 @@ class G4TouchableHistory;
|
||||
class HadrontherapyDetectorSD : public G4VSensitiveDetector
|
||||
{
|
||||
public:
|
||||
HadrontherapyDetectorSD(G4String name);
|
||||
~HadrontherapyDetectorSD();
|
||||
|
||||
std::ofstream ofs;
|
||||
void Initialize(G4HCofThisEvent*);
|
||||
|
||||
G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
|
||||
|
||||
void EndOfEvent(G4HCofThisEvent*HCE);
|
||||
|
||||
HadrontherapyDetectorSD(G4String name);
|
||||
~HadrontherapyDetectorSD();
|
||||
|
||||
|
||||
std::ofstream ofs;
|
||||
void Initialize(G4HCofThisEvent*);
|
||||
|
||||
G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
|
||||
|
||||
void EndOfEvent(G4HCofThisEvent*HCE);
|
||||
|
||||
private:
|
||||
HadrontherapyDetectorHitsCollection *HitsCollection;
|
||||
G4String sensitiveDetectorName;
|
||||
HadrontherapyDetectorHitsCollection *HitsCollection;
|
||||
G4String sensitiveDetectorName;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
|
||||
#include "g4csv.hh"
|
||||
#include "HadrontherapyMatrix.hh"
|
||||
struct ionLet
|
||||
{
|
||||
G4bool isPrimary; // True if particle is primary
|
||||
struct ionLet
|
||||
{
|
||||
G4bool isPrimary; // True if particle is primary
|
||||
G4int PDGencoding; // Particle data group id for the particle
|
||||
G4String fullName; // AZ[excitation energy]: like He3[1277.4], He4[0.0], Li7[231.4], ...
|
||||
G4String name; // simple name without excitation energy: He3, He4, Li7, ...
|
||||
G4int Z; // atomic number
|
||||
G4int A; // mass number
|
||||
G4double *letDN , *letDD; // Track averaged LET and Dose averaged LET
|
||||
G4int A; // mass number
|
||||
G4double *letDN , *letDD, *letTN , *letTD; // Track averaged LET and Dose averaged LET
|
||||
//friend bool operator<(const ionLet& a, const ionLet& b) {return (a.Z == b.Z) ? b.A < a.A : b.Z < a.Z ;}
|
||||
G4bool operator<(const ionLet& a) const{return (this->Z == a.Z) ? this-> A < a.A : this->Z < a.Z ;}
|
||||
// For isotopes sort by the mass number, else sort by the atomic one.
|
||||
@@ -60,48 +60,49 @@ class HadrontherapyDetectorConstruction;
|
||||
|
||||
class HadrontherapyLet
|
||||
{
|
||||
private:
|
||||
HadrontherapyLet(HadrontherapyDetectorConstruction*);
|
||||
|
||||
public:
|
||||
~HadrontherapyLet();
|
||||
static HadrontherapyLet* GetInstance(HadrontherapyDetectorConstruction*);
|
||||
static HadrontherapyLet* GetInstance();
|
||||
static G4bool doCalculation;
|
||||
void Initialize();
|
||||
void Clear();
|
||||
|
||||
void Fill(G4int i, G4int j, G4int k, G4double DE, G4double DX);
|
||||
void FillEnergySpectrum (G4int trackID,
|
||||
G4ParticleDefinition* particleDef,
|
||||
/*G4double kinEnergy,*/
|
||||
G4double DE,
|
||||
G4double DX,
|
||||
G4int i, G4int j, G4int k);
|
||||
void LetOutput();
|
||||
void StoreLetAscii();
|
||||
|
||||
|
||||
private:
|
||||
static HadrontherapyLet *instance;
|
||||
HadrontherapyPrimaryGeneratorAction* pPGA;
|
||||
// Detector material
|
||||
G4Material* detectorMat;
|
||||
G4double density;
|
||||
G4String filename;
|
||||
|
||||
std::ofstream ofs;
|
||||
std::ofstream stopFile;
|
||||
HadrontherapyMatrix *matrix;
|
||||
G4int nVoxels, numberOfVoxelAlongX, numberOfVoxelAlongY, numberOfVoxelAlongZ ;
|
||||
G4double primaryEnergy, energyLimit, binWidth;
|
||||
G4int nBins;
|
||||
G4double nT, dT, nD, dD;
|
||||
G4double nSecondaryT, nSecondaryD, dSecondaryT, dSecondaryD;
|
||||
G4double nPrimaryT, nPrimaryD, dPrimaryT, dPrimaryD ;
|
||||
|
||||
G4double *secondaryLetT, *secondaryLetD, *totalLetT, *DtotalLetD, *totalLetD;
|
||||
G4String nome_file;
|
||||
|
||||
std::vector<ionLet> ionLetStore;
|
||||
private:
|
||||
HadrontherapyLet(HadrontherapyDetectorConstruction*);
|
||||
|
||||
public:
|
||||
~HadrontherapyLet();
|
||||
static HadrontherapyLet* GetInstance(HadrontherapyDetectorConstruction*);
|
||||
static HadrontherapyLet* GetInstance();
|
||||
static G4bool doCalculation;
|
||||
void Initialize();
|
||||
void Clear();
|
||||
|
||||
void Fill(G4int i, G4int j, G4int k, G4double DE, G4double DX);
|
||||
void FillEnergySpectrum (G4int trackID,
|
||||
G4ParticleDefinition* particleDef,
|
||||
G4double ekinMean,
|
||||
G4Material* mat,
|
||||
G4double DE,
|
||||
G4double DEEletrons,
|
||||
G4double DX,
|
||||
G4int i, G4int j, G4int k);
|
||||
void LetOutput();
|
||||
void StoreLetAscii();
|
||||
|
||||
|
||||
private:
|
||||
static HadrontherapyLet *instance;
|
||||
HadrontherapyPrimaryGeneratorAction* pPGA;
|
||||
// Detector material
|
||||
G4Material* detectorMat;
|
||||
G4double density;
|
||||
G4String filename;
|
||||
|
||||
std::ofstream ofs;
|
||||
std::ofstream stopFile;
|
||||
HadrontherapyMatrix *matrix;
|
||||
G4int nVoxels, numberOfVoxelAlongX, numberOfVoxelAlongY, numberOfVoxelAlongZ ;
|
||||
G4double primaryEnergy, energyLimit, binWidth;
|
||||
G4int nBins;
|
||||
G4double nT, dT, nD, dD;
|
||||
G4double nSecondaryT, nSecondaryD, dSecondaryT, dSecondaryD;
|
||||
G4double nPrimaryT, nPrimaryD, dPrimaryT, dPrimaryD ;
|
||||
G4double *secondaryLetT, *secondaryLetD, *totalLetT, *DtotalLetT , *DtotalLetD, *totalLetD;
|
||||
G4String nome_file;
|
||||
|
||||
std::vector<ionLet> ionLetStore;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "globals.hh"
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include "g4csv.hh"
|
||||
//#include "g4csv.hh"
|
||||
|
||||
|
||||
#ifndef HADRONTHERAPYANALYSISMANAGER_HH
|
||||
@@ -43,7 +43,7 @@ class HadrontherapyAnalysisFileMessenger;
|
||||
/**
|
||||
* A class for connecting the simulation to an analysis package.
|
||||
*/
|
||||
class HadrontherapyAnalysisManager
|
||||
class HadrontherapyAnalysis
|
||||
{
|
||||
private:
|
||||
/**
|
||||
@@ -52,21 +52,21 @@ private:
|
||||
*
|
||||
* @see GetInstance
|
||||
*/
|
||||
HadrontherapyAnalysisManager();
|
||||
HadrontherapyAnalysis();
|
||||
|
||||
|
||||
|
||||
public:
|
||||
~HadrontherapyAnalysisManager();
|
||||
~HadrontherapyAnalysis();
|
||||
|
||||
/**
|
||||
* Get the pointer to the analysis manager.
|
||||
*/
|
||||
static HadrontherapyAnalysisManager* GetInstance();
|
||||
static HadrontherapyAnalysis* GetInstance();
|
||||
|
||||
|
||||
|
||||
static HadrontherapyAnalysisManager* instance;
|
||||
static HadrontherapyAnalysis* instance;
|
||||
HadrontherapyAnalysisFileMessenger* fMess;
|
||||
|
||||
};
|
||||
@@ -115,7 +115,6 @@ public:
|
||||
// Full list of generated nuclides
|
||||
|
||||
|
||||
|
||||
void PrintNuclides();
|
||||
// Hit array marker (useful to avoid multiple counts of fluence)
|
||||
void ClearHitTrack();
|
||||
|
||||
@@ -41,39 +41,38 @@ class G4Event;
|
||||
class HadrontherapyPrimaryGeneratorMessenger;
|
||||
class HadrontherapyPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
||||
{
|
||||
public:
|
||||
HadrontherapyPrimaryGeneratorAction();
|
||||
~HadrontherapyPrimaryGeneratorAction();
|
||||
|
||||
public:
|
||||
// Methods to change the parameters of primary particle generation
|
||||
// interactively
|
||||
void GeneratePrimaries(G4Event*);
|
||||
static G4bool ReadFile;
|
||||
|
||||
public:
|
||||
HadrontherapyPrimaryGeneratorAction();
|
||||
~HadrontherapyPrimaryGeneratorAction();
|
||||
|
||||
public:
|
||||
// Methods to change the parameters of primary particle generation
|
||||
// interactively
|
||||
void GeneratePrimaries(G4Event*);
|
||||
static G4bool ReadFile;
|
||||
|
||||
inline void setNewSource(G4bool Varbool){NewSource= Varbool;};
|
||||
G4String PathSource;
|
||||
G4bool Readfile;
|
||||
G4String PathSource;
|
||||
G4bool Readfile;
|
||||
G4bool NewSource;
|
||||
inline void setCalculatedPhaseSpaceFileIN(G4String val){calculatedPhaseSpaceFileIN=val;}
|
||||
|
||||
inline void setCalculatedPhaseSpaceFileIN(G4String val){calculatedPhaseSpaceFileIN=val;}
|
||||
|
||||
private:
|
||||
void SetDefaultPrimaryParticle();
|
||||
|
||||
|
||||
G4String calculatedPhaseSpaceFileIN;
|
||||
void setGunCalculatedPhaseSpace();
|
||||
private:
|
||||
void SetDefaultPrimaryParticle();
|
||||
|
||||
|
||||
G4String calculatedPhaseSpaceFileIN;
|
||||
void setGunCalculatedPhaseSpace();
|
||||
|
||||
HadrontherapyPrimaryGeneratorMessenger *PrimaryGeneratorMessenger;
|
||||
G4ParticleGun *particleGuns;
|
||||
|
||||
|
||||
private:
|
||||
G4GeneralParticleSource* particleGun;
|
||||
G4double sigmaX;
|
||||
std::ifstream in;
|
||||
std::ofstream ofs;
|
||||
G4ParticleGun *particleGuns;
|
||||
|
||||
|
||||
private:
|
||||
G4GeneralParticleSource* particleGun;
|
||||
G4double sigmaX;
|
||||
std::ofstream ofs;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -42,16 +42,23 @@ class HadrontherapyPrimaryGeneratorMessenger:
|
||||
public G4UImessenger
|
||||
{
|
||||
public:
|
||||
|
||||
HadrontherapyPrimaryGeneratorMessenger(HadrontherapyPrimaryGeneratorAction*);
|
||||
~HadrontherapyPrimaryGeneratorMessenger();
|
||||
|
||||
|
||||
|
||||
HadrontherapyPrimaryGeneratorMessenger(HadrontherapyPrimaryGeneratorAction*);
|
||||
~HadrontherapyPrimaryGeneratorMessenger();
|
||||
|
||||
|
||||
HadrontherapyPrimaryGeneratorAction* HadrontherapyAction;
|
||||
|
||||
|
||||
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
|
||||
|
||||
G4UIcmdWithABool *NewSource;
|
||||
G4UIcmdWithAString *calculatedPhaseSpaceFileIN;
|
||||
G4UIdirectory* changeTheSource;
|
||||
G4bool *BoolRead;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// HadrontherapyRBE.hh;
|
||||
//
|
||||
|
||||
#ifndef HadrontherapyRBE_H
|
||||
#define HadrontherapyRBE_H 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include <vector>
|
||||
#include <valarray>
|
||||
#include <map>
|
||||
#include "G4Pow.hh"
|
||||
|
||||
class G4GenericMessenger;
|
||||
|
||||
/**
|
||||
* @brief Main class of the RBE calculation.
|
||||
*
|
||||
* The calculation has to be explicitly enabled
|
||||
* (use macro command)
|
||||
*
|
||||
* Available macro commands:
|
||||
*
|
||||
* - /rbe/calculation 0/1 : enable or disable RBE calculation
|
||||
* - /rbe/verbose 0/1/2 : level of screen output detail
|
||||
* - /rbe/loadLemTable [path] : read a CSV file with alphas, betas, ...
|
||||
* - /rbe/cellLine [name] : select one of the cell lines from the data file
|
||||
* - /rbe/doseScale [number] : factor to make the survival/RBE calculation correct
|
||||
* - /rbe/accumulate 0/1 : enable or disable data summing over multiple runs
|
||||
* - /rbe/reset : clear accumulated data back to 0.
|
||||
*/
|
||||
class HadrontherapyRBE
|
||||
{
|
||||
public:
|
||||
virtual ~HadrontherapyRBE();
|
||||
|
||||
// Make a new & get instance pointer
|
||||
static HadrontherapyRBE* CreateInstance(G4int nX, G4int nY, G4int nZ, G4double massOfVoxel);
|
||||
static HadrontherapyRBE* GetInstance();
|
||||
|
||||
// If this is false (set with macro), nothing happens
|
||||
G4bool IsCalculationEnabled() const { return fCalculationEnabled; }
|
||||
|
||||
// If this is true, dose (and alpha/beta parameters) are accumulated over multiple runs
|
||||
G4bool IsAccumulationEnabled() const { return fAccumulate; }
|
||||
|
||||
// Initialization of data from a CSV file
|
||||
void LoadLEMTable(G4String path);
|
||||
|
||||
// Select the cell and update the pointer
|
||||
void SetCellLine(G4String name);
|
||||
|
||||
// Calculate alpha and beta for single deposition, {0,0} if not applicable
|
||||
std::tuple<G4double, G4double> GetHitAlphaAndBeta(G4double E, G4int Z);
|
||||
|
||||
// Parameter setting
|
||||
void SetDoseScale(G4double scale);
|
||||
void SetCalculationEnabled(G4bool enabled);
|
||||
void SetAccumulationEnabled(G4bool accumulate);
|
||||
|
||||
// Verbosity for output
|
||||
void SetVerboseLevel(G4int level) { fVerboseLevel = level; }
|
||||
G4int GetVerboseLevel() const { return fVerboseLevel; }
|
||||
|
||||
// Alias for matrix type
|
||||
using array_type = std::valarray<G4double>;
|
||||
|
||||
// Calculation
|
||||
void ComputeAlphaAndBeta();
|
||||
void ComputeRBE();
|
||||
|
||||
// Update the class with accumulated data
|
||||
// (To be used from HadrontherapyRBEAccumulable)
|
||||
void SetAlphaNumerator(const array_type alpha);
|
||||
void SetBetaNumerator(const array_type beta);
|
||||
void SetEnergyDeposit(const array_type eDep);
|
||||
void SetDenominator(const array_type denom);
|
||||
|
||||
// Accumulation variants necessary for multi-run sumation
|
||||
void AddAlphaNumerator(const array_type alpha);
|
||||
void AddBetaNumerator(const array_type beta);
|
||||
void AddEnergyDeposit(const array_type eDep);
|
||||
void AddDenominator(const array_type denom);
|
||||
|
||||
// Clear accumulated data
|
||||
void Reset();
|
||||
|
||||
// Output to text files (called at the end of run)
|
||||
void StoreAlphaAndBeta();
|
||||
void StoreRBE();
|
||||
|
||||
// Information about voxels
|
||||
size_t GetNumberOfVoxelsAlongX() const { return fNumberOfVoxelsAlongX; }
|
||||
size_t GetNumberOfVoxelsAlongY() const { return fNumberOfVoxelsAlongY; }
|
||||
size_t GetNumberOfVoxelsAlongZ() const { return fNumberOfVoxelsAlongZ; }
|
||||
|
||||
// Some basic output to the screen
|
||||
void PrintParameters();
|
||||
|
||||
protected:
|
||||
inline G4int Index(G4int i, G4int j, G4int k) {return (i * fNumberOfVoxelsAlongY + j) * fNumberOfVoxelsAlongZ + k;}
|
||||
|
||||
// Interpolation
|
||||
// G4int GetRowVecEnergy();
|
||||
// G4bool NearLookup(G4double E, G4double DE);
|
||||
// G4bool LinearLookup(G4double E, G4double DE, G4int Z);
|
||||
// void interpolation_onE(G4int k,G4int m, G4int indexE, G4double E, G4int Z);
|
||||
// G4bool interpolation_onLET1_onLET2_onE(G4int k,G4int m, G4int indexE, G4double E, G4double LET);
|
||||
// void InitDynamicVec(std::vector<G4double> &vecEnergy, G4int matrix_energy);
|
||||
|
||||
// Messenger initialization
|
||||
void CreateMessenger();
|
||||
|
||||
private:
|
||||
HadrontherapyRBE(G4int numberOfVoxelX, G4int numberOfVoxelY, G4int numberOfVoxelZ, G4double massOfVoxel);
|
||||
|
||||
G4GenericMessenger* fMessenger;
|
||||
G4Pow* g4pow = G4Pow::GetInstance();
|
||||
|
||||
static HadrontherapyRBE* instance;
|
||||
G4int fVerboseLevel { 1 };
|
||||
|
||||
// Parameters for calculation
|
||||
G4double fAlphaX { 0.0 };
|
||||
G4double fBetaX { 0.0 };
|
||||
G4double fDoseCut { 0.0 };
|
||||
G4double fDoseScale { 1.0 };
|
||||
|
||||
// Output paths (TODO: Change to analysis tools)
|
||||
G4String fAlphaBetaPath { "AlphaAndBeta.out" };
|
||||
G4String fRBEPath { "RBE.out" };
|
||||
|
||||
// Voxelization
|
||||
G4int fNumberOfVoxelsAlongX, fNumberOfVoxelsAlongY, fNumberOfVoxelsAlongZ;
|
||||
G4int fNumberOfVoxels;
|
||||
G4double fMassOfVoxel;
|
||||
|
||||
G4double* x; // TODO: Currently not used (that much)
|
||||
|
||||
G4bool fCalculationEnabled { false };
|
||||
G4bool fAccumulate { false };
|
||||
|
||||
// Matrices to be set when accumulated
|
||||
array_type fAlpha;
|
||||
array_type fBeta;
|
||||
array_type fDose; // Note: this is calculated from energyDeposit, massOfVoxel and doseScale
|
||||
|
||||
array_type fAlphaNumerator;
|
||||
array_type fBetaNumerator;
|
||||
array_type fDenominator;
|
||||
|
||||
// Matrices of calculated values
|
||||
array_type fLnS;
|
||||
array_type fSurvival;
|
||||
array_type fDoseX;
|
||||
array_type fRBE;
|
||||
|
||||
// Available tables and associated values.
|
||||
using vector_type = std::map<G4int, std::vector<G4double>>;
|
||||
std::map<G4String, vector_type> fTablesEnergy;
|
||||
// std::map<G4String, vector_type> fTablesLet;
|
||||
std::map<G4String, vector_type> fTablesAlpha;
|
||||
std::map<G4String, vector_type> fTablesBeta;
|
||||
std::map<G4String, G4double> fTablesAlphaX;
|
||||
std::map<G4String, G4double> fTablesBetaX;
|
||||
std::map<G4String, G4double> fTablesDoseCut;
|
||||
|
||||
// Selected tables and associated values.
|
||||
// (changed when the cell line is set)
|
||||
G4String fActiveCellLine = "";
|
||||
vector_type* fActiveTableEnergy { nullptr };
|
||||
// vector_type* fActiveTableLet { nullptr };
|
||||
vector_type* fActiveTableAlpha { nullptr };
|
||||
vector_type* fActiveTableBeta { nullptr };
|
||||
std::map<G4int, G4double> fMaxEnergies;
|
||||
std::map<G4int, G4double> fMinEnergies;
|
||||
G4int fMinZ;
|
||||
G4int fMaxZ;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// HadrontherapyRBEAccumulable.hh;
|
||||
//
|
||||
#ifndef HADRONTHERAPYRBEACCUMULABLE_HH
|
||||
#define HADRONTHERAPYRBEACCUMULABLE_HH
|
||||
|
||||
#include <G4VAccumulable.hh>
|
||||
|
||||
#include <valarray>
|
||||
|
||||
/**
|
||||
* @brief Accumulable of RBE-related data (that must be thread-local).
|
||||
*
|
||||
* It keeps the sum of alpha and beta numerators/denominator, as well as energy deposits.
|
||||
* The class is closely tied with the singleton HadrontherapyRBE that is used both
|
||||
* to calculate alphas and betas, and also to store results.
|
||||
*
|
||||
* This is implemented as a customized G4VAccumulable with non-scalar data.
|
||||
*
|
||||
* @note There are two levels of merging (accumulation):
|
||||
* 1) From more threads in one run (G4VAccumulable merging is applied)
|
||||
* 2) (Optional) inter-run merging of data (implemented in HadrontherapyRBE).
|
||||
*
|
||||
* @note std::valarray is used (instead of C arrays or std::vectors)
|
||||
* to accumulate data for its logical simplicity.
|
||||
*/
|
||||
class HadrontherapyRBEAccumulable : public G4VAccumulable
|
||||
{
|
||||
public:
|
||||
HadrontherapyRBEAccumulable();
|
||||
HadrontherapyRBEAccumulable(const HadrontherapyRBEAccumulable& other) = default;
|
||||
|
||||
// G4VAccumulable virtual methods
|
||||
void Merge(const G4VAccumulable &rhs) override;
|
||||
void Reset() override;
|
||||
|
||||
// Store information from a single step
|
||||
void Accumulate(G4double E, G4double energyDeposit, G4double dX, G4int Z, G4int i, G4int j, G4int k);
|
||||
|
||||
// Type alias for numerical arrays
|
||||
using array_type = std::valarray<G4double>;
|
||||
|
||||
// Access to stored data (to be called on the merged data)
|
||||
const array_type GetEnergyDeposit() const;
|
||||
const array_type GetAlphaNumerator() const { return fAlphaNumerator; }
|
||||
const array_type GetBetaNumerator() const { return fBetaNumerator; }
|
||||
const array_type GetDenominator() const { return fDenominator; }
|
||||
|
||||
// Verbosity, shared with HadrontherapyRBE
|
||||
G4int GetVerboseLevel() const;
|
||||
|
||||
private:
|
||||
/** @brief Helper function to get the 1D index in the 3D array */
|
||||
inline G4int GetIndex(G4int i, G4int j, G4int k) const {return (i * fVoxelsAlongY + j) * fVoxelsAlongZ + k; }
|
||||
|
||||
// Apply configuration from the HadrontherapyRBE class and prepare matrices
|
||||
void Initialize();
|
||||
G4bool fInitialized { false };
|
||||
|
||||
array_type fAlphaNumerator;
|
||||
array_type fBetaNumerator;
|
||||
array_type fDenominator;
|
||||
array_type fEnergyDeposit;
|
||||
|
||||
// How many voxels do we have?
|
||||
// ...along each axis
|
||||
size_t fVoxelsAlongX;
|
||||
size_t fVoxelsAlongY;
|
||||
size_t fVoxelsAlongZ;
|
||||
// ...and in total
|
||||
size_t fVoxels;
|
||||
};
|
||||
|
||||
#endif // HADRONTHERAPYRBEACCUMULABLE_HH
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "G4RunManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "HadrontherapyRBEAccumulable.hh"
|
||||
|
||||
class G4Run;
|
||||
class HadrontherapyAnalysisManager;
|
||||
class HadrontherapyDetectorConstruction;
|
||||
@@ -61,6 +63,8 @@ public:
|
||||
private:
|
||||
G4int electromagnetic;
|
||||
G4int hadronic;
|
||||
|
||||
HadrontherapyRBEAccumulable fRBEAccumulable;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user