Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
-1
View File
@@ -7,7 +7,6 @@
#
# Created on : 15/07/2013
#
# $Id: CMakeLists.txt 72292 2013-07-15 12:01:43Z ihrivnac $
#
#------------------------------------------------------------------------------
-1
View File
@@ -1,4 +1,3 @@
# $Id: GNUmakefile 66356 2012-12-18 09:02:32Z gcosmo $
# --------------------------------------------------------------------
# GNUmakefile for analysis/root sub-library.
# --------------------------------------------------------------------
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisManager.hh 106985 2017-10-31 10:07:18Z gcosmo $
// The main manager for Root analysis.
// It delegates most of functions to the object specific managers.
@@ -60,6 +59,8 @@ enum class G4NtupleMergeMode {
class G4RootAnalysisManager : public G4ToolsAnalysisManager
{
friend class G4RootMpiAnalysisManager;
public:
explicit G4RootAnalysisManager(G4bool isMaster = true);
virtual ~G4RootAnalysisManager();
@@ -81,15 +82,19 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
// MT/MPI
void SetNtupleMerging(G4bool mergeNtuples,
G4int nofReducedNtupleFiles = 0,
G4bool rowWise = 0,
G4bool rowWise = true,
unsigned int basketSize = fgkDefaultBasketSize);
void SetNtupleRowWise(G4bool rowWise);
protected:
// virtual methods from base class
virtual G4bool OpenFileImpl(const G4String& fileName) final;
virtual G4bool OpenFileImpl(const G4String& fileName) override;
virtual G4bool WriteImpl() final;
virtual G4bool CloseFileImpl() final;
virtual G4bool CloseFileImpl(G4bool reset) override;
virtual G4bool IsOpenFileImpl() const final;
// virtual functions (overriden in MPI implementation)
virtual G4bool WriteNtuple();
virtual G4bool Reset();
private:
// constants
@@ -100,10 +105,13 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
static G4ThreadLocal G4RootAnalysisManager* fgInstance;
// methods
void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles);
void SetNtupleMergingMode(G4bool mergeNtuples,
G4int nofNtupleFiles,
G4bool rowWise);
void ClearNtupleManagers();
void CreateNtupleManagers();
G4int GetNtupleFileNumber();
G4bool ResetNtuple();
template <typename T>
G4bool WriteT(const std::vector<T*>& htVector,
@@ -115,8 +123,6 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
G4bool WriteH3();
G4bool WriteP1();
G4bool WriteP2();
G4bool WriteNtuple();
G4bool Reset();
// data members
G4int fNofNtupleFiles;
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
#include "G4RootNtupleManager.hh"
#include "G4RootFileManager.hh"
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisReader.hh 74257 2013-10-02 14:24:55Z gcosmo $
// The main manager for Root analysis reader.
// It delegates most of functions to the object specific managers.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisReader.hh 70604 2013-06-03 11:27:06Z ihrivnac $
#include "G4RootRNtupleManager.hh"
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootFileManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
// The manager for Root output file operations.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id:$
// Class for Root main ntuple management.
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
// Manager class for Root ntuples.
// It implements functions specific to Root ntuples.
@@ -67,11 +66,13 @@ class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
{
friend class G4RootAnalysisManager;
friend class G4RootMainNtupleManager;
friend class G4RootMpiAnalysisManager;
friend class G4RootMpiNtupleManager;
public:
explicit G4RootNtupleManager(const G4AnalysisManagerState& state,
G4int nofMainManagers = 0,
G4bool rowWise = true);
explicit G4RootNtupleManager(const G4AnalysisManagerState& state,
G4int nofMainManagers,
G4bool rowWise);
virtual ~G4RootNtupleManager();
private:
@@ -93,13 +94,14 @@ class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
NtupleDescriptionType* ntupleDescription) final;
virtual void FinishTNtuple(
NtupleDescriptionType* ntupleDescription) final;
NtupleDescriptionType* ntupleDescription,
G4bool fromBooking) final;
virtual G4bool Reset(G4bool deleteNtuple);
// Method for merging
//
G4bool Merge();
virtual G4bool Merge();
// Access functions
//
@@ -117,6 +119,7 @@ class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
std::shared_ptr<G4RootFileManager> fFileManager;
tools::wroot::directory* fNtupleDirectory;
std::vector<G4RootMainNtupleManager*> fMainNtupleManagers;
G4bool fRowWise;
};
// inline functions
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// Structure containing the information related to Root pntuple.
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id:$
// Class for Root pntuple management.
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootRFileManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
// The manager for Root file input operations.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootRNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
// Manager class for Root read ntuples.
// It implements functions specific to Root read ntuples.
-1
View File
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: g4root.hh 72292 2013-07-15 12:01:43Z ihrivnac $
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: g4root_defs.hh 92688 2015-09-14 07:01:13Z gcosmo $
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
-1
View File
@@ -11,7 +11,6 @@
#
# Generated on : 15/07/2013
#
# $Id: sources.cmake 105338 2017-07-21 09:14:27Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisManager.cc 106985 2017-10-31 10:07:18Z gcosmo $
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
@@ -80,7 +79,7 @@ G4bool G4RootAnalysisManager::IsInstance()
G4RootAnalysisManager::G4RootAnalysisManager(G4bool isMaster)
: G4ToolsAnalysisManager("Root", isMaster),
fNofNtupleFiles(0),
fNtupleRowWise(true),
fNtupleRowWise(false),
fNtupleMergeMode(G4NtupleMergeMode::kNone),
fNtupleManager(nullptr),
fSlaveNtupleManager(nullptr),
@@ -107,7 +106,7 @@ G4RootAnalysisManager::G4RootAnalysisManager(G4bool isMaster)
// Merging may require user code migration as analysis manager
// must be created both on master and workers.
auto mergeNtuples = false;
SetNtupleMergingMode(mergeNtuples, fNofNtupleFiles);
SetNtupleMergingMode(mergeNtuples, fNofNtupleFiles, fNtupleRowWise);
// Create ntuple managers
CreateNtupleManagers();
@@ -126,7 +125,8 @@ G4RootAnalysisManager::~G4RootAnalysisManager()
//_____________________________________________________________________________
void G4RootAnalysisManager::SetNtupleMergingMode(G4bool mergeNtuples,
G4int nofNtupleFiles)
G4int nofNtupleFiles,
G4bool rowWise)
{
#ifdef G4VERBOSE
@@ -167,12 +167,12 @@ void G4RootAnalysisManager::SetNtupleMergingMode(G4bool mergeNtuples,
G4String mergingMode;
if ( ( ! mergeNtuples ) || ( ! canMerge ) ) {
fNtupleMergeMode = G4NtupleMergeMode::kNone;
mergingMode = "G4NtupleMergeMode::kNone";
mergingMode = "G4NtupleMergeMode::kNone";
}
else {
// Set the number of reduced ntuple files
// G4int nofThreads = G4Threading::GetNumberOfThreads();
fNofNtupleFiles = nofNtupleFiles;
fNtupleRowWise = rowWise;
// Check the number of reduced ntuple files
// if ( fNofNtupleFiles < 0 || fNofNtupleFiles > nofThreads ) {
@@ -260,7 +260,7 @@ void G4RootAnalysisManager::CreateNtupleManagers()
switch ( fNtupleMergeMode )
{
case G4NtupleMergeMode::kNone:
fNtupleManager = new G4RootNtupleManager(fState);
fNtupleManager = new G4RootNtupleManager(fState, 0, fNtupleRowWise);
fNtupleManager->SetFileManager(fFileManager);
SetNtupleManager(fNtupleManager);
break;
@@ -466,6 +466,22 @@ G4bool G4RootAnalysisManager::WriteNtuple()
return finalResult;
}
//_____________________________________________________________________________
G4bool G4RootAnalysisManager::ResetNtuple()
{
// Reset histograms and ntuple
auto finalResult = true;
if ( fNtupleMergeMode == G4NtupleMergeMode::kNone ||
fNtupleMergeMode == G4NtupleMergeMode::kMain ) {
auto result = fNtupleManager->Reset(false);
finalResult = result && finalResult;
}
return finalResult;
}
//_____________________________________________________________________________
G4bool G4RootAnalysisManager::Reset()
{
@@ -476,13 +492,8 @@ G4bool G4RootAnalysisManager::Reset()
auto result = G4ToolsAnalysisManager::Reset();
finalResult = finalResult && result;
if ( fNtupleMergeMode == G4NtupleMergeMode::kNone ||
fNtupleMergeMode == G4NtupleMergeMode::kMain ) {
result = fNtupleManager->Reset(false);
finalResult = result && finalResult;
}
finalResult = finalResult && result;
result = ResetNtuple();
finalResult = result && finalResult;
return finalResult;
}
@@ -510,6 +521,7 @@ G4bool G4RootAnalysisManager::OpenFileImpl(const G4String& fileName)
finalResult = finalResult && result;
fNtupleManager->SetNtupleDirectory(fFileManager->GetNtupleDirectory());
fNtupleManager->CreateNtuplesFromBooking();
#ifdef G4VERBOSE
@@ -607,7 +619,7 @@ G4bool G4RootAnalysisManager::WriteImpl()
}
//_____________________________________________________________________________
G4bool G4RootAnalysisManager::CloseFileImpl()
G4bool G4RootAnalysisManager::CloseFileImpl(G4bool reset)
{
auto finalResult = true;
@@ -615,13 +627,18 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
// the ntuple decription vector is cleared on Reset()
// in kNoMergeAfterOpen ntuple manager mode
// reset data
auto result = Reset();
auto result = true;
if ( reset ) {
result = Reset();
} else {
// ntuple must be reset
result = ResetNtuple();
}
if ( ! result ) {
G4ExceptionDescription description;
description << " " << "Resetting data failed";
G4Exception("G4RootAnalysisManager::Write()",
"Analysis_W021", JustWarning, description);
G4ExceptionDescription description;
description << " " << "Resetting data failed";
G4Exception("G4RootAnalysisManager::CloseFile()",
"Analysis_W021", JustWarning, description);
}
finalResult = finalResult && result;
@@ -672,10 +689,9 @@ void G4RootAnalysisManager::SetNtupleMerging(G4bool mergeNtuples,
{
// Keep basketSize in file manager
fFileManager->SetBasketSize(basketSize);
fNtupleRowWise = rowWise;
// Set ntuple merging mode
SetNtupleMergingMode(mergeNtuples, nofNtupleFiles);
SetNtupleMergingMode(mergeNtuples, nofNtupleFiles, rowWise);
// Clear existing managers
ClearNtupleManagers();
@@ -683,3 +699,19 @@ void G4RootAnalysisManager::SetNtupleMerging(G4bool mergeNtuples,
// Re-create managers
CreateNtupleManagers();
}
//_____________________________________________________________________________
void G4RootAnalysisManager::SetNtupleRowWise(G4bool rowWise)
{
// Do nothing if the mode is not changed
if ( fNtupleRowWise == rowWise ) return;
fNtupleRowWise = rowWise;
// Clear existing managers
ClearNtupleManagers();
// Re-create managers
CreateNtupleManagers();
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisReader.cc 74257 2013-10-02 14:24:55Z gcosmo $
// Author: Ivana Hrivnacova, 09/04/2014 (ivana@ipno.in2p3.fr)
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootFileManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
//
// Author: Ivana Hrivnacova, 04/10/2016 (ivana@ipno.in2p3.fr)
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootNtupleManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
@@ -45,7 +44,8 @@ G4RootNtupleManager::G4RootNtupleManager(const G4AnalysisManagerState& state,
fCreateMode(G4NtupleCreateMode::kUndefined),
fFileManager(nullptr),
fNtupleDirectory(nullptr),
fMainNtupleManagers()
fMainNtupleManagers(),
fRowWise(rowWise)
{
for ( G4int i=0; i<nofMainManagers; ++i) {
fMainNtupleManagers.push_back(
@@ -64,7 +64,8 @@ G4RootNtupleManager::~G4RootNtupleManager()
//_____________________________________________________________________________
void G4RootNtupleManager::SetCreateMode()
{
// Set create mode if not yet defined
// Set create mode if not yet defined, or reset it if ntuples are defined both
// before and after open file
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
@@ -93,6 +94,18 @@ void G4RootNtupleManager::SetCreateMode()
}
}
}
if ( fCreateMode == G4NtupleCreateMode::kNoMergeBeforeOpen &&
fFileManager->GetNtupleFile(0) ) {
fCreateMode = G4NtupleCreateMode::kNoMergeAfterOpen;
createMode = "G4NtupleCreateMode::kNoMergeAfterOpen";
}
if ( fCreateMode == G4NtupleCreateMode::kMainBeforeOpen &&
fFileManager->GetNtupleFile(0) ) {
fCreateMode = G4NtupleCreateMode::kMainAfterOpen;
createMode = "G4NtupleCreateMode::kMainAfterOpen";
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() )
@@ -116,7 +129,7 @@ void G4RootNtupleManager::CreateTNtuple(
ntupleDescription->fNtuple
= new tools::wroot::ntuple(
*fNtupleDirectory, ntupleDescription->fNtupleBooking);
*fNtupleDirectory, ntupleDescription->fNtupleBooking, fRowWise);
auto basketSize = fFileManager->GetBasketSize();
ntupleDescription->fNtuple->set_basket_size(basketSize);
@@ -150,12 +163,15 @@ void G4RootNtupleManager::CreateTNtupleFromBooking(
//_____________________________________________________________________________
void G4RootNtupleManager::FinishTNtuple(
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription)
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription,
G4bool fromBooking)
{
// Create main ntuples
// Set create mode if not yet defined
SetCreateMode();
if ( ! fromBooking ) {
SetCreateMode();
}
// Create ntuple if file is open
if ( fCreateMode == G4NtupleCreateMode::kNoMergeAfterOpen ) {
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
//
// Author: Ivana Hrivnacova, 04/10/2016 (ivana@ipno.in2p3.fr)
@@ -36,9 +35,8 @@
// mutex in a file scope
namespace {
//Mutex to lock master manager when adding ntuple row
G4Mutex addRowMutex = G4MUTEX_INITIALIZER;
G4Mutex endFillMutex = G4MUTEX_INITIALIZER;
//Mutex to lock master manager when adding ntuple row and ending fill
G4Mutex pntupleMutex = G4MUTEX_INITIALIZER;
}
//_____________________________________________________________________________
@@ -366,7 +364,7 @@ G4bool G4RootPNtupleManager::AddNtupleRow(G4int ntupleId)
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "AddNtupleRow");
if ( ! ntupleDescription ) return false;
G4AutoLock lock(&addRowMutex);
G4AutoLock lock(&pntupleMutex);
lock.unlock();
mutex toolsLock(lock);
auto result
@@ -407,7 +405,7 @@ G4bool G4RootPNtupleManager::Merge()
}
#endif
G4AutoLock lock(&endFillMutex);
G4AutoLock lock(&pntupleMutex);
lock.unlock();
mutex toolsLock(lock);
auto result
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootRFileManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 10/09/2014 (ivana@ipno.in2p3.fr)
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootRNtupleManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
// Author: Ivana Hrivnacova, 09/04/2014 (ivana@ipno.in2p3.fr)