Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:03

0001 #!/usr/local/bin/perl
0002 
0003 use strict;
0004 use warnings;
0005 use Getopt::Long;
0006 use File::Path;
0007 use File::Basename;
0008 use File::Copy;
0009 
0010 my $test;
0011 GetOptions("test"=>\$test);
0012 if ($#ARGV < 3)
0013 {
0014     print "usage: run_condor.pl <particle> <eta> <momentum> <outdir>\n";
0015     print "options:\n";
0016     print "-test: testmode - no condor submission\n";
0017     exit(-2);
0018 }
0019 else
0020 {
0021     print "running condor\n";
0022 }
0023 my $curdir = `pwd`;
0024 chomp $curdir;
0025 my $rundir = $curdir;
0026 
0027 my $executable = sprintf("run_single_particle.csh");
0028 
0029 my $particle = $ARGV[0];
0030 my $eta = $ARGV[1];
0031 my $mom = $ARGV[2];
0032 my $outdir = $ARGV[3];
0033 mkpath($outdir);
0034 
0035 my $indir = "/sphenix/data/data02/review_2017-08-02/single_particle/spacal2d/fieldmap";
0036 
0037 my $suffix = sprintf("%s_eta%s_%sGeV",$particle,$eta,$mom);
0038 my $listfile = sprintf("%s/%s.list",$outdir,$suffix);
0039 my $outputdir = sprintf("%s/ntuple",$outdir);
0040 mkpath($outputdir);
0041 my $outputfile = sprintf("%s/%s.root",$outputdir,$suffix);
0042 open(F,">$listfile");
0043 my $nfiles = 0;
0044 for (my $iseg=0; $iseg<12; $iseg++)
0045 {
0046     my $infile = sprintf("%s/G4Hits_sPHENIX_%s_eta%s_%sGeV-%04d.root",$indir,$particle,$eta,$mom,$iseg);
0047     if (! -f $infile)
0048     {
0049     print "could not locate $infile\n";
0050     next;
0051     }
0052     print F "$infile\n";
0053     $nfiles++;
0054 }
0055 close(F);
0056 if ($nfiles <= 0)
0057 {
0058     die "no files in list - dying now\n";
0059 }
0060 my $logdir = sprintf("%s/condor/log",$outdir);
0061 mkpath($logdir);
0062 my $jobfile = sprintf("%s/condor_%s.job",$logdir,$suffix);
0063 my $condorlogfile = sprintf("%s/condor_%s.log",$logdir,$suffix);
0064 if (-f $condorlogfile)
0065 {
0066     unlink $condorlogfile;
0067 }
0068 my $outfile = sprintf("%s/condor_%s.out",$logdir,$suffix);
0069 my $errfile = sprintf("%s/condor_%s.err",$logdir,$suffix);
0070 print "job: $jobfile\n";
0071 open(F,">$jobfile");
0072 print F "Universe       = vanilla\n";
0073 print F "Executable     = $executable\n";
0074 print F "+Experiment    = \"phenix\"\n";
0075 #print F "+Job_Type      = \"highmem\"\n";
0076 print F "Arguments       = \"$listfile $outputfile\"\n";
0077 print F "notification   = Error\n";
0078 print F "Output         = $outfile\n";
0079 print F "Error          = $errfile\n";
0080 print F "Log            = $condorlogfile\n";
0081 print F "Initialdir     = $rundir\n";
0082 print F "PeriodicHold   = (NumJobStarts>=1 && JobStatus == 1)\n";
0083 #print F "Requirements   = (CPU_Experiment == \"phenix\" && (SlotID == 39 ||SlotID == 40)) \n";
0084 print F "Requirements   = (CPU_Experiment == \"phenix\") \n";
0085 print F "Priority       = 42\n";
0086 print F "job_lease_duration = 3600\n";
0087 print F "Queue 1\n";
0088 close(F);
0089 
0090 if (defined $test)
0091 {
0092     print "would submit $jobfile\n";
0093 }
0094 else
0095 {
0096     system("condor_submit $jobfile");
0097 }