Geant4  10.00.p02
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 //
26 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application
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 //
34 
35 
38 #include "G4UIcmdWithAString.hh"
39 #include "G4UIcmdWithABool.hh"
40 #include "G4UIdirectory.hh"
41 #include "G4SystemOfUnits.hh"
42 
43 #include "HadrontherapyMatrix.hh"
44 #include "HadrontherapyLet.hh"
45 
48 :AnalysisManager(amgr)
49 {
50  secondaryCmd = new G4UIcmdWithABool("/analysis/secondary",this);
51  secondaryCmd -> SetParameterName("secondary", true);
52  secondaryCmd -> SetDefaultValue("true");
53  secondaryCmd -> SetGuidance("Set if dose/fluence for the secondary particles will be written"
54  "\n[usage]: /analysis/secondary [true/false]");
55  secondaryCmd -> AvailableForStates(G4State_Idle, G4State_PreInit);
56 
57  DoseMatrixCmd = new G4UIcmdWithAString("/analysis/writeDoseFile",this);
58  DoseMatrixCmd->SetGuidance("Write the dose/fluence to an ASCII file");
59  DoseMatrixCmd->SetDefaultValue("Dose.out");
60  DoseMatrixCmd->SetParameterName("choice",true);
61 
62  // With this messenger you can:
63  // give a name to the generated .root file
64  // One can use this messenger to define a different .root file name other then the default one
65 #ifdef G4ANALYSIS_USE_ROOT
66  FileNameCmd = new G4UIcmdWithAString("/analysis/setAnalysisFile",this);
67  FileNameCmd->SetGuidance("Set the .root filename for the root-output");
68  FileNameCmd->SetDefaultValue("default.root");
69  FileNameCmd->SetParameterName("choice",true);
70  FileNameCmd->AvailableForStates(G4State_Idle,G4State_PreInit);
71 #endif
72 
73 
74 LetCmd = new G4UIcmdWithABool("/analysis/computeLet",this);
75  LetCmd -> SetParameterName("choice",true);
76  LetCmd -> SetDefaultValue(true);
77  LetCmd -> SetGuidance("Set if Let must be computed and write the ASCII filename for the Let");
78  LetCmd -> AvailableForStates(G4State_Idle, G4State_PreInit);
79 
80 
81 
82 }
83 
86 {
87  delete secondaryCmd;
88  delete DoseMatrixCmd;
89  delete LetCmd;
90 
91 #ifdef G4ANALYSIS_USE_ROOT
92  delete FileNameCmd;
93 #endif
94 }
95 
98 {
99  if (command == secondaryCmd)
100  {
102  {
103  HadrontherapyMatrix::GetInstance() -> secondary = secondaryCmd -> GetNewBoolValue(newValue);
104  }
105  }
106 
107  else if (command == DoseMatrixCmd) // Filename can be passed here TODO
108  {
110  {
111  pMatrix -> TotalEnergyDeposit();
112  pMatrix -> StoreDoseFluenceAscii(newValue);
113 #ifdef G4ANALYSIS_USE_ROOT
114  pMatrix -> StoreDoseFluenceRoot();
115  HadrontherapyAnalysisManager::GetInstance() -> flush(); // Finalize & write the root file
116 #endif
117  }
118  }
119 
120  else if (command == LetCmd)
121  {
123  HadrontherapyLet::GetInstance() -> doCalculation = LetCmd -> GetNewBoolValue(newValue);
124  }
125 
126 #ifdef G4ANALYSIS_USE_ROOT
127  else if (command == FileNameCmd)
128  {
129  AnalysisManager->SetAnalysisFileName(newValue);
130  HadrontherapyAnalysisManager::GetInstance() -> book(); // Book for a new ROOT TFile
131  }
132 #endif
133 }
134 
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 *)