Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Previous authors: G. Guerrieri, S. Guatelli, and M. G. Pia, INFN Genova, Italy
0027 // Authors (since 2007): S. Guatelli, University of Wollongong, Australia
0028 //
0029 #include "G4HumanPhantomMessenger.hh"
0030 #include "G4HumanPhantomConstruction.hh"
0031 
0032 #include "G4UIdirectory.hh"
0033 #include "G4UIcmdWithAString.hh"
0034 #include "G4UIcmdWithoutParameter.hh"
0035 
0036 #include "globals.hh"
0037 
0038 #include "G4RunManager.hh"
0039 
0040 G4HumanPhantomMessenger::G4HumanPhantomMessenger(G4HumanPhantomConstruction* myUsrPhtm)
0041   :fUserPhantom(myUsrPhtm),fBps(false)
0042 { 
0043   fPhantomDir = new G4UIdirectory("/phantom/");
0044   fPhantomDir->SetGuidance("Set Your Phantom.");
0045   
0046   fDir = new G4UIdirectory("/bodypart/");
0047   fDir->SetGuidance("Add Body Part to Phantom");
0048 
0049   fModelCmd = new G4UIcmdWithAString("/phantom/setPhantomModel",this);
0050   fModelCmd->SetGuidance("Set sex of Phantom: MIRD, ORNLFemale, ORNLMale, MIX, MIRDHead, ORNLHead.");
0051   fModelCmd->SetParameterName("phantomModel",true);
0052   fModelCmd->SetDefaultValue("MIRD");
0053   fModelCmd->SetCandidates("MIRD ORNLFemale ORNLMale MIRDHead ORNLHead");
0054   fModelCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0055 
0056   fSexCmd = new G4UIcmdWithAString("/phantom/setPhantomSex",this);
0057   fSexCmd->SetGuidance("Set sex of Phantom: Male or Female.");
0058   fSexCmd->SetParameterName("phantomSex",true);
0059   fSexCmd->SetDefaultValue("Female");
0060   fSexCmd->SetCandidates("Male Female");
0061   fSexCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
0062   
0063   fBodypartCmd = new G4UIcmdWithAString("/bodypart/addBodyPart",this);
0064   fBodypartCmd->SetGuidance("Add a Body Part to Phantom");
0065   fBodypartCmd->SetParameterName("bpName",true);
0066   fBodypartCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0067   
0068   fEndCmd = new G4UIcmdWithoutParameter("/phantom/buildNewPhantom",this);
0069   fEndCmd->SetGuidance("Build your Phantom.");
0070   fEndCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
0071 }
0072 
0073 G4HumanPhantomMessenger::~G4HumanPhantomMessenger()
0074 {
0075   delete  fModelCmd;
0076   delete  fSexCmd;
0077   delete  fBodypartCmd;
0078   delete  fEndCmd;
0079   delete  fPhantomDir;
0080   delete  fDir;
0081 }
0082 
0083 void G4HumanPhantomMessenger::SetNewValue(G4UIcommand* command,G4String newValue){ 
0084 
0085   if( command == fModelCmd )
0086     { 
0087       fUserPhantom->SetPhantomModel(newValue); 
0088     }       
0089   if( command == fSexCmd )
0090     { 
0091       fUserPhantom->SetPhantomSex(newValue); 
0092     }
0093   if( command == fBodypartCmd )
0094     {
0095       AddBodyPart(newValue);
0096     }
0097   if( command == fEndCmd )
0098     { 
0099       G4cout << 
0100     " ****************>>>> NEW PHANTOM CONSTRUCTION <<<<***************** " 
0101          << G4endl;
0102     }
0103 }
0104 
0105 void  G4HumanPhantomMessenger::AddBodyPart(G4String newBodyPartSensitivity)
0106 {
0107   char* str = new char[newBodyPartSensitivity.length()+1];
0108 
0109   strcpy(str, newBodyPartSensitivity.c_str()); 
0110   
0111   std::string bpart = strtok(str," ");
0112 
0113   std::string sensitivity = strtok(nullptr," ");
0114 
0115   if(sensitivity=="yes"){
0116     fBps=true;
0117   }else{
0118     fBps=false;
0119   }
0120 
0121   G4cout << " >>> Body Part = " << bpart << "\n"
0122      << " >>> Sensitivity = " << sensitivity << G4endl;
0123 
0124   fUserPhantom->SetBodyPartSensitivity(bpart,fBps);
0125 }
0126