G4PolarizationManager.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id: G4PolarizationManager.cc 69847 2013-05-16 09:36:18Z gcosmo $
00027 //
00028 // GEANT4 Class file
00029 //
00030 //
00031 // File name:     G4PolarizationManager
00032 //
00033 // Author:        Andreas Schaelicke
00034 //
00035 // Creation date: 01.05.2005
00036 //
00037 // Modifications:
00038 //
00039 // Class Description:
00040 //
00041 // Provides polarization information for logical volumes, and some basic 
00042 // transformation routines.
00043 //
00044 #include "G4PolarizationManager.hh"
00045 #include "G4PolarizationMessenger.hh"
00046 #include "G4StokesVector.hh"
00047 
00048 #include "G4LogicalVolume.hh"
00049 
00050 G4PolarizationManager * G4PolarizationManager::instance = 0;
00051 
00052 G4PolarizationManager* G4PolarizationManager::GetInstance()
00053 {
00054   if (instance == 0) instance = new G4PolarizationManager();
00055   return instance;
00056 }
00057 
00058 void G4PolarizationManager::Dispose()
00059 {
00060   if (instance != 0)
00061   {
00062     delete instance;
00063     instance = 0;
00064   }
00065 }
00066 
00067 G4PolarizationManager::G4PolarizationManager()
00068   : messenger(0), verboseLevel(0), activated(true)
00069 {
00070   messenger = new G4PolarizationMessenger(this);  
00071 }
00072 
00073 G4PolarizationManager::~G4PolarizationManager()
00074 {  
00075 }
00076 
00077 void G4PolarizationManager::ListVolumes()
00078 {
00079   if (volumePolarizations.size()==0) return;
00080   G4cout<<" Polarization for "<<volumePolarizations.size()
00081         <<" registered volume(s) : "<<G4endl;
00082   if (!activated) 
00083     G4cout<<" but polarization deactivated "<<G4endl;
00084   for (PolarizationMap::const_iterator cit=volumePolarizations.begin();
00085        cit!=volumePolarizations.end();cit++) {
00086     G4cout<<cit->first->GetName()<<" : "<<cit->second<<G4endl;
00087   }
00088 }
00089 
00090 void G4PolarizationManager::SetVolumePolarization(G4LogicalVolume* lVol, const G4ThreeVector & pol)
00091 {
00092   volumePolarizations[lVol]=pol;
00093   if (verboseLevel>=1) G4cout<<" SetVolumePolarization "
00094                              <<lVol->GetName()<<" "
00095                              <<pol<<G4endl;
00096 }
00097 
00098 void G4PolarizationManager::SetVolumePolarization(const G4String & lVolName, const G4ThreeVector & pol)
00099 {
00100   for (PolarizationMap::iterator it=volumePolarizations.begin();
00101        it!=volumePolarizations.end();it++) {
00102     if (it->first->GetName()==lVolName) {
00103       it->second=pol;
00104       if (verboseLevel>=1) G4cout<<" SetVolumePolarization "
00105                                  <<lVolName<<" "
00106                                  <<pol<<G4endl;
00107       return;
00108     }
00109   }
00110   G4cout<<" logical volume '"<<lVolName<<"'not registerd yet \n"
00111         <<" please register before using '/polarization/volume/set' "<<G4endl;
00112 }
00113 

Generated on Mon May 27 17:49:22 2013 for Geant4 by  doxygen 1.4.7