Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
+17 -2
View File
@@ -1,4 +1,4 @@
$Id: History 102848 2017-02-27 13:09:25Z gcosmo $
$Id: History 103532 2017-04-13 14:00:35Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,7 +17,22 @@ committal in the SVN repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
February 24, 2017 I. Hrivnacova (analysis-V10-02-26)
April 12, 2017 I. Hrivnacova (analysis-V10-03-03)
- Corrected handling of open file failure
(This fixes problem report #1957.)
March 14, 2017 I. Hrivnacova (analysis-V10-03-02)
- Added GetP[1,2]Id(const G4String&) functions to
the G4AnaysisManager public interface.
(This fixes problem report #1949.)
March 03, 2017 I. Hrivnacova (analysis-V10-03-01)
- Fixed problem of removing non-empty ntuple files
in user application where ntuples are created after
open file.
(This mode is used in dna examples, eg. dnaphysics.)
February 24, 2017 I. Hrivnacova (analysis-V10-03-00)
- Restored clean-up of Root empty files in MT mode
(which was lost with previous updates)
+1 -1
View File
@@ -7,7 +7,7 @@
#
# Created on : 15/07/2013
#
# $Id: CMakeLists.txt 92606 2015-09-08 12:34:01Z ihrivnac $
# $Id: CMakeLists.txt 99561 2016-09-27 07:04:12Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -47,6 +47,9 @@ G4bool G4CsvAnalysisManager::WriteT(const std::vector<tools::histo::p1d*>& htVec
auto fileName = fFileManager->GetHnFileName(hnType, name);
std::ofstream hnFile(fileName);
// Do nothing if there is no file
if ( ! hnFile.is_open() ) return false;
auto result
= tools::wcsv::pto(hnFile, ht->s_cls(), *ht);
@@ -85,6 +88,9 @@ G4bool G4CsvAnalysisManager::WriteT(const std::vector<tools::histo::p2d*>& htVec
auto fileName = fFileManager->GetHnFileName(hnType, name);
std::ofstream hnFile(fileName);
// Do nothing if there is no file
if ( ! hnFile.is_open() ) return false;
auto result
= tools::wcsv::pto(hnFile, ht->s_cls(), *ht);
@@ -123,6 +129,9 @@ G4bool G4CsvAnalysisManager::WriteT(const std::vector<T*>& htVector,
auto fileName = fFileManager->GetHnFileName(hnType, name);
std::ofstream hnFile(fileName);
// Do nothing if there is no file
if ( ! hnFile.is_open() ) return false;
auto result
= tools::wcsv::hto(hnFile, ht->s_cls(), *ht);
if ( ! result ) {
@@ -85,6 +85,7 @@ G4bool G4CsvFileManager::CreateNtupleFile(
auto ntupleFile = new std::ofstream(GetNtupleFileName(ntupleName));
if ( ntupleFile->fail() ) {
delete ntupleFile;
G4ExceptionDescription description;
description << " " << "Cannot open file "
<< GetNtupleFileName(ntupleName);
@@ -107,6 +108,9 @@ G4bool G4CsvFileManager::CreateNtupleFile(
G4bool G4CsvFileManager::CloseNtupleFile(
G4TNtupleDescription<tools::wcsv::ntuple>* ntupleDescription)
{
// Do nothing if there is no file
if ( ! ntupleDescription->fFile ) return true;
G4String ntupleName = ntupleDescription->fNtupleBooking.name();
#ifdef G4VERBOSE
@@ -404,6 +404,8 @@ class G4VAnalysisManager
G4int GetH1Id(const G4String& name, G4bool warn = true) const;
G4int GetH2Id(const G4String& name, G4bool warn = true) const;
G4int GetH3Id(const G4String& name, G4bool warn = true) const;
G4int GetP1Id(const G4String& name, G4bool warn = true) const;
G4int GetP2Id(const G4String& name, G4bool warn = true) const;
// Methods to manipulate histogram, profiles & ntuples additional information
//
@@ -177,6 +177,20 @@ G4int G4VAnalysisManager::GetH3Id(const G4String& name, G4bool warn) const
return fVH3Manager->GetH3Id(name, warn);
}
//_____________________________________________________________________________
inline
G4int G4VAnalysisManager::GetP1Id(const G4String& name, G4bool warn) const
{
return fVP1Manager->GetP1Id(name, warn);
}
//_____________________________________________________________________________
inline
G4int G4VAnalysisManager::GetP2Id(const G4String& name, G4bool warn) const
{
return fVP2Manager->GetP2Id(name, warn);
}
//_____________________________________________________________________________
inline
G4int G4VAnalysisManager::GetH1Nbins(G4int id) const
@@ -39,6 +39,9 @@ G4bool G4RootAnalysisManager::WriteT(const std::vector<T*>& htVector,
tools::wroot::directory* directory,
const G4String& hnType)
{
// Do nothing if there is no file
if ( ! directory ) return true;
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
auto info = hnVector[i];
auto activation = info->GetActivation();
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4RootAnalysisManager.cc 102848 2017-02-27 13:09:25Z gcosmo $
// $Id: G4RootAnalysisManager.cc 103532 2017-04-13 14:00:35Z gcosmo $
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
@@ -513,7 +513,7 @@ G4bool G4RootAnalysisManager::OpenFileImpl(const G4String& fileName)
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("open", "analysis file", name);
fState.GetVerboseL1()->Message("open", "analysis file", name, finalResult);
#endif
}
@@ -534,7 +534,7 @@ G4bool G4RootAnalysisManager::OpenFileImpl(const G4String& fileName)
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("open", "main analysis file", name);
fState.GetVerboseL1()->Message("open", "main analysis file", name, finalResult);
#endif
}
@@ -609,6 +609,10 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
{
auto finalResult = true;
G4bool isNtupleManagerEmpty = fNtupleManager->IsEmpty();
// the ntuple decription vector is cleared on Reset()
// in kNoMergeAfterOpen ntuple manager mode
// reset data
auto result = Reset();
if ( ! result ) {
@@ -626,12 +630,12 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
// No files clean-up in sequential mode
if ( ! G4Threading::IsMultithreadedApplication() ) return finalResult;
// Delete files if empty in MT mode
if ( ( fState.GetIsMaster() &&
fH1Manager->IsEmpty() && fH2Manager->IsEmpty() && fH3Manager->IsEmpty() &&
fP1Manager->IsEmpty() && fP2Manager->IsEmpty() && fNtupleManager->IsEmpty() ) ||
( ( ! fState.GetIsMaster() ) && fNtupleManager->IsEmpty() &&
fP1Manager->IsEmpty() && fP2Manager->IsEmpty() && isNtupleManagerEmpty ) ||
( ( ! fState.GetIsMaster() ) && isNtupleManagerEmpty &&
fNtupleMergeMode == G4NtupleMergeMode::kNone ) ) {
result = ! std::remove(fFileManager->GetFullFileName());
// std::remove returns 0 when success
@@ -125,6 +125,9 @@ G4bool G4RootFileManager::WriteFile(std::shared_ptr<tools::wroot::file> rfile,
const G4String& /*fileName*/)
#endif
{
// Do nothing if there is no file
if ( ! fIsOpenFile ) return true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("write", "file", fileName);
@@ -149,6 +152,9 @@ G4bool G4RootFileManager::CloseFile(std::shared_ptr<tools::wroot::file> rfile,
const G4String& /*fileName*/)
#endif
{
// Do nothing if there is no file
if ( ! fIsOpenFile ) return true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("close", "file", fileName);
@@ -183,6 +189,7 @@ G4bool G4RootFileManager::OpenFile(const G4String& fileName)
fFile->set_compression(fState.GetCompressionLevel());
if ( ! fFile->is_open() ) {
fFile = nullptr;
G4ExceptionDescription description;
description << " " << "Cannot open file " << fileName;
G4Exception("G4RootAnalysisManager::OpenFile()",
@@ -109,6 +109,15 @@ void G4RootNtupleManager::CreateTNtuple(
SetCreateMode();
if ( fCreateMode == G4NtupleCreateMode::kNoMergeAfterOpen ) {
if ( ! fNtupleDirectory ) {
G4String inFunction = "G4RootNtupleManager::::CreateTNtuple";
G4ExceptionDescription description;
description << " "
<< "Cannot create ntuple. Ntuple directory does not exist." << G4endl;
G4Exception(inFunction, "Analysis_W002", JustWarning, description);
return;
}
ntupleDescription->fNtuple
= new tools::wroot::ntuple(*fNtupleDirectory, name, title);
ntupleDescription->fIsNtupleOwner = false;
@@ -122,6 +131,16 @@ void G4RootNtupleManager::CreateTNtupleFromBooking(
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription)
{
if ( fCreateMode == G4NtupleCreateMode::kNoMergeBeforeOpen ) {
if ( ! fNtupleDirectory ) {
G4String inFunction = "G4RootNtupleManager::::CreateTNtuple";
G4ExceptionDescription description;
description << " "
<< "Cannot create ntuple. Ntuple directory does not exist." << G4endl;
G4Exception(inFunction, "Analysis_W002", JustWarning, description);
return;
}
ntupleDescription->fNtuple
= new tools::wroot::ntuple(
*fNtupleDirectory, ntupleDescription->fNtupleBooking);
@@ -52,6 +52,9 @@ G4bool G4XmlAnalysisManager::WriteT(const std::vector<T*>& htVector,
G4String path = "/";
path.append(directoryName);
std::shared_ptr<std::ofstream> hnFile = fFileManager->GetHnFile();
// Do nothing if there is no file
if ( ! hnFile.get() ) return false;
G4bool result
= tools::waxml::write(*hnFile, *ht, path, name);
if ( ! result ) {
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4XmlAnalysisManager.cc 93815 2015-11-02 11:32:20Z gcosmo $
// $Id: G4XmlAnalysisManager.cc 103532 2017-04-13 14:00:35Z gcosmo $
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
@@ -310,7 +310,7 @@ G4bool G4XmlAnalysisManager::OpenFileImpl(const G4String& fileName)
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()->Message("open", "analysis file", name);
fState.GetVerboseL1()->Message("open", "analysis file", name, finalResult);
#endif
return finalResult;
@@ -91,6 +91,7 @@ G4bool G4XmlFileManager::CreateHnFile()
fHnFile = std::make_shared<std::ofstream>(GetFullFileName());
if ( fHnFile->fail() ) {
fHnFile = nullptr;
G4ExceptionDescription description;
description << " " << "Cannot open file " << GetFullFileName();
G4Exception("G4XmlFileManager::CreateHnFile()",
@@ -146,6 +147,7 @@ G4bool G4XmlFileManager::CreateNtupleFile(
auto ntupleFile = new std::ofstream(GetNtupleFileName(ntupleName));
if ( ntupleFile->fail() ) {
delete ntupleFile;
G4ExceptionDescription description;
description << " " << "Cannot open file "
<< GetNtupleFileName(ntupleName);
@@ -170,6 +172,9 @@ G4bool G4XmlFileManager::CreateNtupleFile(
G4bool G4XmlFileManager::CloseNtupleFile(
G4TNtupleDescription<tools::waxml::ntuple>* ntupleDescription)
{
// Do nothing if there is no file
if ( ! ntupleDescription->fFile ) return true;
G4String ntupleName = ntupleDescription->fNtupleBooking.name();
#ifdef G4VERBOSE