Import Geant4 11.4.0.beta source tree
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file ActionInitialization.cc
|
||||
/// @brief Define action initialization
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#include "EventAction.hh"
|
||||
#include "MedicalBeam.hh"
|
||||
#include "RunAction.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
ActionInitialization::ActionInitialization() : G4VUserActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
ActionInitialization::~ActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
SetUserAction(new RunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
SetUserAction(new MedicalBeam);
|
||||
SetUserAction(new EventAction);
|
||||
SetUserAction(new RunAction);
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file Analysis.cc
|
||||
/// @brief Define histograms
|
||||
|
||||
#include "Analysis.hh"
|
||||
|
||||
#include "TFile.h"
|
||||
#include "TH1.h"
|
||||
#include "TH2.h"
|
||||
#include "TROOT.h"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
G4ThreadLocal G4int Analysis::fincidentFlag = false;
|
||||
G4ThreadLocal Analysis* the_analysis = 0;
|
||||
|
||||
G4Mutex rootm = G4MUTEX_INITIALIZER;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Analysis* Analysis::GetAnalysis()
|
||||
{
|
||||
if (!the_analysis) the_analysis = new Analysis;
|
||||
return the_analysis;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Analysis::Analysis()
|
||||
{
|
||||
G4AutoLock l(&rootm);
|
||||
// define histograms
|
||||
fincident_map = new TH2D("incident map", "Incident Distributuon", 50, -5., 5., 50, -5., 5.);
|
||||
fincident_map->GetXaxis()->SetTitle("X (cm)");
|
||||
fincident_map->GetYaxis()->SetTitle("Y (cm)");
|
||||
fincident_map->SetStats(0);
|
||||
|
||||
fincident_x_hist = new TH1D("incident x", "Incident X", 100, -5., 5.);
|
||||
fincident_x_hist->GetXaxis()->SetTitle("X (cm)");
|
||||
fincident_x_hist->SetFillColor(kRed);
|
||||
|
||||
fdose_map = new TH2D("dose map", "Dose Distribution", 500, 0., 50., 200, -10., 10.);
|
||||
fdose_map->GetXaxis()->SetTitle("Z (cm)");
|
||||
fdose_map->GetYaxis()->SetTitle("X (cm)");
|
||||
fdose_map->SetStats(0);
|
||||
|
||||
fdose_hist = new TH1D("dose", "Dose Distribution", 500, 0., 50.);
|
||||
fdose_hist->GetXaxis()->SetTitle("Z (cm)");
|
||||
fdose_hist->GetYaxis()->SetTitle("Dose (GeV)");
|
||||
fdose_hist->SetFillColor(kBlue);
|
||||
fdose_hist->SetStats(0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Analysis::~Analysis()
|
||||
{
|
||||
delete fincident_map;
|
||||
delete fincident_x_hist;
|
||||
delete fdose_map;
|
||||
delete fdose_hist;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::Update()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::Clear()
|
||||
{
|
||||
fincident_map->Reset();
|
||||
fincident_x_hist->Reset();
|
||||
fdose_map->Reset();
|
||||
fdose_hist->Reset();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::Save(const G4String& fname)
|
||||
{
|
||||
G4AutoLock l(&rootm);
|
||||
TFile* file = new TFile(fname.c_str(), "RECREATE", "Geant4 ROOT analysis");
|
||||
|
||||
fincident_map->Write();
|
||||
fincident_x_hist->Write();
|
||||
fdose_map->Write();
|
||||
fdose_hist->Write();
|
||||
|
||||
file->Close();
|
||||
|
||||
delete file;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::FillIncident(const G4ThreeVector& p)
|
||||
{
|
||||
if (!fincidentFlag) {
|
||||
fincident_map->Fill(p.x() / cm, p.y() / cm);
|
||||
fincident_x_hist->Fill(p.x() / cm);
|
||||
|
||||
fincidentFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void Analysis::FillDose(const G4ThreeVector& p, G4double dedx)
|
||||
{
|
||||
const G4double Z0 = 25. * cm;
|
||||
const G4double dxy = 10. * mm;
|
||||
|
||||
if (std::abs(p.y()) < dxy) {
|
||||
fdose_map->Fill((p.z() + Z0) / cm, p.x() / cm, dedx / GeV);
|
||||
|
||||
if (std::abs(p.x()) < dxy) {
|
||||
fdose_hist->Fill((p.z() + Z0) / cm, dedx / GeV);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file DetectorConstruction.hh
|
||||
/// @brief Define geometry
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "VoxelParam.hh"
|
||||
#include "VoxelSD.hh"
|
||||
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
typedef G4LogicalVolume G4LV;
|
||||
typedef G4PVPlacement G4PVP;
|
||||
typedef G4VisAttributes G4VA;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
DetectorConstruction::DetectorConstruction() : flv_voxel(NULL) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
DetectorConstruction::~DetectorConstruction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct()
|
||||
{
|
||||
G4NistManager* nistManager = G4NistManager::Instance();
|
||||
G4VisAttributes* va;
|
||||
|
||||
// world volume
|
||||
const G4double DXYZ_WORLD = 200. * cm;
|
||||
G4Box* sld_world = new G4Box("world", DXYZ_WORLD / 2., DXYZ_WORLD / 2., DXYZ_WORLD / 2.);
|
||||
|
||||
G4Material* vacuum = nistManager->FindOrBuildMaterial("G4_Galactic");
|
||||
G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
|
||||
G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA", lv_world, 0, false, 0);
|
||||
// vis. attributes
|
||||
va = new G4VA(G4Color(1., 1., 1.));
|
||||
va->SetVisibility(false);
|
||||
lv_world->SetVisAttributes(va);
|
||||
|
||||
// water phantom
|
||||
const G4double DXY_PHANTOM = 20. * cm;
|
||||
const G4double DZ_PHANTOM = 50. * cm;
|
||||
|
||||
G4Box* sld_phantom = new G4Box("phantom", DXY_PHANTOM / 2., DXY_PHANTOM / 2., DZ_PHANTOM / 2.);
|
||||
|
||||
G4Material* water = nistManager->FindOrBuildMaterial("G4_WATER");
|
||||
G4LV* lv_phantom = new G4LogicalVolume(sld_phantom, water, "phantom");
|
||||
|
||||
va = new G4VA(G4Color(0., 1., 1.));
|
||||
lv_phantom->SetVisAttributes(va);
|
||||
|
||||
new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
|
||||
|
||||
// voxel planes
|
||||
const G4double DXY_VXP = 20. * cm;
|
||||
const G4double DZ_VXP = 1. * mm;
|
||||
|
||||
G4Box* sld_vxp = new G4Box("vxplane", DXY_VXP / 2., DXY_VXP / 2., DZ_VXP / 2.);
|
||||
G4LV* lv_vxp = new G4LV(sld_vxp, water, "vxplane");
|
||||
|
||||
va = new G4VA(G4Color(1., 0., 0.));
|
||||
va->SetVisibility(false);
|
||||
lv_vxp->SetVisAttributes(va);
|
||||
|
||||
for (G4int iz = 0; iz < 500; iz++) {
|
||||
G4double z0 = -DZ_PHANTOM / 2. + (iz + 0.5) * DZ_VXP;
|
||||
new G4PVP(0, G4ThreeVector(0., 0., z0), lv_vxp, "vxplane", lv_phantom, false, 1000 + iz);
|
||||
}
|
||||
|
||||
// voxel parameterized
|
||||
G4Box* sld_voxel = new G4Box("voxel", 1., 1., 1.); // dummy
|
||||
flv_voxel = new G4LV(sld_voxel, water, "voxel");
|
||||
|
||||
va = new G4VA(G4Color(0., 1., 1.));
|
||||
va->SetVisibility(false);
|
||||
flv_voxel->SetVisAttributes(va);
|
||||
|
||||
const G4int nvoxels = 100 * 100;
|
||||
new G4PVParameterised("voxle", flv_voxel, lv_vxp, kUndefined, nvoxels, new VoxelParam());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void DetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
flv_voxel->SetSensitiveDetector(new VoxelSD("voxel"));
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file EventAction.cc
|
||||
/// @brief Describe event actions
|
||||
|
||||
#include "EventAction.hh"
|
||||
|
||||
#include "Analysis.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
EventAction::EventAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
EventAction::~EventAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void EventAction::BeginOfEventAction(const G4Event*)
|
||||
{
|
||||
Analysis* myana = Analysis::GetAnalysis();
|
||||
myana->ClearIncidentFlag();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void EventAction::EndOfEventAction(const G4Event*) {}
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file MedicalBeam.cc
|
||||
/// @brief Define beam profile as primary generator
|
||||
|
||||
#include "MedicalBeam.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PrimaryVertex.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
MedicalBeam::MedicalBeam()
|
||||
: fparticle(0),
|
||||
fkineticE(1. * MeV),
|
||||
fsourcePosition(G4ThreeVector()),
|
||||
fSSD(1. * m),
|
||||
ffieldShape(MedicalBeam::kSQUARE),
|
||||
ffieldR(10. * cm)
|
||||
{
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
fparticle = particleTable->FindParticle("proton");
|
||||
|
||||
fkineticE = 200. * MeV;
|
||||
fsourcePosition = G4ThreeVector(0., 0., -125. * cm);
|
||||
fSSD = 100. * cm;
|
||||
ffieldXY[0] = ffieldXY[1] = 5. * cm;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
MedicalBeam::~MedicalBeam() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4ThreeVector MedicalBeam::GenerateBeamDirection() const
|
||||
{
|
||||
// uniform distribution in a limitted solid angle
|
||||
G4double dr;
|
||||
if (ffieldShape == MedicalBeam::kSQUARE) {
|
||||
dr = std::sqrt(sqr(ffieldXY[0] / 2.) + sqr(ffieldXY[1] / 2.));
|
||||
}
|
||||
else {
|
||||
dr = ffieldR;
|
||||
}
|
||||
|
||||
G4double sin0 = dr / fSSD;
|
||||
G4double cos0 = std::sqrt(1. - sqr(sin0));
|
||||
|
||||
G4double dcos = 0.;
|
||||
G4double dsin, dphi, z;
|
||||
|
||||
G4double x = DBL_MAX;
|
||||
G4double y = DBL_MAX;
|
||||
|
||||
G4double xmax, ymax;
|
||||
if (ffieldShape == MedicalBeam::kSQUARE) {
|
||||
xmax = ffieldXY[0] / 2. / fSSD;
|
||||
ymax = ffieldXY[1] / 2. / fSSD;
|
||||
}
|
||||
else {
|
||||
xmax = ymax = DBL_MAX - 1.;
|
||||
}
|
||||
|
||||
while (!(std::abs(x) < xmax && std::abs(y) < ymax)) {
|
||||
dcos = G4RandFlat::shoot(cos0, 1.);
|
||||
dsin = std::sqrt(1. - sqr(dcos));
|
||||
dphi = G4RandFlat::shoot(0., twopi);
|
||||
|
||||
x = std::cos(dphi) * dsin * dcos;
|
||||
y = std::sin(dphi) * dsin * dcos;
|
||||
}
|
||||
z = dcos;
|
||||
|
||||
return G4ThreeVector(x, y, z);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void MedicalBeam::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
if (fparticle == NULL) return;
|
||||
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex = new G4PrimaryVertex(fsourcePosition, 0. * ns);
|
||||
|
||||
// momentum
|
||||
G4double mass = fparticle->GetPDGMass();
|
||||
G4double p = std::sqrt(sqr(mass + fkineticE) - sqr(mass));
|
||||
G4ThreeVector pmon = p * GenerateBeamDirection();
|
||||
G4PrimaryParticle* primary = new G4PrimaryParticle(fparticle, pmon.x(), pmon.y(), pmon.z());
|
||||
|
||||
// set primary to vertex
|
||||
vertex->SetPrimary(primary);
|
||||
|
||||
// set vertex to event
|
||||
anEvent->AddPrimaryVertex(vertex);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file RunAction.cc
|
||||
/// @brief Describe run actions
|
||||
|
||||
#include "RunAction.hh"
|
||||
|
||||
#include "Analysis.hh"
|
||||
|
||||
#include "G4MPImanager.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
RunAction::RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
RunAction::~RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void RunAction::BeginOfRunAction(const G4Run*)
|
||||
{
|
||||
Analysis* myana = Analysis::GetAnalysis();
|
||||
myana->Clear();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void RunAction::EndOfRunAction(const G4Run*)
|
||||
{
|
||||
G4int rank = G4MPImanager::GetManager()->GetRank();
|
||||
|
||||
char str[64];
|
||||
snprintf(str, 64, "dose-rank%03d.root", rank);
|
||||
G4String fname(str);
|
||||
|
||||
Analysis* myana = Analysis::GetAnalysis();
|
||||
myana->Save(fname);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file VoxelParam.cc
|
||||
/// @brief Define voxel parameterization
|
||||
|
||||
#include "VoxelParam.hh"
|
||||
|
||||
#include "G4Box.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelParam::VoxelParam() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelParam::~VoxelParam() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelParam::ComputeTransformation(const G4int id, G4VPhysicalVolume* vol) const
|
||||
{
|
||||
const G4int NX = 100;
|
||||
|
||||
G4int iy = id / NX;
|
||||
G4int ix = id % NX;
|
||||
|
||||
const G4double dxyz = 1. * mm;
|
||||
const G4double DXY = 10. * cm;
|
||||
|
||||
G4double x0 = -DXY / 2. + ix * dxyz;
|
||||
G4double y0 = -DXY / 2. + iy * dxyz;
|
||||
|
||||
vol->SetTranslation(G4ThreeVector(x0, y0, 0.));
|
||||
vol->SetRotation(0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelParam::ComputeDimensions(G4Box& box, const G4int, const G4VPhysicalVolume*) const
|
||||
{
|
||||
const G4double dxyz = 0.5 * mm;
|
||||
|
||||
box.SetXHalfLength(dxyz);
|
||||
box.SetYHalfLength(dxyz);
|
||||
box.SetZHalfLength(dxyz);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// @file VoxelSD.cc
|
||||
/// @brief Define detector sensitivity on voxels
|
||||
|
||||
// #include "G4MPImanager.hh"
|
||||
#include "VoxelSD.hh"
|
||||
|
||||
#include "Analysis.hh"
|
||||
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelSD::VoxelSD(const G4String& name) : G4VSensitiveDetector(name)
|
||||
{
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
VoxelSD::~VoxelSD() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4bool VoxelSD::ProcessHits(G4Step* astep, G4TouchableHistory*)
|
||||
{
|
||||
G4ThreeVector x0 = astep->GetPreStepPoint()->GetPosition();
|
||||
G4ThreeVector x1 = astep->GetPostStepPoint()->GetPosition();
|
||||
|
||||
G4int tid = astep->GetTrack()->GetTrackID();
|
||||
G4int iz = astep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber(1);
|
||||
|
||||
Analysis* myana = Analysis::GetAnalysis();
|
||||
|
||||
// incident position
|
||||
if (tid == 1 && iz == 1000) { // scored @ first layer
|
||||
myana->FillIncident(x0);
|
||||
}
|
||||
|
||||
// energy deposit
|
||||
G4ThreeVector p = G4UniformRand() * (x1 - x0) + x0; // position sampling
|
||||
G4double edep = astep->GetTotalEnergyDeposit();
|
||||
myana->FillDose(p, edep);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelSD::Initialize(G4HCofThisEvent*) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
void VoxelSD::EndOfEvent(G4HCofThisEvent*) {}
|
||||
Reference in New Issue
Block a user