BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
FileMapper.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef FILEMAPPER_H
19#define FILEMAPPER_H
20
21#include <string>
22#include <vector>
23
25class TDirectory;
26class TFile;
27class TH1;
28
29namespace RBDS
30{
36 bool GetFileType(TFile* file,
37 std::string& fileType,
38 int* dataVersion = nullptr);
39
42 bool IsBDSIMOutputFile(TFile* file,
43 int* dataVersion = nullptr);
44
46 bool IsBDSIMOutputFile(const std::string& filePath,
47 int* dataVersion = nullptr);
48
51 bool IsREBDSIMOutputFile(TFile* file);
52
54 bool IsREBDSIMOutputFile(const std::string& filePath);
55
58 bool IsREBDSIMOrCombineOutputFile(TFile* file);
59
61 bool IsREBDSIMOrCombineOutputFile(const std::string& filePath);
62
64 int DetermineDimensionality(TH1* h);
65
67 void WarningMissingHistogram(const std::string& histName,
68 const std::string& fileName);
69
72 {
73 std::string path;
74 std::string name;
75 HistogramAccumulator* accumulator;
76 TDirectory* outputDir;
77 bool BDSBH4Dtype;
78 };
79
81 enum class MergeType {none, meanmerge, sum};
82
84 MergeType DetermineMergeType(const std::string& parentDir);
85}
86
94{
95public:
96 HistogramMap() = delete;
97 HistogramMap(TFile* file,
98 TFile* output,
99 bool debugIn = false);
100 ~HistogramMap(){;}
101
104 void MapDirectory(TDirectory* dir,
105 TFile* output,
106 const std::string& parentDir);
107
109 inline const std::vector<RBDS::HistogramPath>& Histograms() const {return histograms;}
110
111private:
112 bool debug;
113 std::vector<RBDS::HistogramPath> histograms;
114};
115
116#endif
Class to accumulate and merge histograms in different ways.
Class to map a rebdsim file structure and create duplicate in output.
Definition FileMapper.hh:94
bool debug
Debug flag.
HistogramMap()=delete
No need for default constructor.
std::vector< RBDS::HistogramPath > histograms
Storage of all objects.
const std::vector< RBDS::HistogramPath > & Histograms() const
Access full vector of histograms.
void MapDirectory(TDirectory *dir, TFile *output, const std::string &parentDir)
Utility functions for data files.
bool IsBDSIMOutputFile(TFile *file, int *dataVersion=nullptr)
Definition FileMapper.cc:65
bool IsREBDSIMOutputFile(TFile *file)
Definition FileMapper.cc:92
bool GetFileType(TFile *file, std::string &fileType, int *dataVersion=nullptr)
Definition FileMapper.cc:43
MergeType DetermineMergeType(const std::string &parentDir)
Determine merge type from parent directory name.
bool IsREBDSIMOrCombineOutputFile(TFile *file)
int DetermineDimensionality(TH1 *h)
Determine the number of dimensions of a histogram by dynamically casting.
MergeType
Types of merging.
Definition FileMapper.hh:81
void WarningMissingHistogram(const std::string &histName, const std::string &fileName)
Common print out method.
Basic structure for accumulating histogram from rebdsim output files.
Definition FileMapper.hh:72
std::string path
Without histogram name.
Definition FileMapper.hh:73
std::string name
Name of histogram.
Definition FileMapper.hh:74