LM_Messenger.cc

Go to the documentation of this file.
00001 //! \file
00002 //!
00003 //! Source file for Luminosity_Monitor messenger class for the user interface.
00004 //!
00005 //! Defines the singleton messenger class and its member routines which
00006 //! control the parameters of Luminosity_Monitor 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-31
00013 //!
00014 //! \ingroup control
00015 
00016 // Include user header files referenced in this file.
00017 
00018 #include "LM_Messenger.h"
00019 #include "LM_SD.h"
00020 
00021 // Include the GEANT4 header files referenced in this file.
00022 
00023 #include "G4UIdirectory.hh"
00024 
00025 // Initialise the static data pointer for the Messenger class.
00026 
00027 LM_Messenger * LM_Messenger::m_pInstance = 0;
00028 
00029 // Use the standard namespace.
00030 
00031 using namespace std;
00032 
00033 // *+****1****+****2****+****3****+****4****+****5****+****6****+****7****+****
00034 
00035 // Define the routine to return pointer to the instance of Messenger.
00036 
00037 LM_Messenger * LM_Messenger::Instance() {
00038    if( m_pInstance == 0 ) {
00039       m_pInstance = new LM_Messenger();
00040    }
00041    return m_pInstance;
00042 }
00043 
00044 // Constructor of LM_Messenger class.
00045 
00046 LM_Messenger::LM_Messenger() {
00047 
00048    LMdir = new G4UIdirectory( "/Olympus/LM/" );
00049    LMdir->SetGuidance( "OLYMPUS Luminosity Monitor user commands." );
00050 
00051 }
00052 
00053 // Routine to set a pointer to the GT_SD class and define the user
00054 // functions available.
00055 
00056 void LM_Messenger::setLM_SDptr( LM_SD * ptr ) {
00057 
00058    pLM_SD = ptr;
00059 
00060    LM_SDdir = new G4UIdirectory( "/Olympus/LM/SD/" );
00061    LM_SDdir->SetGuidance( "Luminosity Monitor Sensitive Detector commands." );
00062 
00063    // Threshold.
00064 
00065    LM_SDsetThreshold = new
00066       G4UIcmdWithADoubleAndUnit( "/Olympus/LM/SD/setThreshold", this );
00067    LM_SDsetThreshold->SetDefaultUnit( "eV" );
00068    LM_SDsetThreshold->SetGuidance( "Set hit threshold." );
00069    LM_SDsetThreshold->SetParameterName( "energy", false );
00070    LM_SDsetThreshold->SetRange( "energy >= 0.0" );
00071    LM_SDsetThreshold->AvailableForStates( G4State_Idle );
00072 
00073    LM_SDgetThreshold = new
00074       G4UIcmdWithoutParameter( "/Olympus/LM/SD/getThreshold", this );
00075    LM_SDgetThreshold->SetGuidance( "Get hit threshold." );
00076 
00077    // X resolution.
00078 
00079    LM_SDsetXresol = new
00080       G4UIcmdWithADoubleAndUnit( "/Olympus/LM/SD/setXresol", this );
00081    LM_SDsetXresol->SetDefaultUnit( "um" );
00082    LM_SDsetXresol->SetGuidance( "Set X resolution." );
00083    LM_SDsetXresol->SetParameterName( "x", false );
00084    LM_SDsetXresol->SetRange( "x >= 0.0" );
00085    LM_SDsetXresol->AvailableForStates( G4State_Idle );
00086 
00087    LM_SDgetXresol = new
00088       G4UIcmdWithoutParameter( "/Olympus/LM/SD/getXresol", this );
00089    LM_SDgetXresol->SetGuidance( "Get X resolution." );
00090 
00091    // Y resolution.
00092 
00093    LM_SDsetYresol = new
00094       G4UIcmdWithADoubleAndUnit( "/Olympus/LM/SD/setYresol", this );
00095    LM_SDsetYresol->SetDefaultUnit( "um" );
00096    LM_SDsetYresol->SetGuidance( "Set Y resolution." );
00097    LM_SDsetYresol->SetParameterName( "y", false );
00098    LM_SDsetYresol->SetRange( "y >= 0.0" );
00099    LM_SDsetYresol->AvailableForStates( G4State_Idle );
00100 
00101    LM_SDgetYresol = new
00102       G4UIcmdWithoutParameter( "/Olympus/LM/SD/getYresol", this );
00103    LM_SDgetYresol->SetGuidance( "Get Y resolution." );
00104 
00105 }
00106 
00107 // Routines to set new values and get current values.
00108 
00109 void LM_Messenger::SetNewValue( G4UIcommand * command, G4String newValue ) {
00110 
00111    // LM_SD Threshold.
00112 
00113    if( command == LM_SDsetThreshold ) {
00114       pLM_SD->setThreshold( LM_SDsetThreshold->GetNewDoubleValue( newValue ) );
00115       G4cout << "LM_SD threshold = " << newValue << G4endl;
00116    }
00117    else if( command == LM_SDgetThreshold ) {
00118       G4cout << "LM_SD threshold = " << pLM_SD->getThreshold() / eV 
00119              << " [eV]" << G4endl;
00120    }
00121 
00122   // LM_SD X resolution.
00123 
00124    else if( command == LM_SDsetXresol ) {
00125       pLM_SD->setXresol( LM_SDsetXresol->GetNewDoubleValue( newValue ) );
00126       G4cout << "LM_SD X resolution = " << newValue << G4endl;
00127    }
00128    else if( command == LM_SDgetXresol ) {
00129       G4cout << "LM_SD X resolution = " << pLM_SD->getXresol() / um 
00130              << " [um]" << G4endl;
00131    }
00132 
00133   // LM_SD Y resolution.
00134 
00135    else if( command == LM_SDsetYresol ) {
00136       pLM_SD->setYresol( LM_SDsetYresol->GetNewDoubleValue( newValue ) );
00137       G4cout << "LM_SD Y resolution = " << newValue << G4endl;
00138    }
00139    else if( command == LM_SDgetYresol ) {
00140       G4cout << "LM_SD Y resolution = " << pLM_SD->getYresol() / um 
00141              << " [um]" << G4endl;
00142    }
00143 
00144 }
00145 
00146 // Get current value.
00147 
00148 G4String LM_Messenger::GetCurrentValue( G4UIcommand * command ) {
00149    G4String cv;
00150    return cv;
00151 }