BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSAperturePointsLoader.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSAPERTUREPOINTSLOADER_H
20#define BDSAPERTUREPOINTSLOADER_H
21#include "BDSFourVector.hh"
22
23#include "G4String.hh"
24#include "G4TwoVector.hh"
25#include "G4Types.hh"
26
27#include <map>
28#include <vector>
29
42template <class T>
44{
45public:
48
51 std::vector<G4TwoVector>* Load(const G4String& fileName,
52 G4double unit = 1.0) const;
53};
54
68{
69public:
72
74
76 void ClearCachedFiles();
77
79 std::vector<G4TwoVector>* FindCachedFile(const G4String& fileNameAndUnits) const;
80
82 void CacheFile(const G4String& fileNameAndUnits,
83 std::vector<G4TwoVector>* contents);
84
85private:
86 BDSAperturePointsCache() = default;
87
88 static BDSAperturePointsCache* instance;
89
90 std::map<G4String, std::vector<G4TwoVector>*> cachedFiles;
91};
92
93namespace BDS
94{
98 std::vector<G4TwoVector>* LoadAperturePoints(const G4String& fileName,
99 const G4String& unit = "");
100}
101
102#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="")