Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
@@ -0,0 +1,73 @@
///\file "analysis/B3aScoreWriter/.README.txt"
///\brief Example B3aScoreWriter README page
/*! \page ExampleB3aScoreWriter Example B3aScoreWriter
This example demonstrates saving the Geant4 scorers hits in form of ntuples in a Root
file using Geant4 analysis tools.
The example is completely based on basic B3a example, the storing hits is activated
in the main () function with instantiating G4ScoreNtupleWriter.
The G4ScoreNtupleWriter and G4ScoreNtupleWriterMessenger classses are provided in
the 'scoreWriter' directory in this example. These classes are fully independent from
the example classes and they can be reused in any Geant4 application.
The Geant4 UI command defined in G4ScoreNtupleWriterMessenger can be used to choose
the output file type, the file name and the level of verbosity:
\verbatim
/score/writerType root
/score/fileName name
/score/writerVerbose 1
\endverbatim
\section B3aScoreWriter_s1 How to build
An additional step is needed when building the example with GNUmake
due to using the extra 'scoreWriter' directory:
\verbatim
% cd path_to_B3aScoreWriter/B3aScoreWriter
% gmake setup
% gmake
\endverbatim
This will copy the files from scoreWriter in the example include and src;
to remove these files:
\verbatim
% gmake clean_setup
\endverbatim
\section B3aScoreWriter_s2 How to run
- Execute exampleB3aExt in the 'interactive mode' with visualization
\verbatim
% ./exampleB3aExt
\endverbatim
and type in the commands from run1.mac line by line:
\verbatim
Idle> /run/initialize
Idle> /control/verbose 2
Idle> /tracking/verbose 2
Idle> /run/beamOn 1
Idle> ...
Idle> exit
\endverbatim
or
\verbatim
Idle> /control/execute run1.mac
....
Idle> exit
\endverbatim
- Execute exampleB3aExt in the 'batch' mode from macro files
(without visualization)
\verbatim
% ./exampleB3aExt run2.mac
% ./exampleB3aExt exampleB3aExt.in > exampleB3.out
\endverbatim
*/
@@ -0,0 +1,65 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(B3aScoreWriter)
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/scoreWriter/include
${Geant4_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add scoreWriter subdirectory
#
add_subdirectory(scoreWriter)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(exampleB3aExt exampleB3aExt.cc ${sources} ${headers})
target_link_libraries(exampleB3aExt scoreWriter ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build B3aScoreWriter. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(B3aScoreWriter_SCRIPTS
exampleB3aExt.in init_vis.mac vis.mac run1.mac run2.mac
)
foreach(_script ${B3aScoreWriter_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS exampleB3aExt DESTINATION bin)
@@ -0,0 +1,32 @@
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := exampleB3aExt
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: setup clean_setup all
all: lib bin
setup:
@echo "Copying files from scoreWriter"
@cp -rp scoreWriter/include/* include
@cp -rp scoreWriter/src/* src
clean_setup:
@echo "Removing files copied from scoreWriter"
@rm -fr include/G4ScoreNtupleWriter*
@rm -fr src/G4ScoreNtupleWriter*
include $(G4INSTALL)/config/binmake.gmk
CPPFLAGS += -I./scoreWriter/include
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
@@ -0,0 +1,18 @@
--------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example B3aScoreWriter History file
-----------------------------------
This file should be used by the G4 example coordinator to briefly
summarize all major modifications introduced in the code and keep
track of all tags.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
30 October 2018, Ivana Hrivnacova (B3aScoreWriter-V10-04-00)
- First version
@@ -0,0 +1,62 @@
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Example B3aScoreWriter
----------------------
This example demonstrates saving the Geant4 scorers hits in form of ntuples in a Root
file using Geant4 analysis tools.
The example is completely based on basic B3a example, the storing hits is activated
in the main () function with instantiating G4ScoreNtupleWriter.
The G4ScoreNtupleWriter and G4ScoreNtupleWriterMessenger classses are provided in
the 'scoreWriter' directory in this example. These classes are fully independent from
the example classes and they can be reused in any Geant4 application.
The Geant4 UI command defined in G4ScoreNtupleWriterMessenger can be used to choose
the output file type, the file name and the level of verbosity:
/score/writerType root
/score/fileName name
/score/writerVerbose 1
How to build
---------------
An additional step is needed when building the example with GNUmake
due to using the extra 'scoreWriter' directory:
% cd path_to_B3aScoreWriter/B3aScoreWriter
% gmake setup
% gmake
This will copy the files from scoreWriter in the example include and src;
to remove these files:
% gmake clean_setup
How to run
-------------
- Execute exampleB3aExt in the 'interactive mode' with visualization
% ./exampleB3aExt
and type in the commands from run1.mac line by line:
Idle> /run/initialize
Idle> /control/verbose 2
Idle> /tracking/verbose 2
Idle> /run/beamOn 1
Idle> ...
Idle> exit
or
Idle> /control/execute run1.mac
....
Idle> exit
- Execute exampleB3aExt in the 'batch' mode from macro files
(without visualization)
% ./exampleB3aExt run2.mac
% ./exampleB3aExt exampleB3aExt.in > exampleB3.out
See the B3 example README for the further documentation of the basic B3 example.
@@ -0,0 +1,126 @@
//
// ********************************************************************
// * 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 exampleB3a.cc
/// \brief Main program of the B3a example
#include "G4Types.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "G4UImanager.hh"
#include "G4ScoreNtupleWriter.hh"
#include "Randomize.hh"
#include "B3DetectorConstruction.hh"
#include "B3PhysicsList.hh"
#include "B3aActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv)
{
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = 0;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
// Choose the Random engine
//
G4Random::setTheEngine(new CLHEP::RanecuEngine);
// Construct the default run manager
//
#ifdef G4MULTITHREADED
G4MTRunManager* runManager = new G4MTRunManager;
#else
G4RunManager* runManager = new G4RunManager;
#endif
// Set mandatory initialization classes
//
runManager->SetUserInitialization(new B3DetectorConstruction);
//
runManager->SetUserInitialization(new B3PhysicsList);
// Set user action initialization
//
runManager->SetUserInitialization(new B3aActionInitialization());
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// Activate score ntuple writer
// The output type and the verbose level can be also set via UI commands
// /score/writerType csv|root|xml
// /score/writerVerbose level
G4ScoreNtupleWriter scoreNtupleWriter;
scoreNtupleWriter.SetOutputType("root");
scoreNtupleWriter.SetVerboseLevel(1);
// Process macro or start UI session
//
if ( ! ui ) {
// batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
}
else {
// interactive mode
UImanager->ApplyCommand("/control/execute init_vis.mac");
ui->SessionStart();
delete ui;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
// delete scoreNtupleWriter;
delete visManager;
delete runManager;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
@@ -0,0 +1,12 @@
#
# Macro file for example B3 test
#
/score/writerType root
/score/writerVerbose 1
#
/run/initialize
#
/control/verbose 2
#
/run/printProgress 1000
/run/beamOn 10000
@@ -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 B3DetectorConstruction.hh
/// \brief Definition of the B3DetectorConstruction class
#ifndef B3DetectorConstruction_h
#define B3DetectorConstruction_h 1
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
/// Detector construction class to define materials and geometry.
///
/// Crystals are positioned in Ring, with an appropriate rotation matrix.
/// Several copies of Ring are placed in the full detector.
class B3DetectorConstruction : public G4VUserDetectorConstruction
{
public:
B3DetectorConstruction();
virtual ~B3DetectorConstruction();
public:
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
private:
void DefineMaterials();
G4bool fCheckOverlaps;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -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 B3PhysicsList.hh
/// \brief Definition of the B3PhysicsList class
#ifndef B3PhysicsList_h
#define B3PhysicsList_h 1
#include "G4VModularPhysicsList.hh"
/// Modular physics list
///
/// It includes the folowing physics builders
/// - G4DecayPhysics
/// - G4RadioactiveDecayPhysics
/// - G4EmStandardPhysics
class B3PhysicsList: public G4VModularPhysicsList
{
public:
B3PhysicsList();
virtual ~B3PhysicsList();
virtual void SetCuts();
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,62 @@
//
// ********************************************************************
// * 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 B3PrimaryGeneratorAction.hh
/// \brief Definition of the B3PrimaryGeneratorAction class
#ifndef B3PrimaryGeneratorAction_h
#define B3PrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
#include "G4ParticleGun.hh"
#include "globals.hh"
class G4ParticleGun;
class G4Event;
/// The primary generator action class with particle gum.
///
/// It defines an ion (F18), at rest, randomly distribued within a zone
/// in a patient defined in GeneratePrimaries(). Ion F18 can be changed
/// with the G4ParticleGun commands (see run2.mac).
class B3PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
B3PrimaryGeneratorAction();
virtual ~B3PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event*);
const G4ParticleGun* GetParticleGun() const { return fParticleGun; }
private:
G4ParticleGun* fParticleGun;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,53 @@
//
// ********************************************************************
// * 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 B3StackingAction.hh
/// \brief Definition of the B3StackingAction class
#ifndef B3StackingAction_h
#define B3StackingAction_h 1
#include "G4UserStackingAction.hh"
#include "globals.hh"
/// Stacking action class : manage the newly generated particles
///
/// One wishes do not track secondary neutrino.Therefore one kills it
/// immediately, before created particles will put in a stack.
class B3StackingAction : public G4UserStackingAction
{
public:
B3StackingAction();
virtual ~B3StackingAction();
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*);
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,55 @@
//
// ********************************************************************
// * 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 B3aActionInitialization.hh
/// \brief Definition of the B3aActionInitialization class
#ifndef B3aActionInitialization_h
#define B3aActionInitialization_h 1
#include "G4VUserActionInitialization.hh"
/// Action initialization class.
///
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class B3aActionInitialization : public G4VUserActionInitialization
{
public:
B3aActionInitialization();
virtual ~B3aActionInitialization();
virtual void BuildForMaster() const;
virtual void Build() const;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -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 B3aEventAction.hh
/// \brief Definition of the B3aEventAction class
#ifndef B3aEventAction_h
#define B3aEventAction_h 1
#include "G4UserEventAction.hh"
#include "globals.hh"
class B3aRunAction;
/// Event action class
///
/// In EndOfEventAction() there is collected information event per event
/// from Hits Collections, and accumulated statistic for
/// B3RunAction::EndOfRunAction().
class B3aEventAction : public G4UserEventAction
{
public:
B3aEventAction(B3aRunAction* runAction);
virtual ~B3aEventAction();
virtual void BeginOfEventAction(const G4Event*);
virtual void EndOfEventAction(const G4Event*);
private:
B3aRunAction* fRunAction;
G4int fCollID_cryst;
G4int fCollID_patient;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,59 @@
//
// ********************************************************************
// * 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 B3aRunAction.hh
/// \brief Definition of the B3aRunAction class
#ifndef B3aRunAction_h
#define B3aRunAction_h 1
#include "G4UserRunAction.hh"
#include "G4Accumulable.hh"
#include "globals.hh"
/// Run action class
class B3aRunAction : public G4UserRunAction
{
public:
B3aRunAction();
virtual ~B3aRunAction();
virtual void BeginOfRunAction(const G4Run*);
virtual void EndOfRunAction(const G4Run*);
void CountEvent() { fGoodEvents += 1; };
void SumDose(G4double dose) { fSumDose += dose; };
private:
G4Accumulable<G4int> fGoodEvents;
G4Accumulable<G4double> fSumDose;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -0,0 +1,17 @@
# Macro file for the initialization of example B3
# in interactive session
#
# Set some default verbose
#
/control/verbose 2
/control/saveHistory
/run/verbose 2
#
# Change the default number of threads (in multi-threaded mode)
#/run/numberOfThreads 4
#
# Initialize kernel
/run/initialize
#
# Visualization setting
/control/execute vis.mac
@@ -0,0 +1,16 @@
#
# Macro file of "exampleB3.cc"
#
# Change the default number of workers (in multi-threading mode)
#/run/numberOfWorkers 4
#
# Initialize kernel
/run/initialize
#
/control/verbose 2
/tracking/verbose 2
#
/run/beamOn 1
#
/tracking/verbose 0
/run/beamOn 20
@@ -0,0 +1,23 @@
#
# Macro file of "exampleB3.cc"
# To be run preferably in batch, without graphics:
# % exampleB3 run3.mac
#
/score/writerType root
/score/writerVerbose 1
#
#/run/numberOfWorkers 4
/run/initialize
#
/control/verbose 2
/run/printProgress 10000
#
/run/beamOn 40000
#
# change beta source
#
/gun/particle ion
/gun/ion 6 11
/score/writerFileName scoring_run2.root
#
/run/beamOn 40000
@@ -0,0 +1,34 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(scoreWriter)
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the library
#
add_library(scoreWriter ${sources} ${headers})
target_link_libraries(scoreWriter ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
# and the library to 'lib' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS scoreWriter DESTINATION lib)
@@ -0,0 +1,98 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Ivana Hrivnacova, 30/10/2018 (ivana@ipno.in2p3.fr)
#ifndef G4ScoreNtupleWriter_h
#define G4ScoreNtupleWriter_h 1
#include "G4VScoreNtupleWriter.hh"
#include "G4HCofThisEvent.hh"
#include "G4AnalysisUtilities.hh"
#include "G4Threading.hh"
#include "globals.hh"
#include <memory>
class G4HCofThisEvent;
class G4VAnalysisManager;
class G4ScoreNtupleWriterMessenger;
// class description:
//
// This class implements storing hits collections of G4THitsMap<G4double>
// type vith Geant4 analysis tools.
//
// An ntuple with three columns is created for each primitive scorer:
// int column - eventNumber
// int column - copyNumber
// double column - scored value
class G4ScoreNtupleWriter : public G4VScoreNtupleWriter
{
public:
G4ScoreNtupleWriter(const G4String& outputType = "none");
virtual ~G4ScoreNtupleWriter();
// methods
virtual G4bool Book(G4HCofThisEvent* hce);
virtual void OpenFile();
virtual void Fill(G4HCofThisEvent* hce, G4int eventNumber);
virtual void Write();
// set methods
void SetOutputType(const G4String& outputTypeName);
void SetFileName(const G4String& fileName);
void SetVerboseLevel(G4int value);
// get methods
G4AnalysisOutput GetOutputType() const;
G4String GetFileName() const { return fFileName; }
G4int GetVerboseLevel() const { return fVerboseLevel; }
protected:
// methods
virtual G4VScoreNtupleWriter* CreateInstance() const;
private:
// methods
void CreateAnalysisManager();
// data members
G4ScoreNtupleWriterMessenger* fMessenger;
std::vector<G4int> fHCIds;
G4VAnalysisManager* fAnalysisManager;
G4String fOutputTypeName;
G4String fFileName;
G4int fVerboseLevel;
G4bool fHasAnalysisManager;
G4bool fHasAnalysisFile;
G4bool fIsBooked;
G4bool fIsInitialized;
G4int fFirstNtupleId;
};
#endif
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Ivana Hrivnacova, 30/10/2018 (ivana@ipno.in2p3.fr)
#ifndef G4ScoreNtupleWriterMessenger_h
#define G4ScoreNtupleWriterMessenger_h 1
#include "G4UImessenger.hh"
class G4ScoreNtupleWriter;
class G4UIdirectory;
class G4UIcmdWithoutParameter;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
// class description:
//
// This is a concrete class of G4UImessenger which handles the commands for
// G4ScoreNtupleWriter. This class has the following commands:
// /score/writerFileName filename
// /score/writerType csv|root|xml|none
// /score/writerVerbose value
//
class G4ScoreNtupleWriterMessenger: public G4UImessenger
{
public:
G4ScoreNtupleWriterMessenger(G4ScoreNtupleWriter* scoreNtupleWriter);
~G4ScoreNtupleWriterMessenger();
void SetNewValue(G4UIcommand * command,G4String newValues);
private:
G4ScoreNtupleWriter* fScoreNtupleWriter;
// G4UIdirectory* fDirectory;
G4UIcmdWithAString* fWriterTypeCmd;
G4UIcmdWithAString* fWriterFileNameCmd;
G4UIcmdWithAnInteger* fWriterVerboseCmd;
};
#endif
@@ -0,0 +1,342 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Ivana Hrivnacova, 30/10/2018 (ivana@ipno.in2p3.fr)
// ---------------------------------------------------------------------
#include "G4ScoreNtupleWriter.hh"
#include "G4ScoreNtupleWriterMessenger.hh"
#include "G4THitsMap.hh"
#include "g4csv.hh"
#include "g4root.hh"
#include "g4xml.hh"
#include "G4Threading.hh"
//_____________________________________________________________________________
//
// ctor, dtor
//
//_____________________________________________________________________________
G4ScoreNtupleWriter::G4ScoreNtupleWriter(const G4String& outputType)
: G4VScoreNtupleWriter(),
fMessenger(nullptr),
fHCIds(),
fAnalysisManager(nullptr),
fOutputTypeName(outputType),
fFileName("scoring"),
fVerboseLevel(1),
fHasAnalysisManager(false),
fHasAnalysisFile(false),
fIsBooked(false),
fIsInitialized(false),
fFirstNtupleId(0)
{
// if ( G4Threading::IsMasterThread() ) {
fMessenger = new G4ScoreNtupleWriterMessenger(this);
// }
}
//_____________________________________________________________________________
G4ScoreNtupleWriter::~G4ScoreNtupleWriter()
{
if ( fHasAnalysisManager ) {
delete fAnalysisManager;
}
delete fMessenger;
}
//
// private methods
//
//_____________________________________________________________________________
void G4ScoreNtupleWriter::CreateAnalysisManager()
{
if ( fAnalysisManager ) return;
switch ( GetOutputType() ) {
case G4AnalysisOutput::kCsv:
// create Csv analysis manager
if ( ! G4CsvAnalysisManager::IsInstance() ) fHasAnalysisManager = true;
fAnalysisManager = G4CsvAnalysisManager::Instance();
break;
case G4AnalysisOutput::kRoot:
// create Root analysis manager
if ( ! G4RootAnalysisManager::IsInstance() ) fHasAnalysisManager = true;
fAnalysisManager = G4RootAnalysisManager::Instance();
break;
case G4AnalysisOutput::kXml:
// create Xml analysis manager
if ( ! G4XmlAnalysisManager::IsInstance() ) fHasAnalysisManager = true;
fAnalysisManager = G4XmlAnalysisManager::Instance();
break;
case G4AnalysisOutput::kNone:
// do nothing
break;
}
fAnalysisManager->SetVerboseLevel(fVerboseLevel);
}
//
// protected methods
//
//_____________________________________________________________________________
G4VScoreNtupleWriter* G4ScoreNtupleWriter::CreateInstance() const
{
auto instance = new G4ScoreNtupleWriter();
instance->SetOutputType(fOutputTypeName);
instance->SetFileName(fFileName);
instance->SetVerboseLevel(fVerboseLevel);
return instance;
}
//
// public methods
//
//_____________________________________________________________________________
G4bool G4ScoreNtupleWriter::Book(G4HCofThisEvent* hce)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- G4ScoreNtupleWriter::Book" << G4endl;
}
#endif
if ( ! hce) return false;
// book collection ID if DoubleHitsMap
if (fHCIds.size() == 0) {
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- going to fill fHCIds " << G4endl;
}
#endif
for (G4int i=0; i<hce->GetNumberOfCollections(); ++i) {
auto hitsMap
= dynamic_cast<G4THitsMap<G4double>*>(hce->GetHC(i));
if ( hitsMap ) {
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- adding hcID = " << i << G4endl;
}
#endif
fHCIds.push_back(i);
}
}
}
// Create analysis manager
if ( fHCIds.size() ) {
CreateAnalysisManager();
}
// Create ntuples (only once)
if ( ! fIsInitialized ) {
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "-- going to create ntuples " << G4endl;
}
#endif
auto first = true;
for (auto id : fHCIds) {
auto hitsMap
= static_cast<G4THitsMap<G4double>*>(hce->GetHC(id));
// Create ntuple for this primitive
G4String ntupleName(hitsMap->GetSDname());
ntupleName.append("_");
ntupleName.append(hitsMap->GetName());
G4int ntupleId
= fAnalysisManager->CreateNtuple(ntupleName, ntupleName);
if ( first ) {
fFirstNtupleId = ntupleId;
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "-- set first ntuple Id " << fFirstNtupleId << G4endl;
}
#endif
first = false;
}
G4String colName(ntupleName);
colName.append("_eventId");
fAnalysisManager->CreateNtupleIColumn(colName);
colName = ntupleName;
colName.append("_cell");
fAnalysisManager->CreateNtupleIColumn(colName);
colName = ntupleName;
colName.append("_score");
fAnalysisManager->CreateNtupleDColumn(colName);
fAnalysisManager->FinishNtuple();
fIsBooked = true;
}
fIsInitialized = true;
}
return fIsBooked;
}
//_____________________________________________________________________________
void G4ScoreNtupleWriter::OpenFile()
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- G4ScoreNtupleWriter::OpenFile" << G4endl;
}
#endif
if ( fAnalysisManager->IsOpenFile() ) return;
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- G4ScoreNtupleWriter::OpenFile executing" << G4endl;
}
#endif
if ( fAnalysisManager->GetFileName() == "" ) {
fAnalysisManager->SetFileName(fFileName);
}
fAnalysisManager->OpenFile();
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- G4ScoreNtupleWriter::OpenFile isOpenFile: "
<< fAnalysisManager->IsOpenFile() << G4endl;
}
#endif
fHasAnalysisFile = fAnalysisManager->IsOpenFile();
}
//_____________________________________________________________________________
void G4ScoreNtupleWriter::Fill(G4HCofThisEvent* hce, G4int eventNumber)
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- start G4ScoreNtupleWriter::Fill" << G4endl;
}
#endif
auto counter = 0;
for (auto id : fHCIds) {
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "in loop over fHCIds, counter " << counter << G4endl;
}
#endif
auto hitsMap
= static_cast<G4THitsMap<G4double>*>(hce->GetHC(id));
//G4cout << eventNumber << ".. go to fill ntuple " << counter + fFirstNtupleId << G4endl;
// fill hits in ntuple
std::map<G4int, G4double*>::iterator it;
for ( it = hitsMap->GetMap()->begin(); it != hitsMap->GetMap()->end(); it++ ) {
fAnalysisManager->FillNtupleIColumn(counter + fFirstNtupleId, 0, eventNumber);
fAnalysisManager->FillNtupleIColumn(counter + fFirstNtupleId, 1, it->first);
fAnalysisManager->FillNtupleDColumn(counter + fFirstNtupleId, 2, *(it->second));
fAnalysisManager->AddNtupleRow(counter + fFirstNtupleId);
}
counter++;
}
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- done G4ScoreNtupleWriter::Fill" << G4endl;
}
#endif
}
//_____________________________________________________________________________
void G4ScoreNtupleWriter::Write()
{
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- start G4ScoreNtupleWriter::Write" << G4endl;
}
#endif
if ( fHasAnalysisFile ) {
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- sG4ScoreNtupleWriter::Write - has file" << G4endl;
}
#endif
fAnalysisManager->Write();
fAnalysisManager->CloseFile();
fAnalysisManager->SetFileName("");
}
#ifdef G4VERBOSE
if ( fVerboseLevel > 1 ) {
G4cout << "--- done G4ScoreNtupleWriter::Write" << G4endl;
}
#endif
}
//_____________________________________________________________________________
void G4ScoreNtupleWriter::SetOutputType(const G4String& outputTypeName)
{
if ( fAnalysisManager ) {
G4ExceptionDescription description;
description
<< "Cannot set output type. The analysis manager has not been created.";
G4Exception("G4HitsNtupleWriter::SetOutputType", "", JustWarning, description);
return;
}
fOutputTypeName = outputTypeName;
}
//_____________________________________________________________________________
void G4ScoreNtupleWriter::SetVerboseLevel(G4int value)
{
fVerboseLevel = value;
if ( fAnalysisManager ) {
fAnalysisManager->SetVerboseLevel(value);
}
}
//_____________________________________________________________________________
void G4ScoreNtupleWriter::SetFileName(const G4String& fileName)
{
fFileName = fileName;
}
//_____________________________________________________________________________
G4AnalysisOutput G4ScoreNtupleWriter::GetOutputType() const
{
return G4Analysis::GetOutput(fOutputTypeName);
}
@@ -0,0 +1,101 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// Author: Ivana Hrivnacova, 30/10/2018 (ivana@ipno.in2p3.fr)
// ---------------------------------------------------------------------
#include "G4ScoreNtupleWriterMessenger.hh"
#include "G4ScoreNtupleWriter.hh"
#include "G4UImanager.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4AnalysisUtilities.hh"
G4ScoreNtupleWriterMessenger::G4ScoreNtupleWriterMessenger(
G4ScoreNtupleWriter* scoreNtupleWriter)
: G4UImessenger(),
fScoreNtupleWriter(scoreNtupleWriter),
// fDirectory(nullptr),
fWriterTypeCmd(nullptr),
fWriterFileNameCmd(nullptr),
fWriterVerboseCmd(nullptr)
{
// Create command directory and commands only if they do not exist.
// To be improved: G4UImanager::FindDirectory cannot be used
// as it is declared private.
// if ( ! G4UImanager::GetUIpointer()->FindDirectory("/score") ) {
// fDirectory = new G4UIdirectory("/score/");
// fDirectory->SetGuidance("Interactive scoring commands.");
// }
fWriterTypeCmd = new G4UIcmdWithAString("/score/writerType",this);
fWriterTypeCmd->SetGuidance( "Set the ntuple writer output file type.");
fWriterTypeCmd->SetParameterName("outputType",false);
G4String candidates;
for ( auto candidate :
{ G4AnalysisOutput::kCsv,
G4AnalysisOutput::kRoot,
G4AnalysisOutput::kXml,
G4AnalysisOutput::kNone } ) {
candidates += G4Analysis::GetOutputName(candidate);
candidates += " ";
}
fWriterTypeCmd->SetCandidates(candidates);
fWriterTypeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fWriterFileNameCmd = new G4UIcmdWithAString("/score/writerFileName",this);
fWriterFileNameCmd->SetGuidance( "Set the ntuple writer output file name.");
fWriterFileNameCmd->SetParameterName("outputFileName",false);
fWriterFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fWriterVerboseCmd = new G4UIcmdWithAnInteger("/score/writerVerbose",this);
fWriterVerboseCmd->SetGuidance("Set the ntuple writer verbose level.");
fWriterVerboseCmd->SetParameterName("writerVerbose",false);
fWriterTypeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
G4ScoreNtupleWriterMessenger::~G4ScoreNtupleWriterMessenger()
{
delete fWriterTypeCmd;
delete fWriterFileNameCmd;
delete fWriterVerboseCmd;
// delete fDirectory;
}
void G4ScoreNtupleWriterMessenger::SetNewValue(G4UIcommand * command,G4String newVal)
{
if ( command==fWriterTypeCmd ) {
fScoreNtupleWriter->SetOutputType(newVal);
}
else if ( command==fWriterFileNameCmd ) {
fScoreNtupleWriter->SetFileName(newVal);
}
else if ( command==fWriterVerboseCmd ) {
fScoreNtupleWriter->SetVerboseLevel(fWriterVerboseCmd->GetNewIntValue(newVal));
}
}
@@ -0,0 +1,273 @@
//
// ********************************************************************
// * 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 B3DetectorConstruction.cc
/// \brief Implementation of the B3DetectorConstruction class
#include "B3DetectorConstruction.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4RotationMatrix.hh"
#include "G4Transform3D.hh"
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4PSEnergyDeposit.hh"
#include "G4PSDoseDeposit.hh"
#include "G4VisAttributes.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3DetectorConstruction::B3DetectorConstruction()
: G4VUserDetectorConstruction(),
fCheckOverlaps(true)
{
DefineMaterials();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3DetectorConstruction::~B3DetectorConstruction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3DetectorConstruction::DefineMaterials()
{
G4NistManager* man = G4NistManager::Instance();
G4bool isotopes = false;
G4Element* O = man->FindOrBuildElement("O" , isotopes);
G4Element* Si = man->FindOrBuildElement("Si", isotopes);
G4Element* Lu = man->FindOrBuildElement("Lu", isotopes);
G4Material* LSO = new G4Material("Lu2SiO5", 7.4*g/cm3, 3);
LSO->AddElement(Lu, 2);
LSO->AddElement(Si, 1);
LSO->AddElement(O , 5);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B3DetectorConstruction::Construct()
{
// Gamma detector Parameters
//
G4double cryst_dX = 6*cm, cryst_dY = 6*cm, cryst_dZ = 3*cm;
G4int nb_cryst = 32;
G4int nb_rings = 9;
//
G4double dPhi = twopi/nb_cryst, half_dPhi = 0.5*dPhi;
G4double cosdPhi = std::cos(half_dPhi);
G4double tandPhi = std::tan(half_dPhi);
//
G4double ring_R1 = 0.5*cryst_dY/tandPhi;
G4double ring_R2 = (ring_R1+cryst_dZ)/cosdPhi;
//
G4double detector_dZ = nb_rings*cryst_dX;
//
G4NistManager* nist = G4NistManager::Instance();
G4Material* default_mat = nist->FindOrBuildMaterial("G4_AIR");
G4Material* cryst_mat = nist->FindOrBuildMaterial("Lu2SiO5");
//
// World
//
G4double world_sizeXY = 2.4*ring_R2;
G4double world_sizeZ = 1.2*detector_dZ;
G4Box* solidWorld =
new G4Box("World", //its name
0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size
G4LogicalVolume* logicWorld =
new G4LogicalVolume(solidWorld, //its solid
default_mat, //its material
"World"); //its name
G4VPhysicalVolume* physWorld =
new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicWorld, //its logical volume
"World", //its name
0, //its mother volume
false, //no boolean operation
0, //copy number
fCheckOverlaps); // checking overlaps
//
// ring
//
G4Tubs* solidRing =
new G4Tubs("Ring", ring_R1, ring_R2, 0.5*cryst_dX, 0., twopi);
G4LogicalVolume* logicRing =
new G4LogicalVolume(solidRing, //its solid
default_mat, //its material
"Ring"); //its name
//
// define crystal
//
G4double gap = 0.5*mm; //a gap for wrapping
G4double dX = cryst_dX - gap, dY = cryst_dY - gap;
G4Box* solidCryst = new G4Box("crystal", dX/2, dY/2, cryst_dZ/2);
G4LogicalVolume* logicCryst =
new G4LogicalVolume(solidCryst, //its solid
cryst_mat, //its material
"CrystalLV"); //its name
// place crystals within a ring
//
for (G4int icrys = 0; icrys < nb_cryst ; icrys++) {
G4double phi = icrys*dPhi;
G4RotationMatrix rotm = G4RotationMatrix();
rotm.rotateY(90*deg);
rotm.rotateZ(phi);
G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi),0.);
G4ThreeVector position = (ring_R1+0.5*cryst_dZ)*uz;
G4Transform3D transform = G4Transform3D(rotm,position);
new G4PVPlacement(transform, //rotation,position
logicCryst, //its logical volume
"crystal", //its name
logicRing, //its mother volume
false, //no boolean operation
icrys, //copy number
fCheckOverlaps); // checking overlaps
}
//
// full detector
//
G4Tubs* solidDetector =
new G4Tubs("Detector", ring_R1, ring_R2, 0.5*detector_dZ, 0., twopi);
G4LogicalVolume* logicDetector =
new G4LogicalVolume(solidDetector, //its solid
default_mat, //its material
"Detector"); //its name
//
// place rings within detector
//
G4double OG = -0.5*(detector_dZ + cryst_dX);
for (G4int iring = 0; iring < nb_rings ; iring++) {
OG += cryst_dX;
new G4PVPlacement(0, //no rotation
G4ThreeVector(0,0,OG), //position
logicRing, //its logical volume
"ring", //its name
logicDetector, //its mother volume
false, //no boolean operation
iring, //copy number
fCheckOverlaps); // checking overlaps
}
//
// place detector in world
//
new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicDetector, //its logical volume
"Detector", //its name
logicWorld, //its mother volume
false, //no boolean operation
0, //copy number
fCheckOverlaps); // checking overlaps
//
// patient
//
G4double patient_radius = 8*cm;
G4double patient_dZ = 10*cm;
G4Material* patient_mat = nist->FindOrBuildMaterial("G4_BRAIN_ICRP");
G4Tubs* solidPatient =
new G4Tubs("Patient", 0., patient_radius, 0.5*patient_dZ, 0., twopi);
G4LogicalVolume* logicPatient =
new G4LogicalVolume(solidPatient, //its solid
patient_mat, //its material
"PatientLV"); //its name
//
// place patient in world
//
new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicPatient, //its logical volume
"Patient", //its name
logicWorld, //its mother volume
false, //no boolean operation
0, //copy number
fCheckOverlaps); // checking overlaps
// Visualization attributes
//
logicRing->SetVisAttributes (G4VisAttributes::GetInvisible());
logicDetector->SetVisAttributes (G4VisAttributes::GetInvisible());
// Print materials
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
//always return the physical World
//
return physWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3DetectorConstruction::ConstructSDandField()
{
G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
// declare crystal as a MultiFunctionalDetector scorer
//
G4MultiFunctionalDetector* cryst = new G4MultiFunctionalDetector("crystal");
G4SDManager::GetSDMpointer()->AddNewDetector(cryst);
G4VPrimitiveScorer* primitiv1 = new G4PSEnergyDeposit("edep");
cryst->RegisterPrimitive(primitiv1);
SetSensitiveDetector("CrystalLV",cryst);
// declare patient as a MultiFunctionalDetector scorer
//
G4MultiFunctionalDetector* patient = new G4MultiFunctionalDetector("patient");
G4SDManager::GetSDMpointer()->AddNewDetector(patient);
G4VPrimitiveScorer* primitiv2 = new G4PSDoseDeposit("dose");
patient->RegisterPrimitive(primitiv2);
SetSensitiveDetector("PatientLV",patient);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -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 B3PhysicsList.cc
/// \brief Implementation of the B3PhysicsList class
#include "B3PhysicsList.hh"
#include "G4DecayPhysics.hh"
#include "G4EmStandardPhysics.hh"
#include "G4RadioactiveDecayPhysics.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3PhysicsList::B3PhysicsList()
: G4VModularPhysicsList(){
SetVerboseLevel(1);
// Default physics
RegisterPhysics(new G4DecayPhysics());
// EM physics
RegisterPhysics(new G4EmStandardPhysics());
// Radioactive decay
RegisterPhysics(new G4RadioactiveDecayPhysics());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3PhysicsList::~B3PhysicsList()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3PhysicsList::SetCuts()
{
G4VUserPhysicsList::SetCuts();
}
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * 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 B3PrimaryGeneratorAction.cc
/// \brief Implementation of the B3PrimaryGeneratorAction class
#include "B3PrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4IonTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ChargedGeantino.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3PrimaryGeneratorAction::B3PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle
= particleTable->FindParticle("chargedgeantino");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,0.));
fParticleGun->SetParticleEnergy(1*eV);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3PrimaryGeneratorAction::~B3PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
G4ParticleDefinition* particle = fParticleGun->GetParticleDefinition();
if (particle == G4ChargedGeantino::ChargedGeantino()) {
//fluorine
G4int Z = 9, A = 18;
G4double ionCharge = 0.*eplus;
G4double excitEnergy = 0.*keV;
G4ParticleDefinition* ion
= G4IonTable::GetIonTable()->GetIon(Z,A,excitEnergy);
fParticleGun->SetParticleDefinition(ion);
fParticleGun->SetParticleCharge(ionCharge);
}
// randomized position
//
///G4double x0 = 0*cm, y0 = 0*cm, z0 = 0*cm;
///G4double dx0 = 0*cm, dy0 = 0*cm, dz0 = 0*cm;
G4double x0 = 4*cm, y0 = 4*cm, z0 = 4*cm;
G4double dx0 = 1*cm, dy0 = 1*cm, dz0 = 1*cm;
x0 += dx0*(G4UniformRand()-0.5);
y0 += dy0*(G4UniformRand()-0.5);
z0 += dz0*(G4UniformRand()-0.5);
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
//create vertex
//
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,58 @@
//
// ********************************************************************
// * 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 B3StackingAction.cc
/// \brief Implementation of the B3StackingAction class
#include "B3StackingAction.hh"
#include "G4Track.hh"
#include "G4NeutrinoE.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3StackingAction::B3StackingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3StackingAction::~B3StackingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ClassificationOfNewTrack
B3StackingAction::ClassifyNewTrack(const G4Track* track)
{
//keep primary particle
if (track->GetParentID() == 0) return fUrgent;
//kill secondary neutrino
if (track->GetDefinition() == G4NeutrinoE::NeutrinoE()) return fKill;
else return fUrgent;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * 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 B3aActionInitialization.cc
/// \brief Implementation of the B3aActionInitialization class
#include "B3aActionInitialization.hh"
#include "B3aRunAction.hh"
#include "B3aEventAction.hh"
#include "B3PrimaryGeneratorAction.hh"
#include "B3StackingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3aActionInitialization::B3aActionInitialization()
: G4VUserActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3aActionInitialization::~B3aActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3aActionInitialization::BuildForMaster() const
{
SetUserAction(new B3aRunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3aActionInitialization::Build() const
{
B3aRunAction* runAction = new B3aRunAction();
SetUserAction(runAction);
SetUserAction(new B3aEventAction(runAction));
SetUserAction(new B3PrimaryGeneratorAction);
SetUserAction(new B3StackingAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,107 @@
//
// ********************************************************************
// * 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 B3aEventAction.cc
/// \brief Implementation of the B3aEventAction class
#include "B3aEventAction.hh"
#include "B3aRunAction.hh"
#include "G4RunManager.hh"
#include "G4Event.hh"
#include "G4SDManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4THitsMap.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3aEventAction::B3aEventAction(B3aRunAction* runAction)
: G4UserEventAction(),
fRunAction(runAction),
fCollID_cryst(-1),
fCollID_patient(-1)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3aEventAction::~B3aEventAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3aEventAction::BeginOfEventAction(const G4Event* /*evt*/)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3aEventAction::EndOfEventAction(const G4Event* evt )
{
//Hits collections
//
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
if(!HCE) return;
// Get hits collections IDs
if (fCollID_cryst < 0) {
G4SDManager* SDMan = G4SDManager::GetSDMpointer();
fCollID_cryst = SDMan->GetCollectionID("crystal/edep");
fCollID_patient = SDMan->GetCollectionID("patient/dose");
}
//Energy in crystals : identify 'good events'
//
const G4double eThreshold = 500*keV;
G4int nbOfFired = 0;
G4THitsMap<G4double>* evtMap =
(G4THitsMap<G4double>*)(HCE->GetHC(fCollID_cryst));
std::map<G4int,G4double*>::iterator itr;
for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
///G4int copyNb = (itr->first);
G4double edep = *(itr->second);
if (edep > eThreshold) nbOfFired++;
///G4cout << "\n cryst" << copyNb << ": " << edep/keV << " keV ";
}
if (nbOfFired == 2) fRunAction->CountEvent();
//Dose deposit in patient
//
G4double dose = 0.;
evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fCollID_patient));
for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
///G4int copyNb = (itr->first);
dose = *(itr->second);
}
if (dose > 0.) fRunAction->SumDose(dose);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,132 @@
//
// ********************************************************************
// * 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 B3aRunAction.cc
/// \brief Implementation of the B3aRunAction class
#include "B3aRunAction.hh"
#include "B3PrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4Run.hh"
#include "G4AccumulableManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3aRunAction::B3aRunAction()
: G4UserRunAction(),
fGoodEvents(0),
fSumDose(0.)
{
//add new units for dose
//
const G4double milligray = 1.e-3*gray;
const G4double microgray = 1.e-6*gray;
const G4double nanogray = 1.e-9*gray;
const G4double picogray = 1.e-12*gray;
new G4UnitDefinition("milligray", "milliGy" , "Dose", milligray);
new G4UnitDefinition("microgray", "microGy" , "Dose", microgray);
new G4UnitDefinition("nanogray" , "nanoGy" , "Dose", nanogray);
new G4UnitDefinition("picogray" , "picoGy" , "Dose", picogray);
// Register accumulable to the accumulable manager
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->RegisterAccumulable(fGoodEvents);
accumulableManager->RegisterAccumulable(fSumDose);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B3aRunAction::~B3aRunAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3aRunAction::BeginOfRunAction(const G4Run* /*run*/)
{
// reset accumulables to their initial values
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->Reset();
//inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B3aRunAction::EndOfRunAction(const G4Run* run)
{
G4int nofEvents = run->GetNumberOfEvent();
if (nofEvents == 0) return;
// Merge accumulables
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->Merge();
// Run conditions
// note: There is no primary generator action object for "master"
// run manager for multi-threaded mode.
const B3PrimaryGeneratorAction* generatorAction
= static_cast<const B3PrimaryGeneratorAction*>(
G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
G4String partName;
if (generatorAction)
{
G4ParticleDefinition* particle
= generatorAction->GetParticleGun()->GetParticleDefinition();
partName = particle->GetParticleName();
}
// Print results
//
if (IsMaster())
{
G4cout
<< G4endl
<< "--------------------End of Global Run-----------------------"
<< G4endl
<< " The run was " << nofEvents << " events ";
}
else
{
G4cout
<< G4endl
<< "--------------------End of Local Run------------------------"
<< G4endl
<< " The run was " << nofEvents << " "<< partName;
}
G4cout
<< "; Nb of 'good' e+ annihilations: " << fGoodEvents.GetValue() << G4endl
<< " Total dose in patient : " << G4BestUnit(fSumDose.GetValue(),"Dose")
<< G4endl
<< "------------------------------------------------------------" << G4endl
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,83 @@
# Macro file for the visualization setting in the initialization phase
# of the B3 example when running in interactive mode
#
# Use these open statements to open selected visualization
#
# Use this open statement to create an OpenGL view:
/vis/open OGL 600x600-0+0
#
# Use this open statement to create an OpenInventor view:
#/vis/open OIX
#
# Use this open statement to create a .prim file suitable for
# viewing in DAWN:
#/vis/open DAWNFILE
#
# Use this open statement to create a .heprep file suitable for
# viewing in HepRApp:
#/vis/open HepRepFile
#
# Use this open statement to create a .wrl file suitable for
# viewing in a VRML viewer:
#/vis/open VRML2FILE
#
# Disable auto refresh and quieten vis messages whilst scene and
# trajectories are established:
/vis/viewer/set/autoRefresh false
/vis/verbose errors
#
# Draw geometry:
/vis/drawVolume
#
# Specify view angle:
##/vis/viewer/set/viewpointThetaPhi 90. 180.
#
# Specify zoom value:
/vis/viewer/zoom 1.4
#
# Specify style (surface, wireframe, auxiliary edges,...)
#/vis/viewer/set/style wireframe
#/vis/viewer/set/auxiliaryEdge true
#/vis/viewer/set/lineSegmentsPerCircle 100
#
# Draw coordinate axes:
#/vis/scene/add/axes 0 0 0 1 m
#
# Draw smooth trajectories at end of event, showing trajectory points
# as markers 2 pixels wide:
/vis/scene/add/trajectories smooth
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1
# (if too many tracks cause core dump => /tracking/storeTrajectory 0)
#
# Draw hits at end of event:
#/vis/scene/add/hits
#
# To draw only gammas:
#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma
#
# To invert the above, drawing all particles except gammas,
# keep the above two lines but also add:
#/vis/filtering/trajectories/particleFilter-0/invert true
#
# Many other options are available with /vis/modeling and /vis/filtering.
# For example, to select colour by particle ID:
/vis/modeling/trajectories/create/drawByParticleID
/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true
#/vis/modeling/trajectories/drawByParticleID-0/default/setStepPtsSize 1
# To select or override default colours (note: e+ is blue by default):
#/vis/modeling/trajectories/list
#/vis/modeling/trajectories/drawByParticleID-0/set e+ yellow
#
# To superimpose all of the events from a given run:
/vis/scene/endOfEventAction accumulate
#
# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true
/vis/verbose warnings
#
# For file-based drivers, use this to create an empty detector view:
#/vis/viewer/flush