DetectorMessenger.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 /// \file hadronic/Hadr00/src/DetectorMessenger.cc
00027 /// \brief Implementation of the DetectorMessenger class
00028 //
00029 //
00030 // $Id$
00031 //
00032 //
00033 /////////////////////////////////////////////////////////////////////////
00034 //
00035 // DetectorMessenger
00036 //
00037 // Created: 20.06.08 V.Ivanchenko
00038 //
00039 // Modified:
00040 //
00041 ////////////////////////////////////////////////////////////////////////
00042 //
00043 
00044 #include "DetectorMessenger.hh"
00045 
00046 #include "DetectorConstruction.hh"
00047 #include "G4UIdirectory.hh"
00048 #include "G4UIcmdWithABool.hh"
00049 #include "G4UIcmdWithAString.hh"
00050 #include "G4UIcmdWithAnInteger.hh"
00051 #include "G4UIcmdWith3Vector.hh"
00052 #include "G4UIcmdWithADoubleAndUnit.hh"
00053 #include "G4UIcmdWithoutParameter.hh"
00054 #include "HistoManager.hh"
00055 
00056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00057 
00058 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
00059 :fDetector(Det)
00060 {
00061   ftestDir = new G4UIdirectory("/testhadr/");
00062   ftestDir->SetGuidance(" Hadronic Extended Example.");
00063 
00064   fmatCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this);
00065   fmatCmd->SetGuidance("Select Material for the target");
00066   fmatCmd->SetParameterName("tMaterial",false);
00067   fmatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00068 
00069   fmat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this);
00070   fmat1Cmd->SetGuidance("Select Material for world");
00071   fmat1Cmd->SetParameterName("wMaterial",false);
00072   fmat1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00073 
00074   frCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this);
00075   frCmd->SetGuidance("Set radius of the target");
00076   frCmd->SetParameterName("radius",false);
00077   frCmd->SetUnitCategory("Length");
00078   frCmd->SetRange("radius>0");
00079   frCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00080 
00081   flCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this);
00082   flCmd->SetGuidance("Set length of the target");
00083   flCmd->SetParameterName("length",false);
00084   flCmd->SetUnitCategory("Length");
00085   flCmd->SetRange("length>0");
00086   flCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00087 
00088   fbinCmd = new G4UIcmdWithAnInteger("/testhadr/nBinsE",this);
00089   fbinCmd->SetGuidance("Set number of bins for energy");
00090   fbinCmd->SetParameterName("NEbins",false);
00091   fbinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00092 
00093   fnOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/nBinsP",this);
00094   fnOfAbsCmd->SetGuidance("Set number of bins for momentum");
00095   fnOfAbsCmd->SetParameterName("NPbins",false);
00096   fnOfAbsCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00097 
00098   fupdateCmd = new G4UIcmdWithoutParameter("/testhadr/update",this);
00099   fupdateCmd->SetGuidance("Update geometry.");
00100   fupdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00101   fupdateCmd->SetGuidance("if you changed geometrical value(s)");
00102   fupdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00103 
00104   fpartCmd = new G4UIcmdWithAString("/testhadr/particle",this);
00105   fpartCmd->SetGuidance("Set particle name");
00106   fpartCmd->SetParameterName("Particle",false);
00107   fpartCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00108 
00109   fcsCmd = new G4UIcmdWithAString("/testhadr/targetElm",this);
00110   fcsCmd->SetGuidance("Set element name");
00111   fcsCmd->SetParameterName("Elm",false);
00112   fcsCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00113 
00114   fe1Cmd = new G4UIcmdWithADoubleAndUnit("/testhadr/minEnergy",this);
00115   fe1Cmd->SetGuidance("Set min kinetic energy");
00116   fe1Cmd->SetParameterName("eMin",false);
00117   fe1Cmd->SetUnitCategory("Energy");
00118   fe1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00119 
00120   fe2Cmd = new G4UIcmdWithADoubleAndUnit("/testhadr/maxEnergy",this);
00121   fe2Cmd->SetGuidance("Set max kinetic energy");
00122   fe2Cmd->SetParameterName("eMax",false);
00123   fe2Cmd->SetUnitCategory("Energy");
00124   fe2Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00125 
00126   fp1Cmd = new G4UIcmdWithADoubleAndUnit("/testhadr/minMomentum",this);
00127   fp1Cmd->SetGuidance("Set min momentum");
00128   fp1Cmd->SetParameterName("pMin",false);
00129   fp1Cmd->SetUnitCategory("Energy");
00130   fp1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00131 
00132   fp2Cmd = new G4UIcmdWithADoubleAndUnit("/testhadr/maxMomentum",this);
00133   fp2Cmd->SetGuidance("Set max momentum");
00134   fp2Cmd->SetParameterName("pMax",false);
00135   fp2Cmd->SetUnitCategory("Energy");
00136   fp2Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00137 
00138   fverbCmd = new G4UIcmdWithAnInteger("/testhadr/verbose",this);
00139   fverbCmd->SetGuidance("Set verbose for ");
00140   fverbCmd->SetParameterName("verb",false);
00141   fverbCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00142 }
00143 
00144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00145 
00146 DetectorMessenger::~DetectorMessenger()
00147 {
00148   delete fmatCmd;
00149   delete fmat1Cmd;
00150   delete frCmd;
00151   delete flCmd;
00152   delete fnOfAbsCmd;
00153   delete fupdateCmd;
00154   delete ftestDir;
00155   delete fpartCmd;
00156   delete fcsCmd;
00157   delete fe1Cmd;
00158   delete fe2Cmd;
00159   delete fp1Cmd;
00160   delete fp2Cmd;
00161   delete fverbCmd;
00162 }
00163 
00164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00165 
00166 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
00167 {
00168   HistoManager* histo = HistoManager::GetPointer();
00169   if( command == fmatCmd ) {
00170     fDetector->SetTargetMaterial(newValue);
00171   } else if( command == fmat1Cmd ) {
00172     fDetector->SetWorldMaterial(newValue);
00173   } else if( command == frCmd ) {
00174     fDetector->SetTargetRadius(frCmd->GetNewDoubleValue(newValue));
00175   } else if( command == flCmd ) { 
00176     fDetector->SetTargetLength(flCmd->GetNewDoubleValue(newValue));
00177   } else if( command == fupdateCmd ) {
00178     fDetector->UpdateGeometry();
00179   } else if( command == fbinCmd ) {
00180     histo->SetNumberOfBinsE(fbinCmd->GetNewIntValue(newValue));
00181   } else if( command == fnOfAbsCmd ) { 
00182     histo->SetNumberOfBinsP(fnOfAbsCmd->GetNewIntValue(newValue));
00183   } else if( command == fverbCmd ) {
00184     histo->SetVerbose(fverbCmd->GetNewIntValue(newValue));
00185   } else if( command == fpartCmd ) {
00186     histo->SetParticleName(newValue);
00187   } else if( command == fcsCmd ) {
00188     histo->SetElementName(newValue);
00189   } else if( command == fe1Cmd ) { 
00190     histo->SetMinKinEnergy(fe1Cmd->GetNewDoubleValue(newValue));
00191   } else if( command == fe2Cmd ) { 
00192     histo->SetMaxKinEnergy(fe2Cmd->GetNewDoubleValue(newValue));
00193   } else if( command == fp1Cmd ) { 
00194     histo->SetMinMomentum(fp1Cmd->GetNewDoubleValue(newValue));
00195   } else if( command == fp2Cmd ) { 
00196     histo->SetMaxMomentum(fp2Cmd->GetNewDoubleValue(newValue));
00197   }
00198 }
00199 
00200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00201 

Generated on 19 Feb 2017 for QwGeant4 by  doxygen 1.6.1