Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:56

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Geant44 Class header file
0027 //
0028 // File name:     G4PolarizationManager
0029 //
0030 // Author:        Andreas Schaelicke
0031 //
0032 // Class Description:
0033 //   Provides polarization information for logical volumes
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0115 inline void G4PolarizationManager::SetVerbose(G4int val)
0116 {
0117   fVerboseLevel = val;
0118 }
0119 inline G4int G4PolarizationManager::GetVerbose() const { return fVerboseLevel; }
0120 
0121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0122 inline void G4PolarizationManager::SetActivated(G4bool val)
0123 {
0124   fActivated = val;
0125 }
0126 inline bool G4PolarizationManager::IsActivated() const { return fActivated; }
0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0128 
0129 inline void G4PolarizationManager::Clean() { fVolumePolarizations.clear(); }
0130 
0131 #endif