G4ProductionCutsTableMessenger.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 //
00027 // $Id$
00028 //
00029 // 
00030 //---------------------------------------------------------------
00031 //
00032 //  G4ProductionCutsTableMessenger.cc
00033 // ------------------------------------------------------------
00034 //      History
00035 //        first version                   02 Mar. 2008 by H.Kurashige 
00036 //
00037 
00038 #include "G4ProductionCutsTableMessenger.hh"
00039 #include "G4ProductionCutsTable.hh"
00040 
00041 #include "G4UIdirectory.hh"
00042 #include "G4UIcmdWithoutParameter.hh"
00043 #include "G4UIcmdWithAnInteger.hh"
00044 #include "G4UIcmdWithADoubleAndUnit.hh"
00045 #include "G4UIcmdWithAString.hh"
00046 #include "G4ios.hh"
00047 #include "G4Tokenizer.hh"           
00048 
00049 #include <sstream>
00050 
00051 G4ProductionCutsTableMessenger::G4ProductionCutsTableMessenger(   G4ProductionCutsTable* pTable)
00052   :theCutsTable(pTable)
00053 {
00054   // /cuts/   directory
00055   theDirectory = new G4UIdirectory("/cuts/");
00056   theDirectory->SetGuidance("Commands for G4VUserPhysicsList.");
00057 
00058   // /cuts/verbose command
00059   verboseCmd = new G4UIcmdWithAnInteger("/cuts/verbose",this);
00060   verboseCmd->SetGuidance("Set the Verbose level of G4ProductionCutsTable.");
00061   verboseCmd->SetGuidance(" 0 : Silent (default)");
00062   verboseCmd->SetGuidance(" 1 : Display warning messages");
00063   verboseCmd->SetGuidance(" 2 : Display more info");
00064   verboseCmd->SetGuidance(" 2 : Display debug info");
00065   verboseCmd->SetParameterName("level",true);
00066   verboseCmd->SetDefaultValue(0);
00067   verboseCmd->SetRange("level >=0 && level <=3");
00068 
00069   // /cuts/setLowEdge command
00070   setLowEdgeCmd = new G4UIcmdWithADoubleAndUnit("/cuts/setLowEdge",this);
00071   setLowEdgeCmd->SetGuidance("Set low edge energy value ");
00072   setLowEdgeCmd->SetParameterName("edge",false);
00073   setLowEdgeCmd->SetDefaultValue(0.99);
00074   setLowEdgeCmd->SetRange("edge >0.0");
00075   setLowEdgeCmd->SetDefaultUnit("keV");
00076   setLowEdgeCmd->AvailableForStates(G4State_PreInit);
00077 
00078   // /cuts/setHighEdge command
00079   setHighEdgeCmd = new G4UIcmdWithADoubleAndUnit("/cuts/setHighEdge",this);
00080   setHighEdgeCmd->SetGuidance("Set high edge energy value ");
00081   setHighEdgeCmd->SetParameterName("edge",false);
00082   setHighEdgeCmd->SetDefaultValue(100.0);
00083   setHighEdgeCmd->SetRange("edge >0.0");
00084   setHighEdgeCmd->SetDefaultUnit("TeV");
00085   setHighEdgeCmd->AvailableForStates(G4State_PreInit);
00086  
00087   // /cuts/setMaxCutEnergy command
00088   setMaxEnergyCutCmd = new G4UIcmdWithADoubleAndUnit("/cuts/setMaxCutEnergy",this);
00089   setMaxEnergyCutCmd->SetGuidance("Set maximum of cut energy value ");
00090   setMaxEnergyCutCmd->SetParameterName("cut",false);
00091   setMaxEnergyCutCmd->SetDefaultValue(10.0);
00092   setMaxEnergyCutCmd->SetRange("cut >0.0");
00093   setMaxEnergyCutCmd->SetDefaultUnit("GeV");
00094   setMaxEnergyCutCmd->AvailableForStates(G4State_PreInit);
00095  
00096  // /cuts/dump command
00097   dumpCmd = new G4UIcmdWithoutParameter("/cuts/dump",this);
00098   dumpCmd->SetGuidance("Dump cuplues in ProductuinCutsTable. ");
00099 
00100 }
00101 
00102 G4ProductionCutsTableMessenger::~G4ProductionCutsTableMessenger()
00103 {
00104   delete dumpCmd;
00105   delete setMaxEnergyCutCmd;
00106   delete setHighEdgeCmd;
00107   delete setLowEdgeCmd;
00108   delete verboseCmd;
00109   delete theDirectory;
00110 }
00111 
00112 void G4ProductionCutsTableMessenger::SetNewValue(G4UIcommand * command,
00113                                                  G4String newValue)
00114 {
00115   if( command==verboseCmd ) {
00116     theCutsTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); 
00117 
00118   } else if( command==dumpCmd ){
00119     theCutsTable-> DumpCouples();
00120 
00121   } else if( command==setLowEdgeCmd ){
00122     G4double lowEdge = setLowEdgeCmd->GetNewDoubleValue(newValue); 
00123     G4double highEdge = theCutsTable->GetHighEdgeEnergy();
00124     theCutsTable->SetEnergyRange(lowEdge, highEdge);
00125     
00126   } else if( command==setHighEdgeCmd ){
00127     G4double highEdge = setHighEdgeCmd->GetNewDoubleValue(newValue); 
00128     G4double lowEdge = theCutsTable->GetLowEdgeEnergy();
00129     theCutsTable->SetEnergyRange(lowEdge, highEdge);
00130     
00131  } else if( command==setMaxEnergyCutCmd ){
00132     G4double cut = setHighEdgeCmd->GetNewDoubleValue(newValue); 
00133     theCutsTable->SetMaxEnergyCut(cut);
00134     
00135   }
00136 }
00137 
00138 G4String G4ProductionCutsTableMessenger::GetCurrentValue(G4UIcommand * command)
00139 {
00140   G4String cv;
00141   
00142   if( command==verboseCmd ){
00143    cv = verboseCmd->ConvertToString(theCutsTable->GetVerboseLevel());
00144 
00145  } else if( command==setLowEdgeCmd ){
00146     G4double lowEdge = theCutsTable->GetLowEdgeEnergy();
00147     cv = setLowEdgeCmd->ConvertToString( lowEdge, "keV" );
00148 
00149  } else if( command==setHighEdgeCmd ){
00150     G4double highEdge = theCutsTable->GetHighEdgeEnergy();
00151     cv = setHighEdgeCmd->ConvertToString( highEdge, "TeV" );
00152 
00153  } else if( command==setMaxEnergyCutCmd ){
00154     G4double cut = theCutsTable->GetMaxEnergyCut();
00155     cv = setMaxEnergyCutCmd->ConvertToString( cut, "GeV" );
00156  }
00157 
00158 
00159   return cv;
00160 
00161 }
00162 

Generated on Mon May 27 17:49:26 2013 for Geant4 by  doxygen 1.4.7