Import Geant4 3.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:55:53 +02:00
parent e7d7193284
commit cfcb558cfe
3050 changed files with 91703 additions and 48310 deletions
@@ -0,0 +1,166 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelAnalysisManager.cc *
// * ------- *
// * *
// * Version: 0.2 *
// * Date: 30/11/00 *
// * Author: A. Pfeiffer, G. Barrand, MG Pia, R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 30.11.2000 M.G. Pia, R. Nartallo
// - Simplification of code: removal of non-Lizard specific code
// - Inheritance directly from the base class G4VAnalysisManager instead
// of the derived class G4AnalysisManager
//
// 15.11.2000 A. Pfeiffer
// - Adaptation to Lizard
//
// 16.10.2000 G. Barrand
// - First implementation of XrayAnalysisManager
// - Provision of code for various AIDA and non-AIDA systems
//
// **********************************************************************
#include "g4std/fstream"
#include "G4ios.hh"
#include "G4Run.hh"
#include "G4Event.hh"
#include "G4Track.hh"
#include "G4VVisManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4SteppingManager.hh"
#include "G4VAnalysisSystem.hh"
#ifdef G4ANALYSIS_USE
#include <IHistogramFactory.h>
#endif
#ifdef G4ANALYSIS_USE_LIZARD
#include <IHistogram1D.h>
#include <IHistogram2D.h>
#include "G4LizardSystem.hh"
#endif
#include "XrayTelAnalysisManager.hh"
#ifndef G4ANALYSIS_USE
XrayTelAnalysisManager::XrayTelAnalysisManager(G4String const& aSystem)
{
}
XrayTelAnalysisManager::~XrayTelAnalysisManager()
{
}
#endif
#ifdef G4ANALYSIS_USE
XrayTelAnalysisManager::XrayTelAnalysisManager(G4String const& aSystem)
:
enteringEnergyHistogram(0),
yzHistogram(0)
{
// The Lizard analysis system is provided here as default
// other analysis systems will be implemented at a later stage
analysisSystem = new G4LizardSystem;
IHistogramFactory* hFactory = analysisSystem->GetHistogramFactory();
if(hFactory) {
// Histogram creation :
enteringEnergyHistogram = hFactory->create1D("Entering energy",100,0,0.5);
// Book the histogram for the 2D position.
// Instead of using a scatter plot, just book enough bins ...
yzHistogram = hFactory->create2D("YZ",200, -50, 50, 200, -50, 50);
}
}
XrayTelAnalysisManager::~XrayTelAnalysisManager()
{
// delete hFactory;
delete enteringEnergyHistogram;
delete yzHistogram;
delete analysisSystem;
}
G4bool XrayTelAnalysisManager::RegisterAnalysisSystem(
G4VAnalysisSystem* )
{
return true;
}
IHistogramFactory* XrayTelAnalysisManager::GetHistogramFactory(
const G4String& aSystem)
{
return hFactory;
}
void XrayTelAnalysisManager::Store(IHistogram* aHistogram,const G4String& aSID)
{
analysisSystem->Store(aHistogram,aSID);
}
void XrayTelAnalysisManager::Plot(IHistogram* aHistogram)
{
analysisSystem->Plot(aHistogram);
}
void XrayTelAnalysisManager::BeginOfRun(){
if(enteringEnergyHistogram)
enteringEnergyHistogram->reset();
if(yzHistogram)
yzHistogram->reset();
}
void XrayTelAnalysisManager::EndOfRun(){
// the following things cannot be done in Run::EndOfRun()
// only now plot the energy of the particles
if(enteringEnergyHistogram) {
Plot(enteringEnergyHistogram);
}
// and store the histograms
if(enteringEnergyHistogram) {
Store(enteringEnergyHistogram,"ekin.vop");
}
if(yzHistogram) {
Store(yzHistogram,"position.vop");
}
}
void XrayTelAnalysisManager::Step(const G4SteppingManager* aSteppingManager) {
if(!aSteppingManager) return;
G4Track* track = aSteppingManager->GetTrack();
G4ThreeVector pos = track->GetPosition();
if(enteringEnergyHistogram) {
enteringEnergyHistogram->fill(track->GetKineticEnergy());
}
if(yzHistogram) {
yzHistogram->fill(pos.y(), pos.z());
Plot(yzHistogram);
}
}
#endif
@@ -0,0 +1,408 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelDetectorConstruction.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope geometry
// - Based on Chandra and XMM models by R Nartallo, P Truscott, F Lei
// and P Arce
//
//
// **********************************************************************
#include "G4UnitsTable.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4Element.hh"
#include "G4ElementTable.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "globals.hh"
#include "XrayTelDetectorConstruction.hh"
XrayTelDetectorConstruction::XrayTelDetectorConstruction()
{
world_x = 2500.*cm;
world_y = 2500.*cm;
world_z = 2500.*cm;
}
XrayTelDetectorConstruction::~XrayTelDetectorConstruction()
{;}
G4VPhysicalVolume* XrayTelDetectorConstruction::Construct( )
{
// Material: Vacuum
G4Material* Vacuum = new G4Material("Vacuum",
1.0 , 1.01*g/mole, 1.0E-25*g/cm3,
kStateGas, 2.73*kelvin, 3.0E-18*pascal );
// Visualization attributes
G4VisAttributes* VisAttWorld= new G4VisAttributes( G4Colour(204/255.,255/255.,255/255.));
// World
G4Box * solidWorld = new G4Box( "world_S", world_x, world_y, world_z );
G4LogicalVolume * logicalWorld = new G4LogicalVolume( solidWorld, // solid
Vacuum, // material
"world_L", // name
0,0,0);
logicalWorld -> SetVisAttributes(VisAttWorld);
// Physical volume
physicalWorld= new G4PVPlacement( 0,
G4ThreeVector(),
"world_P", // name (2nd constructor)
logicalWorld, // logical volume
NULL, // mother volume
false, // no boolean operation
0); // copy number
// Make Invisible
logicalWorld -> SetVisAttributes(G4VisAttributes::Invisible);
// Construct geometry
ConstructTelescope();
ConstructFocalPlane();
return physicalWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// Construct Telescope
void XrayTelDetectorConstruction::ConstructTelescope()
{
// Construct Mirror
// Single shell mirror made of Nickel with thin Gold coating
// Mirror made up of two cones approximating the parabolic section and
// two cones approximating the hyperbolic section
// The centre of the mirror is filled wiith a solid aluminium rod shaped as the
// mirrors, so as to leave a constant BaffleGap distance from the mirror surface
// Build materials
G4Material* Ni = new G4Material("Nickel", 28., 58.6934*g/mole, 8.902*g/cm3);
G4Material* Au = new G4Material("Gold", 79., 196.96654*g/mole, 19.300*g/cm3);
G4Material* Al = new G4Material("Aluminium", 13., 26.98*g/mole, 2.700*g/cm3);
// Visualization attributes
G4VisAttributes* VisAttMirror = new G4VisAttributes(
G4Colour(0/255., 0/255.,255/255.));
G4VisAttributes* VisAttAuCoating = new G4VisAttributes(
G4Colour(255/255., 255/255., 0/255.));
G4VisAttributes* VisAttBaffle = new G4VisAttributes(
G4Colour(128/255., 128/255., 128/255.));
// Rotation Matrix
G4RotationMatrix *rotateMatrix = new G4RotationMatrix();
rotateMatrix -> rotateY(90.*deg);
// Construct cones to make Mirror sections
G4int i;
G4double MirrorEnd[5] = { 34.9995975*cm, 34.8277209*cm, 34.6549918*cm,
34.1347834*cm, 33.6137753*cm };
G4double MirrorPosition[4] = { 772.5*cm, 757.5*cm, 742.5*cm, 727.5*cm };
G4double MirrorSectionLength = 15.0*cm;
G4double MirrorNiThickness = 1.07*mm;
G4double MirrorAuCoating = 50.0e-6*mm;
G4double BaffleGap = 4.0*mm;
G4Cons* MirrorSolid[4];
G4Cons* MirrorAuCoatingSolid[4];
G4Cons* BaffleSolid[4];
G4LogicalVolume* MirrorLogicalVolume[4];
G4LogicalVolume* MirrorAuCoatingLogicalVolume[4];
G4LogicalVolume* BaffleLogicalVolume[4];
for ( i=0; i<4; i++ ) {
// Mirror Nickel base
MirrorSolid[i] = new G4Cons( "Mirror_S",
MirrorEnd[i], MirrorEnd[i] + MirrorNiThickness,
MirrorEnd[i+1], MirrorEnd[i+1] + MirrorNiThickness,
MirrorSectionLength/2, 0*deg, 360.*deg);
MirrorLogicalVolume[i] = new G4LogicalVolume(
MirrorSolid[i], Ni, "Mirror_L", 0, 0, 0 );
MirrorLogicalVolume[i]->SetVisAttributes(VisAttMirror);
// Gold coating on mirror
MirrorAuCoatingSolid[i] = new G4Cons(
"MirrorAuCoating_S",
MirrorEnd[i] - MirrorAuCoating, MirrorEnd[i],
MirrorEnd[i+1] - MirrorAuCoating, MirrorEnd[i+1],
MirrorSectionLength/2, 0*deg, 360.*deg);
MirrorAuCoatingLogicalVolume[i] = new G4LogicalVolume(
MirrorAuCoatingSolid[i],
Au,
"MirrorAuCoating_L",
0, 0, 0 );
MirrorAuCoatingLogicalVolume[i]->SetVisAttributes(VisAttAuCoating);
// Aluminium baffle inside mirror
BaffleSolid[i] = new G4Cons( "Baffle_S",
0, MirrorEnd[i] - BaffleGap,
0, MirrorEnd[i+1] - BaffleGap,
MirrorSectionLength/2, 0*deg, 360.*deg);
BaffleLogicalVolume[i] = new G4LogicalVolume(
BaffleSolid[i], Al, "Baffle_L", 0, 0, 0 );
BaffleLogicalVolume[i]-> SetVisAttributes(VisAttBaffle);
}
// Physical volume
G4VPhysicalVolume* MirrorPhysicalVolume[4];
G4VPhysicalVolume* MirrorAuCoatingPhysicalVolume[4];
G4VPhysicalVolume* BafflePhysicalVolume[4];
for ( i=0; i<4; i++ ) {
MirrorPhysicalVolume[i] = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( MirrorPosition[i], 0.0*cm, 0.0*cm ),
"Mirror_P",
MirrorLogicalVolume[i],
physicalWorld, false, 0 );
MirrorAuCoatingPhysicalVolume[i] = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( MirrorPosition[i], 0.0*cm, 0.0*cm ),
"MirrorAuCoating_P",
MirrorAuCoatingLogicalVolume[i],
physicalWorld, false, 0 );
BafflePhysicalVolume[i] = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( MirrorPosition[i], 0.0*cm, 0.0*cm ),
"Baffle_P",
BaffleLogicalVolume[i],
physicalWorld, false, 0 );
}
// Make Mirror Invisible
for ( i=0; i<4; i++ ) {
// MirrorLogicalVolume[i] -> SetVisAttributes(G4VisAttributes::Invisible);
// MirrorAuCoatingLogicalVolume[i] -> SetVisAttributes(G4VisAttributes::Invisible);
BaffleLogicalVolume[i] -> SetVisAttributes(G4VisAttributes::Invisible);
}
// Construct Optical Bench
// Main Telescope carbon fibre tube and two aluminium end caps
G4int nel;
G4String symbol;
// Elements
G4Element* C = new G4Element("Carbon", symbol="C", 6., 12.011*g/mole);
G4Element* H = new G4Element("Hydrogen",symbol="H", 1., 1.00794*g/mole);
// Materials from Combination
G4Material* Cf = new G4Material("Carbon Fibre", 2.0*g/cm3, nel=2);
Cf->AddElement(C,1);
Cf->AddElement(H,2);
// Visualization attributes
G4VisAttributes* VisAttBench = new G4VisAttributes(
G4Colour(0/255., 200/255., 0/255.));
// Construct Optical bench
G4double BenchThickness = 1.0*cm;
G4double BenchFrontEndMinRadiusOut = MirrorEnd[4] +
( MirrorEnd[3] - MirrorEnd[4] )*7.5/15
+ MirrorNiThickness;
G4double BenchFrontEndMinRadiusIn = MirrorEnd[4] +
( MirrorEnd[3] - MirrorEnd[4] )*7.4/15
+ MirrorNiThickness;
G4double BenchFrontEndMaxRadius = MirrorEnd[4] + MirrorNiThickness + 25.*cm;
G4double BenchBackEndMinRadius = 0.0*cm;
G4double BenchBackEndMaxRadius = MirrorEnd[4] + MirrorNiThickness + 5.*cm;
G4double BenchMainLength;
BenchMainLength = MirrorPosition[3] - BenchThickness;
G4Cons* BenchFrontEndSolid;
G4Tubs* BenchBackEndSolid;
G4Cons* BenchMainSolid;
G4LogicalVolume* BenchFrontEndLogicalVolume;
G4LogicalVolume* BenchBackEndLogicalVolume;
G4LogicalVolume* BenchMainLogicalVolume;
BenchFrontEndSolid = new G4Cons( "BenchFrontEnd_S",
BenchFrontEndMinRadiusOut, BenchFrontEndMaxRadius,
BenchFrontEndMinRadiusIn, BenchFrontEndMaxRadius,
BenchThickness/2, 0*deg, 360.*deg );
BenchFrontEndLogicalVolume = new G4LogicalVolume(
BenchFrontEndSolid, Al, "BenchFrontEnd_L", 0, 0, 0 );
BenchFrontEndLogicalVolume->SetVisAttributes(VisAttBench);
BenchBackEndSolid = new G4Tubs( "BenchBackEnd_S",
BenchBackEndMinRadius, BenchBackEndMaxRadius,
BenchThickness/2, 0*deg, 360.*deg );
BenchBackEndLogicalVolume = new G4LogicalVolume(
BenchBackEndSolid, Al, "BenchBackEnd_L", 0, 0, 0 );
BenchBackEndLogicalVolume->SetVisAttributes(VisAttBench);
BenchMainSolid = new G4Cons( "BenchMain_S",
BenchFrontEndMaxRadius - BenchThickness,
BenchFrontEndMaxRadius,
BenchBackEndMaxRadius - BenchThickness,
BenchBackEndMaxRadius,
BenchMainLength/2, 0*deg, 360.*deg);
BenchMainLogicalVolume = new G4LogicalVolume(
BenchMainSolid, Cf, "BenchMain_L", 0, 0, 0 );
BenchMainLogicalVolume -> SetVisAttributes(VisAttBench);
// Physical volume
G4VPhysicalVolume* BenchFrontEndPhysicalVolume;
G4VPhysicalVolume* BenchBackEndPhysicalVolume;
G4VPhysicalVolume* BenchMainPhysicalVolume;
BenchFrontEndPhysicalVolume = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( MirrorPosition[3] - BenchThickness/2,
0.0*cm, 0.0*cm ),
"BenchFrontEnd_P",
BenchFrontEndLogicalVolume,
physicalWorld, false, 0 );
BenchBackEndPhysicalVolume = new G4PVPlacement(
rotateMatrix,
G4ThreeVector(0.0*cm - BenchThickness/2, 0.0*cm, 0.0*cm ),
"BenchBackEnd_P",
BenchBackEndLogicalVolume,
physicalWorld, false, 0 );
BenchMainPhysicalVolume = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( BenchMainLength/2, 0.0*cm, 0.0*cm ),
"BenchMain_P",
BenchMainLogicalVolume,
physicalWorld, false, 0 );
//--- Make Bench Invisible
// BenchFrontEndLogicalVolume -> SetVisAttributes(G4VisAttributes::Invisible);
// BenchBackEndLogicalVolume -> SetVisAttributes(G4VisAttributes::Invisible);
BenchMainLogicalVolume -> SetVisAttributes(G4VisAttributes::Invisible);
return;
}
// Construct Focal Plane
// Conical Titanium baffle and silicon detector
void XrayTelDetectorConstruction::ConstructFocalPlane()
{
// Elements
G4Material* Ti = new G4Material("Titanium", 22., 47.867*g/mole, 4.54*g/cm3);
G4Material* Si = new G4Material("Silicon", 14., 28.090*g/mole, 2.33*g/cm3);
// Visualization attributes
G4VisAttributes* VisDetectorBaffle = new G4VisAttributes(
G4Colour(190/255., 255/255., 0/255.) );
G4VisAttributes* VisDetector = new G4VisAttributes(
G4Colour(255/255., 0/255., 0/255.) );
// Rotation Matrix
G4RotationMatrix *rotateMatrix = new G4RotationMatrix();
rotateMatrix -> rotateY(90.*deg);
// Construct Detector Baffle
G4double DetectorBaffleLength = 57.2*cm;
G4double DetectorBaffleOuterRadiusIn = 7.1*cm;
G4double DetectorBaffleOuterRadiusOut = 7.35*cm;
G4double DetectorBaffleInnerRadiusIn = 4.55*cm;
G4double DetectorBaffleInnerRadiusOut = 5.75*cm;
G4Cons* DetectorBaffleSolid;
G4LogicalVolume* DetectorBaffleLogicalVolume;
DetectorBaffleSolid = new G4Cons( "DetectorBaffle_S",
DetectorBaffleOuterRadiusIn,
DetectorBaffleOuterRadiusOut,
DetectorBaffleInnerRadiusIn,
DetectorBaffleInnerRadiusOut,
DetectorBaffleLength/2, 0*deg, 360.*deg);
DetectorBaffleLogicalVolume = new G4LogicalVolume(
DetectorBaffleSolid, Ti, "DetectorBaffle_L", 0, 0, 0 );
DetectorBaffleLogicalVolume -> SetVisAttributes( VisDetectorBaffle );
// Physical volume
G4VPhysicalVolume* DetectorBafflePhysicalVolume;
DetectorBafflePhysicalVolume = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( DetectorBaffleLength/2, 0.0*cm, 0.0*cm),
"DetectorBaffle_P",
DetectorBaffleLogicalVolume,
physicalWorld, false, 0 );
//--- Make Invisible
// DetectorBaffleLogicalVolume -> SetVisAttributes( G4VisAttributes::Invisible );
// Construct Detector
G4double DetectorRadius = 32.5*mm;
G4double DetectorThickness = 50e-6*m;
G4Tubs* DetectorSolid;
G4LogicalVolume* DetectorLogicalVolume;
DetectorSolid = new G4Tubs( "Detector_S",
0, DetectorRadius,
DetectorThickness/2, 0*deg, 360.*deg);
DetectorLogicalVolume = new G4LogicalVolume(
DetectorSolid, Si, "Detector_L", 0, 0, 0 );
DetectorLogicalVolume -> SetVisAttributes( VisDetector );
// Physical volume
G4VPhysicalVolume* DetectorPhysicalVolume;
DetectorPhysicalVolume = new G4PVPlacement(
rotateMatrix,
G4ThreeVector( DetectorThickness/2, 0.0*cm, 0.0*cm),
"Detector_P",
DetectorLogicalVolume,
physicalWorld, false, 0 );
//--- Make Invisible
// DetectorLogicalVolume -> SetVisAttributes( G4VisAttributes::Invisible );
return;
}
@@ -0,0 +1,137 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelEventAction.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope event action
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#include "G4ios.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4VVisManager.hh"
#include "G4UImanager.hh"
#include "G4UnitsTable.hh"
#include "XrayTelEventAction.hh"
#include "XrayTelEventActionMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelEventAction::XrayTelEventAction(G4bool* dEvent)
: drawFlag("all"),eventMessenger(NULL), drawEvent(dEvent)
{
eventMessenger = new XrayTelEventActionMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelEventAction::~XrayTelEventAction()
{
delete eventMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelEventAction::BeginOfEventAction(const G4Event* Ev)
{
*drawEvent=false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelEventAction::EndOfEventAction(const G4Event* Ev)
{
if (*drawEvent){
const G4Event* evt = fpEventManager->GetConstCurrentEvent();
G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
G4int n_trajectories = 0;
if ( trajectoryContainer ){
n_trajectories = trajectoryContainer->entries();
}
if ( G4VVisManager::GetConcreteInstance() ) {
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);
trj->ShowTrajectory();
}
}
}
}
@@ -0,0 +1,71 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelEventActionMessenger.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope event action messenger
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#include "G4UIcmdWithAString.hh"
#include "globals.hh"
#include "XrayTelEventAction.hh"
#include "XrayTelEventActionMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelEventActionMessenger::XrayTelEventActionMessenger(XrayTelEventAction* EvAct)
:eventAction(EvAct)
{
DrawCmd = new G4UIcmdWithAString("/event/drawTracks",this);
DrawCmd->SetGuidance("Draw the tracks in the event");
DrawCmd->SetGuidance(" Choice : none, charged, all (default)");
DrawCmd->SetParameterName("choice",true);
DrawCmd->SetDefaultValue("charged");
DrawCmd->SetCandidates("none charged all");
DrawCmd->AvailableForStates(Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelEventActionMessenger::~XrayTelEventActionMessenger()
{
delete DrawCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelEventActionMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{
if(command == DrawCmd)
{eventAction->SetDrawFlag(newValue);}
}
@@ -0,0 +1,257 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelPhysicsList.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope Physics list
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#include "G4ParticleDefinition.hh"
#include "G4ParticleWithCuts.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4ShortLivedConstructor.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "XrayTelPhysicsList.hh"
XrayTelPhysicsList::XrayTelPhysicsList(): G4VUserPhysicsList()
{
// Default cut values
defaultCutValue = 2.0*mm;
cutForGamma = 1.0*micrometer;
cutForElectron = 1.0*micrometer;
cutForProton = 1.0*micrometer;
SetVerboseLevel(1);
}
XrayTelPhysicsList::~XrayTelPhysicsList()
{}
void XrayTelPhysicsList::ConstructParticle()
{
// Here are constructed all particles
ConstructBosons();
ConstructLeptons();
ConstructMesons();
ConstructBaryons();
ConstructAllShortLiveds();
}
// In this method, static member functions should be called for ALL particles to be used.
void XrayTelPhysicsList::ConstructBosons()
{
// pseudo-particles
G4Geantino::GeantinoDefinition();
G4ChargedGeantino::ChargedGeantinoDefinition();
// gamma
G4Gamma::GammaDefinition();
// optical photon
G4OpticalPhoton::OpticalPhotonDefinition();
}
void XrayTelPhysicsList::ConstructLeptons()
{
// leptons
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}
void XrayTelPhysicsList::ConstructMesons()
{
}
void XrayTelPhysicsList::ConstructBaryons()
{
// barions
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
}
void XrayTelPhysicsList::ConstructAllShortLiveds()
{
}
void XrayTelPhysicsList::ConstructProcess()
{
// Transportation, electromagnetic and general processes
AddTransportation();
ConstructEM();
ConstructGeneral();
}
// Here are respective header files for chosen processes
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MultipleScattering.hh"
#include "G4hLowEnergyIonisation.hh"
void XrayTelPhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma")
{
//gamma
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
pmanager->AddDiscreteProcess(new G4ComptonScattering());
pmanager->AddDiscreteProcess(new G4GammaConversion());
}
else if (particleName == "e-")
{
//electron
pmanager->AddProcess(new G4MultipleScattering(),-1, 1,1);
pmanager->AddProcess(new G4eIonisation(), -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung(), -1,-1,3);
}
else if (particleName == "e+")
{
//positron
pmanager->AddProcess(new G4MultipleScattering(),-1, 1,1);
pmanager->AddProcess(new G4eIonisation(), -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung(), -1,-1,3);
pmanager->AddProcess(new G4eplusAnnihilation(), 0,-1,4);
}
else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino"))
{
//all others charged particles except geantino
pmanager->AddProcess(new G4MultipleScattering(),-1,1,1);
G4double demax = 0.05; // try to lose at most 5% of the energy in
// a single step (in limit of large energies)
G4double stmin = 1.e-9 * m; // length of the final step: 10 angstrom
// reproduced angular distribution of TRIM
G4hLowEnergyIonisation* lowEIonisation = new G4hLowEnergyIonisation();
pmanager->AddProcess( lowEIonisation, -1,2,2);
lowEIonisation->SetStepFunction( demax, stmin );
}
}
}
#include "G4Decay.hh"
void XrayTelPhysicsList::ConstructGeneral()
{
G4Decay* theDecayProcess = new G4Decay();
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theDecayProcess->IsApplicable(*particle)) {
pmanager ->AddProcess(theDecayProcess);
pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
void XrayTelPhysicsList::SetCuts()
{
// defaultCutValue you have typed in is used
if (verboseLevel >1){
G4cout << "XrayTelPhysicsList::SetCuts:" << G4endl;
}
// set cut values for gamma at first and for e- second
SetCutValue(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForElectron, "e+");
// set cut values for proton
SetCutValue(cutForProton, "proton");
SetCutValue(cutForProton, "anti_proton");
SetCutValueForOthers(defaultCutValue);
if (verboseLevel >1) {
DumpCutValuesTable();
}
}
void XrayTelPhysicsList::SetCutForGamma(G4double cut)
{
ResetCuts();
cutForGamma = cut;
}
void XrayTelPhysicsList::SetCutForElectron(G4double cut)
{
ResetCuts();
cutForElectron = cut;
}
void XrayTelPhysicsList::SetCutForProton(G4double cut)
{
ResetCuts();
cutForProton = cut;
}
G4double XrayTelPhysicsList::GetCutForGamma() const
{
return cutForGamma;
}
G4double XrayTelPhysicsList::GetCutForElectron() const
{
return cutForElectron;
}
G4double XrayTelPhysicsList::GetCutForProton() const
{
return cutForProton;
}
@@ -0,0 +1,59 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelPrimaryGeneratorAction.cc *
// * ------- *
// * *
// * Version: 0.5 *
// * Date: 15/11/00 *
// * Author: F.Lei *
// * Organisation: DERA, UK *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 15.11.2000 F.Lei
// - New version of PrimaryGeneratorAction using the GPS insead of the
// standard particle gun.
// - The PrimaryGeneratorMessenger is no longer needed.
//
// 06.11.2000 R.Nartallo
// - First implementation of PrimaryGeneratorAction
// - Based on Chandra and XMM models by S Magni and F Lei
//
// **********************************************************************
#include "G4Event.hh"
#include "G4GeneralParticleSource.hh"
#include "XrayTelPrimaryGeneratorAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelPrimaryGeneratorAction::XrayTelPrimaryGeneratorAction()
{
particleGun = new G4GeneralParticleSource ();
}
XrayTelPrimaryGeneratorAction::~XrayTelPrimaryGeneratorAction()
{
delete particleGun;
}
void XrayTelPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
particleGun->GeneratePrimaryVertex(anEvent);
}
@@ -0,0 +1,151 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelRunAction.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 30.11.2000 R. Nartallo
// - Add pre-processor directives to compile without analysis option
//
// 16.11.2000 A. Pfeiffer
// - Implementation of analysis manager call
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope Physics list
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#include "G4Run.hh"
#include "G4UImanager.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
#include "g4std/fstream"
#include "g4std/vector"
#include "XrayTelRunAction.hh"
#include "XrayTelAnalysisManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelRunAction::XrayTelRunAction(G4std::vector<G4double*> *enEnergy,
G4std::vector<G4ThreeVector*> *enDirect,
G4bool* dEvent,
XrayTelAnalysisManager* aAnalysisManager)
:enteringEnergy(enEnergy),
enteringDirection(enDirect),drawEvent(dEvent),
fAnalysisManager(aAnalysisManager)
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelRunAction::~XrayTelRunAction()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelRunAction::BeginOfRunAction(const G4Run* aRun)
{
G4int RunN = aRun->GetRunID();
if ( RunN % 1000 == 0 )
G4cout << "### Run : " << RunN << G4endl;
if (G4VVisManager::GetConcreteInstance()) {
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/vis/clear/view");
UI->ApplyCommand("/vis/draw/current");
}
enteringEnergy->clear();
enteringDirection->clear();
#ifdef G4ANALYSIS_USE
if(fAnalysisManager) fAnalysisManager->BeginOfRun();
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelRunAction::EndOfRunAction(const G4Run* )
{
G4int i;
if (G4VVisManager::GetConcreteInstance())
G4UImanager::GetUIpointer()->ApplyCommand("/vis/show/view");
G4std::ofstream outscat("detector.hist", ios::app);
G4cout << "End of Run summary" << G4endl << G4endl;
G4double totEnteringEnergy = 0.0;
for (i=0;i< enteringEnergy->size();i++)
totEnteringEnergy += *(*enteringEnergy)[i];
G4cout << "Total Entering Detector : " << enteringEnergy->size() << G4endl;
G4cout << "Total Entering Detector Energy : " << totEnteringEnergy << G4endl;
for (i=0;i<enteringEnergy->size();i++) {
outscat << " "
<< *(*enteringEnergy)[i]
<< " "
<< (*enteringDirection)[i]->x()
<< " "
<< (*enteringDirection)[i]->y()
<< " "
<< (*enteringDirection)[i]->z()
<< G4endl;
}
outscat.close();
#ifdef G4ANALYSIS_USE
if(fAnalysisManager) fAnalysisManager->EndOfRun();
#endif
}
@@ -0,0 +1,58 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelStepCut.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope Physics list
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#include "G4Step.hh"
#include "G4VParticleChange.hh"
#include "G4EnergyLossTables.hh"
#include "XrayTelStepCut.hh"
XrayTelStepCut::XrayTelStepCut(const G4String& aName)
: G4VDiscreteProcess(aName),MaxChargedStep(DBL_MAX)
{
if (verboseLevel>0) {
G4cout << GetProcessName() << " is created "<< G4endl;
}
}
XrayTelStepCut::~XrayTelStepCut()
{
}
XrayTelStepCut::XrayTelStepCut(XrayTelStepCut& right)
:G4VDiscreteProcess(right)
{}
void XrayTelStepCut::SetMaxStep(G4double step)
{
MaxChargedStep = step ;
}
@@ -0,0 +1,115 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelSteppingAction.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 30.11.2000 R. Nartallo
// - Add pre-processor directives to compile without analysis option
//
// 16.11.2000 A. Pfeiffer
// - Implementation of analysis manager call
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope Physics list
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#include "G4ios.hh"
#include "G4Track.hh"
#include "G4SteppingManager.hh"
#include "globals.hh"
#include <assert.h>
#include "g4std/fstream"
#include "g4std/iomanip"
#include "g4std/iostream"
#include "g4std/vector"
#include "XrayTelSteppingAction.hh"
#include "XrayTelAnalysisManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelSteppingAction::XrayTelSteppingAction(
G4std::vector<G4double*>* enEnergy,
G4std::vector<G4ThreeVector*>* enDirect,
G4bool* dEvent,
XrayTelAnalysisManager* aAnalysisManager)
: enteringEnergy(enEnergy),
enteringDirection(enDirect),drawEvent(dEvent),
fAnalysisManager(aAnalysisManager)
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelSteppingAction::~XrayTelSteppingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelSteppingAction::UserSteppingAction(const G4Step*)
{
const G4SteppingManager* pSM = fpSteppingManager;
G4Track* fTrack = pSM->GetTrack();
G4Step* fStep = pSM->GetStep();
G4int TrackID = fTrack->GetTrackID();
G4int StepNo = fTrack->GetCurrentStepNumber();
if(StepNo >= 10000) fTrack->SetTrackStatus(fStopAndKill);
G4String volName;
if ( fTrack->GetVolume() )
volName = fTrack->GetVolume()->GetName();
G4String nextVolName;
if ( fTrack->GetNextVolume() )
nextVolName = fTrack->GetNextVolume()->GetName();
G4ThreeVector pos = fTrack->GetPosition();
//--- Entering Detector
if(volName != "Detector_P" && nextVolName == "Detector_P") {
enteringEnergy->push_back ( new G4double (fTrack->GetKineticEnergy()) );
enteringDirection->push_back (new G4ThreeVector (pos));
// now we want to do some analysis at this step ...
// call back to the analysis-manger to do the analysis ...
#ifdef G4ANALYSIS_USE
if(fAnalysisManager) fAnalysisManager->Step(fpSteppingManager);
#endif
*drawEvent = true;
}
}
@@ -0,0 +1,157 @@
// 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.
//
// **********************************************************************
// * *
// * GEANT 4 xray_telescope advanced example *
// * *
// * MODULE: XrayTelVisManager.cc *
// * ------- *
// * *
// * Version: 0.4 *
// * Date: 06/11/00 *
// * Author: R Nartallo *
// * Organisation: ESA/ESTEC, Noordwijk, THe Netherlands *
// * *
// **********************************************************************
//
// CHANGE HISTORY
// --------------
//
// 06.11.2000 R.Nartallo
// - First implementation of xray_telescope Physics list
// - Based on Chandra and XMM models
//
//
// **********************************************************************
#ifdef G4VIS_USE
#include "XrayTelVisManager.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_RAYX
#include "G4RayX.hh"
#endif
#ifdef G4VIS_USE_VRML
#include "G4VRML1.hh"
#include "G4VRML2.hh"
#endif
#ifdef G4VIS_USE_VRMLFILE
#include "G4VRML1File.hh"
#include "G4VRML2File.hh"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
XrayTelVisManager::XrayTelVisManager () {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void XrayTelVisManager::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_RAYX
RegisterGraphicsSystem (new G4RayX);
#endif
#ifdef G4VIS_USE_VRML
RegisterGraphicsSystem (new G4VRML1);
RegisterGraphicsSystem (new G4VRML2);
#endif
#ifdef G4VIS_USE_VRMLFILE
RegisterGraphicsSystem (new G4VRML1File);
RegisterGraphicsSystem (new G4VRML2File);
#endif
if (fVerbose > 0) {
G4cout <<
"\nYou have successfully chosen to use the following graphics systems."
<< G4endl;
PrintAvailableGraphicsSystems ();
}
}
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....