-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetBXForEBeamOnly.py
More file actions
47 lines (36 loc) · 1.32 KB
/
getBXForEBeamOnly.py
File metadata and controls
47 lines (36 loc) · 1.32 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
38
39
40
41
42
43
44
45
46
47
### code to divide the background in separate BXs
### run: python getBXForEBeamOnly.py <list of background file names>
import os
import sys
import time
import pprint
import math
from ROOT import *
from collections import OrderedDict
import argparse
def main():
inFile = open(sys.argv[1])
totalNumber = 0
for lines in inFile.readlines():
lines = lines.rstrip()
if('#' in lines): continue
print("I am working on: ",lines)
rootFile = TFile(lines, "READ")
try:
dirAddress = gDirectory.Get("hist")
h0Value = dirAddress.Get("h0")
eventNumber = h0Value.GetEntries()
totalNumber += eventNumber
#print("totalNumber of electrons: ",totalNumber)
#i = int(totalNumber) // 1500000000
#print("The division = ", i)
#outFile1 = open("ePlusLaser_list_root_7671ee4c_DividedByBX"+str(i+1)+".txt", "a")
#outFile1.write(lines+"\n")
except:
print("something wrong here: ", lines)
print("Total number of events: ",totalNumber)
outFile1.close()
if __name__=="__main__":
start = time.time()
main()
print("--- The time taken: ", time.time() - start, " s")