Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
-10
View File
@@ -11,16 +11,6 @@
This module is going to be enhanced in future. Currently it provides
the following sets of classes:
- \ref extended_common_analysis :
- ExG4HbookAnalysisManager - the analysis manager class for HBOOK
As this class requires CERNLIB libraries, its compilation
is optional. To build it, the following environment variables
must be defined:
\verbatim
G4_USE_HBOOK = 1
CERNLIB = path to the CERNLIB installation
\endverbatim
- \ref extended_common_detectorConstruction :
- two simple detector construction classes with a messenger
+56 -7
View File
@@ -1,9 +1,58 @@
#---Adding all common examples subdirectories explicitly
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(common)
add_subdirectory(analysis)
add_subdirectory(detectorConstruction)
add_subdirectory(physicsList)
add_subdirectory(primaryGenerator)
add_subdirectory(userActions)
#----------------------------------------------------------------------------
# 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(common ${sources} ${headers})
target_link_libraries(common ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries and common library
#
add_executable(testCommon testCommon.cc )
target_link_libraries(testCommon common ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build detectorConstruction. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(detectorConstruction_SCRIPTS
)
foreach(_script ${detectorConstruction_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
# and the library to 'lib' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS testCommon DESTINATION bin)
install(TARGETS common DESTINATION lib)
+37
View File
@@ -0,0 +1,37 @@
# $Id$
# --------------------------------------------------------------
# GNUmakefile for common repository examples module.
# --------------------------------------------------------------
name := common
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPNumerics/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/tracking/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/cuts/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/electromagnetic/pii/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/particles/bosons/include \
-I$(G4BASE)/particles/leptons/include \
-I$(G4BASE)/particles/hadrons/barions/include \
-I$(G4BASE)/particles/hadrons/mesons/include \
-I$(G4BASE)/particles/hadrons/ions/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/event/include \
-I$(G4BASE)/run/include
CPPFLAGS += -I$(G4INCLUDE)
include $(G4INSTALL)/config/common.gmk
+28
View File
@@ -15,6 +15,34 @@ track of all tags.
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
06/11/14 I. Hrivnacova (excommon-V10-00-06)
- Fixed CMakeLists.txt for removal of analysis directory
05/11/14 I. Hrivnacova (excommon-V10-00-05)
- Restoring back GNUmakefile (lost with previous update)
05/11/14 I. Hrivnacova (excommon-V10-00-04)
- Moved analysis subdirectory in extended/analysis/AnaEx01/hbook,
as it is not used anywhere else
05/11/14 I. Hrivnacova (excommon-V10-00-03)
- Removed sub-directories with user classes and scripts (now obsolete)
04/11/14 I. Hrivnacova (excommon-V10-00-02)
- Added GNUmakefile in top directory
04/11/14 I. Hrivnacova (excommon-V10-00-01)
- Modifications to facilitate use of common directory via svn:externals:
merging user classes in the top directoy (include and src),
added testCommon.cc for all classes altogether and
added building common library
28/05/14 I. Hrivnacova (excommon-V10-00-00)
- Removed fPrintModulo from ExG4EventAction01
and fSetPrintModuloCmd from ExG4EventAction01Messenger,
now obsolete.
- Fixed long lines, separators in userActions classes
28/02/13 I. Hrivnacova (excommon-V09-06-00)
- When building materials with NistManager
do not set fromIsotopes argument (which was set to false),
+4 -12
View File
@@ -14,25 +14,17 @@ $Id$
This module is going to be enhanced in future. Currently it provides
the following sets of classes:
- analysis
- ExG4HbookAnalysisManager - the analysis manager class for HBOOK
As this class requires CERNLIB libraries, its compilation
is optional. To build it, the following environment variables
must be defined:
G4_USE_HBOOK = 1
CERNLIB = path to the CERNLIB installation
- detectorConstruction
- Detector construction classes
- two simple detector construction classes with a messenger
- physicsList
- Physics list classes
- ExG4PhysicsList00 - physics list with geantino and chargedgeantino only
- primaryGenerator
- Primary generator classes
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
- userActions:
- User action classes:
- event action and run action classes with messengers
@@ -1,92 +0,0 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(analysis)
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Find HBOOK (required package)
#
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
find_package(HBOOK QUIET)
if(NOT HBOOK_FOUND)
message(STATUS "G4 Examples: HBOOK package not found. --> g4tools/hbook analysis disabled")
return()
else()
message(STATUS "G4 Examples: HBOOK package found. --> g4tools/hbook analysis enabled")
add_definitions(-DG4_USE_HBOOK)
endif()
#----------------------------------------------------------------------------
# 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)
#----------------------------------------------------------------------------
# Build fortran sources from g4tools/hbook
#
if(HBOOK_FOUND)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/close.o
COMMAND gfortran
ARGS -c ${Geant4_INCLUDE_DIR}/tools/hbook/close.f )
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/setpawc.o
COMMAND gfortran
ARGS -c ${Geant4_INCLUDE_DIR}/tools/hbook/setpawc.f )
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/setntuc.o
COMMAND gfortran
ARGS -c ${Geant4_INCLUDE_DIR}/tools/hbook/setntuc.f )
set(TOOLS_FORTRAN_OBJECTS close.o setpawc.o setntuc.o)
endif()
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(testAnalysis testAnalysis.cc ${sources} ${headers} ${TOOLS_FORTRAN_OBJECTS})
target_link_libraries(testAnalysis ${Geant4_LIBRARIES} ${HBOOK_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build analysis. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(analysis_SCRIPTS
)
foreach(_script ${analysis_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(analysis DEPENDS testAnalysis)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS testAnalysis DESTINATION bin)
@@ -1,27 +0,0 @@
# $Id: GNUmakefile 68059 2013-03-13 14:49:02Z gcosmo $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := testAnalysis
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: hbook lib bin
# HBOOK support
include GNUmakefile.tools_hbook
include $(G4INSTALL)/config/binmake.gmk
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
histclean:
rm ${G4WORKDIR}/tmp/${G4SYSTEM}/${G4TARGET}/HistoManager.o
@@ -1,48 +0,0 @@
# $Id$
# --------------------------------------------------------------
# GNUmakefile for ing4 HBOOK support.
# --------------------------------------------------------------
ifdef G4_USE_HBOOK
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -DG4_USE_HBOOK
EXTRALIBS += $(G4TMPDIR)/exe/close.o $(G4TMPDIR)/exe/setpawc.o $(G4TMPDIR)/exe/setntuc.o
EXTRALIBS += -L${CERNLIB}/lib -lpacklib -lmathlib -lgfortran -lcrypt
#FC=gfortran
hbook: close.o setpawc.o setntuc.o
(mv *.o $(G4TMPDIR)/exe);
close.o : $(G4BASE)/analysis/include/tools/hbook/close.f
@echo Compiling close.f
ifdef CPPVERBOSE
$(FC) -c $(G4BASE)/analysis/include/tools/hbook/close.f
else
@$(FC) -c $(G4BASE)/analysis/include/tools/hbook/close.f
endif
setpawc.o : $(G4BASE)/analysis/include/tools/hbook/setpawc.f
@echo Compiling setpawc.f
ifdef CPPVERBOSE
$(FC) -c $(G4BASE)/analysis/include/tools/hbook/setpawc.f
else
@$(FC) -c $(G4BASE)/analysis/include/tools/hbook/setpawc.f
endif
setntuc.o : $(G4BASE)/analysis/include/tools/hbook/setntuc.f
@echo Compiling setntuc.f
ifdef CPPVERBOSE
$(FC) -c $(G4BASE)/analysis/include/tools/hbook/setntuc.f
else
@$(FC) -c $(G4BASE)/analysis/include/tools/hbook/setntuc.f
endif
else
hbook:
endif
-82
View File
@@ -1,82 +0,0 @@
$Id$
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
extended/commmon/analysis 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 *
----------------------------------------------------------
07/11/2013 I. Hrivnacova (excommon-analysis-V09-06-04)
- Implemented functions for user defined/logarithmic binning for H1
and H2; in case of H2 an exception is (not available in HBOOK)
11/07/2013 I. Hrivnacova (excommon-analysis-V09-06-03)
- Refactoring ExG4Hnook manager class following changes
in analysis (analysis-V09-06-11)
20/06/2013 I. Hrivnacova (excommon-analysis-V09-06-02)
- Fixed a typo in ExG4HbookAnalysisManager.hh which caused compilation
error
03/06/2013 I. Hrivnacova (excommon-analysis-V09-06-01)
- Implemented ExG4HbookAnalysisManager::Create() required with
update for MT migration; returns an exception in case of MT mode
(as Hbook is not supported with MT)
29/03/2013 I. Hrivnacova (excommon-analysis-V09-06-00)
- Updated to analysis-V09-06-05
- Extended the manager class for handling more than one ntuple
19/11/2012 I. Hrivnacova (excommon-analysis-V09-05-04)
- Updated to analysis-V09-05-15
- Adding functions for accessing h1, h2 by name
- Splitting verbose level 1 in 2 levels and shifting the upper levels
- Fixed GetH1[2]Width: return the correct value also when histogram is
inactive.
28/08/2012 I. Hrivnacova (excommon-analysis-V09-05-03)
- Updated to analysis-V09-05-10
- Adding a possibility to fill h1, h2 with values with automatically
applied function (eg. log10, exp)
- Pass units via a name instead of value
- Adding getters for many h1, h2 attributes
- Adding ScaleH1(), ScaleH2()
- Adding setters/getters for histogram axis titles
(though they are not propagated to paw)
27/07/2012 I. Hrivnacova (excommon-analysis-V09-05-02)
- Adding an additional information to analysis objects:
units, activation option (defined in G4HnInformation.hh)
- Make possible to book histograms/ntuple before openning a file
(using new h1_booking, h2_booking and tools::ntuple_booking classes)
- Using new bN::configure functions in SetHN(..)
- Messages from Fill functions only in verbose level 3
- Fixes in memory management
delete file before opening a new one (all)
delete ntuple before closing a file
- Based on g4tools 1.3.1 (by G. Barrand) - see History_tools
23/02/2012 I. Hrivnacova (excommon-analysis-V09-05-01)
- Added functions to customize the HBOOK IDs by user:
G4bool SetH1HbookIdOffset(G4int offset);
G4bool SetH2HbookIdOffset(G4int offset);
G4bool SetNtupleHbookId(G4int ntupleId);
and appropriate data members and their getters
- Added setting locks introduced in the base class
- Fixed handling of directories for both histograms and ntuple
14/02/2012 I. Hrivnacova (excommon-analysis-V09-05-00)
- Adding defs include files for Hbook manager
- Adding GetNtuple() function to specific managers
- Increased granularity of verbose levels (now 3 levels are available)
- Making creating directories optional
@@ -1,21 +0,0 @@
# Locate CERNLIB libraries (needed for g4tools/hbook)
# in a directory defined via CERNLIB environment variable
#
# Defines:
# HBOOK_FOUND
# HBOOK_LIBRARIES
find_library(PACKLIB_LIBRARY NAMES packlib
HINTS $ENV{CERNLIB} $ENV{CERNLIB}/lib)
# handle the QUIETLY and REQUIRED arguments and set HBOOK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HBOOK DEFAULT_MSG PACKLIB_LIBRARY)
if (HBOOK_FOUND)
get_filename_component(CERNLIB_LIBRARY_DIR ${PACKLIB_LIBRARY} PATH)
set(HBOOK_LIBRARIES "-L${CERNLIB_LIBRARY_DIR} -lpacklib -lmathlib -lgfortran -lcrypt")
endif()
mark_as_advanced(HBOOK_FOUND HBOOK_LIBRARIES)
@@ -1,138 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/ExG4HbookAnalysisManager.hh
/// \brief Definition of the ExG4HbookAnalysisManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookAnalysisManager_h
#define ExG4HbookAnalysisManager_h 1
#include "G4VAnalysisManager.hh"
#include "globals.hh"
#include <tools/hbook/wfile>
#include <tools/hbook/h1>
#include <tools/hbook/h2>
#include <tools/hbook/wntuple>
#include <vector>
#include <map>
#define setpawc setpawc_
#define setntuc setntuc_
//#define ntuc ntuc_
class ExG4HbookAnalysisManager;
namespace G4Hbook {
typedef tools::hbook::h1 G4AnaH1;
typedef ExG4HbookAnalysisManager G4AnalysisManager;
}
class ExG4HbookFileManager;
class ExG4HbookH1Manager;
class ExG4HbookH2Manager;
class ExG4HbookNtupleManager;
/// HBook Analysis manager
///
/// The class implements the G4VAnalysisManager manager for HBook.
/// It is provided separately from geant4/source/analysis in order
/// to avoid a need of linking Geant4 kernel libraries with cerblib.
class ExG4HbookAnalysisManager : public G4VAnalysisManager
{
public:
ExG4HbookAnalysisManager();
virtual ~ExG4HbookAnalysisManager();
// static methods
static ExG4HbookAnalysisManager* Create(G4bool isMaster = true);
static ExG4HbookAnalysisManager* Instance();
// HBOOK does not allow IDs the same IDs for H1 and H2,
// and also IDs starting from 0; thats why there is defined an offset
// with respect to the G4AnalysisManager generic Ids.
// The default values of these offsets can be changed by the user.
//
// Set the offset of HBOOK ID for H1
// ( default value = firstHistoID if firstHistoID > 0; otherwise = 1)
G4bool SetH1HbookIdOffset(G4int offset);
G4int GetH1HbookIdOffset() const;
// Set the offset of HBOOK ID for H2
// ( default value = firstHistoID + 100 if firstHistoID > 0;
// otherwise = 101 )
G4bool SetH2HbookIdOffset(G4int offset);
G4int GetH2HbookIdOffset() const;
// Set the offset of NTUPLE ID for ntuples
// ( default value = firstNtupleID if firstNtupleID > 0; otherwise = 1)
G4bool SetNtupleHbookIdOffset(G4int offset);
G4int GetNtupleHbookIdOffset() const;
// Access methods
//
tools::hbook::h1* GetH1(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
tools::hbook::h2* GetH2(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
tools::hbook::wntuple* GetNtuple() const;
tools::hbook::wntuple* GetNtuple(G4int ntupleId) const;
protected:
// virtual methods from base class
virtual G4bool OpenFileImpl(const G4String& fileName);
virtual G4bool WriteImpl();
virtual G4bool CloseFileImpl();
private:
// static data members
//
static ExG4HbookAnalysisManager* fgInstance;
// methods
//
void Reset();
ExG4HbookH1Manager* fH1Manager;
ExG4HbookH2Manager* fH2Manager;
ExG4HbookNtupleManager* fNtupleManager;
ExG4HbookFileManager* fFileManager;
};
#include "ExG4HbookAnalysisManager.icc"
#endif
#endif
@@ -1,102 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: ExG4HbookAnalysisManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
#include "ExG4HbookH1Manager.hh"
#include "ExG4HbookH2Manager.hh"
#include "ExG4HbookNtupleManager.hh"
//_____________________________________________________________________________
inline
G4bool ExG4HbookAnalysisManager::SetH1HbookIdOffset(G4int offset)
{
return fH1Manager->SetH1HbookIdOffset(offset);
}
//_____________________________________________________________________________
inline
G4int ExG4HbookAnalysisManager::GetH1HbookIdOffset() const
{
return fH1Manager->GetH1HbookIdOffset();
}
//_____________________________________________________________________________
inline
G4bool ExG4HbookAnalysisManager::SetH2HbookIdOffset(G4int offset)
{
return fH2Manager->SetH2HbookIdOffset(offset);
}
//_____________________________________________________________________________
inline
G4int ExG4HbookAnalysisManager::GetH2HbookIdOffset() const
{
return fH2Manager->GetH2HbookIdOffset();
}
//_____________________________________________________________________________
inline
G4bool ExG4HbookAnalysisManager::SetNtupleHbookIdOffset(G4int offset)
{
return fNtupleManager->SetNtupleHbookIdOffset(offset);
}
//_____________________________________________________________________________
inline
G4int ExG4HbookAnalysisManager::GetNtupleHbookIdOffset() const
{
return fNtupleManager->GetNtupleHbookIdOffset();
}
//_____________________________________________________________________________
inline
tools::hbook::h1* ExG4HbookAnalysisManager::GetH1(G4int id, G4bool warn,
G4bool onlyIfActive) const
{
return fH1Manager->GetH1(id, warn, onlyIfActive);
}
//_____________________________________________________________________________
inline
tools::hbook::h2* ExG4HbookAnalysisManager::GetH2(G4int id, G4bool warn,
G4bool onlyIfActive) const
{
return fH2Manager->GetH2(id, warn, onlyIfActive);
}
//_____________________________________________________________________________
inline
tools::hbook::wntuple* ExG4HbookAnalysisManager::GetNtuple() const
{
return fNtupleManager->GetNtuple();
}
//_____________________________________________________________________________
inline
tools::hbook::wntuple* ExG4HbookAnalysisManager::GetNtuple(G4int ntupleId) const
{
return fNtupleManager->GetNtuple(ntupleId);
}
@@ -1,81 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/ExG4HbookFileManager.hh
/// \brief Definition of the ExG4HbookFileManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookFileManager_h
#define ExG4HbookFileManager_h 1
#include "G4VFileManager.hh"
#include "globals.hh"
#include <tools/hbook/wfile>
/// The manager for HBook file operations.
///
/// The class implements the G4VFileManager manager for HBook.
/// It is provided separately from geant4/source/analysis in order
/// to avoid a need of linking Geant4 kernel libraries with cerblib.
class ExG4HbookFileManager : public G4VFileManager
{
public:
ExG4HbookFileManager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookFileManager();
// Methods to manipulate files
using G4VFileManager::OpenFile;
virtual G4bool OpenFile(const G4String& fileName);
virtual G4bool WriteFile();
virtual G4bool CloseFile();
// Specific methods for files per objects
void CreateNtupleDirectory();
// Get method
G4bool IsFile() const;
private:
static const G4String fgkDefaultNtupleDirectoryName;
// data members
tools::hbook::wfile* fFile;
};
// inline functions
inline G4bool ExG4HbookFileManager::IsFile() const
{ return fFile; }
#endif
#endif
@@ -1,215 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/ExG4HbookH1Manager.hh
/// \brief Definition of the ExG4HbookH1Manager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookH1Manager_h
#define ExG4HbookH1Manager_h 1
#include "G4VH1Manager.hh"
#include "G4HnInformation.hh"
#include "globals.hh"
#include <tools/hbook/h1>
#include <vector>
#include <map>
class ExG4HbookFileManager;
struct h1_booking {
h1_booking(G4int nbins, G4double xmin, G4double xmax)
: fTitle(""),
fNbins(nbins),
fXmin(xmin),
fXmax(xmax),
fEdges() {}
h1_booking(const std::vector<G4double>& edges)
: fTitle(""),
fNbins(0),
fXmin(0),
fXmax(0),
fEdges() {
for (G4int i=0; i<=G4int(edges.size()); ++i) fEdges.push_back(edges[i]);
}
G4String fTitle;
G4int fNbins;
G4double fXmin;
G4double fXmax;
std::vector<G4double> fEdges;
};
/// Manager class for HBook H1 histograms
///
/// The class implements the G4VH1Manager manager for HBook.
/// It is provided separately from geant4/source/analysis in order
/// to avoid a need of linking Geant4 kernel libraries with cerblib.
class ExG4HbookH1Manager : public G4VH1Manager
{
friend class ExG4HbookAnalysisManager;
protected:
ExG4HbookH1Manager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookH1Manager();
// Functions specific to the output type
//
// HBOOK does not allow IDs the same IDs for H1 and H2,
// and also IDs starting from 0; thats why there is defined an offset
// with respect to the G4AnalysisManager generic Ids.
// The default values of these offsets can be changed by the user.
//
// Set the offset of HBOOK ID for H1
// ( default value = firstHistoID if firstHistoID > 0; otherwise = 1)
G4bool SetH1HbookIdOffset(G4int offset);
G4int GetH1HbookIdOffset() const;
// Set methods
void SetFileManager(ExG4HbookFileManager* fileManager);
// Access methods
//
tools::hbook::h1* GetH1(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
// Virtual functions from base class
//
// Methods to create histogrammes, ntuples
virtual G4int CreateH1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName = "none",
const G4String& fcnName = "none",
const G4String& binSchemeName = "linear");
virtual G4int CreateH1(const G4String& name, const G4String& title,
const std::vector<G4double>& edges,
const G4String& unitName = "none",
const G4String& fcnName = "none");
virtual G4bool SetH1(G4int id,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName = "none",
const G4String& fcnName = "none",
const G4String& binSchemeName = "linear");
virtual G4bool SetH1(G4int id,
const std::vector<G4double>& edges,
const G4String& unitName = "none",
const G4String& fcnName = "none");
virtual G4bool ScaleH1(G4int id, G4double factor);
// Methods to fill histogrammes, ntuples
virtual G4bool FillH1(G4int id, G4double value, G4double weight = 1.0);
// Access methods
//
virtual G4int GetH1Id(const G4String& name, G4bool warn = true) const;
// Access to H1 parameters
virtual G4int GetH1Nbins(G4int id) const;
virtual G4double GetH1Xmin(G4int id) const;
virtual G4double GetH1Xmax(G4int id) const;
virtual G4double GetH1Width(G4int id) const;
// Setters for attributes for plotting
virtual G4bool SetH1Title(G4int id, const G4String& title);
virtual G4bool SetH1XAxisTitle(G4int id, const G4String& title);
virtual G4bool SetH1YAxisTitle(G4int id, const G4String& title);
// Access attributes for plotting
virtual G4String GetH1Title(G4int id) const;
virtual G4String GetH1XAxisTitle(G4int id) const;
virtual G4String GetH1YAxisTitle(G4int id) const;
// Write data on ASCII file
virtual G4bool WriteOnAscii(std::ofstream& output);
private:
// methods
//
void SetH1HbookIdOffset();
void AddH1Information(const G4String& name,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme) const;
G4int CreateH1FromBooking(h1_booking* h1Booking,
G4bool chDir = true);
G4int RegisterH1Booking(const G4String& name,
h1_booking* h1Booking);
void BeginCreateH1(const G4String& name);
G4int FinishCreateH1(const G4String& name, h1_booking* h1Booking,
const G4String& unitName, const G4String& fcnName,
G4BinScheme binScheme);
G4bool BeginSetH1(G4int id,
h1_booking* h1Booking,
G4HnInformation* info);
G4bool FinishSetH1(G4int id,
G4HnInformation* info,
const G4String& unitName, const G4String& fcnName,
G4BinScheme binScheme);
void CreateH1sFromBooking();
void Reset();
virtual h1_booking* GetH1Booking(G4int id, G4bool warn = true) const;
virtual tools::hbook::h1* GetH1InFunction(G4int id, G4String function,
G4bool warn = true,
G4bool onlyIfActive = true) const;
// data members
//
ExG4HbookFileManager* fFileManager;
G4int fH1HbookIdOffset;
std::vector<tools::hbook::h1*> fH1Vector;
std::vector<h1_booking*> fH1BookingVector;
std::map<G4String, G4int> fH1NameIdMap;
};
// inline functions
inline void ExG4HbookH1Manager::SetFileManager(ExG4HbookFileManager* fileManager)
{ fFileManager = fileManager; }
inline G4int ExG4HbookH1Manager::GetH1HbookIdOffset() const {
return fH1HbookIdOffset;
}
#endif
#endif
@@ -1,209 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/ExG4HbookH2Manager.hh
/// \brief Definition of the ExG4HbookH2Manager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookH2Manager_h
#define ExG4HbookH2Manager_h 1
#include "G4VH2Manager.hh"
#include "globals.hh"
#include <tools/hbook/h2>
#include <vector>
#include <map>
class ExG4HbookFileManager;
struct h2_booking {
h2_booking(G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax)
: fTitle(""),
fNxbins(nxbins),
fXmin(xmin),
fXmax(xmax),
fNybins(nybins),
fYmin(ymin),
fYmax(ymax) {}
G4String fTitle;
G4int fNxbins;
G4double fXmin;
G4double fXmax;
G4int fNybins;
G4double fYmin;
G4double fYmax;
};
/// Manager class for HBook H2 histograms
///
/// The class implements the G4VH2Manager manager for HBook.
/// It is provided separately from geant4/source/analysis in order
/// to avoid a need of linking Geant4 kernel libraries with cerblib.
class ExG4HbookH2Manager : public G4VH2Manager
{
friend class ExG4HbookAnalysisManager;
protected:
ExG4HbookH2Manager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookH2Manager();
// Functions specific to the output type
//
// Set the offset of HBOOK ID for H2
// ( default value = firstHistoID + 100 if firstHistoID > 0;
// otherwise = 101 )
G4bool SetH2HbookIdOffset(G4int offset);
G4int GetH2HbookIdOffset() const;
// Set methods
void SetFileManager(ExG4HbookFileManager* fileManager);
// Access methods
tools::hbook::h2* GetH2(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
protected:
// Virtual functions from base class
//
// Methods to create histogrammes, ntuples
virtual G4int CreateH2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& xbinScheme = "linear",
const G4String& ybinScheme = "linear");
virtual G4int CreateH2(const G4String& name, const G4String& title,
const std::vector<G4double>& xedges,
const std::vector<G4double>& yedges,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none");
virtual G4bool SetH2(G4int id,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& xbinScheme = "linear",
const G4String& ybinScheme = "linear");
virtual G4bool SetH2(G4int id,
const std::vector<G4double>& xedges,
const std::vector<G4double>& yedges,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none");
virtual G4bool ScaleH2(G4int id, G4double factor);
// Methods to fill histogrammes, ntuples
virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue,
G4double weight = 1.0);
// Access methods via names
virtual G4int GetH2Id(const G4String& name, G4bool warn = true) const;
// Access to H2 parameters
virtual G4int GetH2Nxbins(G4int id) const;
virtual G4double GetH2Xmin(G4int id) const;
virtual G4double GetH2Xmax(G4int id) const;
virtual G4double GetH2XWidth(G4int id) const;
virtual G4int GetH2Nybins(G4int id) const;
virtual G4double GetH2Ymin(G4int id) const;
virtual G4double GetH2Ymax(G4int id) const;
virtual G4double GetH2YWidth(G4int id) const;
// Setters for attributes for plotting
virtual G4bool SetH2Title(G4int id, const G4String& title);
virtual G4bool SetH2XAxisTitle(G4int id, const G4String& title);
virtual G4bool SetH2YAxisTitle(G4int id, const G4String& title);
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String& title);
// Access attributes for plotting
virtual G4String GetH2Title(G4int id) const;
virtual G4String GetH2XAxisTitle(G4int id) const;
virtual G4String GetH2YAxisTitle(G4int id) const;
virtual G4String GetH2ZAxisTitle(G4int id) const;
// Write data on ASCII file
virtual G4bool WriteOnAscii(std::ofstream& output);
private:
// static data members
//
static const G4int fgkDefaultH2HbookIdOffset;
// methods
//
void SetH2HbookIdOffset();
void CreateH2sFromBooking();
void Reset();
virtual h2_booking* GetH2Booking(G4int id, G4bool warn = true) const;
virtual tools::hbook::h2* GetH2InFunction(G4int id, G4String function,
G4bool warn = true,
G4bool onlyIfActive = true) const;
// data members
//
ExG4HbookFileManager* fFileManager;
G4int fH2HbookIdOffset;
std::vector<tools::hbook::h2*> fH2Vector;
std::vector<h2_booking*> fH2BookingVector;
std::map<G4String, G4int> fH2NameIdMap;
};
// inline functions
inline void ExG4HbookH2Manager::SetFileManager(ExG4HbookFileManager* fileManager)
{ fFileManager = fileManager; }
inline G4int ExG4HbookH2Manager::GetH2HbookIdOffset() const {
return fH2HbookIdOffset;
}
#endif
#endif
@@ -1,63 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4HnInformation.hh 66310 2012-12-17 11:56:35Z ihrivnac $
// Author: Ivana Hrivnacova, 04/07/2012 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookNtupleDescription_h
#define ExG4HbookNtupleDescription_h 1
#include "tools/hbook/wntuple"
#include "tools/ntuple_booking"
#include <map>
// Structure containing the information related to one Hbook ntuple
struct ExG4HbookNtupleDescription
{
ExG4HbookNtupleDescription()
: fNtuple(0),
fNtupleBooking(0),
fNtupleIColumnMap(),
fNtupleFColumnMap(),
fNtupleDColumnMap() {}
~ExG4HbookNtupleDescription()
{ delete fNtupleBooking; }
tools::hbook::wntuple* fNtuple;
tools::ntuple_booking* fNtupleBooking;
std::map<G4int, tools::hbook::wntuple::column<int>* > fNtupleIColumnMap;
std::map<G4int, tools::hbook::wntuple::column<float>* > fNtupleFColumnMap;
std::map<G4int, tools::hbook::wntuple::column<double>* > fNtupleDColumnMap;
};
#endif
#endif
@@ -1,152 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/ExG4HbookNtupleManager.hh
/// \brief Definition of the ExG4HbookNtupleManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookNtupleManager_h
#define ExG4HbookNtupleManager_h 1
#include "G4VNtupleManager.hh"
#include "ExG4HbookNtupleDescription.hh"
#include "globals.hh"
#include <tools/hbook/wntuple>
#include <vector>
#include <map>
class ExG4HbookFileManager;
/// Manager class for HBook ntuples
///
/// The class implements the G4VAnalysisManager manager for HBook.
/// It is provided separately from geant4/source/analysis in order
/// to avoid a need of linking Geant4 kernel libraries with cerblib.
class ExG4HbookNtupleManager : public G4VNtupleManager
{
friend class ExG4HbookAnalysisManager;
protected:
ExG4HbookNtupleManager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookNtupleManager();
// Functions specific to the output type
//
// Set the offset of NTUPLE ID for ntuples
// ( default value = firstNtupleID if firstNtupleID > 0; otherwise = 1)
G4bool SetNtupleHbookIdOffset(G4int offset);
G4int GetNtupleHbookIdOffset() const;
// Set methods
void SetFileManager(ExG4HbookFileManager* fileManager);
// Access methods
tools::hbook::wntuple* GetNtuple() const;
tools::hbook::wntuple* GetNtuple(G4int ntupleId) const;
// Virtual functions from base class
//
// Methods to create ntuples
virtual G4int CreateNtuple(const G4String& name, const G4String& title);
// Create columns in the last created ntuple
virtual G4int CreateNtupleIColumn(const G4String& name);
virtual G4int CreateNtupleFColumn(const G4String& name);
virtual G4int CreateNtupleDColumn(const G4String& name);
virtual void FinishNtuple();
// Create columns in the ntuple with given id
virtual G4int CreateNtupleIColumn(G4int ntupleId, const G4String& name);
virtual G4int CreateNtupleFColumn(G4int ntupleId, const G4String& name);
virtual G4int CreateNtupleDColumn(G4int ntupleId, const G4String& name);
virtual void FinishNtuple(G4int ntupleId);
// Methods to fill ntuples
// Methods for ntuple with id = FirstNtupleId
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
virtual G4bool AddNtupleRow();
// Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
virtual G4bool FillNtupleIColumn(
G4int ntupleId, G4int columnId, G4int value);
virtual G4bool FillNtupleFColumn(
G4int ntupleId, G4int columnId, G4float value);
virtual G4bool FillNtupleDColumn(
G4int ntupleId, G4int columnId, G4double value);
virtual G4bool AddNtupleRow(G4int ntupleId);
// Access methods
virtual G4int GetNofNtuples() const;
private:
// methods
//
void SetNtupleHbookIdOffset();
void CreateNtuplesFromBooking();
tools::hbook::wntuple::column<int>*
GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
tools::hbook::wntuple::column<float>*
GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
tools::hbook::wntuple::column<double>*
GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
void Reset();
ExG4HbookNtupleDescription* GetNtupleInFunction(G4int id,
G4String function,
G4bool warn = true,
G4bool onlyIfActive = true) const;
// data members
//
ExG4HbookFileManager* fFileManager;
G4int fNtupleHbookIdOffset;
std::vector<ExG4HbookNtupleDescription*> fNtupleVector;
};
// inline functions
inline void ExG4HbookNtupleManager::SetFileManager(ExG4HbookFileManager* fileManager)
{ fFileManager = fileManager; }
inline G4int ExG4HbookNtupleManager::GetNtupleHbookIdOffset() const {
return fNtupleHbookIdOffset;
}
inline G4int ExG4HbookNtupleManager::GetNofNtuples() const
{ return fNtupleVector.size(); }
#endif
#endif
@@ -1,42 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/g4hbook.hh
/// \brief Definition of the G4Hbook analysis typedefs
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifndef g4hbook_h
#define g4hbook_h
#include "g4hbook_defs.hh"
using namespace G4Hbook;
#endif
@@ -1,51 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/include/g4hbook_defs.hh
/// \brief Definition of the G4Hbook analysis typedefs
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifndef g4hbook_defs_h
#define g4hbook_defs_h
#include <tools/hbook/h1>
#include <tools/hbook/h2>
#include <tools/hbook/wntuple>
#include "ExG4HbookAnalysisManager.hh"
namespace G4Hbook {
typedef tools::hbook::h1 G4AnaH1;
typedef tools::hbook::h2 G4AnaH2;
typedef tools::hbook::wntuple G4Ntuple;
typedef ExG4HbookAnalysisManager G4AnalysisManager;
}
#endif
@@ -1,220 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/src/ExG4HbookAnalysisManager.cc
/// \brief Implementation of the ExG4HbookAnalysisManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookAnalysisManager.hh"
#include "ExG4HbookFileManager.hh"
#include "ExG4HbookH1Manager.hh"
#include "ExG4HbookH2Manager.hh"
#include "ExG4HbookNtupleManager.hh"
#include "G4AnalysisManagerState.hh"
#include "G4UnitsTable.hh"
#include <iostream>
extern "C" int setpawc();
extern "C" int setntuc();
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::fgInstance = 0;
//_____________________________________________________________________________
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::Create(G4bool /*isMaster*/)
{
if ( fgInstance == 0 ) {
fgInstance = new ExG4HbookAnalysisManager();
}
return fgInstance;
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::Instance()
{
if ( fgInstance == 0 ) {
fgInstance = new ExG4HbookAnalysisManager();
}
return fgInstance;
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
: G4VAnalysisManager("Hbook", true),
fH1Manager(0),
fH2Manager(0),
fNtupleManager(0),
fFileManager(0)
{
if ( G4AnalysisManagerState::IsMT() ) {
// Hbook output is not supported in MT mode
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager is not supported in multi-threading mode.";
G4Exception("ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()",
"Analysis_F002", FatalException, description);
}
if ( fgInstance ) {
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager already exists."
<< "Cannot create another instance.";
G4Exception("ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()",
"Analysis_F001", FatalException, description);
}
fgInstance = this;
// Create managers
fH1Manager = new ExG4HbookH1Manager(fState);
fH2Manager = new ExG4HbookH2Manager(fState);
fNtupleManager = new ExG4HbookNtupleManager(fState);
fFileManager = new ExG4HbookFileManager(fState);
// Set managers to base class
SetH1Manager(fH1Manager);
SetH2Manager(fH2Manager);
SetNtupleManager(fNtupleManager);
SetFileManager(fFileManager);
// Set file manager to component managers
fH1Manager->SetFileManager(fFileManager);
fH2Manager->SetFileManager(fFileManager);
fNtupleManager->SetFileManager(fFileManager);
// Initialize HBOOK :
tools::hbook::CHLIMIT(setpawc());
setntuc(); //for ntuple.
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager::~ExG4HbookAnalysisManager()
{
fgInstance = 0;
}
//
// private methods
//
//_____________________________________________________________________________
void ExG4HbookAnalysisManager::Reset()
{
// Reset histograms and ntuple
fH1Manager->Reset();
fH2Manager->Reset();
fNtupleManager->Reset();
}
//
// public methods
//
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::OpenFileImpl(const G4String& fileName)
{
G4bool finalResult = true;
G4bool result = fFileManager->SetFileName(fileName);
finalResult = finalResult && result;
#ifdef G4VERBOSE
G4String name = fFileManager->GetFullFileName();
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("open", "analysis file", name);
#endif
// Open file
result = fFileManager->OpenFile(fileName);
finalResult = finalResult && result;
// Create h1 histrograms
fH1Manager->CreateH1sFromBooking();
// Create h2 histrograms if any is booked
fH2Manager->CreateH2sFromBooking();
// Create ntuples if they are booked
fNtupleManager->CreateNtuplesFromBooking();
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("open", "analysis file", name);
#endif
return finalResult;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::WriteImpl()
{
G4bool finalResult = true;
G4bool result = fFileManager->WriteFile();
finalResult = finalResult && result;
// Write ASCII if activated
if ( IsAscii() ) {
result = WriteAscii(fFileManager->GetFileName());
finalResult = finalResult && result;
}
return finalResult;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::CloseFileImpl()
{
G4bool finalResult = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("close", "file", fFileManager->GetFullFileName());
#endif
// reset data
Reset();
// close file
G4bool result = fFileManager->CloseFile();
finalResult = finalResult && result;
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("close", "file", fFileManager->GetFullFileName(), result);
#endif
return finalResult;
}
#endif
@@ -1,163 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/src/ExG4HbookFileManager.cc
/// \brief Implementation of the ExG4HbookFileManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookFileManager.hh"
#include "G4AnalysisManagerState.hh"
#include <iostream>
const G4String ExG4HbookFileManager::fgkDefaultNtupleDirectoryName = "ntuple";
//_____________________________________________________________________________
ExG4HbookFileManager::ExG4HbookFileManager(const G4AnalysisManagerState& state)
: G4VFileManager(state),
fFile(0)
{
}
//_____________________________________________________________________________
ExG4HbookFileManager::~ExG4HbookFileManager()
{
delete fFile;
}
//
// public methods
//
//_____________________________________________________________________________
G4bool ExG4HbookFileManager::OpenFile(const G4String& fileName)
{
// Keep file name
fFileName = fileName;
G4String name = GetFullFileName();
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("open", "analysis file", name);
#endif
// delete a previous file if it exists
if ( fFile ) delete fFile;
tools::hbook::CHCDIR("//PAWC"," ");
unsigned int unit = 1;
fFile = new tools::hbook::wfile(std::cout, name, unit);
if ( ! fFile->is_valid() ) {
G4ExceptionDescription description;
description << " " << "Cannot open file " << fileName;
G4Exception("G4HbookAnalysisManager::OpenFile()",
"Analysis_W001", JustWarning, description);
return false;
}
// At this point, in HBOOK, we should have :
// - created a //LUN1 directory attached to the file
// - created a //PAWC/LUN1 in memory
// - be in the directory //PAWC/LUN1.
// create an "histo" HBOOK directory both in memory and in the file :
if ( fHistoDirectoryName != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
tools::hbook::CHCDIR("//LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
}
// the five upper lines could have been done with :
//fFile->cd_home();
//fFile->mkcd("histo");
fLockFileName = true;
fLockHistoDirectoryName = true;
fLockNtupleDirectoryName = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("open", "analysis file", name);
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookFileManager::WriteFile()
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("write", "file", GetFullFileName());
#endif
// Return to //PAWC/LUN1 :
//tools::hbook::CHCDIR("//PAWC/LUN1"," ");
G4bool result = fFile->write();
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("write", "file", GetFullFileName(), result);
#endif
return result;
}
//_____________________________________________________________________________
G4bool ExG4HbookFileManager::CloseFile()
{
// close file
G4bool result = fFile->close();
fLockFileName = false;
return result;
}
//_____________________________________________________________________________
void ExG4HbookFileManager::CreateNtupleDirectory()
{
// Create an "ntuple" directory both in memory and in the file
static G4bool isDone = false;
// Do not create directory more than once
if (isDone) return;
fFile->cd_home(); //go under //PAWC/LUN1
if ( fNtupleDirectoryName == "" )
fFile->mkcd(fgkDefaultNtupleDirectoryName.data());
else
fFile->mkcd(fNtupleDirectoryName.data());
fLockNtupleDirectoryName = true;
isDone = false;
}
#endif
@@ -1,896 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/src/ExG4HbookH1Manager.cc
/// \brief Implementation of the ExG4HbookH1Manager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookH1Manager.hh"
#include "ExG4HbookFileManager.hh"
#include "G4HnManager.hh"
#include "G4AnalysisManagerState.hh"
#include "G4AnalysisUtilities.hh"
#include <fstream>
using namespace G4Analysis;
//_____________________________________________________________________________
ExG4HbookH1Manager::ExG4HbookH1Manager(const G4AnalysisManagerState& state)
: G4VH1Manager(state),
fFileManager(0),
fH1HbookIdOffset(-1),
fH1Vector(),
fH1BookingVector(),
fH1NameIdMap()
{
}
//_____________________________________________________________________________
ExG4HbookH1Manager::~ExG4HbookH1Manager()
{
// Delete h1
Reset();
// Delete h1 booking
std::vector<h1_booking*>::iterator it;
for ( it = fH1BookingVector.begin(); it != fH1BookingVector.end(); it++ ) {
delete *it;
}
}
//
// utility functions
//
namespace {
//_____________________________________________________________________________
void ConvertToFloat(const std::vector<G4double>& doubleVector,
std::vector<float>& floatVector)
{
for (G4int i=0; i<G4int(doubleVector.size()); ++i)
floatVector.push_back((float)doubleVector[i]);
}
//_____________________________________________________________________________
void UpdateH1Information(G4HnInformation* information,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
information->fXUnitName = unitName;
information->fYUnitName = unitName;
information->fXFcnName = fcnName;
information->fYFcnName = fcnName;
information->fXUnit = unit;
information->fYUnit = unit;
information->fXFcn = fcn;
information->fYFcn = fcn;
information->fXBinScheme = binScheme;
information->fYBinScheme = binScheme;
}
//_____________________________________________________________________________
h1_booking* CreateH1Booking(const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme)
{
G4Fcn fcn = GetFunction(fcnName);
h1_booking* h1Booking = 0;
if ( binScheme != kLogBinScheme ) {
if ( binScheme == kUserBinScheme ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
description
<< " User binning scheme setting was ignored." << G4endl
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
G4Exception("ExG4HbookH1Manager::CreateH1",
"Analysis_W013", JustWarning, description);
}
h1Booking = new h1_booking(nbins, fcn(xmin), fcn(xmax));
// h1_booking object is deleted in destructor
}
else {
// Compute edges
G4cout << " 1x1" << G4endl;
std::vector<G4double> edges;
G4cout << " 1x2" << G4endl;
ComputeEdges(nbins, xmin, xmax, fcn, binScheme, edges);
G4cout << " 1x2" << G4endl;
h1Booking = new h1_booking(edges);
// h1_booking object is deleted in destructor
}
h1Booking->fTitle = title;
UpdateTitle(h1Booking->fTitle, unitName, fcnName);
return h1Booking;
}
//_____________________________________________________________________________
h1_booking* CreateH1Booking(const G4String& title,
const std::vector<G4double>& edges,
const G4String& unitName,
const G4String& fcnName)
{
G4Fcn fcn = GetFunction(fcnName);
// Apply function
std::vector<G4double> newEdges;
ComputeEdges(edges, fcn, newEdges);
G4cout << " 11" << G4endl;
h1_booking* h1Booking = new h1_booking(newEdges);
G4cout << " 12" << G4endl;
// h1_booking object is deleted in destructor
h1Booking->fTitle = title;
UpdateTitle(h1Booking->fTitle, unitName, fcnName);
return h1Booking;
}
//_____________________________________________________________________________
void UpdateH1Booking(h1_booking* h1Booking,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
const G4String& binSchemeName)
{
G4Fcn fcn = GetFunction(fcnName);
G4BinScheme binScheme = GetBinScheme(binSchemeName);
if ( binScheme != kLogBinScheme ) {
if ( binScheme == kUserBinScheme ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
description
<< " User binning scheme setting was ignored." << G4endl
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
G4Exception("ExG4HbookH1Manager::SetH1",
"Analysis_W013", JustWarning, description);
}
h1Booking->fNbins = nbins;
h1Booking->fXmin = fcn(xmin);
h1Booking->fXmax = fcn(xmax);
}
else {
// Compute edges
ComputeEdges(nbins, xmin, xmax, fcn, binScheme, h1Booking->fEdges);
}
UpdateTitle(h1Booking->fTitle, unitName, fcnName);
}
//_____________________________________________________________________________
void UpdateH1Booking(h1_booking* h1Booking,
const std::vector<G4double>& edges,
const G4String& unitName,
const G4String& fcnName)
{
G4Fcn fcn = GetFunction(fcnName);
// Apply function
ComputeEdges(edges, fcn, h1Booking->fEdges);
UpdateTitle(h1Booking->fTitle, unitName, fcnName);
}
//_____________________________________________________________________________
void ConfigureHbookH1(tools::hbook::h1* h1,
G4int nbins, G4double xmin, G4double xmax,
const G4String& fcnName,
G4BinScheme binScheme)
{
G4Fcn fcn = GetFunction(fcnName);
if ( binScheme != kLogBinScheme ) {
if ( binScheme == kUserBinScheme ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
description
<< " User binning scheme setting was ignored." << G4endl
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
G4Exception("ExG4HbookH1Manager::SetH1",
"Analysis_W013", JustWarning, description);
}
h1->configure(nbins, fcn(xmin), fcn(xmax));
}
else {
// Compute bins
std::vector<G4double> edges;
ComputeEdges(nbins, xmin, xmax, fcn, binScheme, edges);
// Convert to float
std::vector<float> fedges;
ConvertToFloat(edges, fedges);
h1->configure(fedges);
}
}
//_____________________________________________________________________________
void ConfigureHbookH1(tools::hbook::h1* h1,
const std::vector<G4double>& edges,
const G4String& fcnName)
{
// Apply function to edges
G4Fcn fcn = GetFunction(fcnName);
std::vector<G4double> newEdges;
ComputeEdges(edges, fcn, newEdges);
// Convert to float
std::vector<float> newFEdges;
ConvertToFloat(newEdges, newFEdges);
h1->configure(newFEdges);
}
}
//
// private methods
//
//_____________________________________________________________________________
void ExG4HbookH1Manager::SetH1HbookIdOffset()
{
// Set fH1HbookIdOffset if needed
if ( fH1HbookIdOffset == -1 ) {
if ( fFirstId > 0 )
fH1HbookIdOffset = 0;
else
fH1HbookIdOffset = 1;
if ( fH1HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
G4Exception("ExG4HbookH1Manager::SetH1HbookIdOffset()",
"Analysis_W011", JustWarning, description);
}
}
}
//_____________________________________________________________________________
void ExG4HbookH1Manager::AddH1Information(const G4String& name,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme) const
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
fHnManager->AddH1Information(name, unitName, fcnName, unit, fcn, binScheme);
}
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::CreateH1FromBooking(h1_booking* h1Booking,
G4bool chDir)
{
// Create h1 from h1_booking.
if ( chDir ) {
// Go to histograms directory if defined
if ( fFileManager->GetHistoDirectoryName() != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fFileManager->GetHistoDirectoryName().data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
}
G4int index = fH1Vector.size();
G4int id = index + fFirstId;
G4HnInformation*
info = fHnManager->GetHnInformation(id, "CreateH1FromBooking");
// Hbook index
G4int hbookIndex = fH1HbookIdOffset + index + fFirstId;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("create from booking", "h1", info->fName);
#endif
// Create h1
tools::hbook::h1* h1 = 0;
if ( ! h1Booking->fEdges.size() ) {
h1 = new tools::hbook::h1(
hbookIndex, h1Booking->fTitle,
h1Booking->fNbins, h1Booking->fXmin, h1Booking->fXmax);
}
else {
// Convert to float
std::vector<float> newEdges;
ConvertToFloat(h1Booking->fEdges, newEdges);
h1 = new tools::hbook::h1(hbookIndex, h1Booking->fTitle, newEdges);
}
fH1Vector.push_back(h1);
if ( chDir ) {
if ( fFileManager->GetHistoDirectoryName() != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() ) {
G4ExceptionDescription description;
description << " name : " << info->fName << " hbook index : " << hbookIndex;
fState.GetVerboseL3()->Message("create from booking", "h1", description);
}
#endif
return id;
}
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::RegisterH1Booking(const G4String& name,
h1_booking* h1Booking)
{
// Register h1
G4int index = fH1BookingVector.size();
fH1BookingVector.push_back(h1Booking);
fH1NameIdMap[name] = index + fFirstId;
// Lock id
fLockFirstId = true;
return index + fFirstId;
}
//_____________________________________________________________________________
void ExG4HbookH1Manager::BeginCreateH1(const G4String& name)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("create", "H1", name);
#endif
// Set fH1HbookIdOffset if needed
SetH1HbookIdOffset();
}
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::FinishCreateH1(
const G4String& name, h1_booking* h1Booking,
const G4String& unitName, const G4String& fcnName,
G4BinScheme binScheme)
{
// Register h1 booking
G4int id = RegisterH1Booking(name, h1Booking);
// Save H1 information
AddH1Information(name, unitName, fcnName, binScheme);
// Create h1 if the file is open
if ( fFileManager->IsFile() ) {
CreateH1FromBooking(h1Booking);
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4int hbookIndex = fH1HbookIdOffset + id;
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fState.GetVerboseL2()->Message("create", "H1", description);
}
#endif
return id;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::BeginSetH1(
G4int id,
h1_booking* h1Booking,
G4HnInformation* info)
{
h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH1()",
"Analysis_W007", JustWarning, description);
return false;
}
info = fHnManager->GetHnInformation(id,"SetH1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H1", info->fName);
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::FinishSetH1(
G4int id,
G4HnInformation* info,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme)
{
// Update information
UpdateH1Information(info, unitName, fcnName, binScheme);
// Set activation
fHnManager->SetActivation(id, true);
return true;
}
//_____________________________________________________________________________
void ExG4HbookH1Manager::CreateH1sFromBooking()
{
// Create all h1 from h1_booking.
// Do nothing if any h1 histogram already exists
// or no h1 histograms are booked
if ( fH1Vector.size() || ( fH1BookingVector.size() == 0 ) ) return;
// Go to histograms directory if defined
if ( fFileManager->GetHistoDirectoryName() != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fFileManager->GetHistoDirectoryName().data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Create histograms
std::vector<h1_booking*>::const_iterator it;
for ( it = fH1BookingVector.begin(); it != fH1BookingVector.end(); ++it) {
CreateH1FromBooking(*it, false);
}
// Return backi from histograms directory if defined
if ( fFileManager->GetHistoDirectoryName() != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
}
//_____________________________________________________________________________
void ExG4HbookH1Manager::Reset()
{
// Reset histograms and ntuple
// Delete histograms
std::vector<tools::hbook::h1*>::iterator it;
for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
delete *it;
}
// Clear vectors
fH1Vector.clear();
}
//_____________________________________________________________________________
h1_booking* ExG4HbookH1Manager::GetH1Booking(G4int id, G4bool warn) const
{
G4int index = id - fFirstId;
if ( index < 0 || index >= G4int(fH1BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH1Booking()",
"Analysis_W007", JustWarning, description);
}
return 0;
}
return fH1BookingVector[index];
}
//
// protected methods
//
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::WriteOnAscii(std::ofstream& output)
{
// Write selected objects on ASCII file
// (Only H1 implemented by now)
// According to the implementation by Michel Maire, originally in
// extended examples.
// h1 histograms
for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) {
G4int id = i + fFirstId;
G4HnInformation* info
= fHnManager->GetHnInformation(id, "WriteOnAscii");
// skip writing if activation is enabled and H1 is inactivated
if ( ! info->fAscii ) continue;
tools::hbook::h1* h1 = fH1Vector[i];
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()->Message("write on ascii", "h1", info->fName);
#endif
output << "\n 1D histogram " << id << ": " << h1->title()
<< "\n \n \t X \t\t Y" << G4endl;
for (G4int j=0; j< G4int(h1->axis().bins()); ++j) {
output << " " << j << "\t"
<< h1->axis().bin_center(j) << "\t"
<< h1->bin_height(j) << G4endl;
}
}
return true;
}
//_____________________________________________________________________________
tools::hbook::h1* ExG4HbookH1Manager::GetH1InFunction(G4int id,
G4String functionName, G4bool warn,
G4bool onlyIfActive) const
{
G4int index = id - fFirstId;
if ( index < 0 || index >= G4int(fH1Vector.size()) ) {
if ( warn) {
G4String inFunction = "ExG4HbookH1Manager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W007", JustWarning, description);
}
return 0;
}
// Do not return histogram if inactive
if ( fState.GetIsActivation() && onlyIfActive && ( ! fHnManager->GetActivation(id) ) ) {
return 0;
}
return fH1Vector[index];
}
//
// public methods
//
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::CreateH1(
const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName, const G4String& fcnName,
const G4String& binSchemeName)
{
BeginCreateH1(name);
G4BinScheme binScheme = GetBinScheme(binSchemeName);
// Create h1 booking
h1_booking* h1Booking
= CreateH1Booking(title, nbins, xmin, xmax, unitName, fcnName, binScheme);
return FinishCreateH1(name, h1Booking, unitName, fcnName, binScheme);
}
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::CreateH1(
const G4String& name, const G4String& title,
const std::vector<G4double>& edges,
const G4String& unitName,
const G4String& fcnName)
{
BeginCreateH1(name);
// Create h1 booking
h1_booking* h1Booking
= CreateH1Booking(title, edges, unitName, fcnName);
return FinishCreateH1(name, h1Booking, unitName, fcnName, kUserBinScheme);
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1(G4int id,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
const G4String& binSchemeName)
{
h1_booking* h1Booking = 0;
G4HnInformation* info = 0;
if ( ! BeginSetH1(id, h1Booking, info) ) return false;
G4BinScheme binScheme = GetBinScheme(binSchemeName);
// Update H1 booking
UpdateH1Booking(h1Booking,
nbins, xmin, xmax, unitName, fcnName, binScheme);
// Re-configure histogram if it was already defined
if ( fH1Vector.size() ) {
tools::hbook::h1* h1 = GetH1(id);
ConfigureHbookH1(h1, nbins, xmin, xmax, fcnName, binScheme);
}
return FinishSetH1(id, info, unitName, fcnName, binScheme);
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1(G4int id,
const std::vector<G4double>& edges,
const G4String& unitName,
const G4String& fcnName)
{
h1_booking* h1Booking = 0;
G4HnInformation* info = 0;
if ( ! BeginSetH1(id, h1Booking, info) ) return false;
// Update H1 booking
UpdateH1Booking(h1Booking, edges, unitName, fcnName);
// Re-configure histogram if it was already defined
if ( fH1Vector.size() ) {
tools::hbook::h1* h1 = GetH1(id);
ConfigureHbookH1(h1, edges, fcnName);
}
return
FinishSetH1(id, info, unitName, fcnName, kUserBinScheme);
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::ScaleH1(G4int id, G4double factor)
{
tools::hbook::h1* h1 = GetH1InFunction(id, "ScaleH1", false, false);
if ( ! h1 ) return false;
return h1->scale(factor);
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::FillH1(G4int id, G4double value, G4double weight)
{
tools::hbook::h1* h1 = GetH1InFunction(id, "FillH1", true, false);
if ( ! h1 ) return false;
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
//G4cout << "Skipping FillH1 for " << id << G4endl;
return false;
}
G4HnInformation* info = fHnManager->GetHnInformation(id, "FillH1");
h1->fill(info->fXFcn(value/info->fXUnit), weight);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fState.GetVerboseL4()->Message("fill", "H1", description);
}
#endif
return true;
}
//_____________________________________________________________________________
tools::hbook::h1* ExG4HbookH1Manager::GetH1(G4int id, G4bool warn,
G4bool onlyIfActive) const
{
return GetH1InFunction(id, "GetH1", warn, onlyIfActive);
}
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::GetH1Id(const G4String& name, G4bool warn) const
{
std::map<G4String, G4int>::const_iterator it = fH1NameIdMap.find(name);
if ( it == fH1NameIdMap.end() ) {
if ( warn) {
G4String inFunction = "ExG4HbookH1Manager::GetH1Id";
G4ExceptionDescription description;
description << " " << "histogram " << name << " does not exist.";
G4Exception(inFunction, "Analysis_W007", JustWarning, description);
}
return -1;
}
return it->second;
}
//_____________________________________________________________________________
G4int ExG4HbookH1Manager::GetH1Nbins(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1Nbins");
if ( ! h1 ) return 0;
return h1->axis().bins();
}
//_____________________________________________________________________________
G4double ExG4HbookH1Manager::GetH1Xmin(G4int id) const
{
// Returns xmin value with applied unit and histogram function
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1Xmin");
if ( ! h1 ) return 0;
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH1Xmin");
return info->fXFcn(h1->axis().lower_edge()*info->fXUnit);
}
//_____________________________________________________________________________
G4double ExG4HbookH1Manager::GetH1Xmax(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1Xmax");
if ( ! h1 ) return 0;
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH1Xmax");
return info->fXFcn(h1->axis().upper_edge()*info->fXUnit);
}
//_____________________________________________________________________________
G4double ExG4HbookH1Manager::GetH1Width(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1XWidth", true, false);
if ( ! h1 ) return 0;
G4int nbins = h1->axis().bins();
if ( ! nbins ) {
G4ExceptionDescription description;
description << " nbins = 0 (for h1 id = " << id << ").";
G4Exception("ExG4HbookH1Manager::GetH1Width",
"Analysis_W014", JustWarning, description);
return 0;
}
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH1XWidth");
return ( info->fXFcn(h1->axis().upper_edge())
- info->fXFcn(h1->axis().lower_edge()))*info->fXUnit/nbins;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1Title(G4int id, const G4String& title)
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH1Title()",
"Analysis_W007", JustWarning, description);
return false;
}
h1Booking->fTitle = title;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1XAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1XAxisTitle");
if ( ! h1 ) return false;
h1->add_annotation(tools::hbook::key_axis_x_title(), title);
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1YAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1YAxisTitle");
if ( ! h1 ) return false;
h1->add_annotation(tools::hbook::key_axis_y_title(), title);
return true;
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1Title(G4int id) const
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH1Title()",
"Analysis_W007", JustWarning, description);
return "";
}
return h1Booking->fTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1XAxisTitle(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1XAxisTitle");
if ( ! h1 ) return "";
G4String title;
G4bool result = h1->annotation(tools::hbook::key_axis_x_title(), title);
if ( ! result ) {
G4ExceptionDescription description;
description << " Failed to get x_axis title for h1 id = " << id << ").";
G4Exception("ExG4HbookH1Manager::GetH1XAxisTitle",
"Analysis_W014", JustWarning, description);
return "";
}
return title;
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1YAxisTitle(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1YAxisTitle");
if ( ! h1 ) return "";
G4String title;
G4bool result = h1->annotation(tools::hbook::key_axis_y_title(), title);
if ( ! result ) {
G4ExceptionDescription description;
description << " Failed to get y_axis title for h1 id = " << id << ").";
G4Exception("ExG4HbookH1Manager::GetH1YAxisTitle",
"Analysis_W014", JustWarning, description);
return "";
}
return title;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1HbookIdOffset(G4int offset)
{
if ( fH1Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fH1HbookIdOffset = offset;
return true;
}
#endif
@@ -1,721 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/src/ExG4HbookH2Manager.cc
/// \brief Implementation of the ExG4HbookH2Manager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookH2Manager.hh"
#include "ExG4HbookFileManager.hh"
#include "G4HnManager.hh"
#include "G4AnalysisManagerState.hh"
#include "G4AnalysisUtilities.hh"
#include <iostream>
using namespace G4Analysis;
const G4int ExG4HbookH2Manager::fgkDefaultH2HbookIdOffset = 100;
//_____________________________________________________________________________
ExG4HbookH2Manager::ExG4HbookH2Manager(const G4AnalysisManagerState& state)
: G4VH2Manager(state),
fFileManager(0),
fH2HbookIdOffset(-1),
fH2Vector(),
fH2BookingVector(),
fH2NameIdMap()
{
}
//_____________________________________________________________________________
ExG4HbookH2Manager::~ExG4HbookH2Manager()
{
// Delete h2
Reset();
// Delete h2 booking
std::vector<h2_booking*>::iterator it2;
for ( it2 = fH2BookingVector.begin(); it2 != fH2BookingVector.end(); it2++ ) {
delete *it2;
}
}
//
// private methods
//
//_____________________________________________________________________________
void ExG4HbookH2Manager::SetH2HbookIdOffset()
{
// Set fH2HbookIdOffset if needed
if ( fH2HbookIdOffset == -1 ) {
if ( fFirstId > 0 )
fH2HbookIdOffset = 0;
else
fH2HbookIdOffset = 1;
if ( fH2HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "H2 will be defined in HBOOK with ID = G4_firstHistoId + 1";
G4Exception("ExG4HbookH2Manager::SetH1HbookIdOffset",
"Analysis_W011", JustWarning, description);
}
}
}
//_____________________________________________________________________________
void ExG4HbookH2Manager::CreateH2sFromBooking()
{
// Create h2 from h2_booking.
// Do nothing if any h2 histogram already exists
// or no h2 histograms are booked
if ( fH2Vector.size() || ( fH2BookingVector.size() == 0 ) ) return;
// Go to histograms directory
if ( fFileManager->GetHistoDirectoryName() != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fFileManager->GetHistoDirectoryName().data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Create histograms
G4int index = 0;
std::vector<h2_booking*>::const_iterator it;
for ( it = fH2BookingVector.begin(); it != fH2BookingVector.end(); ++it) {
// Get information
G4int id = index + fFirstId;
G4HnInformation* info = fHnManager->GetHnInformation(id, "CreateH2FromBooking");
// Hbook index
G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
++index;
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()->Message("create from booking", "h2", info->fName);
#endif
// Create h2
tools::hbook::h2* h2
= new tools::hbook::h2(hbookIndex, (*it)->fTitle,
(*it)->fNxbins, (*it)->fXmin, (*it)->fXmax,
(*it)->fNybins, (*it)->fYmin, (*it)->fYmax);
fH2Vector.push_back(h2);
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() ) {
G4ExceptionDescription description;
description << " name : " << info->fName << " hbook index : " << hbookIndex;
fState.GetVerboseL3()->Message("create from booking", "h2", description);
}
#endif
}
if ( fFileManager->GetHistoDirectoryName() != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
}
//_____________________________________________________________________________
void ExG4HbookH2Manager::Reset()
{
// Reset histograms and ntuple
// Delete histograms
std::vector<tools::hbook::h2*>::iterator it2;
for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
delete *it2;
}
// Clear vectors
fH2Vector.clear();
}
//_____________________________________________________________________________
h2_booking* ExG4HbookH2Manager::GetH2Booking(G4int id, G4bool warn) const
{
G4int index = id - fFirstId;
if ( index < 0 || index >= G4int(fH2BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH2Booking()",
"Analysis_W007", JustWarning, description);
}
return 0;
}
return fH2BookingVector[index];
}
//
// protected methods
//
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::WriteOnAscii(std::ofstream& /*output*/)
{
// Write selected objects on ASCII file
// According to the implementation by Michel Maire, originally in
// extended examples.
// Not yet available for H2
return false;
}
//_____________________________________________________________________________
tools::hbook::h2* ExG4HbookH2Manager::GetH2InFunction(G4int id,
G4String functionName, G4bool warn,
G4bool onlyIfActive) const
{
G4int index = id - fFirstId;
if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
if ( warn) {
G4String inFunction = "ExG4HbookH2Manager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W007", JustWarning, description);
}
return 0;
}
// Do not return histogram if inactive
if ( fState.GetIsActivation() && onlyIfActive && ( ! fHnManager->GetActivation(id) ) ) {
return 0;
}
return fH2Vector[index];
}
//
// public methods
//
//_____________________________________________________________________________
G4int ExG4HbookH2Manager::CreateH2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
const G4String& xunitName, const G4String& yunitName,
const G4String& xfcnName, const G4String& yfcnName,
const G4String& xbinSchemeName,
const G4String& ybinSchemeName)
{
// HBook does not support user defined binning for H2
if ( xbinSchemeName != "linear" || ybinSchemeName != "linear" ) {
G4ExceptionDescription description;
description
<< " "
<< "Logarithimc binning is not supported for H2.";
G4Exception("ExG4HbookH2Manager::CreateH2",
"Analysis_F015", FatalException, description);
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("create", "H2", name);
#endif
// Create h2 booking & information
G4int index = fH2BookingVector.size();
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
G4String newTitle(title);
UpdateTitle(newTitle, xunitName, xfcnName);
UpdateTitle(newTitle, yunitName, yfcnName);
h2_booking* h2Booking = new h2_booking(nxbins, xfcn(xmin), xfcn(xmax),
nybins, yfcn(ymin), yfcn(ymax));
// h2_booking object is deleted in destructor
h2Booking->fTitle = newTitle;
fH2BookingVector.push_back(h2Booking);
fHnManager
->AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
xunit, yunit, xfcn, yfcn, xbinScheme, ybinScheme);
// Set fH1HbookIdOffset if needed
SetH2HbookIdOffset();
// Hbook index
G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
// Create h2 if the file is open
if ( fFileManager->IsFile() ) {
// Go to histograms directory
G4String histoPath = "//PAWC/LUN1/";
if ( fFileManager->GetHistoDirectoryName() != "" ) {
histoPath.append(fFileManager->GetHistoDirectoryName().data());
}
tools::hbook::CHCDIR(histoPath.data()," ");
// Create histogram
tools::hbook::h2* h2
= new tools::hbook::h2(hbookIndex, title,
nxbins, xfcn(xmin), xfcn(xmax),
nybins, yfcn(ymin), yfcn(ymax));
// h2 objects are deleted when closing a file.
fH2Vector.push_back(h2);
// Return to //PAWC/LUN1
if ( fFileManager->GetHistoDirectoryName() != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
}
fLockFirstId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fState.GetVerboseL2()->Message("create", "H2", description);
}
#endif
fH2NameIdMap[name] = index + fFirstId;
return index + fFirstId;
}
//_____________________________________________________________________________
G4int ExG4HbookH2Manager::CreateH2(const G4String& /*name*/, const G4String& /*title*/,
const std::vector<G4double>& /*xedges*/,
const std::vector<G4double>& /*yedges*/,
const G4String& /*xunitName*/, const G4String& /*yunitName*/,
const G4String& /*xfcnName*/, const G4String& /*yfcnName*/)
{
// HBook does not support user defined binning for H2
G4ExceptionDescription description;
description
<< " "
<< "User defined binning is not supported for H2.";
G4Exception("ExG4HbookH2Manager::CreateH2",
"Analysis_F015", FatalException, description);
return 0;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2(G4int id,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
const G4String& xunitName, const G4String& yunitName,
const G4String& xfcnName, const G4String& yfcnName,
const G4String& xbinScheme, const G4String& ybinScheme)
{
// HBook does not support user defined binning for H2
if ( xbinScheme != "linear" || ybinScheme != "linear" ) {
G4ExceptionDescription description;
description
<< " "
<< "Logarithimc binning is not supported for H2.";
G4Exception("ExG4HbookH2Manager::CreateH2",
"Analysis_F015", FatalException, description);
}
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH2()",
"Analysis_W007", JustWarning, description);
return false;
}
G4HnInformation* info = fHnManager->GetHnInformation(id, "SetH2");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H2", info->fName);
#endif
// Keep new parameters in booking & information
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
h2Booking->fNxbins = nxbins;
h2Booking->fXmin = xfcn(xmin);
h2Booking->fXmax = xfcn(xmax);
h2Booking->fNybins = nybins;
h2Booking->fYmin = yfcn(ymin);
h2Booking->fYmax = yfcn(ymax);
info->fXUnitName = xunitName;
info->fYUnitName = yunitName;
info->fXFcnName = xfcnName;
info->fYFcnName = yfcnName;
info->fXUnit = xunit;
info->fYUnit = yunit;
info->fXFcn = xfcn;
info->fYFcn = yfcn;
fHnManager->SetActivation(id, true);
G4String newTitle(h2Booking->fTitle);
UpdateTitle(newTitle, xunitName, xfcnName);
UpdateTitle(newTitle, yunitName, yfcnName);
h2Booking->fTitle = newTitle;
// Re-configure histogram if it was already defined
if ( fH2Vector.size() ) {
tools::hbook::h2* h2 = GetH2(id);
h2->configure(nxbins, xfcn(xmin), xfcn(xmax),
nybins, yfcn(ymin), yfcn(ymax));
}
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2(G4int /*id*/,
const std::vector<G4double>& /*xedges*/,
const std::vector<G4double>& /*yedges*/,
const G4String& /*xunitName*/, const G4String& /*yunitName*/,
const G4String& /*xfcnName*/, const G4String& /*yfcnName*/)
{
// HBook does not support user defined binning for H2
G4ExceptionDescription description;
description
<< " "
<< "User defined binning is not supported for H2.";
G4Exception("ExG4HbookH2Manager::CreateH2",
"Analysis_F015", FatalException, description);
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::ScaleH2(G4int id, G4double factor)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "ScaleH2", false, false);
if ( ! h2 ) return false;
return h2->scale(factor);
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::FillH2(G4int id,
G4double xvalue, G4double yvalue,
G4double weight)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "FillH2", true, false);
if ( ! h2 ) return false;
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) return false;
G4HnInformation* info = fHnManager->GetHnInformation(id, "FillH2");
h2->fill(info->fXFcn(xvalue/info->fXUnit),
info->fYFcn(yvalue/info->fYUnit), weight);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " id " << id
<< " xvalue " << xvalue << " yvalue " << yvalue;
fState.GetVerboseL4()->Message("fill", "H2", description);
}
#endif
return true;
}
//_____________________________________________________________________________
tools::hbook::h2* ExG4HbookH2Manager::GetH2(G4int id, G4bool warn,
G4bool onlyIfActive) const
{
return GetH2InFunction(id, "GetH2", warn, onlyIfActive);
}
//_____________________________________________________________________________
G4int ExG4HbookH2Manager::GetH2Id(const G4String& name, G4bool warn) const
{
std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name);
if ( it == fH2NameIdMap.end() ) {
if ( warn) {
G4String inFunction = "ExG4HbookH2Manager::GetH2Id";
G4ExceptionDescription description;
description << " " << "histogram " << name << " does not exist.";
G4Exception(inFunction, "Analysis_W007", JustWarning, description);
}
return -1;
}
return it->second;
}
//_____________________________________________________________________________
G4int ExG4HbookH2Manager::GetH2Nxbins(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2NXbins");
if ( ! h2 ) return 0;
return h2->axis_x().bins();
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2Xmin(G4int id) const
{
// Returns xmin value with applied unit and histogram function
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Xmin");
if ( ! h2 ) return 0;
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH2Xmin");
return info->fXFcn(h2->axis_x().lower_edge()*info->fXUnit);
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2Xmax(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Xmax");
if ( ! h2 ) return 0;
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH2Xmax");
return info->fXFcn(h2->axis_x().upper_edge()*info->fXUnit);
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2XWidth(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2XWidth", true, false);
if ( ! h2 ) return 0;
G4int nbins = h2->axis_x().bins();
if ( ! nbins ) {
G4ExceptionDescription description;
description << " nbins = 0 (for h1 id = " << id << ").";
G4Exception("ExG4HbookH2Manager::GetH2Width",
"Analysis_W014", JustWarning, description);
return 0;
}
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH2XWidth");
return ( info->fXFcn(h2->axis_x().upper_edge())
- info->fXFcn(h2->axis_x().lower_edge()))*info->fXUnit/nbins;
}
//_____________________________________________________________________________
G4int ExG4HbookH2Manager::GetH2Nybins(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2NYbins");
if ( ! h2 ) return 0;
return h2->axis_y().bins();
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2Ymin(G4int id) const
{
// Returns xmin value with applied unit and histogram function
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Ymin");
if ( ! h2 ) return 0;
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH2Ymin");
return info->fYFcn(h2->axis_y().lower_edge()*info->fYUnit);
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2Ymax(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Ymax");
if ( ! h2 ) return 0;
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH2Ymax");
return info->fYFcn(h2->axis_y().upper_edge()*info->fYUnit);
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2YWidth(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2YWidth", true, false);
if ( ! h2 ) return 0;
G4int nbins = h2->axis_y().bins();
if ( ! nbins ) {
G4ExceptionDescription description;
description << " nbins = 0 (for h1 id = " << id << ").";
G4Exception("ExG4HbookH2Manager::GetH2Width",
"Analysis_W014", JustWarning, description);
return 0;
}
G4HnInformation* info = fHnManager->GetHnInformation(id, "GetH2YWidth");
return ( info->fYFcn(h2->axis_y().upper_edge())
- info->fYFcn(h2->axis_y().lower_edge()))*info->fYUnit/nbins;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2Title(G4int id, const G4String& title)
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH2Title()",
"Analysis_W007", JustWarning, description);
return false;
}
h2Booking->fTitle = title;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2XAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2XAxisTitle");
if ( ! h2 ) return false;
h2->add_annotation(tools::hbook::key_axis_x_title(), title);
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2YAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2YAxisTitle");
if ( ! h2 ) return false;
h2->add_annotation(tools::hbook::key_axis_x_title(), title);
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2ZAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2ZAxisTitle");
if ( ! h2 ) return false;
h2->add_annotation(tools::hbook::key_axis_z_title(), title);
return true;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2Title(G4int id) const
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH2Title()",
"Analysis_W007", JustWarning, description);
return "";
}
return h2Booking->fTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2XAxisTitle(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2XAxisTitle");
if ( ! h2 ) return "";
G4String title;
G4bool result = h2->annotation(tools::hbook::key_axis_x_title(), title);
if ( ! result ) {
G4ExceptionDescription description;
description << " Failed to get x_axis title for h2 id = " << id << ").";
G4Exception("ExG4HbookH2Manager::GetH2XAxisTitle",
"Analysis_W014", JustWarning, description);
return "";
}
return title;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2YAxisTitle(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2YAxisTitle");
if ( ! h2 ) return "";
G4String title;
G4bool result = h2->annotation(tools::hbook::key_axis_y_title(), title);
if ( ! result ) {
G4ExceptionDescription description;
description << " Failed to get y_axis title for h2 id = " << id << ").";
G4Exception("ExG4HbookH2Manager::GetH2YAxisTitle",
"Analysis_W014", JustWarning, description);
return "";
}
return title;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2ZAxisTitle(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2ZAxisTitle");
if ( ! h2 ) return "";
G4String title;
G4bool result = h2->annotation(tools::hbook::key_axis_z_title(), title);
if ( ! result ) {
G4ExceptionDescription description;
description << " Failed to get z_axis title for h2 id = " << id << ").";
G4Exception("ExG4HbookH2Manager::GetH2ZAxisTitle",
"Analysis_W014", JustWarning, description);
return "";
}
return title;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2HbookIdOffset(G4int offset)
{
if ( fH2Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fH2HbookIdOffset = offset;
return true;
}
#endif
@@ -1,698 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
/// \file common/analysis/src/ExG4HbookNtupleManager.cc
/// \brief Implementation of the ExG4HbookNtupleManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookNtupleManager.hh"
#include "ExG4HbookFileManager.hh"
#include "G4AnalysisManagerState.hh"
#include "G4UnitsTable.hh"
#include <iostream>
//_____________________________________________________________________________
ExG4HbookNtupleManager::ExG4HbookNtupleManager(const G4AnalysisManagerState& state)
: G4VNtupleManager(state),
fNtupleHbookIdOffset(-1),
fNtupleVector()
{
}
//_____________________________________________________________________________
ExG4HbookNtupleManager::~ExG4HbookNtupleManager()
{
// Reset();
std::vector<ExG4HbookNtupleDescription*>::iterator it;
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
delete *it;
}
}
//
// private methods
//
//_____________________________________________________________________________
void ExG4HbookNtupleManager::SetNtupleHbookIdOffset()
{
// Set fH1HbookIdOffset if needed
if ( fNtupleHbookIdOffset == -1 ) {
if ( fFirstId > 0 )
fNtupleHbookIdOffset = 0;
else
fNtupleHbookIdOffset = 1;
if ( fNtupleHbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "Ntuple will be defined in HBOOK with ID = G4_firstNtupleId + 1";
G4Exception("ExG4HbookNtupleManager::SetNtupleHbookIdOffset()",
"Analysis_W011", JustWarning, description);
}
}
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::CreateNtuplesFromBooking()
{
// Create ntuple from ntuple_booking.
if ( ! fNtupleVector.size() ) return;
// Set fNtupleHbookIdOffset if needed
SetNtupleHbookIdOffset();
G4int index = 0;
std::vector<ExG4HbookNtupleDescription*>::iterator itn;
for (itn = fNtupleVector.begin(); itn != fNtupleVector.end(); itn++ ) {
tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
if ( ! ntupleBooking ) continue;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()
->Message("create from booking", "ntuple", ntupleBooking->m_name);
#endif
// Create an "ntuple" directory both in memory and in the file
fFileManager->CreateNtupleDirectory();
G4int hbookIndex = fNtupleHbookIdOffset + index + fFirstId;
++index;
// We should be under //PAWC/LUN1/ntuple
(*itn)->fNtuple
= new tools::hbook::wntuple(hbookIndex, G4cout, *ntupleBooking);
if ( ntupleBooking->m_columns.size() ) {
// store ntuple columns in local maps
const std::vector<tools::ntuple_booking::col_t>& columns
= ntupleBooking->m_columns;
std::vector<tools::ntuple_booking::col_t>::const_iterator it;
G4int counter = 0;
for ( it = columns.begin(); it!=columns.end(); ++it) {
if ( (*it).second == tools::_cid(int(0) ) ) {
(*itn)->fNtupleIColumnMap[counter++]
= (*itn)->fNtuple->find_column<int>((*it).first);
}
else if( (*it).second == tools::_cid(float(0) ) ) {
(*itn)->fNtupleFColumnMap[counter++]
= (*itn)->fNtuple->find_column<float>((*it).first);
}
else if((*it).second== tools::_cid(double(0))) {
(*itn)->fNtupleDColumnMap[counter++]
= (*itn)->fNtuple->find_column<double>((*it).first);
}
else {
G4ExceptionDescription description;
description << " "
<< "Unsupported column type " << (*it).first;
G4Exception("G4HbookAnalysisManager::CreateNtupleFromBooking()",
"Analysis_W004", JustWarning, description);
}
}
}
FinishNtuple();
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()
->Message("create from booking", "ntuple", ntupleBooking->m_name);
#endif
}
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<int>*
ExG4HbookNtupleManager::GetNtupleIColumn(G4int ntupleId, G4int columnId) const
{
ExG4HbookNtupleDescription* ntupleDecription
= GetNtupleInFunction(ntupleId, "GetNtupleIColumn");
if ( ! ntupleDecription ) return 0;
std::map<G4int, tools::hbook::wntuple::column<int>* >& ntupleIColumnMap
= ntupleDecription->fNtupleIColumnMap;
std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
= ntupleIColumnMap.find(columnId);
if ( it == ntupleIColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< "column " << columnId << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleIColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<float>*
ExG4HbookNtupleManager::GetNtupleFColumn(G4int ntupleId, G4int columnId) const
{
ExG4HbookNtupleDescription* ntupleDecription
= GetNtupleInFunction(ntupleId, "GetNtupleFColumn");
if ( ! ntupleDecription ) return 0;
std::map<G4int, tools::hbook::wntuple::column<float>* >& ntupleFColumnMap
= ntupleDecription->fNtupleFColumnMap;
std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
= ntupleFColumnMap.find(columnId);
if ( it == ntupleFColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< "column " << columnId << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleFColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<double>*
ExG4HbookNtupleManager::GetNtupleDColumn(G4int ntupleId, G4int columnId) const
{
ExG4HbookNtupleDescription* ntupleDecription
= GetNtupleInFunction(ntupleId, "GetNtupleDColumn");
if ( ! ntupleDecription ) return 0;
std::map<G4int, tools::hbook::wntuple::column<double>* >& ntupleDColumnMap
= ntupleDecription->fNtupleDColumnMap;
std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
= ntupleDColumnMap.find(columnId);
if ( it == ntupleDColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< "column " << columnId << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleDColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::Reset()
{
// Reset ntuple
std::vector<ExG4HbookNtupleDescription*>::iterator it3;
for (it3 = fNtupleVector.begin(); it3 != fNtupleVector.end(); it3++ ) {
delete (*it3)->fNtuple;
(*it3)->fNtuple = 0;
}
}
//
// protected methods
//
//_____________________________________________________________________________
ExG4HbookNtupleDescription* ExG4HbookNtupleManager::GetNtupleInFunction(
G4int id,
G4String functionName, G4bool warn,
G4bool /*onlyIfActive*/) const
{
G4int index = id - fFirstId;
if ( index < 0 || index >= G4int(fNtupleVector.size()) ) {
if ( warn) {
G4String inFunction = "G4HbookAnalysisManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "ntuple " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W007", JustWarning, description);
}
return 0;
}
return fNtupleVector[index];
}
//
// public methods
//
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtuple(const G4String& name,
const G4String& title)
{
// Create an "ntuple" directory both in memory and in the file
if ( fFileManager->IsFile() )
fFileManager->CreateNtupleDirectory();
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("create", "ntuple", name);
#endif
// Create ntuple description
G4int index = fNtupleVector.size();
ExG4HbookNtupleDescription* ntupleDescription
= new ExG4HbookNtupleDescription();
fNtupleVector.push_back(ntupleDescription);
// Create ntuple booking
ntupleDescription->fNtupleBooking = new tools::ntuple_booking();
ntupleDescription->fNtupleBooking->m_name = name;
ntupleDescription->fNtupleBooking->m_title = title;
// ntuple booking object is deleted in destructor
// Set fNtupleHbookIdOffset if needed
SetNtupleHbookIdOffset();
// Create ntuple if the file is open
// We should be under //PAWC/LUN1/ntuple
if ( fFileManager->IsFile() ) {
G4int hbookIndex = fNtupleHbookIdOffset + index + fFirstId;
ntupleDescription->fNtuple
= new tools::hbook::wntuple(hbookIndex, name);
// ntuple object is deleted when closing a file
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << index + fFirstId;
fState.GetVerboseL2()->Message("create", "ntuple", description);
}
#endif
return index + fFirstId;
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleIColumn(const G4String& name)
{
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
return CreateNtupleIColumn(ntupleId, name);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleFColumn(const G4String& name)
{
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
return CreateNtupleFColumn(ntupleId, name);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleDColumn(const G4String& name)
{
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
return CreateNtupleDColumn(ntupleId, name);
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::FinishNtuple()
{
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
FinishNtuple(ntupleId);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleIColumn(G4int ntupleId,
const G4String& name)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("create", "ntuple I column", description);
}
#endif
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "CreateNtupleIColumn");
tools::ntuple_booking* ntupleBooking
= ntupleDescription->fNtupleBooking;
if ( ! ntupleBooking ) {
G4ExceptionDescription description;
description << " "
<< "Ntuple " << ntupleId << " has to be created first. ";
G4Exception("G4HbookAnalysisManager::CreateNtupleIColumn()",
"Analysis_W005", JustWarning, description);
return -1;
}
// Save column info in booking
G4int index = ntupleBooking->m_columns.size();
ntupleBooking->add_column<int>(name);
// Create column if ntuple already exists
if ( ntupleDescription->fNtuple ) {
tools::hbook::wntuple::column<int>* column
= ntupleDescription->fNtuple->create_column<int>(name);
ntupleDescription->fNtupleIColumnMap[index] = column;
}
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL2()->Message("create", "ntuple I column", description);
}
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleFColumn(G4int ntupleId,
const G4String& name)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("create", "ntuple F column", description);
}
#endif
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "CreateNtupleFColumn");
tools::ntuple_booking* ntupleBooking
= ntupleDescription->fNtupleBooking;
if ( ! ntupleBooking ) {
G4ExceptionDescription description;
description << " "
<< "Ntuple " << ntupleId << " has to be created first. ";
G4Exception("G4HbookAnalysisManager::CreateNtupleFColumn()",
"Analysis_W005", JustWarning, description);
return -1;
}
// Save column info in booking
G4int index = ntupleBooking->m_columns.size();
ntupleBooking->add_column<float>(name);
// Create column if ntuple already exists
if ( ntupleDescription->fNtuple ) {
tools::hbook::wntuple::column<float>* column
= ntupleDescription->fNtuple->create_column<float>(name);
ntupleDescription->fNtupleFColumnMap[index] = column;
}
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL2()->Message("create", "ntuple F column", description);
}
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleDColumn(G4int ntupleId,
const G4String& name)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("create", "ntuple D column", description);
}
#endif
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
tools::ntuple_booking* ntupleBooking
= ntupleDescription->fNtupleBooking;
if ( ! ntupleBooking ) {
G4ExceptionDescription description;
description << " "
<< "Ntuple " << ntupleId << " has to be created first. ";
G4Exception("G4HbookAnalysisManager::CreateNtupleDColumn()",
"Analysis_W005", JustWarning, description);
return -1;
}
// Save column info in booking
G4int index = ntupleBooking->m_columns.size();
ntupleBooking->add_column<double>(name);
// Create column if ntuple already exists
if ( ntupleDescription->fNtuple ) {
tools::hbook::wntuple::column<double>* column
= ntupleDescription->fNtuple->create_column<double>(name);
ntupleDescription->fNtupleDColumnMap[index] = column;
}
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << name << " ntupleId " << ntupleId;
fState.GetVerboseL2()->Message("create", "ntuple D column", description);
}
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::FinishNtuple(G4int ntupleId)
{
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
tools::hbook::wntuple* ntuple = ntupleDescription->fNtuple;
if ( ! ntuple ) return;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()
->Message("finish", "ntuple", ntupleDescription->fNtupleBooking->m_name);
#endif
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
//fNtuple->add_row_beg();
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() )
fState.GetVerboseL2()
->Message("finish", "ntuple", ntupleDescription->fNtupleBooking->m_name);
#endif
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleIColumn(G4int columnId, G4int value)
{
return FillNtupleIColumn(fFirstId, columnId, value);
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleFColumn(G4int columnId, G4float value)
{
return FillNtupleFColumn(fFirstId, columnId, value);
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleDColumn(G4int columnId, G4double value)
{
return FillNtupleDColumn(fFirstId, columnId, value);
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::AddNtupleRow()
{
return AddNtupleRow(fFirstId);
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleIColumn(
G4int ntupleId, G4int columnId,
G4int value)
{
tools::hbook::wntuple::column<int>* column
= GetNtupleIColumn(ntupleId, columnId);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< "column " << columnId << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleIColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "ntuple I column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleFColumn(
G4int ntupleId, G4int columnId,
G4float value)
{
tools::hbook::wntuple::column<float>* column
= GetNtupleFColumn(ntupleId, columnId);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< "column " << columnId << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleFColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "ntuple F column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleDColumn(
G4int ntupleId, G4int columnId,
G4double value)
{
tools::hbook::wntuple::column<double>* column
= GetNtupleDColumn(ntupleId, columnId);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< "column " << columnId << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleDColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "ntuple D column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::AddNtupleRow(G4int ntupleId)
{
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("add", "ntuple row", description);
}
#endif
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "AddNtupleRow");
if ( ! ntupleDescription || ! ntupleDescription->fNtuple ) {
G4ExceptionDescription description;
description << " " << " ntupleId " << ntupleId
<< " does not exist. ";
G4Exception("G4HbookAnalysisManager::AddNtupleRow()",
"Analysis_W008", JustWarning, description);
return false;
}
ntupleDescription->fNtuple->add_row();
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("add", "ntuple row", description, true);
}
#endif
return true;
}
//_____________________________________________________________________________
tools::hbook::wntuple* ExG4HbookNtupleManager::GetNtuple() const
{
return GetNtuple(fFirstId);
}
//_____________________________________________________________________________
tools::hbook::wntuple* ExG4HbookNtupleManager::GetNtuple(G4int ntupleId) const
{
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "GetNtuple");
return ntupleDescription->fNtuple;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::SetNtupleHbookIdOffset(G4int offset)
{
if ( fNtupleVector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set NtupleHbookIdOffset as some ntuples already exist.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first ntuple HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fNtupleHbookIdOffset = offset;
return true;
}
#endif
@@ -1,52 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id$
//
/// \file common/analysis/testAnalysis.cc
/// \brief Test program for the analysis common classes
#ifdef G4_USE_HBOOK
#include "ExG4HbookAnalysisManager.hh"
#endif
// test program which only instantiates classes defined in
// examples/extended/common/analysis
int main()
{
#ifdef G4_USE_HBOOK
ExG4HbookAnalysisManager* hbookManager = ExG4HbookAnalysisManager::Instance();
delete hbookManager;
hbookManager = ExG4HbookAnalysisManager::Instance();
delete hbookManager;
#endif
return 0;
}
@@ -1,58 +0,0 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(detectorConstruction)
#----------------------------------------------------------------------------
# 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 executable, and link it to the Geant4 libraries
#
add_executable(testDetectorConstruction testDetectorConstruction.cc ${sources} ${headers})
target_link_libraries(testDetectorConstruction ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build detectorConstruction. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(detectorConstruction_SCRIPTS
)
foreach(_script ${detectorConstruction_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(detectorConstruction DEPENDS testDetectorConstruction)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS testDetectorConstruction DESTINATION bin)
@@ -1,17 +0,0 @@
# $Id: GNUmakefile 68059 2013-03-13 14:49:02Z gcosmo $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := testDetectorConstruction
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
@@ -1,53 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id$
//
/// \file testDetectorConstruction.cc
/// \brief Test program for the detectorConstruction common classes
#include "ExG4DetectorConstruction01.hh"
#include "ExG4DetectorConstruction02.hh"
// test program which only instantiates classes defined in
// examples/common/primaryGenerator
int main()
{
// Instantiate all detector construction classes
ExG4DetectorConstruction01* detectorConstruction01
= new ExG4DetectorConstruction01;
ExG4DetectorConstruction02* detectorConstruction02
= new ExG4DetectorConstruction02;
// delete all
delete detectorConstruction01;
delete detectorConstruction02;
return 0;
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ExG4DetectorConstruction01Messenger.hh 68059 2013-03-13 14:49:02Z gcosmo $
// $Id: ExG4DetectorConstruction01Messenger.hh 85902 2014-11-06 08:45:49Z gcosmo $
//
/// \file ExG4DetectorConstruction01Messenger.hh
/// \brief Definition of the ExG4DetectorConstruction01Messenger class
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ExG4DetectorConstruction02Messenger.hh 68059 2013-03-13 14:49:02Z gcosmo $
// $Id: ExG4DetectorConstruction02Messenger.hh 85902 2014-11-06 08:45:49Z gcosmo $
//
/// \file ExG4DetectorConstruction02Messenger.hh
/// \brief Definition of the ExG4DetectorConstruction02Messenger class
@@ -55,7 +55,6 @@ class ExG4EventAction01 : public G4UserEventAction
// set methods
void SetVerboseLevel(G4int level);
void SetPrintModulo(G4int value);
void SetSaveRndm(G4bool value);
void SetDrawFlag(G4String value);
@@ -67,7 +66,6 @@ class ExG4EventAction01 : public G4UserEventAction
// data members
ExG4EventAction01Messenger fMessenger;
G4int fVerboseLevel;
G4int fPrintModulo;
G4bool fSaveRndm;
};
@@ -77,10 +75,6 @@ inline void ExG4EventAction01::SetVerboseLevel(G4int level) {
fVerboseLevel = level;
}
inline void ExG4EventAction01::SetPrintModulo(G4int value) {
fPrintModulo = value;
}
inline void ExG4EventAction01::SetSaveRndm(G4bool value) {
fSaveRndm = value;
}
@@ -56,13 +56,11 @@ class ExG4EventAction01Messenger: public G4UImessenger
private:
// data members
ExG4EventAction01* fEventAction;
ExG4EventAction01* fEventAction;
G4UIdirectory* fTopDirectory;
G4UIdirectory* fDirectory;
G4UIcmdWithAnInteger* fSetVerboseLevelCmd;
G4UIcmdWithAnInteger* fSetPrintModuloCmd;
G4UIcmdWithABool* fSetSaveRndmCmd;
//G4UIcmdWithAString* DrawCmd;
};
#endif //ExG4EventAction01Messenger_h
@@ -1,58 +0,0 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(physicsList)
#----------------------------------------------------------------------------
# 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 executable, and link it to the Geant4 libraries
#
add_executable(testPhysicsList testPhysicsList.cc ${sources} ${headers})
target_link_libraries(testPhysicsList ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build physicsList. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(physicsList_SCRIPTS
)
foreach(_script ${physicsList_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(physicsList DEPENDS testPhysicsList)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS testPhysicsList DESTINATION bin)
@@ -1,17 +0,0 @@
# $Id: GNUmakefile 68059 2013-03-13 14:49:02Z gcosmo $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := testPhysicsList
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
@@ -1,48 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id$
//
/// \file testPhysicsList.cc
/// \brief Test program for the physicsList common classes
#include "ExG4PhysicsList00.hh"
// test program which only instantiates classes defined in
// examples/common/physicsList
int main()
{
// Instantiate all physics list classes
ExG4PhysicsList00* physicsList00 = new ExG4PhysicsList00();
// delete all
delete physicsList00;
return 0;
}
@@ -1,58 +0,0 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(primaryGenerator)
#----------------------------------------------------------------------------
# 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 executable, and link it to the Geant4 libraries
#
add_executable(testPrimaryGenerator testPrimaryGenerator.cc ${sources} ${headers})
target_link_libraries(testPrimaryGenerator ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build primaryGenerator. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(primaryGenerator_SCRIPTS
)
foreach(_script ${primaryGenerator_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(primaryGenerator DEPENDS testPrimaryGenerator)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS testPrimaryGenerator DESTINATION bin)
@@ -1,17 +0,0 @@
# $Id: GNUmakefile 68059 2013-03-13 14:49:02Z gcosmo $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := testPrimaryGenerator
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
@@ -1,5 +0,0 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(EXAMPLE_NAME)
@@ -1,11 +0,0 @@
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
@@ -1,17 +0,0 @@
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI drivers by default
# You can set WITH_GEANT4_UI to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UI "Build example with Geant4 UI drivers" ON)
if(WITH_GEANT4_UI)
find_package(Geant4 REQUIRED ui_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
@@ -1,17 +0,0 @@
#----------------------------------------------------------------------------
# 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})
@@ -1,17 +0,0 @@
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available Vis drivers by default
# You can set WITH_GEANT4_VIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_VIS "Build example with Geant4 Vis drivers" ON)
if(WITH_GEANT4_VIS)
find_package(Geant4 REQUIRED vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
@@ -1,9 +0,0 @@
#----------------------------------------------------------------------------
# Find EXTERN_PACKAGE (required package)
#
find_package(EXTERN_PACKAGE QUIET)
if(NOT EXTERN_PACKAGE_TO_UPPER_FOUND)
message(STATUS "G4 Examples: EXTERN_PACKAGE package not found. --> EXAMPLE_NAME example disabled")
return()
endif()
@@ -1,10 +0,0 @@
#----------------------------------------------------------------------------
# Find EXTERN_PACKAGE (optional package)
#
find_package(EXTERN_PACKAGE QUIET)
if(EXTERN_PACKAGE_TO_UPPER_FOUND)
message(STATUS "G4 Examples: EXTERN_PACKAGE found. --> EXAMPLE_NAME example with EXTERN_PACKAGE enabled.")
# Uncomment this line if suitable (some customization may be needed)
# add_definitions(-DG4EXTERN_PACKAGE_USE)
endif()
@@ -1,8 +0,0 @@
#----------------------------------------------------------------------------
# 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)
@@ -1,9 +0,0 @@
#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR}
${EXTERN_PACKAGE_TO_UPPER_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
@@ -1,6 +0,0 @@
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(EXAMPLE_PROGRAM_NAME EXAMPLE_PROGRAM_NAME.cc ${sources} ${headers})
target_link_libraries(EXAMPLE_PROGRAM_NAME ${Geant4_LIBRARIES} FIX_XT)
@@ -1,6 +0,0 @@
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(EXAMPLE_PROGRAM_NAME EXAMPLE_PROGRAM_NAME.cc ${sources} ${headers})
target_link_libraries(EXAMPLE_PROGRAM_NAME ${Geant4_LIBRARIES} ${EXTERN_PACKAGE_TO_UPPER_LIBRARIES} FIX_XT)
@@ -1,17 +0,0 @@
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build EXAMPLE_NAME. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(EXAMPLE_NAME_SCRIPTS
EXAMPLE_SCRIPT_LIST
)
foreach(_script ${EXAMPLE_NAME_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
@@ -1,6 +0,0 @@
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(EXAMPLE_NAME DEPENDS EXAMPLE_PROGRAM_NAME)
@@ -1,5 +0,0 @@
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS EXAMPLE_PROGRAM_NAME DESTINATION bin)
@@ -1,25 +0,0 @@
#!/bin/bash
#
# Usage:
# check_long_lines.sh [maxColumn]
#set -x
CURDIR=`pwd`
MAX=90
if [ $# -eq 1 ]; then
MAX=$1
fi
for SOURCE in `ls *.cc include/*.hh src/*.cc`
do
LINE_LENGTH=`wc -L $SOURCE | sed sY" $SOURCE"YYg`
RESULT=`echo "$LINE_LENGTH > $MAX" | bc`
if [ $RESULT -ne 0 ];
then
echo "LONG LINE ($LINE_LENGTH characters) detected in $SOURCE"
fi
done
cd $CURDIR
@@ -1,26 +0,0 @@
#!/bin/bash
#
# Usage:
# check_separator.sh
#set -x
CURDIR=`pwd`
#The correct separator with 80 characters
#SEPARATOR="//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......"
#Still tolerated separator with 78 characters
SEPARATOR="//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...."
for SOURCE in `ls src/*.cc`
do
LINES=`cat $SOURCE | grep $SEPARATOR | wc -l `
RESULT=`echo "$LINES > 0" | bc`
if [ $RESULT -ne 1 ];
then
echo "NO SEPARATOR found in $SOURCE"
fi
done
cd $CURDIR
@@ -1,20 +0,0 @@
#!/bin/bash
#
# Usage:
# check_tabs.sh
#set -x
CURDIR=`pwd`
for SOURCE in `ls *.cc include/*.hh src/*.cc`
do
RESULT=`cat $SOURCE | sed 's/\t/TAB_TO_BE_REMOVED/g' | grep TAB_TO_BE_REMOVED`
if [ ! "$RESULT" = "" ];
then
echo "TAB detected in $SOURCE"
#cat $SOURCE | sed 's/\t/TAB_TO_BE_REMOVED/g' > $CURDIR/"$DIR"_tabs/$SOURCE
fi
done
cd $CURDIR
@@ -1,117 +0,0 @@
#!/bin/sh
# Script to clean classes specified in SharedFilesList.txt file.
# Usage: clean_files.sh [example_source_dir]
#
# By I. Hrivnacova, IPN Orsay
CURDIR=`pwd`
IS_KEYWORD="no"
WHERE=""
NEXT_COMMON_CLASSES_LIST="no"
NEXT_SHARED_CLASSES_LIST="no"
EXTH=".hh"
EXTC=".cc"
# Files directories
CURDIR=`pwd`
# default setting when script is called from the example directory
# which is inside examples top directory a files are searcxh via relative paths
if [ "$#" = "0" ]; then
EXAMPLE_SOURCE_DIR="."
else
if [ "$#" = "1" ]; then
EXAMPLE_SOURCE_DIR=$1
else
echo "Usage: clean_files.sh [example_source_dir]"
exit 1
fi
fi
cd $EXAMPLE_SOURCE_DIR
# check if {1} is a keyword
is_keyword() {
if [ "${1}" = "COMMON_CLASSES_PATH" -o "${1}" = "SHARED_CLASSES_PATH" -o "${1}" = "COMMON_CLASSES_LIST" -o "${1}" = "SHARED_CLASSES_LIST" ]; then
IS_KEYWORD="yes"
else
IS_KEYWORD="no"
fi
}
# check if filename {1} is defined with an extension
# and if yes decide whether it should go in include (.hh and .icc)
# or is src (.cc)
# pront error if extension is unkbown
where() {
EXTENSION="`echo ${1#*.}`"
if [ $EXTENSION = "${1}" ]; then
WHERE=""
else
if [ $EXTENSION = "hh" -o $EXTENSION = "icc" ]; then
WHERE="include"
else
if [ $EXTENSION = "cc" ]; then
WHERE="src"
else
WHERE="nowhere"
fi
fi
fi
}
# reset all NEXT_* variables
reset_all() {
NEXT_COMMON_CLASSES_LIST="no"
NEXT_SHARED_CLASSES_LIST="no"
}
# remove the file {1}
remove_file() {
echo "removing ${1}"
FILE=`find . -name ${1}`
if [ "$FILE" = "" ]; then
echo "${1} not found."
else
rm -f $FILE
fi
}
for WORD in `cat SharedFilesList.txt`; do
### process keywords
#echo $WORD
is_keyword $WORD
if [ "$IS_KEYWORD" = "yes" ]; then
### reset keywords
reset_all
if [ $WORD = "COMMON_CLASSES_LIST" ]; then
NEXT_COMMON_CLASSES_LIST="yes"
fi
if [ $WORD = "SHARED_CLASSES_LIST" ]; then
NEXT_SHARED_CLASSES_LIST="yes"
fi
else
# classes from common
if [ $NEXT_COMMON_CLASSES_LIST = "yes" ]; then
where $WORD
if [ "$WHERE" != "" -a "$WHERE" != "nowhere" ]; then
remove_file $WORD
else
remove_file $WORD$EXTH
remove_file $WORD$EXTC
fi
fi
# classes from shared
if [ $NEXT_SHARED_CLASSES_LIST = "yes" ]; then
where $WORD
if [ "$WHERE" != "" -a "$WHERE" != "nowhere" ]; then
remove_file $WORD
else
remove_file $WORD$EXTH
remove_file $WORD$EXTC
fi
fi
fi
done
@@ -1,21 +0,0 @@
#!/bin/sh
# Script to remove classes copied from common repository in examples.
# All files with ExG4 prefix will be removed.
#
# Usage:
# clean_files.sh [--force]
FROM=`pwd`
FORCE=""
if [ "$1" = "--force" ]; then
FORCE="-f"
fi
rm $FORCE include/ExG4*.hh
rm $FORCE src/ExG4*.cc
@@ -1,180 +0,0 @@
#!/bin/sh
# Script to copy classes specified in SharedFilesList.txt file.
# Usage: copy_files.sh [root_dir example_source_dir]
#
# By I. Hrivnacova, IPN Orsay
IS_KEYWORD="no"
WHERE=""
EXAMPLE_PATH="undefined"
COMMON_CLASSES_PATH="undefined"
SHARED_CLASSES_PATH="undefined"
NEXT_EXAMPLE_PATH="no"
NEXT_COMMON_CLASSES_PATH="no"
NEXT_SHARED_CLASSES_PATH="no"
NEXT_COMMON_CLASSES_LIST="no"
NEXT_SHARED_CLASSES_LIST="no"
EXTH=".hh"
EXTC=".cc"
# Files directories
CURDIR=`pwd`
if [ "$#" = "0" ]; then
# default setting when script is called without arguments from the example directory
# which is inside examples top directory and files are searched via relative paths
ROOT_DIR=""
EXAMPLE_SOURCE_DIR="."
RELATIVE="yes"
else
if [ "$#" = "2" ]; then
# setting when script is called with arguments
# and files are searched via absolute paths
ROOT_DIR=$1
EXAMPLE_SOURCE_DIR=$2
RELATIVE="no"
else
echo "Usage: copy_files.sh [root_dir example_source_dir]"
exit 1
fi
fi
cd $EXAMPLE_SOURCE_DIR
# check if {1} is a keyword
is_keyword() {
if [ "${1}" = "EXAMPLE" -o "${1}" = "COMMON_CLASSES_PATH" -o "${1}" = "SHARED_CLASSES_PATH" -o "${1}" = "COMMON_CLASSES_LIST" -o "${1}" = "SHARED_CLASSES_LIST" ]; then
IS_KEYWORD="yes"
else
IS_KEYWORD="no"
fi
}
# check if filename {1} is defined with an extension
# and if yes decide whether it should go in include (.hh and .icc)
# or is src (.cc)
# pront error if extension is unkbown
where() {
EXTENSION="`echo ${1#*.}`"
if [ $EXTENSION = "${1}" ]; then
WHERE=""
else
if [ $EXTENSION = "hh" -o $EXTENSION = "icc" ]; then
WHERE="include"
else
if [ $EXTENSION = "cc" ]; then
WHERE="src"
else
WHERE="nowhere"
fi
fi
fi
}
# reset all NEXT_* variables
reset_all() {
NEXT_EXAMPLE_PATH="no"
NEXT_COMMON_CLASSES_PATH="no"
NEXT_SHARED_CLASSES_PATH="no"
NEXT_COMMON_CLASSES_LIST="no"
NEXT_SHARED_CLASSES_LIST="no"
}
# copy the file {1} from {2} to {3} with keaword {4} in messages
copy_file() {
# parameters:
# {1} $WORD; {2} from_path; {3} to_path; {4} COMMON/SHARED
echo "getting file ${1}"
if [ ${2} = "undefined" ]; then
echo "The path to ${3} classes (${4}_CLASSES_PATH) must be set first"
exit 1
fi
FILE=`find ${2} -name ${1}`
IS_FILE=`find . -name ${1}`
if [ "$FILE" = "" ]; then
echo "${1} not found in ${2}"
else
if [ ! "$IS_FILE" = "" ]; then
echo "${1} is already installed."
echo "You have to run clean to install sources again"
exit 1
else
cp $FILE ${3}
fi
fi
}
for WORD in `cat SharedFilesList.txt`; do
### process keywords
#echo $WORD
is_keyword $WORD
if [ "$IS_KEYWORD" = "yes" ]; then
### reset keywords
reset_all
if [ $WORD = "EXAMPLE" ]; then
NEXT_EXAMPLE_PATH="yes"
fi
if [ $WORD = "COMMON_CLASSES_PATH" ]; then
NEXT_COMMON_CLASSES_PATH="yes"
fi
if [ $WORD = "SHARED_CLASSES_PATH" ]; then
NEXT_SHARED_CLASSES_PATH="yes"
fi
if [ $WORD = "COMMON_CLASSES_LIST" ]; then
NEXT_COMMON_CLASSES_LIST="yes"
fi
if [ $WORD = "SHARED_CLASSES_LIST" ]; then
NEXT_SHARED_CLASSES_LIST="yes"
fi
else
# path to example
if [ $NEXT_EXAMPLE_PATH = "yes" ]; then
if [ $RELATIVE = "no" ]; then
echo "Setting path to the example $WORD"
EXAMPLE_PATH="/${WORD}/"
else
EXAMPLE_PATH=""
fi
NEXT_EXAMPLE_PATH="no"
fi
# path to common
if [ $NEXT_COMMON_CLASSES_PATH = "yes" ]; then
echo "Setting path to common classes $WORD"
COMMON_CLASSES_PATH=${ROOT_DIR}${EXAMPLE_PATH}${WORD}
NEXT_COMMON_CLASSES_PATH="no"
fi
# path to shared
if [ $NEXT_SHARED_CLASSES_PATH = "yes" ]; then
echo "Setting path to shared classes $WORD"
SHARED_CLASSES_PATH=${ROOT_DIR}${EXAMPLE_PATH}${WORD}
NEXT_SHARED_CLASSES_PATH="no"
fi
# classes from common
if [ $NEXT_COMMON_CLASSES_LIST = "yes" ]; then
where $WORD
if [ "$WHERE" != "" -a "$WHERE" != "nowhere" ]; then
copy_file $WORD $COMMON_CLASSES_PATH $WHERE "COMMON"
else
copy_file $WORD$EXTH $COMMON_CLASSES_PATH include "COMMON"
copy_file $WORD$EXTC $COMMON_CLASSES_PATH src "COMMON"
fi
fi
# classes from shared
if [ $NEXT_SHARED_CLASSES_LIST = "yes" ]; then
where $WORD
if [ "$WHERE" != "" -a "$WHERE" != "nowhere" ]; then
copy_file $WORD $SHARED_CLASSES_PATH $WHERE "SHARED"
else
copy_file $WORD$EXTH $SHARED_CLASSES_PATH include "SHARED"
copy_file $WORD$EXTC $SHARED_CLASSES_PATH src "SHARED"
fi
fi
fi
done
cd $CURDIR
echo "end copy_files.sh"
@@ -1,40 +0,0 @@
#!/bin/sh
# Script to copy classes from common repository in examples.
# Usage:
# copy_files.sh className versionNumber [messenger]
COMMON_DIR=../../../common
PREFIX="ExG4"
TO=`pwd`
fileName=$1
fileVersion=$2
isMessenger=$3
fileDir=""
if [ "$fileName" = "HbookAnalysisManager" ]; then
fileDir="analysis"
fileVersion=""
fi
if [ "$fileName" = "DetectorConstruction" ]; then
fileDir="detectorConstruction"
fi
if [ "$fileName" = "PrimaryGeneratorAction" ]; then
fileDir="primaryGenerator"
fi
if [ "$fileName" = "EventAction" -o "$fileName" = "RunAction" ]; then
fileDir="userActions"
fi
echo "... copying $PREFIX$fileName$fileVersion"
cp $COMMON_DIR/$fileDir/include/$PREFIX$fileName$fileVersion".hh" include
cp $COMMON_DIR/$fileDir/src/$PREFIX$fileName$fileVersion".cc" src
if [ "$isMessenger" != "" ]; then
echo "... copying $PREFIX$fileName"Messenger"$fileVersion"
cp $COMMON_DIR/$fileDir/include/$PREFIX$fileName$fileVersion"Messenger.hh" include
cp $COMMON_DIR/$fileDir/src/$PREFIX$fileName$fileVersion"Messenger.cc" src
fi
@@ -1,271 +0,0 @@
#!/bin/sh
# Script to generate CMakeList.tx file from templates.
# The following fields in the template files are replaced with
# specific example entries:
# EXAMPLE_NAME
# EXAMPLE_PROGRAM_NAME
# EXAMPLE_SCRIPT_LIST
# EXTERN_PACKAGE
#
# Usage:
# generate_cmake.sh categoryName
# categoryName = all - process all categories
#
# By I. Hrivnacova, IPN Orsay
CURDIR=`pwd`
#FIX_XT="-lXt"
FIX_XT=""
# generate documentation
# {1} example directory
# {2} external package name
generate() {
echo " processing ${1}"
cd ../../${1}
EXAMPLE_NAME=${PWD##*/}
# Extract program name
# Get only first .cc and print a warning if more programs exist
EXAMPLE_PROGRAM_FILES=`ls *.cc`
FILE_FOUND="no"
MESSAGE="no"
for FILE in $EXAMPLE_PROGRAM_FILES; do
if [ "${FILE_FOUND}" = "yes" ]; then
if [ "${MESSAGE}" = "no" ]; then
echo " ... more programs found !!!"
MESSAGE="yes"
fi
# update program name only if equal EXAMPLE_NAME
# otherwise keep the first program found
TMP_EXAMPLE_PROGRAM_NAME=`echo $FILE | sed 's/\(.*\)\..*/\1/'`
if [ "${TMP_EXAMPLE_PROGRAM_NAME}" = "${EXAMPLE_NAME}" ]; then
EXAMPLE_PROGRAM_NAME=$TMP_EXAMPLE_PROGRAM_NAME
break
fi
else
EXAMPLE_PROGRAM_NAME=`echo $FILE | sed 's/\(.*\)\..*/\1/'`
FILE_FOUND="yes"
fi
done
# Extract use of ui/visualization
UI_VIS=""
GREP_UI=`cat "$EXAMPLE_PROGRAM_NAME"".cc" | grep G4UIExecutive`
if [ "${GREP_UI}" != "" ]; then
UI_VIS=${UI_VIS}"_ui"
fi
GREP_VIS=`cat "$EXAMPLE_PROGRAM_NAME"".cc" | grep G4VisExecutive`
if [ "${GREP_VIS}" != "" ]; then
UI_VIS=${UI_VIS}"_vis"
fi
# Extract list of scripts:
# all files with extension *.mac *.in, *.out
EXAMPLE_SCRIPT_LIST0=`ls *.mac *.in *.out *.gdml 2> /dev/null`
EXAMPLE_SCRIPT_LIST=""
for SCRIPT in $EXAMPLE_SCRIPT_LIST0; do
EXAMPLE_SCRIPT_LIST="$EXAMPLE_SCRIPT_LIST ""$SCRIPT"
done
# Select a template if extern package
if [ "${2}" = "" ]; then
WITH_EXTERN=""
else
WITH_EXTERN="_with_extern"
EXTERN_PACKAGE=${2}
EXTERN_PACKAGE_TO_UPPER=`echo $EXTERN_PACKAGE | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
fi
if [ "${3}" = "optional" ]; then
OPTIONAL="_opt"
else
OPTIONAL=""
fi
# Generate file from templates
# Project
cat $CURDIR/CMakeLists_template_1.txt | sed s/"EXAMPLE_NAME"/"${EXAMPLE_NAME}"/g > CMakeLists.txt
# Use Geant4
cat $CURDIR/CMakeLists_template_2"${UI_VIS}".txt >> CMakeLists.txt
# Find extern package
cat $CURDIR/CMakeLists_template_3"${WITH_EXTERN}""${OPTIONAL}".txt | sed s/"EXAMPLE_NAME"/"${EXAMPLE_NAME}"/g | sed s/"EXTERN_PACKAGE_TO_UPPER"/"${EXTERN_PACKAGE_TO_UPPER}"/g | sed s/"EXTERN_PACKAGE"/"${EXTERN_PACKAGE}"/g >> CMakeLists.txt
# Locate sources and headers
cat $CURDIR/CMakeLists_template_4"${WITH_EXTERN}".txt | sed s/"EXTERN_PACKAGE_TO_UPPER"/"${EXTERN_PACKAGE_TO_UPPER}"/g >> CMakeLists.txt
# Add executable and link libraries
cat $CURDIR/CMakeLists_template_5"${WITH_EXTERN}".txt | sed s/"EXAMPLE_PROGRAM_NAME"/"${EXAMPLE_PROGRAM_NAME}"/g | sed s/"EXTERN_PACKAGE_TO_UPPER"/"${EXTERN_PACKAGE_TO_UPPER}"/g | sed s/"FIX_XT"/"${FIX_XT}"/g >> CMakeLists.txt
# Copy scripts
cat $CURDIR/CMakeLists_template_6.txt | sed s/"EXAMPLE_NAME"/"${EXAMPLE_NAME}"/g | sed s/"EXAMPLE_SCRIPT_LIST"/"${EXAMPLE_SCRIPT_LIST}"/g >> CMakeLists.txt
# Add custom target
if [ ! "${EXAMPLE_NAME}" = "${EXAMPLE_PROGRAM_NAME}" ]; then
cat $CURDIR/CMakeLists_template_7.txt | sed s/"EXAMPLE_NAME"/"${EXAMPLE_NAME}"/g | sed s/"EXAMPLE_PROGRAM_NAME"/"${EXAMPLE_PROGRAM_NAME}"/g >> CMakeLists.txt
fi
# Install executable
cat $CURDIR/CMakeLists_template_8.txt | sed s/"EXAMPLE_PROGRAM_NAME"/"${EXAMPLE_PROGRAM_NAME}"/g >> CMakeLists.txt
cd $CURDIR
}
# Functions per examples/extened categories
#
generate_analysis() {
generate analysis/A01 AIDA optional
generate analysis/AnaEx01
generate analysis/AnaEx02 ROOT
generate analysis/AnaEx03 AIDA
generate analysis/N03Con
}
generate_biasing() {
generate biasing/B01
generate biasing/B02 AIDA
generate biasing/ReverseMC01
}
generate_common() {
generate common/analysis HBOOK
generate common/detectorConstruction
generate common/physicsList
generate common/primaryGenerator
generate common/userActions
}
generate_electromagnetic() {
for DIR in electromagnetic/TestEm0 electromagnetic/TestEm1 electromagnetic/TestEm2 electromagnetic/TestEm3 electromagnetic/TestEm4 electromagnetic/TestEm5 electromagnetic/TestEm6 electromagnetic/TestEm7 electromagnetic/TestEm8 electromagnetic/TestEm9 electromagnetic/TestEm10 electromagnetic/TestEm11 electromagnetic/TestEm12 electromagnetic/TestEm13 electromagnetic/TestEm14 electromagnetic/TestEm15 electromagnetic/TestEm16 electromagnetic/TestEm17 electromagnetic/TestEm18; do
#for DIR in electromagnetic/TestEm1; do
generate ${DIR}
done
}
generate_errorpropagation() {
generate errorpropagation
}
generate_eventgenerator() {
generate eventgenerator/exgps AIDA optional
generate eventgenerator/HepMC/HepMCEx01 HepMC
generate eventgenerator/HepMC/HepMCEx02 HepMC
generate eventgenerator/HepMC/MCTruth HepMC
generate eventgenerator/particleGun
generate eventgenerator/pythia/decayer6 Pythia6 optional
}
generate_exoticphysics() {
generate exoticphysics/monopole
}
generate_field() {
generate field/BlineTracer
generate field/field01
generate field/field02
generate field/field03
generate field/field04
generate field/field05
generate field/field06
}
generate_g3tog4() {
generate g3tog4/clGeometry
}
generate_geometry() {
generate geometry/olap
generate geometry/transforms
}
generate_hadronic() {
generate hadronic/Hadr00
generate hadronic/Hadr01
generate hadronic/Hadr02
generate hadronic/Hadr03
}
generate_medical() {
generate medical/DICOM
generate medical/electronScattering
generate medical/electronScattering2
generate medical/fanoCavity
generate medical/fanoCavity2
generate medical/GammaTherapy
}
generate_optical() {
generate optical/LXe
generate optical/wls
}
generate_parameterisations() {
generate parameterisations/gflash
}
generate_persistency() {
generate persistency/P01 ROOT
generate persistency/P02 ROOT
generate persistency/P03
generate persistency/gdml/G01
generate persistency/gdml/G02
generate persistency/gdml/G03
generate persistency/gdml/G04
}
generate_polarisation() {
generate polarisation/Pol01 AIDA optional
}
generate_radioactivedecay() {
generate radioactivedecay/rdecay01
generate radioactivedecay/rdecay02
}
generate_runAndEvent() {
generate runAndEvent/RE01
generate runAndEvent/RE02
generate runAndEvent/RE03
generate runAndEvent/RE04
}
generate_visualization() {
generate visualization/perspective
generate visualization/standalone
generate visualization/userVisAction
}
generate_novice() {
generate ../novice/N01
generate ../novice/N02
generate ../novice/N03
generate ../novice/N04
generate ../novice/N05
generate ../novice/N06
generate ../novice/N07
}
generate_advanced() {
generate ../advanced/air_shower
generate ../advanced/gammaknife
generate ../advanced/ChargeExchangeMC
generate ../advanced/dnaphysics
# to be completed
}
# Check arguments
if [ $# -ne 1 ]; then
echo " Usage: "
echo " generate_cmake.sh categoryName"
echo " categoryName = all - process all categories "
exit
fi
# Process a selected category or all
CATEGORY=$1
if [ "$CATEGORY" = "all" ]; then
# to be done
echo generate_analysis
echo generate_electromagnetic
else
echo "processing ${CATEGORY}"
generate_${CATEGORY}
fi
cd $CURDIR
@@ -1,31 +0,0 @@
#!/bin/bash
#
# Usage:
# process_examples.sh script
#set -x
CURDIR=`pwd`
SCRIPT=$1
SCRIPT_ARG=$2
# call a script
# {1} example directory
call_script() {
echo "... calling ${1} for example ${2}"
${1}
}
# basic
for DIR in basic; do
echo ... processing $DIR
cd $DIR
BASIC_DIR=`pwd`
for EXAMPLE in B1 B2/B2a B3 B4/B4a B4/B4b B4/B4c B4/B4d; do
cd $EXAMPLE
call_script $SCRIPT $EXAMPLE
cd $BASIC_DIR
done
cd $CURDIR
done
@@ -1,52 +0,0 @@
#!/bin/bash
#
# Usage:
# process_examples.sh script
#set -x
CURDIR=`pwd`
SCRIPT=$1
SCRIPT_ARG=$2
# call a script
# {1} example directory
call_script() {
echo "... calling ${1} for example ${2}"
${1}
}
# extended
#CATEGORY errorpropagation; polarisation
for DIR in extended; do
echo ... processing $DIR
cd $DIR
EXTENDED_DIR=`pwd`
for CATEGORY in `ls`; do
# select directories with .README
if [ -f ${CATEGORY}/.README ]; then
echo ... processing $CATEGORY
cd $CATEGORY
CATEGORY_DIR=`pwd`
for FILE in `find -name .README`; do
EXAMPLE_DIR=`echo $FILE | sed sY/.READMEYYg`
NOT_EXAMPLE=`echo ". ./gdml ./pythia ./MPI" | grep $EXAMPLE_DIR`
if [ "${NOT_EXAMPLE}" = "" ]; then
cd $EXAMPLE_DIR
call_script $SCRIPT $EXAMPLE_DIR
cd $CATEGORY_DIR
fi
done
fi
cd $EXTENDED_DIR
done
# categories with a single example in the same level
for EXAMPLE_DIR in errorpropagation; do
cd $EXAMPLE_DIR
call_script $SCRIPT $EXAMPLE_DIR
cd $CATEGORY_DIR
cd $EXTENDED_DIR
done
cd $CURDIR
done
@@ -1,21 +0,0 @@
#!/bin/bash
#
# Usage:
# replace_tabs.sh
#set -x
CURDIR=`pwd`
for SOURCE in `ls *.cc include/*.hh src/*.cc`
do
RESULT=`cat $SOURCE | sed 's/\t/TAB_TO_BE_REMOVED/g' | grep TAB_TO_BE_REMOVED`
if [ ! "$RESULT" = "" ];
then
echo "Updating file $SOURCE ... "
cat $SOURCE | sed --posix -e 's/\t/ /g' > $SOURCE.1
mv $SOURCE.1 $SOURCE
fi
done
cd $CURDIR
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ExG4DetectorConstruction01Messenger.cc 68059 2013-03-13 14:49:02Z gcosmo $
// $Id: ExG4DetectorConstruction01Messenger.cc 85902 2014-11-06 08:45:49Z gcosmo $
//
/// \file ExG4DetectorConstruction01Messenger.cc
/// \brief Implementation of the ExG4DetectorConstruction01Messenger class
@@ -40,35 +40,36 @@
#include <sstream>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4int ExG4EventAction01::fgkDefaultVerboseLevel = 1;
const G4int ExG4EventAction01::fgkDefaultPrintModulo = 10000;
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExG4EventAction01::ExG4EventAction01()
: G4UserEventAction(),
fMessenger(this),
fVerboseLevel(fgkDefaultVerboseLevel),
fPrintModulo(fgkDefaultPrintModulo),
fSaveRndm(false)
{
/// Standard constructor
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExG4EventAction01::~ExG4EventAction01()
{
/// Destructor
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExG4EventAction01::BeginOfEventAction(const G4Event* event)
{
// Print event info
//
G4int eventNumber = event->GetEventID();
if ( eventNumber%fPrintModulo == 0 ) {
G4cout << "\n---> Begin of Event: " << eventNumber << G4endl;
}
// Print verbose info
//
@@ -77,7 +78,8 @@ void ExG4EventAction01::BeginOfEventAction(const G4Event* event)
}
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExG4EventAction01::EndOfEventAction(const G4Event* event)
{
// Print verbose info
@@ -95,10 +97,7 @@ void ExG4EventAction01::EndOfEventAction(const G4Event* event)
std::ostringstream fileName;
fileName << "run" << runNumber << "event" << eventNumber << ".rndm";
CLHEP::HepRandom::saveEngineStatus(fileName.str().c_str());
if ( eventNumber%fPrintModulo == 0 ) {
G4cout << "\n---> End of Event: " << eventNumber << G4endl;
CLHEP::HepRandom::showEngineStatus();
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -36,14 +36,15 @@
#include "G4UIcmdWithABool.hh"
#include "globals.hh"
//_____________________________________________________________________________
ExG4EventAction01Messenger::ExG4EventAction01Messenger(ExG4EventAction01* eventAction)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExG4EventAction01Messenger::ExG4EventAction01Messenger(
ExG4EventAction01* eventAction)
: G4UImessenger(),
fEventAction(eventAction),
fTopDirectory(0),
fDirectory(0),
fSetVerboseLevelCmd(0),
fSetPrintModuloCmd(0),
fSetSaveRndmCmd(0)
{
fTopDirectory = new G4UIdirectory("/ExG4/");
@@ -52,43 +53,41 @@ ExG4EventAction01Messenger::ExG4EventAction01Messenger(ExG4EventAction01* eventA
fDirectory = new G4UIdirectory("/ExG4/event/");
fDirectory->SetGuidance("Event control");
fSetVerboseLevelCmd = new G4UIcmdWithAnInteger("/ExG4/event/verboseLevel",this);
fSetVerboseLevelCmd
= new G4UIcmdWithAnInteger("/ExG4/event/verboseLevel",this);
fSetVerboseLevelCmd->SetGuidance("Set event verbose level ." );
fSetVerboseLevelCmd->SetParameterName("VerboseLevel",false);
fSetVerboseLevelCmd->AvailableForStates(G4State_PreInit, G4State_Init);
fSetPrintModuloCmd = new G4UIcmdWithAnInteger("/ExG4/event/printModulo",this);
fSetPrintModuloCmd->SetGuidance("Print events modulo n");
fSetPrintModuloCmd->SetParameterName("PrintModulo",false);
fSetPrintModuloCmd->SetRange("PrintModulo>0");
fSetPrintModuloCmd->AvailableForStates(G4State_Idle, G4State_Init);
fSetSaveRndmCmd = new G4UIcmdWithABool("/ExG4/event/saveRndm",this);
fSetSaveRndmCmd->SetGuidance("Activate saving random number at endOfEvent.");
fSetSaveRndmCmd
->SetGuidance("Activate saving random number at endOfEvent.");
fSetSaveRndmCmd->SetParameterName("SaveRndm",false);
fSetSaveRndmCmd->AvailableForStates(G4State_Idle, G4State_Init);
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExG4EventAction01Messenger::~ExG4EventAction01Messenger()
{
delete fTopDirectory;
delete fDirectory;
delete fSetVerboseLevelCmd;
delete fSetPrintModuloCmd;
delete fSetSaveRndmCmd;
}
//_____________________________________________________________________________
void ExG4EventAction01Messenger::SetNewValue(G4UIcommand* command, G4String newValue)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExG4EventAction01Messenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if(command == fSetVerboseLevelCmd) {
fEventAction->SetVerboseLevel(fSetVerboseLevelCmd->GetNewIntValue(newValue));
fEventAction
->SetVerboseLevel(fSetVerboseLevelCmd->GetNewIntValue(newValue));
}
else if ( command == fSetPrintModuloCmd ) {
fEventAction->SetPrintModulo(fSetPrintModuloCmd->GetNewIntValue(newValue));
}
else if ( command == fSetSaveRndmCmd ) {
fEventAction->SetSaveRndm(fSetSaveRndmCmd->GetNewBoolValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,7 +41,8 @@
const G4String ExG4RunAction01::fgkDefaultRndmFileName = "run0.rndm";
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExG4RunAction01::ExG4RunAction01()
: G4UserRunAction(),
fMessenger(this),
@@ -54,13 +55,15 @@ ExG4RunAction01::ExG4RunAction01()
/// Standard constructor
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ExG4RunAction01::~ExG4RunAction01()
{
/// Destructor
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExG4RunAction01::BeginOfRunAction(const G4Run* run)
{
if ( fVerboseLevel > 0 ) {
@@ -70,8 +73,8 @@ void ExG4RunAction01::BeginOfRunAction(const G4Run* run)
// read Rndm status
if ( fReadRndm ) {
G4cout << "\n---> rndm status restored from file: " << fRndmFileName << G4endl;
CLHEP::HepRandom::restoreEngineStatus(fRndmFileName);
CLHEP::HepRandom::showEngineStatus();
G4Random::restoreEngineStatus(fRndmFileName);
G4Random::showEngineStatus();
}
// automatic (time-based) random seeds for each run
@@ -87,8 +90,8 @@ void ExG4RunAction01::BeginOfRunAction(const G4Run* run)
time_t systime = time(NULL);
seeds[0] = (long) systime;
seeds[1] = (long) (systime*G4UniformRand());
CLHEP::HepRandom::setTheSeeds(seeds);
CLHEP::HepRandom::showEngineStatus();
G4Random::setTheSeeds(seeds);
G4Random::showEngineStatus();
}
// save Rndm status
@@ -96,8 +99,8 @@ void ExG4RunAction01::BeginOfRunAction(const G4Run* run)
G4int runNumber = run->GetRunID();
std::ostringstream fileName;
fileName << "run" << runNumber << ".rndm";
CLHEP::HepRandom::saveEngineStatus(fileName.str().c_str());
CLHEP::HepRandom::showEngineStatus();
G4Random::saveEngineStatus(fileName.str().c_str());
G4Random::showEngineStatus();
}
if ( G4VVisManager::GetConcreteInstance() ) {
@@ -105,7 +108,8 @@ void ExG4RunAction01::BeginOfRunAction(const G4Run* run)
}
}
//_____________________________________________________________________________
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ExG4RunAction01::EndOfRunAction(const G4Run* run)
{
// save Rndm status
@@ -113,11 +117,13 @@ void ExG4RunAction01::EndOfRunAction(const G4Run* run)
G4int runNumber = run->GetRunID();
std::ostringstream fileName;
fileName << "run" << runNumber << "end.rndm";
CLHEP::HepRandom::saveEngineStatus(fileName.str().c_str());
CLHEP::HepRandom::showEngineStatus();
G4Random::saveEngineStatus(fileName.str().c_str());
G4Random::showEngineStatus();
}
if ( G4VVisManager::GetConcreteInstance() ) {
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,35 +26,59 @@
//
// $Id$
//
/// \file testPrimaryGenerator.cc
/// \brief Test program for the primaryGenerator common classes
/// \file testCommon.cc
/// \brief Test program for the common classes
#include "ExG4DetectorConstruction01.hh"
#include "ExG4DetectorConstruction02.hh"
#include "ExG4PhysicsList00.hh"
#include "ExG4PrimaryGeneratorAction01.hh"
#include "ExG4PrimaryGeneratorAction02.hh"
#include "ExG4EventAction01.hh"
#include "ExG4RunAction01.hh"
#include "G4RunManager.hh"
#include "QGSP_BERT.hh"
#include "FTFP_BERT.hh"
// test program which only instantiates classes defined in
// examples/common/primaryGenerator
// Test program which only instantiates classes defined in
// examples/common
int main()
{
// First construct necessary classes
//
G4RunManager * runManager = new G4RunManager;
G4VModularPhysicsList* physicsList = new QGSP_BERT;
G4VModularPhysicsList* physicsList = new FTFP_BERT;
runManager->SetUserInitialization(physicsList);
// Instantiate all detector construction classes
ExG4DetectorConstruction01* detectorConstruction01
= new ExG4DetectorConstruction01;
ExG4DetectorConstruction02* detectorConstruction02
= new ExG4DetectorConstruction02;
// Instantiate all physics list classes
ExG4PhysicsList00* physicsList00 = new ExG4PhysicsList00();
// Instantiate all primary generator actions classes
ExG4PrimaryGeneratorAction01* primaryGeneratorAction01
= new ExG4PrimaryGeneratorAction01();
ExG4PrimaryGeneratorAction02* primaryGeneratorAction02
= new ExG4PrimaryGeneratorAction02();
// Instantiate all user actions classes
ExG4EventAction01* eventAction01 = new ExG4EventAction01();
ExG4RunAction01* runAction01 = new ExG4RunAction01();
// delete all
delete detectorConstruction01;
delete detectorConstruction02;
delete physicsList00;
delete primaryGeneratorAction01;
delete primaryGeneratorAction02;
delete eventAction01;
delete runAction01;
return 0;
}
@@ -1,58 +0,0 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(userActions)
#----------------------------------------------------------------------------
# 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 executable, and link it to the Geant4 libraries
#
add_executable(testUserActions testUserActions.cc ${sources} ${headers})
target_link_libraries(testUserActions ${Geant4_LIBRARIES} )
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build userActions. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(userActions_SCRIPTS
)
foreach(_script ${userActions_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(userActions DEPENDS testUserActions)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS testUserActions DESTINATION bin)
@@ -1,17 +0,0 @@
# $Id: GNUmakefile 68059 2013-03-13 14:49:02Z gcosmo $
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := testUserActions
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
@@ -1,60 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//
// $Id$
//
/// \file testUserActions.cc
/// \brief Test program for the userActions common classes
#include "ExG4EventAction01.hh"
#include "ExG4RunAction01.hh"
#include "G4RunManager.hh"
#include "QGSP_BERT.hh"
// test program which only instantiates classes defined in
// examples/common/userActions
int main()
{
// First construct necessary classes
//
G4RunManager * runManager = new G4RunManager;
G4VModularPhysicsList* physicsList = new QGSP_BERT;
runManager->SetUserInitialization(physicsList);
// Instantiate all primary generator actions classes
ExG4EventAction01* eventAction01 = new ExG4EventAction01();
ExG4RunAction01* runAction01 = new ExG4RunAction01();
// delete all
delete eventAction01;
delete runAction01;
return 0;
}