Functions | Variables
gMaxPathLengths.cxx File Reference
#include <cassert>
#include <string>
#include <TMath.h>
#include "Framework/EventGen/PathLengthList.h"
#include "Tools/Geometry/ROOTGeomAnalyzer.h"
#include "Framework/Messenger/Messenger.h"
#include "Framework/Numerical/RandomGen.h"
#include "Framework/Utils/CmdLnArgParser.h"
#include "Framework/Utils/UnitUtils.h"
#include "Framework/Utils/PrintUtils.h"
#include "Framework/Utils/AppInit.h"
#include "Framework/Utils/RunOpt.h"

Go to the source code of this file.

Functions

void GetCommandLineArgs (int argc, char **argv)
 
void PrintSyntax (void)
 
int main (int argc, char **argv)
 

Variables

string kDefOptXMLFilename = "maxpl.xml"
 
string kDefOptGeomLUnits = "mm"
 
string kDefOptGeomDUnits = "g_cm3"
 
string gOptGeomFilename = ""
 
string gOptXMLFilename = ""
 
string gOptRootGeomTopVol = ""
 
double gOptGeomLUnits = 0
 
double gOptGeomDUnits = 0
 
int gOptNPoints = -1
 
int gOptNRays = -1
 
long int gOptRanSeed = -1
 

Function Documentation

void GetCommandLineArgs ( int  argc,
char **  argv 
)

Definition at line 150 of file gMaxPathLengths.cxx.

151 {
152  LOG("gmxpl", pINFO) << "Parsing command line arguments";
153 
154  // Common run options.
155  RunOpt::Instance()->ReadFromCommandLine(argc,argv);
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";
178  lunits = kDefOptGeomLUnits;
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";
198  gOptRootGeomTopVol = "";
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 }
long int gOptRanSeed
int gOptNRays
string kDefOptXMLFilename
#define pFATAL
Definition: Messenger.h:56
string gOptRootGeomTopVol
string gOptGeomFilename
int gOptNPoints
void PrintSyntax(void)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
string kDefOptGeomDUnits
double UnitFromString(string u)
Definition: UnitUtils.cxx:18
#define pINFO
Definition: Messenger.h:62
double gOptGeomLUnits
double gOptGeomDUnits
string PrintFramedMesg(string mesg, unsigned int nl=1, const char f='*')
Definition: PrintUtils.cxx:164
Command line argument parser.
#define pNOTICE
Definition: Messenger.h:61
string gOptXMLFilename
string kDefOptGeomLUnits
#define pDEBUG
Definition: Messenger.h:63
int main ( int  argc,
char **  argv 
)

Definition at line 112 of file gMaxPathLengths.cxx.

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 
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;
143  plmax.SaveAsXml(gOptXMLFilename);
144 
145  delete geom;
146 
147  return 0;
148 }
void RandGen(long int seed)
Definition: AppInit.cxx:30
long int gOptRanSeed
virtual const PathLengthList & ComputeMaxPathLengths(void)
int gOptNRays
string gOptRootGeomTopVol
string gOptGeomFilename
int gOptNPoints
Object to be filled with the neutrino path-length, for all detector geometry materials, when starting from a position x and travelling along the direction of the neutrino 4-momentum.
void SaveAsXml(string filename) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual void SetScannerNRays(int nr)
A ROOT/GEANT4 geometry driver.
#define pINFO
Definition: Messenger.h:62
double gOptGeomLUnits
double gOptGeomDUnits
virtual void SetScannerNPoints(int np)
set geometry driver&#39;s configuration options
void GetCommandLineArgs(int argc, char **argv)
void MesgThresholds(string inpfile)
Definition: AppInit.cxx:99
string gOptXMLFilename
void PrintSyntax ( void  )

Definition at line 259 of file gMaxPathLengths.cxx.

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 }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pNOTICE
Definition: Messenger.h:61

Variable Documentation

double gOptGeomDUnits = 0

Definition at line 106 of file gMaxPathLengths.cxx.

string gOptGeomFilename = ""

Definition at line 102 of file gMaxPathLengths.cxx.

double gOptGeomLUnits = 0

Definition at line 105 of file gMaxPathLengths.cxx.

int gOptNPoints = -1

Definition at line 107 of file gMaxPathLengths.cxx.

int gOptNRays = -1

Definition at line 108 of file gMaxPathLengths.cxx.

long int gOptRanSeed = -1

Definition at line 109 of file gMaxPathLengths.cxx.

string gOptRootGeomTopVol = ""

Definition at line 104 of file gMaxPathLengths.cxx.

string gOptXMLFilename = ""

Definition at line 103 of file gMaxPathLengths.cxx.

string kDefOptGeomDUnits = "g_cm3"

Definition at line 99 of file gMaxPathLengths.cxx.

string kDefOptGeomLUnits = "mm"

Definition at line 98 of file gMaxPathLengths.cxx.

string kDefOptXMLFilename = "maxpl.xml"

Definition at line 97 of file gMaxPathLengths.cxx.