SM_Messenger.cc

Go to the documentation of this file.
00001 //! \file
00002 //!
00003 //! Source file for Symmetric_Moeller messenger class for the user interface.
00004 //!
00005 //! Defines the singleton messenger class and its member routines which
00006 //! control the parameters of Symmetric_Moeller detector within the OLYMPUS
00007 //! Monte Carlo.  This allow the user to control the parameters and/or
00008 //! running from command files or interactively.
00009 //!
00010 //! \author D.K. Hasell
00011 //! \version 1.0
00012 //! \date 2010-10-17
00013 //!
00014 //! \ingroup control
00015 
00016 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00017 
00018 // Include user header files referenced in this file.
00019 
00020 #include "SM_Messenger.h"
00021 #include "SM_SD.h"
00022 
00023 // Include the GEANT4 header files referenced in this file.
00024 
00025 #include "G4UIdirectory.hh"
00026 
00027 // Initialise the static data pointer for the SM_Messenger class.
00028 
00029 SM_Messenger * SM_Messenger::m_pInstance = 0;
00030 
00031 // Use the standard namespace.
00032 
00033 using namespace std;
00034 
00035 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00036 
00037 // Define the routine to return pointer to the instance of SM_Messenger.
00038 
00039 SM_Messenger * SM_Messenger::Instance() {
00040    if( m_pInstance == 0 ) {
00041       m_pInstance = new SM_Messenger();
00042    }
00043    return m_pInstance;
00044 }
00045 
00046 // Constructor of SM_Messenger class.
00047 
00048 SM_Messenger::SM_Messenger() {
00049 
00050    SMdir = new G4UIdirectory( "/Olympus/SM/" );
00051    SMdir->SetGuidance( "OLYMPUS Symmetric Moeller user commands." );
00052 
00053 }
00054 
00055 // Routine to set a pointer to the SM_SD class and define the user
00056 // functions available.
00057 
00058 void SM_Messenger::setSM_SDptr( SM_SD * ptr ) {
00059 
00060    pSM_SD = ptr;
00061 
00062    SM_SDdir = new G4UIdirectory( "/Olympus/SM/SD/" );
00063    SM_SDdir->SetGuidance( "Symmetric Moeller Sensitive Detector commands." );
00064 
00065    // Threshold.
00066 
00067    SM_SDsetThreshold = new
00068       G4UIcmdWithADoubleAndUnit( "/Olympus/SM/SD/setThreshold", this );
00069    SM_SDsetThreshold->SetDefaultUnit( "eV" );
00070    SM_SDsetThreshold->SetGuidance( "Set hit threshold." );
00071    SM_SDsetThreshold->SetParameterName( "energy", false );
00072    SM_SDsetThreshold->SetRange( "energy >= 0.0" );
00073    SM_SDsetThreshold->AvailableForStates( G4State_Idle );
00074 
00075    SM_SDgetThreshold = new
00076       G4UIcmdWithoutParameter( "/Olympus/SM/SD/getThreshold", this );
00077    SM_SDgetThreshold->SetGuidance( "Get hit threshold." );
00078 
00079    // Energy resolution.
00080 
00081    SM_SDsetEresol = new
00082       G4UIcmdWithADoubleAndUnit( "/Olympus/SM/SD/setEresol", this );
00083    SM_SDsetEresol->SetDefaultUnit( "eV" );
00084    SM_SDsetEresol->SetGuidance( "Set Energy resolution." );
00085    SM_SDsetEresol->SetParameterName( "E", false );
00086    SM_SDsetEresol->SetRange( "E >= 0.0" );
00087    SM_SDsetEresol->AvailableForStates( G4State_Idle );
00088 
00089    SM_SDgetEresol = new
00090       G4UIcmdWithoutParameter( "/Olympus/SM/SD/getEresol", this );
00091    SM_SDgetEresol->SetGuidance( "Get E resolution." );
00092 
00093 }
00094 
00095 // Routines to set new values and get current values.
00096 
00097 void SM_Messenger::SetNewValue( G4UIcommand * command, G4String newValue ) {
00098 
00099    // SM_SD Threshold.
00100 
00101    if( command == SM_SDsetThreshold ) {
00102       pSM_SD->setThreshold( SM_SDsetThreshold->GetNewDoubleValue( newValue ) );
00103       G4cout << "SM_SD threshold = " << newValue << G4endl;
00104    }
00105    else if( command == SM_SDgetThreshold ) {
00106       G4cout << "SM_SD threshold = " << pSM_SD->getThreshold() / eV 
00107              << " [eV]" << G4endl;
00108    }
00109 
00110    // SM_SD Energy resolution.
00111 
00112     else if( command == SM_SDsetEresol ) {
00113        pSM_SD->setEresol( SM_SDsetEresol->GetNewDoubleValue( newValue ) );
00114        G4cout << "SM_SD E resolution = " << newValue << G4endl;
00115     }
00116     else if( command == SM_SDgetEresol ) {
00117        G4cout << "SM_SD E resolution = " << pSM_SD->getEresol() / um 
00118               << " [eV]" << G4endl;
00119     }
00120 
00121 }
00122 
00123 // Routine to get current value (not used).
00124 
00125 G4String SM_Messenger::GetCurrentValue( G4UIcommand * command ) {
00126    G4String cv;
00127    return cv;
00128 }