Import Geant4 8.0.0 source tree
This commit is contained in:
@@ -0,0 +1,371 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: RE02DetectorConstruction.cc,v 1.1 2005/11/24 01:44:18 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
|
||||
#include "RE02DetectorConstruction.hh"
|
||||
|
||||
#include "G4MultiFunctionalDetector.hh"
|
||||
|
||||
#include "G4PSEnergyDeposit.hh"
|
||||
//#include "G4PSDoseDeposit.hh"
|
||||
#include "G4PSNofStep.hh"
|
||||
//#include "G4PSNofSecondary.hh"
|
||||
//#include "G4PSMinKinEAtGeneration.hh"
|
||||
#include "G4PSCellFlux.hh"
|
||||
//#include "G4PSTrackLength.hh"
|
||||
//#include "G4PSPassageTrackLength.hh"
|
||||
//#include "G4PSPassageCurrent.hh"
|
||||
#include "G4PSPassageCellFlux.hh"
|
||||
#include "G4PSFlatSurfaceFlux.hh"
|
||||
#include "G4PSFlatSurfaceCurrent.hh"
|
||||
//#include "G4PSSphereSurfaceCurrent.hh"
|
||||
#include "G4SDParticleWithEnergyFilter.hh"
|
||||
#include "G4SDParticleFilter.hh"
|
||||
#include "G4SDChargedFilter.hh"
|
||||
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SDManager.hh"
|
||||
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "RE02PhantomParameterisation.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
//=======================================================================
|
||||
// RE02DetectorConstruction
|
||||
//
|
||||
// (Description)
|
||||
//
|
||||
// Detector construction for example RE02.
|
||||
//
|
||||
// [Geometry]
|
||||
// The world volume is defined as 200 cm x 200 cm x 200 cm box with Air.
|
||||
// Water phantom is defined as 200 mm x 200 mm x 400 mm box with Water.
|
||||
// The water phantom is divided into 100 segments in x,y plane, and 200 segments
|
||||
// perpendicular to z axis using parameterised volume.
|
||||
// These values are defined at constructor,
|
||||
// e.g. the size of water phantom (fphantomSize), and number of segmentation
|
||||
// of water phantom (fNx, fNy, fNz).
|
||||
// NIST database is used for materials.
|
||||
//
|
||||
// [Scorer]
|
||||
// Assignment of G4MultiFunctionalDetector and G4PrimitiveScorer
|
||||
// is demonstrated in this example.
|
||||
// -------------------------------------------------
|
||||
// The collection names of defined Primitives are
|
||||
// 0 PhantomSD/totalEDep
|
||||
// 1 PhantomSD/protonEDep
|
||||
// 2 PhantomSD/protonNStep
|
||||
// 3 PhantomSD/chargedPassCellFlux
|
||||
// 4 PhantomSD/chargedCellFlux
|
||||
// 5 PhantomSD/chargedSurfFlux
|
||||
// 6 PhantomSD/gammaSurfCurr000
|
||||
// 7 PhantomSD/gammaSurfCurr001
|
||||
// 9 PhantomSD/gammaSurdCurr002
|
||||
// 10 PhantomSD/gammaSurdCurr003
|
||||
// -------------------------------------------------
|
||||
// Please see README for detail description.
|
||||
//
|
||||
//=======================================================================
|
||||
|
||||
//
|
||||
RE02DetectorConstruction::RE02DetectorConstruction()
|
||||
{
|
||||
fphantomSize.setX(200.*mm);
|
||||
fphantomSize.setY(200.*mm);
|
||||
fphantomSize.setZ(400.*mm);
|
||||
//fNx = fNy = fNz = 100;
|
||||
fNx = 100; fNy = 100; fNz = 200;
|
||||
//fNx = 1; fNy = 1; fNz = 200;
|
||||
G4cout << "<-- RE02DetectorConstruction -----------------" <<G4endl;
|
||||
G4cout << " Water Phantom Size " << fphantomSize/mm << G4endl;
|
||||
G4cout << " Segmentation ("<< fNx<<","<<fNy<<","<<fNz<<")"<<G4endl;
|
||||
G4cout << "<---------------------------------------------"<<G4endl;
|
||||
}
|
||||
|
||||
//
|
||||
RE02DetectorConstruction::~RE02DetectorConstruction()
|
||||
{;}
|
||||
|
||||
//
|
||||
G4VPhysicalVolume* RE02DetectorConstruction::Construct()
|
||||
{
|
||||
//=====================
|
||||
// Material Definitions
|
||||
//=====================
|
||||
//
|
||||
//-------- NIST Materials ----------------------------------------------------
|
||||
// Material Information imported from NIST database.
|
||||
//
|
||||
G4NistManager* NISTman = G4NistManager::Instance();
|
||||
G4Material* Air = NISTman->FindOrBuildMaterial("G4_AIR");
|
||||
G4Material* H2O = NISTman->FindOrBuildMaterial("G4_WATER");
|
||||
|
||||
//
|
||||
// Print all the materials defined.
|
||||
G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
|
||||
//============================================================================
|
||||
// Definitions of Solids, Logical Volumes, Physical Volumes
|
||||
//============================================================================
|
||||
|
||||
//-------------
|
||||
// World Volume
|
||||
//-------------
|
||||
|
||||
G4ThreeVector worldSize = G4ThreeVector(200*cm, 200*cm, 200*cm);
|
||||
|
||||
G4Box * solidWorld
|
||||
= new G4Box("world", worldSize.x()/2., worldSize.y()/2., worldSize.z()/2.);
|
||||
G4LogicalVolume * logicWorld
|
||||
= new G4LogicalVolume(solidWorld, Air, "World", 0, 0, 0);
|
||||
|
||||
//
|
||||
// Must place the World Physical volume unrotated at (0,0,0).
|
||||
G4VPhysicalVolume * physiWorld
|
||||
= new G4PVPlacement(0, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
logicWorld, // its logical volume
|
||||
"World", // its name
|
||||
0, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
//---------------
|
||||
// Water Phantom
|
||||
//---------------
|
||||
|
||||
//................................
|
||||
// Mother Volume of Water Phantom
|
||||
//................................
|
||||
|
||||
//-- Default size of water phantom is defined at constructor.
|
||||
G4ThreeVector phantomSize = fphantomSize;
|
||||
|
||||
G4Box * solidPhantom
|
||||
= new G4Box("phantom",
|
||||
phantomSize.x()/2., phantomSize.y()/2., phantomSize.z()/2.);
|
||||
G4LogicalVolume * logicPhantom
|
||||
= new G4LogicalVolume(solidPhantom, H2O, "Phantom", 0, 0, 0);
|
||||
|
||||
G4RotationMatrix* rot=new G4RotationMatrix();
|
||||
//rot->rotateY(30.*deg);
|
||||
G4ThreeVector positionPhantom;
|
||||
//G4VPhysicalVolume * physiPhantom =
|
||||
new G4PVPlacement(rot, // no rotation
|
||||
positionPhantom, // at (x,y,z)
|
||||
logicPhantom, // its logical volume
|
||||
"Phantom", // its name
|
||||
logicWorld, // its mother volume
|
||||
false, // no boolean operations
|
||||
0); // copy number
|
||||
|
||||
//..............................................
|
||||
// Phantom segmentation using Parameterisation
|
||||
//..............................................
|
||||
//
|
||||
// Number of segmentation.
|
||||
// - Default number of segmentation is defined at constructor.
|
||||
G4int nxCells = fNx;
|
||||
G4int nyCells = fNy;
|
||||
G4int nzCells = fNz;
|
||||
|
||||
G4int nCells = nxCells*nyCells*nzCells;
|
||||
G4ThreeVector sensSize;
|
||||
sensSize.setX(phantomSize.x()/(G4double)nxCells);
|
||||
sensSize.setY(phantomSize.y()/(G4double)nyCells);
|
||||
sensSize.setZ(phantomSize.z()/(G4double)nzCells);
|
||||
// i.e Voxel size will be 2.0 x 2.0 x 2.0 mm3 cube by default.
|
||||
//
|
||||
|
||||
//..................................
|
||||
// Voxel solid and logical volumes
|
||||
//..................................
|
||||
//
|
||||
G4Box * solidPhantomSens
|
||||
= new G4Box("phantomSens",
|
||||
sensSize.x()/2., sensSize.y()/2., sensSize.z()/2.);
|
||||
G4LogicalVolume * logicPhantomSens
|
||||
= new G4LogicalVolume(solidPhantomSens, H2O,"PhantomSens",0,0,0);
|
||||
//
|
||||
// Parameterisation for transformation of voxels.
|
||||
// (voxel size is fixed in this example. i.e parameterisation handles
|
||||
// only transfomation of voxels.)
|
||||
RE02PhantomParameterisation* paramPhantom
|
||||
= new RE02PhantomParameterisation(phantomSize/2.,nxCells,nyCells,nzCells);
|
||||
//G4VPhysicalVolume * physiPhantomSens =
|
||||
new G4PVParameterised("PhantomSens", // their name
|
||||
logicPhantomSens, // their logical volume
|
||||
logicPhantom, // Mother logical volume
|
||||
kUndefined, // Are placed along this axis
|
||||
nCells, // Number of cells
|
||||
paramPhantom); // Parameterisation.
|
||||
// Optimization flag is avaiable for,
|
||||
// kUndefined, kXAxis, kYAxis, kZAxis.
|
||||
//
|
||||
|
||||
//================================================
|
||||
// Sensitive detectors : MultiFunctionalDetector
|
||||
//================================================
|
||||
//
|
||||
// Sensitive Detector Manager.
|
||||
G4SDManager* SDman = G4SDManager::GetSDMpointer();
|
||||
//
|
||||
// Sensitive Detector Name
|
||||
G4String phantomSDname = "PhantomSD";
|
||||
|
||||
//------------------------
|
||||
// MultiFunctionalDetector
|
||||
//------------------------
|
||||
//
|
||||
// Define MultiFunctionalDetector with name.
|
||||
G4MultiFunctionalDetector* MFDet = new G4MultiFunctionalDetector(phantomSDname);
|
||||
SDman->AddNewDetector( MFDet ); // Register SD to SDManager.
|
||||
logicPhantomSens->SetSensitiveDetector(MFDet); // Assign SD to the logical volume.
|
||||
|
||||
//---------------------------------------
|
||||
// SDFilter : Sensitive Detector Filters
|
||||
//---------------------------------------
|
||||
//
|
||||
// Particle Filter for Primitive Scorer with filter name(fltName)
|
||||
// and particle name(particleName),
|
||||
// or particle names are given by add("particle name"); method.
|
||||
//
|
||||
G4String fltName,particleName;
|
||||
//
|
||||
//-- proton filter
|
||||
G4SDParticleFilter* protonFilter =
|
||||
new G4SDParticleFilter(fltName="protonFilter", particleName="proton");
|
||||
//
|
||||
//-- electron filter
|
||||
G4SDParticleFilter* electronFilter =
|
||||
new G4SDParticleFilter(fltName="electronFilter");
|
||||
electronFilter->add(particleName="e+"); // accept electrons.
|
||||
electronFilter->add(particleName="e-"); // accept positorons.
|
||||
//
|
||||
//-- charged particle filter
|
||||
G4SDChargedFilter* chargedFilter =
|
||||
new G4SDChargedFilter(fltName="chargedFilter");
|
||||
|
||||
//------------------------
|
||||
// PS : Primitive Scorers
|
||||
//------------------------
|
||||
// Primitive Scorers are used with SDFilters according to your purpose.
|
||||
//
|
||||
//
|
||||
//-- Primitive Scorer for Energy Deposit.
|
||||
// Total, by protons, by electrons.
|
||||
G4String psName;
|
||||
G4PSEnergyDeposit* scorer0 = new G4PSEnergyDeposit(psName="totalEDep");
|
||||
G4PSEnergyDeposit* scorer1 = new G4PSEnergyDeposit(psName="protonEDep");
|
||||
scorer1->SetFilter(protonFilter);
|
||||
|
||||
//
|
||||
//-- Number of Steps for protons
|
||||
G4PSNofStep* scorer2 = new G4PSNofStep(psName="protonNStep");
|
||||
scorer2->SetFilter(protonFilter);
|
||||
|
||||
//
|
||||
//-- CellFlux for charged particles
|
||||
G4PSPassageCellFlux* scorer3 = new G4PSPassageCellFlux(psName="chargedPassCellFlux");
|
||||
G4PSCellFlux* scorer4 = new G4PSCellFlux(psName="chargedCellFlux");
|
||||
G4PSFlatSurfaceFlux* scorer5 = new G4PSFlatSurfaceFlux(psName="chargedSurfFlux",fFlux_InOut);
|
||||
scorer3->SetFilter(chargedFilter);
|
||||
scorer4->SetFilter(chargedFilter);
|
||||
scorer5->SetFilter(chargedFilter);
|
||||
|
||||
//
|
||||
//------------------------------------------------------------
|
||||
// Register primitive scorers to MultiFunctionalDetector
|
||||
//------------------------------------------------------------
|
||||
MFDet->RegisterPrimitive(scorer0);
|
||||
MFDet->RegisterPrimitive(scorer1);
|
||||
MFDet->RegisterPrimitive(scorer2);
|
||||
MFDet->RegisterPrimitive(scorer3);
|
||||
MFDet->RegisterPrimitive(scorer4);
|
||||
MFDet->RegisterPrimitive(scorer5);
|
||||
|
||||
|
||||
//========================
|
||||
// More additional Primitive Scoreres
|
||||
//========================
|
||||
//
|
||||
//--- Surface Current for gamma with energy bin.
|
||||
// This example creates four primitive scorers.
|
||||
// 4 bins with energy --- Primitive Scorer Name
|
||||
// 1. to 10 KeV, gammaSurfCurr000
|
||||
// 10 keV to 100 KeV, gammaSurfCurr001
|
||||
// 100 keV to 1 MeV, gammaSurfCurr002
|
||||
// 1 MeV to 10 MeV. gammaSurfCurr003
|
||||
//
|
||||
char name[16];
|
||||
for ( G4int i = 0; i < 4; i++){
|
||||
std::sprintf(name,"gammaSurfCurr%03d",i);
|
||||
G4String psgName(name);
|
||||
G4double kmin = std::pow(10.,(G4double)i)*keV;
|
||||
G4double kmax = std::pow(10.,(G4double)(i+1))*keV;
|
||||
//-- Particle with kinetic energy filter.
|
||||
G4SDParticleWithEnergyFilter* pkinEFilter =
|
||||
new G4SDParticleWithEnergyFilter(fltName="gammaE filter",kmin,kmax);
|
||||
pkinEFilter->add("gamma"); // Accept only gamma.
|
||||
pkinEFilter->show(); // Show accepting condition to stdout.
|
||||
//-- Surface Current Scorer which scores number of tracks in unit area.
|
||||
G4PSFlatSurfaceCurrent* scorer =
|
||||
new G4PSFlatSurfaceCurrent(psgName,fCurrent_InOut);
|
||||
scorer->SetFilter(pkinEFilter); // Assign filter.
|
||||
MFDet->RegisterPrimitive(scorer); // Register it to MultiFunctionalDetector.
|
||||
}
|
||||
//
|
||||
|
||||
//===============================
|
||||
// Visualization attributes
|
||||
//===============================
|
||||
|
||||
G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
logicWorld ->SetVisAttributes(BoxVisAtt);
|
||||
//logicWorld->SetVisAttributes(G4VisAttributes::Invisible);
|
||||
|
||||
G4VisAttributes* PhantomVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
|
||||
logicPhantom->SetVisAttributes(PhantomVisAtt);
|
||||
|
||||
// If number of segmentation of water phantom is too large,
|
||||
// skip the visualization for those voxels.
|
||||
if ( nCells > 1000 ) {
|
||||
logicPhantomSens->SetVisAttributes(G4VisAttributes::Invisible);
|
||||
}
|
||||
|
||||
return physiWorld;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user