10 #ifndef GGSROOTFILESERVICE_H_
11 #define GGSROOTFILESERVICE_H_
17 #include "TObjString.h"
22 #include "G4VPhysicalVolume.hh"
24 #include "boost/filesystem.hpp"
25 #include "boost/unordered_map.hpp"
26 #include <boost/functional/hash.hpp>
27 using namespace boost::filesystem;
71 TFile *GetFileForThisRun(
const path &baseName,
const G4Run *run);
88 void CloseFileForThisRun(
const path &baseName);
107 TTree *GetDefaultTree(TFile *file);
115 void SetSuffix(
const std::string &suffix) { _suffix = suffix; }
141 int StoreVolume(TFile *filePtr,
const std::string &detector,
const G4VPhysicalVolume *volume,
142 const G4ThreeVector &position,
int id);
153 path _GetAbsolutePath(
const path &baseName);
154 TString _AppendSuffixAndExt(
const path &baseName,
const G4Run *run);
157 void _FillDefaultEventsTrees();
162 const G4VPhysicalVolume *physVol;
163 G4ThreeVector position;
165 VolumeKey(
const std::string &volName,
const G4VPhysicalVolume *physVolPtr,
const G4ThreeVector &pos)
166 : name(volName), physVol(physVolPtr), position(pos) {}
167 bool operator==(
const VolumeKey &rhs)
const {
168 return (name == rhs.name && physVol == rhs.physVol && position == rhs.position);
172 friend std::size_t hash_value(
const VolumeKey &key) {
173 std::size_t seed = 0;
174 boost::hash_combine(seed, key.name);
175 boost::hash_combine(seed, key.physVol);
176 boost::hash_combine(seed, key.position[0]);
177 boost::hash_combine(seed, key.position[1]);
178 boost::hash_combine(seed, key.position[2]);
182 typedef boost::unordered_map<VolumeKey, G4int, boost::hash<VolumeKey>>
184 typedef std::list<std::pair<std::string, HitVolMap>> HitDetMap;
190 TTree *defaultEventsTree;
192 HitDetMap *detectorsMap;
193 TClonesArray *detectorsArray;
198 typedef std::list<FileInfo> FileInfoContainer;
200 FileInfoContainer _files;
203 path _defaultOutBase;
208 TFile *_currVolStorageFile;
209 std::string _currDetVolName;
210 FileInfoContainer::iterator _currVolStorageFileInfo;
void SetDefaultFileBase(const path &newFileBase)
Sets the default file name.
Singleton for a centralized ROOT files management.
The GGS ser actions manager.
void SetSuffix(const std::string &suffix)
Sets the suffix for file names.
void SetSimInfo(const GGSTSimInfo &simInfo)
Set the simulation info object to be saved on output files.
A class to store simulation informations.