Import Geant4 10.3.1 source tree

This commit is contained in:
Gabriele Cosmo
2017-02-28 16:18:37 +01:00
parent 4597adb7c4
commit 3a5407696b
563 changed files with 0 additions and 95641 deletions
@@ -1,80 +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()
#--- Enable Fortran ------------------------------------------------------------
enable_language(Fortran)
#----------------------------------------------------------------------------
# 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)
#----------------------------------------------------------------------------
# Locate fortran sources
#
if(HBOOK_FOUND)
file(GLOB fortran_sources ${PROJECT_SOURCE_DIR}/src/*.f)
endif()
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(testAnalysis testAnalysis.cc ${sources} ${fortran_sources} ${headers})
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 66241 2012-12-13 18:34:42Z gunter $
# --------------------------------------------------------------
# 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,53 +0,0 @@
# $Id$
# --------------------------------------------------------------
# GNUmakefile for ing4 HBOOK support.
# --------------------------------------------------------------
ifdef G4_USE_HBOOK
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -DG4_USE_HBOOK
CPPFLAGS += -I./hbook/include
EXTRALIBS += $(G4TMPDIR)/exe/close.o $(G4TMPDIR)/exe/setpawc.o $(G4TMPDIR)/exe/setntuc.o
EXTRALIBS += -L${CERNLIB}/lib -lpacklib -lmathlib -lgfortran -lcrypt -lkernlib
#FC=gfortran
hbook: close.o setpawc.o setntuc.o
ifdef CPPVERBOSE
(mv *.o $(G4TMPDIR)/exe);
else
@(mv *.o $(G4TMPDIR)/exe);
endif
close.o : hbook/src/close.f
@echo Compiling close.f
ifdef CPPVERBOSE
$(FC) -c hbook/src/close.f
else
@$(FC) -c hbook/src/close.f
endif
setpawc.o : hbook/src/setpawc.f
@echo Compiling setpawc.f
ifdef CPPVERBOSE
$(FC) -c hbook/src/setpawc.f
else
@$(FC) -c hbook/src/setpawc.f
endif
setntuc.o : hbook/src/setntuc.f
@echo Compiling setntuc.f
ifdef CPPVERBOSE
$(FC) -c hbook/src/setntuc.f
else
@$(FC) -c hbook/src/setntuc.f
endif
else
hbook:
endif
@@ -1,117 +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 *
----------------------------------------------------------
03/11/2014 I. Hrivnacova (excommon-analysis-V10-00-03)
- Updated for changes in analysis category
- Implemented P1 manager
- Added H3 and P2 dummy managers (now removed from Geant4 kernel)
- Fixed applying units
- Applied new exception classification
17/06/2014 I. Hrivnacova (excommon-analysis-V10-00-02)
- Fixed problems reported by Davide Mancusi:
- Moving tools/hbook/*.f files in examples/extended/common/analysis/src
to avoid their retrieval from Geant4 source/includes which causes problem
when building examples against Geant4 build directory.
- Added -lkernlib in list of libraries (required with Debian cernlib
distribution 20061220)
- In CMake build: replaced explicit use of gfortran with
enable_language(Fortran) and using fortran_sources variable in analogous
way as sources
12/06/2014 I. Hrivnacova (excommon-analysis-V10-00-01)
- Added typedefs and functions for accessing iterators
over H1, H2, Ntuples;
Usage:
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
for (G4H1Iterator it = analysisManager->BeginH1();
it != analysisManager->EndH1(); it++ ) {
G4H1* h1 = *it;
// call any h1 function define in tools
}
11/06/2014 I. Hrivnacova (excommon-analysis-V10-00-00)
- Updated for changes in analysis category:
ntuple columns of vectors (disabled), changes in ntuple_booking
- Updated to g4tools 1.10.0 (by G. Barrand):
See History_tools for complete list of modifications.
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 -lkernlib")
endif()
mark_as_advanced(HBOOK_FOUND HBOOK_LIBRARIES)
@@ -1,180 +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 hbook/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/p1>
#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 tools::hbook::h1 G4H1;
typedef tools::hbook::h2 G4AnaH2;
typedef tools::hbook::h2 G4H2;
typedef tools::hbook::p1 G4P1;
typedef tools::hbook::wntuple G4Ntuple;
typedef ExG4HbookAnalysisManager G4AnalysisManager;
}
class ExG4HbookFileManager;
class ExG4HbookH1Manager;
class ExG4HbookH2Manager;
class ExG4HbookH3DummyManager;
class ExG4HbookP1Manager;
class ExG4HbookP2DummyManager;
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 HBOOK ID for P1
// ( default value = firstHistoID + 200 if firstHistoID > 0;
// otherwise = 201 )
G4bool SetP1HbookIdOffset(G4int offset);
G4int GetP1HbookIdOffset() 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::p1* GetP1(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
tools::hbook::wntuple* GetNtuple() const;
tools::hbook::wntuple* GetNtuple(G4int ntupleId) const;
// Iterators
std::vector<tools::hbook::h1*>::iterator BeginH1();
std::vector<tools::hbook::h1*>::iterator EndH1();
std::vector<tools::hbook::h1*>::const_iterator BeginConstH1() const;
std::vector<tools::hbook::h1*>::const_iterator EndConstH1() const;
std::vector<tools::hbook::h2*>::iterator BeginH2();
std::vector<tools::hbook::h2*>::iterator EndH2();
std::vector<tools::hbook::h2*>::const_iterator BeginConstH2() const;
std::vector<tools::hbook::h2*>::const_iterator EndConstH2() const;
std::vector<tools::hbook::p1*>::iterator BeginP1();
std::vector<tools::hbook::p1*>::iterator EndP1();
std::vector<tools::hbook::p1*>::const_iterator BeginConstP1() const;
std::vector<tools::hbook::p1*>::const_iterator EndConstP1() const;
std::vector<tools::hbook::wntuple*>::iterator BeginNtuple();
std::vector<tools::hbook::wntuple*>::iterator EndNtuple();
std::vector<tools::hbook::wntuple*>::const_iterator BeginConstNtuple() const;
std::vector<tools::hbook::wntuple*>::const_iterator EndConstNtuple() const;
protected:
// virtual methods from base class
virtual G4bool OpenFileImpl(const G4String& fileName);
virtual G4bool WriteImpl();
virtual G4bool CloseFileImpl();
virtual G4bool PlotImpl();
virtual G4bool MergeImpl(tools::histo::hmpi* hmpi);
virtual G4bool IsOpenFileImpl() const;
private:
// static data members
//
static ExG4HbookAnalysisManager* fgInstance;
// methods
//
void Reset();
ExG4HbookH1Manager* fH1Manager;
ExG4HbookH2Manager* fH2Manager;
ExG4HbookH3DummyManager* fH3Manager;
ExG4HbookP1Manager* fP1Manager;
ExG4HbookP2DummyManager* fP2Manager;
ExG4HbookNtupleManager* fNtupleManager;
std::shared_ptr<ExG4HbookFileManager> fFileManager;
};
#include "ExG4HbookAnalysisManager.icc"
#endif
#endif
@@ -1,257 +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 $
/// \file hbook/include/ExG4HbookAnalysisManager.icc
/// \brief Inline functions of the ExG4HbookAnalysisManager class
#include "ExG4HbookH1Manager.hh"
#include "ExG4HbookH2Manager.hh"
#include "ExG4HbookP1Manager.hh"
#include "ExG4HbookNtupleManager.hh"
#include "ExG4HbookFileManager.hh"
//_____________________________________________________________________________
inline
G4bool ExG4HbookAnalysisManager::IsOpenFileImpl() const
{
return fFileManager->IsOpenFile();
}
//_____________________________________________________________________________
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::SetP1HbookIdOffset(G4int offset)
{
return fP1Manager->SetP1HbookIdOffset(offset);
}
//_____________________________________________________________________________
inline
G4int ExG4HbookAnalysisManager::GetP1HbookIdOffset() const
{
return fP1Manager->GetP1HbookIdOffset();
}
//_____________________________________________________________________________
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::p1* ExG4HbookAnalysisManager::GetP1(G4int id, G4bool warn,
G4bool onlyIfActive) const
{
return fP1Manager->GetP1(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);
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h1*>::iterator ExG4HbookAnalysisManager::BeginH1()
{
return fH1Manager->BeginH1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h1*>::iterator ExG4HbookAnalysisManager::EndH1()
{
return fH1Manager->EndH1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h1*>::const_iterator
ExG4HbookAnalysisManager::BeginConstH1() const
{
return fH1Manager->BeginConstH1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h1*>::const_iterator
ExG4HbookAnalysisManager::EndConstH1() const
{
return fH1Manager->EndConstH1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h2*>::iterator ExG4HbookAnalysisManager::BeginH2()
{
return fH2Manager->BeginH2();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h2*>::iterator ExG4HbookAnalysisManager::EndH2()
{
return fH2Manager->EndH2();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h2*>::const_iterator
ExG4HbookAnalysisManager::BeginConstH2() const
{
return fH2Manager->BeginConstH2();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::h2*>::const_iterator
ExG4HbookAnalysisManager::EndConstH2() const
{
return fH2Manager->EndConstH2();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::p1*>::iterator ExG4HbookAnalysisManager::BeginP1()
{
return fP1Manager->BeginP1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::p1*>::iterator ExG4HbookAnalysisManager::EndP1()
{
return fP1Manager->EndP1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::p1*>::const_iterator
ExG4HbookAnalysisManager::BeginConstP1() const
{
return fP1Manager->BeginConstP1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::p1*>::const_iterator
ExG4HbookAnalysisManager::EndConstP1() const
{
return fP1Manager->EndConstP1();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::wntuple*>::iterator ExG4HbookAnalysisManager::BeginNtuple()
{
return fNtupleManager->BeginNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::wntuple*>::iterator ExG4HbookAnalysisManager::EndNtuple()
{
return fNtupleManager->EndNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::wntuple*>::const_iterator
ExG4HbookAnalysisManager::BeginConstNtuple() const
{
return fNtupleManager->BeginConstNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::hbook::wntuple*>::const_iterator
ExG4HbookAnalysisManager::EndConstNtuple() const
{
return fNtupleManager->EndConstNtuple();
}
@@ -1,86 +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 hbook/include/ExG4HbookBaseHnManager.hh
/// \brief Definition of the ExG4HbookBaseHnManager class
// Author: Ivana Hrivnacova, 03/11/2014 (ivana@ipno.in2p3.fr)
#ifndef ExG4HbookBaseHnManager_h
#define ExG4HbookBaseHnManager_h 1
#include "globals.hh"
#include "tools/hbook/base_histo"
#include "tools/hbook/axis"
/// Manager class for tools::hbook::base_histo functions.
///
/// It implements functions common to all hbook histograms and profiles.
class ExG4HbookBaseHnManager //: public G4VH1Manager
{
public:
ExG4HbookBaseHnManager(const G4String& hnType);
virtual ~ExG4HbookBaseHnManager();
friend class ExG4HbookH1Manager;
friend class ExG4HbookH2Manager;
friend class ExG4HbookP1Manager;
protected:
typedef tools::hbook::base_histo G4HbookBaseHisto;
// Access to datA parameters
G4int GetNbins(const tools::hbook::axis& axis) const;
G4double GetMin(const tools::hbook::axis& axis) const;
G4double GetMax(const tools::hbook::axis& axis) const;
G4double GetWidth(const tools::hbook::axis& axis) const;
// Attributes for plotting
//
// Setters
//G4bool SetTitle(G4HbookBaseHisto& baseHisto, const G4String& title);
G4bool SetAxisTitle(G4HbookBaseHisto& baseHisto, G4int dimension, const G4String& title);
// Accessors
//G4String GetTitle(const G4HbookBaseHisto& baseHisto) const;
G4String GetAxisTitle(const G4HbookBaseHisto& baseHisto, G4int dimension) const;
// Static data members
static const G4int kX;
static const G4int kY;
static const G4int kZ;
private:
// Data members
G4String fHnType;
};
#endif
@@ -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 hbook/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>
/// Manager class 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,248 +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 hbook/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 "G4THnManager.hh"
#include "G4HnManager.hh"
#include "ExG4HbookBaseHnManager.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(""),
fXAxisTitle(""),
fYAxisTitle(""),
fNbins(nbins),
fXmin(xmin),
fXmax(xmax),
fEdges() {}
h1_booking(const std::vector<G4double>& edges)
: fTitle(""),
fXAxisTitle(""),
fYAxisTitle(""),
fNbins(0),
fXmin(0),
fXmax(0),
fEdges() {
for (G4int i=0; i<G4int(edges.size()); ++i) fEdges.push_back(edges[i]);
}
G4String fTitle;
G4String fXAxisTitle;
G4String fYAxisTitle;
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,
public G4THnManager<tools::hbook::h1>
{
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;
// Iterators
std::vector<tools::hbook::h1*>::iterator BeginH1();
std::vector<tools::hbook::h1*>::iterator EndH1();
std::vector<tools::hbook::h1*>::const_iterator BeginConstH1() const;
std::vector<tools::hbook::h1*>::const_iterator EndConstH1() 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);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager();
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 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
//
ExG4HbookBaseHnManager fBaseToolsManager;
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;
}
inline std::vector<tools::hbook::h1*>::iterator ExG4HbookH1Manager::BeginH1()
{ return BeginT(); }
inline std::vector<tools::hbook::h1*>::iterator ExG4HbookH1Manager::EndH1()
{ return EndT(); }
inline std::vector<tools::hbook::h1*>::const_iterator
ExG4HbookH1Manager::BeginConstH1() const
{ return BeginConstT(); }
inline std::vector<tools::hbook::h1*>::const_iterator
ExG4HbookH1Manager::EndConstH1() const
{ return EndConstT(); }
inline std::shared_ptr<G4HnManager> ExG4HbookH1Manager::GetHnManager()
{ return std::shared_ptr<G4HnManager>(fHnManager); }
#endif
#endif
@@ -1,246 +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 hbook/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 "G4THnManager.hh"
#include "G4HnManager.hh"
#include "ExG4HbookBaseHnManager.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(""),
fXAxisTitle(""),
fYAxisTitle(""),
fZAxisTitle(""),
fNxbins(nxbins),
fXmin(xmin),
fXmax(xmax),
fNybins(nybins),
fYmin(ymin),
fYmax(ymax) {}
G4String fTitle;
G4String fXAxisTitle;
G4String fYAxisTitle;
G4String fZAxisTitle;
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,
public G4THnManager<tools::hbook::h2>
{
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;
// Iterators
std::vector<tools::hbook::h2*>::iterator BeginH2();
std::vector<tools::hbook::h2*>::iterator EndH2();
std::vector<tools::hbook::h2*>::const_iterator BeginConstH2() const;
std::vector<tools::hbook::h2*>::const_iterator EndConstH2() 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);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager();
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
//
ExG4HbookBaseHnManager fBaseToolsManager;
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;
}
inline std::vector<tools::hbook::h2*>::iterator ExG4HbookH2Manager::BeginH2()
{ return BeginT(); }
inline std::vector<tools::hbook::h2*>::iterator ExG4HbookH2Manager::EndH2()
{ return EndT(); }
inline std::vector<tools::hbook::h2*>::const_iterator
ExG4HbookH2Manager::BeginConstH2() const
{ return BeginConstT(); }
inline std::vector<tools::hbook::h2*>::const_iterator
ExG4HbookH2Manager::EndConstH2() const
{ return EndConstT(); }
inline std::shared_ptr<G4HnManager> ExG4HbookH2Manager::GetHnManager()
{ return std::shared_ptr<G4HnManager>(fHnManager); }
#endif
#endif
@@ -1,179 +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: ExG4HbookH3DummyManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
/// \file hbook/include/ExG4HbookH3DummyManager.hh
/// \brief Definition of the ExG4HbookH3DummyManager class
// Author: Ivana Hrivnacova, 03/11/2014 (ivana@ipno.in2p3.fr)
#ifndef ExG4HbookH3DummyManager_h
#define ExG4HbookH3DummyManager_h 1
#include "G4VH3Manager.hh"
#include "G4THnManager.hh"
#include "G4HnManager.hh"
#include "globals.hh"
#include <vector>
#include <map>
namespace tools {
namespace histo {
class h3d;
}
}
/// Manager class for H3 with dummy implementation.
///
/// It will just issue warnings.
class ExG4HbookH3DummyManager : public G4VH3Manager,
public G4THnManager<G4int>
{
public:
ExG4HbookH3DummyManager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookH3DummyManager();
protected:
// Virtual functions from base class
//
// Methods to create histograms
//
virtual G4int CreateH3(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
G4int nzbins, G4double zmin, G4double zmax,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none",
const G4String& xbinScheme = "linear",
const G4String& ybinScheme = "linear",
const G4String& zbinScheme = "linear");
virtual G4int CreateH3(const G4String& name, const G4String& title,
const std::vector<G4double>& xedges,
const std::vector<G4double>& yedges,
const std::vector<G4double>& zedges,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none");
virtual G4bool SetH3(G4int id,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
G4int nzbins, G4double zmin, G4double zmax,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none",
const G4String& xbinScheme = "linear",
const G4String& ybinScheme = "linear",
const G4String& zbinScheme = "linear");
virtual G4bool SetH3(G4int id,
const std::vector<G4double>& xedges,
const std::vector<G4double>& yedges,
const std::vector<G4double>& zedges,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none");
virtual G4bool ScaleH3(G4int id, G4double factor);
// Method to fill histograms
//
virtual G4bool FillH3(G4int id,
G4double xvalue, G4double yvalue, G4double zvalue,
G4double weight = 1.0);
// Methods to manipulate histograms
//
// Access methods
virtual G4int GetH3Id(const G4String& name, G4bool warn = true) const;
// Access to H3 parameters
virtual G4int GetH3Nxbins(G4int id) const;
virtual G4double GetH3Xmin(G4int id) const;
virtual G4double GetH3Xmax(G4int id) const;
virtual G4double GetH3XWidth(G4int id) const;
virtual G4int GetH3Nybins(G4int id) const;
virtual G4double GetH3Ymin(G4int id) const;
virtual G4double GetH3Ymax(G4int id) const;
virtual G4double GetH3YWidth(G4int id) const;
virtual G4int GetH3Nzbins(G4int id) const;
virtual G4double GetH3Zmin(G4int id) const;
virtual G4double GetH3Zmax(G4int id) const;
virtual G4double GetH3ZWidth(G4int id) const;
// Setters for attributes for plotting
virtual G4bool SetH3Title(G4int id, const G4String& title);
virtual G4bool SetH3XAxisTitle(G4int id, const G4String& title);
virtual G4bool SetH3YAxisTitle(G4int id, const G4String& title);
virtual G4bool SetH3ZAxisTitle(G4int id, const G4String& title);
// Access attributes for plotting
virtual G4String GetH3Title(G4int id) const;
virtual G4String GetH3XAxisTitle(G4int id) const;
virtual G4String GetH3YAxisTitle(G4int id) const;
virtual G4String GetH3ZAxisTitle(G4int id) const;
// Write data on ASCII file
virtual G4bool WriteOnAscii(std::ofstream& output);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager();
private:
// methods
void ExceptionForHistograms(const G4String& functionName);
void ExceptionForHistogramsConst(const G4String& functionName) const;
// data members
G4bool fWarn;
};
// inline functions
inline std::shared_ptr<G4HnManager> ExG4HbookH3DummyManager::GetHnManager()
{ return std::shared_ptr<G4HnManager>(fHnManager); }
#endif
@@ -1,68 +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 $
/// \file hbook/include/ExG4HbookNtupleDescription.hh
/// \brief Definition of the ExG4HbookNtupleDescription structure
// 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(),
fActivation(true) {}
~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;
G4bool fActivation;
};
#endif
#endif
@@ -1,191 +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 hbook/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;
// Iterators
std::vector<tools::hbook::wntuple*>::iterator BeginNtuple();
std::vector<tools::hbook::wntuple*>::iterator EndNtuple();
std::vector<tools::hbook::wntuple*>::const_iterator BeginConstNtuple() const;
std::vector<tools::hbook::wntuple*>::const_iterator EndConstNtuple() 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, std::vector<int>* vector);
virtual G4int CreateNtupleFColumn(
const G4String& name, std::vector<float>* vector);
virtual G4int CreateNtupleDColumn(
const G4String& name, std::vector<double>* vector);
virtual G4int CreateNtupleSColumn(const G4String& name);
virtual void FinishNtuple();
// Create columns in the ntuple with given id
virtual G4int CreateNtupleIColumn(G4int ntupleId,
const G4String& name, std::vector<int>* vector);
virtual G4int CreateNtupleFColumn(G4int ntupleId,
const G4String& name, std::vector<float>* vector);
virtual G4int CreateNtupleDColumn(G4int ntupleId,
const G4String& name, std::vector<double>* vector);
virtual G4int CreateNtupleSColumn(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 FillNtupleSColumn(G4int columnId, const G4String& 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 FillNtupleSColumn(
G4int ntupleId, G4int columnId, const G4String& value);
virtual G4bool AddNtupleRow(G4int ntupleId);
// Activation option
virtual void SetActivation(G4bool activation);
virtual void SetActivation(G4int ntupleId, G4bool activation);
virtual G4bool GetActivation(G4int ntupleId) const;
// 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*> fNtupleDescriptionVector;
std::vector<tools::hbook::wntuple*> fNtupleVector;
};
// inline functions
inline void ExG4HbookNtupleManager::SetFileManager(ExG4HbookFileManager* fileManager)
{ fFileManager = fileManager; }
inline G4int ExG4HbookNtupleManager::GetNtupleHbookIdOffset() const {
return fNtupleHbookIdOffset;
}
inline std::vector<tools::hbook::wntuple*>::iterator
ExG4HbookNtupleManager::BeginNtuple()
{ return fNtupleVector.begin(); }
inline std::vector<tools::hbook::wntuple*>::iterator
ExG4HbookNtupleManager::EndNtuple()
{ return fNtupleVector.end(); }
inline std::vector<tools::hbook::wntuple*>::const_iterator
ExG4HbookNtupleManager::BeginConstNtuple() const
{ return fNtupleVector.begin(); }
inline std::vector<tools::hbook::wntuple*>::const_iterator
ExG4HbookNtupleManager::EndConstNtuple() const
{ return fNtupleVector.end(); }
inline G4int ExG4HbookNtupleManager::GetNofNtuples() const
{ return fNtupleVector.size(); }
#endif
#endif
@@ -1,286 +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 hbook/include/ExG4HbookP1Manager.hh
/// \brief Definition of the ExG4HbookP1Manager class
// Author: Ivana Hrivnacova, 03/11/2014 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#ifndef ExG4HbookP1Manager_h
#define ExG4HbookP1Manager_h 1
#include "G4VP1Manager.hh"
#include "G4THnManager.hh"
#include "G4HnManager.hh"
#include "G4HnInformation.hh"
#include "ExG4HbookBaseHnManager.hh"
#include "globals.hh"
#include <tools/hbook/p1>
#include <vector>
#include <map>
class ExG4HbookFileManager;
struct p1_booking {
p1_booking(G4int nbins, G4double xmin, G4double xmax,
G4double ymin, G4double ymax)
: fTitle(""),
fXAxisTitle(""),
fYAxisTitle(""),
fZAxisTitle(""),
fNbins(nbins),
fXmin(xmin),
fXmax(xmax),
fYmin(ymin),
fYmax(ymax),
fEdges() {}
p1_booking(const std::vector<G4double>& edges,
G4double ymin, G4double ymax)
: fTitle(""),
fXAxisTitle(""),
fYAxisTitle(""),
fZAxisTitle(""),
fNbins(0),
fXmin(0),
fXmax(0),
fYmin(ymin),
fYmax(ymax),
fEdges() {
for (G4int i=0; i<G4int(edges.size()); ++i) fEdges.push_back(edges[i]);
}
G4String fTitle;
G4String fXAxisTitle;
G4String fYAxisTitle;
G4String fZAxisTitle;
G4int fNbins;
G4double fXmin;
G4double fXmax;
G4double fYmin;
G4double fYmax;
std::vector<G4double> fEdges;
};
/// Manager class for HBook P1 histograms
///
/// The class implements the G4VP1Manager 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 ExG4HbookP1Manager : public G4VP1Manager,
public G4THnManager<tools::hbook::p1>
{
friend class ExG4HbookAnalysisManager;
protected:
ExG4HbookP1Manager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookP1Manager();
// Functions specific to the output type
//
// HBOOK does not allow IDs the same IDs for P1 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 P1
// ( default value = firstHistoID if firstHistoID > 0; otherwise = 1)
G4bool SetP1HbookIdOffset(G4int offset);
G4int GetP1HbookIdOffset() const;
// Set methods
void SetFileManager(ExG4HbookFileManager* fileManager);
// Access methods
//
tools::hbook::p1* GetP1(G4int id, G4bool warn = true,
G4bool onlyIfActive = true) const;
// Iterators
std::vector<tools::hbook::p1*>::iterator BeginP1();
std::vector<tools::hbook::p1*>::iterator EndP1();
std::vector<tools::hbook::p1*>::const_iterator BeginConstP1() const;
std::vector<tools::hbook::p1*>::const_iterator EndConstP1() const;
// Virtual functions from base class
//
// Methods to create profiles
virtual G4int CreateP1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
G4double ymin = 0, G4double ymax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& xbinScheme = "linear");
virtual G4int CreateP1(const G4String& name, const G4String& title,
const std::vector<G4double>& edges,
G4double ymin = 0, G4double ymax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none");
virtual G4bool SetP1(G4int id,
G4int nbins, G4double xmin, G4double xmax,
G4double ymin = 0, G4double ymax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& xbinScheme = "linear");
virtual G4bool SetP1(G4int id,
const std::vector<G4double>& edges,
G4double ymin = 0, G4double ymax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none");
virtual G4bool ScaleP1(G4int id, G4double factor);
// Methods to fill profiles
virtual G4bool FillP1(G4int id, G4double value, G4double yvalue,
G4double weight = 1.0);
// Access methods
//
virtual G4int GetP1Id(const G4String& name, G4bool warn = true) const;
// Access to P1 parameters
virtual G4int GetP1Nbins(G4int id) const;
virtual G4double GetP1Xmin(G4int id) const;
virtual G4double GetP1Xmax(G4int id) const;
virtual G4double GetP1XWidth(G4int id) const;
virtual G4double GetP1Ymin(G4int id) const;
virtual G4double GetP1Ymax(G4int id) const;
// Setters for attributes for plotting
virtual G4bool SetP1Title(G4int id, const G4String& title);
virtual G4bool SetP1XAxisTitle(G4int id, const G4String& title);
virtual G4bool SetP1YAxisTitle(G4int id, const G4String& title);
// Access attributes for plotting
virtual G4String GetP1Title(G4int id) const;
virtual G4String GetP1XAxisTitle(G4int id) const;
virtual G4String GetP1YAxisTitle(G4int id) const;
// Write data on ASCII file
// virtual G4bool WriteOnAscii(std::ofstream& output);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager();
private:
// methods
//
void SetP1HbookIdOffset();
void AddP1Information(const G4String& name,
const G4String& xunitName,
const G4String& yunitName,
const G4String& xfcnName,
const G4String& yfcnName,
G4BinScheme xbinScheme) const;
G4int CreateP1FromBooking(p1_booking* p1Booking,
G4bool chDir = true);
G4int RegisterP1Booking(const G4String& name,
p1_booking* p1Booking);
void BeginCreateP1(const G4String& name);
G4int FinishCreateP1(const G4String& name, p1_booking* p1Booking,
const G4String& xunitName,
const G4String& yunitName,
const G4String& xfcnName,
const G4String& yfcnName,
G4BinScheme xbinScheme) ;
G4bool FinishSetP1(G4int id,
G4HnInformation* info,
const G4String& xunitName,
const G4String& yunitName,
const G4String& xfcnName,
const G4String& yfcnName,
G4BinScheme xbinScheme) ;
void CreateP1sFromBooking();
void Reset();
virtual p1_booking* GetP1Booking(G4int id, G4bool warn = true) const;
virtual tools::hbook::p1* GetP1InFunction(G4int id, G4String function,
G4bool warn = true,
G4bool onlyIfActive = true) const;
// static data members
//
static const G4int fgkDefaultP1HbookIdOffset;
// data members
//
ExG4HbookBaseHnManager fBaseToolsManager;
ExG4HbookFileManager* fFileManager;
G4int fP1HbookIdOffset;
std::vector<tools::hbook::p1*> fP1Vector;
std::vector<p1_booking*> fP1BookingVector;
std::map<G4String, G4int> fP1NameIdMap;
};
// inline functions
inline void ExG4HbookP1Manager::SetFileManager(ExG4HbookFileManager* fileManager)
{ fFileManager = fileManager; }
inline G4int ExG4HbookP1Manager::GetP1HbookIdOffset() const
{ return fP1HbookIdOffset; }
inline std::vector<tools::hbook::p1*>::iterator ExG4HbookP1Manager::BeginP1()
{ return BeginT(); }
inline std::vector<tools::hbook::p1*>::iterator ExG4HbookP1Manager::EndP1()
{ return EndT(); }
inline std::vector<tools::hbook::p1*>::const_iterator
ExG4HbookP1Manager::BeginConstP1() const
{ return BeginConstT(); }
inline std::vector<tools::hbook::p1*>::const_iterator
ExG4HbookP1Manager::EndConstP1() const
{ return EndConstT(); }
inline std::shared_ptr<G4HnManager> ExG4HbookP1Manager::GetHnManager()
{ return std::shared_ptr<G4HnManager>(fHnManager); }
#endif
#endif
@@ -1,170 +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: ExG4HbookP2DummyManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
/// \file hbook/include/ExG4HbookP2DummyManager.hh
/// \brief Definition of the ExG4HbookP2DummyManager class
// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
#ifndef ExG4HbookP2DummyManager_h
#define ExG4HbookP2DummyManager_h 1
#include "G4VP2Manager.hh"
#include "G4THnManager.hh"
#include "G4HnManager.hh"
namespace tools {
namespace histo {
class h3d;
}
}
/// Manager class for P2 with dummy implementation.
///
/// It will just issue warnings.
class ExG4HbookP2DummyManager : public G4VP2Manager,
public G4THnManager<G4int>
{
public:
ExG4HbookP2DummyManager(const G4AnalysisManagerState& state);
virtual ~ExG4HbookP2DummyManager();
protected:
// Virtual functions from base class
//
// Methods to create histograms
//
virtual G4int CreateP2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
G4double zmin = 0, G4double zmax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none",
const G4String& xbinScheme = "linear",
const G4String& ybinScheme = "linear");
virtual G4int CreateP2(const G4String& name, const G4String& title,
const std::vector<G4double>& xedges,
const std::vector<G4double>& yedges,
G4double zmin = 0, G4double zmax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none");
virtual G4bool SetP2(G4int id,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax,
G4double zmin = 0, G4double zmax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none",
const G4String& xbinScheme = "linear",
const G4String& ybinScheme = "linear");
virtual G4bool SetP2(G4int id,
const std::vector<G4double>& xedges,
const std::vector<G4double>& yedges,
G4double zmin = 0, G4double zmax = 0,
const G4String& xunitName = "none",
const G4String& yunitName = "none",
const G4String& zunitName = "none",
const G4String& xfcnName = "none",
const G4String& yfcnName = "none",
const G4String& zfcnName = "none");
virtual G4bool ScaleP2(G4int id, G4double factor);
// Method to fill histograms
//
virtual G4bool FillP2(G4int id,
G4double xvalue, G4double yvalue, G4double zvalue,
G4double weight = 1.0);
// Methods to manipulate histograms
//
// Access methods
virtual G4int GetP2Id(const G4String& name, G4bool warn = true) const;
// Access to P2 parameters
virtual G4int GetP2Nxbins(G4int id) const;
virtual G4double GetP2Xmin(G4int id) const;
virtual G4double GetP2Xmax(G4int id) const;
virtual G4double GetP2XWidth(G4int id) const;
virtual G4int GetP2Nybins(G4int id) const;
virtual G4double GetP2Ymin(G4int id) const;
virtual G4double GetP2Ymax(G4int id) const;
virtual G4double GetP2YWidth(G4int id) const;
virtual G4double GetP2Zmin(G4int id) const;
virtual G4double GetP2Zmax(G4int id) const;
// Setters for attributes for plotting
virtual G4bool SetP2Title(G4int id, const G4String& title);
virtual G4bool SetP2XAxisTitle(G4int id, const G4String& title);
virtual G4bool SetP2YAxisTitle(G4int id, const G4String& title);
virtual G4bool SetP2ZAxisTitle(G4int id, const G4String& title);
// Access attributes for plotting
virtual G4String GetP2Title(G4int id) const;
virtual G4String GetP2XAxisTitle(G4int id) const;
virtual G4String GetP2YAxisTitle(G4int id) const;
virtual G4String GetP2ZAxisTitle(G4int id) const;
// Write data on ASCII file
virtual G4bool WriteOnAscii(std::ofstream& output);
// Access to Hn manager
virtual std::shared_ptr<G4HnManager> GetHnManager();
private:
// methods
void ExceptionForProfiles(const G4String& functionName);
void ExceptionForProfilesConst(const G4String& functionName) const;
// data members
G4bool fWarn;
};
// inline functions
inline std::shared_ptr<G4HnManager> ExG4HbookP2DummyManager::GetHnManager()
{ return std::shared_ptr<G4HnManager>(fHnManager); }
#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 hbook/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,71 +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 hbook/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 {
// H1 types
typedef tools::hbook::h1 G4AnaH1; // keep for backward compatibility
typedef tools::hbook::h1 G4H1;
typedef std::vector<tools::hbook::h1*>::iterator G4H1Iterator;
typedef std::vector<tools::hbook::h1*>::const_iterator G4H1ConstIterator;
// H2 types
typedef tools::hbook::h2 G4AnaH2; // keep for backward compatibility
typedef tools::hbook::h2 G4H2;
typedef std::vector<tools::hbook::h2*>::iterator G4H2Iterator;
typedef std::vector<tools::hbook::h2*>::const_iterator G4H2ConstIterator;
// P1 types
typedef tools::hbook::p1 G4P1;
typedef std::vector<tools::hbook::p1*>::iterator G4P1Iterator;
typedef std::vector<tools::hbook::p1*>::const_iterator G4P1ConstIterator;
// Ntuple types
typedef tools::hbook::wntuple G4Ntuple;
typedef std::vector<tools::hbook::wntuple*>::iterator G4NtupleIterator;
typedef std::vector<tools::hbook::wntuple*>::const_iterator G4NtupleConstIterator;
// Managers
typedef ExG4HbookAnalysisManager G4AnalysisManager;
}
#endif
@@ -1,261 +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 hbook/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 "ExG4HbookH3DummyManager.hh"
#include "ExG4HbookP1Manager.hh"
#include "ExG4HbookP2DummyManager.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),
fH3Manager(0),
fP1Manager(0),
fP2Manager(0),
fNtupleManager(0),
fFileManager(0)
{
if ( G4Threading::IsWorkerThread() ) {
// 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);
fH3Manager = new ExG4HbookH3DummyManager(fState);
fP1Manager = new ExG4HbookP1Manager(fState);
fP2Manager = new ExG4HbookP2DummyManager(fState);
fNtupleManager = new ExG4HbookNtupleManager(fState);
fFileManager = std::make_shared<ExG4HbookFileManager>(fState);
// Set managers to base class
SetH1Manager(fH1Manager);
SetH2Manager(fH2Manager);
SetH3Manager(fH3Manager);
SetP1Manager(fP1Manager);
SetP2Manager(fP2Manager);
SetNtupleManager(fNtupleManager);
SetFileManager(fFileManager);
// Set file manager to component managers
fH1Manager->SetFileManager(fFileManager.get());
fH2Manager->SetFileManager(fFileManager.get());
fP1Manager->SetFileManager(fFileManager.get());
fNtupleManager->SetFileManager(fFileManager.get());
// 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();
fP1Manager->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 p1 profiles if any is booked
fP1Manager->CreateP1sFromBooking();
// 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;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::PlotImpl()
{
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager does not support batch plotting.";
G4Exception("ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()",
"Analysis_W041", JustWarning, description);
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::MergeImpl(tools::histo::hmpi* /*hmpi*/)
{
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager does not support MPI.";
G4Exception("ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()",
"Analysis_W041", JustWarning, description);
return false;
}
#endif
@@ -1,159 +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 hbook/src/ExG4HbookBaseHnManager.cc
/// \brief Implementation of the ExG4HbookBaseHnManager class
// Author: Ivana Hrivnacova, 03/11/2014 (ivana@ipno.in2p3.fr)
#include "ExG4HbookBaseHnManager.hh"
// static data
const G4int ExG4HbookBaseHnManager::kX = 0;
const G4int ExG4HbookBaseHnManager::kY = 1;
const G4int ExG4HbookBaseHnManager::kZ = 2;
//
// Constructors, destructor
//
//_____________________________________________________________________________
ExG4HbookBaseHnManager::ExG4HbookBaseHnManager(const G4String& hnType)
: fHnType(hnType)
{
}
//_____________________________________________________________________________
ExG4HbookBaseHnManager::~ExG4HbookBaseHnManager()
{
}
//_____________________________________________________________________________
G4int ExG4HbookBaseHnManager::GetNbins(const tools::hbook::axis& axis) const
{
return axis.bins();
}
//_____________________________________________________________________________
G4double ExG4HbookBaseHnManager::GetMin(const tools::hbook::axis& axis) const
{
// Returns min data value
return axis.lower_edge();
}
//_____________________________________________________________________________
G4double ExG4HbookBaseHnManager::GetMax(const tools::hbook::axis& axis) const
{
// Returns max data value
return axis.upper_edge();
}
//_____________________________________________________________________________
G4double ExG4HbookBaseHnManager::GetWidth(const tools::hbook::axis& axis) const
{
G4int nbins = axis.bins();
if ( ! nbins ) {
G4String functionName = "ExG4HbookBaseHnManager::Get";
functionName += fHnType;
functionName += "Width";
G4ExceptionDescription description;
description << " nbins = 0 (for " << fHnType << ").";
G4Exception(functionName, "Analysis_W014", JustWarning, description);
return 0;
}
return ( axis.upper_edge() - axis.lower_edge() )/nbins;
}
/*
//_____________________________________________________________________________
G4bool ExG4HbookBaseHnManager::SetTitle(G4HbookBaseHisto& baseHisto,
const G4String& title)
{
return baseHisto.set_title(title);
}
*/
//_____________________________________________________________________________
G4bool ExG4HbookBaseHnManager::SetAxisTitle(G4HbookBaseHisto& baseHisto,
G4int dimension, const G4String& title)
{
if ( title == "" ) return false;
if ( dimension == 0 ) {
baseHisto.add_annotation(tools::hbook::key_axis_x_title(), title);
}
else if ( dimension == 1 ) {
baseHisto.add_annotation(tools::hbook::key_axis_y_title(), title);
}
else if ( dimension == 2 ) {
baseHisto.add_annotation(tools::hbook::key_axis_z_title(), title);
}
return true;
}
/*
//_____________________________________________________________________________
G4String ExG4HbookBaseHnManager::GetTitle(const G4HbookBaseHisto& baseHisto) const
{
return baseHisto.title();
}
*/
//_____________________________________________________________________________
G4String ExG4HbookBaseHnManager::GetAxisTitle(const G4HbookBaseHisto& baseHisto,
G4int dimension) const
{
G4String title;
G4bool result = false;
if ( dimension == 0 ) {
result = baseHisto.annotation(tools::hbook::key_axis_x_title(), title);
}
else if ( dimension == 1 ) {
result = baseHisto.annotation(tools::hbook::key_axis_y_title(), title);
}
else if ( dimension == 2 ) {
result = baseHisto.annotation(tools::hbook::key_axis_z_title(), title);
}
if ( ! result ) {
G4String axes("xyz");
G4String axis = axes(dimension, 1);
G4String functionName = "ExG4HbookBaseHnManager::Get";
functionName += fHnType;
functionName += axis;
functionName += "Title";
G4ExceptionDescription description;
description << " Failed to get " << axis << " axis " << fHnType << " title.";
G4Exception(functionName, "Analysis_W014", JustWarning, description);
return "";
}
return title;
}
@@ -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 hbook/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 a "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,893 +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 hbook/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(),
G4THnManager<tools::hbook::h1>(state, "H1"),
fBaseToolsManager("H1"),
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* hnInformation,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme)
{
hnInformation->SetDimension(kX, unitName, fcnName, binScheme);
}
//_____________________________________________________________________________
h1_booking* CreateH1Booking(const G4String& title,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
h1_booking* h1Booking = 0;
if ( binScheme != G4BinScheme::kLog ) {
if ( binScheme == G4BinScheme::kUser ) {
// 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/unit), fcn(xmax/unit));
// h1_booking object is deleted in destructor
}
else {
// Compute edges
std::vector<G4double> edges;
ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
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)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
// Apply function
std::vector<G4double> newEdges;
ComputeEdges(edges, unit, fcn, newEdges);
h1_booking* h1Booking = new h1_booking(newEdges);
// 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,
G4BinScheme binScheme)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
if ( binScheme != G4BinScheme::kLog ) {
if ( binScheme == G4BinScheme::kUser ) {
// 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/unit);
h1Booking->fXmax = fcn(xmax/unit);
}
else {
// Compute edges
ComputeEdges(nbins, xmin, xmax, unit, 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)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
// Apply function
ComputeEdges(edges, unit, fcn, h1Booking->fEdges);
UpdateTitle(h1Booking->fTitle, unitName, fcnName);
}
//_____________________________________________________________________________
void ConfigureHbookH1(tools::hbook::h1* h1,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
if ( binScheme != G4BinScheme::kLog ) {
if ( binScheme == G4BinScheme::kUser ) {
// 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);
}
G4cout << "configuring "
<< h1 << ", " << fcn(xmin/unit) << ", " << fcn(xmax/unit) << G4endl;
h1->configure(nbins, fcn(xmin/unit), fcn(xmax/unit));
}
else {
// Compute bins
std::vector<G4double> edges;
ComputeEdges(nbins, xmin, xmax, unit, 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& unitName,
const G4String& fcnName)
{
// Apply function to edges
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
std::vector<G4double> newEdges;
ComputeEdges(edges, unit, 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 ( fHnManager->GetFirstId() > 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_W013", JustWarning, description);
//}
}
}
//_____________________________________________________________________________
void ExG4HbookH1Manager::AddH1Information(const G4String& name,
const G4String& unitName,
const G4String& fcnName,
G4BinScheme binScheme) const
{
auto hnInformation = fHnManager->AddHnInformation(name, 1);
hnInformation->AddDimension(unitName, fcnName, 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 + fHnManager->GetFirstId();
G4HnInformation*
info = fHnManager->GetHnInformation(id, "CreateH1FromBooking");
// Hbook index
G4int hbookIndex = fH1HbookIdOffset + index + fHnManager->GetFirstId();
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("create from booking", "h1", info->GetName());
#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);
// Update axis titles
fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kX, h1Booking->fXAxisTitle);
fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kY, h1Booking->fYAxisTitle);
if ( chDir ) {
if ( fFileManager->GetHistoDirectoryName() != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() ) {
G4ExceptionDescription description;
description << " name : " << info->GetName() << " 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 + fHnManager->GetFirstId();
return index + fHnManager->GetFirstId();
}
//_____________________________________________________________________________
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::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 (not needed as done by Hbook when closing file)
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 - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fH1BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookH1Manager::GetH1Booking()",
"Analysis_W011", 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 + fHnManager->GetFirstId();
G4HnInformation* info
= fHnManager->GetHnInformation(id, "WriteOnAscii");
// skip writing if activation is enabled and H1 is inactivated
if ( ! info->GetAscii() ) continue;
tools::hbook::h1* h1 = fH1Vector[i];
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()->Message("write on ascii", "h1", info->GetName());
#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 - fHnManager->GetFirstId();
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_W011", 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, G4BinScheme::kUser);
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1(G4int id,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
const G4String& binSchemeName)
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1()",
"Analysis_W011", JustWarning, description);
return false;
}
G4HnInformation* info = fHnManager->GetHnInformation(id,"SetH1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
#endif
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, unitName, 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 = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1()",
"Analysis_W011", JustWarning, description);
return false;
}
G4HnInformation* info = fHnManager->GetHnInformation(id,"SetH1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
#endif
// 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, unitName, fcnName);
}
return
FinishSetH1(id, info, unitName, fcnName, G4BinScheme::kUser);
}
//_____________________________________________________________________________
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;
}
G4HnDimensionInformation* info
= fHnManager->GetHnDimensionInformation(id, kX, "FillH1");
h1->fill(info->fFcn(value/info->fUnit), weight);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value
<< " fcn(value/unit) " << info->fFcn(value/info->fUnit)
<< " weight " << weight;
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_W011", 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 fBaseToolsManager.GetNbins(h1->axis());
}
//_____________________________________________________________________________
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;
return fBaseToolsManager.GetMin(h1->axis());
}
//_____________________________________________________________________________
G4double ExG4HbookH1Manager::GetH1Xmax(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1Xmax");
if ( ! h1 ) return 0;
return fBaseToolsManager.GetMax(h1->axis());
}
//_____________________________________________________________________________
G4double ExG4HbookH1Manager::GetH1Width(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1XWidth", true, false);
if ( ! h1 ) return 0;
return fBaseToolsManager.GetWidth(h1->axis());
}
//_____________________________________________________________________________
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("G4HbookH1Manager::SetH1Title()",
"Analysis_W011", JustWarning, description);
return false;
}
h1Booking->fTitle = title;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1XAxisTitle(G4int id, const G4String& title)
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1XAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h1Booking->fXAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1XAxisTitle", false, false);
if ( ! h1 ) return true;
return fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kX, title);
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1YAxisTitle(G4int id, const G4String& title)
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1YAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h1Booking->fYAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1YAxisTitle", false, false);
if ( ! h1 ) return true;
return fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kY, title);
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1Title(G4int id) const
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::GetH1Title()",
"Analysis_W011", JustWarning, description);
return "";
}
return h1Booking->fTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1XAxisTitle(G4int id) const
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::GetH1XAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return h1Booking->fXAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1YAxisTitle(G4int id) const
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::GetH1YAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return h1Booking->fYAxisTitle;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1HbookIdOffset(G4int offset)
{
if ( fH1Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
G4Exception("G4HbookH1Manager::SetH1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
if ( fHnManager->GetFirstId() + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookH1Manager::SetH1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
fH1HbookIdOffset = offset;
return true;
}
#endif
@@ -1,734 +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 hbook/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 = 101;
//_____________________________________________________________________________
ExG4HbookH2Manager::ExG4HbookH2Manager(const G4AnalysisManagerState& state)
: G4VH2Manager(),
G4THnManager<tools::hbook::h2>(state, "H2"),
fBaseToolsManager("H2"),
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 ( fHnManager->GetFirstId() > 0 )
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset - 1;
else
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset;
//G4ExceptionDescription description;
// description << "H2 will be defined in HBOOK with ID = G4_firstHistoId + 101";
// G4Exception("ExG4HbookH2Manager::SetH2HbookIdOffset",
// "Analysis_W013", 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 + fHnManager->GetFirstId();
G4HnInformation* info = fHnManager->GetHnInformation(id, "CreateH2FromBooking");
// Hbook index
G4int hbookIndex = fH2HbookIdOffset + index + fHnManager->GetFirstId();
++index;
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()->Message("create from booking", "h2", info->GetName());
#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);
// Update axis titles
fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kX, (*it)->fXAxisTitle);
fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kY, (*it)->fYAxisTitle);
fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ, (*it)->fZAxisTitle);
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() ) {
G4ExceptionDescription description;
description << " name : " << info->GetName() << " 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 (not needed as done by Hbook when closing file)
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 - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fH2BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2Booking()",
"Analysis_W011", 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 - fHnManager->GetFirstId();
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_W011", 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);
h2_booking* h2Booking
= new h2_booking(nxbins, xfcn(xmin/xunit), xfcn(xmax/yunit),
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
// h2_booking object is deleted in destructor
G4String newTitle(title);
UpdateTitle(newTitle, xunitName, xfcnName);
UpdateTitle(newTitle, yunitName, yfcnName);
h2Booking->fTitle = newTitle;
fH2BookingVector.push_back(h2Booking);
auto hnInformation = fHnManager->AddHnInformation(name, 2);
hnInformation->AddDimension(xunitName, xfcnName, G4BinScheme::kLinear);
hnInformation->AddDimension(yunitName, yfcnName, G4BinScheme::kLinear);
// Set fH2HbookIdOffset if needed
SetH2HbookIdOffset();
// Hbook index
G4int hbookIndex = fH2HbookIdOffset + index + fHnManager->GetFirstId();
// 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"," ");
}
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fState.GetVerboseL2()->Message("create", "H2", description);
}
#endif
fH2NameIdMap[name] = index + fHnManager->GetFirstId();
return index + fHnManager->GetFirstId();
}
//_____________________________________________________________________________
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("G4HbookH2Manager::SetH2()",
"Analysis_W011", JustWarning, description);
return false;
}
G4HnInformation* hnInfo = fHnManager->GetHnInformation(id, "SetH2");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H2", hnInfo->GetName());
#endif
// Keep new parameters in booking
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
h2Booking->fNxbins = nxbins;
h2Booking->fXmin = xfcn(xmin/xunit);
h2Booking->fXmax = xfcn(xmax/xunit);
h2Booking->fNybins = nybins;
h2Booking->fYmin = yfcn(ymin/yunit);
h2Booking->fYmax = yfcn(ymax/yunit);
// Keep new parameters in information
G4HnDimensionInformation* xInfo
= hnInfo->GetHnDimensionInformation(kX);
xInfo->fUnitName = xunitName;
xInfo->fFcnName = xfcnName;
xInfo->fUnit = xunit;
xInfo->fFcn = xfcn;
G4HnDimensionInformation* yInfo
= hnInfo->GetHnDimensionInformation(kY);
yInfo->fUnitName = yunitName;
yInfo->fFcnName = yfcnName;
yInfo->fUnit = yunit;
yInfo->fFcn = 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/xunit), xfcn(xmax/xunit),
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
}
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;
G4HnDimensionInformation* xInfo
= fHnManager->GetHnDimensionInformation(id, kX, "FillH2");
G4HnDimensionInformation* yInfo
= fHnManager->GetHnDimensionInformation(id, kY, "FillH2");
h2->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
yInfo->fFcn(yvalue/yInfo->fUnit), weight);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " id " << id
<< " xvalue " << xvalue
<< " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
<< " yvalue " << yvalue
<< " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
<< " weight " << weight;
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_W011", 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 fBaseToolsManager.GetNbins(h2->axis_x());
}
//_____________________________________________________________________________
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;
return fBaseToolsManager.GetMin(h2->axis_x());
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2Xmax(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Xmax");
if ( ! h2 ) return 0;
return fBaseToolsManager.GetMin(h2->axis_x());
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2XWidth(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2XWidth", true, false);
if ( ! h2 ) return 0;
return fBaseToolsManager.GetWidth(h2->axis_x());
}
//_____________________________________________________________________________
G4int ExG4HbookH2Manager::GetH2Nybins(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2NYbins");
if ( ! h2 ) return 0;
return fBaseToolsManager.GetNbins(h2->axis_y());
}
//_____________________________________________________________________________
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;
return fBaseToolsManager.GetMin(h2->axis_y());
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2Ymax(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2Ymax");
if ( ! h2 ) return 0;
return fBaseToolsManager.GetMax(h2->axis_y());
}
//_____________________________________________________________________________
G4double ExG4HbookH2Manager::GetH2YWidth(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2YWidth", true, false);
if ( ! h2 ) return 0;
return fBaseToolsManager.GetWidth(h2->axis_y());
}
//_____________________________________________________________________________
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("G4HbookH2Manager::SetH2Title()",
"Analysis_W011", JustWarning, description);
return false;
}
h2Booking->fTitle = title;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2XAxisTitle(G4int id, const G4String& title)
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::SetH2XAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h2Booking->fXAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2XAxisTitle", false, false);
if ( ! h2 ) return true;
return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kX, title);
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2YAxisTitle(G4int id, const G4String& title)
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::SetH2YAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h2Booking->fYAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2YAxisTitle", false, false);
if ( ! h2 ) return true;
return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kY, title);
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2ZAxisTitle(G4int id, const G4String& title)
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::SetH2ZAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h2Booking->fZAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2ZAxisTitle", false, false);
if ( ! h2 ) return true;
return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ, title);
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2Title(G4int id) const
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2Title()",
"Analysis_W011", JustWarning, description);
return "";
}
return h2Booking->fTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2XAxisTitle(G4int id) const
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2XAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return h2Booking->fXAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2YAxisTitle(G4int id) const
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2YAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return h2Booking->fYAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2ZAxisTitle(G4int id) const
{
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2ZAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return h2Booking->fZAxisTitle;
}
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2HbookIdOffset(G4int offset)
{
if ( fH2Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
G4Exception("G4HbookH2Manager::SetH2HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
if ( fHnManager->GetFirstId() + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookH2Manager::SetH2HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
fH2HbookIdOffset = offset;
return true;
}
#endif
@@ -1,332 +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 hbook/src/ExG4HbookH3DummyManager.cc
/// \brief Implementation of the ExG4HbookH3DummyManager class
// Author: Ivana Hrivnacova, 03/11/2014 (ivana@ipno.in2p3.fr)
#include "ExG4HbookH3DummyManager.hh"
#include "G4AnalysisManagerState.hh"
//_____________________________________________________________________________
ExG4HbookH3DummyManager::ExG4HbookH3DummyManager(
const G4AnalysisManagerState& state)
: G4VH3Manager(),
G4THnManager<G4int>(state, "H3")
{
}
//_____________________________________________________________________________
ExG4HbookH3DummyManager::~ExG4HbookH3DummyManager()
{
}
//
// private methods
//
//_____________________________________________________________________________
void ExG4HbookH3DummyManager::ExceptionForHistograms(
const G4String& functionName)
{
if ( ! fWarn ) return;
ExceptionForHistogramsConst(functionName);
fWarn = false;
}
//_____________________________________________________________________________
void ExG4HbookH3DummyManager::ExceptionForHistogramsConst(
const G4String& functionName) const
{
G4String inFunction = "G4";
inFunction += fState.GetType();
inFunction += "AnalysisManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " "
<< "Histograms are not supported." ;
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
//
// protected methods
//
//_____________________________________________________________________________
G4int ExG4HbookH3DummyManager::CreateH3(const G4String& /*name*/,
const G4String& /*title*/,
G4int /*nxbins*/,
G4double /*xmin*/, G4double /*xmax*/,
G4int /*nybins*/,
G4double /*ymin*/, G4double /*ymax*/,
G4int /*nzbins*/,
G4double /*zmin*/, G4double /*zmax*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/,
const G4String& /*xbinScheme*/,
const G4String& /*ybinScheme*/,
const G4String& /*zbinScheme*/)
{
ExceptionForHistograms("CreateH3");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookH3DummyManager::CreateH3(const G4String& /*name*/,
const G4String& /*title*/,
const std::vector<G4double>& /*xedges*/,
const std::vector<G4double>& /*yedges*/,
const std::vector<G4double>& /*zedges*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/)
{
ExceptionForHistograms("CreateH3");
return 0;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::SetH3(G4int /*id*/,
G4int /*nxbins*/,
G4double /*xmin*/, G4double /*xmax*/,
G4int /*nybins*/,
G4double /*ymin*/, G4double /*ymax*/,
G4int /*nzbins*/,
G4double /*zmin*/, G4double /*zmax*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/,
const G4String& /*xbinScheme*/,
const G4String& /*ybinScheme*/,
const G4String& /*zbinScheme*/)
{
ExceptionForHistograms("SetH3");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::SetH3(G4int /*id*/,
const std::vector<G4double>& /*xedges*/,
const std::vector<G4double>& /*yedges*/,
const std::vector<G4double>& /*zedges*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/)
{
ExceptionForHistograms("SetH3");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::ScaleH3(G4int /*id*/, G4double /*factor*/)
{
ExceptionForHistograms("ScaleH3");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::FillH3(G4int /*id*/,
G4double /*xvalue*/, G4double /*yvalue*/,
G4double /*zvalue*/,
G4double /*weight*/)
{
ExceptionForHistograms("FillH3");
return false;
}
//_____________________________________________________________________________
G4int ExG4HbookH3DummyManager::GetH3Id(const G4String& /*name*/, G4bool /*warn*/) const
{
ExceptionForHistogramsConst("GetH3Id");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookH3DummyManager::GetH3Nxbins(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Nxbins");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3Xmin(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Xmin");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3Xmax(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Xmax");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3XWidth(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3XWidth");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookH3DummyManager::GetH3Nybins(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Nybins");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3Ymin(G4int /*id*/) const
{
ExceptionForHistogramsConst("");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3Ymax(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Ymax");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3YWidth(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3YWidth");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookH3DummyManager::GetH3Nzbins(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Nzbins");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3Zmin(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Zmin");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3Zmax(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Zmax");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookH3DummyManager::GetH3ZWidth(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3ZWidth");
return 0;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::SetH3Title(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForHistograms("SetH3Title");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::SetH3XAxisTitle(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForHistograms("SetH3XAxisTitle");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::SetH3YAxisTitle(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForHistograms("SetH3YAxisTitle");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::SetH3ZAxisTitle(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForHistograms("SetH3ZAxisTitle");
return false;
}
//_____________________________________________________________________________
G4String ExG4HbookH3DummyManager::GetH3Title(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3Title");
return "";
}
//_____________________________________________________________________________
G4String ExG4HbookH3DummyManager::GetH3XAxisTitle(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3XAxisTitle");
return "";
}
//_____________________________________________________________________________
G4String ExG4HbookH3DummyManager::GetH3YAxisTitle(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3YAxisTitle");
return "";
}
//_____________________________________________________________________________
G4String ExG4HbookH3DummyManager::GetH3ZAxisTitle(G4int /*id*/) const
{
ExceptionForHistogramsConst("GetH3ZAxisTitle");
return "";
}
//_____________________________________________________________________________
G4bool ExG4HbookH3DummyManager::WriteOnAscii(std::ofstream& /*output*/)
{
ExceptionForHistograms("WriteOnAscii");
return false;
}
@@ -1,838 +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 hbook/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 "G4AnalysisUtilities.hh"
#include "G4UnitsTable.hh"
#include <iostream>
using namespace G4Analysis;
//_____________________________________________________________________________
ExG4HbookNtupleManager::ExG4HbookNtupleManager(const G4AnalysisManagerState& state)
: G4VNtupleManager(state),
fNtupleHbookIdOffset(-1),
fNtupleDescriptionVector(),
fNtupleVector()
{
}
//_____________________________________________________________________________
ExG4HbookNtupleManager::~ExG4HbookNtupleManager()
{
// Reset();
std::vector<ExG4HbookNtupleDescription*>::iterator it;
for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.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_W013", JustWarning, description);
}
}
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::CreateNtuplesFromBooking()
{
// Create ntuple from ntuple_booking.
if ( ! fNtupleDescriptionVector.size() ) return;
// Set fNtupleHbookIdOffset if needed
SetNtupleHbookIdOffset();
G4int index = 0;
std::vector<ExG4HbookNtupleDescription*>::iterator itn;
for (itn = fNtupleDescriptionVector.begin(); itn != fNtupleDescriptionVector.end(); itn++ ) {
tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
if ( ! ntupleBooking ) continue;
// Do not create ntuple if it is inactivated
if ( fState.GetIsActivation() && ( ! (*itn)->fActivation ) ) continue;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()
->Message("create from booking", "ntuple", ntupleBooking->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);
fNtupleVector.push_back((*itn)->fNtuple);
if ( ntupleBooking->columns().size() ) {
// store ntuple columns in local maps
const std::vector<tools::column_booking>& columns
= ntupleBooking->columns();
std::vector<tools::column_booking>::const_iterator it;
G4int counter = 0;
for ( it = columns.begin(); it!=columns.end(); ++it) {
if ( it->cls_id() == tools::_cid(int(0) ) ) {
(*itn)->fNtupleIColumnMap[counter++]
= (*itn)->fNtuple->find_column<int>(it->name());
}
else if( it->cls_id() == tools::_cid(float(0) ) ) {
(*itn)->fNtupleFColumnMap[counter++]
= (*itn)->fNtuple->find_column<float>(it->name());
}
else if(it->cls_id()== tools::_cid(double(0))) {
(*itn)->fNtupleDColumnMap[counter++]
= (*itn)->fNtuple->find_column<double>(it->name());
}
else {
G4ExceptionDescription description;
description << " "
<< "Unsupported column type " << it->name();
G4Exception("G4HbookAnalysisManager::CreateNtupleFromBooking()",
"Analysis_W002", JustWarning, description);
}
}
}
FinishNtuple();
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() )
fState.GetVerboseL3()
->Message("create from booking", "ntuple", ntupleBooking->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_W011", 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_W011", 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_W011", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::Reset()
{
// Reset ntuple
std::vector<ExG4HbookNtupleDescription*>::iterator it3;
for (it3 = fNtupleDescriptionVector.begin(); it3 != fNtupleDescriptionVector.end(); it3++ ) {
delete (*it3)->fNtuple;
(*it3)->fNtuple = 0;
}
fNtupleVector.clear();
}
//
// protected methods
//
//_____________________________________________________________________________
ExG4HbookNtupleDescription* ExG4HbookNtupleManager::GetNtupleInFunction(
G4int id,
G4String functionName, G4bool warn,
G4bool /*onlyIfActive*/) const
{
G4int index = id - fFirstId;
if ( index < 0 || index >= G4int(fNtupleDescriptionVector.size()) ) {
if ( warn) {
G4String inFunction = "G4HbookAnalysisManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " " << "ntuple " << id << " does not exist.";
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
return 0;
}
return fNtupleDescriptionVector[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 = fNtupleDescriptionVector.size();
ExG4HbookNtupleDescription* ntupleDescription
= new ExG4HbookNtupleDescription();
fNtupleDescriptionVector.push_back(ntupleDescription);
// Create ntuple booking
ntupleDescription->fNtupleBooking
= new tools::ntuple_booking(name, 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
fNtupleVector.push_back(ntupleDescription->fNtuple);
}
#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,
std::vector<int>* vector)
{
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
return CreateNtupleIColumn(ntupleId, name, vector);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleFColumn(const G4String& name,
std::vector<float>* vector)
{
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
return CreateNtupleFColumn(ntupleId, name, vector);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleDColumn(const G4String& name,
std::vector<double>* vector)
{
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
return CreateNtupleDColumn(ntupleId, name, vector);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleSColumn(const G4String& name)
{
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
return CreateNtupleSColumn(ntupleId, name);
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::FinishNtuple()
{
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
FinishNtuple(ntupleId);
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleIColumn(G4int ntupleId,
const G4String& name,
std::vector<int>* vector)
{
// Vector columns are not supported in HBOOK
if ( vector ) {
G4ExceptionDescription description;
description << " "
<< "Vector columns are not supported in HBOOK.";
G4Exception("(ExG4HbookNtupleManager::CreateNtupleIColumn)",
"Analysis_W002", FatalException, description);
return kInvalidId;
}
#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_W002", JustWarning, description);
return kInvalidId;
}
// Save column info in booking
G4int index = ntupleBooking->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,
std::vector<float>* vector)
{
// Vector columns are not supported in HBOOK
if ( vector ) {
G4ExceptionDescription description;
description << " "
<< "Vector columns are not supported in HBOOK.";
G4Exception("(ExG4HbookNtupleManager::CreateNtupleFColumn)",
"Analysis_W002", FatalException, description);
return kInvalidId;
}
#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_W002", JustWarning, description);
return kInvalidId;
}
// Save column info in booking
G4int index = ntupleBooking->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,
std::vector<double>* vector)
{
// Vector columns are not supported in HBOOK
if ( vector ) {
G4ExceptionDescription description;
description << " "
<< "Vector columns are not supported in HBOOK.";
G4Exception("(ExG4HbookNtupleManager::CreateNtupleDColumn)",
"Analysis_W002", FatalException, description);
return kInvalidId;
}
#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_W002", JustWarning, description);
return kInvalidId;
}
// Save column info in booking
G4int index = ntupleBooking->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;
}
//_____________________________________________________________________________
G4int ExG4HbookNtupleManager::CreateNtupleSColumn(G4int /*ntupleId*/,
const G4String& /*name*/)
{
G4ExceptionDescription description;
description << " "
<< "Columns of string type are not supported in HBOOK.";
G4Exception("(ExG4HbookNtupleManager::CreateNtupleDColumn)",
"Analysis_W002", FatalException, description);
return kInvalidId;
}
//_____________________________________________________________________________
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->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->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::FillNtupleSColumn(G4int columnId,
const G4String& value)
{
return FillNtupleSColumn(fFirstId, columnId, value);
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::AddNtupleRow()
{
return AddNtupleRow(fFirstId);
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleIColumn(
G4int ntupleId, G4int columnId,
G4int value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
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_W011", 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)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
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_W011", 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)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
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_W011", 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::FillNtupleSColumn(
G4int ntupleId, G4int /*columnId*/,
const G4String& /*value*/)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
G4ExceptionDescription description;
description << " "
<< "Columns of string type are not supported in HBOOK.";
G4Exception("(ExG4HbookNtupleManager::FillNtupleSColumn)",
"Analysis_W011", JustWarning, description);
return kInvalidId;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::AddNtupleRow(G4int ntupleId)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
#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_W011", 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 ( fNtupleDescriptionVector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set NtupleHbookIdOffset as some ntuples already exist.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first ntuple HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
fNtupleHbookIdOffset = offset;
return true;
}
#endif
//_____________________________________________________________________________
void ExG4HbookNtupleManager::SetActivation(G4bool activation)
{
std::vector<ExG4HbookNtupleDescription*>::iterator it;
for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
(*it)->fActivation = activation;
}
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::SetActivation(G4int ntupleId, G4bool activation)
{
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "SetActivation");
if ( ! ntupleDescription ) return;
ntupleDescription->fActivation = activation;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::GetActivation(G4int ntupleId) const
{
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "GetActivation");
if ( ! ntupleDescription ) return false;
return ntupleDescription->fActivation;
}
File diff suppressed because it is too large Load Diff
@@ -1,315 +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 hbook/src/ExG4HbookP2DummyManager.cc
/// \brief Implementation of the ExG4HbookP2DummyManager class
\
// Author: Ivana Hrivnacova, 03/11/2014 (ivana@ipno.in2p3.fr)
#include "ExG4HbookP2DummyManager.hh"
#include "G4AnalysisManagerState.hh"
//_____________________________________________________________________________
ExG4HbookP2DummyManager::ExG4HbookP2DummyManager(
const G4AnalysisManagerState& state)
: G4VP2Manager(),
G4THnManager<G4int>(state, "H3"),
fWarn(true)
{
}
//_____________________________________________________________________________
ExG4HbookP2DummyManager::~ExG4HbookP2DummyManager()
{
}
//
// private methods
//
//_____________________________________________________________________________
void ExG4HbookP2DummyManager::ExceptionForProfiles(
const G4String& functionName)
{
if ( ! fWarn ) return;
ExceptionForProfilesConst(functionName);
fWarn = false;
}
//_____________________________________________________________________________
void ExG4HbookP2DummyManager::ExceptionForProfilesConst(
const G4String& functionName) const
{
G4String inFunction = "G4";
inFunction += fState.GetType();
inFunction += "AnalysisManager::";
inFunction += functionName;
G4ExceptionDescription description;
description << " "
<< "Profiles are not supported." ;
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
}
//
// protected methods
//
//_____________________________________________________________________________
G4int ExG4HbookP2DummyManager::CreateP2(const G4String& /*name*/,
const G4String& /*title*/,
G4int /*nxbins*/,
G4double /*xmin*/, G4double /*xmax*/,
G4int /*nybins*/,
G4double /*ymin*/, G4double /*ymax*/,
G4double /*zmin*/, G4double /*zmax*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/,
const G4String& /*xbinScheme*/,
const G4String& /*ybinScheme*/)
{
ExceptionForProfiles("CreateP2");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookP2DummyManager::CreateP2(const G4String& /*name*/,
const G4String& /*title*/,
const std::vector<G4double>& /*xedges*/,
const std::vector<G4double>& /*yedges*/,
G4double /*zmin*/, G4double /*zmax*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/)
{
ExceptionForProfiles("CreateP2");
return 0;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::SetP2(G4int /*id*/,
G4int /*nxbins*/,
G4double /*xmin*/, G4double /*xmax*/,
G4int /*nybins*/,
G4double /*ymin*/, G4double /*ymax*/,
G4double /*zmin*/, G4double /*zmax*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/,
const G4String& /*xbinScheme*/,
const G4String& /*ybinScheme*/)
{
ExceptionForProfiles("SetP2");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::SetP2(G4int /*id*/,
const std::vector<G4double>& /*xedges*/,
const std::vector<G4double>& /*yedges*/,
G4double /*zmin*/, G4double /*zmax*/,
const G4String& /*xunitName*/,
const G4String& /*yunitName*/,
const G4String& /*zunitName*/,
const G4String& /*xfcnName*/,
const G4String& /*yfcnName*/,
const G4String& /*zfcnName*/)
{
ExceptionForProfiles("SetP2");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::ScaleP2(G4int /*id*/, G4double /*factor*/)
{
ExceptionForProfiles("ScaleP2");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::FillP2(G4int /*id*/,
G4double /*xvalue*/, G4double /*yvalue*/,
G4double /*zvalue*/,
G4double /*weight*/)
{
ExceptionForProfiles("FillP2");
return false;
}
//_____________________________________________________________________________
G4int ExG4HbookP2DummyManager::GetP2Id(const G4String& /*name*/, G4bool /*warn*/) const
{
ExceptionForProfilesConst("GetP2Id");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookP2DummyManager::GetP2Nxbins(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Nxbins");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2Xmin(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Xmin");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2Xmax(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Xmax");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2XWidth(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2XWidth");
return 0;
}
//_____________________________________________________________________________
G4int ExG4HbookP2DummyManager::GetP2Nybins(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Nybins");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2Ymin(G4int /*id*/) const
{
ExceptionForProfilesConst("");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2Ymax(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Ymax");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2YWidth(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2YWidth");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2Zmin(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Zmin");
return 0;
}
//_____________________________________________________________________________
G4double ExG4HbookP2DummyManager::GetP2Zmax(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Zmax");
return 0;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::SetP2Title(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForProfiles("SetP2Title");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::SetP2XAxisTitle(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForProfiles("SetP2XAxisTitle");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::SetP2YAxisTitle(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForProfiles("SetP2YAxisTitle");
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::SetP2ZAxisTitle(G4int /*id*/, const G4String& /*title*/)
{
ExceptionForProfiles("SetP2ZAxisTitle");
return false;
}
//_____________________________________________________________________________
G4String ExG4HbookP2DummyManager::GetP2Title(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2Title");
return "";
}
//_____________________________________________________________________________
G4String ExG4HbookP2DummyManager::GetP2XAxisTitle(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2XAxisTitle");
return "";
}
//_____________________________________________________________________________
G4String ExG4HbookP2DummyManager::GetP2YAxisTitle(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2YAxisTitle");
return "";
}
//_____________________________________________________________________________
G4String ExG4HbookP2DummyManager::GetP2ZAxisTitle(G4int /*id*/) const
{
ExceptionForProfilesConst("GetP2ZAxisTitle");
return "";
}
//_____________________________________________________________________________
G4bool ExG4HbookP2DummyManager::WriteOnAscii(std::ofstream& /*output*/)
{
ExceptionForProfiles("WriteOnAscii");
return false;
}
@@ -1,31 +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. *
* ********************************************************************
*
SUBROUTINE OCLOSE(IUNIT)
IMPLICIT NONE
INTEGER IUNIT
CLOSE(IUNIT)
RETURN
END
@@ -1,34 +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. *
* ********************************************************************
*
INTEGER*4 FUNCTION SETNTUC()
INTEGER NNTUC
PARAMETER (NNTUC = 200)
INTEGER*4 NVAR,P
COMMON /NTUC/ NVAR,P(NNTUC)
NVAR = 0
SETNTUC = NNTUC
RETURN
END
@@ -1,35 +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. *
* ********************************************************************
*
INTEGER*4 FUNCTION SETPAWC()
INTEGER NPAWC
PARAMETER (NPAWC = 1000000)
INTEGER P
COMMON /PAWC/ P(NPAWC)
INTEGER IQUEST
COMMON/QUEST/IQUEST(100)
SETPAWC = NPAWC
RETURN
END
@@ -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,15 +0,0 @@
macro plotHisto.kumac
*
h/file 1 anaex01.hbook
*
h/list
*
opt stat
h/pl 1
h/pl 2
*
opt logy
opt grid
h/pl 3
*
return
@@ -1,74 +0,0 @@
//$Id$
///\file "analysis/AnaEx03/.README.AIDA"
///\brief Example AnaEx03 README.AIDA page
/*! \page ExampleAnaEx03AIDA Example AnaEx03 - Install AIDA
To use histograms, at least one of the AIDA implementations should be
available.
You can use various file formats to write histograms (hbook, root, AIDA-XML).
\section ExampleAnaEx03AIDA_s1 OpenScientist (lal/in2p3)
OpenScientist is available at http://OpenScientist.lal.in2p3.fr.
osc_batch is a small package ( ~ 6MB), easy to install.
It provides an AIDA interface to write files in ROOT or HBOOK formats.
See the specific \link ExampleAnaEx03OpenScientist README.OpenScientist \endlink
page for more.
\section ExampleAnaEx03AIDA_s2 RAIDA (desy)
It is a ROOT based AIDA interface. It can be downloaded from
http://ilcsoft.desy.de/portal/software_packages/raida/index_eng.html
\section ExampleAnaEx03AIDA_s3 iAIDA
Another package including AIDA (an evolution of the former cern PI project)
is the iAIDA package: http://iaida.dynalias.net
Once you have installed iAIDA in a specified local area $MYIAIDA, it is
required to add the installation path to $PATH, i.e. for example, for
release 1.0.11 of iAIDA:
\verbatim
setenv PATH ${PATH}:$MYIAIDA/bin
\endverbatim
Before running the example the command should be issued:
\verbatim
eval `aida-config --runtime csh`
\endverbatim
\section ExampleAnaEx03AIDA_s4 JAIDA (slac)
JAIDA is an implementation of AIDA in Java. To use it, one needs Java
as well as AIDAJNI, a connector between AIDA-C++ and AIDA-Java.
Available for: Linux-g++2, Linux-g++3, WIN32-VC, SUN-CC,
Darwin-g++2, Darwin-g++3
To compile and link with JAIDA using AIDAJNI, make sure you have:
-# JAIDA: see http://java.freehep.org/jaida
-# set enviroment variable JAIDA_HOME to your JAIDA installation
-# source the aida-setup script $JAIDA_HOME/bin/aida-setup.[sh|csh|win32] \n\n
-# AIDAJNI: see http://java.freehep.org/aidajni
-# set environment variable AIDAJNI_HOME to your AIDAJNI installation
-# set environment variable JDK_HOME to your Java Standard Development Kit (1.4.x or up).
-# source the aidajni-setup script $AIDAJNI_HOME/bin/$G4SYSTEM/aidajni-setup.[sh|csh|win32]
Last tested versions (with Geant4 examples): JAIDA 3.2.0, AIDAJNI 3.2.0.
Now execute:
\verbatim
source setup-analysis (.csh, .sh, .win32)
gmake clean
gmake
\endverbatim
*/
@@ -1,56 +0,0 @@
//$Id$
///\file "analysis/AnaEx03/.README.OpenScientist"
///\brief Example AnaEx03 README.OpenScientist page
/*! \page ExampleAnaEx03OpenScientist Example AnaEx03 - Working with the OpenScientist packages
To create the analysis file, you can install the light "osc_batch"
binary kit (See http://OpenScientist.lal.in2p3.fr ). For example
from a UNIX sh flavoured shell :
\verbatim
sh> cd /usr/local
sh> <arrange to be su>
sh> <get an osc_batch binary kit>
sh> unzip -q osc_batch<platform>.zip
sh> cd osc_batch/<version>
sh> ./install
\endverbatim
Then before building the example you have to source the OpenScientist
environment with :
\verbatim
<create another terminal>
sh> . /usr/local/osc_batch/<version>/aida-setup.sh
or
csh> source /usr/local/osc_batch/<version>/aida-setup.csh
\endverbatim
Depending of the file format, you can visualize the produced
file with various interactive tools (CERN/PAW, CERN/ROOT, jas).
But if installing also an OpenScientist osc_vis binary kit,
you shall be able to visualize all formats by using
the osc-plot program. To install an osc_vis kit :
\verbatim
sh> cd /usr/local
sh> <arrange to be su>
sh> <get an osc_vis binary kit>
sh> unzip -q osc_vis<platform>.zip
sh> cd osc_vis/<version>
sh> ./install
\endverbatim
Then to browse the AnaEx03.<format> file (for exa from an UNIX sh shell) :
\verbatim
<create another terminal>
sh> . /usr/local/osc_vis/<version>/setup.sh
sh> <setenv DISPLAY if needed>
sh> osc-plot AnaEx03.[aida,root,hbook]
\endverbatim
The OpenScientist URL is :
- http://OpenScientist.lal.in2p3.fr.
Note that OpenScientist is installed on CERN/lxplus under :
- /afs/cern.ch/sw/contrib/[osc_batch,osc_vis].
*/