Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This example is provided by the Geant4-DNA collaboration
|
||||
// Any report or published results obtained using the Geant4-DNA software
|
||||
// shall cite the following Geant4-DNA collaboration publication:
|
||||
// Med. Phys. 37 (2010) 4692-4708
|
||||
// The Geant4-DNA web site is available at http://geant4-dna.org
|
||||
//
|
||||
|
||||
#include "HadrontherapyActionInitialization.hh"
|
||||
#include "HadrontherapyPrimaryGeneratorAction.hh"
|
||||
#include "HadrontherapyRunAction.hh"
|
||||
#include "HadrontherapySteppingAction.hh"
|
||||
#include "HadrontherapyDetectorConstruction.hh"
|
||||
#include "G4GeneralParticleSource.hh"
|
||||
|
||||
#include "HadrontherapyEventAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HadrontherapyActionInitialization::HadrontherapyActionInitialization(/*G4VUserDetectorConstruction* detConstruction*/)
|
||||
: G4VUserActionInitialization()//,
|
||||
// fDetectorConstruction(detConstruction)
|
||||
{
|
||||
//AND->3June2014, temporary to take into account new GPS
|
||||
//Create an instance of GPS in master so shared resources and messenger
|
||||
//exist in master.
|
||||
// masterGPS = new G4GeneralParticleSource();
|
||||
//AND<-3June2014
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HadrontherapyActionInitialization::~HadrontherapyActionInitialization()
|
||||
{//delete masterGPS;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HadrontherapyActionInitialization::BuildForMaster() const
|
||||
{
|
||||
// In MT mode, to be clearer, the RunAction class for the master thread might be
|
||||
// different than the one used for the workers.
|
||||
// This RunAction will be called before and after starting the
|
||||
// workers.
|
||||
// For more details, please refer to :
|
||||
// https://twiki.cern.ch/twiki/bin/view/Geant4/Geant4MTForApplicationDevelopers
|
||||
//
|
||||
// HadrontherapyRunAction* runAction= new HadrontherapyRunAction(fDetectorConstruction);
|
||||
// SetUserAction(runAction);
|
||||
HadrontherapyRunAction* pRunAction = new HadrontherapyRunAction();
|
||||
SetUserAction(pRunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HadrontherapyActionInitialization::Build() const
|
||||
{
|
||||
// Initialize the primary particles
|
||||
HadrontherapyPrimaryGeneratorAction *pPrimaryGenerator = new HadrontherapyPrimaryGeneratorAction();
|
||||
SetUserAction(pPrimaryGenerator);
|
||||
|
||||
// Optional UserActions: run, event, stepping
|
||||
HadrontherapyRunAction* pRunAction = new HadrontherapyRunAction();
|
||||
SetUserAction(pRunAction);
|
||||
|
||||
|
||||
HadrontherapyEventAction* pEventAction = new HadrontherapyEventAction();
|
||||
SetUserAction(pEventAction);
|
||||
|
||||
HadrontherapySteppingAction* steppingAction = new HadrontherapySteppingAction(pRunAction);
|
||||
SetUserAction(steppingAction);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -23,15 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
// Institute in the framework of the MC-INFN Group
|
||||
//
|
||||
|
||||
// Hadrontherapy development is supported by the
|
||||
// Italian Institute for Nuclear Physics (INFN)
|
||||
// in the framework of the MC-INFN Project
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SDManager.hh"
|
||||
@@ -52,7 +46,6 @@
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4NistManager.hh"
|
||||
|
||||
#include "HadrontherapyDetectorConstruction.hh"
|
||||
#include "HadrontherapyDetectorROGeometry.hh"
|
||||
#include "HadrontherapyDetectorMessenger.hh"
|
||||
@@ -68,89 +61,85 @@
|
||||
HadrontherapyDetectorConstruction* HadrontherapyDetectorConstruction::instance = 0;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyDetectorConstruction::HadrontherapyDetectorConstruction(G4VPhysicalVolume* physicalTreatmentRoom)
|
||||
: motherPhys(physicalTreatmentRoom), // pointer to WORLD volume
|
||||
detectorSD(0), detectorROGeometry(0), matrix(0),
|
||||
phantom(0), detector(0),
|
||||
phantomLogicalVolume(0), detectorLogicalVolume(0),
|
||||
phantomPhysicalVolume(0), detectorPhysicalVolume(0),
|
||||
aRegion(0)
|
||||
: motherPhys(physicalTreatmentRoom), // pointer to WORLD volume
|
||||
detectorSD(0), detectorROGeometry(0), matrix(0),
|
||||
phantom(0), detector(0),
|
||||
phantomLogicalVolume(0), detectorLogicalVolume(0),
|
||||
phantomPhysicalVolume(0), detectorPhysicalVolume(0),
|
||||
aRegion(0)
|
||||
{
|
||||
HadrontherapyAnalysisManager::GetInstance();
|
||||
|
||||
/* NOTE! that the HadrontherapyDetectorConstruction class
|
||||
* does NOT inherit from G4VUserDetectorConstruction G4 class
|
||||
* So the Construct() mandatory virtual method is inside another geometric class
|
||||
* like the passiveProtonBeamLIne, ...
|
||||
*/
|
||||
|
||||
// Messenger to change parameters of the phantom/detector geometry
|
||||
detectorMessenger = new HadrontherapyDetectorMessenger(this);
|
||||
|
||||
// Default detector voxels size
|
||||
// 200 slabs along the beam direction (X)
|
||||
sizeOfVoxelAlongX = 200 *um;
|
||||
sizeOfVoxelAlongY = 4 *cm;
|
||||
sizeOfVoxelAlongZ = 4 *cm;
|
||||
|
||||
// Define here the material of the water phantom and of the detector
|
||||
SetPhantomMaterial("G4_WATER");
|
||||
// Construct geometry (messenger commands)
|
||||
SetDetectorSize(4.*cm, 4.*cm, 4.*cm);
|
||||
SetPhantomSize(40. *cm, 40. *cm, 40. *cm);
|
||||
SetPhantomPosition(G4ThreeVector(20. *cm, 0. *cm, 0. *cm));
|
||||
SetDetectorToPhantomPosition(G4ThreeVector(0. *cm, 18. *cm, 18. *cm));
|
||||
SetDetectorPosition();
|
||||
//GetDetectorToWorldPosition();
|
||||
|
||||
|
||||
// Write virtual parameters to the real ones and check for consistency
|
||||
UpdateGeometry();
|
||||
HadrontherapyAnalysisManager::GetInstance();
|
||||
|
||||
/* NOTE! that the HadrontherapyDetectorConstruction class
|
||||
* does NOT inherit from G4VUserDetectorConstruction G4 class
|
||||
* So the Construct() mandatory virtual method is inside another geometric class
|
||||
* like the passiveProtonBeamLIne, ...
|
||||
*/
|
||||
|
||||
// Messenger to change parameters of the phantom/detector geometry
|
||||
detectorMessenger = new HadrontherapyDetectorMessenger(this);
|
||||
|
||||
// Default detector voxels size
|
||||
// 200 slabs along the beam direction (X)
|
||||
sizeOfVoxelAlongX = 200 *um;
|
||||
sizeOfVoxelAlongY = 4 *cm;
|
||||
sizeOfVoxelAlongZ = 4 *cm;
|
||||
|
||||
// Define here the material of the water phantom and of the detector
|
||||
SetPhantomMaterial("G4_WATER");
|
||||
// Construct geometry (messenger commands)
|
||||
SetDetectorSize(4.*cm, 4.*cm, 4.*cm);
|
||||
SetPhantomSize(40. *cm, 40. *cm, 40. *cm);
|
||||
SetPhantomPosition(G4ThreeVector(20. *cm, 0. *cm, 0. *cm));
|
||||
SetDetectorToPhantomPosition(G4ThreeVector(0. *cm, 18. *cm, 18. *cm));
|
||||
SetDetectorPosition();
|
||||
//GetDetectorToWorldPosition();
|
||||
|
||||
// Write virtual parameters to the real ones and check for consistency
|
||||
UpdateGeometry();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyDetectorConstruction::~HadrontherapyDetectorConstruction()
|
||||
{
|
||||
delete detectorROGeometry;
|
||||
delete matrix;
|
||||
{
|
||||
delete detectorROGeometry;
|
||||
delete matrix;
|
||||
delete detectorMessenger;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyDetectorConstruction* HadrontherapyDetectorConstruction::GetInstance()
|
||||
{
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ConstructPhantom() is the method that reconstuct a water box (called phantom
|
||||
// (or water phantom) in the usual Medical physicists slang).
|
||||
// A water phantom can be considered a good
|
||||
// approximation of a an human body.
|
||||
// ConstructPhantom() is the method that construct a water box (called phantom
|
||||
// (or water phantom) in the usual Medical physicists slang).
|
||||
// A water phantom can be considered a good approximation of a an human body.
|
||||
void HadrontherapyDetectorConstruction::ConstructPhantom()
|
||||
{
|
||||
// Definition of the solid volume of the Phantom
|
||||
phantom = new G4Box("Phantom",
|
||||
phantomSizeX/2,
|
||||
phantomSizeY/2,
|
||||
phantomSizeZ/2);
|
||||
phantom = new G4Box("Phantom",
|
||||
phantomSizeX/2,
|
||||
phantomSizeY/2,
|
||||
phantomSizeZ/2);
|
||||
|
||||
// Definition of the logical volume of the Phantom
|
||||
phantomLogicalVolume = new G4LogicalVolume(phantom,
|
||||
phantomMaterial,
|
||||
"phantomLog", 0, 0, 0);
|
||||
|
||||
// Definition of the logical volume of the Phantom
|
||||
phantomLogicalVolume = new G4LogicalVolume(phantom,
|
||||
phantomMaterial,
|
||||
"phantomLog", 0, 0, 0);
|
||||
|
||||
// Definition of the physics volume of the Phantom
|
||||
phantomPhysicalVolume = new G4PVPlacement(0,
|
||||
phantomPosition,
|
||||
"phantomPhys",
|
||||
phantomLogicalVolume,
|
||||
motherPhys,
|
||||
false,
|
||||
0);
|
||||
|
||||
// Visualisation attributes of the phantom
|
||||
phantomPosition,
|
||||
"phantomPhys",
|
||||
phantomLogicalVolume,
|
||||
motherPhys,
|
||||
false,
|
||||
0);
|
||||
|
||||
// Visualisation attributes of the phantom
|
||||
red = new G4VisAttributes(G4Colour(255/255., 0/255. ,0/255.));
|
||||
red -> SetVisibility(true);
|
||||
red -> SetForceSolid(true);
|
||||
@@ -159,12 +148,11 @@ void HadrontherapyDetectorConstruction::ConstructPhantom()
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ConstructDetector() it the method the reconstruct a detector region
|
||||
// inside the water phantom. It is a volume, located inside the water phantom
|
||||
// and with two coincident faces:
|
||||
// ConstructDetector() is the method the reconstruct a detector region
|
||||
// inside the water phantom. It is a volume, located inside the water phantom.
|
||||
//
|
||||
// **************************
|
||||
// * water phantom *
|
||||
// * water phantom *
|
||||
// * *
|
||||
// * *
|
||||
// *--------------- *
|
||||
@@ -177,131 +165,119 @@ void HadrontherapyDetectorConstruction::ConstructPhantom()
|
||||
// * *
|
||||
// **************************
|
||||
//
|
||||
// The detector is the volume that can be dived in slices or voxelized
|
||||
// and in it we can collect a number of usefull information:
|
||||
// dose distribution, fluence distribution, LET and so on
|
||||
// The detector can be dived in slices or voxelized
|
||||
// and inside it different quantities (dose distribution, fluence distribution, LET, etc)
|
||||
// can be stored.
|
||||
void HadrontherapyDetectorConstruction::ConstructDetector()
|
||||
{
|
||||
|
||||
// Definition of the solid volume of the Detector
|
||||
detector = new G4Box("Detector",
|
||||
detectorSizeX/2,
|
||||
detectorSizeY/2,
|
||||
detectorSizeZ/2);
|
||||
detector = new G4Box("Detector",
|
||||
detectorSizeX/2,
|
||||
detectorSizeY/2,
|
||||
detectorSizeZ/2);
|
||||
|
||||
// Definition of the logic volume of the Phantom
|
||||
detectorLogicalVolume = new G4LogicalVolume(detector,
|
||||
detectorMaterial,
|
||||
"DetectorLog",
|
||||
0,0,0);
|
||||
// Definition of the physical volume of the Phantom
|
||||
detectorPhysicalVolume = new G4PVPlacement(0,
|
||||
detectorPosition, // Setted by displacement
|
||||
"DetectorPhys",
|
||||
detectorLogicalVolume,
|
||||
phantomPhysicalVolume,
|
||||
false,0);
|
||||
|
||||
// Visualisation attributes of the detector
|
||||
detectorMaterial,
|
||||
"DetectorLog",
|
||||
0,0,0);
|
||||
// Definition of the physical volume of the Phantom
|
||||
detectorPhysicalVolume = new G4PVPlacement(0,
|
||||
detectorPosition, // Setted by displacement
|
||||
"DetectorPhys",
|
||||
detectorLogicalVolume,
|
||||
phantomPhysicalVolume,
|
||||
false,0);
|
||||
|
||||
// Visualisation attributes of the detector
|
||||
skyBlue = new G4VisAttributes( G4Colour(135/255. , 206/255. , 235/255. ));
|
||||
skyBlue -> SetVisibility(true);
|
||||
skyBlue -> SetForceSolid(true);
|
||||
//skyBlue -> SetForceWireframe(true);
|
||||
detectorLogicalVolume -> SetVisAttributes(skyBlue);
|
||||
|
||||
// **************
|
||||
// Cut per Region
|
||||
// **************
|
||||
|
||||
// A smaller cut is fixed in the phantom to calculate the energy deposit with the
|
||||
// required accuracy
|
||||
|
||||
// **************
|
||||
// Cut per Region
|
||||
// **************
|
||||
//
|
||||
// A smaller cut is fixed in the phantom to calculate the energy deposit with the
|
||||
// required accuracy
|
||||
if (!aRegion)
|
||||
{
|
||||
aRegion = new G4Region("DetectorLog");
|
||||
detectorLogicalVolume -> SetRegion(aRegion);
|
||||
aRegion -> AddRootLogicalVolume(detectorLogicalVolume);
|
||||
aRegion = new G4Region("DetectorLog");
|
||||
detectorLogicalVolume -> SetRegion(aRegion);
|
||||
aRegion -> AddRootLogicalVolume(detectorLogicalVolume);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
void HadrontherapyDetectorConstruction::InitializeDetectorROGeometry(
|
||||
HadrontherapyDetectorROGeometry* RO,
|
||||
G4ThreeVector
|
||||
detectorToWorldPosition)
|
||||
HadrontherapyDetectorROGeometry* RO,
|
||||
G4ThreeVector
|
||||
detectorToWorldPosition)
|
||||
{
|
||||
RO->Initialize(detectorToWorldPosition,
|
||||
detectorSizeX/2,
|
||||
detectorSizeY/2,
|
||||
detectorSizeZ/2,
|
||||
numberOfVoxelsAlongX,
|
||||
numberOfVoxelsAlongY,
|
||||
numberOfVoxelsAlongZ);
|
||||
RO->Initialize(detectorToWorldPosition,
|
||||
detectorSizeX/2,
|
||||
detectorSizeY/2,
|
||||
detectorSizeZ/2,
|
||||
numberOfVoxelsAlongX,
|
||||
numberOfVoxelsAlongY,
|
||||
numberOfVoxelsAlongZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::ParametersCheck()
|
||||
{
|
||||
// Check phantom/detector sizes & relative position
|
||||
if (!IsInside(detectorSizeX,
|
||||
detectorSizeY,
|
||||
detectorSizeZ,
|
||||
phantomSizeX,
|
||||
phantomSizeY,
|
||||
phantomSizeZ,
|
||||
detectorToPhantomPosition
|
||||
))
|
||||
G4Exception("HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0001", FatalException, "Error: Detector is not fully inside Phantom!");
|
||||
|
||||
if (!IsInside(detectorSizeX,
|
||||
detectorSizeY,
|
||||
detectorSizeZ,
|
||||
phantomSizeX,
|
||||
phantomSizeY,
|
||||
phantomSizeZ,
|
||||
detectorToPhantomPosition
|
||||
))
|
||||
G4Exception("HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0001", FatalException, "Error: Detector is not fully inside Phantom!");
|
||||
|
||||
// Check Detector sizes respect to the voxel ones
|
||||
|
||||
|
||||
if ( detectorSizeX < sizeOfVoxelAlongX) {
|
||||
G4Exception("HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0002", FatalException, "Error: Detector X size must be bigger or equal than that of Voxel X!");
|
||||
G4Exception("HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0002", FatalException, "Error: Detector X size must be bigger or equal than that of Voxel X!");
|
||||
}
|
||||
if ( detectorSizeY < sizeOfVoxelAlongY) {
|
||||
G4Exception(" HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0003", FatalException, "Error: Detector Y size must be bigger or equal than that of Voxel Y!");
|
||||
G4Exception(" HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0003", FatalException, "Error: Detector Y size must be bigger or equal than that of Voxel Y!");
|
||||
}
|
||||
if ( detectorSizeZ < sizeOfVoxelAlongZ) {
|
||||
G4Exception(" HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0004", FatalException, "Error: Detector Z size must be bigger or equal than that of Voxel Z!");
|
||||
G4Exception(" HadrontherapyDetectorConstruction::ParametersCheck()", "Hadrontherapy0004", FatalException, "Error: Detector Z size must be bigger or equal than that of Voxel Z!");
|
||||
}
|
||||
|
||||
}
|
||||
/////////////////
|
||||
// MESSENGERS //
|
||||
////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
G4bool HadrontherapyDetectorConstruction::SetPhantomMaterial(G4String material)
|
||||
{
|
||||
|
||||
|
||||
if (G4Material* pMat = G4NistManager::Instance()->FindOrBuildMaterial(material, false) )
|
||||
{
|
||||
phantomMaterial = pMat;
|
||||
detectorMaterial = pMat;
|
||||
if (detectorLogicalVolume && phantomLogicalVolume)
|
||||
{
|
||||
detectorLogicalVolume -> SetMaterial(pMat);
|
||||
phantomLogicalVolume -> SetMaterial(pMat);
|
||||
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
G4RunManager::GetRunManager() -> GeometryHasBeenModified();
|
||||
G4cout << "The material of Phantom/Detector has been changed to " << material << G4endl;
|
||||
}
|
||||
phantomMaterial = pMat;
|
||||
detectorMaterial = pMat;
|
||||
if (detectorLogicalVolume && phantomLogicalVolume)
|
||||
{
|
||||
detectorLogicalVolume -> SetMaterial(pMat);
|
||||
phantomLogicalVolume -> SetMaterial(pMat);
|
||||
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
G4RunManager::GetRunManager() -> GeometryHasBeenModified();
|
||||
G4cout << "The material of Phantom/Detector has been changed to " << material << G4endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "WARNING: material \"" << material << "\" doesn't exist in NIST elements/materials"
|
||||
" table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
|
||||
G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
|
||||
return false;
|
||||
G4cout << "WARNING: material \"" << material << "\" doesn't exist in NIST elements/materials"
|
||||
" table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl;
|
||||
G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -311,7 +287,7 @@ void HadrontherapyDetectorConstruction::SetPhantomSize(G4double sizeX, G4double
|
||||
if (sizeY > 0.) phantomSizeY = sizeY;
|
||||
if (sizeZ > 0.) phantomSizeZ = sizeZ;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ)
|
||||
{
|
||||
@@ -320,14 +296,16 @@ void HadrontherapyDetectorConstruction::SetDetectorSize(G4double sizeX, G4double
|
||||
if (sizeZ > 0.) {detectorSizeZ = sizeZ;}
|
||||
SetVoxelSize(sizeOfVoxelAlongX, sizeOfVoxelAlongY, sizeOfVoxelAlongZ);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ)
|
||||
{
|
||||
if (sizeX > 0.) {sizeOfVoxelAlongX = sizeX;}
|
||||
if (sizeY > 0.) {sizeOfVoxelAlongY = sizeY;}
|
||||
if (sizeZ > 0.) {sizeOfVoxelAlongZ = sizeZ;}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::SetPhantomPosition(G4ThreeVector pos)
|
||||
{
|
||||
phantomPosition = pos;
|
||||
@@ -338,124 +316,140 @@ void HadrontherapyDetectorConstruction::SetDetectorToPhantomPosition(G4ThreeVect
|
||||
{
|
||||
detectorToPhantomPosition = displ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
/*
|
||||
* Check parameters consistency
|
||||
*/
|
||||
ParametersCheck();
|
||||
|
||||
G4GeometryManager::GetInstance() -> OpenGeometry();
|
||||
if (phantom)
|
||||
{
|
||||
phantom -> SetXHalfLength(phantomSizeX/2);
|
||||
phantom -> SetYHalfLength(phantomSizeY/2);
|
||||
phantom -> SetZHalfLength(phantomSizeZ/2);
|
||||
phantomPhysicalVolume -> SetTranslation(phantomPosition);
|
||||
}
|
||||
else ConstructPhantom();
|
||||
|
||||
// Get the center of the detector
|
||||
SetDetectorPosition();
|
||||
if (detector)
|
||||
{
|
||||
detector -> SetXHalfLength(detectorSizeX/2);
|
||||
detector -> SetYHalfLength(detectorSizeY/2);
|
||||
detector -> SetZHalfLength(detectorSizeZ/2);
|
||||
detectorPhysicalVolume -> SetTranslation(detectorPosition);
|
||||
}
|
||||
else ConstructDetector();
|
||||
|
||||
// Round to nearest integer number of voxel
|
||||
|
||||
numberOfVoxelsAlongX = G4lrint(detectorSizeX / sizeOfVoxelAlongX);
|
||||
|
||||
sizeOfVoxelAlongX = ( detectorSizeX / numberOfVoxelsAlongX );
|
||||
|
||||
numberOfVoxelsAlongY = G4lrint(detectorSizeY / sizeOfVoxelAlongY);
|
||||
|
||||
sizeOfVoxelAlongY = ( detectorSizeY / numberOfVoxelsAlongY );
|
||||
/*
|
||||
* Check parameters consistency
|
||||
*/
|
||||
ParametersCheck();
|
||||
|
||||
numberOfVoxelsAlongZ = G4lrint(detectorSizeZ / sizeOfVoxelAlongZ);
|
||||
|
||||
sizeOfVoxelAlongZ = ( detectorSizeZ / numberOfVoxelsAlongZ );
|
||||
|
||||
PassiveProtonBeamLine *ppbl= (PassiveProtonBeamLine*)
|
||||
|
||||
G4RunManager::GetRunManager()->GetUserDetectorConstruction();
|
||||
|
||||
|
||||
HadrontherapyDetectorROGeometry* RO = (HadrontherapyDetectorROGeometry*) ppbl->GetParallelWorld(0);
|
||||
|
||||
//Set parameters, either for the Construct() or for the UpdateROGeometry()
|
||||
RO->Initialize(GetDetectorToWorldPosition(),
|
||||
detectorSizeX/2,
|
||||
detectorSizeY/2,
|
||||
detectorSizeZ/2,
|
||||
numberOfVoxelsAlongX,
|
||||
numberOfVoxelsAlongY,
|
||||
numberOfVoxelsAlongZ);
|
||||
|
||||
//This method below has an effect only if the RO geometry is already built.
|
||||
RO->UpdateROGeometry();
|
||||
|
||||
volumeOfVoxel = sizeOfVoxelAlongX * sizeOfVoxelAlongY * sizeOfVoxelAlongZ;
|
||||
massOfVoxel = detectorMaterial -> GetDensity() * volumeOfVoxel;
|
||||
// This will clear the existing matrix (together with all data inside it)!
|
||||
matrix = HadrontherapyMatrix::GetInstance(numberOfVoxelsAlongX,
|
||||
numberOfVoxelsAlongY,
|
||||
numberOfVoxelsAlongZ,
|
||||
massOfVoxel);
|
||||
|
||||
|
||||
// Comment out the line below if let calculation is not needed!
|
||||
// Initialize LET with energy of primaries and clear data inside
|
||||
if ( (let = HadrontherapyLet::GetInstance(this)) )
|
||||
G4GeometryManager::GetInstance() -> OpenGeometry();
|
||||
if (phantom)
|
||||
{
|
||||
HadrontherapyLet::GetInstance() -> Initialize();
|
||||
}
|
||||
|
||||
|
||||
// Initialize analysis
|
||||
phantom -> SetXHalfLength(phantomSizeX/2);
|
||||
phantom -> SetYHalfLength(phantomSizeY/2);
|
||||
phantom -> SetZHalfLength(phantomSizeZ/2);
|
||||
phantomPhysicalVolume -> SetTranslation(phantomPosition);
|
||||
}
|
||||
else ConstructPhantom();
|
||||
|
||||
// Get the center of the detector
|
||||
SetDetectorPosition();
|
||||
if (detector)
|
||||
{
|
||||
detector -> SetXHalfLength(detectorSizeX/2);
|
||||
detector -> SetYHalfLength(detectorSizeY/2);
|
||||
detector -> SetZHalfLength(detectorSizeZ/2);
|
||||
detectorPhysicalVolume -> SetTranslation(detectorPosition);
|
||||
}
|
||||
else ConstructDetector();
|
||||
|
||||
// Round to nearest integer number of voxel
|
||||
|
||||
numberOfVoxelsAlongX = G4lrint(detectorSizeX / sizeOfVoxelAlongX);
|
||||
sizeOfVoxelAlongX = ( detectorSizeX / numberOfVoxelsAlongX );
|
||||
numberOfVoxelsAlongY = G4lrint(detectorSizeY / sizeOfVoxelAlongY);
|
||||
sizeOfVoxelAlongY = ( detectorSizeY / numberOfVoxelsAlongY );
|
||||
numberOfVoxelsAlongZ = G4lrint(detectorSizeZ / sizeOfVoxelAlongZ);
|
||||
sizeOfVoxelAlongZ = ( detectorSizeZ / numberOfVoxelsAlongZ );
|
||||
PassiveProtonBeamLine *ppbl= (PassiveProtonBeamLine*)
|
||||
|
||||
G4RunManager::GetRunManager()->GetUserDetectorConstruction();
|
||||
|
||||
HadrontherapyDetectorROGeometry* RO = (HadrontherapyDetectorROGeometry*) ppbl->GetParallelWorld(0);
|
||||
|
||||
//Set parameters, either for the Construct() or for the UpdateROGeometry()
|
||||
RO->Initialize(GetDetectorToWorldPosition(),
|
||||
detectorSizeX/2,
|
||||
detectorSizeY/2,
|
||||
detectorSizeZ/2,
|
||||
numberOfVoxelsAlongX,
|
||||
numberOfVoxelsAlongY,
|
||||
numberOfVoxelsAlongZ);
|
||||
|
||||
//This method below has an effect only if the RO geometry is already built.
|
||||
RO->UpdateROGeometry();
|
||||
|
||||
|
||||
|
||||
volumeOfVoxel = sizeOfVoxelAlongX * sizeOfVoxelAlongY * sizeOfVoxelAlongZ;
|
||||
massOfVoxel = detectorMaterial -> GetDensity() * volumeOfVoxel;
|
||||
// This will clear the existing matrix (together with all data inside it)!
|
||||
matrix = HadrontherapyMatrix::GetInstance(numberOfVoxelsAlongX,
|
||||
numberOfVoxelsAlongY,
|
||||
numberOfVoxelsAlongZ,
|
||||
massOfVoxel);
|
||||
|
||||
|
||||
// Comment out the line below if let calculation is not needed!
|
||||
// Initialize LET with energy of primaries and clear data inside
|
||||
if ( (let = HadrontherapyLet::GetInstance(this)) )
|
||||
{
|
||||
HadrontherapyLet::GetInstance() -> Initialize();
|
||||
}
|
||||
|
||||
|
||||
// Initialize analysis
|
||||
#ifdef G4ANALYSIS_USE_ROOT
|
||||
HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::GetInstance();
|
||||
analysis -> flush(); // Finalize the root file
|
||||
analysis -> book();
|
||||
HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::GetInstance();
|
||||
analysis -> flush(); // Finalize the root file
|
||||
analysis -> book();
|
||||
#endif
|
||||
// Inform the kernel about the new geometry
|
||||
G4RunManager::GetRunManager() -> GeometryHasBeenModified();
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
|
||||
PrintParameters();
|
||||
// Inform the kernel about the new geometry
|
||||
G4RunManager::GetRunManager() -> GeometryHasBeenModified();
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
|
||||
PrintParameters();
|
||||
// CheckOverlaps();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//Check of the geometry
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::CheckOverlaps()
|
||||
{
|
||||
G4PhysicalVolumeStore* thePVStore = G4PhysicalVolumeStore::GetInstance();
|
||||
G4cout << thePVStore->size() << " physical volumes are defined" << G4endl;
|
||||
G4bool overlapFlag = false;
|
||||
G4int res=1000;
|
||||
G4double tol=0.; //tolerance
|
||||
for (size_t i=0;i<thePVStore->size();i++)
|
||||
{
|
||||
//overlapFlag = (*thePVStore)[i]->CheckOverlaps(res,tol,fCheckOverlapsVerbosity) | overlapFlag;
|
||||
overlapFlag = (*thePVStore)[i]->CheckOverlaps(res,tol,true) | overlapFlag; }
|
||||
if (overlapFlag)
|
||||
G4cout << "Check: there are overlapping volumes" << G4endl;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyDetectorConstruction::PrintParameters()
|
||||
{
|
||||
|
||||
G4cout << "The (X,Y,Z) dimensions of the phantom are : (" <<
|
||||
G4BestUnit( phantom -> GetXHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( phantom -> GetYHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( phantom -> GetZHalfLength()*2., "Length") << ')' << G4endl;
|
||||
|
||||
G4cout << "The (X,Y,Z) dimensions of the detector are : (" <<
|
||||
G4BestUnit( detector -> GetXHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( detector -> GetYHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( detector -> GetZHalfLength()*2., "Length") << ')' << G4endl;
|
||||
|
||||
G4cout << "Displacement between Phantom and World is: ";
|
||||
G4cout << "DX= "<< G4BestUnit(phantomPosition.getX(),"Length") <<
|
||||
"DY= "<< G4BestUnit(phantomPosition.getY(),"Length") <<
|
||||
G4cout << "The (X,Y,Z) dimensions of the phantom are : (" <<
|
||||
G4BestUnit( phantom -> GetXHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( phantom -> GetYHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( phantom -> GetZHalfLength()*2., "Length") << ')' << G4endl;
|
||||
|
||||
G4cout << "The (X,Y,Z) dimensions of the detector are : (" <<
|
||||
G4BestUnit( detector -> GetXHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( detector -> GetYHalfLength()*2., "Length") << ',' <<
|
||||
G4BestUnit( detector -> GetZHalfLength()*2., "Length") << ')' << G4endl;
|
||||
|
||||
G4cout << "Displacement between Phantom and World is: ";
|
||||
G4cout << "DX= "<< G4BestUnit(phantomPosition.getX(),"Length") <<
|
||||
"DY= "<< G4BestUnit(phantomPosition.getY(),"Length") <<
|
||||
"DZ= "<< G4BestUnit(phantomPosition.getZ(),"Length") << G4endl;
|
||||
|
||||
G4cout << "The (X,Y,Z) sizes of the Voxels are: (" <<
|
||||
G4BestUnit(sizeOfVoxelAlongX, "Length") << ',' <<
|
||||
G4BestUnit(sizeOfVoxelAlongY, "Length") << ',' <<
|
||||
|
||||
G4cout << "The (X,Y,Z) sizes of the Voxels are: (" <<
|
||||
G4BestUnit(sizeOfVoxelAlongX, "Length") << ',' <<
|
||||
G4BestUnit(sizeOfVoxelAlongY, "Length") << ',' <<
|
||||
G4BestUnit(sizeOfVoxelAlongZ, "Length") << ')' << G4endl;
|
||||
|
||||
G4cout << "The number of Voxels along (X,Y,Z) is: (" <<
|
||||
|
||||
G4cout << "The number of Voxels along (X,Y,Z) is: (" <<
|
||||
numberOfVoxelsAlongX << ',' <<
|
||||
numberOfVoxelsAlongY <<',' <<
|
||||
numberOfVoxelsAlongZ << ')' << G4endl;
|
||||
|
||||
numberOfVoxelsAlongY <<',' <<
|
||||
numberOfVoxelsAlongZ << ')' << G4endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
@@ -34,9 +30,13 @@
|
||||
|
||||
#include "HadrontherapyDetectorHit.hh"
|
||||
|
||||
G4Allocator<HadrontherapyDetectorHit> HadrontherapyDetectorHitAllocator;
|
||||
|
||||
//**********************MT
|
||||
G4ThreadLocal G4Allocator<HadrontherapyDetectorHit>* HadrontherapyDetectorHitAllocator=0;
|
||||
//**********************MT
|
||||
|
||||
HadrontherapyDetectorHit::HadrontherapyDetectorHit()
|
||||
: G4VHit()
|
||||
{
|
||||
energyDeposit = 0;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ HadrontherapyDetectorHit::~HadrontherapyDetectorHit()
|
||||
{
|
||||
}
|
||||
|
||||
HadrontherapyDetectorHit::HadrontherapyDetectorHit(const HadrontherapyDetectorHit &right)
|
||||
HadrontherapyDetectorHit::HadrontherapyDetectorHit(const HadrontherapyDetectorHit& right)
|
||||
: G4VHit()
|
||||
{
|
||||
xHitID = right.xHitID;
|
||||
@@ -54,7 +54,7 @@ HadrontherapyDetectorHit::HadrontherapyDetectorHit(const HadrontherapyDetectorHi
|
||||
energyDeposit = right.energyDeposit;
|
||||
}
|
||||
|
||||
const HadrontherapyDetectorHit& HadrontherapyDetectorHit::operator=(const HadrontherapyDetectorHit &right)
|
||||
const HadrontherapyDetectorHit& HadrontherapyDetectorHit::operator=(const HadrontherapyDetectorHit& right)
|
||||
{
|
||||
xHitID = right.xHitID;
|
||||
zHitID = right.zHitID;
|
||||
@@ -63,9 +63,7 @@ const HadrontherapyDetectorHit& HadrontherapyDetectorHit::operator=(const Hadron
|
||||
return *this;
|
||||
}
|
||||
|
||||
int HadrontherapyDetectorHit::operator==(const HadrontherapyDetectorHit &right) const
|
||||
G4int HadrontherapyDetectorHit::operator==(const HadrontherapyDetectorHit& right) const
|
||||
{
|
||||
return((xHitID==right.xHitID)&&(zHitID==right.zHitID)&&(yHitID==right.yHitID));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
@@ -40,6 +36,7 @@
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* detector)
|
||||
:hadrontherapyDetector(detector)
|
||||
@@ -114,7 +111,8 @@ HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(HadrontherapyDete
|
||||
changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
|
||||
changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
|
||||
changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger()
|
||||
@@ -127,7 +125,7 @@ HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger()
|
||||
delete changeTheDetectorDir;
|
||||
delete changeTheDetectorSizeCmd;
|
||||
delete changeTheDetectorToPhantomPositionCmd;
|
||||
delete changeTheDetectorVoxelCmd;
|
||||
delete changeTheDetectorVoxelCmd;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
+242
@@ -0,0 +1,242 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "HadrontherapyElectricTabulatedField3D.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
namespace{ G4Mutex MyHadrontherapyLockEField=G4MUTEX_INITIALIZER; }
|
||||
|
||||
HadrontherapyElectricTabulatedField3D::HadrontherapyElectricTabulatedField3D( const char* filename, G4double exOffset, G4double eyOffset, G4double ezOffset)
|
||||
:feXoffset(exOffset),feYoffset(eyOffset),feZoffset(ezOffset),einvertX(false),einvertY(false),einvertZ(false)
|
||||
{
|
||||
//The format file is: X Y Z Ex Ey Ez
|
||||
|
||||
G4double ElenUnit= cm;
|
||||
G4double EfieldUnit= volt/m;
|
||||
G4cout << "\n-----------------------------------------------------------"
|
||||
<< "\n Electric field"
|
||||
<< "\n-----------------------------------------------------------";
|
||||
|
||||
G4cout << "\n ---> " "Reading the field grid from " << filename << " ... " << endl;
|
||||
G4AutoLock lock(&MyHadrontherapyLockEField);
|
||||
|
||||
ifstream file( filename ); // Open the file for reading.
|
||||
|
||||
// Ignore first blank line
|
||||
char ebuffer[256];
|
||||
file.getline(ebuffer,256);
|
||||
|
||||
// Read table dimensions
|
||||
file >> Enx >> Eny >> Enz; // Note dodgy order
|
||||
|
||||
G4cout << " [ Number of values x,y,z: "
|
||||
<< Enx << " " << Eny << " " << Enz << " ] "
|
||||
<< endl;
|
||||
|
||||
// Set up storage space for table
|
||||
xEField.resize( Enx );
|
||||
yEField.resize( Enx );
|
||||
zEField.resize( Enx );
|
||||
G4int ix, iy, iz;
|
||||
for (ix=0; ix<Enx; ix++) {
|
||||
xEField[ix].resize(Eny);
|
||||
yEField[ix].resize(Eny);
|
||||
zEField[ix].resize(Eny);
|
||||
for (iy=0; iy<Eny; iy++) {
|
||||
xEField[ix][iy].resize(Enz);
|
||||
yEField[ix][iy].resize(Enz);
|
||||
zEField[ix][iy].resize(Enz);
|
||||
}
|
||||
}
|
||||
|
||||
// Read in the data
|
||||
G4double Exval=0.;
|
||||
G4double Eyval=0.;
|
||||
G4double Ezval=0.;
|
||||
G4double Ex=0.;
|
||||
G4double Ey=0.;
|
||||
G4double Ez=0.;
|
||||
for (iz=0; iz<Enz; iz++) {
|
||||
for (iy=0; iy<Eny; iy++) {
|
||||
for (ix=0; ix<Enx; ix++) {
|
||||
file >> Exval >> Eyval >> Ezval >> Ex >> Ey >> Ez;
|
||||
|
||||
if ( ix==0 && iy==0 && iz==0 ) {
|
||||
Eminx = Exval * ElenUnit;
|
||||
Eminy = Eyval * ElenUnit;
|
||||
Eminz = Ezval * ElenUnit;
|
||||
}
|
||||
xEField[ix][iy][iz] = Ex * EfieldUnit;
|
||||
yEField[ix][iy][iz] = Ey * EfieldUnit;
|
||||
zEField[ix][iy][iz] = Ez * EfieldUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
lock.unlock();
|
||||
|
||||
Emaxx = Exval * ElenUnit;
|
||||
Emaxy = Eyval * ElenUnit;
|
||||
Emaxz = Ezval * ElenUnit;
|
||||
|
||||
G4cout << "\n ---> ... done reading " << endl;
|
||||
|
||||
// G4cout << " Read values of field from file " << filename << endl;
|
||||
G4cout << " ---> assumed the order: x, y, z, Ex, Ey, Ez "
|
||||
<< "\n ---> Min values x,y,z: "
|
||||
<< Eminx/cm << " " << Eminy/cm << " " << Eminz/cm << " cm "
|
||||
<< "\n ---> Max values x,y,z: "
|
||||
<< Emaxx/cm << " " << Emaxy/cm << " " << Emaxz/cm << " cm "
|
||||
<< "\n ---> The field will be offset in x by " << exOffset/cm << " cm "
|
||||
<< "\n ---> The field will be offset in y by " << eyOffset/cm << " cm "
|
||||
<< "\n ---> The field will be offset in z by " << ezOffset/cm << " cm " << endl;
|
||||
|
||||
// Should really check that the limits are not the wrong way around.
|
||||
if (Emaxx < Eminx) {swap(Emaxx,Eminx); einvertX = true;}
|
||||
if (Emaxy < Eminy) {swap(Emaxy,Eminy); einvertY = true;}
|
||||
if (Emaxz < Eminz) {swap(Emaxz,Eminz); einvertZ = true;}
|
||||
G4cout << "\nAfter reordering if neccesary"
|
||||
<< "\n ---> Min values x,y,z: "
|
||||
<< Eminx/cm << " " << Eminy/cm << " " << Eminz/cm << " cm "
|
||||
<< " \n ---> Max values x,y,z: "
|
||||
<< Emaxx/cm << " " << Emaxy/cm << " " << Emaxz/cm << " cm ";
|
||||
|
||||
dx1 = Emaxx - Eminx;
|
||||
dy1 = Emaxy - Eminy;
|
||||
dz1 = Emaxz - Eminz;
|
||||
G4cout << "\n ---> Dif values x,y,z (range): "
|
||||
<< dx1/cm << " " << dy1/cm << " " << dz1/cm << " cm "
|
||||
<< "\n-----------------------------------------------------------" << endl;
|
||||
}
|
||||
|
||||
void HadrontherapyElectricTabulatedField3D::GetFieldValue(const G4double Epoint[4],
|
||||
G4double *Efield ) const
|
||||
{
|
||||
//G4cout<<"sono dentro getfieldvalue (elctric)"<<G4endl;
|
||||
|
||||
G4double x1 = Epoint[0] + feXoffset;
|
||||
G4double y1 = Epoint[1] + feYoffset;
|
||||
G4double z1 = Epoint[2] + feZoffset;
|
||||
|
||||
// Check that the point is within the defined region
|
||||
if ( x1>=Eminx && x1<Emaxx &&
|
||||
y1>=Eminy && y1<Emaxy &&
|
||||
z1>=Eminz && z1<Emaxz ) {
|
||||
|
||||
// Position of given point within region, normalized to the range
|
||||
// [0,1]
|
||||
G4double Exfraction = (x1 - Eminx) / dx1;
|
||||
G4double Eyfraction = (y1 - Eminy) / dy1;
|
||||
G4double Ezfraction = (z1 - Eminz) / dz1;
|
||||
|
||||
if (einvertX) { Exfraction = 1 - Exfraction;}
|
||||
if (einvertY) { Eyfraction = 1 - Eyfraction;}
|
||||
if (einvertZ) { Ezfraction = 1 - Ezfraction;}
|
||||
|
||||
// Need addresses of these to pass to modf below.
|
||||
// modf uses its second argument as an OUTPUT argument.
|
||||
G4double exdindex, eydindex, ezdindex;
|
||||
|
||||
// Position of the point within the cuboid defined by the
|
||||
// nearest surrounding tabulated points
|
||||
G4double exlocal = ( std::modf(Exfraction*(Enx-1), &exdindex));
|
||||
G4double eylocal = ( std::modf(Eyfraction*(Eny-1), &eydindex));
|
||||
G4double ezlocal = ( std::modf(Ezfraction*(Enz-1), &ezdindex));
|
||||
|
||||
// The indices of the nearest tabulated point whose coordinates
|
||||
// are all less than those of the given point
|
||||
G4int exindex = static_cast<G4int>(exdindex);
|
||||
G4int eyindex = static_cast<G4int>(eydindex);
|
||||
G4int ezindex = static_cast<G4int>(ezdindex);
|
||||
|
||||
/*
|
||||
#ifdef DEBUG_G4intERPOLATING_FIELD
|
||||
G4cout << "Local x,y,z: " << exlocal << " " << eylocal << " " << ezlocal << endl;
|
||||
G4cout << "Index x,y,z: " << exindex << " " << eyindex << " " << ezindex << endl;
|
||||
G4double valx0z0, mulx0z0, valx1z0, mulx1z0;
|
||||
G4double valx0z1, mulx0z1, valx1z1, mulx1z1;
|
||||
valx0z0= table[exindex ][0][ezindex]; mulx0z0= (1-exlocal) * (1-ezlocal);
|
||||
valx1z0= table[exindex+1][0][ezindex]; mulx1z0= exlocal * (1-ezlocal);
|
||||
valx0z1= table[exindex ][0][ezindex+1]; mulx0z1= (1-exlocal) * ezlocal;
|
||||
valx1z1= table[exindex+1][0][ezindex+1]; mulx1z1= exlocal * ezlocal;
|
||||
#endif
|
||||
*/
|
||||
// Full 3-dimensional version
|
||||
|
||||
Efield[0] = 0.0;
|
||||
Efield[1] = 0.0;
|
||||
Efield[2] = 0.0;
|
||||
|
||||
Efield[3] =
|
||||
xEField[exindex ][eyindex ][ezindex ] * (1-exlocal) * (1-eylocal) * (1-ezlocal) +
|
||||
xEField[exindex ][eyindex ][ezindex+1] * (1-exlocal) * (1-eylocal) * ezlocal +
|
||||
xEField[exindex ][eyindex+1][ezindex ] * (1-exlocal) * eylocal * (1-ezlocal) +
|
||||
xEField[exindex ][eyindex+1][ezindex+1] * (1-exlocal) * eylocal * ezlocal +
|
||||
xEField[exindex+1][eyindex ][ezindex ] * exlocal * (1-eylocal) * (1-ezlocal) +
|
||||
xEField[exindex+1][eyindex ][ezindex+1] * exlocal * (1-eylocal) * ezlocal +
|
||||
xEField[exindex+1][eyindex+1][ezindex ] * exlocal * eylocal * (1-ezlocal) +
|
||||
xEField[exindex+1][eyindex+1][ezindex+1] * exlocal * eylocal * ezlocal ;
|
||||
Efield[4] =
|
||||
yEField[exindex ][eyindex ][ezindex ] * (1-exlocal) * (1-eylocal) * (1-ezlocal) +
|
||||
yEField[exindex ][eyindex ][ezindex+1] * (1-exlocal) * (1-eylocal) * ezlocal +
|
||||
yEField[exindex ][eyindex+1][ezindex ] * (1-exlocal) * eylocal * (1-ezlocal) +
|
||||
yEField[exindex ][eyindex+1][ezindex+1] * (1-exlocal) * eylocal * ezlocal +
|
||||
yEField[exindex+1][eyindex ][ezindex ] * exlocal * (1-eylocal) * (1-ezlocal) +
|
||||
yEField[exindex+1][eyindex ][ezindex+1] * exlocal * (1-eylocal) * ezlocal +
|
||||
yEField[exindex+1][eyindex+1][ezindex ] * exlocal * eylocal * (1-ezlocal) +
|
||||
yEField[exindex+1][eyindex+1][ezindex+1] * exlocal * eylocal * ezlocal ;
|
||||
Efield[5] =
|
||||
zEField[exindex ][eyindex ][ezindex ] * (1-exlocal) * (1-eylocal) * (1-ezlocal) +
|
||||
zEField[exindex ][eyindex ][ezindex+1] * (1-exlocal) * (1-eylocal) * ezlocal +
|
||||
zEField[exindex ][eyindex+1][ezindex ] * (1-exlocal) * eylocal * (1-ezlocal) +
|
||||
zEField[exindex ][eyindex+1][ezindex+1] * (1-exlocal) * eylocal * ezlocal +
|
||||
zEField[exindex+1][eyindex ][ezindex ] * exlocal * (1-eylocal) * (1-ezlocal) +
|
||||
zEField[exindex+1][eyindex ][ezindex+1] * exlocal * (1-eylocal) * ezlocal +
|
||||
zEField[exindex+1][eyindex+1][ezindex ] * exlocal * eylocal * (1-ezlocal) +
|
||||
zEField[exindex+1][eyindex+1][ezindex+1] * exlocal * eylocal * ezlocal ;
|
||||
|
||||
} else {
|
||||
Efield[0] = 0.0;
|
||||
Efield[1] = 0.0;
|
||||
Efield[2] = 0.0;
|
||||
Efield[3] = 0.0;
|
||||
Efield[4] = 0.0;
|
||||
Efield[5] = 0.0;
|
||||
}
|
||||
//G4cout << "Getting electric field " << Efield[3]/(volt/m) << " " << Efield[4]/(volt/m) << " " << Efield[5]/(volt/m) << endl;
|
||||
//G4cout << "For coordinates: " << Epoint[0] << " " << Epoint[1] << " " << Epoint[2] << G4endl;
|
||||
|
||||
/*std::ofstream WriteDataIn("ElectricFieldFC.out", std::ios::app);
|
||||
WriteDataIn << Epoint[0] << '\t' << " "
|
||||
<< Epoint[1] << '\t' << " "
|
||||
<< Epoint[2] << '\t' << " "
|
||||
<< Efield[3]/(volt/m) << '\t' << " "
|
||||
<< Efield[4]/(volt/m) << '\t' << " "
|
||||
<< Efield[5]/(volt/m) << '\t' << " "
|
||||
<< G4endl; */
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
// Institute in the framework of the MC-INFN Group
|
||||
//
|
||||
// Hadrontherapy development is supported by the
|
||||
// Italian Institute for Nuclear Physics (INFN)
|
||||
// in the framework of the MC-INFN Project
|
||||
|
||||
#include "HadrontherapyGeometryController.hh"
|
||||
#include "HadrontherapyDetectorConstruction.hh"
|
||||
@@ -39,9 +34,11 @@
|
||||
|
||||
#include "PassiveProtonBeamLine.hh"
|
||||
#include "PassiveCarbonBeamLine.hh"
|
||||
#include "LaserDrivenBeamLine.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4VUserParallelWorld.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyGeometryController::HadrontherapyGeometryController()
|
||||
{}
|
||||
@@ -54,34 +51,29 @@ HadrontherapyGeometryController::~HadrontherapyGeometryController()
|
||||
void HadrontherapyGeometryController::SetGeometry(G4String name)
|
||||
{
|
||||
G4cout <<"Activating geometry " << name << G4endl;
|
||||
|
||||
|
||||
if(name == "default")
|
||||
if(name == "default")
|
||||
{
|
||||
|
||||
registerGeometry(new PassiveProtonBeamLine());
|
||||
|
||||
|
||||
}
|
||||
|
||||
registerGeometry(new PassiveProtonBeamLine());
|
||||
}
|
||||
else if(name == "Carbon")
|
||||
{
|
||||
|
||||
registerGeometry(new PassiveCarbonBeamLine());
|
||||
registerGeometry(new PassiveCarbonBeamLine());
|
||||
}
|
||||
else if(name == "LaserDriven")
|
||||
{
|
||||
registerGeometry(new LaserDrivenBeamLine());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
G4cout <<"Unknown geometry: " << name << ". Geometry not changed." << G4endl;
|
||||
G4cout <<"Unknown geometry: " << name << ". Geometry not changed." << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyGeometryController::registerGeometry(G4VUserDetectorConstruction *detector)
|
||||
{
|
||||
G4RunManager *runManager = G4RunManager::GetRunManager();
|
||||
|
||||
runManager->SetUserInitialization(detector);
|
||||
runManager->GeometryHasBeenModified();
|
||||
runManager -> SetUserInitialization(detector);
|
||||
runManager -> GeometryHasBeenModified();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,43 +22,51 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
// Institute in the framework of the MC-INFN Group
|
||||
//
|
||||
|
||||
//
|
||||
#include "HadrontherapyGeometryMessenger.hh"
|
||||
#include "HadrontherapyGeometryController.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyGeometryMessenger::HadrontherapyGeometryMessenger(HadrontherapyGeometryController* controller)
|
||||
:hadrontherapyGeometryController(controller)
|
||||
:hadrontherapyGeometryController(controller)
|
||||
|
||||
{
|
||||
changeTheGeometryDir = new G4UIdirectory("/geometrySetup/");
|
||||
changeTheGeometryDir -> SetGuidance("Geometry setup");
|
||||
|
||||
changeTheGeometryCmd = new G4UIcmdWithAString("/geometrySetup/selectGeometry",this);
|
||||
changeTheGeometryCmd -> SetGuidance("Select the geometry you wish to use");
|
||||
changeTheGeometryCmd -> SetParameterName("Geometry",false);
|
||||
changeTheGeometryCmd -> AvailableForStates(G4State_PreInit);
|
||||
changeTheGeometryDir = new G4UIdirectory("/geometrySetup/");
|
||||
changeTheGeometryDir -> SetGuidance("Geometry setup");
|
||||
|
||||
changeTheGeometryCmd = new G4UIcmdWithAString("/geometrySetup/selectGeometry",this);
|
||||
changeTheGeometryCmd -> SetGuidance("Select the geometry you wish to use");
|
||||
changeTheGeometryCmd -> SetParameterName("Geometry",false);
|
||||
changeTheGeometryCmd -> AvailableForStates(G4State_PreInit);
|
||||
|
||||
/* changeTheDetectorCmd = new G4UIcmdWithAString("/geometrySetup/selectDetector",this);
|
||||
changeTheDetectorCmd -> SetGuidance("Select the detector you wish to use");
|
||||
changeTheDetectorCmd -> SetParameterName("Detector",false);
|
||||
changeTheDetectorCmd -> AvailableForStates(G4State_PreInit);*/
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyGeometryMessenger::~HadrontherapyGeometryMessenger()
|
||||
{
|
||||
delete changeTheGeometryDir;
|
||||
delete changeTheGeometryCmd;
|
||||
{
|
||||
delete changeTheGeometryDir;
|
||||
delete changeTheGeometryCmd;
|
||||
// delete changeTheDetectorCmd;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyGeometryMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == changeTheGeometryCmd )
|
||||
{ hadrontherapyGeometryController -> SetGeometry (newValue);}
|
||||
{
|
||||
/* if( command == changeTheDetectorCmd )
|
||||
{
|
||||
hadrontherapyGeometryController -> SetDetector (newValue);
|
||||
}
|
||||
else*/
|
||||
if( command == changeTheGeometryCmd )
|
||||
{
|
||||
hadrontherapyGeometryController -> SetGeometry (newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "HadrontherapyDetectorConstruction.hh"
|
||||
#include "HadrontherapyLet.hh"
|
||||
#include "HadrontherapyAnalysisManager.hh"
|
||||
@@ -44,35 +42,39 @@ HadrontherapyLet* HadrontherapyLet::GetInstance(HadrontherapyDetectorConstructio
|
||||
return instance;
|
||||
}
|
||||
|
||||
HadrontherapyLet* HadrontherapyLet::GetInstance()
|
||||
HadrontherapyLet* HadrontherapyLet::GetInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
HadrontherapyLet::HadrontherapyLet(HadrontherapyDetectorConstruction* pDet)
|
||||
:filename("Let.out") // Default output filename
|
||||
:filename("Let.out"),matrix(0) // Default output filename
|
||||
{
|
||||
|
||||
|
||||
matrix = HadrontherapyMatrix::GetInstance();
|
||||
|
||||
if (!matrix) G4Exception("HadrontherapyLet::HadrontherapyLet","Hadrontherapy0005", FatalException, "HadrontherapyMatrix not found. Firstly create an instance of it.");
|
||||
|
||||
|
||||
if (!matrix)
|
||||
G4Exception("HadrontherapyLet::HadrontherapyLet",
|
||||
"Hadrontherapy0005", FatalException,
|
||||
"HadrontherapyMatrix not found. Firstly create an instance of it.");
|
||||
|
||||
nVoxels = matrix -> GetNvoxel();
|
||||
|
||||
|
||||
numberOfVoxelAlongX = matrix -> GetNumberOfVoxelAlongX();
|
||||
numberOfVoxelAlongY = matrix -> GetNumberOfVoxelAlongY();
|
||||
numberOfVoxelAlongZ = matrix -> GetNumberOfVoxelAlongZ();
|
||||
|
||||
|
||||
G4RunManager *runManager = G4RunManager::GetRunManager();
|
||||
pPGA = (HadrontherapyPrimaryGeneratorAction*)runManager -> GetUserPrimaryGeneratorAction();
|
||||
// Pointer to the detector material
|
||||
detectorMat = pDet -> GetDetectorLogicalVolume() -> GetMaterial();
|
||||
density = detectorMat -> GetDensity();
|
||||
// Instances for Total LET
|
||||
// Instances for Total LET
|
||||
totalLetD = new G4double[nVoxels];
|
||||
DtotalLetD = new G4double[nVoxels];
|
||||
|
||||
|
||||
}
|
||||
|
||||
HadrontherapyLet::~HadrontherapyLet()
|
||||
{
|
||||
Clear();
|
||||
@@ -99,20 +101,20 @@ void HadrontherapyLet::Clear()
|
||||
ionLetStore.clear();
|
||||
}
|
||||
void HadrontherapyLet::FillEnergySpectrum(G4int trackID,
|
||||
G4ParticleDefinition* particleDef,
|
||||
/*G4double kinEnergy,*/
|
||||
G4double DE,
|
||||
G4double DX,
|
||||
G4int i, G4int j, G4int k)
|
||||
G4ParticleDefinition* particleDef,
|
||||
/*G4double kinEnergy,*/
|
||||
G4double DE,
|
||||
G4double DX,
|
||||
G4int i, G4int j, G4int k)
|
||||
{
|
||||
if (DE <= 0. || DX <=0.) return;
|
||||
if (!doCalculation) return;
|
||||
G4int Z = particleDef -> GetAtomicNumber();
|
||||
|
||||
|
||||
|
||||
|
||||
G4int PDGencoding = particleDef -> GetPDGEncoding();
|
||||
PDGencoding -= PDGencoding%10;
|
||||
|
||||
|
||||
G4int voxel = matrix -> Index(i,j,k);
|
||||
// Total LET calculation...
|
||||
totalLetD[voxel] += DE*(DE/DX);
|
||||
@@ -122,24 +124,24 @@ void HadrontherapyLet::FillEnergySpectrum(G4int trackID,
|
||||
{
|
||||
// Search for already allocated data...
|
||||
size_t l;
|
||||
for (l=0; l < ionLetStore.size(); l++)
|
||||
for (l=0; l < ionLetStore.size(); l++)
|
||||
{
|
||||
if (ionLetStore[l].PDGencoding == PDGencoding)
|
||||
if ( ((trackID ==1) && (ionLetStore[l].isPrimary)) || ((trackID !=1) && (!ionLetStore[l].isPrimary)))
|
||||
if (ionLetStore[l].PDGencoding == PDGencoding)
|
||||
if ( ((trackID ==1) && (ionLetStore[l].isPrimary)) || ((trackID !=1) && (!ionLetStore[l].isPrimary)))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (l == ionLetStore.size()) // Just another type of ion/particle for our store...
|
||||
{
|
||||
|
||||
|
||||
G4int A = particleDef -> GetAtomicMass();
|
||||
|
||||
|
||||
G4String fullName = particleDef -> GetParticleName();
|
||||
G4String name = fullName.substr (0, fullName.find("[") ); // cut excitation energy [x.y]
|
||||
|
||||
G4String name = fullName.substr (0, fullName.find("[") ); // cut excitation energy [x.y]
|
||||
|
||||
ionLet ion =
|
||||
{
|
||||
(trackID == 1) ? true:false, // is it the primary particle?
|
||||
(trackID == 1) ? true:false, // is it the primary particle?
|
||||
PDGencoding,
|
||||
fullName,
|
||||
name,
|
||||
@@ -148,12 +150,12 @@ void HadrontherapyLet::FillEnergySpectrum(G4int trackID,
|
||||
new G4double[nVoxels], // Let Dose Numerator
|
||||
new G4double[nVoxels] // Let Dose Denominator
|
||||
};
|
||||
|
||||
|
||||
// Initialize let
|
||||
for(G4int v=0; v < nVoxels; v++) ion.letDN[v] = ion.letDD[v] = 0.;
|
||||
ionLetStore.push_back(ion);
|
||||
//G4cout << "Allocated LET data for " << ion.name << G4endl;
|
||||
|
||||
|
||||
}
|
||||
ionLetStore[l].letDN[voxel] += DE*(DE/DX);
|
||||
ionLetStore[l].letDD[voxel] += DE;
|
||||
@@ -169,16 +171,16 @@ void HadrontherapyLet::LetOutput()
|
||||
// Sort ions by A and then by Z ...
|
||||
std::sort(ionLetStore.begin(), ionLetStore.end());
|
||||
// Compute Let Track and Let Dose for any single ion
|
||||
|
||||
for(G4int v=0; v < nVoxels; v++)
|
||||
|
||||
for(G4int v=0; v < nVoxels; v++)
|
||||
{
|
||||
for (size_t ion=0; ion < ionLetStore.size(); ion++)
|
||||
{
|
||||
if (ionLetStore[ion].letDD[v] >0.) ionLetStore[ion].letDN[v] = ionLetStore[ion].letDN[v] / ionLetStore[ion].letDD[v];
|
||||
|
||||
|
||||
}// end loop over ions
|
||||
}
|
||||
|
||||
|
||||
}// end loop over voxels
|
||||
|
||||
void HadrontherapyLet::StoreLetAscii()
|
||||
@@ -189,22 +191,22 @@ void HadrontherapyLet::StoreLetAscii()
|
||||
ofs.open(filename, std::ios::out);
|
||||
if (ofs.is_open())
|
||||
{
|
||||
|
||||
// Write the voxels index and the list of particles/ions
|
||||
|
||||
// Write the voxels index and the list of particles/ions
|
||||
ofs << std::setprecision(6) << std::left <<
|
||||
"i\tj\tk\t";
|
||||
ofs << std::setw(width) << "LDT";
|
||||
"i\tj\tk\t";
|
||||
ofs << std::setw(width) << "LDT";
|
||||
for (size_t l=0; l < ionLetStore.size(); l++)
|
||||
{
|
||||
G4String a = (ionLetStore[l].isPrimary) ? "_1":"";
|
||||
ofs << std::setw(width) << ionLetStore[l].name + a ;
|
||||
}
|
||||
ofs << G4endl;
|
||||
|
||||
|
||||
// Write data
|
||||
for(G4int i = 0; i < numberOfVoxelAlongX; i++)
|
||||
for(G4int j = 0; j < numberOfVoxelAlongY; j++)
|
||||
for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
|
||||
for(G4int i = 0; i < numberOfVoxelAlongX; i++)
|
||||
for(G4int j = 0; j < numberOfVoxelAlongY; j++)
|
||||
for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
|
||||
{
|
||||
G4int v = matrix -> Index(i, j, k);
|
||||
// row write
|
||||
@@ -215,43 +217,43 @@ void HadrontherapyLet::StoreLetAscii()
|
||||
{
|
||||
ofs << G4endl;
|
||||
ofs << i << '\t' << j << '\t' << k << '\t';
|
||||
|
||||
ofs << std::setw(width) << totalLetD[v]/(keV/um);
|
||||
|
||||
ofs << std::setw(width) << totalLetD[v]/(keV/um);
|
||||
for (size_t ll=0; ll < ionLetStore.size(); ll++)
|
||||
{
|
||||
ofs << std::setw(width) << ionLetStore[ll].letDN[v]/(keV/um) ;
|
||||
ofs << std::setw(width) << ionLetStore[ll].letDN[v]/(keV/um) ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ofs.close();
|
||||
G4cout << "Let is being written to " << filename << G4endl;
|
||||
G4cout << "Let is being written to " << filename << G4endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void HadrontherapyLet::StoreLetRoot()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE_ROOT
|
||||
|
||||
|
||||
HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::GetInstance();
|
||||
|
||||
for(G4int i = 0; i < numberOfVoxelAlongX; i++)
|
||||
for(G4int j = 0; j < numberOfVoxelAlongY; j++)
|
||||
for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
|
||||
{
|
||||
G4int v = matrix -> Index(i, j, k);
|
||||
for (size_t ion=0; ion < ionLetStore.size(); ion++)
|
||||
{
|
||||
|
||||
analysis -> FillLetFragmentTuple( i, j, k, ionLetStore[ion].A, ionLetStore[ion].Z, ionLetStore[ion].letDN[v]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(G4int i = 0; i < numberOfVoxelAlongX; i++)
|
||||
for(G4int j = 0; j < numberOfVoxelAlongY; j++)
|
||||
for(G4int k = 0; k < numberOfVoxelAlongZ; k++)
|
||||
{
|
||||
G4int v = matrix -> Index(i, j, k);
|
||||
for (size_t ion=0; ion < ionLetStore.size(); ion++)
|
||||
{
|
||||
|
||||
analysis -> FillLetFragmentTuple( i, j, k, ionLetStore[ion].A, ionLetStore[ion].Z, ionLetStore[ion].letDN[v]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// *************************************
|
||||
// * *
|
||||
// * HadrontherapyMagneticField3D.cc *
|
||||
// * *
|
||||
// *************************************
|
||||
//
|
||||
//
|
||||
|
||||
#include "HadrontherapyMagneticField3D.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
namespace{ G4Mutex MyHadrontherapyLock=G4MUTEX_INITIALIZER; }
|
||||
|
||||
HadrontherapyMagneticField3D::HadrontherapyMagneticField3D( const char* filename, double xOffset )
|
||||
:fXoffset(xOffset),invertX(false),invertY(false),invertZ(false)
|
||||
{
|
||||
//The format file is: X Y Z Ex Ey Ez
|
||||
|
||||
double lenUnit= meter;
|
||||
double fieldUnit= tesla;
|
||||
G4cout << "\n-----------------------------------------------------------"
|
||||
<< "\n Magnetic field"
|
||||
<< "\n-----------------------------------------------------------";
|
||||
|
||||
|
||||
G4cout << "\n ---> " "Reading the field grid from " << filename << " ... " << endl;
|
||||
G4AutoLock lock(&MyHadrontherapyLock);
|
||||
|
||||
ifstream file( filename ); // Open the file for reading.
|
||||
|
||||
// Ignore first blank line
|
||||
char buffer[256];
|
||||
file.getline(buffer,256);
|
||||
|
||||
// Read table dimensions
|
||||
file >> nx >> ny >> nz; // Note dodgy order
|
||||
|
||||
G4cout << " [ Number of values x,y,z: "
|
||||
<< nx << " " << ny << " " << nz << " ] "
|
||||
<< endl;
|
||||
|
||||
// Set up storage space for table
|
||||
xField.resize( nx );
|
||||
yField.resize( nx );
|
||||
zField.resize( nx );
|
||||
int ix, iy, iz;
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
xField[ix].resize(ny);
|
||||
yField[ix].resize(ny);
|
||||
zField[ix].resize(ny);
|
||||
for (iy=0; iy<ny; iy++) {
|
||||
xField[ix][iy].resize(nz);
|
||||
yField[ix][iy].resize(nz);
|
||||
zField[ix][iy].resize(nz);
|
||||
}
|
||||
}
|
||||
|
||||
// Read in the data
|
||||
G4double xval=0.;
|
||||
G4double yval=0.;
|
||||
G4double zval=0.;
|
||||
G4double bx=0.;
|
||||
G4double by=0.;
|
||||
G4double bz=0.;
|
||||
double permeability=0.; // Not used in this example.
|
||||
for (ix=0; ix<nx; ix++) {
|
||||
for (iy=0; iy<ny; iy++) {
|
||||
for (iz=0; iz<nz; iz++) {
|
||||
file >> xval >> yval >> zval >> bx >> by >> bz >> permeability;
|
||||
if ( ix==0 && iy==0 && iz==0 ) {
|
||||
minx = xval * lenUnit;
|
||||
miny = yval * lenUnit;
|
||||
minz = zval * lenUnit;
|
||||
}
|
||||
xField[ix][iy][iz] = bx * fieldUnit;
|
||||
yField[ix][iy][iz] = by * fieldUnit;
|
||||
zField[ix][iy][iz] = bz * fieldUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
|
||||
lock.unlock();
|
||||
|
||||
maxx = xval * lenUnit;
|
||||
maxy = yval * lenUnit;
|
||||
maxz = zval * lenUnit;
|
||||
|
||||
G4cout << "\n ---> ... done reading " << endl;
|
||||
|
||||
// G4cout << " Read values of field from file " << filename << endl;
|
||||
G4cout << " ---> assumed the order: x, y, z, Bx, By, Bz "
|
||||
<< "\n ---> Min values x,y,z: "
|
||||
<< minx/cm << " " << miny/cm << " " << minz/cm << " cm "
|
||||
<< "\n ---> Max values x,y,z: "
|
||||
<< maxx/cm << " " << maxy/cm << " " << maxz/cm << " cm "
|
||||
<< "\n ---> The field will be offset by " << xOffset/cm << " cm " << endl;
|
||||
|
||||
// Should really check that the limits are not the wrong way around.
|
||||
if (maxx < minx) {swap(maxx,minx); invertX = true;}
|
||||
if (maxy < miny) {swap(maxy,miny); invertY = true;}
|
||||
if (maxz < minz) {swap(maxz,minz); invertZ = true;}
|
||||
G4cout << "\nAfter reordering if neccesary"
|
||||
<< "\n ---> Min values x,y,z: "
|
||||
<< minx/cm << " " << miny/cm << " " << minz/cm << " cm "
|
||||
<< " \n ---> Max values x,y,z: "
|
||||
<< maxx/cm << " " << maxy/cm << " " << maxz/cm << " cm ";
|
||||
|
||||
dx = maxx - minx;
|
||||
dy = maxy - miny;
|
||||
dz = maxz - minz;
|
||||
G4cout << "\n ---> Dif values x,y,z (range): "
|
||||
<< dx/cm << " " << dy/cm << " " << dz/cm << " cm in z "
|
||||
<< "\n-----------------------------------------------------------" << endl;
|
||||
}
|
||||
|
||||
void HadrontherapyMagneticField3D::GetFieldValue(const double point[4],
|
||||
double *Bfield ) const
|
||||
{
|
||||
double x = point[0]+ fXoffset;
|
||||
double y = point[1];
|
||||
double z = point[2];
|
||||
|
||||
// Check that the point is within the defined region
|
||||
if ( x>=minx && x<maxx &&
|
||||
y>=miny && y<maxy &&
|
||||
z>=minz && z<maxz ) {
|
||||
// Position of given point within region, normalized to the range
|
||||
// [0,1]
|
||||
double xfraction = (x - minx) / dx;
|
||||
double yfraction = (y - miny) / dy;
|
||||
double zfraction = (z - minz) / dz;
|
||||
|
||||
if (invertX) { xfraction = 1 - xfraction;}
|
||||
if (invertY) { yfraction = 1 - yfraction;}
|
||||
if (invertZ) { zfraction = 1 - zfraction;}
|
||||
|
||||
// Need addresses of these to pass to modf below.
|
||||
// modf uses its second argument as an OUTPUT argument.
|
||||
double xdindex, ydindex, zdindex;
|
||||
|
||||
// Position of the point within the cuboid defined by the
|
||||
// nearest surrounding tabulated points
|
||||
double xlocal = ( std::modf(xfraction*(nx-1), &xdindex));
|
||||
double ylocal = ( std::modf(yfraction*(ny-1), &ydindex));
|
||||
double zlocal = ( std::modf(zfraction*(nz-1), &zdindex));
|
||||
|
||||
// The indices of the nearest tabulated point whose coordinates
|
||||
// are all less than those of the given point
|
||||
int xindex = static_cast<int>(xdindex);
|
||||
int yindex = static_cast<int>(ydindex);
|
||||
int zindex = static_cast<int>(zdindex);
|
||||
|
||||
|
||||
#ifdef DEBUG_INTERPOLATING_FIELD
|
||||
G4cout << "Local x,y,z: " << xlocal << " " << ylocal << " " << zlocal << endl;
|
||||
G4cout << "Index x,y,z: " << xindex << " " << yindex << " " << zindex << endl;
|
||||
double valx0z0, mulx0z0, valx1z0, mulx1z0;
|
||||
double valx0z1, mulx0z1, valx1z1, mulx1z1;
|
||||
valx0z0= table[xindex ][0][zindex]; mulx0z0= (1-xlocal) * (1-zlocal);
|
||||
valx1z0= table[xindex+1][0][zindex]; mulx1z0= xlocal * (1-zlocal);
|
||||
valx0z1= table[xindex ][0][zindex+1]; mulx0z1= (1-xlocal) * zlocal;
|
||||
valx1z1= table[xindex+1][0][zindex+1]; mulx1z1= xlocal * zlocal;
|
||||
#endif
|
||||
// Full 3-dimensional version
|
||||
Bfield[0] =
|
||||
xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
|
||||
xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
|
||||
xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
|
||||
xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
|
||||
xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
|
||||
xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
|
||||
xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
|
||||
xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
|
||||
|
||||
Bfield[1] =
|
||||
yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
|
||||
yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
|
||||
yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
|
||||
yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
|
||||
yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
|
||||
yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
|
||||
yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
|
||||
yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
|
||||
|
||||
Bfield[2] =
|
||||
zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
|
||||
zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
|
||||
zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
|
||||
zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
|
||||
zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
|
||||
zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
|
||||
zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
|
||||
zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
|
||||
|
||||
} else {
|
||||
Bfield[0] = 0.0;
|
||||
Bfield[1] = 0.0;
|
||||
Bfield[2] = 0.0;
|
||||
}
|
||||
//In order to obtain the output file with the magnetic components read from a particle passing in the magnetic field
|
||||
/* std::ofstream MagneticField("MagneticField.out", std::ios::app);
|
||||
MagneticField<< Bfield[0] << '\t' << " "
|
||||
<< Bfield[1] << '\t' << " "
|
||||
<< Bfield[2] << '\t' << " "
|
||||
<< point[0] << '\t' << " "
|
||||
<< point[1] << '\t' << " "
|
||||
<< point[2] << '\t' << " "
|
||||
<< G4endl;*/
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -23,29 +23,17 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
// Institute in the framework of the MC-INFN Group
|
||||
//
|
||||
//
|
||||
// Hadrontherapy Users are recommended to use the prepared macro files in order to activate the
|
||||
// most appropriate physics for hadrontherapy applications.
|
||||
// As one can easily see the physics we suggest is contained in the
|
||||
// 'QGSP_BIC_EMY' list adding to the decay processes (activated as default).
|
||||
// ****** SUGGESTED PHYSICS FOR ACCURATE SIMULATIONS *********
|
||||
//
|
||||
//
|
||||
// ****** SUGGESTED PHYSICS *********
|
||||
//
|
||||
// AT MOMENT, IF ACCURATE RESULTS ARE NEEDED, WE STRONGLY RECOMMEND:
|
||||
// 1. The use of the macro 'hadron_therapy.mac', that is connected with the HadrontherapyPhysicsList.cc file.
|
||||
// 2. the QGSP_BIC_EMY Reference Physics Lists (define the PHYSLIST eviroment variable):
|
||||
// export PHYSLIST=QGSP_BIC_EMY
|
||||
// User must considered that, in this second case, radioactive processes are not activated
|
||||
|
||||
// At moment, if accurate simulations are necessary, we suggest the use of the
|
||||
// Physics Lists 'HADRONTHERAPY_1';
|
||||
// It can be activated inside any macro file using the command:
|
||||
// /Physics/addPhysics HADRONTHERAPY_1
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Region.hh"
|
||||
@@ -57,13 +45,14 @@
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
|
||||
// Local physic directly implemented in the Hadronthrapy directory
|
||||
#include "LocalIonIonInelasticPhysic.hh" // Physic dedicated to the ion-ion inelastic processes
|
||||
// Physic dedicated to the ion-ion inelastic processes
|
||||
//
|
||||
#include "LocalIonIonInelasticPhysic.hh"
|
||||
|
||||
// Physic lists (contained inside the Geant4 source code, in the 'physicslists folder')
|
||||
#include "G4HadronPhysicsQGSP_BIC_HP.hh"
|
||||
#include "G4HadronPhysicsQGSP_BIC.hh"
|
||||
#include "G4EmStandardPhysics_option3.hh"
|
||||
#include "G4EmLivermorePhysics.hh"
|
||||
#include "G4EmPenelopePhysics.hh"
|
||||
#include "G4EmStandardPhysics_option4.hh"
|
||||
#include "G4EmExtraPhysics.hh"
|
||||
#include "G4StoppingPhysics.hh"
|
||||
#include "G4DecayPhysics.hh"
|
||||
@@ -80,145 +69,217 @@
|
||||
#include "G4IonParametrisedLossModel.hh"
|
||||
#include "G4EmProcessOptions.hh"
|
||||
#include "G4ParallelWorldPhysics.hh"
|
||||
#include "G4EmLivermorePhysics.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyPhysicsList::HadrontherapyPhysicsList() : G4VModularPhysicsList()
|
||||
{
|
||||
G4LossTableManager::Instance();
|
||||
defaultCutValue = 1.*mm;
|
||||
cutForGamma = defaultCutValue;
|
||||
cutForElectron = defaultCutValue;
|
||||
cutForPositron = defaultCutValue;
|
||||
G4LossTableManager::Instance();
|
||||
defaultCutValue = 1.*mm;
|
||||
cutForGamma = defaultCutValue;
|
||||
cutForElectron = defaultCutValue;
|
||||
cutForPositron = defaultCutValue;
|
||||
|
||||
pMessenger = new HadrontherapyPhysicsListMessenger(this);
|
||||
|
||||
SetVerboseLevel(1);
|
||||
|
||||
helIsRegistered = false;
|
||||
bicIsRegistered = false;
|
||||
biciIsRegistered = false;
|
||||
locIonIonInelasticIsRegistered = false;
|
||||
radioactiveDecayIsRegistered = false;
|
||||
|
||||
stepMaxProcess = 0;
|
||||
|
||||
pMessenger = new HadrontherapyPhysicsListMessenger(this);
|
||||
|
||||
SetVerboseLevel(1);
|
||||
|
||||
// ****** Definition of some defaults for the physics *****
|
||||
// ****** in case no physics is called by the macro file *****
|
||||
// EM physics
|
||||
emPhysicsList = new G4EmStandardPhysics_option3(1);
|
||||
emName = G4String("emstandard_opt3");
|
||||
|
||||
// Decay physics and all particles
|
||||
decPhysicsList = new G4DecayPhysics();
|
||||
raddecayList = new G4RadioactiveDecayPhysics();
|
||||
|
||||
// ****** Definition of defaults for the physics processes *****
|
||||
// ****** in case no physics is called by the macro file *****
|
||||
//
|
||||
// The default physics corresponds to the actual QGSP_BIC_HP list
|
||||
// but with the following differences:
|
||||
// --> G4EmStandardPhysics_option4 for the electromagnetic processes
|
||||
// is used n place of the less accurate G4EmStandardPhysics
|
||||
// --> The G4RadioactiveDecayPhysics is add
|
||||
// --> G4HadronPhysicsQGSP_BIC is used in place of G4HadronPhysicsQGSP_BIC_HP
|
||||
// --> G4HadronElasticPhysics is used in place of G4HadronElasticPhysics_HP
|
||||
|
||||
// Elecromagnetic physics
|
||||
//
|
||||
emPhysicsList = new G4EmStandardPhysics_option4();
|
||||
emName = G4String("emstandard_opt4");
|
||||
|
||||
// Hadronic physics
|
||||
//
|
||||
hadronPhys.push_back( new G4DecayPhysics());
|
||||
hadronPhys.push_back( new G4RadioactiveDecayPhysics());
|
||||
hadronPhys.push_back( new G4IonBinaryCascadePhysics());
|
||||
hadronPhys.push_back( new G4EmExtraPhysics());
|
||||
hadronPhys.push_back( new G4HadronElasticPhysics());
|
||||
hadronPhys.push_back( new G4StoppingPhysics());
|
||||
hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC());
|
||||
|
||||
// Decay physics
|
||||
//
|
||||
decay_List = new G4DecayPhysics();
|
||||
radioactiveDecay_List = new G4RadioactiveDecayPhysics();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyPhysicsList::~HadrontherapyPhysicsList()
|
||||
{
|
||||
delete pMessenger;
|
||||
delete emPhysicsList;
|
||||
delete decPhysicsList;
|
||||
delete raddecayList;
|
||||
|
||||
for(size_t i=0; i<hadronPhys.size(); i++) {delete hadronPhys[i];}
|
||||
delete pMessenger;
|
||||
delete emPhysicsList;
|
||||
delete decay_List;
|
||||
delete radioactiveDecay_List;
|
||||
hadronPhys.clear();
|
||||
for(size_t i=0; i<hadronPhys.size(); i++)
|
||||
{
|
||||
delete hadronPhys[i];
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::ConstructParticle()
|
||||
{
|
||||
decPhysicsList->ConstructParticle();
|
||||
decay_List -> ConstructParticle();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::ConstructProcess()
|
||||
{
|
||||
// transportation
|
||||
AddTransportation();
|
||||
|
||||
// electromagnetic physics list
|
||||
emPhysicsList->ConstructProcess();
|
||||
em_config.AddModels();
|
||||
|
||||
// decay physics list
|
||||
decPhysicsList->ConstructProcess();
|
||||
raddecayList->ConstructProcess();
|
||||
|
||||
// hadronic physics lists
|
||||
for(size_t i=0; i<hadronPhys.size(); i++) {
|
||||
hadronPhys[i] -> ConstructProcess();
|
||||
}
|
||||
|
||||
// step limitation (as a full process)
|
||||
//
|
||||
AddStepMax();
|
||||
|
||||
//Parallel world sensitivity
|
||||
G4ParallelWorldPhysics* pWorld = new G4ParallelWorldPhysics("DetectorROGeometry");
|
||||
pWorld->ConstructProcess();
|
||||
|
||||
return;
|
||||
// Transportation
|
||||
//
|
||||
AddTransportation();
|
||||
|
||||
// Electromagnetic physics
|
||||
//
|
||||
emPhysicsList -> ConstructProcess();
|
||||
em_config.AddModels();
|
||||
|
||||
// Hadronic physics
|
||||
//
|
||||
for(size_t i=0; i < hadronPhys.size(); i++)
|
||||
{
|
||||
hadronPhys[i] -> ConstructProcess();
|
||||
}
|
||||
|
||||
// step limitation (as a full process)
|
||||
//
|
||||
AddStepMax();
|
||||
|
||||
//Parallel world sensitivity
|
||||
//
|
||||
G4ParallelWorldPhysics* pWorld = new G4ParallelWorldPhysics("DetectorROGeometry");
|
||||
pWorld->ConstructProcess();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::AddPhysicsList(const G4String& name)
|
||||
{
|
||||
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
|
||||
}
|
||||
if (name == emName) return;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ELECTROMAGNETIC MODELS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
if (name == "standard_opt3") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new G4EmStandardPhysics_option3();
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option3" << G4endl;
|
||||
|
||||
} else if (name == "LowE_Livermore") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new G4EmLivermorePhysics();
|
||||
G4RunManager::GetRunManager()-> PhysicsHasBeenModified();
|
||||
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmLivermorePhysics" << G4endl;
|
||||
|
||||
} else if (name == "LowE_Penelope") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new G4EmPenelopePhysics();
|
||||
G4RunManager::GetRunManager()-> PhysicsHasBeenModified();
|
||||
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmPenelopePhysics" << G4endl;
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
|
||||
}
|
||||
if (name == emName) return;
|
||||
|
||||
} else if (name == "local_ion_ion_inelastic") {
|
||||
hadronPhys.push_back(new LocalIonIonInelasticPhysic());
|
||||
locIonIonInelasticIsRegistered = true;
|
||||
|
||||
} else if (name == "QGSP_BIC_EMY") {
|
||||
AddPhysicsList("emstandard_opt3");
|
||||
hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC());
|
||||
hadronPhys.push_back( new G4EmExtraPhysics());
|
||||
hadronPhys.push_back( new G4HadronElasticPhysics());
|
||||
hadronPhys.push_back( new G4StoppingPhysics());
|
||||
hadronPhys.push_back( new G4IonBinaryCascadePhysics());
|
||||
hadronPhys.push_back( new G4NeutronTrackingCut());
|
||||
///////////////////////////////////
|
||||
// ELECTROMAGNETIC MODELS
|
||||
///////////////////////////////////
|
||||
if (name == "standard_opt4") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
hadronPhys.clear();
|
||||
emPhysicsList = new G4EmStandardPhysics_option4();
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option4" << G4endl;
|
||||
|
||||
// The following 'local_ion_ion_inelastic' is an example of implemenation of
|
||||
// inelastic hadronic models to be used when
|
||||
// mucleus-nulceus (ion-ion) interactions have to be
|
||||
// taken into account;
|
||||
// It must be used, of course, in connection with other lists: electromagnetic
|
||||
// plus hadronic elastic plus nucleon-nulcleon hadronic inelastic
|
||||
//
|
||||
// An example of coplete physics list using the 'local_ion_ion_inelastic' physics
|
||||
// is the one named HADRONTHERAPY_2, and defined below.
|
||||
//
|
||||
} else if (name == "standard_opt3") {
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
hadronPhys.clear();
|
||||
emPhysicsList = new G4EmStandardPhysics_option3();
|
||||
G4RunManager::GetRunManager() -> PhysicsHasBeenModified();
|
||||
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option3" << G4endl;
|
||||
} else if (name == "local_ion_ion_inelastic") {
|
||||
hadronPhys.push_back(new LocalIonIonInelasticPhysic());
|
||||
locIonIonInelasticIsRegistered = true;
|
||||
|
||||
} else if (name == "HADRONTHERAPY_1") {
|
||||
|
||||
// The HADRONTHERAPY_1 physics list corresponds to the actual QGSP_BIC_HP list
|
||||
// but with the following differences:
|
||||
// --> G4EmStandardPhysics_option4 for the electromagnetic processes
|
||||
// is used in place of the less accurate G4EmStandardPhysics
|
||||
// --> The G4RadioactiveDecayPhysics is added
|
||||
|
||||
AddPhysicsList("standard_opt4");
|
||||
hadronPhys.push_back( new G4DecayPhysics());
|
||||
hadronPhys.push_back( new G4RadioactiveDecayPhysics());
|
||||
hadronPhys.push_back( new G4IonBinaryCascadePhysics());
|
||||
hadronPhys.push_back( new G4EmExtraPhysics());
|
||||
hadronPhys.push_back( new G4HadronElasticPhysicsHP());
|
||||
hadronPhys.push_back( new G4StoppingPhysics());
|
||||
hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC_HP());
|
||||
|
||||
G4cout << "HADRONTHERAPY_1 PHYSICS LIST has been activated" << G4endl;
|
||||
|
||||
|
||||
} else if (name == "HADRONTHERAPY_2") {
|
||||
|
||||
// The HADRONTHERAPY_2 physics list corresponds to the actual QGSP_BIC_HP list
|
||||
// but with the following differences:
|
||||
// --> G4EmStandardPhysics_option4 for the electromagnetic processes
|
||||
// is used in place of the less accurate G4EmStandardPhysics
|
||||
// --> The G4RadioactiveDecayPhysics is added
|
||||
// --> The 'local_ion_ion_inelastic' physics is used in place of the
|
||||
// G4IonBinaryCascadePhysics(): it used the QMD model to treat
|
||||
// the ion-ion inelastic interactions
|
||||
|
||||
AddPhysicsList("standard_opt4");
|
||||
AddPhysicsList("local_ion_ion_inelastic");
|
||||
hadronPhys.push_back( new G4DecayPhysics());
|
||||
hadronPhys.push_back( new G4RadioactiveDecayPhysics());
|
||||
hadronPhys.push_back( new G4EmExtraPhysics());
|
||||
hadronPhys.push_back( new G4HadronElasticPhysicsHP());
|
||||
hadronPhys.push_back( new G4StoppingPhysics());
|
||||
hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC_HP());
|
||||
|
||||
G4cout << "HADRONTHERAPY_2 PHYSICS LIST has been acivated" << G4endl;
|
||||
|
||||
}
|
||||
else if (name == "QGSP_BIC_EMY") {
|
||||
AddPhysicsList("standard_opt3");
|
||||
//emPhysicsList = new G4EmLivermorePhysics();
|
||||
hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC());
|
||||
hadronPhys.push_back( new G4EmExtraPhysics());
|
||||
hadronPhys.push_back( new G4HadronElasticPhysics());
|
||||
hadronPhys.push_back( new G4StoppingPhysics());
|
||||
hadronPhys.push_back( new G4IonBinaryCascadePhysics());
|
||||
hadronPhys.push_back( new G4NeutronTrackingCut());
|
||||
hadronPhys.push_back( new G4DecayPhysics());
|
||||
}
|
||||
else {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
|
||||
<< " is not defined"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
} else {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
|
||||
<< " is not defined"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::AddStepMax()
|
||||
{
|
||||
// Step limitation seen as a process
|
||||
stepMaxProcess = new HadrontherapyStepMax();
|
||||
|
||||
// This process must exist in all threads.
|
||||
//
|
||||
HadrontherapyStepMax* stepMaxProcess = new HadrontherapyStepMax();
|
||||
G4AutoDelete::Register( stepMaxProcess );
|
||||
|
||||
theParticleIterator->reset();
|
||||
while ((*theParticleIterator)()){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
@@ -235,52 +296,29 @@ void HadrontherapyPhysicsList::AddStepMax()
|
||||
void HadrontherapyPhysicsList::SetCuts()
|
||||
{
|
||||
|
||||
if (verboseLevel >0){
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
|
||||
}
|
||||
|
||||
// set cut values for gamma at first and for e- second and next for e+,
|
||||
// because some processes for e+/e- need cut values for gamma
|
||||
if (verboseLevel >0){
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
|
||||
}
|
||||
|
||||
// Production thresholds for detector regions
|
||||
// The G4Regions, for which you want define a given cut via de macro command
|
||||
// '/run/setCutForRegion <G4Region name> <cut value>'
|
||||
// must be defined here
|
||||
//
|
||||
SetCutValue(cutForGamma, "gamma");
|
||||
SetCutValue(cutForElectron, "e-");
|
||||
SetCutValue(cutForPositron, "e+");
|
||||
|
||||
// Set cuts for detector
|
||||
SetDetectorCut(defaultCutValue);
|
||||
if (verboseLevel>0) DumpCutValuesTable();
|
||||
// At moment, only 'DetectorLog' is defined as G4Region
|
||||
//
|
||||
G4String regName[] = {"DetectorLog"};
|
||||
G4double fuc = 1.;
|
||||
for(G4int i=0;i<1;i++)
|
||||
{
|
||||
G4Region* reg = G4RegionStore::GetInstance()->GetRegion(regName[i]);
|
||||
G4ProductionCuts* cuts = new G4ProductionCuts;
|
||||
cuts->SetProductionCut(defaultCutValue*fuc);
|
||||
reg->SetProductionCuts(cuts);
|
||||
fuc *= 10.;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::SetCutForGamma(G4double cut)
|
||||
{
|
||||
cutForGamma = cut;
|
||||
SetParticleCuts(cutForGamma, G4Gamma::Gamma());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::SetCutForElectron(G4double cut)
|
||||
{
|
||||
cutForElectron = cut;
|
||||
SetParticleCuts(cutForElectron, G4Electron::Electron());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsList::SetCutForPositron(G4double cut)
|
||||
{
|
||||
cutForPositron = cut;
|
||||
SetParticleCuts(cutForPositron, G4Positron::Positron());
|
||||
}
|
||||
|
||||
void HadrontherapyPhysicsList::SetDetectorCut(G4double cut)
|
||||
{
|
||||
G4String regionName = "DetectorLog";
|
||||
G4Region* region = G4RegionStore::GetInstance()->GetRegion(regionName);
|
||||
|
||||
G4ProductionCuts* cuts = new G4ProductionCuts ;
|
||||
cuts -> SetProductionCut(cut,G4ProductionCuts::GetIndex("gamma"));
|
||||
cuts -> SetProductionCut(cut,G4ProductionCuts::GetIndex("e-"));
|
||||
cuts -> SetProductionCut(cut,G4ProductionCuts::GetIndex("e+"));
|
||||
region -> SetProductionCuts(cuts);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
@@ -33,7 +29,6 @@
|
||||
//
|
||||
|
||||
#include "HadrontherapyPhysicsListMessenger.hh"
|
||||
|
||||
#include "HadrontherapyPhysicsList.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
@@ -45,85 +40,24 @@ HadrontherapyPhysicsListMessenger::HadrontherapyPhysicsListMessenger(Hadronthera
|
||||
{
|
||||
physDir = new G4UIdirectory("/Physics/");
|
||||
physDir->SetGuidance("Commands to activate physics models and set cuts");
|
||||
|
||||
gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/Physics/setGCut",this);
|
||||
gammaCutCmd->SetGuidance("Set gamma cut.");
|
||||
gammaCutCmd->SetParameterName("Gcut",false);
|
||||
gammaCutCmd->SetUnitCategory("Length");
|
||||
gammaCutCmd->SetRange("Gcut>0.0");
|
||||
gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
electCutCmd = new G4UIcmdWithADoubleAndUnit("/Physics/setECut",this);
|
||||
electCutCmd->SetGuidance("Set electron cut.");
|
||||
electCutCmd->SetParameterName("Ecut",false);
|
||||
electCutCmd->SetUnitCategory("Length");
|
||||
electCutCmd->SetRange("Ecut>0.0");
|
||||
electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
protoCutCmd = new G4UIcmdWithADoubleAndUnit("/Physics/setPCut",this);
|
||||
protoCutCmd->SetGuidance("Set positron cut.");
|
||||
protoCutCmd->SetParameterName("Pcut",false);
|
||||
protoCutCmd->SetUnitCategory("Length");
|
||||
protoCutCmd->SetRange("Pcut>0.0");
|
||||
protoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
allCutCmd = new G4UIcmdWithADoubleAndUnit("/Physics/setCuts",this);
|
||||
allCutCmd->SetGuidance("Set cut for all.");
|
||||
allCutCmd->SetParameterName("cut",false);
|
||||
allCutCmd->SetUnitCategory("Length");
|
||||
allCutCmd->SetRange("cut>0.0");
|
||||
allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
allDetectorCmd = new G4UIcmdWithADoubleAndUnit("/Physics/setDetectorCuts",this);
|
||||
allDetectorCmd->SetGuidance("Set cut for all. into Detector");
|
||||
allDetectorCmd->SetParameterName("cut",false);
|
||||
allDetectorCmd->SetUnitCategory("Length");
|
||||
allDetectorCmd->SetRange("cut>0.0");
|
||||
allDetectorCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
pListCmd = new G4UIcmdWithAString("/Physics/addPhysics",this);
|
||||
pListCmd->SetGuidance("Add physics list.");
|
||||
pListCmd->SetParameterName("PList",false);
|
||||
pListCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
pListCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
HadrontherapyPhysicsListMessenger::~HadrontherapyPhysicsListMessenger()
|
||||
{
|
||||
delete gammaCutCmd;
|
||||
delete electCutCmd;
|
||||
delete protoCutCmd;
|
||||
delete allCutCmd;
|
||||
delete allDetectorCmd;
|
||||
delete pListCmd;
|
||||
delete physDir;
|
||||
delete physDir;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapyPhysicsListMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
{
|
||||
if( command == gammaCutCmd )
|
||||
{ pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
else if( command == electCutCmd )
|
||||
{ pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
else if( command == protoCutCmd )
|
||||
{ pPhysicsList->SetCutForPositron(protoCutCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
else if( command == allCutCmd )
|
||||
{
|
||||
G4double cut = allCutCmd->GetNewDoubleValue(newValue);
|
||||
pPhysicsList->SetCutForGamma(cut);
|
||||
pPhysicsList->SetCutForElectron(cut);
|
||||
pPhysicsList->SetCutForPositron(cut);
|
||||
}
|
||||
else if( command == allDetectorCmd)
|
||||
{
|
||||
G4double cut = allDetectorCmd -> GetNewDoubleValue(newValue);
|
||||
pPhysicsList -> SetDetectorCut(cut);
|
||||
}
|
||||
else if( command == pListCmd )
|
||||
{
|
||||
if( command == pListCmd )
|
||||
{ pPhysicsList->AddPhysicsList(newValue);}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
@@ -63,10 +59,9 @@ G4double HadrontherapyStepMax::PostStepGetPhysicalInteractionLength(const G4Trac
|
||||
*condition = NotForced;
|
||||
|
||||
G4double ProposedStep = DBL_MAX;
|
||||
if((MaxChargedStep > 0.) &&
|
||||
(aTrack.GetVolume() != 0) && ((aTrack.GetVolume()->GetName() == "DetectorPhys")||(aTrack.GetVolume()->GetName() == "InternalChamber")||(aTrack.GetVolume()->GetName() == "CollimatorHole")||(aTrack.GetVolume()->GetName() == "PhysFourthTQuad")||(aTrack.GetVolume()->GetName() == "PhysThirdTQuad")||(aTrack.GetVolume()->GetName() == "PhysSecondTQuad")||(aTrack.GetVolume()->GetName() == "PhysFirstTQuad")||(aTrack.GetVolume()->GetName() =="physQuadChamber")||(aTrack.GetVolume()->GetName() =="PVirtualMag")||(aTrack.GetVolume()->GetName() =="PhysicCup")))
|
||||
|
||||
if((MaxChargedStep > 0.) &&
|
||||
(aTrack.GetVolume() != 0) &&
|
||||
(aTrack.GetVolume()->GetName() == "DetectorPhys"))
|
||||
ProposedStep = MaxChargedStep;
|
||||
|
||||
return ProposedStep;
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
@@ -64,7 +60,53 @@ HadrontherapySteppingAction::~HadrontherapySteppingAction()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void HadrontherapySteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
{
|
||||
G4StepPoint* PreStep = aStep->GetPreStepPoint();
|
||||
G4StepPoint* PostStep = aStep->GetPostStepPoint();
|
||||
|
||||
G4double PreStepX =PreStep->GetPosition().x();
|
||||
G4double PreStepY =PreStep->GetPosition().y();
|
||||
G4double PreStepZ =PreStep->GetPosition().z();
|
||||
G4double parentID =aStep->GetTrack()->GetParentID();
|
||||
G4double trackID =aStep->GetTrack()->GetTrackID();
|
||||
|
||||
G4double PostStepX =PostStep->GetPosition().x();
|
||||
G4double PostStepY =PostStep->GetPosition().y();
|
||||
G4double PostStepZ =PostStep->GetPosition().z();
|
||||
|
||||
// positions in the global coordinate system:
|
||||
//G4ThreeVector posPreStep = PreStep->GetPosition();
|
||||
// G4ThreeVector posPostStep = PostStep->GetPosition();
|
||||
|
||||
G4TouchableHandle touchPreStep = PreStep->GetTouchableHandle();
|
||||
G4TouchableHandle touchPostStep = PostStep->GetTouchableHandle();
|
||||
//To get the current volume:
|
||||
G4VPhysicalVolume* volumePre = touchPreStep->GetVolume();
|
||||
G4VPhysicalVolume* volumePost =touchPostStep->GetVolume();
|
||||
|
||||
//To get its name:
|
||||
G4String namePre = volumePre->GetName();
|
||||
G4String namePost;
|
||||
|
||||
if(volumePost){
|
||||
namePost = volumePost->GetName();
|
||||
}
|
||||
|
||||
|
||||
G4int eventNum = G4RunManager::GetRunManager() -> GetCurrentEvent() -> GetEventID();
|
||||
G4double eKin = aStep -> GetPreStepPoint() -> GetKineticEnergy();
|
||||
G4double PosX = aStep->GetTrack()->GetPosition().x();
|
||||
G4double PosY = aStep->GetTrack()->GetPosition().y();
|
||||
G4double PosZ = aStep->GetTrack()->GetPosition().z();
|
||||
G4String material= aStep -> GetTrack() -> GetMaterial() -> GetName();
|
||||
G4String volume= aStep->GetTrack()->GetVolume()->GetName();
|
||||
G4Track* theTrack = aStep->GetTrack();
|
||||
|
||||
if((namePre== "collimator")||(namePre== "PhysicExternalMagnet_1Down")||(namePre== "PhysicExternalMagnet_1")||(namePre== "PhysicMagnet_1Right")||(namePre== "PhysicMagnet_1Left")||(namePre== "PhysicExternalMagnet_2")||(namePre== "PhysicExternalMagnet_2Down")||(namePre== "PhysicMagnet_2Right")||(namePre== "PhysicMagnet_2Left")||(namePre== "PhysicExternalMagnet_3")||(namePre== "PhysicExternalMagnet_3Down")||(namePre== "PhysicMagnet_3Right")||(namePre== "PhysicMagnet_3Left")||(namePre== "PhysicExternalMagnet_4")||(namePre== "PhysicExternalMagnet_4Down")||(namePre=="physQuadChamberWall")||(namePre== "PhysicMagnet_4Right")||(namePre== "PhysicMagnet_4Left")||(namePre=="ExternalChamber")||(namePre=="collimatorFinal")||(namePre=="ExternalSlit")||(namePre=="PhysFourthQuad")||(namePre=="PhysThirdQuad")||(namePre=="PhysSecondQuad")||(namePre=="PhysFirstQuad"))
|
||||
{
|
||||
theTrack -> SetTrackStatus(fKillTrackAndSecondaries);
|
||||
}
|
||||
|
||||
// G4TransportationManager* tManager = G4TransportationManager::GetTransportationManager();
|
||||
//G4VPhysicalVolume* pW = tManager->GetParallelWorld ("DetectorROGeometry");
|
||||
|
||||
@@ -78,20 +120,452 @@ void HadrontherapySteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
// G4cout << "Sensitive Detector: " << currentVol->GetLogicalVolume()->GetSensitiveDetector()->GetName() << G4endl;
|
||||
|
||||
|
||||
/*
|
||||
// USEFULL METHODS TO RETRIEVE INFORMATION DURING THE STEPS
|
||||
if( (aStep->GetTLocateGlobalPointAndSeturack()->GetVolume()->GetName() == "DetectorPhys")
|
||||
&& aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton")
|
||||
//G4int evtNb = G4RunManager::GetRunManager()->GetCurrentEvent() -> GetEventID();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// A METHOD TO RETRIEVE INFORMATIONS ABOUT SECONDARY ELECTRONS IN DIFFERENT POINTS OF FARADAY CUP ////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
//if( (aStep->GetTLocateGlobalPointAndSeturack()->GetVolume()->GetName() == "PVirtualMag")
|
||||
if((aStep->GetTrack()->GetVolume()->GetName()=="PVirtualMag") && aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-")
|
||||
{
|
||||
G4cout << "ENERGIA: " << aStep->GetTrack()->GetKineticEnergy()
|
||||
std::ofstream WriteDataIn("new200.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PosX << '\t' << " "
|
||||
<< PosY << '\t' << " "
|
||||
<< PosZ << '\t' << " "
|
||||
//<< material << '\t' << " "
|
||||
// << volume << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// USEFULL METHODS TO RETRIEVE INFORMATION DURING THE STEPS
|
||||
|
||||
/* G4cout << "ENERGIA: " << aStep->GetTrack()->GetKineticEnergy()
|
||||
<< " VOLUME " << aStep->GetTrack()->GetVolume()->GetName()
|
||||
<< " MATERIALE " << aStep -> GetTrack() -> GetMaterial() -> GetName()
|
||||
<< " EVENTO " << G4RunManager::GetRunManager()->GetCurrentEvent() -> GetEventID()
|
||||
<< " POS " << aStep->GetTrack()->GetPosition().x()
|
||||
<< G4endl;
|
||||
}
|
||||
*/
|
||||
<< G4endl;*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ((namePre=="PhysicEntranceWindow") &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-") && (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
std::ofstream WriteDataIn("finestra.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
//theTrack -> SetTrackStatus(fKillTrackAndSecondaries);
|
||||
|
||||
}
|
||||
|
||||
if ((namePre=="PhysicCup") && (aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-") && (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
|
||||
std::ofstream WriteDataBack("fondo.out", std::ios::app);
|
||||
WriteDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
|
||||
//theTrack -> SetTrackStatus(fKillTrackAndSecondaries);
|
||||
}
|
||||
|
||||
//////////////////////////////////// VIRTUAL WINDOW //////////////////////////////////////////////////
|
||||
|
||||
if (((namePost=="PhysicVirtualWindow") && (namePre!="PhysicVirtualWindow")) &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-") && (PreStep->GetStepStatus() == fGeomBoundary)) //To check that the particle has just entered in the current volume (i.e. it is at the first step in the volume; the preStepPoint is at the boundary):
|
||||
{ //(namePost=="VirtualWindow") &&
|
||||
|
||||
if ((PostStepX - PreStepX)>0)
|
||||
{
|
||||
|
||||
//To check that the particle is leaving the current volume (i.e. it is at the last step in the volume; the postStepPoint is at the boundary):
|
||||
// if (PostStep->GetStepStatus() == fGeomBoundary)
|
||||
|
||||
|
||||
|
||||
|
||||
std::ofstream WriteDataIn("DatiFCWindowIn.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
//<< direction.x() << '\t' << " "
|
||||
//<< direction.y() << '\t' << " "
|
||||
//<< direction.z() << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
else //if ((PostStepX - PreStepX)<0)
|
||||
{
|
||||
|
||||
//G4cout<<"ecco il nome del volume nella condizione Out "<< namePre<<" "<<namePost<<G4endl;
|
||||
|
||||
std::ofstream WriteDataBack("DatiFCWindowBack.out", std::ios::app);
|
||||
WriteDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////// proton in window //////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
if ((namePost=="SpectrumPVolume") && (namePre!="SpectrumPVolume") &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton"))//&& (PreStep->GetStepStatus() == fGeomBoundary)To check that the particle has just entered in the current volume (i.e. it is at the first step in the volume; the preStepPoint is at the boundary):
|
||||
{ //(namePost=="VirtualVolumeWindow") &&
|
||||
|
||||
|
||||
|
||||
//To check that the particle is leaving the current volume (i.e. it is at the last step in the volume; the postStepPoint is at the boundary):
|
||||
// if (PostStep->GetStepStatus() == fGeomBoundary)
|
||||
|
||||
|
||||
*/
|
||||
/*
|
||||
|
||||
std::ofstream WriteDataP("DatiFCWindowProton.out", std::ios::app);
|
||||
WriteDataP << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
if (((namePost=="PhysicVirtualWindow") && (namePre!="PhysicVirtualWindow")) &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton"))//&& (PreStep->GetStepStatus() == fGeomBoundary)) //To check that the particle has just entered in the current volume (i.e. it is at the first step in the volume; the preStepPoint is at the boundary):
|
||||
{ //(namePost=="VirtualVolumeWindow") &&
|
||||
|
||||
|
||||
|
||||
//To check that the particle is leaving the current volume (i.e. it is at the last step in the volume; the postStepPoint is at the boundary):
|
||||
// if (PostStep->GetStepStatus() == fGeomBoundary)
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
std::ofstream WriteData("DatiFCAfterWindowProton.out", std::ios::app);
|
||||
WriteData << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////// GUARD RING ///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
if ((namePre=="PhysicGuardRing") &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-")&& (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
|
||||
if ((PostStepX - PreStepX)>0)
|
||||
{
|
||||
|
||||
|
||||
std::ofstream WriteDataIn("DatiFCGuardRingIn.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
std::ofstream WriteDataBack("DatiFCGuardRingBack.out", std::ios::app);
|
||||
WriteDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////// VIRTUAL MIDDLE ///////////////////////////////////////////////////////////////
|
||||
|
||||
if (((namePost=="PhysicVirtualMiddle") && (namePre!="PhysicVirtualMiddle")) &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-") && (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
|
||||
if ((PostStepX - PreStepX)>0)
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
|
||||
std::ofstream WriteMDataIn("DatiFCMiddleIn.out", std::ios::app);
|
||||
WriteMDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
std::ofstream WriteMDataBack("DatiFCMiddleBack.out", std::ios::app);
|
||||
WriteMDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////// VIRTUAL BOTTOM ///////////////////////////////////////////////////////////////
|
||||
|
||||
if (((namePost=="PhysicVirtualBottom") && (namePre!="PhysicVirtualBottom")) &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-")&& (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
|
||||
if ((PostStepX - PreStepX)>0)
|
||||
{
|
||||
|
||||
std::ofstream WriteDataIn("DatiFCBottomIn.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//G4cout<<"ecco il nome del volume nella condizione Back "<< namePre<<" "<<namePost<<G4endl;
|
||||
|
||||
std::ofstream WriteDataBack("DatiFCBottomBack.out", std::ios::app);
|
||||
WriteDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
//<< direction.x() << '\t' << " "
|
||||
//<< direction.y() << '\t' << " "
|
||||
//<< direction.z() << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////// Dose Calculation ///////////////////////////////////////////////////////////////
|
||||
|
||||
//namePre!=("Cup")
|
||||
if (((namePost=="PhysicCup") && (namePre!="PhysicCup")) &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton") && (PreStep->GetStepStatus() == fGeomBoundary)) //|| (namePre=="Cup") && )
|
||||
{
|
||||
|
||||
std::ofstream Carica("CaricaRaccolta.out", std::ios::app);
|
||||
Carica << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//namePre!=("PhysicFaradayCupBottom")
|
||||
if (((namePost=="PhysicFaradayCupBottom") && (namePre!="PhysicFaradayCupBottom"))&&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "proton") && (PreStep->GetStepStatus() == fGeomBoundary)) // || (namePre=="cup") && )
|
||||
{
|
||||
|
||||
std::ofstream CaricaLatFC("CaricaRaccoltaLatFC.out", std::ios::app);
|
||||
CaricaLatFC << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (((namePre=="PhysicFaradayCupBottom") || (namePre=="PhysicCup")) && ((aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-") && (PreStep->GetStepStatus() == fGeomBoundary)))
|
||||
{
|
||||
|
||||
if ((PostStepX - PreStepX)>0)
|
||||
{
|
||||
|
||||
std::ofstream WriteDataIn("DatiFCConeBottomCupIn.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//G4cout<<"ecco il nome del volume nella condizione Back "<< namePre<<" "<<namePost<<G4endl;
|
||||
|
||||
std::ofstream WriteDataBack("DatiFCConeBottomCupBack.out", std::ios::app);
|
||||
WriteDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////// VIRTUAL OVER BOTTOM ///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
if ((namePre=="PhysicVirtualOverBottom") &&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-")&& (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
|
||||
if ((PostStepX - PreStepX)>0)
|
||||
{
|
||||
|
||||
|
||||
//
|
||||
|
||||
std::ofstream WriteDataIn("DatiFCOverBottomIn.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//G4cout<<"ecco il nome del volume nella condizione Back "<< namePre<<" "<<namePost<<G4endl;
|
||||
|
||||
std::ofstream WriteDataBack("DatiFCOverBottomBack.out", std::ios::app);
|
||||
WriteDataBack << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PreStepX << '\t' << " "
|
||||
<< PreStepY << '\t' << " "
|
||||
<< PreStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////// VIRTUAL LATERAL ///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
if (((namePost=="PhysicVirtualLateral") && (namePre!="PhysicVirtualLateral"))&&
|
||||
(aStep->GetTrack()->GetDefinition()->GetParticleName() == "e-") && (PreStep->GetStepStatus() == fGeomBoundary))
|
||||
{
|
||||
|
||||
|
||||
std::ofstream WriteDataIn("DatiFCLateral.out", std::ios::app);
|
||||
WriteDataIn << eKin << '\t' << " "
|
||||
<< eventNum << '\t' << " "
|
||||
<< PostStepX << '\t' << " "
|
||||
<< PostStepY << '\t' << " "
|
||||
<< PostStepZ << '\t' << " "
|
||||
<< parentID << '\t' << " "
|
||||
<< trackID << '\t' << " "
|
||||
<< G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( aStep->GetTrack()->GetVolume()->GetName() == "NewDetectorPhys"){
|
||||
#ifdef G4ANALYSIS_USE_ROOT
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
// Institute in the framework of the MC-INFN Group
|
||||
//
|
||||
|
||||
#include "LaserDrivenBeamLineMessenger.hh"
|
||||
#include "LaserDrivenBeamLine.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
LaserDrivenBeamLineMessenger::LaserDrivenBeamLineMessenger(LaserDrivenBeamLine* laserDriven)
|
||||
:laserDrivenMessengerPointer(laserDriven)
|
||||
{
|
||||
// Messenger directories for the Energy Selector module
|
||||
laserDrivenDir = new G4UIdirectory("/LaserDriven/");
|
||||
laserDrivenDir -> SetGuidance("The Laser Driven Beam Line module of Hadrontherapy");
|
||||
|
||||
// Messenger directories for the Energy Selector module
|
||||
energySelectorDir = new G4UIdirectory("/LaserDriven/EnergySelector/");
|
||||
energySelectorDir -> SetGuidance("The Energy selector (ESS) module of Hadrontherapy");
|
||||
|
||||
FcollimatorDir = new G4UIdirectory("/LaserDriven/EnergySelector/FirstCollimator/");
|
||||
FcollimatorDir -> SetGuidance("Define geometrical characteristics of the ESS first collimator");
|
||||
|
||||
ScollimatorDir = new G4UIdirectory("/LaserDriven/EnergySelector/SecondCollimator/");
|
||||
ScollimatorDir -> SetGuidance("Define geometrical characteristics of the ESS second collimator");
|
||||
|
||||
slitDir = new G4UIdirectory("/LaserDriven/EnergySelector/Slit/");
|
||||
slitDir -> SetGuidance("Define geometrical characteristics of the ESS slit");
|
||||
|
||||
// Messenger directories for the Quadrupole module
|
||||
quadrupoleDir = new G4UIdirectory("/LaserDriven/Quadrupoles/");
|
||||
quadrupoleDir -> SetGuidance("The Quadrupoles module of Hadrontherapy");
|
||||
|
||||
relativePosDir = new G4UIdirectory("/LaserDriven/Quadrupoles/xRelPosition/");
|
||||
relativePosDir -> SetGuidance("Define the x relative positions of the quadrupoles");
|
||||
|
||||
// ESS DISABLE
|
||||
DisableESSCmd = new G4UIcmdWithoutParameter("/LaserDriven/EnergySelector/Disable", this);
|
||||
DisableESSCmd -> SetGuidance("Disable the Energy Selector.");
|
||||
DisableESSCmd -> SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
DisableESSCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// THE FIRST ESS COLLIMATOR
|
||||
//
|
||||
// Diameter of the first collimator
|
||||
FcollimatorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/Radius", this);
|
||||
FcollimatorRadiusCmd -> SetGuidance("Set the Radius of the first collimator");
|
||||
FcollimatorRadiusCmd -> SetParameterName("Size",false);
|
||||
FcollimatorRadiusCmd -> SetDefaultUnit("mm");
|
||||
FcollimatorRadiusCmd -> SetUnitCandidates("mm cm m");
|
||||
FcollimatorRadiusCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Thickness of the first collimator
|
||||
FcollimatorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/Thickness", this);
|
||||
FcollimatorThicknessCmd -> SetGuidance("Set the thickness of the first collimator");
|
||||
FcollimatorThicknessCmd -> SetParameterName("Size",false);
|
||||
FcollimatorThicknessCmd -> SetDefaultUnit("mm");
|
||||
FcollimatorThicknessCmd -> SetUnitCandidates("mm cm m");
|
||||
FcollimatorThicknessCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Z Position of the first collimator hole
|
||||
FcollimatorZpositionCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/zPosizion", this);
|
||||
FcollimatorZpositionCmd -> SetGuidance("Set the Z position of the first collimator hole as respect the internal vacuum chamber center axis");
|
||||
FcollimatorZpositionCmd -> SetParameterName("Size",false);
|
||||
FcollimatorZpositionCmd -> SetDefaultUnit("mm");
|
||||
FcollimatorZpositionCmd -> SetUnitCandidates("mm cm m");
|
||||
FcollimatorZpositionCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// THE SECOND ESS COLLIMATOR
|
||||
//
|
||||
// Diameter of the second collimator
|
||||
ScollimatorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/Radius", this);
|
||||
ScollimatorRadiusCmd -> SetGuidance("Set the Radius of the second collimator");
|
||||
ScollimatorRadiusCmd -> SetParameterName("Size",false);
|
||||
ScollimatorRadiusCmd -> SetDefaultUnit("mm");
|
||||
ScollimatorRadiusCmd -> SetUnitCandidates("mm cm m");
|
||||
ScollimatorRadiusCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Thickness of the second collimator
|
||||
ScollimatorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/Thickness", this);
|
||||
ScollimatorThicknessCmd -> SetGuidance("Set the thickness of the second collimator");
|
||||
ScollimatorThicknessCmd -> SetParameterName("Size",false);
|
||||
ScollimatorThicknessCmd -> SetDefaultUnit("mm");
|
||||
ScollimatorThicknessCmd -> SetUnitCandidates("mm cm m");
|
||||
ScollimatorThicknessCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Z Position of the second collimator hole
|
||||
ScollimatorZpositionCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/zPosizion", this);
|
||||
ScollimatorZpositionCmd -> SetGuidance("Set the Z position of the second collimator hole as respect the internal vacuum chamber center axis");
|
||||
ScollimatorZpositionCmd -> SetParameterName("Size",false);
|
||||
ScollimatorZpositionCmd -> SetDefaultUnit("mm");
|
||||
ScollimatorZpositionCmd -> SetUnitCandidates("mm cm m");
|
||||
ScollimatorZpositionCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// THE SLIT
|
||||
//
|
||||
// Thickness Slit
|
||||
SlitThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/thickness",this);
|
||||
SlitThicknessCmd -> SetGuidance("Set the X dimension of the Slit, the maximum value is 10 mm");
|
||||
SlitThicknessCmd -> SetParameterName("Size",false);
|
||||
SlitThicknessCmd -> SetDefaultUnit("mm");
|
||||
SlitThicknessCmd -> SetUnitCandidates("mm cm m");
|
||||
SlitThicknessCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
//Hole dimension of the Slit (in Y direction)
|
||||
holeSlitDimensionYCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HoleDimensionY",this);
|
||||
holeSlitDimensionYCmd -> SetGuidance("Set the Y dimension of the Slit Hole");
|
||||
holeSlitDimensionYCmd -> SetParameterName("Size",false);
|
||||
holeSlitDimensionYCmd -> SetDefaultUnit("mm");
|
||||
holeSlitDimensionYCmd -> SetUnitCandidates("mm cm m");
|
||||
holeSlitDimensionYCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Hole dimension of the Slit (in Z direction)
|
||||
holeSlitDimensionZCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HoleDimensionZ",this);
|
||||
holeSlitDimensionZCmd -> SetGuidance("Set the Z dimension of the external part of magnet 4");
|
||||
holeSlitDimensionZCmd -> SetParameterName("Size",false);
|
||||
holeSlitDimensionZCmd -> SetDefaultUnit("mm");
|
||||
holeSlitDimensionZCmd -> SetUnitCandidates("mm cm m");
|
||||
holeSlitDimensionZCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Hole position of the Slit (in Z direction as respect the Slit body)
|
||||
slitHolePositionZCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HolePositionZ", this);
|
||||
slitHolePositionZCmd -> SetGuidance("Set the Slit hole position in the Z direction as respect the Slit body center");
|
||||
slitHolePositionZCmd -> SetParameterName("Size",false);
|
||||
slitHolePositionZCmd -> SetDefaultUnit("mm");
|
||||
slitHolePositionZCmd -> SetUnitCandidates("mm cm m");
|
||||
slitHolePositionZCmd -> AvailableForStates(G4State_Idle);
|
||||
|
||||
// Quadrupole system DISABLE
|
||||
DisableQuadsCmd = new G4UIcmdWithoutParameter("/LaserDriven/Quadrupoles/DisableQuads", this);
|
||||
DisableQuadsCmd -> SetGuidance("Disable the Quadrupole system.");
|
||||
DisableQuadsCmd -> SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
DisableQuadsCmd -> AvailableForStates(G4State_Idle);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
LaserDrivenBeamLineMessenger::~LaserDrivenBeamLineMessenger()
|
||||
{
|
||||
|
||||
delete laserDrivenDir;
|
||||
delete energySelectorDir;
|
||||
delete FcollimatorDir;
|
||||
delete ScollimatorDir;
|
||||
delete slitDir;
|
||||
delete quadrupoleDir;
|
||||
delete relativePosDir;
|
||||
delete DisableESSCmd;
|
||||
delete FcollimatorRadiusCmd;
|
||||
delete FcollimatorThicknessCmd;
|
||||
delete FcollimatorZpositionCmd;
|
||||
delete ScollimatorRadiusCmd;
|
||||
delete ScollimatorThicknessCmd;
|
||||
delete ScollimatorZpositionCmd;
|
||||
|
||||
delete SlitThicknessCmd;
|
||||
delete holeSlitDimensionYCmd;
|
||||
delete holeSlitDimensionZCmd;
|
||||
delete slitHolePositionZCmd;
|
||||
|
||||
delete DisableQuadsCmd;
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void LaserDrivenBeamLineMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if (command == DisableESSCmd)
|
||||
{
|
||||
laserDrivenMessengerPointer -> RemoveESS();
|
||||
}
|
||||
if( command == FcollimatorRadiusCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetFirstCollimatorRadius
|
||||
(FcollimatorRadiusCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == FcollimatorThicknessCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetFirstCollimatorThickness
|
||||
(FcollimatorThicknessCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == FcollimatorZpositionCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetFirstCollimatorPositionZ
|
||||
(FcollimatorZpositionCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == ScollimatorRadiusCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetSecondCollimatorRadius
|
||||
(ScollimatorRadiusCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == ScollimatorThicknessCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetSecondCollimatorThickness
|
||||
(ScollimatorThicknessCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == ScollimatorZpositionCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetSecondCollimatorPositionZ
|
||||
(ScollimatorZpositionCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == SlitThicknessCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetThicknessSlit
|
||||
(SlitThicknessCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == holeSlitDimensionYCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetSlitHoleDimensionY
|
||||
(holeSlitDimensionYCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == holeSlitDimensionZCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetSlitHoleDimensionZ
|
||||
(holeSlitDimensionZCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if( command == slitHolePositionZCmd )
|
||||
{
|
||||
laserDrivenMessengerPointer -> SetSlitHolePositionZ
|
||||
(slitHolePositionZCmd -> GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if (command==DisableQuadsCmd)
|
||||
{
|
||||
laserDrivenMessengerPointer -> RemoveQuads();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,197 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
// Institute in the framework of the MC-INFN Group
|
||||
//
|
||||
//
|
||||
// In this class the models for ion-ion interactions at intermediate energies (0 - 1 GeV per nucleon)
|
||||
// can be activate. This class can be used alternatively to the "binary_ion" physics list
|
||||
//
|
||||
// The usefullness of this class is that you can explicitally see the total inelastic sections
|
||||
// activated and the models called. Moreover you can choose to activate for ions (from deuteron
|
||||
// to heavier nucleus) three different and exclusive models: the Binary Light Ion cascade, the QMD
|
||||
// and The Wilson.
|
||||
|
||||
// For hadrotherapy pouposes, where distributions of produced fragments is importante we strongly
|
||||
// suggest to use Binary or QMD. The Binary model is the default and at moment, you can swith beetween models decommenting
|
||||
// the line of code and recompiling
|
||||
|
||||
#include "LocalINCLIonIonInelasticPhysic.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
// Total cross section for inelastic processes
|
||||
#include "G4TripathiCrossSection.hh"
|
||||
#include "G4TripathiLightCrossSection.hh"
|
||||
#include "G4IonsShenCrossSection.hh"
|
||||
|
||||
#include "G4DeuteronInelasticProcess.hh"
|
||||
#include "G4TritonInelasticProcess.hh"
|
||||
#include "G4AlphaInelasticProcess.hh"
|
||||
#include "G4BinaryLightIonReaction.hh"
|
||||
#include "G4INCLXXInterface.hh"
|
||||
#include "G4QMDReaction.hh"
|
||||
#include "G4WilsonAbrasionModel.hh"
|
||||
#include "G4IonInelasticProcess.hh"
|
||||
#include "G4GeneralSpaceNNCrossSection.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
LocalINCLIonIonInelasticPhysic::LocalINCLIonIonInelasticPhysic(const G4String& name):
|
||||
G4VPhysicsConstructor(name)
|
||||
{
|
||||
G4cout << G4endl
|
||||
<< "A local inelastic model is activated for all ions"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
LocalINCLIonIonInelasticPhysic::~LocalINCLIonIonInelasticPhysic()
|
||||
{}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void LocalINCLIonIonInelasticPhysic::ConstructProcess()
|
||||
{
|
||||
G4ParticleDefinition* particle = 0;
|
||||
G4ProcessManager* processManager = 0;
|
||||
|
||||
// ****************************************************************
|
||||
// *** Ion-Ion models definition ***
|
||||
// ****************************************************************
|
||||
G4QMDReaction* JQMDmodel = new G4QMDReaction();
|
||||
JQMDmodel -> SetMinEnergy(0*MeV);
|
||||
JQMDmodel -> SetMaxEnergy(10*GeV);
|
||||
|
||||
G4BinaryLightIonReaction* lightBinary = new G4BinaryLightIonReaction();
|
||||
lightBinary -> SetMinEnergy(0*MeV);
|
||||
lightBinary -> SetMaxEnergy(10*GeV);
|
||||
|
||||
G4WilsonAbrasionModel* WilsonModel = new G4WilsonAbrasionModel();
|
||||
WilsonModel -> SetUseAblation(true);
|
||||
WilsonModel -> SetMinEnergy(0*MeV);
|
||||
WilsonModel -> SetMaxEnergy(10 *GeV);
|
||||
|
||||
// G4INCLXXInterface* INCLIonModel = new G4INCLXXInterface();
|
||||
|
||||
G4TripathiCrossSection* TripatiCrossSections = new G4TripathiCrossSection;
|
||||
G4TripathiCrossSection* TripatiLightCrossSections = new G4TripathiCrossSection;
|
||||
G4IonsShenCrossSection* ShenCrossSections = new G4IonsShenCrossSection;
|
||||
|
||||
// ****************
|
||||
// *** Deuteron ***
|
||||
// ****************
|
||||
G4DeuteronInelasticProcess* deuteronInelasticProcess = new G4DeuteronInelasticProcess;
|
||||
|
||||
deuteronInelasticProcess -> AddDataSet(ShenCrossSections);
|
||||
deuteronInelasticProcess -> AddDataSet(TripatiCrossSections);
|
||||
deuteronInelasticProcess -> AddDataSet(TripatiLightCrossSections);
|
||||
|
||||
//deuteronInelasticProcess -> RegisterMe(INCLIonModel);
|
||||
//deuteronInelasticProcess -> RegisterMe(lightBinary);
|
||||
deuteronInelasticProcess -> RegisterMe(JQMDmodel);
|
||||
//deuteronInelasticProcess -> RegisterMe(WilsonModel);
|
||||
|
||||
particle = G4Deuteron::Deuteron();
|
||||
processManager = particle -> GetProcessManager();
|
||||
processManager -> AddDiscreteProcess(deuteronInelasticProcess);
|
||||
|
||||
// **************
|
||||
// *** Triton ***
|
||||
// **************
|
||||
G4TritonInelasticProcess* tritonInelasticProcess = new G4TritonInelasticProcess;
|
||||
|
||||
tritonInelasticProcess -> AddDataSet(ShenCrossSections);
|
||||
tritonInelasticProcess -> AddDataSet(TripatiCrossSections);
|
||||
tritonInelasticProcess -> AddDataSet(TripatiLightCrossSections);
|
||||
|
||||
//tritonInelasticProcess -> RegisterMe(INCLIonModel);
|
||||
//tritonInelasticProcess -> RegisterMe(lightBinary);
|
||||
tritonInelasticProcess -> RegisterMe(JQMDmodel);
|
||||
//tritonInelasticProcess -> RegisterMe(WilsonModel);
|
||||
|
||||
particle = G4Triton::Triton();
|
||||
processManager = particle -> GetProcessManager();
|
||||
processManager -> AddDiscreteProcess(tritonInelasticProcess);
|
||||
|
||||
// *************
|
||||
// *** He3 ***
|
||||
// *************
|
||||
/*
|
||||
G4He3InelasticProcess* he3InelasticProcess = new G4He3InelasticProcess;
|
||||
|
||||
he3InelasticProcess -> AddDataSet(ShenCrossSections);
|
||||
he3InelasticProcess -> AddDataSet(TripatiCrossSections);
|
||||
he3InelasticProcess -> AddDataSet(TripatiLightCrossSections);
|
||||
|
||||
he3InelasticProcess -> RegisterMe(INCLIonModel);
|
||||
|
||||
particle = G4He3::He3();
|
||||
processManager = particle -> GetProcessManager();
|
||||
processManager -> AddDiscreteProcess(he3InelasticProcess);
|
||||
*/
|
||||
// *************
|
||||
// *** Alpha ***
|
||||
// *************
|
||||
G4AlphaInelasticProcess* alphaInelasticProcess = new G4AlphaInelasticProcess;
|
||||
|
||||
alphaInelasticProcess -> AddDataSet(ShenCrossSections);
|
||||
alphaInelasticProcess -> AddDataSet(TripatiCrossSections);
|
||||
alphaInelasticProcess -> AddDataSet(TripatiLightCrossSections);
|
||||
|
||||
//alphaInelasticProcess -> RegisterMe(INCLIonModel);
|
||||
//alphaInelasticProcess -> RegisterMe(lightBinary);
|
||||
alphaInelasticProcess -> RegisterMe(JQMDmodel);
|
||||
//alphaInelasticProcess -> RegisterMe(WilsonModel);
|
||||
|
||||
particle = G4Alpha::Alpha();
|
||||
processManager = particle -> GetProcessManager();
|
||||
processManager -> AddDiscreteProcess(alphaInelasticProcess);
|
||||
|
||||
// *******************
|
||||
// *** Generic Ion ***
|
||||
// *******************
|
||||
G4IonInelasticProcess* genericIonInelasticProcess = new G4IonInelasticProcess();
|
||||
|
||||
genericIonInelasticProcess -> AddDataSet(ShenCrossSections);
|
||||
genericIonInelasticProcess -> AddDataSet(TripatiCrossSections);
|
||||
genericIonInelasticProcess -> AddDataSet(TripatiLightCrossSections);
|
||||
|
||||
//genericIonInelasticProcess -> RegisterMe(lightBinary);
|
||||
genericIonInelasticProcess -> RegisterMe(JQMDmodel);
|
||||
//genericIonInelasticProcess -> RegisterMe(WilsonModel);
|
||||
|
||||
particle = G4GenericIon::GenericIon();
|
||||
processManager = particle -> GetProcessManager();
|
||||
processManager -> AddDiscreteProcess(genericIonInelasticProcess);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
@@ -27,20 +27,6 @@
|
||||
//
|
||||
// HADRONTHERAPY: a Geant4-based application for proton/ion-therapy studies
|
||||
// _________________________________________________________________________
|
||||
//
|
||||
// This is the FULL version of the Hadrontherapy application.
|
||||
// It is based on the Geant4 toolkit classes and released under the GPL3 license.
|
||||
//
|
||||
// Its basic version is released and maintained inside the Geant4 code
|
||||
// as Advanced Example.
|
||||
//
|
||||
// To compile and run Hadrontherapy you only require the installation of Geant4 and,
|
||||
// if you wish, the ROOT ananlysis program.
|
||||
//
|
||||
// For more information see the documentation at http://sites.google.com/site/hadrontherapy/
|
||||
// or contact cirrone@lns.infn.it
|
||||
//
|
||||
// **************************************************************************************
|
||||
|
||||
|
||||
#include "G4Box.hh"
|
||||
@@ -58,10 +44,9 @@
|
||||
#include "HadrontherapyModulator.hh"
|
||||
#include "PassiveCarbonBeamLine.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
//#include "FaradayCup.hh"
|
||||
|
||||
|
||||
|
||||
|
||||
//G4bool PassiveCarbonBeamLine::doCalculation = false;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
PassiveCarbonBeamLine::PassiveCarbonBeamLine():
|
||||
physicalTreatmentRoom(0), hadrontherapyDetectorConstruction(0),
|
||||
@@ -74,9 +59,7 @@ physiSecondHoleNozzleSupport(0),
|
||||
solidFinalCollimator(0),
|
||||
physiFinalCollimator(0)
|
||||
{
|
||||
// Messenger to change parameters of the passiveProtonBeamLine geometry
|
||||
//passiveMessenger = new PassiveProtonBeamLineMessenger(this);
|
||||
|
||||
|
||||
//***************************** PW ***************************************
|
||||
|
||||
static G4String ROGeometryName = "DetectorROGeometry";
|
||||
@@ -88,15 +71,11 @@ physiFinalCollimator(0)
|
||||
RegisterParallelWorld(RO);
|
||||
G4cout << "... done" << G4endl;
|
||||
//***************************** PW ***************************************
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
PassiveCarbonBeamLine::~PassiveCarbonBeamLine()
|
||||
{
|
||||
//delete passiveMessenger;
|
||||
delete hadrontherapyDetectorConstruction;
|
||||
}
|
||||
|
||||
@@ -122,9 +101,7 @@ G4VPhysicalVolume* PassiveCarbonBeamLine::Construct()
|
||||
|
||||
hadrontherapyDetectorConstruction->InitializeDetectorROGeometry(RO,hadrontherapyDetectorConstruction->GetDetectorToWorldPosition());
|
||||
|
||||
//***************************** PW ***************************************
|
||||
|
||||
|
||||
//***************************** PW ***************************************
|
||||
return physicalTreatmentRoom;
|
||||
}
|
||||
|
||||
@@ -427,8 +404,8 @@ void PassiveCarbonBeamLine::HadrontherapyBeamLineSupport()
|
||||
const G4double beamLineCoverZSize = 10.*mm;
|
||||
|
||||
const G4double beamLineCoverXPosition = -1745.09 *mm;
|
||||
const G4double beamLineCoverYPosition = -980.*mm;
|
||||
const G4double beamLineCoverZPosition = 600.*mm;
|
||||
const G4double beamLineCoverYPosition = -1000.*mm;
|
||||
const G4double beamLineCoverZPosition = 610.*mm;
|
||||
|
||||
G4Box* beamLineCover = new G4Box("BeamLineCover",
|
||||
beamLineCoverXSize,
|
||||
@@ -744,19 +721,32 @@ void PassiveCarbonBeamLine::HadrontherapyBeamNozzle()
|
||||
0);
|
||||
|
||||
logicNozzleSupport -> SetVisAttributes(yellow);
|
||||
|
||||
// -------------------//
|
||||
// BRASS TUBE //
|
||||
// -------------------//
|
||||
const G4double innerRadiusHoleNozzleSupport = 18.*mm;
|
||||
const G4double outerRadiusHoleNozzleSupport = 21.5 *mm;
|
||||
//XXX h/2 = 142.5 mm
|
||||
const G4double hightHoleNozzleSupport = 142.5*mm;
|
||||
const G4double hightHoleNozzleSupportFirst = nozzleSupportXSize;
|
||||
const G4double hightHoleNozzleSupport = 113.0*mm;
|
||||
const G4double startAngleHoleNozzleSupport = 0.*deg;
|
||||
const G4double spanningAngleHoleNozzleSupport = 360.*deg;
|
||||
//XXX -(320+142.5)mm
|
||||
const G4double holeNozzleSupportXPosition = -462.50 *mm;
|
||||
const G4double holeNozzleSupportXPosition = -415.5 *mm;
|
||||
G4Tubs* solidNozzleSupportHole = new G4Tubs("NozzleSupportHole1", innerRadiusHoleNozzleSupport,
|
||||
outerRadiusHoleNozzleSupport,
|
||||
hightHoleNozzleSupportFirst,
|
||||
startAngleHoleNozzleSupport,
|
||||
spanningAngleHoleNozzleSupport);
|
||||
|
||||
G4LogicalVolume* logicNozzleSupportHole = new G4LogicalVolume(solidNozzleSupportHole,
|
||||
holeNozzleSupportMaterial,
|
||||
"NozzleSupportHole1");
|
||||
|
||||
physiNozzleSupportHole = new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(0, 0., 0.)),
|
||||
"HoleNozzleSupportHole1",
|
||||
logicNozzleSupportHole,
|
||||
physiNozzleSupport, false, 0);
|
||||
|
||||
G4Tubs* solidHoleNozzleSupport = new G4Tubs("HoleNozzleSupport",
|
||||
innerRadiusHoleNozzleSupport,
|
||||
outerRadiusHoleNozzleSupport,
|
||||
@@ -773,7 +763,7 @@ void PassiveCarbonBeamLine::HadrontherapyBeamNozzle()
|
||||
"HoleNozzleSupport",
|
||||
logicHoleNozzleSupport,
|
||||
physicalTreatmentRoom, false, 0);
|
||||
|
||||
logicNozzleSupportHole -> SetVisAttributes(darkOrange3);
|
||||
logicHoleNozzleSupport -> SetVisAttributes(darkOrange3);
|
||||
|
||||
//--------------------------------------------------------------//
|
||||
@@ -820,7 +810,7 @@ void PassiveCarbonBeamLine::HadrontherapyBeamFinalCollimator()
|
||||
const G4double startAngleFinalCollimator = 0.*deg;
|
||||
const G4double spanningAngleFinalCollimator = 360.*deg;
|
||||
//XXX
|
||||
const G4double finalCollimatorXPosition = -323.50 *mm;
|
||||
const G4double finalCollimatorXPosition = -299.0 *mm;
|
||||
|
||||
G4double phi = 90. *deg;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,10 +22,7 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
|
||||
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
||||
//
|
||||
|
||||
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
|
||||
// the *COMPLETE* version of this program, together with its documentation;
|
||||
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
|
||||
|
||||
Reference in New Issue
Block a user