2// ********************************************************************
3// * License and Disclaimer *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
27// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
29#include "G4AnalysisUtilities.hh"
31#include "tools/waxml/histos"
32#include "tools/waxml/begend"
34//_____________________________________________________________________________
36G4bool G4XmlHnFileManager<HT>::WriteExtra(
37 HT* ht, const G4String& htName, const G4String& fileName)
40 std::ofstream hnFile(fileName);
42 // Do nothing if there is no file
43 if ( ! hnFile.is_open() ) return false;
46 tools::waxml::begin(hnFile);
48 // no directory supported in this mode
52 auto result = tools::waxml::write(hnFile, *ht, path, htName);
54 // TO DO: give an exception about failure
59 tools::waxml::end(hnFile);
64//_____________________________________________________________________________
66G4bool G4XmlHnFileManager<HT>::Write(
67 HT* ht, const G4String& htName, G4String& fileName)
69 if ( fileName.empty()) {
71 G4cerr << "!!! Xml file name not defined." << G4endl;
72 G4cerr << "!!! Write " << htName << " failed." << G4endl;
76 auto hnFile = fFileManager->GetTFile(fileName);
77 if ( hnFile == nullptr ) {
78 // This prototype can be used only with OpenFile() mode
80 G4String("Failed to get Xml file ") + fileName, fkClass, "Write");
85 path.append(fFileManager->GetHistoDirectoryName());
87 auto result = tools::waxml::write(*hnFile, *ht, path, htName);
88 fFileManager->LockDirectoryNames();