Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:17

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 // Hadrontherapy advanced example for Geant4
0027 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
0028 
0029 #include "HadrontherapyAnalysisFileMessenger.hh"
0030 #include "G4UIcmdWithAString.hh"
0031 #include "G4UIcmdWithABool.hh"
0032 #include "G4UIdirectory.hh"
0033 #include "G4SystemOfUnits.hh"
0034 
0035 #include "HadrontherapyMatrix.hh"
0036 #include "HadrontherapyLet.hh"
0037 
0038 /////////////////////////////////////////////////////////////////////////////
0039 HadrontherapyAnalysisFileMessenger::HadrontherapyAnalysisFileMessenger(HadrontherapyAnalysis* amgr)
0040 :AnalysisManager(amgr)
0041 {
0042     secondaryCmd = new G4UIcmdWithABool("/analysis/secondary",this);
0043     secondaryCmd -> SetParameterName("secondary", true);
0044     secondaryCmd -> SetDefaultValue("true");
0045     secondaryCmd -> SetGuidance("Set if dose/fluence for the secondary particles will be written"
0046                                 "\n[usage]: /analysis/secondary [true/false]");
0047     secondaryCmd -> AvailableForStates(G4State_Idle, G4State_PreInit);
0048     
0049     DoseMatrixCmd = new G4UIcmdWithAString("/analysis/writeDoseFile",this);
0050     DoseMatrixCmd->SetGuidance("Write the dose/fluence to an ASCII file");
0051     DoseMatrixCmd->SetDefaultValue("Dose.out");
0052     DoseMatrixCmd->SetParameterName("choice",true);
0053     
0054     LetCmd = new G4UIcmdWithABool("/analysis/computeLet",this);
0055     LetCmd  -> SetParameterName("choice",true);
0056     LetCmd  -> SetDefaultValue(true);
0057     LetCmd  -> SetGuidance("Set if Let must be computed and write the ASCII filename for the Let");
0058     LetCmd  -> AvailableForStates(G4State_Idle, G4State_PreInit);
0059     
0060 }
0061 
0062 /////////////////////////////////////////////////////////////////////////////
0063 HadrontherapyAnalysisFileMessenger::~HadrontherapyAnalysisFileMessenger()
0064 {
0065     delete secondaryCmd;
0066     delete DoseMatrixCmd;
0067     delete LetCmd;
0068 }
0069 
0070 /////////////////////////////////////////////////////////////////////////////
0071 void HadrontherapyAnalysisFileMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0072 {
0073     if (command == secondaryCmd)
0074     {
0075         if (HadrontherapyMatrix::GetInstance())
0076         {
0077             HadrontherapyMatrix::GetInstance() -> secondary = secondaryCmd -> GetNewBoolValue(newValue);
0078         }
0079     }
0080     
0081     else if (command == DoseMatrixCmd) // Filename can be passed here TODO
0082     {
0083         if ( HadrontherapyMatrix * pMatrix = HadrontherapyMatrix::GetInstance() )
0084         {
0085             //pMatrix -> TotalEnergyDeposit();
0086             pMatrix -> StoreDoseFluenceAscii(newValue);
0087         }
0088     }
0089     
0090     else if (command == LetCmd)
0091     {
0092         if (HadrontherapyLet::GetInstance())
0093             HadrontherapyLet::GetInstance() -> doCalculation = LetCmd -> GetNewBoolValue(newValue);
0094     }
0095 }
0096