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