G4PolarizationMessenger.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: G4PolarizationMessenger.cc 69847 2013-05-16 09:36:18Z gcosmo $
00027 //
00028 //
00029 // GEANT4 Class file
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 access to general polarization information and to 
00042 // polarization for logical volumes through macro files.
00043 
00044 #include "G4PolarizationMessenger.hh"
00045 #include "G4PolarizationManager.hh"
00046 #include "G4PolarizationHelper.hh"
00047 
00048 #include "G4UIdirectory.hh"
00049 #include "G4Tokenizer.hh"
00050 #include "G4UIcmdWithoutParameter.hh"
00051 #include "G4UIcmdWithAString.hh"
00052 #include "G4UIcmdWithAnInteger.hh"
00053 #include "G4UIcmdWithABool.hh"
00054 #include "G4ios.hh"
00055 
00056 
00057 G4PolarizationMessenger::G4PolarizationMessenger(G4PolarizationManager * polMgr)
00058   : polarizationManager(polMgr)
00059 {
00060   polarizationDirectory = new G4UIdirectory("/polarization/");
00061   polarizationDirectory->SetGuidance("polarization control commands.");
00062 
00063   managerDirectory = new G4UIdirectory("/polarization/manager/");
00064   managerDirectory->SetGuidance("general polarization information.");
00065 
00066   verboseCmd = new G4UIcmdWithAnInteger("/polarization/manager/verbose",this);
00067   verboseCmd->SetGuidance("Set the Verbose level of G4PolarizationManager.");
00068   verboseCmd->SetGuidance(" 0 : Silent (default)");
00069   verboseCmd->SetGuidance(" 1 : Verbose");
00070   verboseCmd->SetParameterName("level",true);
00071   verboseCmd->SetDefaultValue(0);
00072   verboseCmd->SetRange("level >=0 && level <=1");
00073 
00074   optActivateCmd = new G4UIcmdWithABool("/polarization/manager/activate",this);
00075   optActivateCmd->SetGuidance("activate/deactivate polarization treatment");
00076   optActivateCmd->SetParameterName("flag",true);
00077   optActivateCmd->SetDefaultValue(true);
00078 
00079 
00080   volumeDirectory = new G4UIdirectory("/polarization/volume/");
00081   volumeDirectory->SetGuidance("Status control commands of registered polarized logical volumes.");
00082 
00083   printVolumeListCmd = new G4UIcmdWithoutParameter("/polarization/volume/list",this);
00084   printVolumeListCmd->SetGuidance("print list of registered polarized logical volumes");
00085   printVolumeListCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
00086   
00087   setPolarizationCmd = new G4UIcommand("/polarization/volume/set",this);
00088   setPolarizationCmd->SetGuidance("set or change polarization of a logical volume");
00089 //   setPolarizationCmd->SetParameterName("polarization",true);
00090 //   setPolarizationCmd->SetDefaultValue("worldVolume  0. 0. 0.");
00091   setPolarizationCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
00092 
00093   G4UIparameter* param;
00094   param = new G4UIparameter("logicalVolumeName",'s',false);
00095   param->SetDefaultValue("worldVolume");
00096   setPolarizationCmd->SetParameter(param);
00097   param = new G4UIparameter("px",'d',true);
00098   param->SetDefaultValue("0.0");
00099   setPolarizationCmd->SetParameter(param);
00100   param = new G4UIparameter("py",'d',true);
00101   param->SetDefaultValue("0.0");
00102   setPolarizationCmd->SetParameter(param);
00103   param = new G4UIparameter("pz",'d',true);
00104   param->SetDefaultValue("0.0");
00105   setPolarizationCmd->SetParameter(param);
00106 
00107   testDirectory = new G4UIdirectory("/polarization/test/");
00108   testDirectory->SetGuidance("provides access to some internal test routines.");
00109 
00110   testPolarizationTransformationCmd = new G4UIcmdWithoutParameter("/polarization/test/polarizationTransformation",this);
00111   testPolarizationTransformationCmd->SetGuidance("checks definition of particle reference frame and corresponding translation routines"); 
00112   testPolarizationTransformationCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
00113 
00114 
00115 
00116 }
00117 
00118 G4PolarizationMessenger::~G4PolarizationMessenger()
00119 {
00120   delete verboseCmd;
00121 }
00122 
00123 void G4PolarizationMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
00124 {
00125   if( command==verboseCmd ) { 
00126     polarizationManager->SetVerbose(verboseCmd->GetNewIntValue(newValue)); 
00127   }
00128   else if ( command==optActivateCmd ) { 
00129     polarizationManager->SetActivated(optActivateCmd->GetNewBoolValue(newValue));
00130   }
00131   else if ( command==printVolumeListCmd ) { 
00132     polarizationManager->ListVolumes();
00133   }
00134   else if ( command==setPolarizationCmd ) {
00135     G4Tokenizer next( newValue );
00136     G4String volumeName=next();
00137     G4double px=0.,py=0.,pz=0.;
00138     G4String dvalue=next();
00139     if (!dvalue.isNull()) {
00140       px=StoD(dvalue);
00141       dvalue=next();
00142       if (!dvalue.isNull()) {
00143         py=StoD(dvalue);
00144         dvalue=next();
00145         if (!dvalue.isNull()) pz=StoD(dvalue);
00146       }
00147     }
00148     G4ThreeVector pol(px,py,pz);
00149     polarizationManager->SetVolumePolarization(volumeName,pol);
00150   }
00151   else if ( command==testPolarizationTransformationCmd ) {
00152     G4PolarizationHelper::TestPolarizationTransformations();
00153   }
00154   else if (command==testInteractionFrameCmd ) {
00155     G4PolarizationHelper::TestInteractionFrame();
00156   }
00157 }
00158 
00159 G4String G4PolarizationMessenger::GetCurrentValue(G4UIcommand * command)
00160 {
00161   G4String cv;
00162   if( command==verboseCmd )
00163   { cv = verboseCmd->ConvertToString(polarizationManager->GetVerbose()); }
00164 
00165   return cv;
00166 }

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