Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -50,7 +50,21 @@
|
||||
==========================================================================
|
||||
</pre>
|
||||
|
||||
\section AnaEx01_s2 An event : PrimaryGeneratorAction
|
||||
\section AnaEx01_s2 Action Initialization
|
||||
|
||||
A newly introduced class, ActionInitialization,
|
||||
instantiates and registers to Geant4 kernel all user action classes
|
||||
which are defined thread-local and a run action class
|
||||
which is defined both thread-local and global.
|
||||
|
||||
The thread-local action classes are defined in
|
||||
ActionInitialization::Build()
|
||||
and the global run action class is defined in
|
||||
ActionInitialization::BuildForMaster().
|
||||
Note that ActionInitialization::Build() is also used to
|
||||
instatiate user action clasess in sequential mode.
|
||||
|
||||
\section AnaEx01_s3 An event : PrimaryGeneratorAction
|
||||
|
||||
The primary kinematic consists of a single particle which hits the
|
||||
calorimeter perpendicular to the input face. The type of the particle
|
||||
@@ -58,7 +72,7 @@
|
||||
be changed via the G4 build-in commands of ParticleGun class.
|
||||
|
||||
|
||||
\section AnaEx01_s3 Histograms
|
||||
\section AnaEx01_s4 Histograms
|
||||
|
||||
AnaEx01 can produce 4 histograms :
|
||||
|
||||
@@ -67,17 +81,21 @@
|
||||
- histo 3 : total track length of charged particles in absorber per event
|
||||
- histo 4 : total track length of charged particles in gap per event
|
||||
|
||||
And 1 Ntuple :
|
||||
- one row per event : EnergyAbs EnergyGap TrackLAbs TrackLGap
|
||||
And 2 Ntuples :
|
||||
- ntuple 1:
|
||||
- one row per event : EnergyAbs EnergyGap
|
||||
- ntuple 1:
|
||||
- one row per event : TrackLAbs TrackLGap
|
||||
|
||||
These histos are booked in HistoManager and filled from EventAction.
|
||||
These histos and ntuples are booked in HistoManager and filled from
|
||||
EventAction.
|
||||
|
||||
One can control the name of the histograms file and its format:
|
||||
- default name : AnaEx01
|
||||
The format of the histogram file can be : root (default),
|
||||
hbook, xml, csv. Include correct g4nnn.hh in HistoManager.hh
|
||||
|
||||
\section AnaEx01_s4 Using hbook format
|
||||
\section AnaEx01_s5 Using hbook format
|
||||
|
||||
Need a special treatement : the Cern Library must be installed and the
|
||||
environment variable CERNLIB correctly set. Then, *before* compiling,
|
||||
|
||||
@@ -27,22 +27,23 @@
|
||||
/// \brief Main program of the analysis/AnaEx01 example
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: AnaEx01.cc 73919 2013-09-17 07:38:47Z gcosmo $
|
||||
//
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "PhysicsList.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "HistoManager.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
#include "G4MTRunManager.hh"
|
||||
#else
|
||||
#include "G4RunManager.hh"
|
||||
#endif
|
||||
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "G4VisExecutive.hh"
|
||||
@@ -58,36 +59,21 @@ int main(int argc,char** argv)
|
||||
{
|
||||
// Construct the default run manager
|
||||
//
|
||||
#ifdef G4MULTITHREADED
|
||||
G4int nThreads = 4;
|
||||
G4MTRunManager * runManager = new G4MTRunManager;
|
||||
runManager->SetNumberOfThreads(nThreads);
|
||||
#else
|
||||
G4RunManager * runManager = new G4RunManager;
|
||||
#endif
|
||||
|
||||
// Set mandatory initialization classes
|
||||
//
|
||||
DetectorConstruction* detector = new DetectorConstruction;
|
||||
runManager->SetUserInitialization(detector);
|
||||
//
|
||||
PhysicsList* physics = new PhysicsList;
|
||||
runManager->SetUserInitialization(physics);
|
||||
|
||||
// set an HistoManager
|
||||
//
|
||||
HistoManager* histo = new HistoManager();
|
||||
runManager->SetUserInitialization(new PhysicsList);
|
||||
runManager->SetUserInitialization(new ActionInitialization(detector));
|
||||
|
||||
// Set user action classes
|
||||
//
|
||||
PrimaryGeneratorAction* gen_action =
|
||||
new PrimaryGeneratorAction(detector);
|
||||
runManager->SetUserAction(gen_action);
|
||||
//
|
||||
RunAction* run_action = new RunAction(histo);
|
||||
runManager->SetUserAction(run_action);
|
||||
//
|
||||
EventAction* event_action = new EventAction(run_action,histo);
|
||||
runManager->SetUserAction(event_action);
|
||||
//
|
||||
SteppingAction* stepping_action =
|
||||
new SteppingAction(detector, event_action);
|
||||
runManager->SetUserAction(stepping_action);
|
||||
|
||||
// Initialize G4 kernel
|
||||
//
|
||||
runManager->Initialize();
|
||||
@@ -124,7 +110,6 @@ int main(int argc,char** argv)
|
||||
}
|
||||
|
||||
// Job termination
|
||||
delete histo;
|
||||
delete runManager;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -33,6 +33,7 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
|
||||
# Get examples sources from common and shared
|
||||
#
|
||||
list(APPEND sources
|
||||
${PROJECT_SOURCE_DIR}/../shared/src/ActionInitialization.cc
|
||||
${PROJECT_SOURCE_DIR}/../shared/src/DetectorConstruction.cc
|
||||
${PROJECT_SOURCE_DIR}/../shared/src/DetectorMessenger.cc
|
||||
${PROJECT_SOURCE_DIR}/../shared/src/EventAction.cc
|
||||
@@ -60,8 +61,9 @@ endif()
|
||||
if (HBOOK_FOUND)
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/../../common/analysis/include)
|
||||
list(APPEND sources
|
||||
${PROJECT_SOURCE_DIR}/../../common/analysis/src/ExG4HbookAnalysisManager.cc)
|
||||
|
||||
file(GLOB add_sources ${PROJECT_SOURCE_DIR}/../../common/analysis/src/*.cc)
|
||||
list(APPEND sources ${add_sources})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/close.o
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.4 2010-11-08 10:38:44 maire Exp $
|
||||
# $Id: GNUmakefile 68015 2013-03-13 13:27:27Z gcosmo $
|
||||
# --------------------------------------------------------------
|
||||
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
|
||||
# --------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.19 2010-11-08 10:38:44 maire Exp $
|
||||
$Id: History 73921 2013-09-17 07:45:43Z gcosmo $
|
||||
--------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -14,7 +14,19 @@ track of all tags.
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
16-09-13 I. Hrivnacova (AnaEx01-V09-06-02)
|
||||
- Updated SharedFilesList.txt for addedActionInitialization class
|
||||
(missing in analysisExample-V09-06-02 in top directory)
|
||||
|
||||
11-07-13 I. Hrivnacova (AnaEx01-V09-06-01)
|
||||
- Updated CMakeLists.txt and SharedFilesList.txt for added classes
|
||||
in Hbook analysis code
|
||||
|
||||
02-04-13 I. Hrivnacova (AnaEx01-V09-06-00)
|
||||
- Create two ntuples instead of one in order to demonstrate
|
||||
how to do this with all tools.
|
||||
|
||||
31-08-12 I. Hrivnacova (AnaEx01-V09-05-05)
|
||||
- Updated CMakeLists.tx:
|
||||
adding visualization, copying macros, install target and comment lines
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: README,v 1.17 2010-11-08 10:38:44 maire Exp $
|
||||
$Id: README 73919 2013-09-17 07:38:47Z gcosmo $
|
||||
--------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -53,7 +53,22 @@ $Id: README,v 1.17 2010-11-08 10:38:44 maire Exp $
|
||||
==========================================================================
|
||||
|
||||
|
||||
2- An event : PrimaryGeneratorAction
|
||||
2- Action Initialization
|
||||
------------------------------------
|
||||
|
||||
A newly introduced class, ActionInitialization,
|
||||
instantiates and registers to Geant4 kernel all user action classes
|
||||
which are defined thread-local and a run action class
|
||||
which is defined both thread-local and global.
|
||||
|
||||
The thread-local action classes are defined in
|
||||
ActionInitialization::Build()
|
||||
and the global run action class is defined in
|
||||
ActionInitialization::BuildForMaster().
|
||||
Note that ActionInitialization::Build() is also used to
|
||||
instatiate user action clasess in sequential mode.
|
||||
|
||||
3- An event : PrimaryGeneratorAction
|
||||
------------------------------------
|
||||
|
||||
The primary kinematic consists of a single particle which hits the
|
||||
@@ -62,7 +77,7 @@ $Id: README,v 1.17 2010-11-08 10:38:44 maire Exp $
|
||||
be changed via the G4 build-in commands of ParticleGun class.
|
||||
|
||||
|
||||
3- Histograms
|
||||
4- Histograms
|
||||
-------------
|
||||
|
||||
AnaEx01 can produce 4 histograms :
|
||||
@@ -72,10 +87,14 @@ $Id: README,v 1.17 2010-11-08 10:38:44 maire Exp $
|
||||
histo 3 : total track length of charged particles in absorber per event
|
||||
histo 4 : total track length of charged particles in gap per event
|
||||
|
||||
And 1 Ntuple :
|
||||
one row per event : EnergyAbs EnergyGap TrackLAbs TrackLGap
|
||||
And 2 Ntuples :
|
||||
- ntuple 1:
|
||||
- one row per event : EnergyAbs EnergyGap
|
||||
- ntuple 1:
|
||||
- one row per event : TrackLAbs TrackLGap
|
||||
|
||||
These histos are booked in HistoManager and filled from EventAction.
|
||||
These histos and ntuples are booked in HistoManager and filled from
|
||||
EventAction.
|
||||
|
||||
One can control the name of the histograms file and its format:
|
||||
default name : AnaEx01
|
||||
|
||||
@@ -4,10 +4,17 @@ COMMON_CLASSES_PATH ../../common
|
||||
COMMON_CLASSES_LIST
|
||||
g4hbook.hh
|
||||
g4hbook_defs.hh
|
||||
ExG4HbookNtupleDescription.hh
|
||||
ExG4HbookAnalysisManager.icc
|
||||
ExG4HbookAnalysisManager
|
||||
ExG4HbookFileManager
|
||||
ExG4HbookH1Manager
|
||||
ExG4HbookH2Manager
|
||||
ExG4HbookNtupleManager
|
||||
|
||||
SHARED_CLASSES_PATH ../shared
|
||||
SHARED_CLASSES_LIST
|
||||
ActionInitialization
|
||||
DetectorConstruction
|
||||
DetectorMessenger
|
||||
EventAction
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Definition of the HistoManager class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: HistoManager.hh 74272 2013-10-02 14:48:50Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -68,8 +68,8 @@ class HistoManager
|
||||
|
||||
private:
|
||||
|
||||
G4String fileName[2];
|
||||
G4bool factoryOn;
|
||||
G4String fFileName[2];
|
||||
G4bool fFactoryOn;
|
||||
|
||||
G4int fHistId[MaxHisto];
|
||||
G4AnaH1* fHistPt[MaxHisto];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $Id: run.mac,v 1.5 2010-11-08 11:01:47 maire Exp $
|
||||
# $Id: run.mac 68015 2013-03-13 13:27:27Z gcosmo $
|
||||
#
|
||||
# Macro file for "AnaEx01.cc"
|
||||
#
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// \brief Implementation of the HistoManager class
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: HistoManager.cc 74272 2013-10-02 14:48:50Z gcosmo $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
HistoManager::HistoManager()
|
||||
{
|
||||
fileName[0] = "AnaEx01";
|
||||
factoryOn = false;
|
||||
fFileName[0] = "AnaEx01";
|
||||
fFactoryOn = false;
|
||||
|
||||
// histograms
|
||||
for (G4int k=0; k<MaxHisto; k++) {
|
||||
@@ -69,7 +69,7 @@ void HistoManager::book()
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->SetVerboseLevel(2);
|
||||
G4String extension = analysisManager->GetFileType();
|
||||
fileName[1] = fileName[0] + "." + extension;
|
||||
fFileName[1] = fFileName[0] + "." + extension;
|
||||
|
||||
// Create directories
|
||||
analysisManager->SetHistoDirectoryName("histo");
|
||||
@@ -77,9 +77,9 @@ void HistoManager::book()
|
||||
|
||||
// Open an output file
|
||||
//
|
||||
G4bool fileOpen = analysisManager->OpenFile(fileName[0]);
|
||||
G4bool fileOpen = analysisManager->OpenFile(fFileName[0]);
|
||||
if (!fileOpen) {
|
||||
G4cout << "\n---> HistoManager::book(): cannot open " << fileName[1]
|
||||
G4cout << "\n---> HistoManager::book(): cannot open " << fFileName[1]
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
@@ -87,6 +87,7 @@ void HistoManager::book()
|
||||
// create selected histograms
|
||||
//
|
||||
analysisManager->SetFirstHistoId(1);
|
||||
analysisManager->SetFirstNtupleId(1);
|
||||
|
||||
fHistId[1] = analysisManager->CreateH1("1","Edep in absorber (MeV)",
|
||||
100, 0., 800*MeV);
|
||||
@@ -104,31 +105,36 @@ void HistoManager::book()
|
||||
100, 0., 50*cm);
|
||||
fHistPt[4] = analysisManager->GetH1(fHistId[4]);
|
||||
|
||||
// Create 1 ntuple
|
||||
// Create 1st ntuple (id = 1)
|
||||
//
|
||||
analysisManager->CreateNtuple("101", "Edep and TrackL");
|
||||
analysisManager->CreateNtuple("101", "Edep");
|
||||
fNtColId[0] = analysisManager->CreateNtupleDColumn("Eabs");
|
||||
fNtColId[1] = analysisManager->CreateNtupleDColumn("Egap");
|
||||
analysisManager->FinishNtuple();
|
||||
|
||||
// Create 2nd ntuple (id = 2)
|
||||
//
|
||||
analysisManager->CreateNtuple("102", "TrackL");
|
||||
fNtColId[2] = analysisManager->CreateNtupleDColumn("Labs");
|
||||
fNtColId[3] = analysisManager->CreateNtupleDColumn("Lgap");
|
||||
analysisManager->FinishNtuple();
|
||||
|
||||
factoryOn = true;
|
||||
G4cout << "\n----> Histogram Tree is opened in " << fileName[1] << G4endl;
|
||||
fFactoryOn = true;
|
||||
G4cout << "\n----> Histogram Tree is opened in " << fFileName[1] << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::save()
|
||||
{
|
||||
if (factoryOn) {
|
||||
if (fFactoryOn) {
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
G4cout << "\n----> Histogram Tree is saved in " << fileName[1] << G4endl;
|
||||
G4cout << "\n----> Histogram Tree is saved in " << fFileName[1] << G4endl;
|
||||
|
||||
delete G4AnalysisManager::Instance();
|
||||
factoryOn = false;
|
||||
fFactoryOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,18 +170,21 @@ void HistoManager::FillNtuple(G4double energyAbs, G4double energyGap,
|
||||
G4double trackLAbs, G4double trackLGap)
|
||||
{
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
analysisManager->FillNtupleDColumn(fNtColId[0], energyAbs);
|
||||
analysisManager->FillNtupleDColumn(fNtColId[1], energyGap);
|
||||
analysisManager->FillNtupleDColumn(fNtColId[2], trackLAbs);
|
||||
analysisManager->FillNtupleDColumn(fNtColId[2], trackLGap);
|
||||
analysisManager->AddNtupleRow();
|
||||
// Fill 1st ntuple ( id = 1)
|
||||
analysisManager->FillNtupleDColumn(1,fNtColId[0], energyAbs);
|
||||
analysisManager->FillNtupleDColumn(1,fNtColId[1], energyGap);
|
||||
analysisManager->AddNtupleRow(1);
|
||||
// Fill 2nd ntuple ( id = 2)
|
||||
analysisManager->FillNtupleDColumn(2,fNtColId[2], trackLAbs);
|
||||
analysisManager->FillNtupleDColumn(2,fNtColId[3], trackLGap);
|
||||
analysisManager->AddNtupleRow(2);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoManager::PrintStatistic()
|
||||
{
|
||||
if(factoryOn) {
|
||||
if(fFactoryOn) {
|
||||
G4cout << "\n ----> print histograms statistic \n" << G4endl;
|
||||
|
||||
G4cout
|
||||
|
||||
Reference in New Issue
Block a user