Geant4  10.01.p01
HadrontherapyAnalysisFileMessenger.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
26 // the *COMPLETE* version of this program, together with its documentation;
27 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
28 // Institute in the framework of the MC-INFN Group
29 //
30 
31 
34 #include "G4UIcmdWithAString.hh"
35 #include "G4UIcmdWithABool.hh"
36 #include "G4UIdirectory.hh"
37 #include "G4SystemOfUnits.hh"
38 
39 #include "HadrontherapyMatrix.hh"
40 #include "HadrontherapyLet.hh"
41 
44 :AnalysisManager(amgr)
45 {
46  secondaryCmd = new G4UIcmdWithABool("/analysis/secondary",this);
47  secondaryCmd -> SetParameterName("secondary", true);
48  secondaryCmd -> SetDefaultValue("true");
49  secondaryCmd -> SetGuidance("Set if dose/fluence for the secondary particles will be written"
50  "\n[usage]: /analysis/secondary [true/false]");
51  secondaryCmd -> AvailableForStates(G4State_Idle, G4State_PreInit);
52 
53  DoseMatrixCmd = new G4UIcmdWithAString("/analysis/writeDoseFile",this);
54  DoseMatrixCmd->SetGuidance("Write the dose/fluence to an ASCII file");
55  DoseMatrixCmd->SetDefaultValue("Dose.out");
56  DoseMatrixCmd->SetParameterName("choice",true);
57 
58  // With this messenger you can:
59  // give a name to the generated .root file
60  // One can use this messenger to define a different .root file name other then the default one
61 #ifdef G4ANALYSIS_USE_ROOT
62  FileNameCmd = new G4UIcmdWithAString("/analysis/setAnalysisFile",this);
63  FileNameCmd->SetGuidance("Set the .root filename for the root-output");
64  FileNameCmd->SetDefaultValue("default.root");
65  FileNameCmd->SetParameterName("choice",true);
66  FileNameCmd->AvailableForStates(G4State_Idle,G4State_PreInit);
67 #endif
68 
69 
70 LetCmd = new G4UIcmdWithABool("/analysis/computeLet",this);
71  LetCmd -> SetParameterName("choice",true);
72  LetCmd -> SetDefaultValue(true);
73  LetCmd -> SetGuidance("Set if Let must be computed and write the ASCII filename for the Let");
74  LetCmd -> AvailableForStates(G4State_Idle, G4State_PreInit);
75 
76 
77 
78 }
79 
82 {
83  delete secondaryCmd;
84  delete DoseMatrixCmd;
85  delete LetCmd;
86 
87 #ifdef G4ANALYSIS_USE_ROOT
88  delete FileNameCmd;
89 #endif
90 }
91 
94 {
95  if (command == secondaryCmd)
96  {
98  {
99  HadrontherapyMatrix::GetInstance() -> secondary = secondaryCmd -> GetNewBoolValue(newValue);
100  }
101  }
102 
103  else if (command == DoseMatrixCmd) // Filename can be passed here TODO
104  {
106  {
107  pMatrix -> TotalEnergyDeposit();
108  pMatrix -> StoreDoseFluenceAscii(newValue);
109 #ifdef G4ANALYSIS_USE_ROOT
110  pMatrix -> StoreDoseFluenceRoot();
111  HadrontherapyAnalysisManager::GetInstance() -> flush(); // Finalize & write the root file
112 #endif
113  }
114  }
115 
116  else if (command == LetCmd)
117  {
119  HadrontherapyLet::GetInstance() -> doCalculation = LetCmd -> GetNewBoolValue(newValue);
120  }
121 
122 #ifdef G4ANALYSIS_USE_ROOT
123  else if (command == FileNameCmd)
124  {
125  AnalysisManager->SetAnalysisFileName(newValue);
126  HadrontherapyAnalysisManager::GetInstance() -> book(); // Book for a new ROOT TFile
127  }
128 #endif
129 }
130 
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static HadrontherapyAnalysisManager * GetInstance()
Get the pointer to the analysis manager.
void SetNewValue(G4UIcommand *command, G4String newValue)
Called when new command given.
static HadrontherapyLet * GetInstance()
static HadrontherapyMatrix * GetInstance()
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetDefaultValue(const char *defVal)
A class for connecting the simulation to an analysis package.
G4UIcmdWithABool * LetCmd
G4 user interface command (that takes a string argument) object Constructor requires command name and...
HadrontherapyAnalysisFileMessenger(HadrontherapyAnalysisManager *)