Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:53

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * ============================================================================
0028  *
0029  *       Filename:  CexmcPrimaryGeneratorActionMessenger.cc
0030  *
0031  *    Description:  user assigned gun parameters
0032  *
0033  *        Version:  1.0
0034  *        Created:  02.11.2009 13:32:33
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * ============================================================================
0042  */
0043 
0044 #include <G4UIcmdWithADouble.hh>
0045 #include <G4UIcmdWithADoubleAndUnit.hh>
0046 #include "CexmcPrimaryGeneratorAction.hh"
0047 #include "CexmcPrimaryGeneratorActionMessenger.hh"
0048 #include "CexmcMessenger.hh"
0049 
0050 
0051 CexmcPrimaryGeneratorActionMessenger::CexmcPrimaryGeneratorActionMessenger(
0052         CexmcPrimaryGeneratorAction *  primaryGeneratorAction_ ) :
0053     primaryGeneratorAction( primaryGeneratorAction_ ),
0054     fwhmPosX( NULL ), fwhmPosY( NULL ), fwhmDirX( NULL ), fwhmDirY( NULL ),
0055     fwhmMomentumAmp( NULL )
0056 {
0057     fwhmPosX = new G4UIcmdWithADoubleAndUnit(
0058                 ( CexmcMessenger::gunDirName + "fwhmPosX" ).c_str(), this );
0059     fwhmPosX->SetGuidance( "Set positional fwhm of the beam along X axis" );
0060     fwhmPosX->SetParameterName( "FwhmPosX", false );
0061     fwhmPosX->SetDefaultValue( 0 );
0062     fwhmPosX->SetUnitCandidates( "mm cm m" );
0063     fwhmPosX->SetDefaultUnit( "cm" );
0064     fwhmPosX->AvailableForStates( G4State_PreInit, G4State_Idle );
0065 
0066     fwhmPosY = new G4UIcmdWithADoubleAndUnit(
0067                 ( CexmcMessenger::gunDirName + "fwhmPosY" ).c_str(), this );
0068     fwhmPosY->SetGuidance( "Set positional fwhm of the beam along Y axis" );
0069     fwhmPosY->SetParameterName( "FwhmPosY", false );
0070     fwhmPosY->SetDefaultValue( 0 );
0071     fwhmPosY->SetUnitCandidates( "mm cm m" );
0072     fwhmPosY->SetDefaultUnit( "cm" );
0073     fwhmPosY->AvailableForStates( G4State_PreInit, G4State_Idle );
0074 
0075     fwhmDirX = new G4UIcmdWithADoubleAndUnit(
0076                 ( CexmcMessenger::gunDirName + "fwhmDirX" ).c_str(), this );
0077     fwhmDirX->SetGuidance( "Set directional fwhm of the beam along X axis" );
0078     fwhmDirX->SetParameterName( "FwhmDirX", false );
0079     fwhmDirX->SetDefaultValue( 0 );
0080     fwhmDirX->SetUnitCandidates( "deg rad" );
0081     fwhmDirX->SetDefaultUnit( "deg" );
0082     fwhmDirX->AvailableForStates( G4State_PreInit, G4State_Idle );
0083 
0084     fwhmDirY = new G4UIcmdWithADoubleAndUnit(
0085                 ( CexmcMessenger::gunDirName + "fwhmDirY" ).c_str(), this );
0086     fwhmDirY->SetGuidance( "Set directional fwhm of the beam along Y axis" );
0087     fwhmDirY->SetParameterName( "FwhmDirY", false );
0088     fwhmDirY->SetDefaultValue( 0 );
0089     fwhmDirY->SetUnitCandidates( "deg rad" );
0090     fwhmDirY->SetDefaultUnit( "deg" );
0091     fwhmDirY->AvailableForStates( G4State_PreInit, G4State_Idle );
0092 
0093     fwhmMomentumAmp = new G4UIcmdWithADouble(
0094             ( CexmcMessenger::gunDirName + "fwhmMomentumAmp" ).c_str(), this );
0095     fwhmMomentumAmp->SetGuidance( "Set fwhm of the beam momentum as fraction "
0096                                   "of its value" );
0097     fwhmMomentumAmp->SetParameterName( "FwhmMomentumAmp", false );
0098     fwhmMomentumAmp->SetDefaultValue( 0 );
0099     fwhmMomentumAmp->AvailableForStates( G4State_PreInit, G4State_Idle );
0100 }
0101 
0102 
0103 CexmcPrimaryGeneratorActionMessenger::~CexmcPrimaryGeneratorActionMessenger()
0104 {
0105     delete fwhmPosX;
0106     delete fwhmPosY;
0107     delete fwhmDirX;
0108     delete fwhmDirY;
0109     delete fwhmMomentumAmp;
0110 }
0111 
0112 
0113 void  CexmcPrimaryGeneratorActionMessenger::SetNewValue( G4UIcommand *  cmd,
0114                                                          G4String  value )
0115 {
0116     do
0117     {
0118         if ( cmd == fwhmPosX )
0119         {
0120             primaryGeneratorAction->SetFwhmPosX(
0121                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0122             break;
0123         }
0124         if ( cmd == fwhmPosY )
0125         {
0126             primaryGeneratorAction->SetFwhmPosY(
0127                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0128             break;
0129         }
0130         if ( cmd == fwhmDirX )
0131         {
0132             primaryGeneratorAction->SetFwhmDirX(
0133                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0134             break;
0135         }
0136         if ( cmd == fwhmDirY )
0137         {
0138             primaryGeneratorAction->SetFwhmDirY(
0139                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0140             break;
0141         }
0142         if ( cmd == fwhmMomentumAmp )
0143         {
0144             primaryGeneratorAction->SetFwhmMomentumAmp(
0145                         G4UIcmdWithADouble::GetNewDoubleValue( value ) );
0146             break;
0147         }
0148     } while ( false );
0149 }
0150