39 #include "tools/wroot/to"
40 #include "tools/wroot/file"
60 if ( fgInstance == 0 ) {
76 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
80 <<
"G4RootAnalysisManager already exists."
81 <<
"Cannot create another instance.";
82 G4Exception(
"G4RootAnalysisManager::G4RootAnalysisManager()",
85 if ( isMaster ) fgMasterInstance =
this;
114 G4bool G4RootAnalysisManager::WriteH1()
116 const std::vector<tools::histo::h1d*>& h1Vector
118 const std::vector<G4HnInformation*>& hnVector
121 if ( ! h1Vector.size() )
return true;
125 for (
G4int i=0; i<
G4int(h1Vector.size()); ++i ) {
136 tools::wroot::directory* histoDirectory
139 = to(*histoDirectory, *h1, name);
142 description <<
" " <<
"saving histogram " << name <<
" failed";
153 fgMasterInstance->fH1Manager->
AddH1Vector(h1Vector);
161 G4bool G4RootAnalysisManager::WriteH2()
163 const std::vector<tools::histo::h2d*>& h2Vector
165 const std::vector<G4HnInformation*>& hnVector
168 if ( ! h2Vector.size() )
return true;
172 for (
G4int i=0; i<
G4int(h2Vector.size()); ++i ) {
178 tools::histo::h2d*
h2 = h2Vector[i];
183 tools::wroot::directory* histoDirectory
186 = to(*histoDirectory, *h2, name);
189 description <<
" " <<
"saving histogram " << name <<
" failed";
200 fgMasterInstance->fH2Manager->
AddH2Vector(h2Vector);
208 G4bool G4RootAnalysisManager::Reset()
212 G4bool finalResult =
true;
215 finalResult = finalResult &&
result;
217 result = fH2Manager->
Reset();
218 finalResult = finalResult &&
result;
220 result = fNtupleManager->
Reset();
221 finalResult = finalResult &&
result;
233 G4bool finalResult =
true;
235 finalResult = finalResult &&
result;
243 result = fFileManager->
OpenFile(fileName);
244 finalResult = finalResult &&
result;
261 G4bool finalResult =
true;
263 if ( ! fgMasterInstance &&
264 ( ( ! fH1Manager->
IsEmpty() ) || ( ! fH2Manager->
IsEmpty() ) ) ) {
267 <<
" " <<
"No master G4RootAnalysisManager instance exists."
269 <<
" " <<
"Histogram data will not be merged.";
275 G4bool result = WriteH1();
276 finalResult = finalResult &&
result;
280 finalResult = finalResult &&
result;
284 finalResult = finalResult &&
result;
289 finalResult = finalResult &&
result;
310 description <<
" " <<
"Resetting data failed";
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4bool CloseFile()
std::ostringstream G4ExceptionDescription
G4String GetFullFileName() const
void SetH1Manager(G4VH1Manager *h1Manager)
G4double G4NeutronHPJENDLHEData::G4double result
virtual G4bool OpenFileImpl(const G4String &fileName)
#define G4MUTEX_INITIALIZER
virtual G4bool WriteFile()
void CreateNtuplesFromBooking()
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL4() const
G4String GetFileName() const
G4RootAnalysisManager(G4bool isMaster=true)
virtual G4bool WriteImpl()
virtual ~G4RootAnalysisManager()
void SetFileManager(G4VFileManager *fileManager)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
tools::wroot::directory * GetNtupleDirectory() const
void SetH2Manager(G4VH2Manager *h2Manager)
virtual G4bool CloseFileImpl()
static G4RootAnalysisManager * Instance()
G4bool GetIsMaster() const
virtual G4bool OpenFile(const G4String &fileName)
const XML_Char XML_Encoding * info
G4bool SetFileName(const G4String &fileName)
tools::wroot::directory * GetHistoDirectory() const
G4AnalysisManagerState fState
G4bool GetIsActivation() const
const G4AnalysisVerbose * GetVerboseL1() const
void SetNtupleManager(G4VNtupleManager *ntupleManager)
void SetNtupleDirectory(tools::wroot::directory *directory)
G4bool WriteAscii(const G4String &fileName)