File indexing completed on 2025-01-18 09:58:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef G4PolarizationManager_h
0036 #define G4PolarizationManager_h 1
0037
0038 #include "globals.hh"
0039 #include "G4StokesVector.hh"
0040 #include "G4ThreeVector.hh"
0041
0042 #include <vector>
0043 #include <map>
0044
0045 class G4LogicalVolume;
0046 class G4PolarizationMessenger;
0047
0048 typedef std::map<G4LogicalVolume*, G4ThreeVector> PolarizationMap;
0049
0050 class G4PolarizationManager
0051 {
0052 public:
0053 ~G4PolarizationManager();
0054 static G4PolarizationManager* GetInstance();
0055 static void Dispose();
0056
0057 void ListVolumes();
0058 inline void Clean();
0059
0060 void SetVolumePolarization(G4LogicalVolume* lVol, const G4ThreeVector& pol);
0061 void SetVolumePolarization(const G4String& lVolName,
0062 const G4ThreeVector& pol);
0063
0064 inline const G4StokesVector GetVolumePolarization(
0065 G4LogicalVolume* lVol) const;
0066 inline bool IsPolarized(G4LogicalVolume* lVol) const;
0067
0068 inline void SetVerbose(G4int val);
0069 inline G4int GetVerbose() const;
0070
0071 inline void SetActivated(G4bool val);
0072 inline bool IsActivated() const;
0073
0074 G4PolarizationManager& operator=(const G4PolarizationManager& right) = delete;
0075 G4PolarizationManager(const G4PolarizationManager&) = delete;
0076
0077 private:
0078 G4PolarizationManager();
0079 static G4ThreadLocal G4PolarizationManager* fInstance;
0080
0081 G4PolarizationMessenger* fMessenger;
0082
0083 PolarizationMap fVolumePolarizations;
0084
0085 G4int fVerboseLevel;
0086
0087 G4bool fActivated;
0088 };
0089
0090
0091 inline const G4StokesVector G4PolarizationManager::GetVolumePolarization(
0092 G4LogicalVolume* lVol) const
0093 {
0094 if(!fActivated)
0095 return G4StokesVector::ZERO;
0096 PolarizationMap::const_iterator cit = fVolumePolarizations.find(lVol);
0097 if(cit != fVolumePolarizations.end())
0098 {
0099 const G4StokesVector vec = G4StokesVector(cit->second);
0100 return vec;
0101 }
0102 return G4StokesVector::ZERO;
0103 }
0104
0105
0106 inline bool G4PolarizationManager::IsPolarized(G4LogicalVolume* lVol) const
0107 {
0108 if(!fActivated)
0109 return false;
0110 PolarizationMap::const_iterator cit = fVolumePolarizations.find(lVol);
0111 return (cit != fVolumePolarizations.end());
0112 }
0113
0114
0115 inline void G4PolarizationManager::SetVerbose(G4int val)
0116 {
0117 fVerboseLevel = val;
0118 }
0119 inline G4int G4PolarizationManager::GetVerbose() const { return fVerboseLevel; }
0120
0121
0122 inline void G4PolarizationManager::SetActivated(G4bool val)
0123 {
0124 fActivated = val;
0125 }
0126 inline bool G4PolarizationManager::IsActivated() const { return fActivated; }
0127
0128
0129 inline void G4PolarizationManager::Clean() { fVolumePolarizations.clear(); }
0130
0131 #endif