Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // Geant4 Class file << 26 // $Id: G4PolarizationManager.cc 68046 2013-03-13 14:31:38Z gcosmo $ >> 27 // >> 28 // GEANT4 Class file >> 29 // 27 // 30 // 28 // File name: G4PolarizationManager 31 // File name: G4PolarizationManager 29 // 32 // 30 // Author: Andreas Schaelicke 33 // Author: Andreas Schaelicke 31 // 34 // >> 35 // Creation date: 01.05.2005 >> 36 // >> 37 // Modifications: >> 38 // 32 // Class Description: 39 // Class Description: 33 // Provides polarization information for log << 40 // 34 // transformation routines. << 41 // Provides polarization information for logical volumes, and some basic 35 << 42 // transformation routines. >> 43 // 36 #include "G4PolarizationManager.hh" 44 #include "G4PolarizationManager.hh" 37 << 38 #include "G4LogicalVolume.hh" << 39 #include "G4PolarizationMessenger.hh" 45 #include "G4PolarizationMessenger.hh" 40 #include "G4StokesVector.hh" 46 #include "G4StokesVector.hh" 41 47 42 G4ThreadLocal G4PolarizationManager* G4Polariz << 48 #include "G4LogicalVolume.hh" >> 49 >> 50 G4ThreadLocal G4PolarizationManager * G4PolarizationManager::instance = 0; 43 51 44 G4PolarizationManager* G4PolarizationManager:: 52 G4PolarizationManager* G4PolarizationManager::GetInstance() 45 { 53 { 46 if(fInstance == nullptr) << 54 if (instance == 0) instance = new G4PolarizationManager(); 47 fInstance = new G4PolarizationManager(); << 55 return instance; 48 return fInstance; << 49 } 56 } 50 57 51 void G4PolarizationManager::Dispose() 58 void G4PolarizationManager::Dispose() 52 { 59 { 53 if(fInstance != nullptr) << 60 if (instance != 0) 54 { 61 { 55 delete fInstance; << 62 delete instance; 56 fInstance = nullptr; << 63 instance = 0; 57 } 64 } 58 } 65 } 59 66 60 G4PolarizationManager::G4PolarizationManager() 67 G4PolarizationManager::G4PolarizationManager() 61 : fMessenger(nullptr) << 68 : messenger(0), verboseLevel(0), activated(true) 62 , fVerboseLevel(0) << 63 , fActivated(true) << 64 { 69 { 65 fMessenger = new G4PolarizationMessenger(thi << 70 messenger = new G4PolarizationMessenger(this); 66 } 71 } 67 72 68 G4PolarizationManager::~G4PolarizationManager( << 73 G4PolarizationManager::~G4PolarizationManager() >> 74 { >> 75 } 69 76 70 void G4PolarizationManager::ListVolumes() 77 void G4PolarizationManager::ListVolumes() 71 { 78 { 72 if(fVolumePolarizations.empty()) << 79 if (volumePolarizations.size()==0) return; 73 return; << 80 G4cout<<" Polarization for "<<volumePolarizations.size() 74 G4cout << " Polarization for " << fVolumePol << 81 <<" registered volume(s) : "<<G4endl; 75 << " registered volume(s) : " << G4en << 82 if (!activated) 76 if(!fActivated) << 83 G4cout<<" but polarization deactivated "<<G4endl; 77 G4cout << " but polarization deactivated " << 84 for (PolarizationMap::const_iterator cit=volumePolarizations.begin(); 78 for(auto& vp : fVolumePolarizations) << 85 cit!=volumePolarizations.end();cit++) { 79 { << 86 G4cout<<cit->first->GetName()<<" : "<<cit->second<<G4endl; 80 G4cout << vp.first->GetName() << " : " << << 81 } 87 } 82 } 88 } 83 89 84 void G4PolarizationManager::SetVolumePolarizat << 90 void G4PolarizationManager::SetVolumePolarization(G4LogicalVolume* lVol, const G4ThreeVector & pol) 85 << 86 { 91 { 87 fVolumePolarizations[lVol] = pol; << 92 volumePolarizations[lVol]=pol; 88 if(fVerboseLevel >= 1) << 93 if (verboseLevel>=1) G4cout<<" SetVolumePolarization " 89 G4cout << " SetVolumePolarization " << lVo << 94 <<lVol->GetName()<<" " 90 << G4endl; << 95 <<pol<<G4endl; 91 } << 96 } 92 << 97 93 void G4PolarizationManager::SetVolumePolarizat << 98 void G4PolarizationManager::SetVolumePolarization(const G4String & lVolName, const G4ThreeVector & pol) 94 << 99 { 95 { << 100 for (PolarizationMap::iterator it=volumePolarizations.begin(); 96 for(auto& vp : fVolumePolarizations) << 101 it!=volumePolarizations.end();it++) { 97 { << 102 if (it->first->GetName()==lVolName) { 98 if(vp.first->GetName() == lVolName) << 103 it->second=pol; 99 { << 104 if (verboseLevel>=1) G4cout<<" SetVolumePolarization " 100 vp.second = pol; << 105 <<lVolName<<" " 101 if(fVerboseLevel >= 1) << 106 <<pol<<G4endl; 102 G4cout << " SetVolumePolarization " << << 103 return; 107 return; 104 } 108 } 105 } 109 } 106 G4ExceptionDescription ed; << 110 G4cout<<" logical volume '"<<lVolName<<"'not registerd yet \n" 107 ed << " Logical volume '" << lVolName << "'n << 111 <<" please register before using '/polarization/volume/set' "<<G4endl; 108 << " Please register before using '/polar << 109 G4Exception("G4PolarizationManager::SetVolum << 110 FatalException, ed); << 111 } 112 } >> 113 112 114