-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_NTuple.py
More file actions
executable file
·102 lines (81 loc) · 3.79 KB
/
run_NTuple.py
File metadata and controls
executable file
·102 lines (81 loc) · 3.79 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
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
# alphatwirl
from Core.EventReader import EventLoopRunner, MPEventLoopRunner, EventLoop
from Core.ProgressBar import ProgressBar,ProgressReport,ProgressMonitor,BProgressMonitor
from Core.Concurrently import CommunicationChannel,CommunicationChannel0
from Core.BEventBuilder import BEventBuilder
from Core.ComponentLoop import ComponentLoop
from Core.UFComponentReader import UFComponentReader
from Core.Utils.git import getGitDescribe,getGitDiff
from Core.Utils.printFunc import pyPrint
# Standard package
import imp,sys,os,time
cfgFileName = sys.argv[1]
file = open( cfgFileName,'r')
cfg = imp.load_source( 'UFNTuple.__cfg_to_run__', cfgFileName, file)
nCores = cfg.nCores
componentList = cfg.componentList
nEvents = cfg.nEvents
disableProgressBar = cfg.disableProgressBar
sequence = cfg.sequence
outputInfo = cfg.outputInfo
endSequence = cfg.endSequence
justEndSequence = cfg.justEndSequence if hasattr(cfg,"justEndSequence") else False
mergeSampleDict = cfg.mergeSampleDict if hasattr(cfg,"mergeSampleDict") else {}
mergeSigSampleDict = cfg.mergeSigSampleDict if hasattr(cfg,"mergeSigSampleDict") else {}
verbose = cfg.verbose if hasattr(cfg,"verbose") else False
skipGitDetail = cfg.skipGitDetail if hasattr(cfg,"skipGitDetail") else False
eventSelection = cfg.eventSelection if hasattr(cfg,"eventSelection") else None
checkInputFile = cfg.checkInputFile if hasattr(cfg,"checkInputFile") else False
if verbose:
pyPrint("Starting")
start_time = time.time()
if not justEndSequence:
if verbose:
pyPrint("Initiating progress bar")
progressBar = ProgressBar()
if nCores != 1:
progressMonitor = BProgressMonitor(progressBar)
communicationChannel = CommunicationChannel(nCores,progressMonitor)
else:
progressMonitor = ProgressMonitor(progressBar)
communicationChannel = CommunicationChannel0(progressMonitor)
pass
if not disableProgressBar: progressMonitor.begin()
communicationChannel.begin()
eventLoopRunner = MPEventLoopRunner(communicationChannel)
eventBuilder = BEventBuilder()
componentReader = UFComponentReader(eventBuilder, eventLoopRunner, sequence, outputInfo,selection=eventSelection)
componentLoop = ComponentLoop(componentReader)
if checkInputFile:
pyPrint("\nChecking samples...\n")
try:
for d in componentList:
cmps = d.makeComponents()
for cmp in cmps:
eventBuilder.build(cmp)
except ReferenceError:
pyPrint("Paths for input files are wrong, please check")
sys.exit()
pyPrint("\nLoading samples:\n")
for cmp in componentList:
pyPrint(cmp.name)
pyPrint("\nBegin Running\n")
componentLoop(componentList)
pyPrint("\nEnd Running\n")
pyPrint("\nOutput saved in "+outputInfo.outputDir+"\n")
if not skipGitDetail:
gitFile = os.path.join(outputInfo.outputDir,"gitDetails.txt")
gitVerboseFile = os.path.join(outputInfo.outputDir,"gitVerboseDetails.txt")
with open(gitFile,'w') as f:
f.write(getGitDescribe())
with open(gitVerboseFile,'w') as f:
f.write(getGitDiff())
if verbose:
pyPrint("Ending progress bar")
if not disableProgressBar: progressMonitor.end()
communicationChannel.end()
pyPrint("\nBegin Summarising\n")
pyPrint("\nInput used: "+outputInfo.outputDir+"\n")
endSequence.run(outputInfo,componentList,mergeSampleDict=mergeSampleDict,mergeSigSampleDict=mergeSigSampleDict)
elapsed_time = time.time() - start_time
pyPrint("Time used: "+str(elapsed_time)+"s")