GENIEGenerator
Loading...
Searching...
No Matches
gMaxPathLengths.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*!
3
4\program gmxpl
5
6\brief GENIE utility program computing the maximum path lengths for any
7 given ROOT/GEANT geometry and saving them in an output XML file.
8
9 The maximum path lengths XML file can then be input to the GENIE
10 event generation drivers to speed up the job initialization.
11
12 Note that this program actually computes the 'density weighted' path
13 lengths required for computing interaction probabilities in the input
14 geometry volumes.
15 For pure materials, this program computes:
16 -> [path length]*[material density]
17 whereas, for the ith element of a mixture, it computes:
18 -> [path length]*[mixture density]*[element weight fraction]
19
20 Syntax :
21 gmxpl -f geom_file [-L length_units] [-D density_units]
22 [-t top_vol_name] [-o output_xml_file] [-n np] [-r nr]
23 [-seed random_number_seed]
24 [--message-thresholds xml_file]
25
26 Options :
27 -f
28 A ROOT file containing a ROOT/GEANT geometry description
29 -L
30 Geometry length units [ default: mm ]
31 -D
32 Geometry density units [ default: gr/cm3 ]
33 -t
34 Top volume name [ default: "" ]
35 -n
36 Number of scanning points / surface [ default: see geom driver's defaults ]
37 -r
38 Number of scanning rays / point [ default: see geom driver's defaults ]
39 -o
40 Name of output XML file [ default: maxpl.xml ]
41 --seed
42 Random number seed.
43 --message-thresholds
44 Allows users to customize the message stream thresholds.
45 The thresholds are specified using an XML file.
46 See $GENIE/config/Messenger.xml for the XML schema.
47
48 Example:
49
50 gmxpl -f mygeometry.root -L m -D kg_m3 -o out.xml -n 1000 -r 1000
51
52 will compute the maximum density weighted path lengths for all the
53 materials of the ROOT geometry at the mygeometry.root input file.
54 The program will use 'm' and 'kg/m^3' as the length and density
55 units of the input geometry.
56 The input geometry will be scanned with 1E+3 points / surface and
57 1E+3 rays / surface.
58 Results will be saved in the out.xml XML file at SI units.
59 See $GENIE/src/Conventions/Units.h for GENIE unit definitions.
60
61\author Costas Andreopoulos <C.V.Andreopoulos@rl.ac.uk>
62 University of Liverpool
63
64\created September 27, 2005
65
66\cpright Copyright (c) 2003-2025, The GENIE Collaboration
67 For the full text of the license visit http://copyright.genie-mc.org
68
69*/
70//____________________________________________________________________________
71
72#include <cassert>
73#include <string>
74
75#include <TMath.h>
76
86
87using std::string;
88
89using namespace genie;
90using namespace genie::geometry;
91
92// Prototypes:
93void GetCommandLineArgs (int argc, char ** argv);
94void PrintSyntax (void);
95
96// Defaults for optional options:
97string kDefOptXMLFilename = "maxpl.xml"; // default output xml filename
98string kDefOptGeomLUnits = "mm"; // default geometry length units
99string kDefOptGeomDUnits = "g_cm3"; // default geometry density units
100
101// User-specified options:
102string gOptGeomFilename = ""; // input geometry file
103string gOptXMLFilename = ""; // input xml filename
104string gOptRootGeomTopVol = ""; // input root geometry top vol name
105double gOptGeomLUnits = 0; // input geometry length units
106double gOptGeomDUnits = 0; // input geometry density units
107int gOptNPoints = -1; // input number of points / surf
108int gOptNRays = -1; // input number of rays / point
109long int gOptRanSeed = -1; // random number seed
110
111//____________________________________________________________________________
112int main(int argc, char ** argv)
113{
114 GetCommandLineArgs(argc,argv);
115
117 utils::app_init::MesgThresholds(RunOpt::Instance()->MesgThresholdFiles());
118
119 // Create the geometry driver
120 LOG("gmxpl", pINFO)
121 << "Creating/configuring a ROOT geom. driver";
122
124 geom -> SetLengthUnits (gOptGeomLUnits);
125 geom -> SetDensityUnits (gOptGeomDUnits);
126 geom -> SetWeightWithDensity (true);
127
128 // Set the top volume name
129 geom -> SetTopVolName (gOptRootGeomTopVol);
130 geom -> SetWeightWithDensity (true);
131
132 if(gOptNPoints > 0) geom->SetScannerNPoints(gOptNPoints);
133 if(gOptNRays > 0) geom->SetScannerNRays (gOptNRays);
134
135 // Compute the maximum path lengths
136 LOG("gmxpl", pINFO)
137 << "Asking input GeomAnalyzerI for the max path-lengths";
138 const PathLengthList & plmax = geom->ComputeMaxPathLengths();
139
140 // Print & save the maximum path lengths in XML format
141 LOG("gmxpl", pINFO)
142 << "Maximum path lengths: " << plmax;
144
145 delete geom;
146
147 return 0;
148}
149//____________________________________________________________________________
150void GetCommandLineArgs(int argc, char ** argv)
151{
152 LOG("gmxpl", pINFO) << "Parsing command line arguments";
153
154 // Common run options.
156
157 // Parse run options for this app
158
159 CmdLnArgParser parser(argc,argv);
160
161 // output XML file name
162 if( parser.OptionExists('o') ) {
163 LOG("gmxpl", pDEBUG) << "Reading output filename";
164 gOptXMLFilename = parser.ArgAsString('o');
165 } else {
166 LOG("gmxpl", pDEBUG)
167 << "Unspecified output filename - Using default";
169 } // -o
170
171 // legth & density units
172 string lunits, dunits;
173 if( parser.OptionExists('L') ) {
174 LOG("gmxpl", pDEBUG) << "Checking for input geometry length units";
175 lunits = parser.ArgAsString('L');
176 } else {
177 LOG("gmxpl", pDEBUG) << "Using default geometry length units";
179 } // -L
180 if( parser.OptionExists('D') ) {
181 LOG("gmxpl", pDEBUG) << "Checking for input geometry density units";
182 dunits = parser.ArgAsString('D');
183 } else {
184 LOG("gmxpl", pDEBUG) << "Using default geometry density units";
185 dunits = kDefOptGeomDUnits;
186 } // -D
189
190 // root geometry top volume name
191 if( parser.OptionExists('t') ) {
192 LOG("gmxpl", pDEBUG)
193 << "Reading root geometry top volume name";
194 gOptRootGeomTopVol = parser.ArgAsString('t');
195 } else {
196 LOG("gmxpl", pDEBUG)
197 << "Unspecified geometry top volume - Using default";
199 } // -o
200
201 // number of scanning points / surface
202 if( parser.OptionExists('n') ) {
203 LOG("gmxpl", pDEBUG)
204 << "Reading input number of scanning points/surface";
205 gOptNPoints = parser.ArgAsInt('n');
206 } else {
207 LOG("gmxpl", pDEBUG)
208 << "Unspecified number of points - Using driver's default";
209 } //-n
210
211 // number of scanning rays / point
212 if( parser.OptionExists('r') ) {
213 LOG("gmxpl", pDEBUG)
214 << "Reading input number of scanning rays/point";
215 gOptNRays = parser.ArgAsInt('r');
216 } else {
217 LOG("gmxpl", pDEBUG)
218 << "Unspecified number of rays - Using driver's default";
219 } //-r
220
221 // input geometry file
222 if( parser.OptionExists('f') ) {
223 LOG("gmxpl", pDEBUG)
224 << "Reading ROOT/GEANT geometry filename";
225 gOptGeomFilename = parser.ArgAsString('f');
226 } else {
227 LOG("gmxpl", pFATAL)
228 << "No geometry file was specified - Exiting";
229 PrintSyntax();
230 exit(1);
231 } //-f
232
233 // random number seed
234 if( parser.OptionExists("seed") ) {
235 LOG("gmxpl", pINFO) << "Reading random number seed";
236 gOptRanSeed = parser.ArgAsLong("seed");
237 } else {
238 LOG("gmxpl", pINFO) << "Unspecified random number seed - Using default";
239 gOptRanSeed = -1;
240 }
241
242 // print the command line arguments
243 LOG("gmxpl", pNOTICE)
244 << "\n"
245 << utils::print::PrintFramedMesg("gmxpl job inputs");
246 LOG("gmxpl", pNOTICE) << "Command line arguments";
247 LOG("gmxpl", pNOTICE) << "Input ROOT geometry : " << gOptGeomFilename;
248 LOG("gmxpl", pNOTICE) << "Output XML file : " << gOptXMLFilename;
249 LOG("gmxpl", pNOTICE) << "Geometry length units : " << gOptGeomLUnits;
250 LOG("gmxpl", pNOTICE) << "Geometry density units : " << gOptGeomDUnits;
251 LOG("gmxpl", pNOTICE) << "Scanner points/surface : " << gOptNPoints;
252 LOG("gmxpl", pNOTICE) << "Scanner rays/point : " << gOptNRays;
253 LOG("gmxpl", pNOTICE) << "Random number seed : " << gOptRanSeed;
254
255 LOG("gmxpl", pNOTICE) << "\n";
256 LOG("gmxpl", pNOTICE) << *RunOpt::Instance();
257}
258//____________________________________________________________________________
259void PrintSyntax(void)
260{
261 LOG("gmxpl", pNOTICE)
262 << "\n\n" << "Syntax:" << "\n"
263 << " gmxpl"
264 << " -f geom_file"
265 << " [-L length_units]"
266 << " [-D density_units]"
267 << " [-t top_volume_name]"
268 << " [-o output_xml_file]"
269 << " [-seed random_number_seed]"
270 << " [--message-thresholds xml_file]\n";
271
272}
273//____________________________________________________________________________
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pFATAL
Definition Messenger.h:56
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
int main()
Command line argument parser.
string ArgAsString(char opt)
bool OptionExists(char opt)
was option set?
Object to be filled with the neutrino path-length, for all detector geometry materials,...
void SaveAsXml(string filename) const
void ReadFromCommandLine(int argc, char **argv)
Definition RunOpt.cxx:99
static RunOpt * Instance(void)
Definition RunOpt.cxx:54
A ROOT/GEANT4 geometry driver.
long int gOptRanSeed
double gOptGeomLUnits
string kDefOptGeomLUnits
string kDefOptGeomDUnits
double gOptGeomDUnits
string gOptRootGeomTopVol
string lunits
string geom
string gOptGeomFilename
int gOptNPoints
string kDefOptXMLFilename
int gOptNRays
void GetCommandLineArgs(int argc, char **argv)
void PrintSyntax(void)
string gOptXMLFilename
GENIE geometry drivers.
void RandGen(long int seed)
Definition AppInit.cxx:30
void MesgThresholds(string inpfile)
Definition AppInit.cxx:99
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f=' *')
double UnitFromString(string u)
Definition UnitUtils.cxx:18
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25