59 #ifdef G4ANALYSIS_USE_ROOT
69 if (pMessenger)
delete pMessenger;
85 if ( !
ParseArg(vararg))
return false;
90 if (kinEmin != kinEmax && npoints >1)
92 G4double logmin = std::log10(kinEmin);
93 G4double logmax = std::log10(kinEmax);
98 en = std::pow(10., logmin + (
c*(logmax-logmin) / (npoints - 1.)) );
99 energy.push_back(en/
MeV);
101 massDedx.push_back ( (dedxtot / density)/(
MeV*
cm2/
g) );
106 energy.push_back(kinEmin/
MeV);
108 massDedx.push_back ( (dedxtot / density)/(
MeV*
cm2/
g) );
112 data <<
"MeV " <<
"MeV*cm2/g " << particle <<
" (into " <<
113 material <<
", density = " <<
G4BestUnit(density,
"Volumic Mass") <<
")" <<
G4endl;
116 for (
size_t i=0; i<energy.size(); i++){
117 data << std::setw(16) << energy[i] << massDedx[i] <<
G4endl;
121 #ifdef G4ANALYSIS_USE_ROOT
126 G4String ofName = (filename ==
"") ?
"User terminal": filename;
127 G4cout <<
"User choice:\n";
129 ", Kinetic energy upper limit= " <<
G4BestUnit(kinEmax,
"Energy") <<
130 ", npoints= "<< npoints <<
", particle= \"" << particle <<
131 "\", material= \"" << material <<
"\", filename= \""<<
137 #ifdef G4ANALYSIS_USE_ROOT
138 void HadrontherapyInteractionParameters::PlotStopping(
const G4String& filetype)
143 gROOT->SetStyle(
"Plain");
144 theRootCanvas =
new TCanvas(
"theRootCanvas",
"Interaction Parameters",200, 10, 600,400);
145 theRootCanvas -> SetFillColor(20);
146 theRootCanvas -> SetBorderMode(1);
147 theRootCanvas -> SetBorderSize(1);
148 theRootCanvas -> SetFrameBorderMode(0);
149 theRootCanvas -> SetGrid();
153 if (theRootGraph)
delete theRootGraph;
154 theRootGraph =
new TGraph(energy.size(), &energy[0], &massDedx[0]);
156 axisX = theRootGraph -> GetXaxis(),
157 axisY = theRootGraph -> GetYaxis();
159 axisY ->
SetTitle(
"Stopping Power (MeV cm2/g)");
163 axisX -> SetAxisColor(2);
164 axisY -> SetAxisColor(2);
167 theRootGraph -> SetMarkerColor(4);
168 theRootGraph -> SetMarkerStyle(20);
169 theRootGraph -> SetMarkerSize(.5);
171 G4String gName = particle.substr(0, particle.find(
"[") );
172 gName = gName +
"_" + material;
173 G4String fName =
"./referenceData/interaction/" + gName +
"." + filetype;
175 theRootGraph -> Draw(
"AP");
178 theRootCanvas -> SaveAs(fName);
186 if (Pmaterial) density = Pmaterial -> GetDensity();
192 kinEmin = kinEmax = npoints = 0.;
193 particle = material = filename =
"";
195 std::istringstream strParam(vararg);
197 strParam >> std::skipws >> material >> kinEmin >> kinEmax >> npoints >> particle >> filename;
199 npoints = std::floor(npoints);
203 if (kinEmax == 0. && kinEmin > 0. ) kinEmax = kinEmin;
204 if (kinEmax == 0. && kinEmin == 0. ) kinEmax = kinEmin = 1.*
MeV;
205 if (kinEmax < kinEmin)
207 G4cout <<
"WARNING: kinEmin must not exceed kinEmax!" <<
G4endl;
208 G4cout <<
"Usage: /parameter/command material EkinMin EKinMax nPoints [particle] [output filename]" <<
G4endl;
211 if (npoints < 1) npoints = 1;
214 if (!GetNistMaterial(material) )
216 G4cout <<
"WARNING: material \"" << material <<
"\" doesn't exist in NIST elements/materials"
217 " table [$G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" <<
G4endl;
218 G4cout <<
"Use command \"/parameter/nist\" to see full materials list" <<
G4endl;
222 if (particle ==
"") particle =
"proton";
225 G4cout <<
"WARNING: Particle \"" << particle <<
"\" isn't supported." <<
G4endl;
226 G4cout <<
"Try the command \"/particle/list\" to get full supported particles list." <<
G4endl;
227 G4cout <<
"If you are interested in an ion that isn't in this list you must give it to the particle gun."
228 "\nTry the commands:\n/gun/particle ion"
229 "\n/gun/ion <atomic number> <mass number> <[charge]>" << G4endl <<
G4endl;
237 outfile.open(filename,std::ios_base::trunc);
238 data.rdbuf(outfile.rdbuf());
251 G4cout <<
"Issuing a G4RunManager::beamOn()... ";
252 G4cout <<
"Current Run State is " << mState -> GetStateString( aState ) <<
G4endl;
269 const std::vector<G4String>& vec = nistMat -> GetMaterialNames();
270 for (
size_t i=0; i<vec.size(); i++)
276 else if (vararg ==
"all" || vararg ==
"simple" || vararg ==
"compound" || vararg ==
"hep" )
278 nistMat -> ListMaterials(vararg);
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double cm2
~HadrontherapyInteractionParameters()
G4double ComputeTotalDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, G4double cut=DBL_MAX)
HadrontherapyInteractionParameters(G4bool)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4NistManager * Instance()
void ListOfNistMaterials(const G4String &vararg)
const XML_Char const XML_Char * data
G4double GetStopping(G4double energy, const G4ParticleDefinition *, const G4Material *, G4double density=0.)
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
bool ParseArg(const G4String &vararg)
G4bool GetStoppingTable(const G4String &vararg)
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)
static G4RunManager * GetRunManager()
const G4ParticleDefinition * FindParticle(const G4String &)
static constexpr double MeV