Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -23,43 +23,92 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// HadrontherapyAnalysisFileMessenger.cc
//
// This is the *BASIC* version of Hadrontherapy, a Geant4-based application
// See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
//
// Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
// the *COMPLETE* version of this program, together with its documentation;
// Hadrontherapy (both basic and full version) are supported by the Italian INFN
// Institute in the framework of the MC-INFN Group
//
#include "HadrontherapyAnalysisFileMessenger.hh"
#include "HadrontherapyAnalysisManager.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIdirectory.hh"
#ifdef ANALYSIS_USE
//
#include "HadrontherapyMatrix.hh"
/////////////////////////////////////////////////////////////////////////////
HadrontherapyAnalysisFileMessenger::HadrontherapyAnalysisFileMessenger(HadrontherapyAnalysisManager* amgr)
:AnalysisManager(amgr)
{
{
secondaryCmd = new G4UIcmdWithABool("/analysis/secondary",this);
secondaryCmd -> SetParameterName("secondary", true);
secondaryCmd -> SetDefaultValue("true");
secondaryCmd -> SetGuidance("Set if dose/fluence for the secondary particles will be written"
"\n[usage]: /analysis/secondary [true/false]");
secondaryCmd -> AvailableForStates(G4State_Idle, G4State_PreInit);
DoseMatrixCmd = new G4UIcmdWithAString("/analysis/writeDoseFile",this);
DoseMatrixCmd->SetGuidance("Write the dose/fluence to an ASCII file");
DoseMatrixCmd->SetDefaultValue("Dose.out");
DoseMatrixCmd->SetParameterName("choice",true);
// With this messenger you can:
// give a name to the generated .root file
// One can use this messenger to define a different .root file name other then the default one
#ifdef G4ANALYSIS_USE_ROOT
FileNameCmd = new G4UIcmdWithAString("/analysis/setAnalysisFile",this);
FileNameCmd->SetGuidance("Set the .root filename for the root-output");
FileNameCmd->SetDefaultValue("default.root");
FileNameCmd->SetParameterName("choice",true); ///<doc did not say what second boolean really does
FileNameCmd->AvailableForStates(G4State_Idle,G4State_PreInit);
#endif
}
/////////////////////////////////////////////////////////////////////////////
HadrontherapyAnalysisFileMessenger::~HadrontherapyAnalysisFileMessenger()
{
delete secondaryCmd;
delete DoseMatrixCmd;
#ifdef G4ANALYSIS_USE_ROOT
delete FileNameCmd;
#endif
}
/////////////////////////////////////////////////////////////////////////////
void HadrontherapyAnalysisFileMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == FileNameCmd)
if (command == secondaryCmd)
{
if (HadrontherapyMatrix::GetInstance())
{
HadrontherapyMatrix::GetInstance() -> secondary = secondaryCmd -> GetNewBoolValue(newValue);
}
}
else if (command == DoseMatrixCmd) // Filename can be passed here TODO
{
if ( HadrontherapyMatrix * pMatrix = HadrontherapyMatrix::GetInstance() )
{
pMatrix -> TotalEnergyDeposit();
pMatrix -> StoreDoseFluenceAscii(newValue);
#ifdef G4ANALYSIS_USE_ROOT
pMatrix -> StoreDoseFluenceRoot();
HadrontherapyAnalysisManager::GetInstance() -> flush(); // Finalize & write the root file
#endif
}
}
#ifdef G4ANALYSIS_USE_ROOT
else if (command == FileNameCmd)
{
AnalysisManager->SetAnalysisFileName(newValue);
AnalysisManager->flush(); //< fills matrix, writes it into file and books a new file and histograms etc.
AnalysisManager->book();
}
HadrontherapyAnalysisManager::GetInstance() -> book(); // Book for a new ROOT TFile
}
#endif
}
#endif