2 # Heavily revised Jan-2010 <seligman@nevis.columbia.edu>
5 # Build a description of the detectors from gdml fragments
8 # Use the command line arguments to give us the list of file fragments
9 # that we'll zip together. The man page for 'GetOptions' can be read
10 # with: perldoc Getopt::Long
15 "output|o:s" => \$output);
19 # If the user requested help, print the usage notes and exit.
26 # If the user has not used "-i", then just take the first
27 # non-option argument.
33 print "Input file $input not found\n";
46 # The "-i" option was provided; check that the input file exists.
49 print "Input file $input not found or cannot be read\n";
57 $output =
"-"; #
write to STDOUT
60 # Read the list of file fragments from an XML-formatted file.
61 # (Type "perldoc XML::LibXML" for how to use this package.)
64 # Create an XML parser.
67 # Read the XML file. The entire contents are slurped into a DOM
71 # Note that @defFiles and @gdmlFiles are both arrays of "nodes".
75 # Keep track of how many constants we read in.
78 # Developer note: If I were slicker, I'd also use XML::LibXML to read
79 # in these GDML fragments. However, the files would have to be edited
80 # to be strict XML, and that's more effort than it's worth. The script
81 # generate_gdml.pl writes strict XML documents, but there's no
82 # guarantee that this program will be used just with those
86 # Build the table of variable replacements
89 # For each node that represents a file of constants...
93 open(CONSTANTS) or die(
"Could not open file $CONSTANTS");
95 # For each line in the file...
96 foreach $line (<CONSTANTS>)
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"
102 # If the line begins with "<constant"...
103 if (
$line =~ /^\
s*\<constant / )
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'
109 # Do a "non-greedy" search to get the text assigned to 'value'
113 # Append to the list of constants. Put parenthesis around
114 # the value, to avoid potential problems with arithmetic.
118 # print "$numberConstants: $name = $value[$numberConstants]\n"; # debug
124 # The main GDML keywords, used in tags. The order here is important:
125 # No matter what order these blocks are in the sub-files, this is the
126 # order in which they must be written in the final GDML output.
128 # If I were being super-slick, I'd use the features of LibXML to read
129 # each of these GDML sub-files, then fiddle with the elements using
130 # XML manipulation routines. However, it's much simpler to treat them
131 # as big globs of text.
135 # For each node that's a file of GDML statements...
143 # Read the entire file into an array.
147 # Slurp the array into a single variable.
148 $file =
join(
"",@file);
152 # Search the file for a keyword block. For example, if
153 # $keyword were "blorg", the following would search for
154 # <blorg>some text</blorg> and snip it out of $file.
157 # Following the above example, this would append "some
158 # text" to $keyhash{blorg}
165 # Write the final GDML file.
168 open(OUTPUT) or die("Could not
open $output
for writing");
170 # The preliminary material for the GDML file. This defines the GDML
171 # schema and namespaces.
175 <
gdml xmlns:
gdml=
"http://cern.ch/2001/Schemas/GDML"
176 xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
177 xsi:noNamespaceSchemaLocation=
"GDMLSchema/gdml.xsd">
180 # Print to OUTPUT all the GDML sections, with each set of tags
181 # unified, in the appropriate order.
185 print OUTPUT
"<$keyword>";
187 # Substitute any constants in the GDML with their numeric
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
198 # Step through this list of constants in reverse order, to resolve
206 # Print the edited section.
209 print OUTPUT
"</$keyword>\n";
212 # The final section of a GDML file is the <setup></setup> section. At
213 # present, we don't define alternate setups in the same GDML file, so
214 # these lines are constant.
219 <world ref=
"volWorld" />
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";
then source grid fermiapp products dune setup_dune_fermiapp sh exit else echo No setup file found exit fi setup
use File::Basename qw(fileparse)
foreach $filename(@defFiles)
process_name can override from command line with o or output proton mvapid_weights muon_all_BDT weights xml
GetOptions("help|h"=>\$help,"suffix|s:s"=>\$suffix,"output|o:s"=>\$output,"concrete|c:s"=>\$thickness_over,"wires|w:s"=>\$wires,"vetocrt|v:s"=>\$crt)
do one_file $F done echo for F in find $TOP name CMakeLists txt print
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.
for($it=0;$it< $RaceTrack_number;$it++)
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
then echo File list $list not found else cat $list while read file do echo $file sed s
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)
std::string sub(const std::string &a, const std::string &b)
open(RACETRACK) or die("Could not open file $RACETRACK for writing")