Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:36

0001 #!/usr/bin/env perl
0002 #     R. Mankel, DESY Hamburg     11-Oct-2007
0003 #     A. Parenti, DESY Hamburg    16-Apr-2008
0004 #     $Revision: 1.11 $ by $Author: flucke $
0005 #     $Date: 2009/06/24 10:14:03 $
0006 #
0007 #  Save output from jobs that have FETCH status
0008 #  
0009 #
0010 #  Usage: mps_save.pl saveDir [n]
0011 #
0012 
0013 BEGIN {
0014 use File::Basename;
0015 unshift(@INC, dirname($0)."/mpslib");
0016 }
0017 use Mpslib;
0018 
0019 $saveDir = "undefined";
0020 # parse the arguments
0021 $i=0;
0022 $nMergeJob=0;
0023 while (@ARGV) {
0024   $arg = shift(ARGV);
0025   if ($arg =~ /\A-/) {  # check for option 
0026     if ($arg =~ "h") {
0027       $helpwanted = 1;
0028     }
0029     elsif ($arg =~ "d") {
0030       $localdir = 1;
0031     }
0032     elsif ($arg =~ "u") {
0033       $updateDb = 1;
0034     }
0035     $optionstring = "$optionstring$arg";
0036   }
0037   else {                # parameters not related to options
0038     $i = $i + 1;
0039     if ($i eq 1) {
0040       $saveDir = $arg;
0041     } elsif ($i eq 2) {
0042       $nMergeJob = $arg;
0043     }
0044   }
0045 }
0046 
0047 
0048 if ($helpwanted == 1 or $saveDir eq "undefined") {
0049   print "Usage:\n  mps_save.pl destination [n]";
0050   print "\n    Saves results in directory 'destination' (that is created if needed).";
0051   print "\n    If <n> is given as second argument, choose n-th merge job, otherwise the 0-th.";
0052   print "\n  mps_save -h\n    This help.\n";
0053   exit 1;
0054 }
0055 
0056 
0057 # create output directory
0058 if (-d $saveDir) {
0059   print "Reusing existing directory $saveDir ...\n";
0060 }
0061 else {
0062   system "mkdir -p $saveDir"; # -p by GF
0063 }
0064 
0065 read_db();
0066 
0067 # go to merge job 
0068 $i = $nJobs + $nMergeJob;
0069 if ($i >= @JOBID) {
0070   print "Bad merge job number $i.\n";
0071 }
0072 
0073 
0074 if (@JOBSTATUS[$i] eq "FETCH"
0075     or @JOBSTATUS[$i] eq "OK" or @JOBSTATUS[$i] eq "TIMEL") {
0076 
0077   $dirPrefix = "jobData/@JOBDIR[$i]/";
0078 
0079   @FILENAMES = ("treeFile_merge.root","histograms_merge.root","millePedeMonitor_merge.root",
0080         "alignment_merge.py","alignment.log*","millepede.log*",
0081         "millepede.res*","millepede.his*","pede.dump*", "millepede.end",
0082         "alignments_MP.db","pedeSteer*.txt*","theScript.sh");
0083 
0084   while ($theFile = shift @FILENAMES) {
0085     $copyFile = $dirPrefix.$theFile;
0086     print "cp -p $copyFile $saveDir/\n";
0087     system "cp -p $copyFile $saveDir/";
0088     $retcode = $? >> 8;
0089     if ($retcode) {
0090     print "Copy of $copyFile failed, retcode=$retcode\n";
0091     }
0092   }
0093 
0094 # Now copy the backup of original scripts, cfg and infiList
0095   $ScriptCfg = `ls jobData/ScriptsAndCfg???.tar`;
0096   chomp($ScriptCfg);
0097   $ScriptCfg =~ s/\n/ /g;
0098   $ScriptCfg =~ s/jobData\///g;
0099 
0100   @FILENAMES = split(' ',$ScriptCfg);
0101 
0102   while ($theFile = shift @FILENAMES) {
0103     $copyFile = "jobData/".$theFile;
0104     if (-r $copyFile) {
0105       print "cp -p $copyFile $saveDir/\n";
0106       system "cp -p $copyFile $saveDir/";
0107       $retcode = $? >> 8;
0108       if ($retcode) {
0109     print "Copy of $copyFile failed, retcode=$retcode\n";
0110       }
0111     }
0112     else {
0113       print "$copyFile unreadable or not existing\n";
0114     }
0115   }
0116 }