BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSAperturePointsLoader.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 BDSAPERTUREPOINTSLOADER_H
19#define BDSAPERTUREPOINTSLOADER_H
20#include "BDSFourVector.hh"
21
22#include "G4String.hh"
23#include "G4TwoVector.hh"
24#include "G4Types.hh"
25
26#include <map>
27#include <vector>
28
41template <class T>
43{
44public:
47
50 std::vector<G4TwoVector>* Load(const G4String& fileName,
51 G4double unit = 1.0) const;
52};
53
67{
68public:
71
73
75 void ClearCachedFiles();
76
78 std::vector<G4TwoVector>* FindCachedFile(const G4String& fileNameAndUnits) const;
79
81 void CacheFile(const G4String& fileNameAndUnits,
82 std::vector<G4TwoVector>* contents);
83
84private:
85 BDSAperturePointsCache() = default;
86
87 static BDSAperturePointsCache* instance;
88
89 std::map<G4String, std::vector<G4TwoVector>*> cachedFiles;
90};
91
92namespace BDS
93{
97 std::vector<G4TwoVector>* LoadAperturePoints(const G4String& fileName,
98 const G4String& unit = "");
99}
100
101#endif
A holder for loaded aperture points files.
void CacheFile(const G4String &fileNameAndUnits, std::vector< G4TwoVector > *contents)
Add an entry to the cache.
static BDSAperturePointsCache * Instance()
Access the singleton instance.
void ClearCachedFiles()
Delete all cached points from memory and clear the map of files loaded.
std::vector< G4TwoVector > * FindCachedFile(const G4String &fileNameAndUnits) const
Retrieve a cached files. Will return nullptr if not found.
A loader for up to set of XY points for an aperture.
std::vector< G4TwoVector > * Load(const G4String &fileName, G4double unit=1.0) const
Return either G4Tubs or G4CutTubs depending on flat face.
std::vector< G4TwoVector > * LoadAperturePoints(const G4String &fileName, const G4String &unit="")