TF_Messenger.cc

Go to the documentation of this file.
00001 //! \file
00002 //!
00003 //! Source file for Time_of_Flight Messenger class for the user interface.
00004 //!
00005 //! Defines the singleton messenger class and its member routines which
00006 //! control the parameters of Time_of_Flight 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-04-12
00013 //!
00014 //! \ingroup control
00015 
00016 // Include user header files referenced in this file.
00017 
00018 #include "TF_Messenger.h"
00019 #include "TF_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 TF_Messenger * TF_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 TF_Messenger * TF_Messenger::Instance() {
00038    if( m_pInstance == 0 ) {
00039       m_pInstance = new TF_Messenger();
00040    }
00041    return m_pInstance;
00042 }
00043 
00044 TF_Messenger::TF_Messenger() {
00045 
00046    TFdir = new G4UIdirectory( "/Olympus/TF/" );
00047    TFdir->SetGuidance( "OLYMPUS Time of Flight user commands." );
00048 
00049 }
00050 
00051 void TF_Messenger::setTF_SDptr( TF_SD * ptr ) {
00052 
00053    pTF_SD = ptr;
00054 
00055    TF_SDdir = new G4UIdirectory( "/Olympus/TF/SD/" );
00056    TF_SDdir->SetGuidance( "Time of Flight Sensitive Detector commands." );
00057 
00058    // Threshold.
00059 
00060    TF_SDsetThreshold = new
00061       G4UIcmdWithADoubleAndUnit( "/Olympus/TF/SD/setThreshold", this );
00062    TF_SDsetThreshold->SetDefaultUnit( "eV" );
00063    TF_SDsetThreshold->SetGuidance( "Set hit threshold." );
00064    TF_SDsetThreshold->SetParameterName( "energy", false );
00065    TF_SDsetThreshold->SetRange( "energy >= 0.0" );
00066    TF_SDsetThreshold->AvailableForStates( G4State_Idle );
00067 
00068    TF_SDgetThreshold = new
00069       G4UIcmdWithoutParameter( "/Olympus/TF/SD/getThreshold", this );
00070    TF_SDgetThreshold->SetGuidance( "Get hit threshold." );
00071 
00072    // T resolution.
00073 
00074    TF_SDsetTresol = new
00075       G4UIcmdWithADoubleAndUnit( "/Olympus/TF/SD/setTresol", this );
00076    TF_SDsetTresol->SetDefaultUnit( "ns" );
00077    TF_SDsetTresol->SetGuidance( "Set T resolution." );
00078    TF_SDsetTresol->SetParameterName( "t", false );
00079    TF_SDsetTresol->SetRange( "t >= 0.0" );
00080    TF_SDsetTresol->AvailableForStates( G4State_Idle );
00081 
00082    TF_SDgetTresol = new
00083       G4UIcmdWithoutParameter( "/Olympus/TF/SD/getTresol", this );
00084    TF_SDgetTresol->SetGuidance( "Get T resolution." );
00085 
00086    // Y resolution.
00087 
00088    TF_SDsetYresol = new
00089       G4UIcmdWithADoubleAndUnit( "/Olympus/TF/SD/setYresol", this );
00090    TF_SDsetYresol->SetDefaultUnit( "um" );
00091    TF_SDsetYresol->SetGuidance( "Set Y resolution." );
00092    TF_SDsetYresol->SetParameterName( "y", false );
00093    TF_SDsetYresol->SetRange( "y >= 0.0" );
00094    TF_SDsetYresol->AvailableForStates( G4State_Idle );
00095 
00096    TF_SDgetYresol = new
00097       G4UIcmdWithoutParameter( "/Olympus/TF/SD/getYresol", this );
00098    TF_SDgetYresol->SetGuidance( "Get Y resolution." );
00099 
00100 }
00101 
00102 // Routines to set new values and get current values.
00103 
00104 void TF_Messenger::SetNewValue( G4UIcommand * command, G4String newValue ) {
00105 
00106    // TF_SD Threshold.
00107 
00108    if( command == TF_SDsetThreshold ) {
00109       pTF_SD->setThreshold( TF_SDsetThreshold->GetNewDoubleValue( newValue ) );
00110       G4cout << "TF_SD threshold = " << newValue << G4endl;
00111    }
00112    else if( command == TF_SDgetThreshold ) {
00113       G4cout << "TF_SD threshold = " << pTF_SD->getThreshold() / eV 
00114              << " [eV]" << G4endl;
00115    }
00116 
00117   // TF_SD T resolution.
00118 
00119    else if( command == TF_SDsetTresol ) {
00120       pTF_SD->setTresol( TF_SDsetTresol->GetNewDoubleValue( newValue ) );
00121       G4cout << "TF_SD T resolution = " << newValue << G4endl;
00122    }
00123    else if( command == TF_SDgetTresol ) {
00124       G4cout << "TF_SD T resolution = " << pTF_SD->getTresol() / ns 
00125              << " [ns]" << G4endl;
00126    }
00127 
00128   // TF_SD Y resolution.
00129 
00130    else if( command == TF_SDsetYresol ) {
00131       pTF_SD->setYresol( TF_SDsetYresol->GetNewDoubleValue( newValue ) );
00132       G4cout << "TF_SD Y resolution = " << newValue << G4endl;
00133    }
00134    else if( command == TF_SDgetYresol ) {
00135       G4cout << "TF_SD Y resolution = " << pTF_SD->getYresol() / um 
00136              << " [um]" << G4endl;
00137    }
00138 
00139 }
00140 
00141 // Routine to get current value (not used).
00142 
00143 G4String TF_Messenger::GetCurrentValue( G4UIcommand * command ) {
00144    G4String cv;
00145    return cv;
00146 }