Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
@@ -0,0 +1,159 @@
#include <stdlib.h>
#include "g4std/fstream"
#include "BrachyAnalysisManager.hh"
#include "G4ios.hh"
#include "AIDA/IHistogram1D.h"
#include "AIDA/IHistogram2D.h"
#include "AIDA/IManagedObject.h"
#include "AIDA/IAnalysisFactory.h"
#include "AIDA/IHistogramFactory.h"
#include "AIDA/ITupleFactory.h"
#include "AIDA/ITreeFactory.h"
#include "AIDA/ITree.h"
#include "AIDA/ITuple.h"
BrachyAnalysisManager* BrachyAnalysisManager::instance = 0;
BrachyAnalysisManager::BrachyAnalysisManager() :
aFact(0), theTree(0), histFact(0), tupFact(0)
{
//build up the factories
aFact = AIDA_createAnalysisFactory();
ITreeFactory * treeFact = aFact->createTreeFactory();
//parameters for the TreeFactory
bool fileExists = false;
bool readOnly = false;
std::string fileName="Brachy3.hbk";
theTree = treeFact->create(fileName, readOnly, fileExists, "hbook");
delete treeFact;
//HistoFactory and TupleFactory depend on theTree
histFact = aFact->createHistogramFactory( *theTree );
tupFact = aFact->createTupleFactory ( *theTree );
}
BrachyAnalysisManager::~BrachyAnalysisManager()
{
delete tupFact;
tupFact=0;
delete histFact;
histFact=0;
delete theTree;
histFact=0;
delete aFact;
aFact = 0;
}
BrachyAnalysisManager* BrachyAnalysisManager::getInstance()
{
if (instance == 0) instance = new BrachyAnalysisManager;
return instance;
}
void BrachyAnalysisManager::book()
{
// histograms and ntuple are managed by theTree
// h2 e h3 are not necessary ,useful for:check for non-zero
//you could do histFact->create2D("20","Energy, pos",300 ,-150.,150.,300,-15 //0.,150.);
IHistogram2D *h2 = histFact->create2D("20","Energy, pos",300 ,-150.,150.,300,-150.,150.);
// check for non-zero
IHistogram1D *h3 = histFact->create1D("30","Initial Energy", 100,0.,1.);
// check for non-zero
//Ntuple management
std::string columnNames = "float energy, float x, float z";
std::string options = "";
ITuple *tup = tupFact->create("1","brachy",columnNames, options);
// check for non-zero ...
if (tup) G4cout<<"The Ntuple is non-zero"<<G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void BrachyAnalysisManager::analyse(G4double xx,G4double zz,G4float en)
{
ITuple * ntuple = dynamic_cast<ITuple *> ( theTree->find("1") );
ntuple->fill(1, en);// fill ( int column, double value )
ntuple->fill(2, xx);
ntuple->fill(3, zz);
// alternatively(if all the columns are of the same type):
// std::vector<float> row;
// row.push_back(en);
// row.push_back(xx);
// row.push_back(zz);
// ntuple->fill(row);
// write Ntuple-row to file
// Should be called after fill is called for the columns.
// Unfilled columns will be filled with the default value for that column.
ntuple->addRow();
}
void BrachyAnalysisManager::hist(G4double x,G4double z, G4float enn)
{
IHistogram2D* h2 = dynamic_cast<IHistogram2D *> ( theTree->find("20") );
h2->fill(x,z,enn);
}
void BrachyAnalysisManager::Spectrum(G4double Init_En)
{
IHistogram1D* h3 = dynamic_cast<IHistogram1D *> ( theTree->find("30") );
h3->fill(Init_En);
}
void BrachyAnalysisManager::finish()
{
// write all histograms to file
theTree->commit();
// close (will again commit)
theTree->close();
}
@@ -1,35 +1,13 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// ****************************************
// * *
// * BrachyDetectorConstruction.cc *
// * *
// ****************************************
#include "BrachyWaterBoxROGeometry.hh"
#include "BrachyWaterBoxSD.hh"
#include "BrachyPhantomROGeometry.hh"
#include "BrachyPhantomSD.hh"
#include "BrachyDetectorMessenger.hh"
#include "BrachyDetectorConstruction.hh"
#include "G4CSGSolid.hh"
#include "G4Sphere.hh"
#include "G4MaterialPropertyVector.hh"
@@ -45,6 +23,8 @@
#include "G4PVPlacement.hh"
#include "globals.hh"
#include "G4MaterialTable.hh"
#include "G4Element.hh"
#include "G4ElementTable.hh"
#include "G4PVParameterised.hh"
@@ -53,153 +33,412 @@
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
#include "G4SDManager.hh"
#include "G4Colour.hh"
#include "G4UserLimits.hh"
#include "G4UnionSolid.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
//....
BrachyDetectorConstruction::BrachyDetectorConstruction(G4String &SDName,G4int NumVoxelX,G4int NumVoxelZ) :
m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ),m_BoxDimX(30*cm),m_BoxDimY(30*cm),m_BoxDimZ(30*cm)
BrachyDetectorConstruction::BrachyDetectorConstruction(G4String &SDName):
NumVoxelX(0),NumVoxelZ(0),m_BoxDimX(0), m_BoxDimY(0), m_BoxDimZ(0),
ExpHall(0),ExpHallLog(0),ExpHallPhys(0),
Phantom(0), PhantomLog(0), PhantomPhys(0),
Capsule(0),CapsuleLog(0),CapsulePhys(0),
CapsuleTip(0),CapsuleTipLog(0),CapsuleTipPhys(0),
IridiumCore(0),IridiumCoreLog(0),IridiumCorePhys(0)
{
m_SDName = SDName;
NumVoxelX=300;
NumVoxelZ=300;
m_BoxDimX=30*cm ;
m_BoxDimY=30*cm;
m_BoxDimZ=30*cm;
ComputeDimVoxel();
m_SDName = SDName;//pointer to sensitive detector
// create commands for interactive definition of the calorimeter
detectorMessenger = new BrachyDetectorMessenger(this);
m_SDName = SDName;
}
//....
BrachyDetectorConstruction::~BrachyDetectorConstruction()
{
{
}
//....
G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
{
// Define required materials
{
DefineMaterials();
return ConstructDetector();
}
G4double A; // atomic mass
G4double Z; // atomic number
G4double d; // density
void BrachyDetectorConstruction::DefineMaterials()
{
// Define required materials
G4double A; // atomic mass
G4double Z; // atomic number
G4double d; // density
// General elements
A = 1.01*g/mole;
Z = 1;
G4Element* elH = new G4Element ("Hydrogen","H",Z,A);
A = 1.01*g/mole;
G4Element* elH = new G4Element ("Hydrogen","H",Z=1.,A);
A = 14.01*g/mole;
Z = 7;
G4Element* elN = new G4Element("Nitrogen","N",Z,A);
A = 14.01*g/mole;
G4Element* elN = new G4Element("Nitrogen","N",Z=7.,A);
A = 16.00*g/mole;
G4Element* elO = new G4Element("Oxygen","O",Z=8.,A);
A=12.011*g/mole;
G4Element* elC=new G4Element("Carbon","C",Z=6.,A);
A=22.99*g/mole;
G4Element* elNa=new G4Element("Sodium","Na",Z=11.,A);
A=24.305*g/mole;
G4Element* elMg=new G4Element("Magnesium","Mg",Z=12.,A);
A=30.974*g/mole;
G4Element* elP=new G4Element("Phosphorus","P",Z=15.,A);
A=32.06*g/mole;
G4Element* elS=new G4Element("Sulfur","S",Z=16.,A);
A=35.453*g/mole;
G4Element* elCl=new G4Element("Chlorine","Cl",Z=17.,A);
A=39.098*g/mole;
G4Element* elK=new G4Element("Potassium","K",Z=19.,A);
A=40.08*g/mole;
G4Element* elCa=new G4Element("Calcium","Ca",Z=20.,A);
A = 16.00*g/mole;
Z = 8;
G4Element* elO = new G4Element("Oxygen","O",Z,A);
// Elements for source capsule and cable
A = 54.94*g/mole;
Z = 25;
G4Element* elMn = new G4Element("Manganese","Mn",Z,A);
A = 28.09*g/mole;
Z = 14;
G4Element* elSi = new G4Element("Silicon","Si",Z,A);
A=65.38*g/mole;
G4Element* elZn=new G4Element("Zinc","Zn",Z=30.,A);
A=26.98*g/mole;
G4Element* elAl=new G4Element("Aluminum","Al", Z=13.,A);
A = 52.00*g/mole;
Z = 24;
G4Element* elCr = new G4Element("Chromium","Cr",Z,A);
A = 58.70*g/mole;
Z = 28;
G4Element* elNi = new G4Element("Nickel","Ni",Z,A);
A = 55.85*g/mole;
Z = 26;
G4Element* elFe = new G4Element("Iron","Fe",Z,A);
A = 54.94*g/mole;
G4Element* elMn = new G4Element("Manganese","Mn",Z=25.,A);
A = 28.09*g/mole;
G4Element* elSi = new G4Element("Silicon","Si",Z=14.,A);
// Lead material
A = 207.19*g/mole;
Z = 82;
d = 11.35*g/cm3;
G4Material* matPb = new G4Material("Lead",Z,A,d);
A = 52.00*g/mole;
G4Element* elCr = new G4Element("Chromium","Cr",Z=24.,A);
// Air material
d = 1.290*mg/cm3;
G4Material* matAir = new G4Material("Air",d,2);
matAir->AddElement(elN,0.7);
matAir->AddElement(elO,0.3);
A = 58.70*g/mole;
G4Element* elNi = new G4Element("Nickel","Ni",Z=28.,A);
// Water
d = 1.000*g/cm3;
G4Material* matH2O = new G4Material("Water",d,2);
matH2O->AddElement(elH,2);
matH2O->AddElement(elO,1);
A = 55.85*g/mole;
G4Element* elFe = new G4Element("Iron","Fe",Z=26.,A);
// Lead material
A = 207.19*g/mole;
Z = 82;
d = 11.35*g/cm3;
G4Material* matPb = new G4Material("Lead",Z,A,d);
// Iridium (Medical Physics, Vol 25, No 10, Oct 1998)
d = 22.42*g/cm3;
A = 191.96260*g/mole ;
Z = 77;
G4Material* matIr192 = new G4Material("Iridium",Z,A,d);
d = 22.42*g/cm3;
A = 191.96260*g/mole ;
Z = 77;
G4Material* matIr192 = new G4Material("Iridium",Z,A,d);
// Stainless steel (Medical Physics, Vol 25, No 10, Oct 1998)
d = 8.02*g/cm3 ;
G4Material* matSteel = new G4Material("Stainless steel",d,5);
matSteel->AddElement(elMn, 0.02);
matSteel->AddElement(elSi, 0.01);
matSteel->AddElement(elCr, 0.19);
matSteel->AddElement(elNi, 0.10);
matSteel->AddElement(elFe, 0.68);
//titanium
A=47.88*g/mole;
d=4.50*g/cm3;
G4Material* Titanium=new G4Material("titanium" ,Z=22.,A,d);
// Volumes
// Air material
d = 1.290*mg/cm3;
G4Material* matAir = new G4Material("Air",d,2);
matAir->AddElement(elN,0.7);
matAir->AddElement(elO,0.3);
// EXPERIMENTAL HALL (our world volume)
G4double ExpHall_x = 4.0*m;
G4double ExpHall_y = 4.0*m;
G4double ExpHall_z = 4.0*m;
// Water
d = 1.000*g/cm3;
G4Material* matH2O = new G4Material("Water",d,2);
matH2O->AddElement(elH,2);
matH2O->AddElement(elO,1);
//soft tissue(NIST data)
d=1.0*g/cm3;
G4Material* soft=new G4Material("tissue",d,13);
soft->AddElement(elH,0.104472);
soft->AddElement(elC,0.23219);
soft->AddElement(elN,0.02488);
soft->AddElement(elO,0.630238);
soft->AddElement(elNa,0.00113);
soft->AddElement(elMg,0.00013);
soft->AddElement(elP,0.00133);
soft->AddElement(elS,0.00199);
soft->AddElement(elCl,0.00134);
soft->AddElement(elK,0.00199);
soft->AddElement(elCa,0.00023);
soft->AddElement(elFe,0.00005);
soft->AddElement(elZn,0.00003);
// Stainless steel (Medical Physics, Vol 25, No 10, Oct 1998)
d = 8.02*g/cm3 ;
G4Material* matSteel = new G4Material("Stainless steel",d,5);
matSteel->AddElement(elMn, 0.02);
matSteel->AddElement(elSi, 0.01);
matSteel->AddElement(elCr, 0.19);
matSteel->AddElement(elNi, 0.10);
matSteel->AddElement(elFe, 0.68);
//--elements for Iodium source which will be introduced in the next release
//--elements for Iodium source which will be introduced in the next release
//gold(chimica degli elementi N.N Greenwood,A.Earnshaw)
A=196.97*g/mole;
d=19.32*g/cm3;
G4Material* gold=new G4Material("gold",Z=79.,A,d);
//IodiumCore(chimica degli elementi N.N Greenwood,A.Earnshaw)
A=124.9*g/mole;
d=4.862*g/cm3;
G4Material* matI=new G4Material("Iodium",Z=53.,A,d);
//ceramica(Medical Physics, May 2000)
G4Box* ExpHall = new G4Box("ExpHall",ExpHall_x,ExpHall_y,ExpHall_z);
G4LogicalVolume* ExpHallLog = new G4LogicalVolume(ExpHall,matAir,"ExpHallLog",0,0,0);
G4VPhysicalVolume* ExpHallPhys = new G4PVPlacement(0,G4ThreeVector(),"ExpHallPhys",ExpHallLog,0,false,0);
d=2.88*g/cm3;
G4Material* ceramica=new G4Material("allumina",d,2);
ceramica->AddElement(elAl,2);
ceramica->AddElement(elO,3);
// Water Box
G4Box* WaterBox = new G4Box("WaterBox",m_BoxDimX/2,m_BoxDimY/2,m_BoxDimZ/2);
G4LogicalVolume* WaterBoxLog = new G4LogicalVolume(WaterBox,matH2O,"WaterBoxLog",0,0,0);
G4VPhysicalVolume* WaterBoxPhys = new G4PVPlacement(0,G4ThreeVector(),WaterBoxLog,"WaterBoxPhys",ExpHallLog,false,0);
// Capsule main body
AbsorberMaterial=matH2O;
air= matAir;
CapsuleMat=matSteel;
IridiumMat=matIr192;
G4Tubs* Capsule = new G4Tubs("Capsule",0,0.55*mm,3.725*mm,0.*deg,360.*deg);
G4LogicalVolume* CapsuleLog = new G4LogicalVolume(Capsule,matSteel,"CapsuleLog");
G4VPhysicalVolume* CapsulePhys = new G4PVPlacement(0,G4ThreeVector(0,0,-1.975),CapsuleLog,"CapsulePhys",WaterBoxLog,false,0);
// Capsule tip
G4Sphere* CapsuleTip = new G4Sphere("CapsuleTip",0.*mm,0.55*mm,0.*deg,360.*deg,0.*deg,90.*deg);
G4LogicalVolume* CapsuleTipLog = new G4LogicalVolume(CapsuleTip,matSteel,"CapsuleTipLog");
G4VPhysicalVolume* CapsuleTipPhys = new G4PVPlacement(0,G4ThreeVector(0.,0.,1.75*mm),CapsuleTipLog,"CapsuleTipPhys",WaterBoxLog,false,0);
// Iridium core
G4Tubs* IridiumCore = new G4Tubs("IrCore",0,0.30*mm,1.75*mm,0.*deg,360.*deg);
G4LogicalVolume* IridiumCoreLog = new G4LogicalVolume(IridiumCore,matIr192,"IridiumCoreLog");
G4VPhysicalVolume* IridiumCorePhys = new G4PVPlacement(0,G4ThreeVector(),IridiumCoreLog,"IridiumCorePhys",CapsuleLog,false,0);
// Sensitive Detector and ReadOut geometry definition
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
BrachyWaterBoxSD* pWaterBoxSD = new BrachyWaterBoxSD(m_SDName,m_NumVoxelX,m_NumVoxelZ);
if(pWaterBoxSD)
{
G4String ROGeometryName = "WaterBoxROGeometry";
BrachyWaterBoxROGeometry* pWaterBoxROGeometry = new BrachyWaterBoxROGeometry(ROGeometryName,m_BoxDimX,m_BoxDimZ,m_NumVoxelX,m_NumVoxelZ);
pWaterBoxROGeometry->BuildROGeometry();
pWaterBoxSD->SetROgeometry(pWaterBoxROGeometry);
pSDManager->AddNewDetector(pWaterBoxSD);
WaterBoxLog->SetSensitiveDetector(pWaterBoxSD);
CapsuleLog->SetSensitiveDetector(pWaterBoxSD);
CapsuleTipLog->SetSensitiveDetector(pWaterBoxSD);
IridiumCoreLog->SetSensitiveDetector(pWaterBoxSD);
}
return ExpHallPhys;
}
G4VPhysicalVolume* BrachyDetectorConstruction::ConstructDetector()
{// Volumes
ComputeDimVoxel();
// EXPERIMENTAL HALL (our world volume)
G4double ExpHall_x = 4.0*m;
G4double ExpHall_y = 4.0*m;
G4double ExpHall_z = 4.0*m;
G4Colour white (1.0, 1.0, 1.0) ;
G4Colour grey (0.5, 0.5, 0.5) ;
G4Colour lgrey (.75, .75, .75) ;
G4Colour red (1.0, 0.0, 0.0) ;
G4Colour blue (0.0, 0.0, 1.0) ;
G4Colour cyan (0.0, 1.0, 1.0) ;
G4Colour magenta (1.0, 0.0, 1.0) ;
G4Colour yellow (1.0, 1.0, 0.0) ;
G4Colour lblue (0.0, 0.0, .75);
//World volume
ExpHall = new G4Box("ExpHall",ExpHall_x,ExpHall_y,ExpHall_z);
ExpHallLog = new G4LogicalVolume(ExpHall,air,"ExpHallLog",0,0,0);
ExpHallPhys = new G4PVPlacement(0,G4ThreeVector(),"ExpHallPhys",ExpHallLog,NULL,false,0);
// Water Box
Phantom= new G4Box("Phantom",m_BoxDimX/2,m_BoxDimY/2,m_BoxDimZ/2);
PhantomLog = new G4LogicalVolume(Phantom,AbsorberMaterial,"PhantomLog",0,0,0);
PhantomPhys = new G4PVPlacement(0,G4ThreeVector(),"WaterBoxPhys",PhantomLog,ExpHallPhys,false,0);
// Capsule main body
G4Tubs* Capsule = new G4Tubs("Capsule",0,0.55*mm,3.725*mm,0.*deg,360.*deg);
G4LogicalVolume* CapsuleLog = new G4LogicalVolume(Capsule,CapsuleMat,"CapsuleLog");
G4VPhysicalVolume* CapsulePhys = new G4PVPlacement(0,G4ThreeVector(0,0,-1.975),"CapsulePhys",CapsuleLog,PhantomPhys,false,0);
// Capsule tip
G4Sphere* CapsuleTip = new G4Sphere("CapsuleTip",0.*mm,0.55*mm,0.*deg,360.*deg,0.*deg,90.*deg);
G4LogicalVolume* CapsuleTipLog = new G4LogicalVolume(CapsuleTip,CapsuleMat,"CapsuleTipLog");
G4VPhysicalVolume* CapsuleTipPhys = new G4PVPlacement(0,G4ThreeVector(0.,0.,1.75*mm),"CapsuleTipPhys",CapsuleTipLog,PhantomPhys,false,0);
// Iridium core
G4Tubs* IridiumCore = new G4Tubs("IrCore",0,0.30*mm,1.75*mm,0.*deg,360.*deg);
G4LogicalVolume* IridiumCoreLog = new G4LogicalVolume(IridiumCore,IridiumMat,"IridiumCoreLog");
G4VPhysicalVolume* IridiumCorePhys = new G4PVPlacement(0,G4ThreeVector(),"IridiumCorePhys",IridiumCoreLog,CapsulePhys,false,0);
// Sensitive Detector and ReadOut geometry definition
//
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
BrachyPhantomSD* pPhantomSD = new BrachyPhantomSD(m_SDName,NumVoxelX,NumVoxelZ);
if(pPhantomSD)
{
G4String ROGeometryName = "PhantomROGeometry";
BrachyPhantomROGeometry* pPhantomROGeometry = new BrachyPhantomROGeometry(ROGeometryName,m_BoxDimX,m_BoxDimZ,NumVoxelX,NumVoxelZ);
pPhantomROGeometry->BuildROGeometry();
pPhantomSD->SetROgeometry(pPhantomROGeometry);
pSDManager->AddNewDetector(pPhantomSD);
PhantomLog->SetSensitiveDetector(pPhantomSD);
CapsuleLog->SetSensitiveDetector(pPhantomSD);
CapsuleTipLog->SetSensitiveDetector(pPhantomSD);
IridiumCoreLog->SetSensitiveDetector(pPhantomSD);
}
//
// Visualization attributes
//
ExpHallLog->SetVisAttributes (G4VisAttributes::Invisible);
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(lblue);
simpleBoxVisAtt->SetVisibility(true);
simpleBoxVisAtt->SetForceWireframe(true);
PhantomLog->SetVisAttributes(simpleBoxVisAtt);
G4VisAttributes* simpleIridiumVisAtt= new G4VisAttributes(magenta);
simpleIridiumVisAtt->SetVisibility(true);
simpleIridiumVisAtt->SetForceWireframe(true);
IridiumCoreLog->SetVisAttributes(simpleIridiumVisAtt);
G4VisAttributes* simpleCapsuleVisAtt= new G4VisAttributes(red);
simpleCapsuleVisAtt->SetVisibility(true);
simpleCapsuleVisAtt->SetForceWireframe(true);
CapsuleLog->SetVisAttributes( simpleCapsuleVisAtt);
G4VisAttributes* simpleCapsuleTipVisAtt= new G4VisAttributes(red);
simpleCapsuleTipVisAtt->SetVisibility(true);
simpleCapsuleTipVisAtt->SetForceSolid(true);
CapsuleTipLog->SetVisAttributes( simpleCapsuleTipVisAtt);
//always return the physical World
PrintDetectorParameters();
return ExpHallPhys;
}
void BrachyDetectorConstruction::PrintDetectorParameters()
{
G4cout << "-----------------------------------------------------------------------"
<< G4endl
<<"the detector is a box whose size is: "
<<G4endl
<<m_BoxDimX/cm
<< " cm * "
<<m_BoxDimY/cm
<< " cm * "
<<m_BoxDimZ/cm
<< " cm"
<< G4endl
<<"numVoxel: "
<<NumVoxelX
<<G4endl
<<"dim voxel: "
<<dimVoxel/mm
<<"mm"
<<G4endl
<<"material of the box : "
<<AbsorberMaterial->GetName()
<<G4endl
<<"the source is at the center of the detector"
<<G4endl
<<"-------------------------------------------------------------------------"
<< G4endl;
}
void BrachyDetectorConstruction::SetAbsorberMaterial(G4String materialChoice)
{
// search the material by its name
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
if (pttoMaterial)
{AbsorberMaterial = pttoMaterial;
PhantomLog->SetMaterial(pttoMaterial);
PrintDetectorParameters();
}
else G4cout<<"that's not avaiable!"<<G4endl;
}
@@ -0,0 +1,78 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: BrachyDetectorMessenger.cc,v 1.2 2002/06/18 22:30:31 guatelli Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "BrachyDetectorMessenger.hh"
#include "BrachyDetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
BrachyDetectorMessenger::BrachyDetectorMessenger( BrachyDetectorConstruction* Det)
:Detector(Det)
{
detDir = new G4UIdirectory("/detector/");
detDir->SetGuidance(" detector control.");
AbsMaterCmd = new G4UIcmdWithAString("/detector/setMaterial",this);
AbsMaterCmd->SetGuidance("Select Material of the detector.");
AbsMaterCmd->SetParameterName("choice",false);
AbsMaterCmd->AvailableForStates(Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
BrachyDetectorMessenger::~BrachyDetectorMessenger()
{
delete AbsMaterCmd;
delete UpdateCmd;
delete detDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void BrachyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == AbsMaterCmd )
{ Detector->SetAbsorberMaterial(newValue);}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,9 +27,9 @@
// *******************************
#include "BrachyEventAction.hh"
#include "BrachyWaterBoxHit.hh"
#include "BrachyWaterBoxSD.hh"
#include "BrachyPhantomHit.hh"
#include "BrachyPhantomSD.hh"
#include "BrachyDetectorConstruction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
@@ -40,54 +40,117 @@
#include "G4SDManager.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "G4VVisManager.hh"
#include"BrachyAnalysisManager.hh"
//....
BrachyEventAction::BrachyEventAction(G4float *pVoxel,G4int NumVoxelX,G4int NumVoxelZ) :
m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
BrachyEventAction::BrachyEventAction(G4String &SDName) :
drawFlag("all" ),printModulo(1)
{
m_HitsCollectionID = -1;
m_pVoxel = pVoxel;
m_HitsCollectionID = -1;
SDname=SDName;
pDetector=new BrachyDetectorConstruction(SDname);
m_NumVoxelX=pDetector-> GetNumVoxelX();
m_NumVoxelZ=pDetector->GetNumVoxelZ();
VoxelWidth_Z= pDetector -> VoxelWidth_Z() ;
VoxelWidth_X=pDetector->VoxelWidth_X();
}
//....
BrachyEventAction::~BrachyEventAction()
{
delete pDetector;
}
//....
void BrachyEventAction::BeginOfEventAction(const G4Event*)
void BrachyEventAction::BeginOfEventAction(const G4Event* aEvent)
{
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
if(m_HitsCollectionID == -1)
m_HitsCollectionID = pSDManager->GetCollectionID("WaterBoxHitsCollection");
G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
if(m_HitsCollectionID == -1)
m_HitsCollectionID = pSDManager->GetCollectionID("PhantomHitsCollection");
}
//....
void BrachyEventAction::EndOfEventAction(const G4Event* evt)
{
if(m_HitsCollectionID < 0)
return;
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
BrachyWaterBoxHitsCollection* CHC = NULL;
G4int evno = fpEventManager->GetConstCurrentEvent()->GetEventID() ;
if(HCE)
CHC = (BrachyWaterBoxHitsCollection*)(HCE->GetHC(m_HitsCollectionID));
if((evno==100)||(evno==500)||(evno==1000)||(evno==2500)
||(evno==5000)||(evno==7000)||(evno==9000)||
(evno==9500)||(evno==29000000)||(evno==29500000))
G4cout << evno << G4endl;
if(m_HitsCollectionID < 0)
return;
if(CHC)
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
BrachyPhantomHitsCollection* CHC = NULL;
if(HCE)
CHC = (BrachyPhantomHitsCollection*)(HCE->GetHC(m_HitsCollectionID));
if(CHC)
{
G4int HitCount = CHC->entries();
for (G4int h=0; h<HitCount; h++)
{
if(m_pVoxel)
{
// Fill voxel matrix with energy deposit data
G4int HitCount = CHC->entries();
for (G4int h=0; h<HitCount; h++)
m_pVoxel[((*CHC)[h])->GetZID() + ((*CHC)[h])->GetXID()*m_NumVoxelX] += (*CHC)[h]->GetEdep();
}
}
BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
i=((*CHC)[h])->GetZID();
k=((*CHC)[h])->GetXID();
j=i+k*m_NumVoxelX;
EnergyDep=(*CHC)[h]->GetEdep();
x = (-m_NumVoxelZ+1+2*k)*VoxelWidth_X/2;
z = (- m_NumVoxelZ+1+2*i)*VoxelWidth_Z/2;
if(EnergyDep!=0){
{ if( abs(x)>0.56*mm && abs(z)>3.8*mm)
analysis->hist(x,z,EnergyDep); analysis->analyse(x,z,EnergyDep);}}}
}
// extract the trajectories and draw them
if (G4VVisManager::GetConcreteInstance())
{
G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
G4int n_trajectories = 0;
if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
for (G4int i=0; i<n_trajectories; i++)
{ G4Trajectory* trj = (G4Trajectory*)((*(evt->
GetTrajectoryContainer()))[i]);
if (drawFlag == "all") trj->DrawTrajectory(50);
else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
trj->DrawTrajectory(50);
else if ((drawFlag == "neutral")&&(trj->GetCharge() == 0.))
trj->DrawTrajectory(50);
}
}
}
@@ -99,5 +162,3 @@ void BrachyEventAction::EndOfEventAction(const G4Event* evt)
@@ -22,73 +22,73 @@
//
// ********************************
// * *
// * BrachyWaterBoxHit.cc *
// * BrachyPhantomHit.cc *
// * *
// ********************************
#include "BrachyWaterBoxHit.hh"
#include "BrachyPhantomHit.hh"
#include "G4ios.hh"
#include "G4VVisManager.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4LogicalVolume.hh"
G4Allocator<BrachyWaterBoxHit> BrachyWaterBoxHitAllocator;
G4Allocator<BrachyPhantomHit> BrachyPhantomHitAllocator;
//....
BrachyWaterBoxHit::BrachyWaterBoxHit(G4LogicalVolume* logVol,G4int XID,G4int ZID)
:m_pLogV(logVol),m_XID(XID),m_ZID(ZID)
BrachyPhantomHit::BrachyPhantomHit(G4LogicalVolume* logVol,G4int XID,G4int ZID)
:m_pLogV(logVol),m_XID(XID),m_ZID(ZID)
{
m_Edep=0;
m_Edep=0;
}
//....
BrachyWaterBoxHit::~BrachyWaterBoxHit()
BrachyPhantomHit::~BrachyPhantomHit()
{
}
//....
BrachyWaterBoxHit::BrachyWaterBoxHit(const BrachyWaterBoxHit &right)
BrachyPhantomHit::BrachyPhantomHit(const BrachyPhantomHit &right)
{
m_XID = right.m_XID;
m_ZID = right.m_ZID;
m_Edep = right.m_Edep;
m_Pos = right.m_Pos;
m_Rot = right.m_Rot;
m_pLogV = right.m_pLogV;
m_XID = right.m_XID;
m_ZID = right.m_ZID;
m_Edep = right.m_Edep;
m_Pos = right.m_Pos;
m_Rot = right.m_Rot;
m_pLogV = right.m_pLogV;
}
//....
const BrachyWaterBoxHit& BrachyWaterBoxHit::operator=(const BrachyWaterBoxHit &right)
const BrachyPhantomHit& BrachyPhantomHit::operator=(const BrachyPhantomHit &right)
{
m_XID = right.m_XID;
m_ZID = right.m_ZID;
m_Edep = right.m_Edep;
m_Pos = right.m_Pos;
m_Rot = right.m_Rot;
m_pLogV = right.m_pLogV;
return *this;
m_XID = right.m_XID;
m_ZID = right.m_ZID;
m_Edep = right.m_Edep;
m_Pos = right.m_Pos;
m_Rot = right.m_Rot;
m_pLogV = right.m_pLogV;
return *this;
}
//....
int BrachyWaterBoxHit::operator==(const BrachyWaterBoxHit &right) const
int BrachyPhantomHit::operator==(const BrachyPhantomHit &right) const
{
return((m_XID==right.m_XID)&&(m_ZID==right.m_ZID));
return((m_XID==right.m_XID)&&(m_ZID==right.m_ZID));
}
//....
void BrachyWaterBoxHit::Draw()
void BrachyPhantomHit::Draw()
{
}
//....
void BrachyWaterBoxHit::Print()
void BrachyPhantomHit::Print()
{
}
@@ -0,0 +1,116 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// ************************************
// * *
// * BrachyWaterBoxROGeometry.cc *
// * *
// ************************************
#include "BrachyPhantomROGeometry.hh"
#include "BrachyDummySD.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4SubtractionSolid.hh"
#include "G4ThreeVector.hh"
#include "G4Material.hh"
//....
BrachyPhantomROGeometry::BrachyPhantomROGeometry(G4String aString,G4double DetDimX,G4double DetDimZ,G4int NumVoxelX,G4int NumVoxelZ)
: G4VReadOutGeometry(aString),m_DetDimX(DetDimX),m_DetDimZ(DetDimZ),m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
{
}
//....
BrachyPhantomROGeometry::~BrachyPhantomROGeometry()
{
}
//....
G4VPhysicalVolume* BrachyPhantomROGeometry::Build()
{
// A dummy material is used to fill the volumes of the readout geometry.
// (It will be allowed to set a NULL pointer in volumes of such virtual
// division in future, since this material is irrelevant for tracking.)
G4Material* dummyMat = new G4Material(name="dummyMat", 1., 1.*g/mole, 1.*g/cm3);
// Slice thickness is the average of Voxel X and Z sizes
G4double DetVoxel_y = (m_DetDimX/m_NumVoxelX+m_DetDimZ/m_NumVoxelZ)/2.0;
G4double ExpHall_x = 4.0*m;
G4double ExpHall_y = 4.0*m;
G4double ExpHall_z = 4.0*m;
G4double Det_x = m_DetDimX/2;
G4double Det_y = DetVoxel_y;
G4double Det_z = m_DetDimZ/2;
G4double DetVoxelX_x = Det_x/m_NumVoxelX;
G4double DetVoxelX_y = DetVoxel_y;
G4double DetVoxelX_z = Det_z;
G4double DetVoxelX_dx = 2*DetVoxelX_x;
G4double DetVoxelZ_x = Det_x;
G4double DetVoxelZ_y = DetVoxel_y;
G4double DetVoxelZ_z = Det_z/m_NumVoxelZ;
G4double DetVoxelZ_dz = 2*DetVoxelZ_z;
G4Box *ROExpHall = new G4Box("ROExpHall",ExpHall_x,ExpHall_y,ExpHall_z);
G4LogicalVolume *ROExpHallLog = new G4LogicalVolume(ROExpHall,dummyMat,"ROExpHallLog",0,0,0);
G4VPhysicalVolume *ROExpHallPhys = new G4PVPlacement(0,G4ThreeVector(),"ROExpHallPhys",ROExpHallLog,0,false,0);
G4Box *RODetector = new G4Box("RODetector", Det_x, Det_y, Det_z);
G4LogicalVolume *RODetectorLog = new G4LogicalVolume(RODetector,dummyMat,"RODetectorLog",0,0,0);
G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,G4ThreeVector(),"DetectorPhys",RODetectorLog,ROExpHallPhys,false,0);
// ReadOut Voxel division
// X division first...
G4Box *RODetectorXDivision = new G4Box("RODetectorXDivision",DetVoxelX_x,DetVoxelX_y,DetVoxelX_z);
G4LogicalVolume *RODetectorXDivisionLog = new G4LogicalVolume(RODetectorXDivision,dummyMat,"RODetectorXDivisionLog",0,0,0);
G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",RODetectorXDivisionLog,RODetectorPhys,kXAxis,m_NumVoxelX,DetVoxelX_dx);
// ...then Z division
G4Box *RODetectorZDivision = new G4Box("RODetectorZDivision",DetVoxelZ_x,DetVoxelZ_y,DetVoxelZ_z);
G4LogicalVolume *RODetectorZDivisionLog = new G4LogicalVolume(RODetectorZDivision,dummyMat,"RODetectorZDivisionLog",0,0,0);
G4VPhysicalVolume *RODetectorZDivisionPhys = new G4PVReplica("RODetectorZDivisionPhys",RODetectorZDivisionLog,RODetectorXDivisionPhys,kZAxis,m_NumVoxelZ,DetVoxelZ_dz);
BrachyDummySD *dummySD = new BrachyDummySD;
RODetectorZDivisionLog->SetSensitiveDetector(dummySD);
return ROExpHallPhys;
}
@@ -0,0 +1,141 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// ********************************
// * *
// * BrachyWaterBoxSD.cc *
// * *
// ********************************
#include "BrachyPhantomSD.hh"
#include "BrachyPhantomHit.hh"
#include "BrachyDetectorConstruction.hh"
#include "G4Track.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Step.hh"
#include "G4VTouchable.hh"
#include "G4TouchableHistory.hh"
#include "G4SDManager.hh"
#include "G4ParticleDefinition.hh"
//....
BrachyPhantomSD::BrachyPhantomSD(G4String name, G4int NumVoxelX, G4int NumVoxelZ)
:G4VSensitiveDetector(name),m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
{
G4String HCname;
collectionName.insert(HCname="PhantomHitsCollection");
m_pVoxelID = new G4int[NumVoxelX*NumVoxelZ];
m_pPhantomHitsCollection = NULL;
}
//....
BrachyPhantomSD::~BrachyPhantomSD()
{
delete[] m_pVoxelID;
}
//....
void BrachyPhantomSD::Initialize(G4HCofThisEvent*HCE)
{
m_pPhantomHitsCollection = new BrachyPhantomHitsCollection(SensitiveDetectorName,collectionName[0]);
for(G4int k=0;k<m_NumVoxelZ;k++)
for(G4int i=0;i<m_NumVoxelX;i++)
m_pVoxelID[i+k*m_NumVoxelX] = -1;
}
//....
G4bool BrachyPhantomSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
{
if(!ROhist)
return false;
if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() != "WaterBoxPhys")
return false;
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep==0.)
return false;
G4VPhysicalVolume* physVol = ROhist->GetVolume();
G4VPhysicalVolume* mothVol = ROhist->GetVolume(1);
// Read Voxel indexes: i is the x index, k is the z index
G4int k = ROhist->GetReplicaNumber();
G4int i = ROhist->GetReplicaNumber(1);
if(m_pVoxelID[i+k*m_NumVoxelX]==-1)
{
BrachyPhantomHit* PhantomHit = new BrachyPhantomHit(physVol->GetLogicalVolume(),i,k);
G4RotationMatrix rotM;
if(physVol->GetObjectRotation())
rotM = *(physVol->GetObjectRotation());
PhantomHit->SetEdep(edep);
PhantomHit->SetPos(physVol->GetTranslation());
PhantomHit->SetRot(rotM);
G4int VoxelID = m_pPhantomHitsCollection->insert(PhantomHit);
m_pVoxelID[i+k*m_NumVoxelX] = VoxelID - 1;
}
else
(*m_pPhantomHitsCollection)[m_pVoxelID[i+k*m_NumVoxelX]]->AddEdep(edep);
return true;
}
//....
void BrachyPhantomSD::EndOfEvent(G4HCofThisEvent*HCE)
{
static G4int HCID = -1;
if(HCID<0)
{
HCID = GetCollectionID(0);
}
HCE->AddHitsCollection(HCID,m_pPhantomHitsCollection);
}
//....
void BrachyPhantomSD::clear()
{
}
//....
void BrachyPhantomSD::DrawAll()
{
}
//....
void BrachyPhantomSD::PrintAll()
{
}
@@ -1,25 +1,3 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// ********************************************
// * *
// * BrachyPrimaryGeneratorAction.cc *
@@ -27,7 +5,7 @@
// ********************************************
#include "BrachyPrimaryGeneratorAction.hh"
#include "BrachyAnalysisManager.hh"
#include "G4ParticleTable.hh"
#include "Randomize.hh"
#include "G4Event.hh"
@@ -37,66 +15,94 @@
#include "G4UImanager.hh"
#include "globals.hh"
#include <math.h>
#include "G4RunManager.hh"
//....
BrachyPrimaryGeneratorAction::BrachyPrimaryGeneratorAction()
{
// Generate a gamma particle with energy = Ir-192 mean energy
G4int NumParticles = 1;
G4double Energy = 0.356*MeV;
G4int NumParticles = 1;
m_pParticleGun = new G4ParticleGun(NumParticles);
m_pParticleGun = new G4ParticleGun(NumParticles);
m_pParticleGun = new G4ParticleGun(NumParticles);
if(m_pParticleGun)
m_pParticleGun->SetParticleEnergy(Energy);
}
//....
BrachyPrimaryGeneratorAction::~BrachyPrimaryGeneratorAction()
{
if(m_pParticleGun)
delete m_pParticleGun;
if(m_pParticleGun)
delete m_pParticleGun;
}
//....
void BrachyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
G4ParticleTable* pParticleTable = G4ParticleTable::GetParticleTable();
G4String ParticleName = "gamma";
G4ParticleDefinition* pParticle = pParticleTable->FindParticle(ParticleName);
BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
m_pParticleGun->SetParticleDefinition(pParticle);
G4ParticleTable* pParticleTable = G4ParticleTable::GetParticleTable();
G4String ParticleName = "gamma";
G4ParticleDefinition* pParticle = pParticleTable->FindParticle(ParticleName);
// Random generation of gamma source point inside the Iridium core cylinder(R=0.3*mm,h=3.5*mm)
G4double radius = 0.3*mm;
G4double x,y,z;
do{
x = (G4UniformRand()-0.5)*radius/0.5;
y = (G4UniformRand()-0.5)*radius/0.5;
}while(x*x+y*y > radius*radius);
z = (G4UniformRand()-0.5)*1.75*mm/0.5;
m_pParticleGun->SetParticleDefinition(pParticle);
G4ThreeVector position(x,y,z);
m_pParticleGun->SetParticlePosition(position);
// Random generation of gamma source point inside the Iodium core
G4double x,y,z;
G4double radius= 0.30*mm;
do{
x = (G4UniformRand()-0.5)*(radius)/0.5;
y = (G4UniformRand()-0.5)*(radius)/0.5;
}while(x*x+y*y > radius*radius);
z = (G4UniformRand()-0.5)*1.75*mm/0.5 ;
// Random generation of the impulse direction
G4double a,b,c;
G4double n;
do{
a = (G4UniformRand()-0.5)/0.5;
b = (G4UniformRand()-0.5)/0.5;
c = (G4UniformRand()-0.5)/0.5;
n = a*a+b*b+c*c;
}while(n > 1 || n == 0.0);
n = sqrt(n);
a /= n;
b /= n;
c /= n;
G4ThreeVector position(x,y,z);
m_pParticleGun->SetParticlePosition(position);
G4ThreeVector direction(a,b,c);
m_pParticleGun->SetParticleMomentumDirection(direction);
m_pParticleGun->GeneratePrimaryVertex(anEvent);
// Random generation of the impulse direction
G4double a,b,c;
G4double n;
do{
a = (G4UniformRand()-0.5)/0.5;
b = (G4UniformRand()-0.5)/0.5;
c = (G4UniformRand()-0.5)/0.5;
n = a*a+b*b+c*c;
}while(n > 1 || n == 0.0);
n = sqrt(n);
a /= n;
b /= n;
c /= n;
G4ThreeVector direction(a,b,c);
m_pParticleGun->SetParticleMomentumDirection(direction);
//Energy = 0.356*MeV;
Energy = 356*keV;
m_pParticleGun->SetParticleEnergy(Energy);
//Check the energy
analysis->Spectrum(Energy);
m_pParticleGun->GeneratePrimaryVertex(anEvent);
}
@@ -0,0 +1,56 @@
#include "BrachyRunAction.hh"
#include "BrachyEventAction.hh"
#include "BrachyAnalysisManager.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "BrachyDetectorConstruction.hh"
#include "G4SDManager.hh"
#include "G4Timer.hh"
BrachyRunAction::BrachyRunAction()
{
}
BrachyRunAction::~BrachyRunAction()
{
}
void BrachyRunAction::BeginOfRunAction(const G4Run* aRun)
{ BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
analysis->book();
G4RunManager* pRunManager=G4RunManager::GetRunManager() ;
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
}
void BrachyRunAction::EndOfRunAction(const G4Run* aRun)
{
BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();
G4cout << "number of event = " << aRun->GetNumberOfEvent() << G4endl;
analysis->finish();
}
@@ -0,0 +1,132 @@
#ifdef G4VIS_USE
#include "BrachyVisManager.hh"
// Supported drivers...
#ifdef G4VIS_USE_DAWN
#include "G4FukuiRenderer.hh"
#endif
#ifdef G4VIS_USE_DAWNFILE
#include "G4DAWNFILE.hh"
#endif
/*#ifdef G4VIS_USE_OPACS
#include "G4Wo.hh"
#include "G4Xo.hh"
#endif
#ifdef G4VIS_USE_OPENGLX
#include "G4OpenGLImmediateX.hh"
#include "G4OpenGLStoredX.hh"
#endif
#ifdef G4VIS_USE_OPENGLWIN32
#include "G4OpenGLImmediateWin32.hh"
#include "G4OpenGLStoredWin32.hh"
#endif
#ifdef G4VIS_USE_OPENGLXM
#include "G4OpenGLImmediateXm.hh"
#include "G4OpenGLStoredXm.hh"
#endif
#ifdef G4VIS_USE_OIX
#include "G4OpenInventorX.hh"
#endif
#ifdef G4VIS_USE_OIWIN32
#include "G4OpenInventorWin32.hh"
#endif
#ifdef G4VIS_USE_VRML
#include "G4VRML1.hh"
#include "G4VRML2.hh"
#endif
#ifdef G4VIS_USE_VRMLFILE
#include "G4VRML1File.hh"
#include "G4VRML2File.hh"
#endif
#ifdef G4VIS_USE_RAYTRACER
#include "G4RayTracer.hh"
#endif
*/
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
BrachyVisManager::BrachyVisManager () {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void BrachyVisManager::RegisterGraphicsSystems () {
#ifdef G4VIS_USE_DAWN
RegisterGraphicsSystem (new G4FukuiRenderer);
#endif
#ifdef G4VIS_USE_DAWNFILE
RegisterGraphicsSystem (new G4DAWNFILE);
#endif
/*
#ifdef G4VIS_USE_OPACS
RegisterGraphicsSystem (new G4Wo);
RegisterGraphicsSystem (new G4Xo);
#endif
#ifdef G4VIS_USE_OPENGLX
RegisterGraphicsSystem (new G4OpenGLImmediateX);
RegisterGraphicsSystem (new G4OpenGLStoredX);
#endif
#ifdef G4VIS_USE_OPENGLWIN32
RegisterGraphicsSystem (new G4OpenGLImmediateWin32);
RegisterGraphicsSystem (new G4OpenGLStoredWin32);
#endif
#ifdef G4VIS_USE_OPENGLXM
RegisterGraphicsSystem (new G4OpenGLImmediateXm);
RegisterGraphicsSystem (new G4OpenGLStoredXm);
#endif
#ifdef G4VIS_USE_OIX
RegisterGraphicsSystem (new G4OpenInventorX);
#endif
#ifdef G4VIS_USE_OIWIN32
RegisterGraphicsSystem (new G4OpenInventorWin32);
#endif
#ifdef G4VIS_USE_VRML
RegisterGraphicsSystem (new G4VRML1);
RegisterGraphicsSystem (new G4VRML2);
#endif
#ifdef G4VIS_USE_VRMLFILE
RegisterGraphicsSystem (new G4VRML1File);
RegisterGraphicsSystem (new G4VRML2File);
#endif
#ifdef G4VIS_USE_RAYTRACER
RegisterGraphicsSystem (new G4RayTracer);
#endif
if (fVerbose > 0) {
G4cout <<
"\nYou have successfully chosen to use the following graphics systems."
<< G4endl;
PrintAvailableGraphicsSystems ();
}
*/
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1,116 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// ************************************
// * *
// * BrachyWaterBoxROGeometry.cc *
// * *
// ************************************
#include "BrachyWaterBoxROGeometry.hh"
#include "BrachyDummySD.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4SubtractionSolid.hh"
#include "G4ThreeVector.hh"
#include "G4Material.hh"
//....
BrachyWaterBoxROGeometry::BrachyWaterBoxROGeometry(G4String aString,G4double DetDimX,G4double DetDimZ,G4int NumVoxelX,G4int NumVoxelZ)
: G4VReadOutGeometry(aString),m_DetDimX(DetDimX),m_DetDimZ(DetDimZ),m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
{
}
//....
BrachyWaterBoxROGeometry::~BrachyWaterBoxROGeometry()
{
}
//....
G4VPhysicalVolume* BrachyWaterBoxROGeometry::Build()
{
// A dummy material is used to fill the volumes of the readout geometry.
// (It will be allowed to set a NULL pointer in volumes of such virtual
// division in future, since this material is irrelevant for tracking.)
G4Material* dummyMat = new G4Material(name="dummyMat", 1., 1.*g/mole, 1.*g/cm3);
// Slice thickness is the average of Voxel X and Z sizes
G4double DetVoxel_y = (m_DetDimX/m_NumVoxelX+m_DetDimZ/m_NumVoxelZ)/2.0;
G4double ExpHall_x = 4.0*m;
G4double ExpHall_y = 4.0*m;
G4double ExpHall_z = 4.0*m;
G4double Det_x = m_DetDimX/2;
G4double Det_y = DetVoxel_y;
G4double Det_z = m_DetDimZ/2;
G4double DetVoxelX_x = Det_x/m_NumVoxelX;
G4double DetVoxelX_y = DetVoxel_y;
G4double DetVoxelX_z = Det_z;
G4double DetVoxelX_dx = 2*DetVoxelX_x;
G4double DetVoxelZ_x = Det_x;
G4double DetVoxelZ_y = DetVoxel_y;
G4double DetVoxelZ_z = Det_z/m_NumVoxelZ;
G4double DetVoxelZ_dz = 2*DetVoxelZ_z;
G4Box *ROExpHall = new G4Box("ROExpHall",ExpHall_x,ExpHall_y,ExpHall_z);
G4LogicalVolume *ROExpHallLog = new G4LogicalVolume(ROExpHall,dummyMat,"ROExpHallLog",0,0,0);
G4VPhysicalVolume *ROExpHallPhys = new G4PVPlacement(0,G4ThreeVector(),"ROExpHallPhys",ROExpHallLog,0,false,0);
G4Box *RODetector = new G4Box("RODetector", Det_x, Det_y, Det_z);
G4LogicalVolume *RODetectorLog = new G4LogicalVolume(RODetector,dummyMat,"RODetectorLog",0,0,0);
G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,G4ThreeVector(),"DetectorPhys",RODetectorLog,ROExpHallPhys,false,0);
// ReadOut Voxel division
// X division first...
G4Box *RODetectorXDivision = new G4Box("RODetectorXDivision",DetVoxelX_x,DetVoxelX_y,DetVoxelX_z);
G4LogicalVolume *RODetectorXDivisionLog = new G4LogicalVolume(RODetectorXDivision,dummyMat,"RODetectorXDivisionLog",0,0,0);
G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",RODetectorXDivisionLog,RODetectorPhys,kXAxis,m_NumVoxelX,DetVoxelX_dx);
// ...then Z division
G4Box *RODetectorZDivision = new G4Box("RODetectorZDivision",DetVoxelZ_x,DetVoxelZ_y,DetVoxelZ_z);
G4LogicalVolume *RODetectorZDivisionLog = new G4LogicalVolume(RODetectorZDivision,dummyMat,"RODetectorZDivisionLog",0,0,0);
G4VPhysicalVolume *RODetectorZDivisionPhys = new G4PVReplica("RODetectorZDivisionPhys",RODetectorZDivisionLog,RODetectorXDivisionPhys,kZAxis,m_NumVoxelZ,DetVoxelZ_dz);
BrachyDummySD *dummySD = new BrachyDummySD;
RODetectorZDivisionLog->SetSensitiveDetector(dummySD);
return ROExpHallPhys;
}
@@ -1,141 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// ********************************
// * *
// * BrachyWaterBoxSD.cc *
// * *
// ********************************
#include "BrachyWaterBoxSD.hh"
#include "BrachyWaterBoxHit.hh"
#include "BrachyDetectorConstruction.hh"
#include "G4Track.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Step.hh"
#include "G4VTouchable.hh"
#include "G4TouchableHistory.hh"
#include "G4SDManager.hh"
#include "G4ParticleDefinition.hh"
//....
BrachyWaterBoxSD::BrachyWaterBoxSD(G4String name, G4int NumVoxelX, G4int NumVoxelZ)
:G4VSensitiveDetector(name),m_NumVoxelX(NumVoxelX),m_NumVoxelZ(NumVoxelZ)
{
G4String HCname;
collectionName.insert(HCname="WaterBoxHitsCollection");
m_pVoxelID = new G4int[NumVoxelX*NumVoxelZ];
m_pWaterBoxHitsCollection = NULL;
}
//....
BrachyWaterBoxSD::~BrachyWaterBoxSD()
{
delete[] m_pVoxelID;
}
//....
void BrachyWaterBoxSD::Initialize(G4HCofThisEvent*HCE)
{
m_pWaterBoxHitsCollection = new BrachyWaterBoxHitsCollection(SensitiveDetectorName,collectionName[0]);
for(G4int k=0;k<m_NumVoxelZ;k++)
for(G4int i=0;i<m_NumVoxelX;i++)
m_pVoxelID[i+k*m_NumVoxelX] = -1;
}
//....
G4bool BrachyWaterBoxSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
{
if(!ROhist)
return false;
if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() != "WaterBoxPhys")
return false;
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep==0.)
return false;
G4VPhysicalVolume* physVol = ROhist->GetVolume();
G4VPhysicalVolume* mothVol = ROhist->GetVolume(1);
// Read Voxel indexes: i is the x index, k is the z index
G4int k = ROhist->GetReplicaNumber();
G4int i = ROhist->GetReplicaNumber(1);
if(m_pVoxelID[i+k*m_NumVoxelX]==-1)
{
BrachyWaterBoxHit* WaterBoxHit = new BrachyWaterBoxHit(physVol->GetLogicalVolume(),i,k);
G4RotationMatrix rotM;
if(physVol->GetObjectRotation())
rotM = *(physVol->GetObjectRotation());
WaterBoxHit->SetEdep(edep);
WaterBoxHit->SetPos(physVol->GetTranslation());
WaterBoxHit->SetRot(rotM);
G4int VoxelID = m_pWaterBoxHitsCollection->insert(WaterBoxHit);
m_pVoxelID[i+k*m_NumVoxelX] = VoxelID - 1;
}
else
(*m_pWaterBoxHitsCollection)[m_pVoxelID[i+k*m_NumVoxelX]]->AddEdep(edep);
return true;
}
//....
void BrachyWaterBoxSD::EndOfEvent(G4HCofThisEvent*HCE)
{
static G4int HCID = -1;
if(HCID<0)
{
HCID = GetCollectionID(0);
}
HCE->AddHitsCollection(HCID,m_pWaterBoxHitsCollection);
}
//....
void BrachyWaterBoxSD::clear()
{
}
//....
void BrachyWaterBoxSD::DrawAll()
{
}
//....
void BrachyWaterBoxSD::PrintAll()
{
}