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[ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/hadrontherapy/src/HadrontherapyPrimaryGeneratorMessenger.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/src/HadrontherapyPrimaryGeneratorMessenger.cc (Version 9.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Hadrontherapy advanced example for Geant4   <<  26 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application
 27 // See more at: https://twiki.cern.ch/twiki/bi <<  27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
                                                   >>  28 //
                                                   >>  29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request 
                                                   >>  30 // the *COMPLETE* version of this program, together with its documentation;
                                                   >>  31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
                                                   >>  32 // Institute in the framework of the MC-INFN Group
                                                   >>  33 //
 28                                                    34 
 29 #include "HadrontherapyPrimaryGeneratorMesseng     35 #include "HadrontherapyPrimaryGeneratorMessenger.hh"
 30 #include "HadrontherapyPrimaryGeneratorAction.     36 #include "HadrontherapyPrimaryGeneratorAction.hh"
 31 #include "G4UIdirectory.hh"                        37 #include "G4UIdirectory.hh"
 32 #include "G4UIcmdWithADoubleAndUnit.hh"            38 #include "G4UIcmdWithADoubleAndUnit.hh"
 33 #include "G4UIcmdWithADouble.hh"                   39 #include "G4UIcmdWithADouble.hh"
 34 #include "G4SystemOfUnits.hh"                  << 
 35 #include "G4UIcmdWithAString.hh"               << 
 36 #include "G4UIcmdWithAnInteger.hh"             << 
 37 #include "G4UIcmdWithABool.hh"                 << 
 38                                                    40 
 39 HadrontherapyPrimaryGeneratorMessenger::Hadron     41 HadrontherapyPrimaryGeneratorMessenger::HadrontherapyPrimaryGeneratorMessenger(
 40                                                <<  42                                              HadrontherapyPrimaryGeneratorAction* HadrontherapyGun)
 41 :HadrontherapyAction(HadrontherapyGun)             43 :HadrontherapyAction(HadrontherapyGun)
 42 {                                              <<  44 { 
 43                                                <<  45   //
 44     changeTheSource = new G4UIdirectory("/prim <<  46   // Definition of the interactive commands to modify the parameters of the
 45     changeTheSource -> SetGuidance("Command to <<  47   // generation of primary particles
 46                                                <<  48   // 
 47     NewSource = new G4UIcmdWithABool("/primary <<  49  beamParametersDir = new G4UIdirectory("/beam/");
 48     NewSource -> SetParameterName("NewSource " <<  50  beamParametersDir -> SetGuidance("set parameters of beam");
 49     NewSource -> SetDefaultValue("false");     <<  51  
 50     NewSource -> SetGuidance("Set if you want  <<  52  EnergyDir = new G4UIdirectory("/beam/energy/");  
 51                              "\n[usage]: /prim <<  53  EnergyDir -> SetGuidance ("set energy of beam");  
 52     NewSource -> AvailableForStates(G4State_Id <<  54 
 53                                                <<  55  particlePositionDir = new G4UIdirectory("/beam/position/");  
 54                                                <<  56  particlePositionDir -> SetGuidance ("set position of particle");  
 55     calculatedPhaseSpaceFileIN=new G4UIcmdWith <<  57 
 56     calculatedPhaseSpaceFileIN->SetDefaultValu <<  58  MomentumDir = new G4UIdirectory("/beam/momentum/");  
 57     calculatedPhaseSpaceFileIN->SetGuidance("f <<  59  MomentumDir -> SetGuidance ("set momentum of particle ");  
 58                                                <<  60 
 59                                                <<  61  sigmaMomentumYCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaY",this);
 60                                                <<  62  sigmaMomentumYCmd -> SetGuidance("set sigma momentum y");
                                                   >>  63  sigmaMomentumYCmd -> SetParameterName("momentum",false);
                                                   >>  64  sigmaMomentumYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >>  65 
                                                   >>  66  sigmaMomentumZCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaZ",this);
                                                   >>  67  sigmaMomentumZCmd -> SetGuidance("set sigma momentum z");
                                                   >>  68  sigmaMomentumZCmd -> SetParameterName("momentum",false);
                                                   >>  69  sigmaMomentumZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >>  70 
                                                   >>  71  meanKineticEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/meanEnergy",this);
                                                   >>  72  meanKineticEnergyCmd -> SetGuidance("set mean Kinetic energy");
                                                   >>  73  meanKineticEnergyCmd -> SetParameterName("Energy",false);
                                                   >>  74  meanKineticEnergyCmd -> SetDefaultUnit("MeV");
                                                   >>  75  meanKineticEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV");
                                                   >>  76  meanKineticEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >>  77  
                                                   >>  78  sigmaEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/sigmaEnergy",this);
                                                   >>  79  sigmaEnergyCmd -> SetGuidance("set sigma energy");
                                                   >>  80  sigmaEnergyCmd -> SetParameterName("Energy",false);
                                                   >>  81  sigmaEnergyCmd -> SetDefaultUnit("keV");
                                                   >>  82  sigmaEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV");
                                                   >>  83  sigmaEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >>  84  
                                                   >>  85  XpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Xposition",this);
                                                   >>  86  XpositionCmd -> SetGuidance("set x coordinate of particle");
                                                   >>  87  XpositionCmd -> SetParameterName("position",false);
                                                   >>  88  XpositionCmd -> SetDefaultUnit("mm");
                                                   >>  89  XpositionCmd -> SetUnitCandidates("mm cm m");
                                                   >>  90  XpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >>  91 
                                                   >>  92  YpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition",this);
                                                   >>  93  YpositionCmd -> SetGuidance("set y coordinate of particle");
                                                   >>  94  YpositionCmd -> SetParameterName("position",false);
                                                   >>  95  YpositionCmd -> SetDefaultUnit("mm");
                                                   >>  96  YpositionCmd -> SetUnitCandidates("mm cm m");
                                                   >>  97  YpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >>  98 
                                                   >>  99  sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition/sigmaY",this);
                                                   >> 100  sigmaYCmd -> SetGuidance("set sigma y");
                                                   >> 101  sigmaYCmd -> SetParameterName("position",false);
                                                   >> 102  sigmaYCmd -> SetDefaultUnit("mm");
                                                   >> 103  sigmaYCmd -> SetUnitCandidates("mm cm m");
                                                   >> 104  sigmaYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >> 105 
                                                   >> 106  ZpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition",this);
                                                   >> 107  ZpositionCmd -> SetGuidance("set z coordinate of particle");
                                                   >> 108  ZpositionCmd -> SetParameterName("position",false);
                                                   >> 109  ZpositionCmd -> SetDefaultUnit("mm");
                                                   >> 110  ZpositionCmd -> SetUnitCandidates("mm cm m");
                                                   >> 111  ZpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
                                                   >> 112 
                                                   >> 113  sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition/sigmaZ",this);
                                                   >> 114  sigmaZCmd -> SetGuidance("set sigma z");
                                                   >> 115  sigmaZCmd -> SetParameterName("position",false);
                                                   >> 116  sigmaZCmd -> SetDefaultUnit("mm");
                                                   >> 117  sigmaZCmd -> SetUnitCandidates("mm cm m");
                                                   >> 118  sigmaZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle);   
 61 }                                                 119 }
 62                                                   120 
 63 HadrontherapyPrimaryGeneratorMessenger::~Hadro    121 HadrontherapyPrimaryGeneratorMessenger::~HadrontherapyPrimaryGeneratorMessenger()
 64 {                                                 122 {
 65                                                << 123   delete beamParametersDir;
 66     delete NewSource;                          << 124   delete EnergyDir;
 67     delete changeTheSource;                    << 125   delete meanKineticEnergyCmd;  
 68     delete calculatedPhaseSpaceFileIN;         << 126   delete sigmaEnergyCmd;
 69                                                << 127   delete particlePositionDir;
 70                                                << 128   delete MomentumDir;
 71 }                                              << 129   delete XpositionCmd; 
 72                                                << 130   delete YpositionCmd; 
 73                                                << 131   delete ZpositionCmd; 
 74 void HadrontherapyPrimaryGeneratorMessenger::S << 132   delete sigmaYCmd; 
                                                   >> 133   delete sigmaZCmd; 
                                                   >> 134   delete sigmaMomentumYCmd; 
                                                   >> 135   delete sigmaMomentumZCmd; 
                                                   >> 136 }  
 75                                                   137 
                                                   >> 138 void HadrontherapyPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)                
 76 {                                                 139 {
 77     if (command == calculatedPhaseSpaceFileIN) << 140   if ( command == meanKineticEnergyCmd )                                                                        
 78     {                                          << 141     { HadrontherapyAction -> SetmeanKineticEnergy(meanKineticEnergyCmd
 79         HadrontherapyAction->setCalculatedPhas << 142               -> GetNewDoubleValue(newValue));}
 80     }                                          << 143   if ( command == sigmaEnergyCmd )                                                                        
 81                                                << 144     { HadrontherapyAction -> SetsigmaEnergy(sigmaEnergyCmd
 82     if (command == NewSource)                  << 145               -> GetNewDoubleValue(newValue));}
 83     {                                          << 146   if ( command == XpositionCmd )                                                                        
 84         HadrontherapyAction->setNewSource(NewS << 147     { HadrontherapyAction -> SetXposition(XpositionCmd
 85                                                << 148             -> GetNewDoubleValue(newValue));}
 86     }                                          << 149 
 87                                                << 150   if ( command == YpositionCmd )                                                                        
 88 }                                              << 151     { HadrontherapyAction -> SetYposition(YpositionCmd
 89                                                << 152             -> GetNewDoubleValue(newValue));}
 90                                                << 153 
 91                                                << 154   if ( command == ZpositionCmd )                                                                        
                                                   >> 155     { HadrontherapyAction -> SetZposition(ZpositionCmd
                                                   >> 156             -> GetNewDoubleValue(newValue));}
                                                   >> 157 
                                                   >> 158   if ( command == sigmaYCmd )                                                                        
                                                   >> 159     { HadrontherapyAction -> SetsigmaY(sigmaYCmd
                                                   >> 160                -> GetNewDoubleValue(newValue));}
                                                   >> 161 
                                                   >> 162   if ( command == sigmaZCmd )                                                                        
                                                   >> 163     { HadrontherapyAction -> SetsigmaZ(sigmaZCmd
                                                   >> 164                -> GetNewDoubleValue(newValue));}
                                                   >> 165 
                                                   >> 166   if ( command == sigmaMomentumYCmd )                                                                        
                                                   >> 167     { HadrontherapyAction -> SetsigmaMomentumY(sigmaMomentumYCmd
                                                   >> 168                  -> GetNewDoubleValue(newValue));}
                                                   >> 169 
                                                   >> 170   if ( command == sigmaMomentumZCmd )                                                                        
                                                   >> 171     { HadrontherapyAction -> SetsigmaMomentumZ(sigmaMomentumZCmd
                                                   >> 172                  -> GetNewDoubleValue(newValue));}
                                                   >> 173 }                 
 92                                                   174