[819] | 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: G4PolarizationMessenger.cc,v 1.1 2006/09/21 21:35:11 vnivanch Exp $ |
---|
[1007] | 27 | // GEANT4 tag $Name: geant4-09-02 $ |
---|
[819] | 28 | // |
---|
| 29 | // |
---|
| 30 | // GEANT4 Class file |
---|
| 31 | // |
---|
| 32 | // File name: G4PolarizationManager |
---|
| 33 | // |
---|
| 34 | // Author: Andreas Schaelicke |
---|
| 35 | // |
---|
| 36 | // Creation date: 01.05.2005 |
---|
| 37 | // |
---|
| 38 | // Modifications: |
---|
| 39 | // |
---|
| 40 | // Class Description: |
---|
| 41 | // |
---|
| 42 | // Provides access to general polarization information and to |
---|
| 43 | // polarization for logical volumes through macro files. |
---|
| 44 | |
---|
| 45 | #include "G4PolarizationMessenger.hh" |
---|
| 46 | #include "G4PolarizationManager.hh" |
---|
| 47 | #include "G4PolarizationHelper.hh" |
---|
| 48 | |
---|
| 49 | #include "G4UIdirectory.hh" |
---|
| 50 | #include "G4Tokenizer.hh" |
---|
| 51 | #include "G4UIcmdWithoutParameter.hh" |
---|
| 52 | #include "G4UIcmdWithAString.hh" |
---|
| 53 | #include "G4UIcmdWithAnInteger.hh" |
---|
| 54 | #include "G4UIcmdWithABool.hh" |
---|
| 55 | #include "G4ios.hh" |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | G4PolarizationMessenger::G4PolarizationMessenger(G4PolarizationManager * polMgr) |
---|
| 59 | : polarizationManager(polMgr) |
---|
| 60 | { |
---|
| 61 | polarizationDirectory = new G4UIdirectory("/polarization/"); |
---|
| 62 | polarizationDirectory->SetGuidance("polarization control commands."); |
---|
| 63 | |
---|
| 64 | managerDirectory = new G4UIdirectory("/polarization/manager/"); |
---|
| 65 | managerDirectory->SetGuidance("general polarization information."); |
---|
| 66 | |
---|
| 67 | verboseCmd = new G4UIcmdWithAnInteger("/polarization/manager/verbose",this); |
---|
| 68 | verboseCmd->SetGuidance("Set the Verbose level of G4PolarizationManager."); |
---|
| 69 | verboseCmd->SetGuidance(" 0 : Silent (default)"); |
---|
| 70 | verboseCmd->SetGuidance(" 1 : Verbose"); |
---|
| 71 | verboseCmd->SetParameterName("level",true); |
---|
| 72 | verboseCmd->SetDefaultValue(0); |
---|
| 73 | verboseCmd->SetRange("level >=0 && level <=1"); |
---|
| 74 | |
---|
| 75 | optActivateCmd = new G4UIcmdWithABool("/polarization/manager/activate",this); |
---|
| 76 | optActivateCmd->SetGuidance("activate/deactivate polarization treatment"); |
---|
| 77 | optActivateCmd->SetParameterName("flag",true); |
---|
| 78 | optActivateCmd->SetDefaultValue(true); |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | volumeDirectory = new G4UIdirectory("/polarization/volume/"); |
---|
| 82 | volumeDirectory->SetGuidance("Status control commands of registered polarized logical volumes."); |
---|
| 83 | |
---|
| 84 | printVolumeListCmd = new G4UIcmdWithoutParameter("/polarization/volume/list",this); |
---|
| 85 | printVolumeListCmd->SetGuidance("print list of registered polarized logical volumes"); |
---|
| 86 | printVolumeListCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); |
---|
| 87 | |
---|
| 88 | setPolarizationCmd = new G4UIcommand("/polarization/volume/set",this); |
---|
| 89 | setPolarizationCmd->SetGuidance("set or change polarization of a logical volume"); |
---|
| 90 | // setPolarizationCmd->SetParameterName("polarization",true); |
---|
| 91 | // setPolarizationCmd->SetDefaultValue("worldVolume 0. 0. 0."); |
---|
| 92 | setPolarizationCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); |
---|
| 93 | |
---|
| 94 | G4UIparameter* param; |
---|
| 95 | param = new G4UIparameter("logicalVolumeName",'s',false); |
---|
| 96 | param->SetDefaultValue("worldVolume"); |
---|
| 97 | setPolarizationCmd->SetParameter(param); |
---|
| 98 | param = new G4UIparameter("px",'d',true); |
---|
| 99 | param->SetDefaultValue("0.0"); |
---|
| 100 | setPolarizationCmd->SetParameter(param); |
---|
| 101 | param = new G4UIparameter("py",'d',true); |
---|
| 102 | param->SetDefaultValue("0.0"); |
---|
| 103 | setPolarizationCmd->SetParameter(param); |
---|
| 104 | param = new G4UIparameter("pz",'d',true); |
---|
| 105 | param->SetDefaultValue("0.0"); |
---|
| 106 | setPolarizationCmd->SetParameter(param); |
---|
| 107 | |
---|
| 108 | testDirectory = new G4UIdirectory("/polarization/test/"); |
---|
| 109 | testDirectory->SetGuidance("provides access to some internal test routines."); |
---|
| 110 | |
---|
| 111 | testPolarizationTransformationCmd = new G4UIcmdWithoutParameter("/polarization/test/polarizationTransformation",this); |
---|
| 112 | testPolarizationTransformationCmd->SetGuidance("checks definition of particle reference frame and corresponding translation routines"); |
---|
| 113 | testPolarizationTransformationCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed); |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | G4PolarizationMessenger::~G4PolarizationMessenger() |
---|
| 120 | { |
---|
| 121 | delete verboseCmd; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | void G4PolarizationMessenger::SetNewValue(G4UIcommand * command,G4String newValue) |
---|
| 125 | { |
---|
| 126 | if( command==verboseCmd ) { |
---|
| 127 | polarizationManager->SetVerbose(verboseCmd->GetNewIntValue(newValue)); |
---|
| 128 | } |
---|
| 129 | else if ( command==optActivateCmd ) { |
---|
| 130 | polarizationManager->SetActivated(optActivateCmd->GetNewBoolValue(newValue)); |
---|
| 131 | } |
---|
| 132 | else if ( command==printVolumeListCmd ) { |
---|
| 133 | polarizationManager->ListVolumes(); |
---|
| 134 | } |
---|
| 135 | else if ( command==setPolarizationCmd ) { |
---|
| 136 | G4Tokenizer next( newValue ); |
---|
| 137 | G4String volumeName=next(); |
---|
| 138 | G4double px=0.,py=0.,pz=0.; |
---|
| 139 | G4String dvalue=next(); |
---|
| 140 | if (!dvalue.isNull()) { |
---|
| 141 | px=StoD(dvalue); |
---|
| 142 | dvalue=next(); |
---|
| 143 | if (!dvalue.isNull()) { |
---|
| 144 | py=StoD(dvalue); |
---|
| 145 | dvalue=next(); |
---|
| 146 | if (!dvalue.isNull()) pz=StoD(dvalue); |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | G4ThreeVector pol(px,py,pz); |
---|
| 150 | polarizationManager->SetVolumePolarization(volumeName,pol); |
---|
| 151 | } |
---|
| 152 | else if ( command==testPolarizationTransformationCmd ) { |
---|
| 153 | G4PolarizationHelper::TestPolarizationTransformations(); |
---|
| 154 | } |
---|
| 155 | else if (command==testInteractionFrameCmd ) { |
---|
| 156 | G4PolarizationHelper::TestInteractionFrame(); |
---|
| 157 | } |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | G4String G4PolarizationMessenger::GetCurrentValue(G4UIcommand * command) |
---|
| 161 | { |
---|
| 162 | G4String cv; |
---|
| 163 | if( command==verboseCmd ) |
---|
| 164 | { cv = verboseCmd->ConvertToString(polarizationManager->GetVerbose()); } |
---|
| 165 | |
---|
| 166 | return cv; |
---|
| 167 | } |
---|