msf_helper.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #------------------------------------------------------------#
3 # warning! do not make *too many* in one go, or FTS will die
4 # usage: python msf_helper.py
5 # prod5, execute as novapro from /nova/app/home/novapro/PROD5_SHIFTERS/mcgen/fcls
6 # script to make make_sim_fcl less error-prone
7 # help: lasquith@fnal.gov, scalvez@fnal.gov
8 #------------------------------------------------------------#
9 import sys, shlex, subprocess, math, os
10 from subprocess import Popen, PIPE
11 debug = True
12 #** ND : [fhc,rhc][nonswap] make 65k, use 15k
13 #** FD : [fhc,rhc][nonswap,fluxswap] make 12k, use 6k
14 # systs = ["cherenkov","llup","lldown","detectoraging"]
15 systs = []#["mcnp"]#["detectoraging"]
16 dets = ["nd"]#,"fd"]
17 swaps = ["nonswap"]#, "swap"]
18 horns = ["0hc"]
19 pot = "2.5e16"
20 potper = "spill"
21 events = "1000"
22 lastrun = "1001999"
23 numsubruns = "64"
24 gainmode = "100"
25 generator = "genie"
26 genietune = "N1810j0211a"
27 
28 iteration = "1"
29 batchnumber = "1"
30 nppfx = "0"
31 timespec = "rocksingles"
32 nogenierw = True
33 rockonly = True
34 singlemod = True
35 geantonly = True
36 fts = True
37 tags = "--nogenierw --fts"
38 o ="/nova/app/home/novapro/PROD5_SHIFTERS/mcgen/fcls/"
39 
40 NOVAPRODUCTION_DIR = os.getenv('NOVAPRODUCTION_DIR')
41 
42 goodruns_fd_fhc = NOVAPRODUCTION_DIR + "/goodruns/fd_grl_v0_period12359.txt"
43 goodruns_nd_fhc = NOVAPRODUCTION_DIR + "/goodruns/nd_grl_v0_period12359.txt"
44 goodruns_fd_rhc = NOVAPRODUCTION_DIR + "/goodruns/fd_grl_v0_period4_6-8.txt"
45 goodruns_nd_rhc = NOVAPRODUCTION_DIR + "/goodruns/nd_grl_v0_period4_6-8.txt"
46 
47 mix_fd_fhc = "cosmic lasquith_fd_cosmics_p12359_goodruns_prod5"
48 mix_fd_rhc = "cosmic scalvez_artdaq_fd_cosmics_p4678_goodruns_prod5"
49 mix_nd_fhc = "rock prod5_nd_fhc_rock_g4"
50 mix_nd_rhc = "rock prod5_nd_rhc_rock_g4"
51 
52 plist_fhc="12359"
53 plist_rhc="4678"
54 
55 num_fd = "12000"
56 num_nd = "10000"
57 
58 mk_outdir_cmd="null"
59 
60 for syst in systs:
61  for det in dets:
62  for horn in horns:
63  if det=="fd":
64  swaps = ["nonswap", "swap"]
65  if horn=="fhc":
66  mix = mix_fd_fhc
67  num = num_fd
68  goodruns = goodruns_fd_fhc
69  plist = plist_fhc
70  elif horn=="rhc":
71  mix = mix_fd_rhc
72  num = num_fd
73  goodruns = goodruns_fd_rhc
74  plist = plist_rhc
75  elif det=="nd":
76  swaps = ["nonswap"]
77  if horn=="fhc":
78  mix = mix_nd_fhc
79  num = num_nd
80  goodruns = goodruns_nd_fhc
81  plist = plist_fhc
82  elif horn=="rhc":
83  mix = mix_nd_rhc
84  num = num_nd
85  goodruns = goodruns_nd_rhc
86  plist = plist_rhc
87 
88  for swap in swaps:
89  log = "new_"+syst+"_"+det+"_"+horn+"_"+swap+".log"
90  if not debug: log_file = open(log, 'w')
91  outdir = o+"new_"+syst+"_"+det+"_"+horn+"_"+swap
92  cmd = "make_sim_fcl --syst "+syst+" -det "+det+" -hp "+horn+" -fs "+swap+" -ts periods"+plist+" --mix "+mix+" -rsr "+num+" "+goodruns+" -gt "+genietune+" -bn "+batchnumber+" -i "+iteration+" -gen "+generator+" --nppfx "+nppfx+" "+tags+" --fts -o "+outdir
93  if det is "nd":
94  cmd += " --potper"+potper+ " --pot " + pot
95  else:
96  cmd += " --events " + events
97  mk_outdir_cmd = "mkdir "+outdir
98 
99  print "mk_outdir_cmd: ",mk_outdir_cmd
100  print "cmd: ",cmd
101  if not debug:
102  if not os.path.isdir(outdir):
103  p1=Popen( shlex.split(mk_outdir_cmd),stdout=PIPE, stderr=PIPE)
104  p2 = Popen( shlex.split(cmd) ,stdout=log_file ,stderr=subprocess.STDOUT )
105  # swaps
106  # horns
107  # detectors
108 #systematics
109 print "Fin."
110 
111 
112 
113 
114 
115 
116 
117 
procfile open("FD_BRL_v0.txt")