|
ATLAS Offline Software
|
|
def | find_matrix_files (process_dir) |
|
def | get_process (infile, test_string='Process:') |
|
def | return_out_index (process) |
|
def | find_W_prepare_DRXhack (mfile, bindex, windex, redefine_twidth, which_DR) |
|
def | do_DR1_hacks (mfile, tmpfile) |
|
def | do_driver_hacks (driver_filename) |
|
def | do_fks_hacks (pdir) |
|
def | do_coupl_hacks (pdir) |
|
def | find_jamp (mfile, helperfile, test_string, end_string) |
|
def | do_DR2_hack (mfile, tmpfile, suffix, to_replace, should_replace) |
|
def | write_jamp_res (my_jamp_line, tmp_c) |
|
def | do_DRX (DRmode, process_dir) |
| Perform DR for matrix element #. More...
|
|
def | do_MadSpin_DRX (DRmode, msdirname) |
| Perform Diagram Removal for MadSpin #. More...
|
|
|
| drlog = Logging.logging.getLogger('DiagramRemoval') |
|
◆ do_coupl_hacks()
def python.DiagramRemoval.do_coupl_hacks |
( |
|
pdir | ) |
|
Definition at line 145 of file DiagramRemoval.py.
146 shutil.copyfile(pdir+
"coupl.inc", pdir+
"coupl.inc~" )
148 test_string1 =
"MDL_WT"
149 test_string2 =
"WIDTHS"
151 with open(pdir+
"../Cards/param_card.dat",
"r")
as pcard:
152 the_lines = pcard.readlines()
153 for line
in the_lines:
154 if "DECAY" in line
and " 6 " in line:
155 top_width = line.split(
" 6 ")[-1].rstrip()
158 with open(pdir+
"coupl.inc",
"w")
as destination,
open(pdir+
"coupl.inc~")
as source:
159 mylines = source.readlines()
160 for i,line
in enumerate(mylines):
161 destination.write(line)
162 if test_string1
in line
and test_string2
in line:
163 destination.write(
"\n DOUBLE PRECISION MDL_WT_nonzero\n")
164 destination.write(
" PARAMETER (MDL_WT_nonzero="+top_width+
")\n")
166 os.remove(pdir+
"coupl.inc~")
◆ do_DR1_hacks()
def python.DiagramRemoval.do_DR1_hacks |
( |
|
mfile, |
|
|
|
tmpfile |
|
) |
| |
Definition at line 86 of file DiagramRemoval.py.
87 drlog.info(
"performing DR1 for file "+mfile)
89 with open(tmpfile,
"r")
as mytmp:
90 for line
in fileinput.input(mfile, inplace=
True):
92 if re.search(
r'TMP_JAMP\(\d+\) =', line)
and not dr1Hack_done:
94 for hackline
in mytmp:
96 print(
"C End DR hack. \n")
◆ do_DR2_hack()
def python.DiagramRemoval.do_DR2_hack |
( |
|
mfile, |
|
|
|
tmpfile, |
|
|
|
suffix, |
|
|
|
to_replace, |
|
|
|
should_replace |
|
) |
| |
Definition at line 193 of file DiagramRemoval.py.
193 def do_DR2_hack(mfile, tmpfile, suffix,to_replace,should_replace):
194 shutil.copyfile(mfile, mfile+
"~" )
195 with open(mfile,
"w")
as destination,
open(mfile+
"~")
as source,
open(tmpfile,
"r")
as mytmp,
open(mfile+
".jamp1",
"r")
as saved_jamp1,
open(mfile+
".jamp2",
"r")
as saved_jamp2:
196 tmp_content = mytmp.readlines()
197 for i,line
in enumerate(source):
198 if i
in to_replace.keys()
and should_replace==1:
199 destination.write(to_replace[i])
201 destination.write(line)
203 if "JAMP(NCOLOR)" in line
and "COMPLEX*16" in line:
204 destination.write(
" REAL*8 MATRIX"+suffix+
"_res\n")
205 destination.write(
" COMPLEX*16 JAMP_res(NCOLOR)\n")
206 elif "JAMP(1)=" in line:
207 drlog.info(
"performing DR2 for file "+mfile)
208 jamplines = saved_jamp1.readlines()
210 for j,jline
in enumerate(jamplines):
213 elif "JAMP(2)=" in line:
214 jamplines = saved_jamp2.readlines()
216 for j,jline
in enumerate(jamplines):
221 elif "DENOM(I)" in line:
223 destination.write(line)
224 destination.write(
"\n "+jamp_res1)
225 destination.write(
" "+jamp_res2+
"\n")
226 hardcode =
" MATRIX"+suffix+
"_res = 0.D0\n DO I = 1, NCOLOR\n ZTEMP = (0.D0,0.D0)\n DO J = 1, NCOLOR\n ZTEMP = ZTEMP + CF(J,I)*JAMP_res(J)\n ENDDO\n MATRIX"+suffix+
"_res = MATRIX"+suffix+
"_res+ZTEMP*DCONJG(JAMP_res(I))/DENOM(I)\n ENDDO\n MATRIX"+suffix+
" = MATRIX"+suffix+
" - MATRIX"+suffix+
"_res\n"
227 destination.write(hardcode)
◆ do_driver_hacks()
def python.DiagramRemoval.do_driver_hacks |
( |
|
driver_filename | ) |
|
Definition at line 102 of file DiagramRemoval.py.
103 test_string1 =
"weight.gt."
104 repl_string1 =
"abs(weight).gt."
106 test_string2 =
"maxweight=weight"
107 repl_string2 =
"maxweight=abs(weight)"
109 source =
open(driver_filename,
"r")
110 mylines = source.readlines()
111 with open(driver_filename,
"w")
as source:
112 for i,line
in enumerate(mylines):
113 if test_string1
in line:
114 mylines[i] = line.replace(test_string1,repl_string1)
115 if test_string2
in line:
116 mylines[i] = line.replace(test_string2,repl_string2)
117 source.write(mylines[i])
◆ do_DRX()
def python.DiagramRemoval.do_DRX |
( |
|
DRmode, |
|
|
|
process_dir |
|
) |
| |
Perform DR for matrix element #.
Definition at line 262 of file DiagramRemoval.py.
262 def do_DRX(DRmode, process_dir):
263 drlog.info(
"in do_DRX, DRmode="+
str(DRmode)+
", process_dir = "+process_dir)
264 pdir=process_dir+
'/SubProcesses/'
273 matrix_idx = re.compile(
r"matrix_(\d+).f").
search(mfile).
group(1)
276 for myline
in process:
277 m2 = myline.split(
"Process: ")[1]
278 the_process = m2.split(
" WEIGHTED")[0]
283 redefine_twidth=
False
288 if os.path.getsize(
"mytmp.txt")>0:
292 find_jamp(mfile,mfile+
".jamp1",
"JAMP(1)",
"JAMP(2)")
293 find_jamp(mfile,mfile+
".jamp2",
"JAMP(2)",
"MATRIX")
294 do_DR2_hack(mfile,
"mytmp.txt",
"_"+matrix_idx,to_replace,1)
296 os.remove(mfile+
".jamp1")
297 os.remove(mfile+
".jamp2")
◆ do_fks_hacks()
def python.DiagramRemoval.do_fks_hacks |
( |
|
pdir | ) |
|
Definition at line 120 of file DiagramRemoval.py.
121 shutil.copyfile(pdir+
"fks_singular.f", pdir+
"fks_singular.f~" )
123 test_string =
"wgt.lt.0.d0"
124 end_string =
"return"
126 with open(pdir+
"fks_singular.f",
"w")
as destination,
open(pdir+
"fks_singular.f~")
as source:
127 mylines = source.readlines()
129 for i,line
in enumerate(mylines):
131 if test_string
in line:
133 destination.write(
"C"+line)
135 destination.write(line)
137 if end_string
in line:
139 destination.write(line)
141 destination.write(
"C"+line)
143 os.remove(pdir+
"fks_singular.f~")
◆ do_MadSpin_DRX()
def python.DiagramRemoval.do_MadSpin_DRX |
( |
|
DRmode, |
|
|
|
msdirname |
|
) |
| |
Perform Diagram Removal for MadSpin #.
Definition at line 302 of file DiagramRemoval.py.
305 pdir=my_ms_dir+
'/production_me/SubProcesses/'
306 fdir=my_ms_dir+
'/full_me/SubProcesses/'
307 full_files=os.listdir(fdir)
313 for myline
in process:
314 m2 = myline.split(
"Process: ")[1]
315 the_process = m2.split(
"WEIGHTED")[0]
319 redefine_twidth=
False
322 if os.path.getsize(
"mytmp.txt")>0:
326 find_jamp(mfile,mfile+
".jamp1",
"JAMP(1)",
"JAMP(2)")
327 find_jamp(mfile,mfile+
".jamp2",
"JAMP(2)",
"MATRIX")
328 do_DR2_hack(mfile,
"mytmp.txt",
"_PROD",to_replace,0)
330 prefix = mfile.replace(
"/matrix_prod.f",
"")
331 prefix_full = prefix.replace(
"production_me",
"full_me")
333 for f_file
in full_files:
334 if prefix_full
in fdir+f_file:
335 full_file_matrix = fdir+f_file+
"/matrix.f"
336 full_file_matrix_prod = fdir+f_file+
"/matrix_prod.f"
341 find_jamp(full_file_matrix,full_file_matrix+
".jamp1",
"JAMP(1)",
"JAMP(2)")
342 find_jamp(full_file_matrix,full_file_matrix+
".jamp2",
"JAMP(2)",
"MATRIX")
343 find_jamp(full_file_matrix_prod,full_file_matrix_prod+
".jamp1",
"JAMP(1)",
"JAMP(2)")
344 find_jamp(full_file_matrix_prod,full_file_matrix_prod+
".jamp2",
"JAMP(2)",
"MATRIX")
346 do_DR2_hack(full_file_matrix,
"mytmp.txt",
"",to_replace,0)
347 do_DR2_hack(full_file_matrix_prod,
"mytmp.txt",
"_PROD",to_replace,0)
350 drlog.info(
"finished do_MadSpin_DRX")
◆ find_jamp()
def python.DiagramRemoval.find_jamp |
( |
|
mfile, |
|
|
|
helperfile, |
|
|
|
test_string, |
|
|
|
end_string |
|
) |
| |
Definition at line 170 of file DiagramRemoval.py.
170 def find_jamp(mfile,helperfile,test_string,end_string):
172 with open(mfile,
"r")
as source:
173 mylines = source.readlines()
176 for i,line
in enumerate(mylines):
178 if test_string
in line:
183 if end_string
in line:
188 with open(helperfile,
"w")
as destination:
189 destination.write(my_jamp)
190 drlog.info(
"my_jamp = "+
str(my_jamp))
◆ find_matrix_files()
def python.DiagramRemoval.find_matrix_files |
( |
|
process_dir | ) |
|
Definition at line 15 of file DiagramRemoval.py.
16 return glob.glob(process_dir+
"/P*_*/matrix_*.f")
◆ find_W_prepare_DRXhack()
def python.DiagramRemoval.find_W_prepare_DRXhack |
( |
|
mfile, |
|
|
|
bindex, |
|
|
|
windex, |
|
|
|
redefine_twidth, |
|
|
|
which_DR |
|
) |
| |
Definition at line 46 of file DiagramRemoval.py.
50 with open(mfile,
"r")
as f,
open(
"mytmp.txt",
"w")
as tmpf:
52 mylines = f.readlines()
53 for i,line
in enumerate(mylines):
54 if "1,"+
str(bindex)+
"))" in line.split(
"(")[-1]
and "XXXXX" not in mylines[i]:
56 elif "1,"+
str(windex)+
"))" in line.split(
"(")[-1]
and "XXXXX" not in mylines[i]:
60 for j
in range(len(W_vector)):
61 if W_vector[j]
in line
and "AMP(" in line:
62 amplitude = line.split(
",")[-1]
64 tmpf.write(
" "+amplitude[:-2]+
"=(0d0,0d0)\n")
66 tmpf.write(amplitude[:-2]+
"\n")
67 elif W_vector[j]
in line
and "AMP" not in line:
68 if W_vector[j]+
")" in line:
69 updated_vector.remove(W_vector[j])
71 the_W = line.split(
",")[-2]+
","+line.split(
",")[-1][0:-2]
72 updated_vector.append(the_W)
73 W_vector=updated_vector
75 if "W(1,"+
str(bindex)+
")" in mylines[i]
and "W(1,"+
str(windex)+
")" in mylines[i]
and "MDL_WT" in mylines[i]:
76 the_W = line.split(
",")[-2]+
","+line.split(
",")[-1][0:-2]
77 W_vector.append(the_W)
78 updated_vector=W_vector
81 edited_line = line.replace(
"MDL_WT",
"MDL_WT_nonzero")
82 to_replace[i]=edited_line
◆ get_process()
def python.DiagramRemoval.get_process |
( |
|
infile, |
|
|
|
test_string = 'Process:' |
|
) |
| |
◆ return_out_index()
def python.DiagramRemoval.return_out_index |
( |
|
process | ) |
|
Definition at line 28 of file DiagramRemoval.py.
29 p_in,p_out = process.split(
" > ")
30 p_in = p_in.split(
" ")
31 p_out = p_out.split(
" ")
32 particles = p_in+p_out
36 for i,particle
in enumerate(particles):
37 if (particle
in ([
"w-",
"w+"]))
and i>=len(p_in):
39 elif (particle
in ([
"b",
"b~"]))
and i>=len(p_in):
◆ write_jamp_res()
def python.DiagramRemoval.write_jamp_res |
( |
|
my_jamp_line, |
|
|
|
tmp_c |
|
) |
| |
Definition at line 231 of file DiagramRemoval.py.
233 my_jamp_line = my_jamp_line.replace(
"+",
",+")
234 my_jamp_line = my_jamp_line.replace(
"-",
",-")
235 split_line = my_jamp_line.split(
",")[1:]
238 for term
in split_line:
240 jamp_resX = jamp_resX+term
242 jamp_prefix = line.split(
"=")[1].
split(
"*(")
243 if len(jamp_prefix)>1:
244 jamp_resX = jamp_prefix[0]+
"*("+jamp_resX
245 if jamp_resX[-2:]!=
"\n":
246 if "))" not in jamp_resX[-4:]:
247 jamp_resX=jamp_resX+
")\n"
249 jamp_resX=jamp_resX+
"\n"
252 if "\n" not in jamp_resX:
253 jamp_resX=jamp_resX+
"\n"
◆ drlog
python.DiagramRemoval.drlog = Logging.logging.getLogger('DiagramRemoval') |
def find_W_prepare_DRXhack(mfile, bindex, windex, redefine_twidth, which_DR)
def write_jamp_res(my_jamp_line, tmp_c)
def do_driver_hacks(driver_filename)
def do_DR1_hacks(mfile, tmpfile)
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
def do_DRX(DRmode, process_dir)
Perform DR for matrix element #.
def do_MadSpin_DRX(DRmode, msdirname)
Perform Diagram Removal for MadSpin #.
def get_process(infile, test_string='Process:')
def find_jamp(mfile, helperfile, test_string, end_string)
def do_DR2_hack(mfile, tmpfile, suffix, to_replace, should_replace)
void print(char *figname, TCanvas *c1)
def return_out_index(process)
def find_matrix_files(process_dir)