-
Notifications
You must be signed in to change notification settings - Fork 0
/
OppFuns.py
executable file
·291 lines (270 loc) · 12.3 KB
/
OppFuns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/usr/bin/env python
from MiscFuns import *
from FitParams import StateParList
from FFParams import *
from Params import *
from SetLists import GetTsinkSmLists
from CombParams import CombList
from copy import copy
def DoubSingList(listin):
return ['doub'+il for il in listin] + ['sing'+il for il in listin]
def DoubSingCmplxList(listin):
return ['doub'+il+'cmplx' for il in listin] + ['sing'+il+'cmplx' for il in listin]
def CreateOppDir(Opp):
if Opp in ['Mass','twopt']: return Opp+'/'
thisSplitOpp,contents = SplitOpp(Opp)
count,iscmplx = 0,''
DS = ''
if 'Gamma' in contents:
igamma = thisSplitOpp[count]
count += 1
if 'Der' in contents:
igamma = igamma + thisSplitOpp[count]
count += 1
if 'DS' in contents:
DS = thisSplitOpp[count]
count += 1
if 'Proj' in contents:
Proj = thisSplitOpp[count]
if 'Run' in contents: iscmplx = 'cmplx'
try:
return igamma + '/' +DS+Proj + iscmplx + '/'
except:
raise IOError('Invalid Opp string '+Opp)
def SetOpps(AllList):
[Extra,thisOppList,thisProjList,thisDSList,RunList] = set([]),set([]),set([]),set([]),set([])
iscmplx = ''
for iOpp in AllList:
if iOpp in ['Mass','twopt','P4giDi','doubP4giDi','singP4giDi']:
Extra = Extra.union([iOpp])
continue
SplitOpps,contents = SplitOpp(iOpp)
count = 0
if 'Gamma' in contents:
if 'Der' in contents:
thisOppList = thisOppList.union([SplitOpps[count]+SplitOpps[count+1]])
count += 1
else:
thisOppList = thisOppList.union([SplitOpps[count]])
count += 1
if 'DS' in contents:
thisDSList = thisDSList.union([SplitOpps[count]])
count += 1
else:
thisDSList = thisDSList.union(['UmD'])
if 'Proj' in contents:
thisProjList = thisProjList.union([SplitOpps[count]])
if 'Run' in contents: iscmplx = 'cmplx'
return sorted(Extra),sorted(thisOppList),sorted(thisDSList),sorted(thisProjList),'real, '+iscmplx
def Wipe2pt(outputdir,tvarlist=[],smlist=[],thisMomList=RunMomList):
thistvarlist = ['PoF'+str(PoFShifts)+itvar for itvar in tvarlist]
thistvarlist += ['CM'+itvar for itvar in tvarlist]
xmlMomList = map(qstrTOqcond,thisMomList)
for iflag in ['cfuns/twopt','Mass']:
for ip in xmlMomList:
thisdir = outputdir+iflag+MakeMomDir(ip)
for itvar in thistvarlist:
ifile = thisdir+itvar+'LREM'+ip+'.xml'
if os.path.isfile(ifile): os.remove(ifile)
ifile = thisdir+'boots/'+itvar+'LREM'+ip+'.boot.p'
if os.path.isfile(ifile): os.remove(ifile)
# for istate in GetStateSet(itvar):
for istate in StateSet:
ifile = thisdir+'state'+istate+itvar+iflag.replace('cfuns/','')+ip+'.xml'
if os.path.isfile(ifile): os.remove(ifile)
ifile = thisdir+'boots/state'+istate+itvar+iflag.replace('cfuns/','')+ip+'.boot.p'
if os.path.isfile(ifile): os.remove(ifile)
for ism in smlist:
ifile = thisdir+'sm'+ism+iflag.replace('cfuns/','')+ip+'.xml'
if os.path.isfile(ifile): os.remove(ifile)
ifile = thisdir+'boots/sm'+ism+iflag.replace('cfuns/','')+ip+'.boot.p'
if os.path.isfile(ifile): os.remove(ifile)
def WipeSet(outputdir,thisGammaList,setlist,thisMomList=RunMomList,filepref=''):
xmlMomList = map(qstrTOqcond,thisMomList)
for igamma in thisGammaList:
thisdir = outputdir+CreateOppDir(igamma)
for iset in setlist:
for ip in xmlMomList:
ifile = thisdir+MakeMomDir(ip)+filepref+iset+igamma+ip+'.xml'
if os.path.isfile(ifile): os.remove(ifile)
ifile = thisdir+MakeMomDir(ip)+'boots/'+filepref+iset+igamma+ip+'.boot.p'
if os.path.isfile(ifile): os.remove(ifile)
# def WipeSet(outputdir,thisGammaList,tlist=[],treveclist=[],statelist=[],revectodtlist=[],todtlist=[],smlist=[],filepref=''):
# for igamma in thisGammaList:
# thisdir = outputdir+CreateOppDir(igamma) + filepref
# if len(tlist) > 0 or len(treveclist) > 0:
# for it in treveclist:
# for istate in statelist:
# for itodt in revectodtlist:
# ifile = thisdir+'tsink'+it+'state'+istate+itodt+igamma+'.txt'
# ifb = thisdir+'boots/tsink'+it+'state'+istate+itodt+igamma+'.boot.txt'
# # print ifile
# # print ifb
# if os.path.isfile(ifile): os.remove(ifile)
# if os.path.isfile(ifb): os.remove(ifb)
# for it in tlist:
# for istate in statelist:
# for itodt in todtlist:
# ifile = thisdir+'tsink'+it+'state'+istate+itodt+igamma+'.txt'
# ifb = thisdir+'boots/tsink'+it+'state'+istate+itodt+igamma+'.boot.txt'
# # print ifile
# # print ifb
# if os.path.isfile(ifile): os.remove(ifile)
# if os.path.isfile(ifb): os.remove(ifb)
# for ism in smlist:
# ifile = thisdir+'tsink'+it+'sm'+ism+igamma+'.txt'
# ifb = thisdir+'boots/tsink'+it+'sm'+ism+igamma+'.boot.txt'
# # print ifile
# # print ifb
# if os.path.isfile(ifile): os.remove(ifile)
# if os.path.isfile(ifb): os.remove(ifb)
# else:
# for istate in statelist:
# for itodt in todtlist:
# ifile = thisdir+'state'+istate+itodt+igamma+'.txt'
# ifb = thisdir+'boots/state'+istate+itodt+igamma+'.boot.txt'
# # print ifile
# # print ifb
# if os.path.isfile(ifile): os.remove(ifile)
# if os.path.isfile(ifb): os.remove(ifb)
# for itodt in revectodtlist:
# ifile = thisdir+'state'+istate+itodt+igamma+'.txt'
# ifb = thisdir+'boots/state'+istate+itodt+igamma+'.boot.txt'
# # print ifile
# # print ifb
# if os.path.isfile(ifile): os.remove(ifile)
# if os.path.isfile(ifb): os.remove(ifb)
# for ism in smlist:
# ifile = thisdir+'sm'+ism+igamma+'.txt'
# ifb = thisdir+'boots/sm'+ism+igamma+'.boot.txt'
# # print ifile
# # print ifb
# if os.path.isfile(ifile): os.remove(ifile)
# if os.path.isfile(ifb): os.remove(ifb)
def WipeSF(outputdir,thisGammaList,RunName,OoT,statelist=[],todtlist=[],smlist=[],tsinklist=['']):
for igamma in thisGammaList:
if igamma == 'twopt':
thisdir = outputdir+'cfuns/'+CreateOppDir(igamma)+RunName+'/'
thisParList = StateParList[OoT]['C2']
thistsinklist = ['']
else:
thisdir = outputdir+CreateOppDir(igamma)+RunName+'/'
thisParList = StateParList[OoT]['C3']
thistsinklist = tsinklist
for ip in thisParList:
if igamma == 'twopt' and 'Two' in OoT:
ifile = thisdir+igamma+ip+'.txt'
ifb = thisdir+'boots/'+igamma+ip+'.boot.txt'
if os.path.isfile(ifile): os.remove(ifile)
if os.path.isfile(ifb): os.remove(ifb)
for its in thistsinklist:
for istate in statelist:
for itodt in todtlist:
ifile = thisdir+its+'state'+istate+itodt+igamma+ip+'.txt'
ifb = thisdir+'boots/'+its+'state'+istate+itodt+igamma+ip+'.boot.txt'
if os.path.isfile(ifile): os.remove(ifile)
if os.path.isfile(ifb): os.remove(ifb)
for ism in smlist:
ifile = thisdir+its+'sm'+ism+igamma+ip+'.txt'
ifb = thisdir+'boots/'+its+'sm'+ism+igamma+ip+'.boot.txt'
if os.path.isfile(ifile): os.remove(ifile)
if os.path.isfile(ifb): os.remove(ifb)
def WipeSFSet(outputdir,thisGammaList,RunName,OoT,setlist=[]):
for igamma in thisGammaList:
if igamma == 'twopt':
thisdir = outputdir+'cfuns/'+CreateOppDir(igamma)+RunName+'/'
thisParList = StateParList[OoT]['C2']
thissetlist = GetTsinkSmLists(setlist)[1]
else:
thisdir = outputdir+CreateOppDir(igamma)+RunName+'/'
thisParList = StateParList[OoT]['C3']
thissetlist = setlist
for ip in thisParList:
if igamma == 'twopt' and 'Two' in OoT:
ifile = thisdir+igamma+ip+'.txt'
ifb = thisdir+'boots/'+igamma+ip+'.boot.txt'
if os.path.isfile(ifile): os.remove(ifile)
if os.path.isfile(ifb): os.remove(ifb)
else:
for iset in thissetlist:
ifile = thisdir+iset+igamma+ip+'.txt'
ifb = thisdir+'boots/'+iset+igamma+ip+'.boot.txt'
if os.path.isfile(ifile): os.remove(ifile)
if os.path.isfile(ifb): os.remove(ifb)
def SplitOpp(All):
Split,OrdSplit,contents = [],[],[]
if any([igamma in All for igamma in GammaSet + ['gi']]):
contents.append('Gamma')
gammalen,thisgamma = 0,''
for igamma in GammaSet+['gi']:
if igamma in All:
if len(igamma) > gammalen:
thisgamma = igamma
gammalen = len(igamma)
Split.append(thisgamma)
if 'D' in All:
contents.append('Der')
for iDer in DerSet+['Di']:
if iDer in All: Split.append(iDer)
if any([iDS in All for iDS in DefDSList]) or any([icomb in All for icomb in CombList]):
contents.append('DS')
for iDS in DefDSList+CombList:
if iDS in All and 'Iso'+iDS not in All:
Split.append(iDS)
if 'P4' in All or 'P3' in All:
contents.append('Proj')
if 'P4' in All: Split.append('P4')
if 'P3' in All: Split.append('P3')
if 'cmplx' in All:
contents.append('Run')
Split.append('cmplx')
return Split,contents
def PrintOpps(AllList):
Extra,thisGS,thisDSS,thisProjS,RunRS = SetOpps(AllList)
print 'All Opperators: \n'+'\n'.join(thisGS)
print ''
print 'Projectors: '+', '.join(thisProjS)
# print 'DS: '+', '.join(thisDSS)
print 'Run: ' +RunRS
print 'Extras: ' + ', '.join(Extra)
print ''
#input arguments can be:
# specific operators (e.g. 'doubP4g4')
# no doub/sing operators give up-down results (e.g. 'P4g4')
# current types (e.g. 'Vector')
# 'giDi' for momenta fraction
# 'twopt' or 'mass' for mass analysis
# 'SmallSet' for small set defined below
def CreateGammaList(thislist,twopt=False):
if len(thislist) == 0:
print 'No Gamma Inputted, using whole set (see Params.py DefGammaList)'
GLout = DefCombGammaList
else:
GLout = []
for ig in thislist:
if 'NoTensor' in ig :
for icurr in CurrTypes:
if icurr in 'Tensor': continue
GLout += DoubSingList(CurrOpps[icurr])
GLout += DoubSingCmplxList(CurrOpps[icurr])
elif ig in CurrTypes:
GLout += DoubSingList(CurrOpps[ig])
GLout += DoubSingCmplxList(CurrOpps[ig])
elif 'SmallSet' in ig :
GLout += DoubSingList(['P4g4','P3g3g5','P4I','P3g1g2','P4giDi'])
elif 'OnlyDS' in ig :
GLout += DefGammaList
elif 'OnlyGamma' in ig :
GLout += DefNoDSGammaList
elif ig in DerCurrTypes:
GLout += DoubSingList(['P4'+ig])
elif ig in DefCombGammaList:
GLout += [ig]
elif ig in ['twopt','Mass']:
GLout += ['twopt']
else:
print 'Warning, opperator not found: ' , ig
if twopt: GLout += ['twopt']
GLout = DelDubs(GLout)
PrintOpps(GLout)
return GLout