Warning, file /include/Geant4/G4RootHnFileManager.icc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "G4AnalysisUtilities.hh"
0030
0031 #include "tools/wroot/to"
0032 #include "tools/wroot/file"
0033 #include "toolx/zlib"
0034
0035
0036 template <typename HT>
0037 G4bool G4RootHnFileManager<HT>::Write(
0038 tools::wroot::directory* directory, HT* ht, const G4String& htName)
0039 {
0040
0041 return to(*directory, *ht, htName);
0042 }
0043
0044
0045 template <typename HT>
0046 G4bool G4RootHnFileManager<HT>::WriteExtra(
0047 HT* ht, const G4String& htName, const G4String& fileName)
0048 {
0049 auto result = true;
0050
0051
0052 auto rfile = new tools::wroot::file(G4cout, fileName);
0053
0054
0055 if (rfile == nullptr) return false;
0056
0057
0058 rfile->add_ziper('Z', toolx::compress_buffer);
0059 rfile->set_compression(fFileManager->GetCompressionLevel());
0060
0061
0062 auto hdirectory = &(rfile->dir());
0063 if (hdirectory == nullptr) return false;
0064
0065
0066 result &= Write(hdirectory, ht, htName);
0067
0068
0069 unsigned int n;
0070 result &= rfile->write(n);
0071 if ( ! result) {
0072 G4Analysis::Warn(
0073 "Saving " + G4Analysis::GetHnType<HT>() + " " + htName + " failed",
0074 fkClass, "WriteExtra");
0075 return false;
0076 }
0077
0078
0079 rfile->close();
0080 return true;
0081 }
0082
0083
0084 template <typename HT>
0085 G4bool G4RootHnFileManager<HT>::Write(
0086 HT* ht, const G4String& htName, G4String& fileName)
0087 {
0088 if ( fileName.empty()) {
0089
0090 G4cerr << "!!! Root file name not defined." << G4endl;
0091 G4cerr << "!!! Write " << htName << " failed." << G4endl;
0092 return false;
0093 }
0094
0095 auto hdirectory = std::get<1>(*fFileManager->GetTFile(fileName));
0096 if ( hdirectory == nullptr ) {
0097 G4Analysis::Warn(
0098 "Failed to get Root file " + fileName + " histo directory.",
0099 fkClass, "Write");
0100 return false;
0101 }
0102
0103 auto result = Write(hdirectory, ht, htName);
0104 fFileManager->LockDirectoryNames();
0105 return result;
0106 }