-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauto.py
More file actions
68 lines (58 loc) · 3.07 KB
/
auto.py
File metadata and controls
68 lines (58 loc) · 3.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
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
#!/usr/bin/env python
import sys
import os
import glob
from threading import Timer
def exit():
print("Exiting due to timeout...")
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD scailfin/madgraph5-amc-nlo:mg5_amc3.3.1 'rm -r eeToJJJ/Events/*'")
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD scailfin/madgraph5-amc-nlo:mg5_amc3.3.1 'rm eeToJJJ/RunWeb'")
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD ghcr.io/scipp-atlas/mario-mapyde/delphes 'rm Delphes-3.5.0/Frag_Study/*'")
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD scailfin/madgraph5-amc-nlo:mg5_amc3.3.1 'exit'")
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD ghcr.io/scipp-atlas/mario-mapyde/delphes 'exit'")
os._exit(os.EX_OK)
try:
input = raw_input
except:
pass
if len(sys.argv) < 2:
print(" Usage: auto.py results_name")
sys.exit(1)
# Starts a timer to end the script after ten minutes
timer = Timer(150, exit)
timer.start()
results_name = sys.argv[1]
print("Beginning...")
# Generates events after parameter change
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD scailfin/madgraph5-amc-nlo:mg5_amc3.3.1 "
"'./eeToJJJ/bin/generate_events -f'")
# Copies and unzips new .hepmc
if len(glob.glob("eeToJJJ/Events/run_01/*hepmc.gz")) == 0:
os.system("cp eeToJJJ/Events/run_01/*.hepmc Delphes-3.5.0/Frag_Study/pythia8_events_" + results_name + ".hepmc")
elif os.path.exists(glob.glob("eeToJJJ/Events/run_01/*hepmc.gz")[0]):
os.system("cp eeToJJJ/Events/run_01/*.hepmc.gz Delphes-3.5.0/Frag_Study/pythia8_events_"+results_name+".hepmc.gz")
os.system("gunzip Delphes-3.5.0/Frag_Study/pythia8_events_"+results_name+".hepmc.gz")
else:
sys.exit("No hepmc file")
timer.cancel()
# Runs .hepmc through Delphes creating a .root
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD ghcr.io/scipp-atlas/mario-mapyde/delphes "
"'./Delphes-3.5.0/DelphesHepMC2 Delphes-3.5.0/cards/delphes_card_CMS.tcl "
"Delphes-3.5.0/Frag_Study/eeToJJJ_"+results_name+".root "
"Delphes-3.5.0/Frag_Study/pythia8_events_"+results_name+".hepmc'")
# Creates plots from the new .root
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD ghcr.io/scipp-atlas/mario-mapyde/delphes 'cd Delphes-3.5.0 && "
"python ../FragmentationStudy/loop.py Frag_Study/eeToJJJ_"+results_name+".root "
"eeToJJJ_"+results_name+"'")
# Removes old run files
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD scailfin/madgraph5-amc-nlo:mg5_amc3.3.1 'rm -r "
"eeToJJJ/Events/run_*'")
# Removes .hepmc files but preserves .root files
os.system("docker run --rm -t -v $PWD:$PWD -w $PWD ghcr.io/scipp-atlas/mario-mapyde/delphes 'rm "
"Delphes-3.5.0/Frag_Study/pythia8_events_"+results_name+".hepmc'")
# Removes .hepmc and .root files
# os.system("docker run --rm -t -v $PWD:$PWD -w $PWD ghcr.io/scipp-atlas/mario-mapyde/delphes 'rm "
# "Delphes-3.5.0/Frag_Study/*'")
# Displays profx.png
# os.system("pwd")
# os.system("display ../FragmentationStudy/plots/eeToJJJ_"+results_name+"_PartVsPprofx.png")