ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/scripts/makeBNTreePlot.py
(Generate patch)

Comparing UserCode/OSUT3Analysis/Configuration/scripts/makeBNTreePlot.py (file contents):
Revision 1.14 by wulsin, Thu Jun 13 09:35:44 2013 UTC vs.
Revision 1.16 by wulsin, Mon Jun 17 08:49:16 2013 UTC

# Line 27 | Line 27 | gROOT.SetBatch(True)  # This is to preve
27  
28  
29   def MakeCondorSubmitFile(arguments, dataset):
30 +    outdir = "condor/"+arguments.condorDir+"/"+dataset+"/"  
31      p = subprocess.Popen(["which", "makeBNTreePlot.py"], stdout=subprocess.PIPE)
32 <    executable = p.communicate()[0]  # read the stdout of the command  
32 >    executable = p.communicate()[0]  # read the stdout of the command
33      workdir = os.getcwd() + "/"
34 <    outdir = "condor/"+arguments.condorDir+"/"+dataset+"/"  
34 >
35 >    # Count the number of hist*root files in the specified directory
36 >    p = subprocess.Popen("ls " + workdir + outdir + "hist*root | wc", shell=True, stdout=subprocess.PIPE)  
37 >    out = p.communicate()[0]
38 >    outSplit = out.split()
39 >    totalJobs = int(outSplit[0])  # The first element of the list is the number of files
40 >
41 >    ## print "Debug: outSplit = "
42 >    ## print outSplit
43 >    ## out, err = p.communicate()
44 >    ## print "Debug: Size of out:"
45 >    ## print len(out)
46 >    ## print "out = "
47 >    ## print out
48 >    ## print "err = "
49 >    ## print err
50 >    ## print "Debug:  p.communicate()[0] = " + p.communicate()[0]
51 >    ## totalJobs = len(out)
52      out = open(outdir+"/condorBNTree.sub", "w")
53      out.write("Executable              = " + executable + " \n")
54      out.write("Universe                = vanilla \n")
55      out.write("Getenv                  = True \n")
56 <    out.write("Arguments               = -D " + dataset + " -l " + arguments.localConfig + " -c " + arguments.condorDir + " \n")
56 >    argCondorProcess = ""  
57 >    if arguments.splitCondorJobs:
58 >        argCondorProcess = " -p $(Process) "
59 >    out.write("Arguments               = -D " + dataset + " -l " + arguments.localConfig + " -c " + arguments.condorDir + argCondorProcess + " \n")
60      out.write("Output                  = " + workdir + outdir + "condorBNTree_$(Process).out \n")
61      out.write("Error                   = " + workdir + outdir + "condorBNTree_$(Process).err \n")
62      out.write("Log                     = " + workdir + outdir + "condorBNTree_$(Process).log \n")
63      out.write("+IsLocalJob             = true \n")
64      out.write("Rank                    = TARGET.IsLocalSlot \n")
65 <    out.write("Queue 1 \n")
65 >    if arguments.splitCondorJobs:
66 >        out.write("Queue " + str(totalJobs) + " \n")
67 >    else:
68 >        out.write("Queue 1 \n")
69      out.close()  
70  
71  
# Line 58 | Line 82 | def RunOnCondor(arguments, split_dataset
82          print "Submitting job: %s " % cmd
83  
84      print "Once condor jobs have finished, merge the composite datasets and then make plots with:"  
85 <    print "    makeBNTreePlot.py -q -l " + arguments.localConfig + " -c " + arguments.condorDir  
86 <    print "    makePlots.py         -l " + arguments.localConfig + " -c " + arguments.condorDir  
85 >    if arguments.splitCondorJobs:
86 >        print "    mergeOutput.py -q    -l " + arguments.localConfig + " -c " + arguments.condorDir
87 >    else:
88 >        print "    makeBNTreePlot.py -q -l " + arguments.localConfig + " -c " + arguments.condorDir
89 >    print     "    makePlots.py         -l " + arguments.localConfig + " -c " + arguments.condorDir  
90          
91      return
92  
# Line 72 | Line 99 | parser = OptionParser()
99   parser = set_commandline_arguments(parser)
100  
101   ###  Only used by makeBNTreePlot.py (maybe move to another file?)        
102 + parser.remove_option("-p")
103   parser.add_option("-D", "--dataset", dest="datasetName",        
104                    help="Name of dataset (overrides value from local configuration file)")        
105   parser.add_option("-C", "--runOnCondor",  action="store_true", dest="runOnCondor", default=False,        
106                    help="Run on condor instead of interactively")        
107 + parser.add_option("-S", "--splitCondorJobs", action="store_true", dest="splitCondorJobs", default=False,                
108 +                  help="Split condor jobs to have one for each file, rather than one for each dataset")  
109 + parser.add_option("-p", "--condorProcessNum", dest="condorProcessNum", default=-1,      
110 +                  help="Specify which condor process to run (default is to run over all).")      
111 +
112  
113   (arguments, args) = parser.parse_args()
114  
# Line 113 | Line 146 | if not arguments.quickMerge:
146      for dataset in split_datasets:
147          if BNTreeUseScript:
148              chainName = "OSUAnalysis/" + BNTreeChannel + "/BNTree_" + BNTreeChannel
149 <            command = "root -l -b -q '" + BNTreeScript + "+(\"" + condor_dir + "\",\"" + dataset + "\",\"" + chainName + "\")'"  
149 >            command = "root -l -b -q '" + BNTreeScript + "+(\"" + condor_dir + "\",\"" + dataset + "\",\"" + chainName + "\"," + str(arguments.condorProcessNum) + ")'"  
150              print "About to execute command:  " + command  
151              os.system(command)
152          else:
# Line 159 | Line 192 | for composite_dataset in composite_datas
192      print "Merging output for composite dataset: " + composite_dataset
193      os.system(command)
194        
195 < print ("Total time: "),
195 > print ("Total time to run makeBNTreePlot.py: "),
196   watch.Stop()
197   watch.Print()
198              

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines