LDMX Software
MagneticFieldStore.h
Go to the documentation of this file.
1
7#ifndef SIMCORE_MAGNETICFIELDSTORE_H_
8#define SIMCORE_MAGNETICFIELDSTORE_H_
9
10// Geant4
11#include <map>
12
13#include "G4MagneticField.hh"
14
15namespace simcore {
16
22 public:
26 using MagFieldMap = std::map<std::string, G4MagneticField*>;
27
33 static MagneticFieldStore instance;
34 return &instance;
35 }
36
43 for (auto& name_field : mag_fields_) {
44 delete name_field.second;
45 }
46 mag_fields_.clear();
47 }
48
53 G4MagneticField* getMagneticField(const std::string& name) {
54 return mag_fields_.at(name);
55 }
56
62 void addMagneticField(const std::string& name, G4MagneticField* magField) {
63 mag_fields_[name] = magField;
64 }
65
66 private:
71};
72
73} // namespace simcore
74
75#endif
Global store to access magnetic field objects.
static MagneticFieldStore * getInstance()
Get the global instance of the magnetic field store.
G4MagneticField * getMagneticField(const std::string &name)
Get a magnetic field by name.
void addMagneticField(const std::string &name, G4MagneticField *magField)
Add a magnetic field by name.
MagFieldMap mag_fields_
Map of names to magnetic fields.
std::map< std::string, G4MagneticField * > MagFieldMap
Map of names to magnetic fields.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...