Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
+38
View File
@@ -0,0 +1,38 @@
//$Id$
///\file "common/.README"
///\brief Common classes README page
/*! \page Examples_common Category "common"
In order to reduce code duplication and to reduce the number of variants of
the code of same kind, we define a set of common classes which
can be reused in "feature" examples demonstrating just a particular feature.
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
- \ref extended_common_physicsList :
- ExG4PhysicsList00 - physics list with geantino and chargedgeantino only
- \ref extended_common_primaryGenerator :
- two simple primary generator classes (with G4ParticleGun and
G4ParticleGeneralSource)
- \ref extended_common_userActions :
- event action and run action classes with messengers
*/
+9
View File
@@ -0,0 +1,9 @@
#---Adding all common examples subdirectories explicitly
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
add_subdirectory(analysis)
add_subdirectory(detectorConstruction)
add_subdirectory(physicsList)
add_subdirectory(primaryGenerator)
add_subdirectory(userActions)
+15
View File
@@ -15,6 +15,21 @@ track of all tags.
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
26/09/2012 I. Hrivnacova (excommon-V09-05-02)
- Added/updated CMakeLists.txt files:
adding copying macros, install target, comment lines
and HBOOK external package in analysis
- Added explicit includes of G4SystemOfUnits.hh and G4PhysicalConstants.hh
- Replaced tabulators with space characters
- Updated script for generating CMakeLists.txt files
19/07/2012 I. Hrivnacova (excommon-V09-05-01)
- Fix in the scripts (copying files from shared with an extension)
05/06/2012 I. Hrivnacova (excommon-V09-05-00)
- Updated scripts for copying shared files; the shared files are now
defined in the SharedFilesList.txt file
23/11/2011 I. Hrivnacova (excommon-V09-04-01)
- Addded physicsList directory with a physics list with genatino
and charged geantino
+1 -1
View File
@@ -15,7 +15,7 @@ $Id$
the following sets of classes:
- analysis
- ExG4HbookManager - the analysis manager class for HBOOK
- 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:
@@ -0,0 +1,92 @@
#----------------------------------------------------------------------------
# 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)
+61
View File
@@ -0,0 +1,61 @@
$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 *
----------------------------------------------------------
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
@@ -0,0 +1,21 @@
# 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)
@@ -25,7 +25,7 @@
//
// $Id$
//
/// \file ExG4HbookAnalysisManager.hh
/// \file common/analysis/include/ExG4HbookAnalysisManager.hh
/// \brief Definition of the ExG4HbookAnalysisManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
@@ -58,6 +58,37 @@ namespace G4Hbook {
typedef ExG4HbookAnalysisManager G4AnalysisManager;
}
struct h1_booking {
h1_booking(G4int nbins, G4double xmin, G4double xmax)
: fTitle(""),
fNbins(nbins),
fXmin(xmin),
fXmax(xmax) {}
G4String fTitle;
G4int fNbins;
G4double fXmin;
G4double fXmax;
};
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;
};
/// HBook Analysis manager
///
/// The class implements the G4VAnalysisManager manager for HBook.
@@ -72,19 +103,41 @@ class ExG4HbookAnalysisManager : public G4VAnalysisManager
// static methods
static ExG4HbookAnalysisManager* Instance();
// Methods to manipulate files
using G4VAnalysisManager::OpenFile;
virtual G4bool OpenFile(const G4String& fileName);
virtual G4bool Write();
virtual G4bool CloseFile();
// Methods to create histogrammes, ntuples
virtual G4int CreateH1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax);
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName = "none",
const G4String& fcnName = "none");
virtual G4int CreateH2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax);
G4int nybins, G4double ymin, G4double ymax,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none");
virtual G4bool SetH1(G4int id,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName = "none",
const G4String& fcnName = "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");
virtual G4bool ScaleH1(G4int id, G4double factor);
virtual G4bool ScaleH2(G4int id, G4double factor);
virtual void CreateNtuple(const G4String& name, const G4String& title);
virtual G4int CreateNtupleIColumn(const G4String& name);
virtual G4int CreateNtupleFColumn(const G4String& name);
@@ -101,39 +154,142 @@ class ExG4HbookAnalysisManager : public G4VAnalysisManager
virtual G4bool AddNtupleRow();
// Access methods
virtual tools::hbook::h1* GetH1(G4int id, G4bool warn = true) const;
virtual tools::hbook::h2* GetH2(G4int id, G4bool warn = true) const;
//tools::hbook::h1* GetH1(const G4String& name, G4bool warn = true) const;
virtual tools::hbook::h1* GetH1(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
virtual tools::hbook::h2* GetH2(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
virtual tools::hbook::wntuple* GetNtuple() const;
// Access methods via names
virtual G4int GetH1Id(const G4String& name, G4bool warn = true) const;
virtual G4int GetH2Id(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;
// 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 SetH1Title(G4int id, const G4String& title);
virtual G4bool SetH1XAxisTitle(G4int id, const G4String& title);
virtual G4bool SetH1YAxisTitle(G4int id, const G4String& title);
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 GetH1Title(G4int id) const;
virtual G4String GetH1XAxisTitle(G4int id) const;
virtual G4String GetH1YAxisTitle(G4int id) const;
virtual G4String GetH2Title(G4int id) const;
virtual G4String GetH2XAxisTitle(G4int id) const;
virtual G4String GetH2YAxisTitle(G4int id) const;
virtual G4String GetH2ZAxisTitle(G4int id) const;
// 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);
//
// Set the offset of HBOOK ID for H2
// ( default value = firstHistoID + 100 if firstHistoID > 0; otherwise = 101 )
G4bool SetH2HbookIdOffset(G4int offset);
//
// Set the HBOOK ID for the ntuple
// (default value = 1 )
G4bool SetNtupleHbookId(G4int ntupleId);
G4int GetH1HbookIdOffset() const;
G4int GetH2HbookIdOffset() const;
G4int GetNtupleHbookId() const;
protected:
virtual G4bool WriteOnAscii(std::ofstream& output);
private:
// static data members
//
static ExG4HbookAnalysisManager* fgInstance;
static const G4int fgkDefaultH2HbookIdOffset;
static const G4int fgkDefaultNtupleHbookId;
static const G4String fgkDefaultNtupleDirectoryName;
// methods
//
void SetH1HbookIdOffset();
void SetH2HbookIdOffset();
void CreateH1FromBooking();
void CreateH2FromBooking();
void CreateNtupleFromBooking();
tools::hbook::wntuple::column<int>* GetNtupleIColumn(G4int id) const;
tools::hbook::wntuple::column<float>* GetNtupleFColumn(G4int id) const;
tools::hbook::wntuple::column<double>* GetNtupleDColumn(G4int id) const;
void Reset();
virtual h1_booking* GetH1Booking(G4int id, G4bool warn = true) const;
virtual h2_booking* GetH2Booking(G4int id, G4bool warn = true) const;
virtual tools::hbook::h1* GetH1InFunction(G4int id, G4String function,
G4bool warn = true,
G4bool onlyIfActive = true) const;
virtual tools::hbook::h2* GetH2InFunction(G4int id, G4String function,
G4bool warn = true,
G4bool onlyIfActive = true) const;
void UpdateTitle(G4String& title,
const G4String& unitName, const G4String& fcnName) const;
// data members
//
G4int fH1HbookIdOffset;
G4int fH2HbookIdOffset;
G4int fNtupleHbookId;
tools::hbook::wfile* fFile;
std::vector<tools::hbook::h1*> fH1Vector;
std::map<G4String, tools::hbook::h1*> fH1MapByName;
std::vector<tools::hbook::h1*> fH1Vector;
std::vector<tools::hbook::h2*> fH2Vector;
std::vector<h1_booking*> fH1BookingVector;
std::vector<h2_booking*> fH2BookingVector;
std::map<G4String, G4int> fH1NameIdMap;
std::map<G4String, G4int> fH2NameIdMap;
std::vector<tools::hbook::h2*> fH2Vector;
std::map<G4String, tools::hbook::h2*> fH2MapByName;
G4String fNtupleName;
G4String fNtupleTitle;
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;
};
// inline functions
inline G4int ExG4HbookAnalysisManager::GetH1HbookIdOffset() const {
return fH1HbookIdOffset;
}
inline G4int ExG4HbookAnalysisManager::GetH2HbookIdOffset() const {
return fH2HbookIdOffset;
}
inline G4int ExG4HbookAnalysisManager::GetNtupleHbookId() const {
return fNtupleHbookId;
}
#endif
#endif
@@ -0,0 +1,42 @@
//
// ********************************************************************
// * 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
@@ -0,0 +1,51 @@
//
// ********************************************************************
// * 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
File diff suppressed because it is too large Load Diff
@@ -26,7 +26,7 @@
//
// $Id$
//
/// \file testAnalysis.cc
/// \file common/analysis/testAnalysis.cc
/// \brief Test program for the analysis common classes
#ifdef G4_USE_HBOOK
@@ -34,7 +34,7 @@
#endif
// test program which only instantiates classes defined in
// examples/common/analysis
// examples/extended/common/analysis
int main()
{
@@ -1,12 +1,58 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(detectorConstruction)
set(name testDetectorConstruction)
project(${name})
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIR})
file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
add_executable(${name} EXCLUDE_FROM_ALL ${name}.cc ${sources})
target_link_libraries(${name} ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# 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)
@@ -36,9 +36,8 @@
#include "ExG4DetectorConstruction01Messenger.hh"
#include "G4ThreeVector.hh"
#include "globals.hh"
#include "CLHEP/Units/SystemOfUnits.h"
class G4LogicalVolume;
class G4Material;
@@ -51,7 +50,9 @@ class ExG4DetectorConstruction01 : public G4VUserDetectorConstruction
public:
ExG4DetectorConstruction01(
const G4String& materialName = "G4_AIR",
G4double hx = 50*cm, G4double hy = 50*cm, G4double hz = 50*cm);
G4double hx = 50*CLHEP::cm,
G4double hy = 50*CLHEP::cm,
G4double hz = 50*CLHEP::cm);
~ExG4DetectorConstruction01();
public:
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ExG4DetectorConstruction01Messenger.hh,v 1.2 2006-06-29 16:46:14 gunter Exp $
// $Id$
//
/// \file ExG4DetectorConstruction01Messenger.hh
/// \brief Definition of the ExG4DetectorConstruction01Messenger class
@@ -36,9 +36,8 @@
#include "ExG4DetectorConstruction02Messenger.hh"
#include "G4ThreeVector.hh"
#include "globals.hh"
#include "CLHEP/Units/SystemOfUnits.h"
class G4LogicalVolume;
class G4Material;
@@ -51,7 +50,9 @@ class ExG4DetectorConstruction02 : public G4VUserDetectorConstruction
public:
ExG4DetectorConstruction02(
const G4String& boxMaterialName = "G4_AIR",
G4double boxHx = 40*cm, G4double boxHy = 40*cm, G4double boxHz = 40*cm,
G4double boxHx = 40*CLHEP::cm,
G4double boxHy = 40*CLHEP::cm,
G4double boxHz = 40*CLHEP::cm,
const G4String& worldMaterialName = "G4_AIR",
G4double worldSizeFactor = 1.25);
~ExG4DetectorConstruction02();
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ExG4DetectorConstruction02Messenger.hh,v 1.2 2006-06-29 16:46:14 gunter Exp $
// $Id$
//
/// \file ExG4DetectorConstruction02Messenger.hh
/// \brief Definition of the ExG4DetectorConstruction02Messenger class
@@ -73,24 +73,24 @@ G4VPhysicalVolume* ExG4DetectorConstruction01::Construct()
// World
//
G4Box* sWorld
= new G4Box("World", //name
fDimensions.x(), //dimensions (half-lentghs)
= new G4Box("World", //name
fDimensions.x(), //dimensions (half-lentghs)
fDimensions.y(),
fDimensions.z());
fWorldVolume
= new G4LogicalVolume(sWorld, //shape
material, //material
"World"); //name
= new G4LogicalVolume(sWorld, //shape
material, //material
"World"); //name
G4VPhysicalVolume* pWorld
= new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
"World", //name
0, //mother volume
false, //no boolean operation
0); //copy number
= new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
"World", //name
0, //mother volume
false, //no boolean operation
0); //copy number
//always return the root volume
//
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ExG4DetectorConstruction01Messenger.cc,v 1.2 2006-06-29 16:46:49 gunter Exp $
// $Id$
//
/// \file ExG4DetectorConstruction01Messenger.cc
/// \brief Implementation of the ExG4DetectorConstruction01Messenger class
@@ -86,45 +86,45 @@ G4VPhysicalVolume* ExG4DetectorConstruction02::Construct()
// World
//
G4Box* sWorld
= new G4Box("World", //name
worldDimensions.x(), //dimensions (half-lentghs)
= new G4Box("World", //name
worldDimensions.x(), //dimensions (half-lentghs)
worldDimensions.y(),
worldDimensions.z());
fWorldVolume
= new G4LogicalVolume(sWorld, //shape
worldMaterial, //material
"World"); //name
= new G4LogicalVolume(sWorld, //shape
worldMaterial, //material
"World"); //name
G4VPhysicalVolume* pWorld
= new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
"World", //name
0, //mother volume
false, //no boolean operation
0); //copy number
= new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fWorldVolume, //logical volume
"World", //name
0, //mother volume
false, //no boolean operation
0); //copy number
// Box
//
//
G4Box* sBox
= new G4Box("Box", //its name
fBoxDimensions.x(), //dimensions (half-lengths)
= new G4Box("Box", //its name
fBoxDimensions.x(), //dimensions (half-lengths)
fBoxDimensions.y(),
fBoxDimensions.z());
fBoxVolume
= new G4LogicalVolume(sBox, //its shape
boxMaterial, //its material
"Box"); //its name
= new G4LogicalVolume(sBox, //its shape
boxMaterial, //its material
"Box"); //its name
new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fBoxVolume, //its logical volume
"Box", //its name
fWorldVolume, //its mother volume
false, //no boolean operation
0); //copy number
new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fBoxVolume, //its logical volume
"Box", //its name
fWorldVolume, //its mother volume
false, //no boolean operation
0); //copy number
//always return the root volume
//
@@ -1,12 +1,58 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(physicsList)
set(name testPhysicsList)
project(${name})
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIR})
file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
add_executable(${name} EXCLUDE_FROM_ALL ${name}.cc ${sources})
target_link_libraries(${name} ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# 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,12 +1,58 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(primaryGenerator)
set(name testPrimaryGenerator)
project(${name})
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIR})
file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
add_executable(${name} EXCLUDE_FROM_ALL ${name}.cc ${sources})
target_link_libraries(${name} ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# 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)
@@ -35,6 +35,8 @@
#include "G4ThreeVector.hh"
#include "globals.hh"
#include "CLHEP/Units/SystemOfUnits.h"
class G4ParticleGun;
class G4Event;
@@ -48,7 +50,7 @@ class ExG4PrimaryGeneratorAction01 : public G4VUserPrimaryGeneratorAction
public:
ExG4PrimaryGeneratorAction01(
const G4String& particleName = "geantino",
G4double energy = 1.*MeV,
G4double energy = 1.*CLHEP::MeV,
G4ThreeVector position= G4ThreeVector(0,0,0),
G4ThreeVector momentumDirection = G4ThreeVector(0,0,1));
~ExG4PrimaryGeneratorAction01();
@@ -32,6 +32,7 @@
#include "G4Event.hh"
#include "G4GeneralParticleSource.hh"
#include "G4SystemOfUnits.hh"
const G4String ExG4PrimaryGeneratorAction02::fgkDefaultParticleName = "e-";
const G4double ExG4PrimaryGeneratorAction02::fgkDefaultEnergy = 1*MeV;
@@ -0,0 +1,5 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(EXAMPLE_NAME)
@@ -0,0 +1,17 @@
#----------------------------------------------------------------------------
# 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})
@@ -0,0 +1,11 @@
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
@@ -0,0 +1,9 @@
#----------------------------------------------------------------------------
# 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()
@@ -0,0 +1,10 @@
#----------------------------------------------------------------------------
# Find EXTERN_PACKAGE (optional package)
#
find_package(EXTERN_PACKAGE)
if(EXTERN_PACKAGE_TO_UPPER_FOUND QUIET)
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()
@@ -0,0 +1,8 @@
#----------------------------------------------------------------------------
# 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)
@@ -0,0 +1,9 @@
#----------------------------------------------------------------------------
# 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)
@@ -0,0 +1,6 @@
#----------------------------------------------------------------------------
# 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)
@@ -0,0 +1,6 @@
#----------------------------------------------------------------------------
# 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)
@@ -0,0 +1,17 @@
#----------------------------------------------------------------------------
# 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()
@@ -0,0 +1,6 @@
#----------------------------------------------------------------------------
# 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)
@@ -0,0 +1,5 @@
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS EXAMPLE_PROGRAM_NAME DESTINATION bin)
+106 -10
View File
@@ -1,21 +1,117 @@
#!/bin/sh
# Script to remove classes copied from common repository in examples.
# All files with ExG4 prefix will be removed.
# Script to clean classes specified in SharedFilesList.txt file.
# Usage: clean_files.sh [example_source_dir]
#
# Usage:
# clean_files.sh [--force]
# By I. Hrivnacova, IPN Orsay
FROM=`pwd`
CURDIR=`pwd`
FORCE=""
if [ "$1" = "--force" ]; then
FORCE="-f"
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
rm $FORCE include/ExG4*.hh
rm $FORCE src/ExG4*.cc
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
+21
View File
@@ -0,0 +1,21 @@
#!/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
+173 -33
View File
@@ -1,40 +1,180 @@
#!/bin/sh
# Script to copy classes from common repository in examples.
# Usage:
# copy_files.sh className versionNumber [messenger]
# Script to copy classes specified in SharedFilesList.txt file.
# Usage: copy_files.sh [root_dir example_source_dir]
#
# By I. Hrivnacova, IPN Orsay
COMMON_DIR=../../../common
PREFIX="ExG4"
TO=`pwd`
IS_KEYWORD="no"
WHERE=""
EXAMPLE_PATH="undefined"
COMMON_CLASSES_PATH="undefined"
SHARED_CLASSES_PATH="undefined"
fileName=$1
fileVersion=$2
isMessenger=$3
NEXT_EXAMPLE_PATH="no"
NEXT_COMMON_CLASSES_PATH="no"
NEXT_SHARED_CLASSES_PATH="no"
NEXT_COMMON_CLASSES_LIST="no"
NEXT_SHARED_CLASSES_LIST="no"
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
EXTH=".hh"
EXTC=".cc"
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
# 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"
+40
View File
@@ -0,0 +1,40 @@
#!/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
+250
View File
@@ -0,0 +1,250 @@
#!/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 visualization
GREP_VIS=`cat "$EXAMPLE_PROGRAM_NAME"".cc" | grep G4VisExecutive`
if [ "${GREP_VIS}" = "" ]; then
NO_VIS="_no_vis"
else
NO_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"${NO_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
}
# 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,12 +1,58 @@
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(userActions)
set(name testUserActions)
project(${name})
#----------------------------------------------------------------------------
# Find Geant4 package, no UI and Vis drivers activated
#
find_package(Geant4 REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${Geant4_INCLUDE_DIR})
file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
add_executable(${name} EXCLUDE_FROM_ALL ${name}.cc ${sources})
target_link_libraries(${name} ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# 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)