-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseparateBkgBX.py
More file actions
37 lines (25 loc) · 1.07 KB
/
separateBkgBX.py
File metadata and controls
37 lines (25 loc) · 1.07 KB
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
#### separate out bkg track info according to the bx number
#### usage: python separateBkgBX.py <inTextFile> <BXNumberWanted>
import os, sys, glob
def main():
bkgFileName = sys.argv[1]
bxWanted = int(sys.argv[2])
inFile = open(bkgFileName)
outDir = "NewSamplesEBeamOnlyFilesMar62021/"
if not os.path.exists(outDir):
os.makedirs(outDir)
outFileName = "ePlusLaserBkgKaptonWindowNewSamplesMarch62021_DividedByBX"+str(bxWanted)+"_trackInfoClean.txt"
outFile = open(outDir+"/"+outFileName,"w")
outFile.write('### bxNumber << pdg << track_id << det_id << xx << yy << eneg << ev_weight << vtx_x << vtx_y << vtx_z\n')
for line in inFile.readlines():
line = line.rstrip()
if "#" in line: continue
eachWord = line.split()
bxNumber = int(eachWord[0])
if(bxNumber == bxWanted):
#print(bxNumber)
#print(bxWanted)
outFile.write(line+'\n')
outFile.close()
if __name__=="__main__":
main()