All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
larcore/larcore/Geometry/gdml/make_gdml.pl File Reference

Go to the source code of this file.

Functions

 GetOptions ("input|i:s"=>\$input,"help|h"=>\$help,"output|o:s"=>\$output)
 
 if (defined $help)
 
 if (!defined $input)
 
foreach $filename (@defFiles)
 
 open (OUTPUT) or die("Could not open $output for writing")
 
print OUTPUT<< EOF;<?xml
version="1.0"encoding="UTF-8"?>
< gdmlxmlns:gdml="http:xmlns:xsi="http:xsi:noNamespaceSchemaLocation="GDMLSchema/gdml.xsd">
EOF foreach 
$keyword (@keywords)
 
print OUTPUT<< EOF;< setup
name="Default"version="1.0">
< worldref="volWorld"/></setup >
</gdml > EOF 
close (OUTPUT)
 
sub usage ()
 

Variables

 else
 
 $parser = new XML::LibXML
 
 $dom = $parser->parse_file($input)
 
 defFiles = $dom->findnodes('/config/constantfiles/filename')
 
 gdmlFiles = $dom->findnodes('/config/gdmlfiles/filename')
 
 $numberConstants = -1
 
 keywords = qw( define materials solids structure )
 
 $OUTPUT = ">" . $output
 

Function Documentation

foreach $filename ( defFiles)

Definition at line 90 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

91 {
92  $CONSTANTS = $filename->to_literal;
93  open(CONSTANTS) or die("Could not open file $CONSTANTS");
94 
95  # For each line in the file...
96  foreach $line (<CONSTANTS>)
97  {
98  # Find the name and value as defined in a <constant> block; e.g.:
99  # <constant name="kInch" value="2.54" />
100  # will be parsed as $name="kInch" and value = "2.54"
101 
102  # If the line begins with "<constant"...
103  if ( $line =~ /^\s*\<constant / )
104  {
105  # (See "perldoc perlfaq6" for the definition of a non-greedy search.)
106  # Do a "non-greedy" search to get the text assigned to 'name'
107  $line =~ /name="(.*?)"/;
108  $name = $1;
109  # Do a "non-greedy" search to get the text assigned to 'value'
110  $line =~ /value="(.*?)"/;
111  $value = $1;
112 
113  # Append to the list of constants. Put parenthesis around
114  # the value, to avoid potential problems with arithmetic.
116  $name[$numberConstants] = $name;
117  $value[$numberConstants] = "($value)";
118  # print "$numberConstants: $name = $value[$numberConstants]\n"; # debug
119  }
120  }
121  close(CONSTANTS);
122 }
foreach $filename(@defFiles)
* file
Definition: file_to_url.sh:69
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
then echo fcl name
temporary value
print OUTPUT<< EOF;< setup name="Default"version="1.0">< worldref="volWorld"/></setup ></gdml > EOF close(OUTPUT)
open(RACETRACK) or die("Could not open file $RACETRACK for writing")
print OUTPUT<<EOF;<?xml version="1.0" encoding="UTF-8" ?><gdmlxmlns:gdml="http:xmlns:xsi="http:xsi:noNamespaceSchemaLocation="GDMLSchema/gdml.xsd"> EOF foreach $keyword ( keywords)

Definition at line 183 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

184 {
185  print OUTPUT "<$keyword>";
186 
187  # Substitute any constants in the GDML with their numeric
188  # equivalents.
189 
190  # In strict GDML, this should not be necessary; according to the
191  # specification, you should be able to define a constant and use
192  # it in subsequent GDML statements. If you use the standard GDML
193  # parser, this not a problem. ROOT, however, uses its own parser,
194  # and (as of ROOT 5.16) it could not handle variables in GDML
195  # expressions. So here we side-step the problem by performing our
196  # own substitutions.
197 
198  # Step through this list of constants in reverse order, to resolve
199  # any dependencies.
200 
201  for ( $i = $numberConstants; $i >= 0; --$i )
202  {
203  $keyhash{$keyword} =~ s/$name[$i]/$value[$i]/g;
204  }
205 
206  # Print the edited section.
207  print OUTPUT $keyhash{$keyword};
208 
209  print OUTPUT "</$keyword>\n";
210 }
do one_file $F done echo for F in find $TOP name CMakeLists txt print
BEGIN_PROLOG g
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do echo $i
Definition: TrainMVA.sh:30
print OUTPUT<< EOF;<?xml version="1.0"encoding="UTF-8"?>< gdmlxmlns:gdml="http:xmlns:xsi="http:xsi:noNamespaceSchemaLocation="GDMLSchema/gdml.xsd"> EOF foreach $keyword(@keywords)
print OUTPUT<<EOF;<setup name="Default" version="1.0"><worldref="volWorld"/></setup></gdml> EOF close ( OUTPUT  )
GetOptions ( "input|i:s"  ,
$input,
"help|h ,
$help,
"output|o:s"  ,
$output 
)
if ( defined  $help)

Definition at line 17 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

18 {
19  # If the user requested help, print the usage notes and exit.
20  usage();
21  exit;
22 }
usage
Definition: doGit.sh:21
if ( !defined  $input)

Definition at line 24 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

25 {
26  # If the user has not used "-i", then just take the first
27  # non-option argument.
28  if ( $#ARGV > -1 )
29  {
30  $input = $ARGV[0];
31  if ( ! -r $input )
32  {
33  print "Input file $input not found\n";
34  usage();
35  exit;
36  }
37  }
38  else
39  {
40  # Read from STDIN
41  $input = "-";
42  }
43 }
do one_file $F done echo for F in find $TOP name CMakeLists txt print
usage
Definition: doGit.sh:21
esac echo uname r
open ( OUTPUT  )
sub usage ( )

Definition at line 228 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

229 {
230  print "Usage: $0 [-h|--help] [-i|--input <xml-fragments-file>] [-o|--output <output-file>]\n";
231  print " -i/--input can be omitted; if no input file, defaults to STDIN\n";
232  print " if -o is omitted, output goes to STDOUT\n";
233  print " -h prints this message, then quits\n";
234 }
do one_file $F done echo for F in find $TOP name CMakeLists txt print

Variable Documentation

$dom = $parser->parse_file($input)

Definition at line 69 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

$numberConstants = -1

Definition at line 76 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

$OUTPUT = ">" . $output

Definition at line 167 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

$parser = new XML::LibXML

Definition at line 65 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

defFiles = $dom->findnodes('/config/constantfiles/filename')

Definition at line 72 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

else
Initial value:
{
if ( ! -r $input )
{
print "Input file $input not found or cannot be read\n";
usage();
}
}
if ( ! defined $output )
{
$output = "-"; # write to STDOUT
}
use XML::LibXML
do one_file $F done echo for F in find $TOP name CMakeLists txt print
def write
Definition: util.py:23
usage
Definition: doGit.sh:21
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not defined
esac echo uname r

Definition at line 45 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

gdmlFiles = $dom->findnodes('/config/gdmlfiles/filename')

Definition at line 73 of file larcore/larcore/Geometry/gdml/make_gdml.pl.

keywords = qw( define materials solids structure )

Definition at line 133 of file larcore/larcore/Geometry/gdml/make_gdml.pl.