-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
mps_save.pl
executable file
·116 lines (100 loc) · 2.73 KB
/
mps_save.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env perl
# R. Mankel, DESY Hamburg 11-Oct-2007
# A. Parenti, DESY Hamburg 16-Apr-2008
# $Revision: 1.11 $ by $Author: flucke $
# $Date: 2009/06/24 10:14:03 $
#
# Save output from jobs that have FETCH status
#
#
# Usage: mps_save.pl saveDir [n]
#
BEGIN {
use File::Basename;
unshift(@INC, dirname($0)."/mpslib");
}
use Mpslib;
$saveDir = "undefined";
# parse the arguments
$i=0;
$nMergeJob=0;
while (@ARGV) {
$arg = shift(ARGV);
if ($arg =~ /\A-/) { # check for option
if ($arg =~ "h") {
$helpwanted = 1;
}
elsif ($arg =~ "d") {
$localdir = 1;
}
elsif ($arg =~ "u") {
$updateDb = 1;
}
$optionstring = "$optionstring$arg";
}
else { # parameters not related to options
$i = $i + 1;
if ($i eq 1) {
$saveDir = $arg;
} elsif ($i eq 2) {
$nMergeJob = $arg;
}
}
}
if ($helpwanted == 1 or $saveDir eq "undefined") {
print "Usage:\n mps_save.pl destination [n]";
print "\n Saves results in directory 'destination' (that is created if needed).";
print "\n If <n> is given as second argument, choose n-th merge job, otherwise the 0-th.";
print "\n mps_save -h\n This help.\n";
exit 1;
}
# create output directory
if (-d $saveDir) {
print "Reusing existing directory $saveDir ...\n";
}
else {
system "mkdir -p $saveDir"; # -p by GF
}
read_db();
# go to merge job
$i = $nJobs + $nMergeJob;
if ($i >= @JOBID) {
print "Bad merge job number $i.\n";
}
if (@JOBSTATUS[$i] eq "FETCH"
or @JOBSTATUS[$i] eq "OK" or @JOBSTATUS[$i] eq "TIMEL") {
$dirPrefix = "jobData/@JOBDIR[$i]/";
@FILENAMES = ("treeFile_merge.root","histograms_merge.root","millePedeMonitor_merge.root",
"alignment_merge.py","alignment.log*","millepede.log*",
"millepede.res*","millepede.his*","pede.dump*", "millepede.end",
"alignments_MP.db","pedeSteer*.txt*","theScript.sh");
while ($theFile = shift @FILENAMES) {
$copyFile = $dirPrefix.$theFile;
print "cp -p $copyFile $saveDir/\n";
system "cp -p $copyFile $saveDir/";
$retcode = $? >> 8;
if ($retcode) {
print "Copy of $copyFile failed, retcode=$retcode\n";
}
}
# Now copy the backup of original scripts, cfg and infiList
$ScriptCfg = `ls jobData/ScriptsAndCfg???.tar`;
chomp($ScriptCfg);
$ScriptCfg =~ s/\n/ /g;
$ScriptCfg =~ s/jobData\///g;
@FILENAMES = split(' ',$ScriptCfg);
while ($theFile = shift @FILENAMES) {
$copyFile = "jobData/".$theFile;
if (-r $copyFile) {
print "cp -p $copyFile $saveDir/\n";
system "cp -p $copyFile $saveDir/";
$retcode = $? >> 8;
if ($retcode) {
print "Copy of $copyFile failed, retcode=$retcode\n";
}
}
else {
print "$copyFile unreadable or not existing\n";
}
}
}