Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -1,110 +1,32 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# CMakeLists.txt
|
||||
# Module : G4analysis
|
||||
# Module : G4geometry
|
||||
# Package: Geant4.src.G4analysis
|
||||
#
|
||||
# CMakeLists.txt for G4analysis. We do not use the usual Geant4 sources.cmake
|
||||
# approach because G4analysis requires a custom install solution for its
|
||||
# headers. The 'tools' subdirectory contains many headers that are needed and
|
||||
# these are in a nested structure which needs to be replicated when we
|
||||
# install, i.e:
|
||||
# <INCLUDE>
|
||||
# +- geant4
|
||||
# +- tools
|
||||
# +- histo
|
||||
# | +- h1d
|
||||
# ...
|
||||
# Top level CMakeLists.txt for a Geant4 Global Library
|
||||
# or collection of sublibraries
|
||||
#
|
||||
# Nevertheless, we're able to build the library via the standard
|
||||
# GEANT4_LIBRARY_TARGET macro.
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# Created on: 28/07/2011
|
||||
#
|
||||
# $Date$
|
||||
# $Revision$
|
||||
# $Author$
|
||||
# $Id: CMakeLists.txt 72312 2013-07-15 16:01:02Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Includes for this modules
|
||||
#
|
||||
include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
include_directories(include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
|
||||
add_subdirectory(csv)
|
||||
add_subdirectory(hntools)
|
||||
add_subdirectory(management)
|
||||
add_subdirectory(root)
|
||||
add_subdirectory(xml)
|
||||
add_subdirectory(g4tools)
|
||||
|
||||
# List the headers and sources
|
||||
#
|
||||
# - Headers
|
||||
# Need to add tools, but since these don't use a standard naming scheme,
|
||||
# will need to work out how to either locate them, or generate a list.
|
||||
# This isn't critical for building the analysis library.
|
||||
set(G4analysis_HEADERS
|
||||
include/G4AnalysisMessenger.hh
|
||||
include/G4AnalysisVerbose.hh
|
||||
include/G4CsvAnalysisManager.hh
|
||||
include/g4csv_defs.hh
|
||||
include/g4csv.hh
|
||||
include/G4Fcn.hh
|
||||
include/G4HnInformation.hh
|
||||
include/G4RootAnalysisManager.hh
|
||||
include/g4root_defs.hh
|
||||
include/g4root.hh
|
||||
include/G4VAnalysisManager.hh
|
||||
include/G4XmlAnalysisManager.hh
|
||||
include/g4xml_defs.hh
|
||||
include/g4xml.hh
|
||||
if(NOT GEANT4_BUILD_GRANULAR_LIBS)
|
||||
include(Geant4MacroLibraryTargets)
|
||||
GEANT4_GLOBAL_LIBRARY_TARGET(NAME G4analysis
|
||||
COMPONENTS
|
||||
csv/sources.cmake
|
||||
hntools/sources.cmake
|
||||
management/sources.cmake
|
||||
root/sources.cmake
|
||||
xml/sources.cmake
|
||||
)
|
||||
|
||||
# - Sources
|
||||
set(G4analysis_SOURCES
|
||||
src/G4AnalysisMessenger.cc
|
||||
src/G4AnalysisVerbose.cc
|
||||
src/G4CsvAnalysisManager.cc
|
||||
src/G4RootAnalysisManager.cc
|
||||
src/G4VAnalysisManager.cc
|
||||
src/G4XmlAnalysisManager.cc
|
||||
)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Now add the library targets
|
||||
#
|
||||
include(Geant4MacroLibraryTargets)
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
GEANT4_LIBRARY_TARGET(NAME G4analysis
|
||||
SOURCES ${G4analysis_SOURCES} ${G4analysis_HEADERS}
|
||||
GEANT4_LINK_LIBRARIES G4globman G4intercoms
|
||||
)
|
||||
else()
|
||||
GEANT4_LIBRARY_TARGET(NAME G4analysis
|
||||
SOURCES ${G4analysis_SOURCES} ${G4analysis_HEADERS}
|
||||
GEANT4_LINK_LIBRARIES G4global G4intercoms
|
||||
)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Ensure the header directory gets added to the list of ones to export
|
||||
#
|
||||
set_property(GLOBAL APPEND PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the headers, retaining their nested structure
|
||||
#
|
||||
install(DIRECTORY include/
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development
|
||||
PATTERN ".svn" EXCLUDE
|
||||
)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# We also need to install the tools license
|
||||
#
|
||||
install(FILES tools.license
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}
|
||||
)
|
||||
|
||||
|
||||
+11
-10
@@ -1,4 +1,4 @@
|
||||
# $Id: GNUmakefile,v 1.4 2010-11-08 10:38:44 maire Exp $
|
||||
# $Id: GNUmakefile 72312 2013-07-15 16:01:02Z gcosmo $
|
||||
# --------------------------------------------------------------
|
||||
#
|
||||
|
||||
@@ -8,17 +8,18 @@ ifndef G4INSTALL
|
||||
G4INSTALL = ../..
|
||||
endif
|
||||
|
||||
GLOBLIBS = libG4global.lib
|
||||
GLOBLIBS = libG4intercoms.lib libG4global.lib
|
||||
ifdef G4LIB_BUILD_ZLIB
|
||||
GLOBLIBS += libG4zlib.lib
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/intercoms/include \
|
||||
-I$(G4BASE)/analysis/include
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
SUBDIRS = management hntools csv root xml
|
||||
SUBLIBS = G4analysismng G4hntools G4csv G4root G4xml
|
||||
|
||||
.PHONY: global
|
||||
|
||||
global: lib
|
||||
include $(G4INSTALL)/config/globlib.gmk
|
||||
|
||||
includes::
|
||||
@for dir in $(SUBDIRS); do (cd $$dir && $(MAKE) $@ ); done
|
||||
cd g4tools; make includes
|
||||
|
||||
+133
-1
@@ -1,4 +1,4 @@
|
||||
$Id:$
|
||||
$Id: History 74257 2013-10-02 14:24:55Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,138 @@ committal in the SVN repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
October 02, 2013 I. Hrivnacova (analysis-V09-06-25)
|
||||
- Do not call WriteH1[2]() when no histograms are defined.
|
||||
This allows to run application which uses only ntuples without
|
||||
a master instance of analysis manager.
|
||||
|
||||
September 30, 2013 I. Hrivnacova (analysis-V09-06-24)
|
||||
- Removed static G4AnalysisManager::Create(G4bool isMaster) function
|
||||
(the master/worker is now identified automatically)
|
||||
- Removed instances counter and its mutex
|
||||
- Reimplemented G4AnalysisManagerState::IsMT() with use of
|
||||
G4Threading functions
|
||||
- Removed virtual declaration for GetH1, GetH2, GetNtuple functions
|
||||
in manager classes (to follow NVI pattern)
|
||||
- Fixed installing of g4analysis_defs.hh header
|
||||
- Fixed g4csv.hh (it was overwritten by mistake with g4csv_defs.hh)
|
||||
- Fixed g4csv_defs.hh (G4Ntuple is the ntuple type, and not a pointer)
|
||||
|
||||
September 17, 2013 I. Hrivnacova (analysis-V09-06-23)
|
||||
- Use thread Id (now available) in generating file names instead
|
||||
of thread Pid.
|
||||
|
||||
September 02, 2013 I. Hrivnacova (analysis-V09-06-22)
|
||||
- Updated to g4tools 1.7.0 (by G. Barrand):
|
||||
Fixed problem report #1523 (incorrect setting the list of free blocks
|
||||
in the ROOT file).
|
||||
See History_tools for complete list of modifications.
|
||||
|
||||
September 02, 2013 I. Hrivnacova (analysis-V09-06-21)
|
||||
- Fixed saving binScheme in H2 information
|
||||
|
||||
August 26, 2013 I. Hrivnacova (analysis-V09-06-20)
|
||||
- Fixed Coverity defects
|
||||
(missing copy constructor and assignment operator in G4VH1Manager
|
||||
and G4VH2Manager)
|
||||
|
||||
August 26, 2013 A.Dotti (analysis-V09-06-19)
|
||||
- New interface for functions in G4Threading.hh,
|
||||
now in G4Threading namespace
|
||||
And also (I. Hrivnacova):
|
||||
- Added a possibility to define logarithmic binning for H1 and H2
|
||||
- Reorganized messenger classes per objects: they are now associated
|
||||
with the public interface (G4VAnalysisManager)
|
||||
- Fixed path to g4tools in test/build
|
||||
|
||||
August 1, 2013 I.Hrivnacova (analysis-V09-06-18)
|
||||
- Fixed CMake build (added missing *.icc files in HEADERS);
|
||||
thanks to Mike Kelsey for pointing at this.
|
||||
|
||||
July 15, 2013 I.Hrivnacova (analysis-V09-06-17)
|
||||
- Added set_property(...GEANT4_BUILDTREE_INCLUDE_DIRS) in
|
||||
g4tools/CMakeLists.txt
|
||||
|
||||
July 15, 2013 I.Hrivnacova (analysis-V09-06-16)
|
||||
- Added GLOBAL_DEPENDENCIES lists in sources.cmake files
|
||||
|
||||
July 15, 2013 I.Hrivnacova (analysis-V09-06-15)
|
||||
- Fixed dependencies on zlib
|
||||
(previous tag failed on linking error on Mac)
|
||||
|
||||
July 15, 2013 I.Hrivnacova (analysis-V09-06-14)
|
||||
- Introduced subdirectories:
|
||||
csv, g4tools, hntools, management, root, xml
|
||||
and updated CMake & GNUmake files accordingly
|
||||
|
||||
July 12, 2013 I.Hrivnacova (analysis-V09-06-13)
|
||||
- Fixed warnings on clang:
|
||||
Use struct keyword instead of class for forward declaration of structs.
|
||||
|
||||
July 11, 2013 I.Hrivnacova (analysis-V09-06-12)
|
||||
- Refactoring manager classes:
|
||||
- Introduced managers per object types (H1, H2, Ntuple, File)
|
||||
and re-implemented G4VAnalysisManager as a composite of the objects
|
||||
managers
|
||||
- Removed enum G4VAnalysisManager::ObjectType and replaced related methods
|
||||
with methods per object type; eg.
|
||||
void SetActivation(ObjectType type, G4int id, G4bool activation);
|
||||
with
|
||||
void SetH1Activation(G4int id, G4bool activation);
|
||||
void SetH2Activation(G4int id, G4bool activation);
|
||||
|
||||
June 20, 2013 I.Hrivnacova (analysis-V09-06-11)
|
||||
- Fixed the problem in Root files clean-up (manifested in
|
||||
examples/advanced/microbeam):
|
||||
non-empty Root file was deleted when only ntuples and no histograms
|
||||
were booked and the application was built against MT Geant4 but run
|
||||
in sequential mode.
|
||||
|
||||
June 11, 2013 I.Hrivnacova (analysis-V09-06-10)
|
||||
- Fixed deleting fNtuple in G4RootNtupleDescription
|
||||
(the ntuple is deleted with root file)
|
||||
|
||||
June 03, 2013 I.Hrivnacova (analysis-V09-06-09)
|
||||
- Improved handling files: empty files are now removed in CloseFile()
|
||||
- Moved generation of file name in G4VAnalysisManager
|
||||
- Forced setting fIsMaster=true in sequential mode
|
||||
|
||||
May 31, 2013 I.Hrivnacova (analysis-V09-06-08)
|
||||
- Fix in G4RootAnalysisManager::WriteOnAscii() - bug report #1473
|
||||
|
||||
April 18, 2013 I.Hrivnacova (analysis-V09-06-07)
|
||||
- Manager classes updated for MT:
|
||||
Added fgMasterInstance, fIsMaster data members and functions for
|
||||
mergings histograms (Root, Xml) from worker tom master:
|
||||
void AddH1Vector(std::vector<tools::histo::h1d*>& h1Vector);
|
||||
void AddH2Vector(std::vector<tools::histo::h2d*>& h2Vector);
|
||||
These functions are automatically called on Worker::Write().
|
||||
Added ThreadId to ntuple file names when processing on workers.
|
||||
|
||||
April 10, 2013 I.Hrivnacova (analysis-V09-06-06)
|
||||
- Updated to g4tools 1.6.0 (by G. Barrand) - see History_tools
|
||||
|
||||
March 29, 2013 I.Hrivnacova (analysis-V09-06-05)
|
||||
- Extended analysis managers for handling more than one ntuple
|
||||
|
||||
March 26, 2013 B.Morgan (analysis-V09-06-04)
|
||||
- source.cmake : Corrected zlib setup for transparent use of
|
||||
internal or external variants.
|
||||
|
||||
March 22, 2013 G.Cosmo (analysis-V09-06-03)
|
||||
- Corrected GNUmakefile and CMakeLists.txt for zlib dependency.
|
||||
|
||||
March 21, 2013 I.Hrivnacova (analysis-V09-06-02)
|
||||
- Updated CMakeList.txt for zlib dependencies
|
||||
|
||||
March 21, 2013 I.Hrivnacova (analysis-V09-06-01)
|
||||
- Updated to g4tools 1.5.0 (by G. Barrand) - see History_tools
|
||||
- Adding file compression in Root manager (now available)
|
||||
- Adding use of zlib in GNUmakefile (needed for compression)
|
||||
|
||||
December 17, 2012 I.Hrivnacova (analysis-V09-06-00)
|
||||
- Added 'svn:keywords' property to all files (except for tools)
|
||||
|
||||
October 26, 2012 I.Hrivnacova (analysis-V09-05-15)
|
||||
- Updated to g4tools 1.4.3 (by G. Barrand) - see History_tools;
|
||||
includes bug correction for histo/h3::fill
|
||||
|
||||
@@ -1,3 +1,48 @@
|
||||
1.7.0 :
|
||||
- test/cpp/list_free_segs.C : to list free segments in a out.root file.
|
||||
- wroot/file : set_END() : update first back free segment m_first field
|
||||
when writing something. This permits to have good free segs infos in file.
|
||||
- wroot/file/make_free_seg : use free_seg/add_free() function.
|
||||
- wroot/free_seg : add_free function.
|
||||
- histo/c[1,2,3] : operator= : protect against same object.
|
||||
- wroot/named/ObjArray : operator= : protect against same object.
|
||||
- wroot/ntuple/column : operator= : protect against same object.
|
||||
- sto/to() : have a default value.
|
||||
- pointer/p2s : void* -> const void*.
|
||||
- args/find() : have a default value.
|
||||
|
||||
1.6.0 :
|
||||
- test/cpp/wroot.cpp : add an empty tree to check the below modification.
|
||||
- wroot/basket/stream : remove the if(!m_data.length()) test that
|
||||
refrains to write an empty tree.
|
||||
- wroot/store : put in this directory the code that permits to stream
|
||||
histos with all their internal infos.
|
||||
- args, path, hbook/hdummy.c : changes coming from the inlib/exlib
|
||||
context but not used within g4tools.
|
||||
|
||||
1.5.0 :
|
||||
- build_f77 : modifications to build from CYGWIN with DF98 fortran.
|
||||
- wroot : osc_streamers, iobj_const_visitor, to, buffer, member_writer :
|
||||
modifications in order to be able to stream histos as in
|
||||
OpenScientist/BatchLab and then with all the internal infos.
|
||||
We remember that the ROOT/TH streaming does not handle the number
|
||||
of entries per bin (but only the weight per bin) and not the annotations.
|
||||
- tools/gzip_buffer, test/cpp/wroot.cpp : show how to use compression
|
||||
with zlib.
|
||||
- histo/base_histo : in a for, change an unsigned to "unsigned int".
|
||||
- histo/c[1,2,3]d : inlib::mn,mx<> changed to mn,mx<>.
|
||||
- wroot/wbuf : have a public : set_byte_swap() method (then
|
||||
the wbuf byte swapping can be changed out of the constructor).
|
||||
- safe_cast, hbook/wntuple : rename the global cast() functions
|
||||
to safe_cast(). It permits to trace them more easily.
|
||||
- strip : have a "return bool" returning true if some stripping had been done.
|
||||
- test/cpp/use_cc, use_cpp, build : [cc,cpp]_linker : variables to
|
||||
explicitely link with cc or cpp.
|
||||
- test/cpp/use_cernlib : Windows : try to handle a build from cygwin.
|
||||
- vmanip, mem, platform, mem : slight changes coming from the inlib/exlib
|
||||
context but not used within g4tools.
|
||||
- license file : correct some typos (` to ').
|
||||
|
||||
1.4.3 :
|
||||
- histo/b3,h3d : have a print() method. (Few things in it for the moment...)
|
||||
- histo/sliced : for h3 : projection_[xy,yz,xz] methods.
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# CMakeLists.txt
|
||||
# Module : G4analysis
|
||||
# Package: Geant4.src.G4analysis.G4csv
|
||||
#
|
||||
# CMakeLists.txt for building a single granular library.
|
||||
#
|
||||
# Created on : 15/07/2013
|
||||
#
|
||||
# $Id: CMakeLists.txt 72292 2013-07-15 12:01:43Z ihrivnac $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
include(Geant4MacroLibraryTargets)
|
||||
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# $Id: GNUmakefile 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
# --------------------------------------------------------------------
|
||||
# GNUmakefile for geometry/biasing library. Gabriele Cosmo, 25/03/02.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
name := G4csv
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/intercoms/include \
|
||||
-I$(G4BASE)/analysis/g4tools/include \
|
||||
-I$(G4BASE)/analysis/management/include \
|
||||
-I$(G4BASE)/analysis/hntools/include
|
||||
|
||||
ifdef G4LIB_BUILD_ZLIB
|
||||
CPPFLAGS += -I$(G4BASE)/externals/zlib/include
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4CsvAnalysisManager.hh 74257 2013-10-02 14:24:55Z gcosmo $
|
||||
|
||||
// The main manager for Csv analysis.
|
||||
// It delegates most of functions to the object specific managers.
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4CsvAnalysisManager_h
|
||||
#define G4CsvAnalysisManager_h 1
|
||||
|
||||
|
||||
#include "G4VAnalysisManager.hh"
|
||||
#include "G4CsvNtupleDescription.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/wcsv_ntuple"
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class G4H1DummyManager;
|
||||
class G4H2DummyManager;
|
||||
class G4CsvFileManager;
|
||||
class G4CsvNtupleManager;
|
||||
|
||||
class G4CsvAnalysisManager : public G4VAnalysisManager
|
||||
{
|
||||
public:
|
||||
G4CsvAnalysisManager(G4bool isMaster = true);
|
||||
~G4CsvAnalysisManager();
|
||||
|
||||
// static methods
|
||||
static G4CsvAnalysisManager* Instance();
|
||||
|
||||
// Access methods
|
||||
tools::wcsv::ntuple* GetNtuple() const;
|
||||
tools::wcsv::ntuple* GetNtuple(G4int ntupleId) const;
|
||||
|
||||
protected:
|
||||
// virtual methods from base class
|
||||
virtual G4bool OpenFileImpl(const G4String& fileName);
|
||||
virtual G4bool WriteImpl();
|
||||
virtual G4bool CloseFileImpl();
|
||||
|
||||
private:
|
||||
// static data members
|
||||
//
|
||||
static G4CsvAnalysisManager* fgMasterInstance;
|
||||
static G4ThreadLocal G4CsvAnalysisManager* fgInstance;
|
||||
|
||||
// methods
|
||||
//
|
||||
G4bool CloseNtupleFiles();
|
||||
|
||||
// data members
|
||||
//
|
||||
G4H1DummyManager* fH1Manager;
|
||||
G4H2DummyManager* fH2Manager;
|
||||
G4CsvNtupleManager* fNtupleManager;
|
||||
G4CsvFileManager* fFileManager;
|
||||
};
|
||||
|
||||
#include "G4CsvAnalysisManager.icc"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4CsvAnalysisManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
#include "G4CsvNtupleManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::wcsv::ntuple* G4CsvAnalysisManager::GetNtuple() const
|
||||
{
|
||||
return fNtupleManager->GetNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::wcsv::ntuple* G4CsvAnalysisManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
return fNtupleManager->GetNtuple(ntupleId);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4CsvFileManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
// The manager for Csv file operations.
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4CsvFileManager_h
|
||||
#define G4CsvFileManager_h 1
|
||||
|
||||
|
||||
#include "G4VFileManager.hh"
|
||||
#include "G4CsvNtupleDescription.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
class G4CsvFileManager : public G4VFileManager
|
||||
{
|
||||
public:
|
||||
G4CsvFileManager(const G4AnalysisManagerState& state);
|
||||
~G4CsvFileManager();
|
||||
|
||||
// Methods to manipulate files
|
||||
virtual G4bool OpenFile(const G4String& fileName);
|
||||
virtual G4bool WriteFile();
|
||||
virtual G4bool CloseFile();
|
||||
|
||||
G4bool CreateNtupleFile(G4CsvNtupleDescription* ntupleDescription);
|
||||
G4bool CloseNtupleFile(G4CsvNtupleDescription* ntupleDescription);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
|
||||
// Structure containing the information related to Csv ntuple
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 04/07/2012 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4CsvNtupleDescription_h
|
||||
#define G4CsvNtupleDescription_h 1
|
||||
|
||||
#include "tools/wcsv_ntuple"
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
namespace tools {
|
||||
class ntuple_booking;
|
||||
}
|
||||
|
||||
struct G4CsvNtupleDescription
|
||||
{
|
||||
G4CsvNtupleDescription()
|
||||
: fFile(0),
|
||||
fNtuple(0),
|
||||
fNtupleBooking(0),
|
||||
fNtupleIColumnMap(),
|
||||
fNtupleFColumnMap(),
|
||||
fNtupleDColumnMap() {}
|
||||
|
||||
~G4CsvNtupleDescription()
|
||||
{ delete fFile;
|
||||
delete fNtuple;
|
||||
delete fNtupleBooking;
|
||||
}
|
||||
|
||||
std::ofstream* fFile;
|
||||
tools::wcsv::ntuple* fNtuple;
|
||||
tools::ntuple_booking* fNtupleBooking;
|
||||
std::map<G4int, tools::wcsv::ntuple::column<int>* > fNtupleIColumnMap;
|
||||
std::map<G4int, tools::wcsv::ntuple::column<float>* > fNtupleFColumnMap;
|
||||
std::map<G4int, tools::wcsv::ntuple::column<double>* > fNtupleDColumnMap;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4CsvNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
// Manager class for CSV ntuples.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4CsvNtupleManager_h
|
||||
#define G4CsvNtupleManager_h 1
|
||||
|
||||
|
||||
#include "G4VNtupleManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/wcsv_ntuple"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class G4CsvFileManager;
|
||||
struct G4CsvNtupleDescription;
|
||||
|
||||
class G4CsvNtupleManager : public G4VNtupleManager
|
||||
{
|
||||
friend class G4CsvAnalysisManager;
|
||||
|
||||
protected:
|
||||
G4CsvNtupleManager(const G4AnalysisManagerState& state);
|
||||
~G4CsvNtupleManager();
|
||||
|
||||
// Functions specific to the output type
|
||||
//
|
||||
|
||||
// Methods to manipulate ntuples
|
||||
void CreateNtuplesFromBooking();
|
||||
G4bool IsEmpty() const;
|
||||
G4bool Reset();
|
||||
|
||||
// Set methods
|
||||
void SetFileManager(G4CsvFileManager* fileManager);
|
||||
|
||||
// Access methods
|
||||
tools::wcsv::ntuple* GetNtuple() const;
|
||||
tools::wcsv::ntuple* GetNtuple(G4int ntupleId) const;
|
||||
|
||||
// Access to ntuple vector (needed for Write())
|
||||
const std::vector<G4CsvNtupleDescription*>& GetNtupleVector() const;
|
||||
|
||||
// Functions independent from the output type
|
||||
//
|
||||
|
||||
// Methods to create ntuples
|
||||
virtual G4int CreateNtuple(const G4String& name, const G4String& title);
|
||||
// Create columns in the last created ntuple
|
||||
virtual G4int CreateNtupleIColumn(const G4String& name);
|
||||
virtual G4int CreateNtupleFColumn(const G4String& name);
|
||||
virtual G4int CreateNtupleDColumn(const G4String& name);
|
||||
virtual void FinishNtuple();
|
||||
// Create columns in the ntuple with given id
|
||||
virtual G4int CreateNtupleIColumn(G4int ntupleId, const G4String& name);
|
||||
virtual G4int CreateNtupleFColumn(G4int ntupleId, const G4String& name);
|
||||
virtual G4int CreateNtupleDColumn(G4int ntupleId, const G4String& name);
|
||||
virtual void FinishNtuple(G4int ntupleId);
|
||||
|
||||
// Methods to fill ntuples
|
||||
// Methods for ntuple with id = FirstNtupleId
|
||||
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
|
||||
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
|
||||
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
|
||||
virtual G4bool AddNtupleRow();
|
||||
// Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
|
||||
virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value);
|
||||
virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value);
|
||||
virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value);
|
||||
virtual G4bool AddNtupleRow(G4int ntupleId);
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetNofNtuples() const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
//
|
||||
tools::wcsv::ntuple::column<int>*
|
||||
GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
|
||||
tools::wcsv::ntuple::column<float>*
|
||||
GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
|
||||
tools::wcsv::ntuple::column<double>*
|
||||
GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
|
||||
|
||||
virtual G4CsvNtupleDescription* GetNtupleInFunction(G4int id,
|
||||
G4String function,
|
||||
G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
|
||||
// data members
|
||||
//
|
||||
G4CsvFileManager* fFileManager;
|
||||
std::vector<G4CsvNtupleDescription*> fNtupleVector;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline void G4CsvNtupleManager::SetFileManager(G4CsvFileManager* fileManager)
|
||||
{ fFileManager = fileManager; }
|
||||
|
||||
inline G4int G4CsvNtupleManager::GetNofNtuples() const
|
||||
{ return fNtupleVector.size(); }
|
||||
|
||||
inline const std::vector<G4CsvNtupleDescription*>& G4CsvNtupleManager::GetNtupleVector() const
|
||||
{ return fNtupleVector; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: g4csv.hh 74257 2013-10-02 14:24:55Z gcosmo $
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
|
||||
|
||||
@@ -35,5 +35,3 @@
|
||||
using namespace G4Csv;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
// $Id: g4csv_defs.hh 74257 2013-10-02 14:24:55Z gcosmo $
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace G4Csv {
|
||||
|
||||
typedef tools::wcsv::ntuple* G4Ntuple;
|
||||
typedef tools::wcsv::ntuple G4Ntuple;
|
||||
typedef G4CsvAnalysisManager G4AnalysisManager;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# sources.cmake
|
||||
# Module : G4csv
|
||||
# Package: Geant4.src.G4analysis.G4csv
|
||||
#
|
||||
# Sources description for a library.
|
||||
# Lists the sources and headers of the code explicitely.
|
||||
# Lists include paths needed.
|
||||
# Lists the internal granular and global dependencies of the library.
|
||||
# Source specific properties should be added at the end.
|
||||
#
|
||||
# Generated on : 15/07/2013
|
||||
#
|
||||
# $Id: sources.cmake 72956 2013-08-14 14:24:35Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# List external includes needed.
|
||||
include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
|
||||
# List internal includes needed.
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/analysis/g4tools/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/analysis/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/analysis/hntools/include)
|
||||
|
||||
#
|
||||
# Define the Geant4 Module.
|
||||
#
|
||||
include(Geant4MacroDefineModule)
|
||||
GEANT4_DEFINE_MODULE(NAME G4csv
|
||||
HEADERS
|
||||
G4CsvAnalysisManager.hh
|
||||
G4CsvAnalysisManager.icc
|
||||
G4CsvFileManager.hh
|
||||
G4CsvNtupleDescription.hh
|
||||
G4CsvNtupleManager.hh
|
||||
g4csv_defs.hh
|
||||
g4csv.hh
|
||||
SOURCES
|
||||
G4CsvAnalysisManager.cc
|
||||
G4CsvFileManager.cc
|
||||
G4CsvNtupleManager.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4globman
|
||||
G4intercoms
|
||||
G4analysismng
|
||||
G4hntools
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4global
|
||||
G4intercoms
|
||||
LINK_LIBRARIES
|
||||
)
|
||||
|
||||
# List any source specific properties here
|
||||
@@ -0,0 +1,192 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4CsvAnalysisManager.cc 74257 2013-10-02 14:24:55Z gcosmo $
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4CsvAnalysisManager.hh"
|
||||
#include "G4CsvFileManager.hh"
|
||||
#include "G4H1DummyManager.hh"
|
||||
#include "G4H2DummyManager.hh"
|
||||
#include "G4CsvNtupleManager.hh"
|
||||
#include "G4AnalysisVerbose.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
G4CsvAnalysisManager* G4CsvAnalysisManager::fgMasterInstance = 0;
|
||||
G4ThreadLocal G4CsvAnalysisManager* G4CsvAnalysisManager::fgInstance = 0;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvAnalysisManager* G4CsvAnalysisManager::Instance()
|
||||
{
|
||||
if ( fgInstance == 0 ) {
|
||||
G4bool isMaster = ! G4Threading::IsWorkerThread();
|
||||
fgInstance = new G4CsvAnalysisManager(isMaster);
|
||||
}
|
||||
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvAnalysisManager::G4CsvAnalysisManager(G4bool isMaster)
|
||||
: G4VAnalysisManager("Csv", isMaster),
|
||||
fNtupleManager(0),
|
||||
fFileManager(0)
|
||||
{
|
||||
if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "G4CsvAnalysisManager already exists."
|
||||
<< "Cannot create another instance.";
|
||||
G4Exception("G4CsvAnalysisManager::G4CsvAnalysisManager()",
|
||||
"Analysis_F001", FatalException, description);
|
||||
}
|
||||
|
||||
if ( isMaster ) fgMasterInstance = this;
|
||||
fgInstance = this;
|
||||
|
||||
// Create managers
|
||||
fH1Manager = new G4H1DummyManager(fState);
|
||||
fH2Manager = new G4H2DummyManager(fState);
|
||||
fNtupleManager = new G4CsvNtupleManager(fState);
|
||||
fFileManager = new G4CsvFileManager(fState);
|
||||
fNtupleManager->SetFileManager(fFileManager);
|
||||
// The managers will be deleted by the base class
|
||||
|
||||
// Set managers to base class
|
||||
SetH1Manager(fH1Manager);
|
||||
SetH2Manager(fH2Manager);
|
||||
SetNtupleManager(fNtupleManager);
|
||||
SetFileManager(fFileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvAnalysisManager::~G4CsvAnalysisManager()
|
||||
{
|
||||
if ( fState.GetIsMaster() ) fgMasterInstance = 0;
|
||||
fgInstance = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvAnalysisManager::CloseNtupleFiles()
|
||||
{
|
||||
const std::vector<G4CsvNtupleDescription*>& ntupleVector
|
||||
= fNtupleManager->GetNtupleVector();
|
||||
|
||||
// Close ntuple files
|
||||
std::vector<G4CsvNtupleDescription*>::const_iterator it;
|
||||
for (it = ntupleVector.begin(); it != ntupleVector.end(); it++ ) {
|
||||
fFileManager->CloseNtupleFile((*it));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvAnalysisManager::OpenFileImpl(const G4String& fileName)
|
||||
{
|
||||
G4bool finalResult = true;
|
||||
|
||||
// Only book file name in file manager
|
||||
G4bool result = fFileManager->OpenFile(fileName);
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// Create ntuples if they are booked
|
||||
// (The files will be created with creating ntuples)
|
||||
fNtupleManager->CreateNtuplesFromBooking();
|
||||
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvAnalysisManager::WriteImpl()
|
||||
{
|
||||
// nothing to be done for Csv file
|
||||
G4bool result = true;
|
||||
|
||||
// Write ASCII if activated
|
||||
// Not available
|
||||
//if ( IsAscii() ) {
|
||||
// result = WriteAscii();
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvAnalysisManager::CloseFileImpl()
|
||||
{
|
||||
G4bool finalResult = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("close", "files", "");
|
||||
#endif
|
||||
|
||||
// Unlock file name only
|
||||
G4bool result = fFileManager->CloseFile();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// Close ntuple files
|
||||
if ( ( ! G4AnalysisManagerState::IsMT() ) || ( ! fState.GetIsMaster() ) ) {
|
||||
// In sequential mode or in MT mode only on workers
|
||||
result = CloseNtupleFiles();
|
||||
finalResult = finalResult && result;
|
||||
}
|
||||
|
||||
// reset data
|
||||
result = fNtupleManager->Reset();
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "Resetting data failed";
|
||||
G4Exception("G4CsvAnalysisManager::CloseFile()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
result = false;
|
||||
}
|
||||
finalResult = finalResult && result;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() ) {
|
||||
fState.GetVerboseL1()->Message("close", "files", "");
|
||||
}
|
||||
#endif
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4CsvFileManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4CsvFileManager.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvFileManager::G4CsvFileManager(const G4AnalysisManagerState& state)
|
||||
: G4VFileManager(state)
|
||||
{
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvFileManager::~G4CsvFileManager()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvFileManager::OpenFile(const G4String& fileName)
|
||||
{
|
||||
// Keep file name
|
||||
fFileName = fileName;
|
||||
|
||||
fLockFileName = true;
|
||||
fLockNtupleDirectoryName = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvFileManager::WriteFile()
|
||||
{
|
||||
// nothing to be done for Csv file
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvFileManager::CloseFile()
|
||||
{
|
||||
fLockFileName = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvFileManager::CreateNtupleFile(
|
||||
G4CsvNtupleDescription* ntupleDescription)
|
||||
{
|
||||
G4String ntupleName = ntupleDescription->fNtupleBooking->m_name;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()
|
||||
->Message("create", "file", GetNtupleFileName(ntupleName));
|
||||
#endif
|
||||
|
||||
std::ofstream* ntupleFile
|
||||
= new std::ofstream(GetNtupleFileName(ntupleName));
|
||||
if ( ntupleFile->fail() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "Cannot open file "
|
||||
<< GetNtupleFileName(ntupleName);
|
||||
G4Exception("G4CsvFileManager::CreateNtupleFile()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() )
|
||||
fState.GetVerboseL1()
|
||||
->Message("create", "file", GetNtupleFileName(ntupleName));
|
||||
#endif
|
||||
|
||||
ntupleDescription->fFile = ntupleFile;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvFileManager::CloseNtupleFile(
|
||||
G4CsvNtupleDescription* ntupleDescription)
|
||||
{
|
||||
G4String ntupleName = ntupleDescription->fNtupleBooking->m_name;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()
|
||||
->Message("close", "file", GetNtupleFileName(ntupleName));
|
||||
#endif
|
||||
|
||||
// close file
|
||||
ntupleDescription->fFile->close();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() )
|
||||
fState.GetVerboseL1()
|
||||
->Message("close", "file", GetNtupleFileName(ntupleName));
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,620 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4CsvNtupleManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4CsvNtupleManager.hh"
|
||||
#include "G4CsvNtupleDescription.hh"
|
||||
#include "G4CsvFileManager.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvNtupleManager::G4CsvNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4VNtupleManager(state),
|
||||
fFileManager(0),
|
||||
fNtupleVector()
|
||||
{
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvNtupleManager::~G4CsvNtupleManager()
|
||||
{
|
||||
std::vector<G4CsvNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wcsv::ntuple::column<int>*
|
||||
G4CsvNtupleManager::GetNtupleIColumn(G4int ntupleId, G4int columnId) const
|
||||
{
|
||||
G4CsvNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleIColumn");
|
||||
if ( ! ntupleDecription ) {
|
||||
// add exception
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::map<G4int, tools::wcsv::ntuple::column<int>* >& ntupleIColumnMap
|
||||
= ntupleDecription->fNtupleIColumnMap;
|
||||
std::map<G4int, tools::wcsv::ntuple::column<int>* >::const_iterator it
|
||||
= ntupleIColumnMap.find(columnId);
|
||||
if ( it == ntupleIColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< "column " << columnId << " does not exist.";
|
||||
G4Exception("G4CsvNtupleManager::GetNtupleIColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wcsv::ntuple::column<float>*
|
||||
G4CsvNtupleManager::GetNtupleFColumn(G4int ntupleId, G4int columnId) const
|
||||
{
|
||||
G4CsvNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleFColumn");
|
||||
if ( ! ntupleDecription ) {
|
||||
// add exception
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::map<G4int, tools::wcsv::ntuple::column<float>* >& ntupleFColumnMap
|
||||
= ntupleDecription->fNtupleFColumnMap;
|
||||
std::map<G4int, tools::wcsv::ntuple::column<float>* >::const_iterator it
|
||||
= ntupleFColumnMap.find(columnId);
|
||||
if ( it == ntupleFColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< "column " << columnId << " does not exist.";
|
||||
G4Exception("G4CsvNtupleManager::GetNtupleFColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wcsv::ntuple::column<double>*
|
||||
G4CsvNtupleManager::GetNtupleDColumn(G4int ntupleId, G4int columnId) const
|
||||
{
|
||||
G4CsvNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleDColumn");
|
||||
if ( ! ntupleDecription ) {
|
||||
// add exception
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::map<G4int, tools::wcsv::ntuple::column<double>* >& ntupleDColumnMap
|
||||
= ntupleDecription->fNtupleDColumnMap;
|
||||
std::map<G4int, tools::wcsv::ntuple::column<double>* >::const_iterator it
|
||||
= ntupleDColumnMap.find(columnId);
|
||||
if ( it == ntupleDColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< "column " << columnId << " does not exist.";
|
||||
G4Exception("G4CsvNtupleManager::GetNtupleDColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4CsvNtupleDescription* G4CsvNtupleManager::GetNtupleInFunction(G4int id,
|
||||
G4String functionName, G4bool warn,
|
||||
G4bool /*onlyIfActive*/) const
|
||||
{
|
||||
G4int index = id - fFirstId;
|
||||
if ( index < 0 || index >= G4int(fNtupleVector.size()) ) {
|
||||
if ( warn) {
|
||||
G4String inFunction = "G4CsvNtupleManager::";
|
||||
inFunction += functionName;
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_W007", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fNtupleVector[index];
|
||||
}
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4CsvNtupleManager::CreateNtuplesFromBooking()
|
||||
{
|
||||
// Create ntuple from ntuple_booking.
|
||||
|
||||
// Do not create ntuples on master thread
|
||||
if ( G4AnalysisManagerState::IsMT() && fState.GetIsMaster() ) return;
|
||||
|
||||
std::vector<G4CsvNtupleDescription*>::iterator itn;
|
||||
for (itn = fNtupleVector.begin(); itn != fNtupleVector.end(); itn++ ) {
|
||||
|
||||
tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
|
||||
if ( ! ntupleBooking ) continue;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()
|
||||
->Message("create from booking", "ntuple", ntupleBooking->m_name);
|
||||
#endif
|
||||
|
||||
// create a file for this ntuple
|
||||
if ( ! fFileManager->CreateNtupleFile((*itn)) ) continue;
|
||||
|
||||
// create ntuple
|
||||
(*itn)->fNtuple
|
||||
= new tools::wcsv::ntuple(*((*itn)->fFile), G4cerr, *ntupleBooking);
|
||||
|
||||
if ( ntupleBooking->m_columns.size() ) {
|
||||
// store ntuple columns in local maps
|
||||
const std::vector<tools::ntuple_booking::col_t>& columns
|
||||
= ntupleBooking->m_columns;
|
||||
std::vector<tools::ntuple_booking::col_t>::const_iterator it;
|
||||
G4int index = 0;
|
||||
for ( it = columns.begin(); it!=columns.end(); ++it) {
|
||||
if ( (*it).second == tools::_cid(int(0) ) ) {
|
||||
(*itn)->fNtupleIColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column<int>((*it).first);
|
||||
}
|
||||
else if ( (*it).second == tools::_cid(float(0) ) ) {
|
||||
(*itn)->fNtupleFColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column<float>((*it).first);
|
||||
}
|
||||
else if ( (*it).second== tools::_cid(double(0))) {
|
||||
(*itn)->fNtupleDColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column<double>((*it).first);
|
||||
}
|
||||
else {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Unsupported column type " << (*it).first;
|
||||
G4Exception("G4CsvNtupleManager::CreateNtupleFromBooking()",
|
||||
"Analysis_W004", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()
|
||||
->Message("create from booking", "ntuple", ntupleBooking->m_name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::IsEmpty() const
|
||||
{
|
||||
return ! fNtupleVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::Reset()
|
||||
{
|
||||
std::vector<G4CsvNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
|
||||
delete (*it)->fNtuple;
|
||||
(*it)->fNtuple = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wcsv::ntuple* G4CsvNtupleManager::GetNtuple() const
|
||||
{
|
||||
return GetNtuple(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wcsv::ntuple* G4CsvNtupleManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
G4CsvNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtuple");
|
||||
|
||||
return ntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4CsvNtupleManager::CreateNtuple(const G4String& name,
|
||||
const G4String& title)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "ntuple", name);
|
||||
#endif
|
||||
|
||||
// Create ntuple description
|
||||
G4int index = fNtupleVector.size();
|
||||
G4CsvNtupleDescription* ntupleDescription
|
||||
= new G4CsvNtupleDescription();
|
||||
fNtupleVector.push_back(ntupleDescription);
|
||||
|
||||
// Create ntuple booking
|
||||
ntupleDescription->fNtupleBooking = new tools::ntuple_booking();
|
||||
ntupleDescription->fNtupleBooking->m_name = name;
|
||||
ntupleDescription->fNtupleBooking->m_title = title;
|
||||
// ntuple booking object is deleted in destructor
|
||||
|
||||
// Create ntuple if the file is open (what means here that
|
||||
// a filename was already set)
|
||||
if ( fFileManager->GetFileName().size() ) {
|
||||
if ( fFileManager->CreateNtupleFile(ntupleDescription) ) {
|
||||
ntupleDescription->fNtuple
|
||||
= new tools::wcsv::ntuple(*(ntupleDescription->fFile));
|
||||
// ntuple object is deleted when closing a file
|
||||
}
|
||||
}
|
||||
|
||||
fLockFirstId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << index + fFirstId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4CsvNtupleManager::CreateNtupleIColumn(const G4String& name)
|
||||
{
|
||||
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
|
||||
return CreateNtupleIColumn(ntupleId, name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4CsvNtupleManager::CreateNtupleFColumn(const G4String& name)
|
||||
{
|
||||
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
|
||||
return CreateNtupleFColumn(ntupleId, name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4CsvNtupleManager::CreateNtupleDColumn(const G4String& name)
|
||||
{
|
||||
G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
|
||||
return CreateNtupleDColumn(ntupleId, name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4CsvNtupleManager::FinishNtuple()
|
||||
{
|
||||
// nothing to be done here
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4CsvNtupleManager::CreateNtupleIColumn(G4int ntupleId, const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4CsvNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleIColumn");
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4CsvNtupleManager::CreateNtupleIColumn()",
|
||||
"Analysis_W005", JustWarning, description);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->m_columns.size();
|
||||
ntupleBooking->add_column<int>(name);
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
tools::wcsv::ntuple::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 G4CsvNtupleManager::CreateNtupleFColumn(G4int ntupleId, const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4CsvNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleFColumn");
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4CsvNtupleManager::CreateNtupleFColumn()",
|
||||
"Analysis_W005", JustWarning, description);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->m_columns.size();
|
||||
ntupleBooking->add_column<float>(name);
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
tools::wcsv::ntuple::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 G4CsvNtupleManager::CreateNtupleDColumn(G4int ntupleId, const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4CsvNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4CsvNtupleManager::CreateNtupleDColumn()",
|
||||
"Analysis_W005", JustWarning, description);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->m_columns.size();
|
||||
ntupleBooking->add_column<double>(name);
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
tools::wcsv::ntuple::column<double>* column
|
||||
= ntupleDescription->fNtuple->create_column<double>(name);
|
||||
ntupleDescription->fNtupleDColumnMap[index] = column;
|
||||
}
|
||||
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4CsvNtupleManager::FinishNtuple(G4int /*ntupleId*/)
|
||||
{
|
||||
// nothing to be done here
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::FillNtupleIColumn(G4int columnId, G4int value)
|
||||
{
|
||||
return FillNtupleIColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::FillNtupleFColumn(G4int columnId, G4float value)
|
||||
{
|
||||
return FillNtupleFColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::FillNtupleDColumn(G4int columnId, G4double value)
|
||||
{
|
||||
return FillNtupleDColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::AddNtupleRow()
|
||||
{
|
||||
return AddNtupleRow(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::FillNtupleIColumn(G4int ntupleId, G4int columnId,
|
||||
G4int value)
|
||||
{
|
||||
tools::wcsv::ntuple::column<int>* column
|
||||
= GetNtupleIColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< "column " << columnId << " does not exist.";
|
||||
G4Exception("G4CsvNtupleManager::FillNtupleIColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("fill", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::FillNtupleFColumn(G4int ntupleId, G4int columnId,
|
||||
G4float value)
|
||||
{
|
||||
tools::wcsv::ntuple::column<float>* column
|
||||
= GetNtupleFColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< "column " << columnId << " does not exist.";
|
||||
G4Exception("G4CsvNtupleManager::FillNtupleFColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("fill", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::FillNtupleDColumn(G4int ntupleId, G4int columnId,
|
||||
G4double value)
|
||||
{
|
||||
tools::wcsv::ntuple::column<double>* column
|
||||
= GetNtupleDColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< "column " << columnId << " does not exist.";
|
||||
G4Exception("G4CsvNtupleManager::FillNtupleDColumn()",
|
||||
"Analysis_W009", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
column->fill(value);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " value " << value;
|
||||
fState.GetVerboseL4()->Message("fill", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4CsvNtupleManager::AddNtupleRow(G4int ntupleId)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("add", "ntuple row", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4CsvNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "AddNtupleRow");
|
||||
|
||||
if ( ! ntupleDescription || ! ntupleDescription->fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple does not exist. ";
|
||||
G4Exception("G4CsvNtupleManager::AddNtupleRow()",
|
||||
"Analysis_W008", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
ntupleDescription->fNtuple->add_row();
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("add", "ntuple row", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
$Id: exception_classification.txt 72312 2013-07-15 16:01:02Z gcosmo $
|
||||
|
||||
Analysis_F001: Fatal exception when trying to create a singleton manager twice
|
||||
|
||||
Analysis_W001: Cannot create directory for histograms or ntpuple
|
||||
@@ -28,3 +30,5 @@ Analysis_W013: Cannot apply histogram/ntuple attribute due to its
|
||||
wrong definition
|
||||
Analysis_W013: Wrong histogram/ntuple attribute value
|
||||
|
||||
Analysis_W014: Master manager not instatiated,
|
||||
histogram data cannot be merged
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#-----------------------------------------------------------------------
|
||||
# CMakeLists.txt
|
||||
# Module : G4analysis
|
||||
# Package: Geant4.src.G4analysis.g4tools
|
||||
#
|
||||
# CMakeLists.txt for g4tools. We do not use the usual Geant4 sources.cmake
|
||||
# approach because G4analysis requires a custom install solution for its
|
||||
# headers. The 'tools' subdirectory contains many headers that are needed and
|
||||
# these are in a nested structure which needs to be replicated when we
|
||||
# install, i.e:
|
||||
# <INCLUDE>
|
||||
# +- geant4
|
||||
# +- tools
|
||||
# +- histo
|
||||
# | +- h1d
|
||||
# ...
|
||||
#
|
||||
# Nevertheless, we're able to build the library via the standard
|
||||
# GEANT4_LIBRARY_TARGET macro.
|
||||
#
|
||||
# Created on: 28/07/2011
|
||||
#
|
||||
# $Id: CMakeLists.txt 72327 2013-07-16 06:52:43Z gcosmo $
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Ensure the header directory gets added to the list of ones to export
|
||||
#
|
||||
set_property(GLOBAL APPEND PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Install the headers, retaining their nested structure
|
||||
#
|
||||
install(DIRECTORY include/
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development
|
||||
PATTERN ".svn" EXCLUDE
|
||||
)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# We also need to install the tools license
|
||||
#
|
||||
install(FILES tools.license
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# $Id: GNUmakefile 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
# --------------------------------------------------------------------
|
||||
# GNUmakefile for geometry/biasing library. Gabriele Cosmo, 25/03/02.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
#includes: $(G4INCLUDE)/% : include/%
|
||||
# @cp -rp $< $@
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_S_STRING
|
||||
#define tools_S_STRING
|
||||
|
||||
// a few place in which a cpp macro help the readability.
|
||||
|
||||
#define TOOLS_CLASS_STRING(a_name)\
|
||||
static const std::string& s_##a_name() {\
|
||||
static const std::string s_v(#a_name);\
|
||||
return s_v;\
|
||||
}
|
||||
|
||||
#define TOOLS_CLASS_STRING_VALUE(a_name,a_value)\
|
||||
static const std::string& s_##a_name() {\
|
||||
static const std::string s_v(#a_value);\
|
||||
return s_v;\
|
||||
}
|
||||
|
||||
#define TOOLS_GLOBAL_STRING(a_name)\
|
||||
inline const std::string& s_##a_name() {\
|
||||
static const std::string s_v(#a_name);\
|
||||
return s_v;\
|
||||
}
|
||||
|
||||
#define TOOLS_GLOBAL_ARG(a_name)\
|
||||
inline const std::string& s_##a_name() {\
|
||||
static const std::string s_v(std::string("-")+std::string(#a_name));\
|
||||
return s_v;\
|
||||
}
|
||||
|
||||
#define TOOLS_SCLASS(a_name)\
|
||||
static const std::string& s_class() {\
|
||||
static const std::string s_v(#a_name);\
|
||||
return s_v;\
|
||||
}\
|
||||
static void check_class_name() {a_name::s_class();}
|
||||
|
||||
#define TOOLS_T_SCLASS(a_T,a_name)\
|
||||
static const std::string& s_class() {\
|
||||
static const std::string s_v(#a_name);\
|
||||
return s_v;\
|
||||
}\
|
||||
static void check_class_name() {a_name<a_T>::s_class();}
|
||||
|
||||
#define TOOLS_SCLASS_NO_CHECK(a_name)\
|
||||
static const std::string& s_class() {\
|
||||
static const std::string s_v(#a_name);\
|
||||
return s_v;\
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -34,7 +34,8 @@ public:
|
||||
}
|
||||
args(const std::vector<std::string>& a_args){add(a_args);}
|
||||
args(const std::vector<arg>& a_args):m_args(a_args){}
|
||||
args(const std::string& a_args,const std::string& a_sep = " ",bool a_strip = false){
|
||||
//args(const std::string& a_args,const std::string& a_sep = " ",bool a_strip = false){
|
||||
args(const std::string& a_args,const std::string& a_sep,bool a_strip){
|
||||
std::vector<std::string> _args;
|
||||
words(a_args,a_sep,false,_args);
|
||||
add(_args,a_strip);
|
||||
@@ -84,10 +85,11 @@ public:
|
||||
return to(s,a_value);
|
||||
}
|
||||
template <class aT>
|
||||
bool find(const std::string& a_string,aT& a_value) const {
|
||||
bool find(const std::string& a_string,aT& a_value,
|
||||
const aT& a_def = aT()) const {
|
||||
std::string _s;
|
||||
if(!find(a_string,_s)) {a_value = aT();return false;}
|
||||
return to<aT>(_s,a_value);
|
||||
if(!find(a_string,_s)) {a_value = a_def;return false;}
|
||||
return to<aT>(_s,a_value,a_def);
|
||||
}
|
||||
std::vector<std::string> tovector() const {
|
||||
// Return a vector of string <name=value>
|
||||
@@ -145,6 +147,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void add(const std::vector<arg>& a_args){
|
||||
std::vector<arg>::const_iterator it;
|
||||
for(it=a_args.begin();it!=a_args.end();++it) m_args.push_back(*it);
|
||||
}
|
||||
|
||||
int remove(const std::string& a_key){
|
||||
unsigned int nbeg = m_args.size();
|
||||
for(std::vector<arg>::iterator it = m_args.begin();it!=m_args.end();) {
|
||||
@@ -227,17 +234,17 @@ public:
|
||||
if(!p) {a_argc = 0;a_argv = 0;return false;} //some delete are lacking.
|
||||
*av = p;
|
||||
{char* pf = (char*)(*it).first.c_str();
|
||||
for(std::string::size_type i=0;i<lf;i++) {*p++ = *pf++;}
|
||||
for(std::string::size_type i=0;i<lf;i++,p++,pf++) {*p = *pf;}
|
||||
*p = 0;}
|
||||
if(ls) {*p = '=';p++;}
|
||||
{char* ps = (char*)(*it).second.c_str();
|
||||
for(std::string::size_type i=0;i<ls;i++) {*p++ = *ps++;}
|
||||
for(std::string::size_type i=0;i<ls;i++,p++,ps++) {*p = *ps;}
|
||||
*p = 0;}
|
||||
}
|
||||
a_argc = (int)m_args.size();
|
||||
return true;
|
||||
}
|
||||
void delete_argcv(int& a_argc,char**& a_argv) const {
|
||||
static void delete_argcv(int& a_argc,char**& a_argv) {
|
||||
for(int index=0;index<a_argc;index++) delete [] a_argv[index];
|
||||
delete [] a_argv;
|
||||
a_argc = 0;
|
||||
@@ -296,6 +303,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
public: //backcomp (for Panoramix).
|
||||
bool isAnArgument(const std::string& a_key) const {return is_arg(a_key);}
|
||||
protected:
|
||||
std::vector<arg> m_args;
|
||||
};
|
||||
@@ -486,6 +495,24 @@ inline void window_size_from_args(const args& a_args,
|
||||
}
|
||||
}
|
||||
|
||||
inline void remove_window_size_args(args& a_args) {
|
||||
//use with Wt apps.
|
||||
a_args.remove("-iPod");
|
||||
a_args.remove("-iPhone");
|
||||
a_args.remove("-iPad");
|
||||
a_args.remove("-iPhone4");
|
||||
a_args.remove("-SGS");
|
||||
a_args.remove("-ww");
|
||||
a_args.remove("-wh");
|
||||
a_args.remove("-land");
|
||||
}
|
||||
|
||||
inline std::vector<std::string> to(int a_argc,char** a_argv) {
|
||||
std::vector<std::string> v;
|
||||
for(int index=0;index<a_argc;index++) v.push_back(a_argv[index]);
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -30,7 +30,7 @@ inline float ffloor(float x) {return (float)::floor(double(x));}
|
||||
inline float ffabs(float x) {return (float)::fabs(double(x));}
|
||||
inline float fceil(float x) {return (float)::ceil(double(x));}
|
||||
|
||||
inline float fdeg2rad() {return fpi()/180.0f;}
|
||||
inline float fdeg2rad() {return fpi()/180.0f;} //0.0174f
|
||||
inline float frad2deg() {return 180.0f/fpi();}
|
||||
|
||||
inline int fround(float a_x) {
|
||||
@@ -39,6 +39,8 @@ inline int fround(float a_x) {
|
||||
else return (a_x>0.0f) ? int(a_x+0.5f) : -int(0.5f-a_x);
|
||||
}
|
||||
|
||||
inline float fstep(float a_x) {return a_x<0.0f?0.0f:1.0f;}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_gzip_buffer
|
||||
#define tools_gzip_buffer
|
||||
|
||||
// what is needed for root file compression with zlib.
|
||||
|
||||
// The gzip library is libz.
|
||||
// Someone must not confuse zlib with zip.
|
||||
// In particular to use zip someone has to
|
||||
// link to -lz that contains inflate, deflate.
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace tools {
|
||||
|
||||
inline bool gzip_buffer(std::ostream& a_out,
|
||||
unsigned int a_level,
|
||||
unsigned int a_srcsize,const char* a_src,
|
||||
unsigned int a_tgtsize,char* a_tgt,
|
||||
unsigned int& a_irep) {
|
||||
|
||||
z_stream stream; // decompression stream
|
||||
|
||||
stream.next_in = (Bytef*)(a_src);
|
||||
stream.avail_in = (uInt)(a_srcsize);
|
||||
stream.next_out = (Bytef*)a_tgt;
|
||||
stream.avail_out = (uInt)(a_tgtsize);
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
int err = deflateInit(&stream,a_level);
|
||||
if(err!=Z_OK) {
|
||||
a_out << "tools::wroot::zip :"
|
||||
<< " error in zlib/deflateInit." << std::endl;
|
||||
a_irep = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
err = deflate(&stream, Z_FINISH);
|
||||
if(err!=Z_STREAM_END) {
|
||||
deflateEnd(&stream);
|
||||
a_out << "tools::wroot::zip :"
|
||||
<< " error in zlib/deflate." << std::endl;
|
||||
a_irep = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
deflateEnd(&stream);
|
||||
|
||||
//a_out << "tools::gzip_buffer : ok "
|
||||
// << stream.total_out << std::endl;
|
||||
|
||||
a_irep = stream.total_out;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool gunzip_buffer(std::ostream& a_out,
|
||||
unsigned int a_srcsize,const char* a_src,
|
||||
unsigned int a_tgtsize,char* a_tgt,
|
||||
unsigned int& a_irep) {
|
||||
|
||||
z_stream stream; // decompression stream
|
||||
|
||||
stream.next_in = (Bytef*)(a_src);
|
||||
stream.avail_in = (uInt)(a_srcsize);
|
||||
stream.next_out = (Bytef*)a_tgt;
|
||||
stream.avail_out = (uInt)(a_tgtsize);
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
int err = inflateInit(&stream);
|
||||
if (err != Z_OK) {
|
||||
a_out << "tools::gunzip_buffer :"
|
||||
<< " error " << err << " in zlib/inflateInit." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
err = inflate(&stream, Z_FINISH);
|
||||
if (err != Z_STREAM_END) {
|
||||
inflateEnd(&stream);
|
||||
a_out << "tools::gunzip_buffer :"
|
||||
<< " error " << err << " in zlib/inflate." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
inflateEnd(&stream);
|
||||
|
||||
//a_out << "tools::gunzip_buffer : zlib : ok "
|
||||
// << stream.total_out << std::endl;
|
||||
|
||||
a_irep = stream.total_out;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+30
-3
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
To resolve some HBOOK entry points used in CLHEP !
|
||||
*/
|
||||
/* To resolve some HBOOK entry points used in CLHEP ! */
|
||||
void hlimit_(){}
|
||||
|
||||
void hnoent_(){}
|
||||
@@ -43,3 +41,32 @@ int hcbook_[51];
|
||||
void mninit_(){}
|
||||
void mnparm_(){}
|
||||
void mnexcm_(){}
|
||||
|
||||
/* to link BatchLabZebra plugin : */
|
||||
void hexist_(){}
|
||||
void hitoc_(){}
|
||||
void hbug_(){}
|
||||
void hndesc_(){}
|
||||
void hdcofl_(){}
|
||||
void hrin_(){}
|
||||
void hldir_(){}
|
||||
void hbookb_(){}
|
||||
void hgive_(){}
|
||||
void hi_(){}
|
||||
void hie_(){}
|
||||
void hij_(){}
|
||||
void hije_(){}
|
||||
void hix_(){}
|
||||
void hijxy_(){}
|
||||
void hxi_(){}
|
||||
void hxyij_(){}
|
||||
void hmin_(){}
|
||||
void hmax_(){}
|
||||
void hreset_(){}
|
||||
void hbnam_(){}
|
||||
void hgiven_(){}
|
||||
void hgnt_(){}
|
||||
void hopera_(){}
|
||||
void lenocc_(){}
|
||||
void locati_(){}
|
||||
void rzink_(){}
|
||||
+1
-1
@@ -187,7 +187,7 @@ public:
|
||||
column<T>* find_column(const std::string& a_name) {
|
||||
icol* col = tools::find_named<icol>(m_cols,a_name);
|
||||
if(!col) return 0;
|
||||
return tools::cast<icol, column<T> >(*col);
|
||||
return tools::safe_cast<icol, column<T> >(*col);
|
||||
}
|
||||
|
||||
//std::string title() const {
|
||||
+1
-1
@@ -388,7 +388,7 @@ public:
|
||||
aIs[iaxis] = offset/m_axes[iaxis].m_offset;
|
||||
offset -= aIs[iaxis] * m_axes[iaxis].m_offset;
|
||||
}}
|
||||
for(unsigned iaxis=0;iaxis<m_dimension;iaxis++) {
|
||||
for(unsigned int iaxis=0;iaxis<m_dimension;iaxis++) {
|
||||
if(aIs[iaxis]==0) {
|
||||
aIs[iaxis] = axis<TC>::UNDERFLOW_BIN;
|
||||
} else if(aIs[iaxis]==int(m_axes[iaxis].m_number_of_bins+1)) {
|
||||
+3
-2
@@ -82,8 +82,8 @@ public:
|
||||
return m_histo->fill(aX,aW);
|
||||
} else {
|
||||
if(m_xs.size()) {
|
||||
m_lower_x = inlib::mn<double>(aX,m_lower_x);
|
||||
m_upper_x = inlib::mx<double>(aX,m_upper_x);
|
||||
m_lower_x = mn<double>(aX,m_lower_x);
|
||||
m_upper_x = mx<double>(aX,m_upper_x);
|
||||
} else {
|
||||
m_lower_x = aX;
|
||||
m_upper_x = aX;
|
||||
@@ -198,6 +198,7 @@ public:
|
||||
|
||||
c1d& operator=(const c1d& a_from){
|
||||
base_cloud::operator=(a_from);
|
||||
if(&a_from==this) return *this;
|
||||
m_xs = a_from.m_xs;
|
||||
m_lower_x = a_from.m_lower_x;
|
||||
m_upper_x = a_from.m_upper_x;
|
||||
+5
-4
@@ -93,6 +93,7 @@ public:
|
||||
|
||||
c2d& operator=(const c2d& a_from) {
|
||||
base_cloud::operator=(a_from);
|
||||
if(&a_from==this) return *this;
|
||||
m_xs = a_from.m_xs;
|
||||
m_ys = a_from.m_ys;
|
||||
m_lower_x = a_from.m_lower_x;
|
||||
@@ -276,15 +277,15 @@ bool c2d::fill(double aX,double aY,double aW){
|
||||
return m_histo->fill(aX,aY,aW);
|
||||
} else {
|
||||
if(m_xs.size()) {
|
||||
m_lower_x = inlib::mn<double>(aX,m_lower_x);
|
||||
m_upper_x = inlib::mx<double>(aX,m_upper_x);
|
||||
m_lower_x = mn<double>(aX,m_lower_x);
|
||||
m_upper_x = mx<double>(aX,m_upper_x);
|
||||
} else {
|
||||
m_lower_x = aX;
|
||||
m_upper_x = aX;
|
||||
}
|
||||
if(m_ys.size()) {
|
||||
m_lower_y = inlib::mn<double>(aY,m_lower_y);
|
||||
m_upper_y = inlib::mx<double>(aY,m_upper_y);
|
||||
m_lower_y = mn<double>(aY,m_lower_y);
|
||||
m_upper_y = mx<double>(aY,m_upper_y);
|
||||
} else {
|
||||
m_lower_y = aY;
|
||||
m_upper_y = aY;
|
||||
+7
-6
@@ -111,6 +111,7 @@ public:
|
||||
|
||||
c3d& operator=(const c3d& a_from) {
|
||||
base_cloud::operator=(a_from);
|
||||
if(&a_from==this) return *this;
|
||||
m_xs = a_from.m_xs;
|
||||
m_ys = a_from.m_ys;
|
||||
m_zs = a_from.m_zs;
|
||||
@@ -362,22 +363,22 @@ bool c3d::fill(double aX,double aY,double aZ,double aW){
|
||||
return m_histo->fill(aX,aY,aZ,aW);
|
||||
} else {
|
||||
if(m_xs.size()) {
|
||||
m_lower_x = inlib::mn<double>(aX,m_lower_x);
|
||||
m_upper_x = inlib::mx<double>(aX,m_upper_x);
|
||||
m_lower_x = mn<double>(aX,m_lower_x);
|
||||
m_upper_x = mx<double>(aX,m_upper_x);
|
||||
} else {
|
||||
m_lower_x = aX;
|
||||
m_upper_x = aX;
|
||||
}
|
||||
if(m_ys.size()) {
|
||||
m_lower_y = inlib::mn<double>(aY,m_lower_y);
|
||||
m_upper_y = inlib::mx<double>(aY,m_upper_y);
|
||||
m_lower_y = mn<double>(aY,m_lower_y);
|
||||
m_upper_y = mx<double>(aY,m_upper_y);
|
||||
} else {
|
||||
m_lower_y = aY;
|
||||
m_upper_y = aY;
|
||||
}
|
||||
if(m_zs.size()) {
|
||||
m_lower_z = inlib::mn<double>(aZ,m_lower_z);
|
||||
m_upper_z = inlib::mx<double>(aZ,m_upper_z);
|
||||
m_lower_z = mn<double>(aZ,m_lower_z);
|
||||
m_upper_z = mx<double>(aZ,m_upper_z);
|
||||
} else {
|
||||
m_lower_z = aZ;
|
||||
m_upper_z = aZ;
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_iobj_const_visitor
|
||||
#define tools_iobj_const_visitor
|
||||
|
||||
#include "typedefs"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tools {
|
||||
|
||||
class iobj_const_visitor;
|
||||
|
||||
class istorable {
|
||||
public:
|
||||
virtual ~istorable() {}
|
||||
//public:
|
||||
// virtual void* cast(const std::string&) const = 0;
|
||||
public:
|
||||
virtual bool visit(iobj_const_visitor&) const = 0;
|
||||
// virtual bool read(IVisitor&) = 0;
|
||||
};
|
||||
|
||||
class iobj_const_visitor {
|
||||
public:
|
||||
virtual ~iobj_const_visitor() {}
|
||||
public:
|
||||
//typedef bool(*Local)(const Slash::Store::istorable&,
|
||||
// iobj_const_visitor&);
|
||||
public:
|
||||
//virtual bool begin(const istorable&,const std::string&,Local) = 0;
|
||||
//virtual bool end(const istorable&) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,bool) = 0;
|
||||
virtual bool visit(const std::string&,char) = 0;
|
||||
//virtual bool visit(const std::string&,unsigned char) = 0;
|
||||
virtual bool visit(const std::string&,short) = 0;
|
||||
//virtual bool visit(const std::string&,unsigned short) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,int) = 0;
|
||||
virtual bool visit(const std::string&,unsigned int) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,int64) = 0;
|
||||
virtual bool visit(const std::string&,uint64) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,float) = 0;
|
||||
virtual bool visit(const std::string&,double) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,const std::string&) = 0;
|
||||
//virtual bool visit(const std::string&,const char*) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<bool>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<char>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<short>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<int>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<int64>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<float>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<double>&) = 0;
|
||||
//virtual bool visit(const std::string&,const std::vector<unsigned char>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<std::string>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector< std::vector<double> >&) = 0;
|
||||
|
||||
//virtual bool visit_double(const std::string&,const IArray&) = 0;
|
||||
virtual bool visit(const std::string&,const istorable&) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_iobj_visitor
|
||||
#define tools_iobj_visitor
|
||||
|
||||
#include "typedefs"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
namespace tools {
|
||||
|
||||
class iobj_visitor {
|
||||
public:
|
||||
virtual ~iobj_visitor() {}
|
||||
public:
|
||||
virtual std::ostream& out() = 0;
|
||||
|
||||
//virtual bool begin(IStorable&) = 0;
|
||||
//virtual bool end(IStorable&) = 0;
|
||||
virtual bool visit(bool&) = 0;
|
||||
virtual bool visit(char&) = 0;
|
||||
virtual bool visit(short&) = 0;
|
||||
virtual bool visit(int&) = 0;
|
||||
virtual bool visit(unsigned int&) = 0;
|
||||
virtual bool visit(int64&) = 0;
|
||||
virtual bool visit(uint64&) = 0;
|
||||
virtual bool visit(float&) = 0;
|
||||
virtual bool visit(double&) = 0;
|
||||
virtual bool visit(std::string&) = 0;
|
||||
virtual bool visit(std::vector<bool>&) = 0;
|
||||
virtual bool visit(std::vector<char>&) = 0;
|
||||
virtual bool visit(std::vector<short>&) = 0;
|
||||
virtual bool visit(std::vector<int>&) = 0;
|
||||
virtual bool visit(std::vector<int64>&) = 0;
|
||||
virtual bool visit(std::vector<float>&) = 0;
|
||||
virtual bool visit(std::vector<double>&) = 0;
|
||||
virtual bool visit(std::vector<unsigned char>&) = 0;
|
||||
virtual bool visit(std::vector<std::string>&) = 0;
|
||||
virtual bool visit(std::vector< std::vector<double> >&) = 0;
|
||||
//virtual bool visit_double(IArray&) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -22,7 +22,7 @@ inline double deg2rad() {return pi()/180.0;}
|
||||
|
||||
template <class T>
|
||||
inline T power(const T& a_A,unsigned int a_B){
|
||||
T v = 1;
|
||||
T v = T(1);
|
||||
for(unsigned int i=0;i<a_B;i++) v *= a_A;
|
||||
return v;
|
||||
}
|
||||
@@ -118,6 +118,16 @@ inline const std::string& s_malloc() {
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_tex() {
|
||||
static const std::string s_v("tex");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_gsto() {
|
||||
static const std::string s_v("gsto");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,657 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_osc_streamers
|
||||
#define tools_osc_streamers
|
||||
|
||||
#include "iobj_const_visitor"
|
||||
#include "iobj_visitor"
|
||||
|
||||
#include "histo/h1d"
|
||||
#include "histo/h2d"
|
||||
#include "histo/h3d"
|
||||
#include "histo/p1d"
|
||||
#include "histo/p2d"
|
||||
#include "vmanip"
|
||||
#include "sto"
|
||||
|
||||
namespace tools {
|
||||
namespace osc {
|
||||
|
||||
inline bool Axis_visit(iobj_const_visitor& a_v,
|
||||
const std::string& /*a_field*/,
|
||||
const histo::axis<double>& a_axis){
|
||||
//SLASH_STORE_BEGIN(BatchLab::Axis)
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
if(!a_v.visit("fOffset",a_axis.m_offset)) return false;
|
||||
if(!a_v.visit("fNumberOfBins",(int)a_axis.m_number_of_bins)) return false;
|
||||
if(!a_v.visit("fMinimumValue",a_axis.m_minimum_value)) return false;
|
||||
if(!a_v.visit("fMaximumValue",a_axis.m_maximum_value)) return false;
|
||||
if(!a_v.visit("fFixed",a_axis.m_fixed)) return false;
|
||||
if(!a_v.visit("fBinWidth",a_axis.m_bin_width)) return false;
|
||||
if(!a_v.visit("fEdges",a_axis.m_edges)) return false;
|
||||
|
||||
//if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Axis_read(iobj_visitor& a_visitor,
|
||||
histo::axis<double>& a_axis){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(!a_visitor.visit(a_axis.m_offset)) return false;
|
||||
|
||||
{int nbin;
|
||||
if(!a_visitor.visit(nbin)) return false;
|
||||
a_axis.m_number_of_bins = nbin;}
|
||||
|
||||
if(!a_visitor.visit(a_axis.m_minimum_value)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_maximum_value)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_fixed)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_bin_width)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_edges)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
class Item : public virtual istorable {
|
||||
public:
|
||||
virtual bool visit(iobj_const_visitor& a_visitor) const {
|
||||
//if(!a_visitor.begin(*this,Item::s_class(),Item::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!a_visitor.visit("fKey",fKey)) return false;
|
||||
if(!a_visitor.visit("fValue",fValue)) return false;
|
||||
if(!a_visitor.visit("fSticky",fSticky)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
virtual bool read(iobj_visitor& a_visitor) {
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(!a_visitor.visit(fKey)) return false;
|
||||
if(!a_visitor.visit(fValue)) return false;
|
||||
if(!a_visitor.visit(fSticky)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
Item(){}
|
||||
Item(const std::string& aKey,const std::string& aValue,bool aSticky)
|
||||
:fKey(aKey),fValue(aValue),fSticky(aSticky){}
|
||||
virtual ~Item(){}
|
||||
public:
|
||||
Item(const Item& aFrom)
|
||||
:istorable(aFrom)
|
||||
,fKey(aFrom.fKey)
|
||||
,fValue(aFrom.fValue)
|
||||
,fSticky(aFrom.fSticky)
|
||||
{}
|
||||
Item& operator=(const Item& aFrom) {
|
||||
fKey = aFrom.fKey;
|
||||
fValue = aFrom.fValue;
|
||||
fSticky = aFrom.fSticky;
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
std::string fKey;
|
||||
std::string fValue;
|
||||
bool fSticky;
|
||||
};
|
||||
|
||||
template <class T> //T must inherit istorable.
|
||||
inline bool std_vector_visit(iobj_const_visitor& a_visitor,
|
||||
const std::string& /*a_field*/,
|
||||
const std::vector<T>& a_vec) {
|
||||
//if(!a_visitor.begin(*this,"BatchLab::Vector<"+a_field+">",Vector<T>::visit))
|
||||
// return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
unsigned int number = a_vec.size();
|
||||
if(!a_visitor.visit("fSize",number)) return false;
|
||||
|
||||
for(unsigned int index=0;index<number;index++) {
|
||||
const T& elem = a_vec[index];
|
||||
if(!a_visitor.visit(to<int>(index),elem)) return false;
|
||||
}
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool std_vector_read(iobj_visitor& a_visitor,
|
||||
std::vector<T>& a_vec) {
|
||||
a_vec.clear();
|
||||
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
unsigned int number;
|
||||
if(!a_visitor.visit(number)) return false;
|
||||
|
||||
a_vec.resize(number);
|
||||
for(unsigned int index=0;index<number;index++) {
|
||||
T& elem = a_vec[index];
|
||||
if(!elem.read(a_visitor)) return false;
|
||||
}
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Annotation_visit(iobj_const_visitor& a_visitor,
|
||||
const std::vector<Item>& a_items) {
|
||||
//if(!a_visitor.begin(*this,Annotation::s_class(),Annotation::s_visit))
|
||||
// return false;
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
if(!std_vector_visit<Item>(a_visitor,"fItems",a_items)) return false;
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Annotation_read(iobj_visitor& a_visitor) {
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
std::vector<Item> fItems;
|
||||
if(!std_vector_read<Item>(a_visitor,fItems)) return false;
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void map2vec(const std::map<std::string,std::string>& a_in,
|
||||
std::vector<Item>& a_out) {
|
||||
a_out.clear();
|
||||
std::map<std::string,std::string>::const_iterator it;
|
||||
for(it=a_in.begin();it!=a_in.end();++it) {
|
||||
a_out.push_back(Item((*it).first,(*it).second,false));
|
||||
}
|
||||
}
|
||||
|
||||
typedef histo::histo_data<double,unsigned int,double> hd_data;
|
||||
|
||||
inline bool BaseHistogram_visit(const hd_data& aData,
|
||||
iobj_const_visitor& a_visitor) {
|
||||
//SLASH_STORE_BEGIN(BatchLab::BaseHistogram)
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
//if(!a_visitor.visit("fAnnotation",fAnnotation)) return false;
|
||||
std::vector<Item> items;
|
||||
map2vec(aData.m_annotations,items);
|
||||
if(!Annotation_visit(a_visitor,items)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool BaseHistogram_read(iobj_visitor& a_visitor){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(!Annotation_read(a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visitHistogram(const hd_data& aData,
|
||||
iobj_const_visitor& a_visitor){
|
||||
if(!a_visitor.visit("fTitle",aData.m_title)) return false;
|
||||
if(!a_visitor.visit("fDimension",(int)aData.m_dimension)) return false;
|
||||
if(!a_visitor.visit("fBinNumber",(int)aData.m_bin_number)) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinEntries",
|
||||
convert<unsigned int,int>(aData.m_bin_entries))) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinSw",aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit("fBinSw2",aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit("fBinSxw",aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit("fBinSx2w",aData.m_bin_Sx2w)) return false;
|
||||
{for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
std::string name = "fAxes_" + to<int>(iaxis);
|
||||
//BatchLab::Axis axis;
|
||||
//axis.copy(aData.m_axes[iaxis]);
|
||||
//if(!a_visitor.visit(name,axis)) return false;
|
||||
if(!Axis_visit(a_visitor,name,aData.m_axes[iaxis])) return false;
|
||||
}}
|
||||
{int dummy = 0;
|
||||
if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
|
||||
if(!a_visitor.visit("fProfile",false)) return false;
|
||||
{std::vector<double> dummy;
|
||||
if(!a_visitor.visit("fBinSvw",dummy)) return false;
|
||||
if(!a_visitor.visit("fBinSv2w",dummy)) return false;}
|
||||
if(!a_visitor.visit("fCutV",false)) return false;
|
||||
{double dummy = 0;
|
||||
if(!a_visitor.visit("fMinV",dummy)) return false;
|
||||
if(!a_visitor.visit("fMaxV",dummy)) return false;}
|
||||
// Not written :
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool readHistogram(hd_data& aData,iobj_visitor& a_visitor){
|
||||
if(!a_visitor.visit(aData.m_title)) return false;
|
||||
{int dim;
|
||||
if(!a_visitor.visit(dim)) return false;
|
||||
aData.m_dimension = dim;}
|
||||
|
||||
{int nbin;
|
||||
if(!a_visitor.visit(nbin)) return false;
|
||||
aData.m_bin_number = nbin;}
|
||||
|
||||
{std::vector<int> vec;
|
||||
if(!a_visitor.visit(vec)) return false;
|
||||
aData.m_bin_entries = convert<int,unsigned int>(vec);}
|
||||
|
||||
if(!a_visitor.visit(aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
|
||||
aData.m_axes.clear();
|
||||
for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
histo::axis<double> baxis;
|
||||
if(!Axis_read(a_visitor,baxis)) return false;
|
||||
aData.m_axes.push_back(baxis);
|
||||
}
|
||||
{int dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_mode
|
||||
|
||||
{bool dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_is_profile
|
||||
|
||||
{std::vector<double> dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_bin_Svw
|
||||
|
||||
{std::vector<double> dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_bin_Sv2w
|
||||
|
||||
{bool dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_cut_v
|
||||
|
||||
{double dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //aData.m_min_v
|
||||
|
||||
{double dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //aData.m_max_v
|
||||
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
//aData.m_coords.resize(aData.m_dimension,0);
|
||||
//aData.m_ints.resize(aData.m_dimension,0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_visitor,
|
||||
const histo::h1d& a_histo) {
|
||||
//SLASH_STORE_BEGIN(BatchLab::Histogram1D)
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!BaseHistogram_visit(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
if(!visitHistogram(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.visit("fAxis",fAxis)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::h1d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
hd_data hdata;
|
||||
if(!readHistogram(hdata,a_visitor)) return false;
|
||||
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxis.copy(fHistogram.get_axis(0));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_visitor,
|
||||
const histo::h2d& a_histo) {
|
||||
//SLASH_STORE_BEGIN(BatchLab::Histogram2D)
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!BaseHistogram_visit(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
if(!visitHistogram(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.visit("fAxisX",fAxisX)) return false;
|
||||
//if(!a_visitor.visit("fAxisY",fAxisY)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::h2d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
hd_data hdata;
|
||||
if(!readHistogram(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxisX.copy(fHistogram.get_axis(0));
|
||||
//fAxisY.copy(fHistogram.get_axis(1));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_visitor,
|
||||
const histo::h3d& a_histo) {
|
||||
//SLASH_STORE_BEGIN(BatchLab::Histogram3D)
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!BaseHistogram_visit(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
if(!visitHistogram(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.visit("fAxisX",fAxisX)) return false;
|
||||
//if(!a_visitor.visit("fAxisY",fAxisY)) return false;
|
||||
//if(!a_visitor.visit("fAxisZ",fAxisY)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::h3d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
hd_data hdata;
|
||||
if(!readHistogram(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxisX.copy(fHistogram.get_axis(0));
|
||||
//fAxisY.copy(fHistogram.get_axis(1));
|
||||
//fAxisZ.copy(fHistogram.get_axis(2));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef histo::profile_data<double,unsigned int,double,double> pd_data;
|
||||
|
||||
inline bool visitProfile(const pd_data& aData,
|
||||
iobj_const_visitor& a_visitor){
|
||||
if(!a_visitor.visit("fTitle",aData.m_title)) return false;
|
||||
if(!a_visitor.visit("fDimension",(int)aData.m_dimension)) return false;
|
||||
if(!a_visitor.visit("fBinNumber",(int)aData.m_bin_number)) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinEntries",
|
||||
convert<unsigned int,int>(aData.m_bin_entries))) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinSw",aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit("fBinSw2",aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit("fBinSxw",aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit("fBinSx2w",aData.m_bin_Sx2w)) return false;
|
||||
for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
std::string name = "fAxes_" + to<int>(iaxis);
|
||||
//BatchLab::Axis axis;
|
||||
//axis.copy(aData.m_axes[iaxis]);
|
||||
//if(!a_visitor.visit(name,axis)) return false;
|
||||
if(!Axis_visit(a_visitor,name,aData.m_axes[iaxis])) return false;
|
||||
}
|
||||
{int dummy = 0;
|
||||
if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
|
||||
if(!a_visitor.visit("fProfile",true)) return false;
|
||||
if(!a_visitor.visit("fBinSvw",aData.m_bin_Svw)) return false;
|
||||
if(!a_visitor.visit("fBinSv2w",aData.m_bin_Sv2w)) return false;
|
||||
if(!a_visitor.visit("fCutV",aData.m_cut_v)) return false;
|
||||
if(!a_visitor.visit("fMinV",aData.m_min_v)) return false;
|
||||
if(!a_visitor.visit("fMaxV",aData.m_max_v)) return false;
|
||||
// Not written :
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool readProfile(pd_data& aData,iobj_visitor& a_visitor){
|
||||
if(!a_visitor.visit(aData.m_title)) return false;
|
||||
|
||||
{int dim;
|
||||
if(!a_visitor.visit(dim)) return false;
|
||||
aData.m_dimension = dim;}
|
||||
|
||||
{int nbin;
|
||||
if(!a_visitor.visit(nbin)) return false;
|
||||
aData.m_bin_number = nbin;}
|
||||
|
||||
{std::vector<int> vec;
|
||||
if(!a_visitor.visit(vec)) return false;
|
||||
aData.m_bin_entries = convert<int,unsigned int>(vec);}
|
||||
|
||||
if(!a_visitor.visit(aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
|
||||
aData.m_axes.clear();
|
||||
for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
histo::axis<double> baxis;
|
||||
if(!Axis_read(a_visitor,baxis)) return false;
|
||||
aData.m_axes.push_back(baxis);
|
||||
}
|
||||
{int dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_mode
|
||||
if(!a_visitor.visit(aData.m_is_profile)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Svw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sv2w)) return false;
|
||||
if(!a_visitor.visit(aData.m_cut_v)) return false;
|
||||
if(!a_visitor.visit(aData.m_min_v)) return false;
|
||||
if(!a_visitor.visit(aData.m_max_v)) return false;
|
||||
|
||||
// Not written :
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
//aData.m_coords.resize(aData.m_dimension,0);
|
||||
//aData.m_ints.resize(aData.m_dimension,0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_visitor,
|
||||
const histo::p1d& a_histo) {
|
||||
//SLASH_STORE_BEGIN(BatchLab::Profile1D)
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!BaseHistogram_visit(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
if(!visitProfile(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.visit("fAxis",fAxis)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::p1d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
pd_data hdata;
|
||||
if(!readProfile(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxis.copy(fHistogram.get_axis(0));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_visitor,
|
||||
const histo::p2d& a_histo) {
|
||||
//SLASH_STORE_BEGIN(BatchLab::Profile2D)
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!BaseHistogram_visit(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
if(!visitProfile(a_histo.get_histo_data(),a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.visit("fAxisX",fAxisX)) return false;
|
||||
//if(!a_visitor.visit("fAxisY",fAxisY)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::p2d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
pd_data hdata;
|
||||
if(!readProfile(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxisX.copy(a_histo.get_axis(0));
|
||||
//fAxisY.copy(a_histo.get_axis(1));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const std::string& s_h1d() {
|
||||
static const std::string s_v("BatchLab::Histogram1D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_h2d() {
|
||||
static const std::string s_v("BatchLab::Histogram2D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_h3d() {
|
||||
static const std::string s_v("BatchLab::Histogram3D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_p1d() {
|
||||
static const std::string s_v("BatchLab::Profile1D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_p2d() {
|
||||
static const std::string s_v("BatchLab::Profile2D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -162,6 +162,41 @@ inline std::string dir_name(const std::string& a_path,unsigned int a_num = 1){
|
||||
return path;
|
||||
}
|
||||
|
||||
//used in OpenPAW, BatchLab.
|
||||
inline bool is_f77(const std::string& a_path){
|
||||
std::string sfx = suffix(a_path);
|
||||
|
||||
//tolowercase(sfx);
|
||||
for(std::string::iterator it=sfx.begin();it!=sfx.end();++it) {
|
||||
char c = *it;
|
||||
*it = ((c) >= 'A' && (c) <= 'Z' ? c - 'A' + 'a' : c);
|
||||
}
|
||||
|
||||
if(sfx=="f") return true; //the standard.
|
||||
if(sfx=="for") return true; //for opaw. Known by g77.
|
||||
if(sfx=="ftn") return true; //for opaw.
|
||||
if(sfx=="fortran") return true; //for opaw.
|
||||
if(sfx=="f77") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//used in OpenPAW, BatchLab.
|
||||
inline bool is_cpp(const std::string& a_path){
|
||||
std::string sfx = suffix(a_path);
|
||||
|
||||
//tolowercase(sfx);
|
||||
for(std::string::iterator it=sfx.begin();it!=sfx.end();++it) {
|
||||
char c = *it;
|
||||
*it = ((c) >= 'A' && (c) <= 'Z' ? c - 'A' + 'a' : c);
|
||||
}
|
||||
|
||||
if(sfx=="c") return true;
|
||||
if(sfx=="cxx") return true;
|
||||
if(sfx=="cpp") return true;
|
||||
if(sfx=="C") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+28
-2
@@ -30,20 +30,21 @@ inline bool is_little_endian() {
|
||||
|
||||
namespace tools {
|
||||
namespace device {
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
inline bool is_iOS() {return true;}
|
||||
#else
|
||||
inline bool is_iOS() {return false;}
|
||||
#endif
|
||||
|
||||
#if ANDROID_NDK
|
||||
#if ANDROID
|
||||
inline bool is_Android() {return true;}
|
||||
#else
|
||||
inline bool is_Android() {return false;}
|
||||
#endif
|
||||
|
||||
|
||||
#if ANDROID_NDK || TARGET_OS_IPHONE
|
||||
#if ANDROID || TARGET_OS_IPHONE
|
||||
inline bool small_screen() {return true;}
|
||||
inline bool no_cursor() {return true;}
|
||||
inline bool stop_app_button() {return true;}
|
||||
@@ -57,6 +58,31 @@ inline bool slow_cpu() {return true;}
|
||||
#else
|
||||
inline bool slow_cpu() {return false;}
|
||||
#endif
|
||||
|
||||
inline unsigned int tex_mem_limit() {
|
||||
// glGet(GL_MAX_TEXTURE_SIZE) :
|
||||
// MacBookPro : it returns 8192.
|
||||
// SGS : it returns 2048.
|
||||
// iPad1 : it returns 2048.
|
||||
// iPod : it returns ?
|
||||
// Nexus 10 : it returns ?
|
||||
|
||||
// 1024*1024 //*3 = 3 145 728
|
||||
// 2048*2048 //*3 = 12 582 912
|
||||
// 4096*4096 //*3 = 50 331 648
|
||||
// 8192*8192 //*3 = 201 326 592
|
||||
// 8192*4096 //*3 = 100 663 296
|
||||
if(small_screen()) {
|
||||
//iOS : Apple says that max 2D tex size is 1024*1024 with two units
|
||||
// texture available. From doc on PowerVR MBX.
|
||||
return 2048*2048*3;
|
||||
} else {
|
||||
//limit = 4096*4096*3; //=8192*2048 //permit to pass ATLAS big image.
|
||||
//permit to pass fete_science_2010/power2/image_0.jpg
|
||||
return 8192*4096*3;
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -27,13 +27,13 @@ inline bool to_pointer(const std::string& a_string,void*& a_value){
|
||||
return true;
|
||||
}
|
||||
|
||||
inline std::string p2s(void* a_value){
|
||||
inline std::string p2s(const void* a_value){
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),"%lu",(unsigned long)a_value);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::string p2sx(void* a_value){
|
||||
inline std::string p2sx(const void* a_value){
|
||||
char s[512];
|
||||
snpf(s,sizeof(s),"0x%lx",(unsigned long)a_value);
|
||||
return s;
|
||||
+2
-2
@@ -9,12 +9,12 @@
|
||||
namespace tools {
|
||||
|
||||
template <class FROM,class TO>
|
||||
inline TO* cast(FROM& a_o) {
|
||||
inline TO* safe_cast(FROM& a_o) {
|
||||
return (TO*)a_o.cast(TO::s_class());
|
||||
}
|
||||
|
||||
template <class FROM,class TO>
|
||||
inline const TO* cast(const FROM& a_o) {
|
||||
inline const TO* safe_cast(const FROM& a_o) {
|
||||
return (const TO*)a_o.cast(TO::s_class());
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ inline bool to(const std::string& a_string,bool& a_value){
|
||||
namespace tools {
|
||||
|
||||
template <class T>
|
||||
inline bool to(const std::string& a_s,T& a_v) {
|
||||
if(a_s.empty()) {a_v = T();return false;} //for TOOLS_STL istringstream.
|
||||
inline bool to(const std::string& a_s,T& a_v,const T& a_def = T()) {
|
||||
if(a_s.empty()) {a_v = a_def;return false;} //for TOOLS_STL istringstream.
|
||||
std::istringstream strm(a_s.c_str());
|
||||
strm >> a_v;
|
||||
if(strm.fail()) {a_v = T();return false;}
|
||||
if(strm.fail()) {a_v = a_def;return false;}
|
||||
return strm.eof();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_store_iobj_const_visitor
|
||||
#define tools_store_iobj_const_visitor
|
||||
|
||||
#include "../typedefs"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tools {
|
||||
|
||||
class iobj_const_visitor;
|
||||
|
||||
class istorable {
|
||||
public:
|
||||
virtual ~istorable() {}
|
||||
public:
|
||||
virtual void* cast(const std::string&) const = 0;
|
||||
public:
|
||||
virtual const std::string& store_cls() const = 0;
|
||||
virtual bool visit(iobj_const_visitor&) const = 0;
|
||||
// virtual bool read(iobj_visitor&) = 0;
|
||||
};
|
||||
|
||||
class iobj_const_visitor {
|
||||
public:
|
||||
virtual ~iobj_const_visitor() {}
|
||||
public:
|
||||
typedef bool(*local_func)(const istorable&,iobj_const_visitor&);
|
||||
public:
|
||||
virtual bool begin(const istorable&,const std::string&,local_func) = 0;
|
||||
virtual bool end(const istorable&) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,bool) = 0;
|
||||
virtual bool visit(const std::string&,char) = 0;
|
||||
//virtual bool visit(const std::string&,unsigned char) = 0;
|
||||
virtual bool visit(const std::string&,short) = 0;
|
||||
//virtual bool visit(const std::string&,unsigned short) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,int) = 0;
|
||||
virtual bool visit(const std::string&,unsigned int) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,int64) = 0;
|
||||
virtual bool visit(const std::string&,uint64) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,float) = 0;
|
||||
virtual bool visit(const std::string&,double) = 0;
|
||||
|
||||
virtual bool visit(const std::string&,const std::string&) = 0;
|
||||
//virtual bool visit(const std::string&,const char*) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<bool>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<char>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<short>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<int>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<int64>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<float>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<double>&) = 0;
|
||||
//virtual bool visit(const std::string&,const std::vector<unsigned char>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector<std::string>&) = 0;
|
||||
virtual bool visit(const std::string&,const std::vector< std::vector<double> >&) = 0;
|
||||
|
||||
//virtual bool visit_double(const std::string&,const IArray&) = 0;
|
||||
virtual bool visit(const std::string&,const istorable&) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_store_iobj_visitor
|
||||
#define tools_store_iobj_visitor
|
||||
|
||||
#include "../typedefs"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
namespace tools {
|
||||
|
||||
class iobj_visitor {
|
||||
public:
|
||||
virtual ~iobj_visitor() {}
|
||||
public:
|
||||
virtual std::ostream& out() = 0;
|
||||
|
||||
//virtual bool begin(IStorable&) = 0;
|
||||
//virtual bool end(IStorable&) = 0;
|
||||
virtual bool visit(bool&) = 0;
|
||||
virtual bool visit(char&) = 0;
|
||||
virtual bool visit(short&) = 0;
|
||||
virtual bool visit(int&) = 0;
|
||||
virtual bool visit(unsigned int&) = 0;
|
||||
virtual bool visit(int64&) = 0;
|
||||
virtual bool visit(uint64&) = 0;
|
||||
virtual bool visit(float&) = 0;
|
||||
virtual bool visit(double&) = 0;
|
||||
virtual bool visit(std::string&) = 0;
|
||||
virtual bool visit(std::vector<bool>&) = 0;
|
||||
virtual bool visit(std::vector<char>&) = 0;
|
||||
virtual bool visit(std::vector<short>&) = 0;
|
||||
virtual bool visit(std::vector<int>&) = 0;
|
||||
virtual bool visit(std::vector<int64>&) = 0;
|
||||
virtual bool visit(std::vector<float>&) = 0;
|
||||
virtual bool visit(std::vector<double>&) = 0;
|
||||
virtual bool visit(std::vector<unsigned char>&) = 0;
|
||||
virtual bool visit(std::vector<std::string>&) = 0;
|
||||
virtual bool visit(std::vector< std::vector<double> >&) = 0;
|
||||
//virtual bool visit_double(IArray&) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,881 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_store_osc_streamers
|
||||
#define tools_store_osc_streamers
|
||||
|
||||
#include "iobj_const_visitor"
|
||||
#include "iobj_visitor"
|
||||
|
||||
#include "../histo/h1d"
|
||||
#include "../histo/h2d"
|
||||
#include "../histo/h3d"
|
||||
#include "../histo/p1d"
|
||||
#include "../histo/p2d"
|
||||
#include "../vmanip"
|
||||
#include "../sto"
|
||||
#include "../S_STRING"
|
||||
#include "../scast"
|
||||
|
||||
namespace tools {
|
||||
namespace osc {
|
||||
|
||||
inline const std::string& s_axis() {
|
||||
static const std::string s_v("BatchLab::Axis");
|
||||
return s_v;
|
||||
}
|
||||
inline const std::string& s_annotation() {
|
||||
static const std::string s_v("BatchLab::Annotation");
|
||||
return s_v;
|
||||
}
|
||||
inline const std::string& s_base_histogram() {
|
||||
static const std::string s_v("BatchLab::BaseHistogram");
|
||||
return s_v;
|
||||
}
|
||||
inline const std::string& s_item() {
|
||||
static const std::string s_v("BatchLab::Item");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_h1d() {
|
||||
static const std::string s_v("BatchLab::Histogram1D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_h2d() {
|
||||
static const std::string s_v("BatchLab::Histogram2D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_h3d() {
|
||||
static const std::string s_v("BatchLab::Histogram3D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_p1d() {
|
||||
static const std::string s_v("BatchLab::Profile1D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
inline const std::string& s_p2d() {
|
||||
static const std::string s_v("BatchLab::Profile2D");
|
||||
return s_v;
|
||||
}
|
||||
|
||||
class Axis : public virtual istorable {
|
||||
public:
|
||||
TOOLS_SCLASS(tools::osc::Axis)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<Axis>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
virtual const std::string& store_cls() const {return s_axis();}
|
||||
virtual bool visit(iobj_const_visitor& a_v) const {
|
||||
if(!a_v.begin(*this,s_axis(),Axis::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
if(!a_v.visit("fOffset",m_axis.m_offset)) return false;
|
||||
if(!a_v.visit("fNumberOfBins",(int)m_axis.m_number_of_bins)) return false;
|
||||
if(!a_v.visit("fMinimumValue",m_axis.m_minimum_value)) return false;
|
||||
if(!a_v.visit("fMaximumValue",m_axis.m_maximum_value)) return false;
|
||||
if(!a_v.visit("fFixed",m_axis.m_fixed)) return false;
|
||||
if(!a_v.visit("fBinWidth",m_axis.m_bin_width)) return false;
|
||||
if(!a_v.visit("fEdges",m_axis.m_edges)) return false;
|
||||
|
||||
if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const Axis* local = tools::safe_cast<istorable,Axis>(a_o);
|
||||
if(!local) return false;
|
||||
return local->Axis::visit(a_v); //IMPORTANT : have Axis::
|
||||
}
|
||||
public:
|
||||
Axis(const histo::axis<double>& a_axis):m_axis(a_axis){}
|
||||
virtual ~Axis(){}
|
||||
private:
|
||||
Axis(const Axis& a_from):istorable(a_from),m_axis(a_from.m_axis){}
|
||||
Axis& operator=(const Axis&){return *this;}
|
||||
protected:
|
||||
const histo::axis<double>& m_axis;
|
||||
};
|
||||
|
||||
|
||||
inline bool Axis_read(iobj_visitor& a_visitor,
|
||||
histo::axis<double>& a_axis){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(!a_visitor.visit(a_axis.m_offset)) return false;
|
||||
|
||||
{int nbin;
|
||||
if(!a_visitor.visit(nbin)) return false;
|
||||
a_axis.m_number_of_bins = nbin;}
|
||||
|
||||
if(!a_visitor.visit(a_axis.m_minimum_value)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_maximum_value)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_fixed)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_bin_width)) return false;
|
||||
if(!a_visitor.visit(a_axis.m_edges)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
class Item : public virtual istorable {
|
||||
public:
|
||||
TOOLS_SCLASS(tools::osc::Item)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<Item>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
virtual const std::string& store_cls() const {return s_item();}
|
||||
virtual bool visit(iobj_const_visitor& a_visitor) const {
|
||||
if(!a_visitor.begin(*this,s_item(),Item::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_visitor.visit("fVersion",version)) return false;
|
||||
|
||||
if(!a_visitor.visit("fKey",fKey)) return false;
|
||||
if(!a_visitor.visit("fValue",fValue)) return false;
|
||||
if(!a_visitor.visit("fSticky",fSticky)) return false;
|
||||
|
||||
if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const Item* local = tools::safe_cast<istorable,Item>(a_o);
|
||||
if(!local) return false;
|
||||
return local->Item::visit(a_v); //IMPORTANT : have Item::
|
||||
}
|
||||
public:
|
||||
virtual bool read(iobj_visitor& a_visitor) {
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(!a_visitor.visit(fKey)) return false;
|
||||
if(!a_visitor.visit(fValue)) return false;
|
||||
if(!a_visitor.visit(fSticky)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
Item(){}
|
||||
Item(const std::string& aKey,const std::string& aValue,bool aSticky)
|
||||
:fKey(aKey),fValue(aValue),fSticky(aSticky){}
|
||||
virtual ~Item(){}
|
||||
public:
|
||||
Item(const Item& aFrom)
|
||||
:istorable(aFrom)
|
||||
,fKey(aFrom.fKey)
|
||||
,fValue(aFrom.fValue)
|
||||
,fSticky(aFrom.fSticky)
|
||||
{}
|
||||
Item& operator=(const Item& aFrom) {
|
||||
fKey = aFrom.fKey;
|
||||
fValue = aFrom.fValue;
|
||||
fSticky = aFrom.fSticky;
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
std::string fKey;
|
||||
std::string fValue;
|
||||
bool fSticky;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class Vector : public virtual istorable {
|
||||
public:
|
||||
TOOLS_T_SCLASS(T,tools::osc::Vector)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<Vector>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
virtual const std::string& store_cls() const {
|
||||
static const std::string s_v("BatchLab::Vector<"+m_T+">");
|
||||
return s_v;
|
||||
}
|
||||
virtual bool visit(iobj_const_visitor& a_v) const {
|
||||
if(!a_v.begin
|
||||
(*this,Vector<T>::store_cls(),Vector<T>::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
unsigned int number = m_vec.size();
|
||||
if(!a_v.visit("fSize",number)) return false;
|
||||
|
||||
for(unsigned int index=0;index<number;index++) {
|
||||
const T& elem = m_vec[index];
|
||||
if(!a_v.visit(to<int>(index),elem)) return false;
|
||||
}
|
||||
|
||||
if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const Vector* local = tools::safe_cast<istorable,Vector>(a_o);
|
||||
if(!local) return false;
|
||||
return local->Vector<T>::visit(a_v); //IMPORTANT : have Vector::
|
||||
}
|
||||
public:
|
||||
Vector(const std::vector<T>& a_vec,const std::string& a_T)
|
||||
:m_vec(a_vec),m_T(a_T){}
|
||||
virtual ~Vector(){}
|
||||
private:
|
||||
Vector(const Vector& a_from)
|
||||
:istorable(a_from),m_vec(a_from.m_vec),m_T(a_from.m_T){}
|
||||
Vector& operator=(const Vector&){return *this;}
|
||||
protected:
|
||||
const std::vector<T>& m_vec;
|
||||
std::string m_T;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
inline bool std_vector_read(iobj_visitor& a_visitor,
|
||||
std::vector<T>& a_vec) {
|
||||
a_vec.clear();
|
||||
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
unsigned int number;
|
||||
if(!a_visitor.visit(number)) return false;
|
||||
|
||||
a_vec.resize(number);
|
||||
for(unsigned int index=0;index<number;index++) {
|
||||
T& elem = a_vec[index];
|
||||
if(!elem.read(a_visitor)) return false;
|
||||
}
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
class Annotation : public virtual istorable {
|
||||
public:
|
||||
TOOLS_SCLASS(tools::osc::Annotation)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<Annotation>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
virtual const std::string& store_cls() const {return s_annotation();}
|
||||
virtual bool visit(iobj_const_visitor& a_v) const {
|
||||
if(!a_v.begin(*this,s_annotation(),Annotation::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
Vector<Item> v(m_items,s_item());
|
||||
if(!a_v.visit("fItems",v)) return false;
|
||||
|
||||
if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const Annotation* local = tools::safe_cast<istorable,Annotation>(a_o);
|
||||
if(!local) return false;
|
||||
return local->Annotation::visit(a_v); //IMPORTANT : have Annotation::
|
||||
}
|
||||
public:
|
||||
Annotation(){}
|
||||
virtual ~Annotation(){}
|
||||
private:
|
||||
Annotation(const Annotation& a_from):istorable(a_from){}
|
||||
Annotation& operator=(const Annotation&){return *this;}
|
||||
public:
|
||||
std::vector<Item> m_items;
|
||||
};
|
||||
|
||||
inline bool Annotation_read(iobj_visitor& a_visitor) {
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
std::vector<Item> fItems;
|
||||
if(!std_vector_read<Item>(a_visitor,fItems)) return false;
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void map2vec(const std::map<std::string,std::string>& a_in,
|
||||
std::vector<Item>& a_out) {
|
||||
a_out.clear();
|
||||
std::map<std::string,std::string>::const_iterator it;
|
||||
for(it=a_in.begin();it!=a_in.end();++it) {
|
||||
a_out.push_back(Item((*it).first,(*it).second,false));
|
||||
}
|
||||
}
|
||||
|
||||
typedef histo::histo_data<double,unsigned int,double> hd_data;
|
||||
|
||||
class BaseHistogram : public virtual istorable {
|
||||
public:
|
||||
TOOLS_SCLASS(tools::osc::BaseHistogram)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<BaseHistogram>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
virtual const std::string& store_cls() const {return s_base_histogram();}
|
||||
virtual bool visit(iobj_const_visitor& a_v) const {
|
||||
if(!a_v.begin
|
||||
(*this,s_base_histogram(),BaseHistogram::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
Annotation ano;
|
||||
map2vec(m_data.m_annotations,ano.m_items);
|
||||
if(!a_v.visit("fAnnotation",ano)) return false;
|
||||
|
||||
if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
protected:
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const BaseHistogram* local =
|
||||
tools::safe_cast<istorable,BaseHistogram>(a_o);
|
||||
if(!local) return false;
|
||||
return local->BaseHistogram::visit(a_v); //IMPORTANT : have BaseHistogram::
|
||||
}
|
||||
public:
|
||||
BaseHistogram(const hd_data& a_data):m_data(a_data){}
|
||||
virtual ~BaseHistogram(){}
|
||||
private:
|
||||
BaseHistogram(const BaseHistogram& a_from)
|
||||
:istorable(a_from),m_data(a_from.m_data)
|
||||
{}
|
||||
BaseHistogram& operator=(const BaseHistogram&){return *this;}
|
||||
protected:
|
||||
const hd_data& m_data;
|
||||
};
|
||||
|
||||
inline bool BaseHistogram_read(iobj_visitor& a_visitor){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(!Annotation_read(a_visitor)) return false;
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visitHistogram(const hd_data& aData,
|
||||
iobj_const_visitor& a_visitor){
|
||||
if(!a_visitor.visit("fTitle",aData.m_title)) return false;
|
||||
if(!a_visitor.visit("fDimension",(int)aData.m_dimension)) return false;
|
||||
if(!a_visitor.visit("fBinNumber",(int)aData.m_bin_number)) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinEntries",
|
||||
convert<unsigned int,int>(aData.m_bin_entries))) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinSw",aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit("fBinSw2",aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit("fBinSxw",aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit("fBinSx2w",aData.m_bin_Sx2w)) return false;
|
||||
{for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
std::string name = "fAxes_" + to<int>(iaxis);
|
||||
Axis axis(aData.m_axes[iaxis]);
|
||||
if(!a_visitor.visit(name,axis)) return false;
|
||||
}}
|
||||
{int dummy = 0;
|
||||
if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
|
||||
if(!a_visitor.visit("fProfile",false)) return false;
|
||||
{std::vector<double> dummy;
|
||||
if(!a_visitor.visit("fBinSvw",dummy)) return false;
|
||||
if(!a_visitor.visit("fBinSv2w",dummy)) return false;}
|
||||
if(!a_visitor.visit("fCutV",false)) return false;
|
||||
{double dummy = 0;
|
||||
if(!a_visitor.visit("fMinV",dummy)) return false;
|
||||
if(!a_visitor.visit("fMaxV",dummy)) return false;}
|
||||
// Not written :
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool readHistogram(hd_data& aData,iobj_visitor& a_visitor){
|
||||
if(!a_visitor.visit(aData.m_title)) return false;
|
||||
{int dim;
|
||||
if(!a_visitor.visit(dim)) return false;
|
||||
aData.m_dimension = dim;}
|
||||
|
||||
{int nbin;
|
||||
if(!a_visitor.visit(nbin)) return false;
|
||||
aData.m_bin_number = nbin;}
|
||||
|
||||
{std::vector<int> vec;
|
||||
if(!a_visitor.visit(vec)) return false;
|
||||
aData.m_bin_entries = convert<int,unsigned int>(vec);}
|
||||
|
||||
if(!a_visitor.visit(aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
|
||||
aData.m_axes.clear();
|
||||
for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
histo::axis<double> baxis;
|
||||
if(!Axis_read(a_visitor,baxis)) return false;
|
||||
aData.m_axes.push_back(baxis);
|
||||
}
|
||||
{int dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_mode
|
||||
|
||||
{bool dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_is_profile
|
||||
|
||||
{std::vector<double> dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_bin_Svw
|
||||
|
||||
{std::vector<double> dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_bin_Sv2w
|
||||
|
||||
{bool dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_cut_v
|
||||
|
||||
{double dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //aData.m_min_v
|
||||
|
||||
{double dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //aData.m_max_v
|
||||
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
//aData.m_coords.resize(aData.m_dimension,0);
|
||||
//aData.m_ints.resize(aData.m_dimension,0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class Histogram : public virtual istorable {
|
||||
public:
|
||||
TOOLS_SCLASS(tools::osc::Histogram)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<Histogram>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
virtual const std::string& store_cls() const {return m_cls;}
|
||||
virtual bool visit(iobj_const_visitor& a_v) const {
|
||||
if(!a_v.begin(*this,m_cls,Histogram::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
BaseHistogram bh(m_data);
|
||||
if(!bh.visit(a_v)) return false;
|
||||
|
||||
if(!visitHistogram(m_data,a_v)) return false;
|
||||
|
||||
if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
protected:
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const Histogram* local = tools::safe_cast<istorable,Histogram>(a_o);
|
||||
if(!local) return false;
|
||||
return local->Histogram::visit(a_v); //IMPORTANT : have Histogram::
|
||||
}
|
||||
public:
|
||||
Histogram(const hd_data& a_data,const std::string& a_cls)
|
||||
:m_data(a_data),m_cls(a_cls){}
|
||||
virtual ~Histogram(){}
|
||||
public:
|
||||
Histogram(const Histogram& a_from)
|
||||
:istorable(a_from)
|
||||
,m_data(a_from.m_data)
|
||||
,m_cls(a_from.m_cls)
|
||||
{}
|
||||
Histogram& operator=(const Histogram& a_from){
|
||||
m_cls = a_from.m_cls;
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
const hd_data& m_data;
|
||||
std::string m_cls;
|
||||
};
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_v,const histo::h1d& a_histo) {
|
||||
hd_data d = a_histo.get_histo_data();
|
||||
Histogram h(d,s_h1d());
|
||||
return h.visit(a_v);
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::h1d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
hd_data hdata;
|
||||
if(!readHistogram(hdata,a_visitor)) return false;
|
||||
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxis.copy(fHistogram.get_axis(0));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_v,const histo::h2d& a_histo) {
|
||||
hd_data d = a_histo.get_histo_data();
|
||||
Histogram h(d,s_h2d());
|
||||
return h.visit(a_v);
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::h2d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
hd_data hdata;
|
||||
if(!readHistogram(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxisX.copy(fHistogram.get_axis(0));
|
||||
//fAxisY.copy(fHistogram.get_axis(1));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_v,const histo::h3d& a_histo) {
|
||||
hd_data d = a_histo.get_histo_data();
|
||||
Histogram h(d,s_h3d());
|
||||
return h.visit(a_v);
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::h3d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
hd_data hdata;
|
||||
if(!readHistogram(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxisX.copy(fHistogram.get_axis(0));
|
||||
//fAxisY.copy(fHistogram.get_axis(1));
|
||||
//fAxisZ.copy(fHistogram.get_axis(2));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef histo::profile_data<double,unsigned int,double,double> pd_data;
|
||||
|
||||
inline bool visitProfile(const pd_data& aData,
|
||||
iobj_const_visitor& a_visitor){
|
||||
if(!a_visitor.visit("fTitle",aData.m_title)) return false;
|
||||
if(!a_visitor.visit("fDimension",(int)aData.m_dimension)) return false;
|
||||
if(!a_visitor.visit("fBinNumber",(int)aData.m_bin_number)) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinEntries",
|
||||
convert<unsigned int,int>(aData.m_bin_entries))) return false;
|
||||
|
||||
if(!a_visitor.visit("fBinSw",aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit("fBinSw2",aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit("fBinSxw",aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit("fBinSx2w",aData.m_bin_Sx2w)) return false;
|
||||
for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
std::string name = "fAxes_" + to<int>(iaxis);
|
||||
Axis axis(aData.m_axes[iaxis]);
|
||||
if(!a_visitor.visit(name,axis)) return false;
|
||||
}
|
||||
{int dummy = 0;
|
||||
if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
|
||||
if(!a_visitor.visit("fProfile",true)) return false;
|
||||
if(!a_visitor.visit("fBinSvw",aData.m_bin_Svw)) return false;
|
||||
if(!a_visitor.visit("fBinSv2w",aData.m_bin_Sv2w)) return false;
|
||||
if(!a_visitor.visit("fCutV",aData.m_cut_v)) return false;
|
||||
if(!a_visitor.visit("fMinV",aData.m_min_v)) return false;
|
||||
if(!a_visitor.visit("fMaxV",aData.m_max_v)) return false;
|
||||
// Not written :
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
return true;
|
||||
}
|
||||
|
||||
class Profile : public virtual istorable {
|
||||
public:
|
||||
TOOLS_SCLASS(tools::osc::Profile)
|
||||
protected:
|
||||
virtual void* cast(const std::string& a_class) const {
|
||||
if(void* p = tools::cmp_cast<Profile>(this,a_class)) return p;
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
virtual const std::string& store_cls() const {return m_cls;}
|
||||
virtual bool visit(iobj_const_visitor& a_v) const {
|
||||
if(!a_v.begin(*this,m_cls,Profile::s_visit)) return false;
|
||||
|
||||
int version = 1;
|
||||
if(!a_v.visit("fVersion",version)) return false;
|
||||
|
||||
BaseHistogram bh(m_data);
|
||||
if(!bh.visit(a_v)) return false;
|
||||
|
||||
if(!visitProfile(m_data,a_v)) return false;
|
||||
|
||||
if(!a_v.end(*this)) return false;
|
||||
return true;
|
||||
}
|
||||
protected:
|
||||
static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
|
||||
const Profile* local = tools::safe_cast<istorable,Profile>(a_o);
|
||||
if(!local) return false;
|
||||
return local->Profile::visit(a_v); //IMPORTANT : have Profile::
|
||||
}
|
||||
public:
|
||||
Profile(const pd_data& a_data,const std::string& a_cls)
|
||||
:m_data(a_data),m_cls(a_cls){}
|
||||
virtual ~Profile(){}
|
||||
public:
|
||||
Profile(const Profile& a_from)
|
||||
:istorable(a_from)
|
||||
,m_data(a_from.m_data)
|
||||
,m_cls(a_from.m_cls)
|
||||
{}
|
||||
Profile& operator=(const Profile& a_from){
|
||||
m_cls = a_from.m_cls;
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
const pd_data& m_data;
|
||||
std::string m_cls;
|
||||
};
|
||||
|
||||
inline bool readProfile(pd_data& aData,iobj_visitor& a_visitor){
|
||||
if(!a_visitor.visit(aData.m_title)) return false;
|
||||
|
||||
{int dim;
|
||||
if(!a_visitor.visit(dim)) return false;
|
||||
aData.m_dimension = dim;}
|
||||
|
||||
{int nbin;
|
||||
if(!a_visitor.visit(nbin)) return false;
|
||||
aData.m_bin_number = nbin;}
|
||||
|
||||
{std::vector<int> vec;
|
||||
if(!a_visitor.visit(vec)) return false;
|
||||
aData.m_bin_entries = convert<int,unsigned int>(vec);}
|
||||
|
||||
if(!a_visitor.visit(aData.m_bin_Sw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
|
||||
aData.m_axes.clear();
|
||||
for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
|
||||
histo::axis<double> baxis;
|
||||
if(!Axis_read(a_visitor,baxis)) return false;
|
||||
aData.m_axes.push_back(baxis);
|
||||
}
|
||||
{int dummy;
|
||||
if(!a_visitor.visit(dummy)) return false;} //m_mode
|
||||
if(!a_visitor.visit(aData.m_is_profile)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Svw)) return false;
|
||||
if(!a_visitor.visit(aData.m_bin_Sv2w)) return false;
|
||||
if(!a_visitor.visit(aData.m_cut_v)) return false;
|
||||
if(!a_visitor.visit(aData.m_min_v)) return false;
|
||||
if(!a_visitor.visit(aData.m_max_v)) return false;
|
||||
|
||||
// Not written :
|
||||
//aData.fDoubles
|
||||
//aData.fInts
|
||||
//aData.m_coords.resize(aData.m_dimension,0);
|
||||
//aData.m_ints.resize(aData.m_dimension,0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_v,const histo::p1d& a_histo) {
|
||||
pd_data d = a_histo.get_histo_data();
|
||||
Profile h(d,s_p1d());
|
||||
return h.visit(a_v);
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::p1d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
pd_data hdata;
|
||||
if(!readProfile(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxis.copy(fHistogram.get_axis(0));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool visit(iobj_const_visitor& a_v,const histo::p2d& a_histo) {
|
||||
pd_data d = a_histo.get_histo_data();
|
||||
Profile h(d,s_p2d());
|
||||
return h.visit(a_v);
|
||||
}
|
||||
|
||||
inline bool read(iobj_visitor& a_visitor,histo::p2d& a_histo){
|
||||
//if(!a_visitor.begin(*this)) return false;
|
||||
|
||||
int version;
|
||||
if(!a_visitor.visit(version)) return false;
|
||||
|
||||
if(version!=1) {
|
||||
//this may come from an unexpected byteswap.
|
||||
a_visitor.out() << "tools::osc::read :"
|
||||
<< " unexpected version " << version
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!BaseHistogram_read(a_visitor)) return false;
|
||||
|
||||
pd_data hdata;
|
||||
if(!readProfile(hdata,a_visitor)) return false;
|
||||
a_histo.copy_from_data(hdata);
|
||||
|
||||
//fAxisX.copy(a_histo.get_axis(0));
|
||||
//fAxisY.copy(a_histo.get_axis(1));
|
||||
|
||||
//if(!a_visitor.end(*this)) return false;
|
||||
|
||||
a_histo.update_fast_getters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
class Histogram_cp : public Histogram {
|
||||
public:
|
||||
Histogram_cp(const hd_data& a_data,const std::string& a_cls)
|
||||
:Histogram(m_cp,a_cls) //give ref of m_cp to Histogram.
|
||||
,m_cp(a_data) //do a local copy.
|
||||
//WARNING : the upper is ok as long as Histogram constructor does nothing
|
||||
// else than keeping the ref to m_cp. Else it would do
|
||||
// something on an empty histo (and not on a copy of the
|
||||
// passed a_data).
|
||||
{}
|
||||
virtual ~Histogram_cp(){}
|
||||
public:
|
||||
Histogram_cp(const Histogram_cp& a_from)
|
||||
:istorable(a_from)
|
||||
,Histogram(m_cp,a_from.m_cls)
|
||||
,m_cp(a_from.m_cp)
|
||||
{}
|
||||
Histogram_cp& operator=(const Histogram_cp& a_from){
|
||||
Histogram::operator=(a_from);
|
||||
m_cp = a_from.m_cp;
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
hd_data m_cp;
|
||||
};
|
||||
|
||||
class Profile_cp : public Profile {
|
||||
public:
|
||||
Profile_cp(const pd_data& a_data,const std::string& a_cls)
|
||||
:Profile(m_cp,a_cls) //give ref of m_cp to Profile.
|
||||
,m_cp(a_data) //do a local copy.
|
||||
//WARNING : the upper is ok as long as Profile constructor does nothing
|
||||
// else than keeping the ref to m_cp. Else it would do
|
||||
// something on an empty histo (and not on a copy of the
|
||||
// passed a_data).
|
||||
{}
|
||||
virtual ~Profile_cp(){}
|
||||
public:
|
||||
Profile_cp(const Profile_cp& a_from)
|
||||
:istorable(a_from)
|
||||
,Profile(m_cp,a_from.m_cls)
|
||||
,m_cp(a_from.m_cp)
|
||||
{}
|
||||
Profile_cp& operator=(const Profile_cp& a_from){
|
||||
Profile::operator=(a_from);
|
||||
m_cp = a_from.m_cp;
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
pd_data m_cp;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -11,38 +11,41 @@ namespace tools {
|
||||
|
||||
enum what { leading, trailing, both };
|
||||
|
||||
inline void strip(std::string& a_string,what a_type = both,char a_char = ' '){
|
||||
inline bool strip(std::string& a_string,what a_type = both,char a_char = ' '){
|
||||
//return true = some stripping had been done.
|
||||
|
||||
std::string::size_type l = a_string.length();
|
||||
if(l==0) return;
|
||||
if(l==0) return false;
|
||||
|
||||
switch ( a_type ) {
|
||||
case leading:{
|
||||
std::string::size_type i;
|
||||
char* pos = (char*)a_string.c_str();
|
||||
for(i=0;i<l;i++,pos++) {
|
||||
for(std::string::size_type i=0;i<l;i++,pos++) {
|
||||
if(*pos!=a_char) {
|
||||
a_string = a_string.substr(i,l-i);
|
||||
return;
|
||||
return (i?true:false); //i=0 : same string.
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case trailing:{
|
||||
std::string::size_type i;
|
||||
char* pos = (char*)a_string.c_str();
|
||||
pos += (l-1);
|
||||
for(i=l-1;;i--,pos--) {
|
||||
for(std::string::size_type i=l-1;;i--,pos--) {
|
||||
if(*pos!=a_char) {
|
||||
a_string = a_string.substr(0,i+1);
|
||||
return;
|
||||
return (i==(l-1)?false:true); //i==l-1 : same string.
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case both:
|
||||
strip(a_string,leading,a_char);
|
||||
strip(a_string,trailing,a_char);
|
||||
break;
|
||||
case both:{
|
||||
bool stat_lead = strip(a_string,leading,a_char);
|
||||
bool stat_trail = strip(a_string,trailing,a_char);
|
||||
if(stat_lead) return true;
|
||||
if(stat_trail) return true;
|
||||
}break;
|
||||
//default:break;
|
||||
}
|
||||
return false; //nothing done.
|
||||
}
|
||||
|
||||
inline std::string strp(const std::string& a_string,what a_type = both,char a_char = ' '){
|
||||
@@ -51,11 +54,13 @@ inline std::string strp(const std::string& a_string,what a_type = both,char a_ch
|
||||
return s;
|
||||
}
|
||||
|
||||
inline void strip(std::vector<std::string>& a_strings,what a_type = both,char a_char = ' ') {
|
||||
inline bool strip(std::vector<std::string>& a_strings,what a_type = both,char a_char = ' ') {
|
||||
bool some_done = false;
|
||||
std::vector<std::string>::iterator it;
|
||||
for(it=a_strings.begin();it!=a_strings.end();++it) {
|
||||
strip(*it,a_type,a_char);
|
||||
if(strip(*it,a_type,a_char)) some_done = true;
|
||||
}
|
||||
return some_done;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -111,6 +111,15 @@ inline std::string tos(const std::vector<T>& a_vals,
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string tos(unsigned int a_linen,const char* a_lines[]) {
|
||||
std::string s;
|
||||
for(unsigned int index=0;index<a_linen;index++) {
|
||||
s += std::string(a_lines[index]);
|
||||
s += "\n";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+7
@@ -82,6 +82,13 @@ typedef const char* const_cstr_t;
|
||||
class fits_bit {public:char m_c;}; //for exlib/cfitsio
|
||||
class csv_time {public:long m_l;}; //for inlib/rcsv_ntuple
|
||||
|
||||
inline unsigned int size_char() {return 1;}
|
||||
inline unsigned int size_short() {return 2;}
|
||||
inline unsigned int size_int() {return 4;}
|
||||
inline unsigned int size_int64() {return 8;}
|
||||
inline unsigned int size_float() {return 4;}
|
||||
inline unsigned int size_double() {return 8;}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_version
|
||||
#define tools_version
|
||||
|
||||
#define TOOLS_MAJOR_VERSION 1
|
||||
#define TOOLS_MINOR_VERSION 7
|
||||
#define TOOLS_PATCH_VERSION 0
|
||||
#define TOOLS_VERSION "1.7.0"
|
||||
#define TOOLS_VERSION_VRP "v1r7p0"
|
||||
|
||||
namespace tools {
|
||||
inline unsigned int version() {return 10700;}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -53,6 +53,17 @@ inline void append(std::vector<T>& a_vec,const std::vector<T>& a_from) {
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void append(std::vector<T>& a_vec,unsigned int a_num,const T* a_from) {
|
||||
typedef typename std::vector<T>::size_type sz_t;
|
||||
sz_t vsize = a_vec.size();
|
||||
a_vec.resize(vsize+a_num);
|
||||
sz_t offset = vsize;
|
||||
for(sz_t index=0;index<a_num;index++,offset++) {
|
||||
a_vec[offset] = a_from[index];
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void removep(std::vector<T*>& a_vec,T* a_elem) {
|
||||
typedef typename std::vector<T*>::iterator it_t;
|
||||
@@ -127,6 +138,16 @@ inline bool item_index(const std::vector<T>& a_vec,const T& a_item,unsigned int&
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool belong(const std::vector<T>& a_vec,const T& a_item){
|
||||
typedef typename std::vector<T>::const_iterator it_t;
|
||||
it_t it;
|
||||
for(it=a_vec.begin();it!=a_vec.end();++it) {
|
||||
if(*it==a_item) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool minimum(const std::vector<T>& a_vec,T& a_value) {
|
||||
if(a_vec.empty()) {a_value = T();return false;}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user