5
from __future__ import absolute_import
6
from __future__ import print_function
9
11
import xml.sax.handler
13
from six.moves import range
14
from six.moves import input
12
17
import madgraph.madweight.Cards as Cards
27
32
def create_TF_main(name,make, MW_dir):
28
print "start main program"
33
print("start main program")
29
34
TF_file=Full_TF(name)
30
35
TF_file.read_file("./data/TF_"+name+".dat")
32
print "deleting the current TFlib: "
37
print("deleting the current TFlib: ")
33
38
os.system("rm ../../../lib/libTF.a >& /dev/null")
35
40
TF_file.create_ordering_file()
36
print "ordering_file.inc created"
41
print("ordering_file.inc created")
37
42
list_var=TF_file.create_transfer_functions()
38
print "transfer_function.f created"
43
print("transfer_function.f created")
39
44
TF_file.create_transfer_card(list_var)
40
print "transfer_card.dat created"
45
print("transfer_card.dat created")
41
46
create_param_inc(list_var)
42
print "TF_param created"
47
print("TF_param created")
43
48
create_ident_card(list_var)
44
print "ident_card created"
49
print("ident_card created")
45
50
create_version(name)
46
print 'TransferFunctionVersion created'
51
print('TransferFunctionVersion created')
47
52
fsock = open('nb_tf.inc','w').write(' integer nb_tf\n parameter (nb_tf=1)\n')
48
53
os.chdir('../../../') #go to main
53
58
for directory in MW_dir:
54
59
obj=TF_in_SubProcesses(TF_file,directory)
55
60
obj.write_transfer_function_file()
56
print 'call_TF.f created in for all Subprocesses'
61
print('call_TF.f created in for all Subprocesses')
57
62
os.chdir('./Source/MadWeight/transfer_function')
58
63
update_dir(name,make,MW_dir)
59
print 'generation completed'
64
print('generation completed')
62
67
#1 #################################################################################
404
409
label_to_block=self.TF_data.find_label_to_block() #return {label:block}
406
411
if pid in ['x1','x2']: #treat special case for initial particles
407
if label_to_block.has_key(pid):
412
if pid in label_to_block:
408
413
return label_to_block[pid]
411
416
pid=abs(int(pid))
412
417
if pid in particle_class.invisible_list:
414
if label_to_block.has_key(pid_to_label[pid]):
419
if pid_to_label[pid] in label_to_block:
415
420
return label_to_block[pid_to_label[pid]]
447
452
#add the definition for external function
448
453
for block in self.blockname_list:
449
if isinstance(block, basestring):
454
if isinstance(block, six.string_types):
450
455
name_list='width_E_'+block+', width_THETA_'+block+', width_PHI_'+block
492
497
text='$B$ START_TRANSFER_FCT $E$\n'
495
if self.TF_data.label_to_block.has_key('met'):
500
if 'met' in self.TF_data.label_to_block:
496
501
met = self.TF_data.label_to_block['met']
497
502
#add new definition
498
503
text+=' double precision p_met_exp(0:3),p_met_rec(0:3)\n'
507
512
for i in range(0,len(self.blockname_list)):
508
513
blockname=self.blockname_list[i]
510
if not isinstance(blockname, basestring):
515
if not isinstance(blockname, six.string_types):
511
516
if met and blockname == -1 and i>2: #invisible particlule but not the initial part
512
517
text+=' do i=0,3\n p_met_rec(i)=p_met_rec(i)+p(i,%s)\n enddo\n' %(i+1)
539
544
text2+='\n'+self.text_tf_E_for_one_part(i)+'\n'
540
545
blockname=self.blockname_list[i]
542
if not isinstance(blockname, basestring):
547
if not isinstance(blockname, six.string_types):
543
548
text+=' if(MG_num.eq.%s) then\n tf_E_for_part=1d0\n return\n endif\n' % (i+1)
545
550
text+=' if(MG_num.eq.%s) then\n' %(i+1)
566
571
text+='$B$ DEF_TF_E_FOR_ONE_PART $E$\n'
568
573
blockname=self.blockname_list[i]
569
if not isinstance(blockname, basestring):
574
if not isinstance(blockname, six.string_types):
570
575
text+=' tf_E_for_%s=1d0\n' %(i+1)
572
577
text+=' tf_E_for_%s=1d0\n' %(i+1)
716
721
""" read the file to find the requested change of variable"""
719
for line in file(filepos):
724
for line in open(filepos):
721
726
name=line.split()[0] #remove blank spae,end of line,...
737
742
listdir=os.listdir('./Source/MadWeight/transfer_function/data')
738
print 'Available TF function:\n ',
739
print '\n '.join([content[3:-4] for content in listdir if (content.startswith('TF') and content.endswith('dat'))])
740
name=raw_input('Choose your Transfer Function\n')
743
print('Available TF function:\n ', end=' ')
744
print('\n '.join([content[3:-4] for content in listdir if (content.startswith('TF') and content.endswith('dat'))]))
745
name=input('Choose your Transfer Function\n')
743
748
if name in ['proc_card.dat','auto']:
749
754
os.chdir('./Source/MadWeight/transfer_function')
750
755
create_TF_main(name,made_make,MW_dir)
752
## file=raw_input("file: ")
757
## file=six.input("file: ")
753
758
## ff=open(file,'r')
754
759
## gg=open(file+'_70.f','w')
755
760
## text=ff.read()