Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PolarizationMessenger.cc
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//
27//
28// GEANT4 Class file
29//
30// File name: G4PolarizationManager
31//
32// Author: Andreas Schaelicke
33//
34// Creation date: 01.05.2005
35//
36// Modifications:
37//
38// Class Description:
39//
40// Provides access to general polarization information and to
41// polarization for logical volumes through macro files.
42
46
47#include "G4UIdirectory.hh"
48#include "G4Tokenizer.hh"
50#include "G4UIcmdWithAString.hh"
52#include "G4UIcmdWithABool.hh"
53#include "G4ios.hh"
54
55
57 : polarizationManager(polMgr)
58{
59 polarizationDirectory = new G4UIdirectory("/polarization/");
60 polarizationDirectory->SetGuidance("polarization control commands.");
61
62 managerDirectory = new G4UIdirectory("/polarization/manager/");
63 managerDirectory->SetGuidance("general polarization information.");
64
65 verboseCmd = new G4UIcmdWithAnInteger("/polarization/manager/verbose",this);
66 verboseCmd->SetGuidance("Set the Verbose level of G4PolarizationManager.");
67 verboseCmd->SetGuidance(" 0 : Silent (default)");
68 verboseCmd->SetGuidance(" 1 : Verbose");
69 verboseCmd->SetParameterName("level",true);
70 verboseCmd->SetDefaultValue(0);
71 verboseCmd->SetRange("level >=0 && level <=1");
72
73 optActivateCmd = new G4UIcmdWithABool("/polarization/manager/activate",this);
74 optActivateCmd->SetGuidance("activate/deactivate polarization treatment");
75 optActivateCmd->SetParameterName("flag",true);
76 optActivateCmd->SetDefaultValue(true);
77
78 volumeDirectory = new G4UIdirectory("/polarization/volume/");
79 volumeDirectory->SetGuidance("Status control commands of registered polarized logical volumes.");
80
81 printVolumeListCmd = new G4UIcmdWithoutParameter("/polarization/volume/list",this);
82 printVolumeListCmd->SetGuidance("print list of registered polarized logical volumes");
84
85 setPolarizationCmd = new G4UIcommand("/polarization/volume/set",this);
86 setPolarizationCmd->SetGuidance("set or change polarization of a logical volume");
87// setPolarizationCmd->SetParameterName("polarization",true);
88// setPolarizationCmd->SetDefaultValue("worldVolume 0. 0. 0.");
90
91 G4UIparameter* param;
92 param = new G4UIparameter("logicalVolumeName",'s',false);
93 param->SetDefaultValue("worldVolume");
94 setPolarizationCmd->SetParameter(param);
95 param = new G4UIparameter("px",'d',true);
96 param->SetDefaultValue("0.0");
97 setPolarizationCmd->SetParameter(param);
98 param = new G4UIparameter("py",'d',true);
99 param->SetDefaultValue("0.0");
100 setPolarizationCmd->SetParameter(param);
101 param = new G4UIparameter("pz",'d',true);
102 param->SetDefaultValue("0.0");
103 setPolarizationCmd->SetParameter(param);
104
105 testDirectory = new G4UIdirectory("/polarization/test/");
106 testDirectory->SetGuidance("provides access to some internal test routines.");
107
108 testPolarizationTransformationCmd = new G4UIcmdWithoutParameter("/polarization/test/polarizationTransformation",this);
109 testPolarizationTransformationCmd->SetGuidance("checks definition of particle reference frame and corresponding translation routines");
110 testPolarizationTransformationCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
111
112 testInteractionFrameCmd = new G4UIcmdWithoutParameter("/polarization/test/interactionFrame",this);
113 testInteractionFrameCmd->SetGuidance("checks definition of interaction frame");
115}
116
118{
119 delete verboseCmd;
120 delete testInteractionFrameCmd;
121 delete testPolarizationTransformationCmd;
122 delete testDirectory;
123 delete setPolarizationCmd;
124 delete printVolumeListCmd;
125 delete volumeDirectory;
126 delete optActivateCmd;
127 delete managerDirectory;
128 delete polarizationDirectory;
129}
130
132{
133 if( command==verboseCmd ) {
134 polarizationManager->SetVerbose(verboseCmd->GetNewIntValue(newValue));
135 }
136 else if ( command==optActivateCmd ) {
137 polarizationManager->SetActivated(optActivateCmd->GetNewBoolValue(newValue));
138 }
139 else if ( command==printVolumeListCmd ) {
140 polarizationManager->ListVolumes();
141 }
142 else if ( command==setPolarizationCmd ) {
143 G4Tokenizer next( newValue );
144 G4String volumeName=next();
145 G4double px=0.,py=0.,pz=0.;
146 G4String dvalue=next();
147 if (!dvalue.isNull()) {
148 px=StoD(dvalue);
149 dvalue=next();
150 if (!dvalue.isNull()) {
151 py=StoD(dvalue);
152 dvalue=next();
153 if (!dvalue.isNull()) pz=StoD(dvalue);
154 }
155 }
156 G4ThreeVector pol(px,py,pz);
157 polarizationManager->SetVolumePolarization(volumeName,pol);
158 }
159 else if ( command==testPolarizationTransformationCmd ) {
161 }
162 else if (command==testInteractionFrameCmd ) {
164 }
165}
166
168{
169 G4String cv;
170 if( command==verboseCmd )
171 { cv = verboseCmd->ConvertToString(polarizationManager->GetVerbose()); }
172
173 return cv;
174}
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
double G4double
Definition: G4Types.hh:83
static void TestPolarizationTransformations()
static void TestInteractionFrame()
void SetVolumePolarization(G4LogicalVolume *lVol, const G4ThreeVector &pol)
void SetNewValue(G4UIcommand *command, G4String newValues) override
G4PolarizationMessenger(G4PolarizationManager *runMgr)
G4String GetCurrentValue(G4UIcommand *command) override
G4bool isNull() const
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:273
G4double StoD(G4String s)
void SetDefaultValue(const char *theDefaultValue)