5 # Short script to submit optical library generation with
10 use File::Basename qw(fileparse);
13 my ($xml, $fcl, $workdir, $check, $merge) = @ARGV;
15 if(!(defined($xml) || defined($fcl) || defined($workdir))) {
16 print "Usage: perl SubmitCommand.pl <project.py xml file> <fcl file> <work dir> [<checkana?>] [<merge?>]\n";
20 if(!(-e "${workdir}/buildopticallibrary")) {
21 mkdir "${workdir}/buildopticallibrary", 0775;
24 if(!(-e "${workdir}/buildopticallibrary/xml")) {
25 mkdir "${workdir}/buildopticallibrary/xml", 0775;
28 if(!(-e "${workdir}/buildopticallibrary)/fcl")) {
29 mkdir "${workdir}/buildopticallibrary/fcl", 0775;
32 my $NPhotonsPerVoxel = 30000;
33 my $NVoxelsPerJob = 240;
37 for(my $i=$StartJob; $i<$StartJob+$NJobs; $i++) {
39 my ($fcl_filename, $fcl_directories, $fcl_suffix) = fileparse($fcl,".fcl");
40 my ($xml_filename, $xml_directories, $xml_suffix) = fileparse($xml,".xml");
42 if(!(-e "${workdir}/buildopticallibrary/fcl/${fcl_filename}_${i}${fcl_suffix}")) {
44 open IN, "${fcl}" or die $!;
45 open OUT, ">${workdir}/buildopticallibrary/fcl/${fcl_filename}_${i}${fcl_suffix}" or die $!;
48 if(/physics.producers.generator.FirstVoxel/) {
49 print OUT "physics.producers.generator.FirstVoxel: " . $NVoxelsPerJob*$i . "\n";
51 elsif(/physics.producers.generator.LastVoxel/) {
52 print OUT "physics.producers.generator.LastVoxel: " . ($NVoxelsPerJob*($i+1)-1) . "\n";
54 elsif(/physics.producers.generator.N/) {
55 print OUT "physics.producers.generator.N: ${NPhotonsPerVoxel}\n";
65 if(!(-e ">${workdir}/buildopticallibrary/xml/${xml_filename}_${i}${xml_suffix}")) {
67 open IN, "${xml}" or die $!;
68 open OUT, ">${workdir}/buildopticallibrary/xml/${xml_filename}_${i}${xml_suffix}" or die $!;
72 print OUT '<!ENTITY name "gen_photon_ball_' . $i . '">' . "\n";
74 elsif(/<fcl>(.*)<\/fcl>/) {
75 print OUT " <fcl>" . abs_path(${workdir}) . "\/buildopticallibrary\/fcl\/${fcl_filename}_${i}${fcl_suffix}<\/fcl>\n";
86 if(!defined($check)) {
87 if(!defined($merge)) {
88 system qq|project.py --xml ${workdir}/buildopticallibrary/xml/${xml_filename}_${i}${xml_suffix} --submit|;
91 system qq|project.py --xml ${workdir}/buildopticallibrary/xml/${xml_filename}_${i}${xml_suffix} --merge|;
94 system qq|project.py --xml ${workdir}/buildopticallibrary/xml/${xml_filename}_${i}${xml_suffix} --checkana|;