Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PolarizationManager.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4PolarizationManager.hh 97384 2016-06-02 09:59:17Z gcosmo $
27 //
28 // GEANT4 Class header file
29 //
30 //
31 // File name: G4PolarizationManager
32 //
33 // Author: Andreas Schaelicke
34 //
35 // Creation date: 01.05.2005
36 //
37 // Modifications:
38 // 12-08-06 Helper routines are moved to G4PolarizationHelper
39 //
40 // Class Description:
41 //
42 // Provides polarization information for logical volumes, and some basic
43 // transformation routines.
44 
45 #ifndef G4PolarizationManager_h
46 #define G4PolarizationManager_h 1
47 
48 #include "globals.hh"
49 #include <vector>
50 #include "G4ThreeVector.hh"
51 
52 #include <map>
53 
54 class G4LogicalVolume;
56 
57 typedef std::map<G4LogicalVolume*,G4ThreeVector> PolarizationMap;
58 
60 public:
61 
62  virtual ~G4PolarizationManager();
64  static void Dispose();
65 
66  void ListVolumes();
67  inline void Clean();
68 
69  void SetVolumePolarization(G4LogicalVolume* lVol, const G4ThreeVector & pol);
70  void SetVolumePolarization(const G4String & lVolName, const G4ThreeVector & pol);
71 
72  inline const G4ThreeVector & GetVolumePolarization(G4LogicalVolume* lVol) const;
73  inline bool IsPolarized(G4LogicalVolume* lVol) const;
74 
75  inline void SetVerbose(G4int val);
76  inline G4int GetVerbose() const;
77 
78  inline void SetActivated(G4bool val);
79  inline bool IsActivated() const;
80 
81 private:
83 
84  G4ThreeVector zeroPolarization;
85  PolarizationMap volumePolarizations;
86  G4PolarizationMessenger * messenger;
87 
88  G4int verboseLevel;
89  G4bool activated;
90 
91  static G4ThreadLocal G4PolarizationManager* instance;
92 };
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96 
98 {
99  if (!activated) return zeroPolarization;
100  PolarizationMap::const_iterator cit=volumePolarizations.find(lVol);
101  if (cit!=volumePolarizations.end()) return cit->second;
102  return zeroPolarization;
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
108 {
109  if (!activated) return false;
110  PolarizationMap::const_iterator cit=volumePolarizations.find(lVol);
111  return (cit!=volumePolarizations.end());
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
116 inline void G4PolarizationManager::SetVerbose(G4int val) { verboseLevel = val; }
117 inline G4int G4PolarizationManager::GetVerbose() const { return verboseLevel; }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120 
121 inline void G4PolarizationManager::SetActivated(G4bool val) { activated = val; }
122 inline bool G4PolarizationManager::IsActivated() const { return activated; }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 
126 inline void G4PolarizationManager::Clean() { volumePolarizations.clear(); }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129 
130 #endif
131 
static G4PolarizationManager * GetInstance()
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
bool IsPolarized(G4LogicalVolume *lVol) const
std::map< G4LogicalVolume *, G4ThreeVector > PolarizationMap
void SetVolumePolarization(G4LogicalVolume *lVol, const G4ThreeVector &pol)
const G4ThreeVector & GetVolumePolarization(G4LogicalVolume *lVol) const