10 #ifndef GGSROOTFILESERVICE_H_
11 #define GGSROOTFILESERVICE_H_
18 #include "TObjString.h"
22 #include "G4VPhysicalVolume.hh"
24 #include "boost/unordered_map.hpp"
25 #include <boost/functional/hash.hpp>
26 #include "boost/filesystem.hpp"
27 using namespace boost::filesystem;
71 TFile* GetFileForThisRun(
const path &baseName,
const G4Run *run);
88 void CloseFileForThisRun(
const path &baseName);
106 TTree *GetDefaultTree(TFile *file);
125 _defaultOutBase = newFileBase;
144 int StoreVolume(TFile *filePtr,
const std::string &detector,
const G4VPhysicalVolume *volume,
145 const G4ThreeVector &position,
int id);
159 path _GetAbsolutePath(
const path &baseName);
160 TString _AppendSuffixAndExt(
const path &baseName,
const G4Run *run);
163 void _FillDefaultEventsTrees();
168 const G4VPhysicalVolume *physVol;
169 G4ThreeVector position;
171 VolumeKey(
const std::string &volName,
const G4VPhysicalVolume *physVolPtr,
const G4ThreeVector &pos) :
172 name(volName), physVol(physVolPtr), position(pos) {
175 bool operator==(
const VolumeKey &rhs)
const {
176 return (name == rhs.name && physVol == rhs.physVol && position == rhs.position);
180 friend std::size_t hash_value(
const VolumeKey &key) {
181 std::size_t seed = 0;
182 boost::hash_combine(seed, key.name);
183 boost::hash_combine(seed, key.physVol);
184 boost::hash_combine(seed, key.position[0]);
185 boost::hash_combine(seed, key.position[1]);
186 boost::hash_combine(seed, key.position[2]);
190 typedef boost::unordered_map<VolumeKey, G4int, boost::hash<VolumeKey> > HitVolMap;
191 typedef std::list<std::pair<std::string, HitVolMap> > HitDetMap;
197 TTree *defaultEventsTree;
199 HitDetMap *detectorsMap;
200 TClonesArray *detectorsArray;
205 typedef std::list<FileInfo> FileInfoContainer;
207 FileInfoContainer _files;
210 path _defaultOutBase;
215 TFile *_currVolStorageFile;
216 std::string _currDetVolName;
217 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.