Merge lp:~ma5dev/madanalysis5/pyhf_update into lp:madanalysis5

Proposed by Benjamin Fuks
Status: Merged
Merge reported by: Benjamin Fuks
Merged at revision: not available
Proposed branch: lp:~ma5dev/madanalysis5/pyhf_update
Merge into: lp:madanalysis5
Diff against target: 9783 lines (+2819/-1364) (has conflicts)
210 files modified
.bzrignore (+24/-0)
bin/ma5 (+9/-5)
madanalysis/IOinterface/delphescard_checker.py (+4/-2)
madanalysis/IOinterface/folder_writer.py (+4/-2)
madanalysis/IOinterface/histo_matplotlib_producer.py (+4/-4)
madanalysis/IOinterface/histo_root_producer.py (+3/-3)
madanalysis/IOinterface/html_report_writer.py (+5/-1)
madanalysis/IOinterface/html_style_writer.py (+1/-0)
madanalysis/IOinterface/job_reader.py (+1/-1)
madanalysis/IOinterface/job_writer.py (+30/-23)
madanalysis/IOinterface/latex_report_writer.py (+4/-1)
madanalysis/IOinterface/layout_writer.py (+1/-1)
madanalysis/IOinterface/library_writer.py (+4/-3)
madanalysis/IOinterface/madgraph_interface.py (+12/-7)
madanalysis/IOinterface/multiparticle_reader.py (+1/-0)
madanalysis/IOinterface/particle_reader.py (+1/-0)
madanalysis/IOinterface/png_reader.py (+27/-16)
madanalysis/IOinterface/text_file_reader.py (+1/-0)
madanalysis/IOinterface/text_file_writer.py (+1/-0)
madanalysis/IOinterface/text_report.py (+3/-1)
madanalysis/IOinterface/ufo_reader.py (+2/-0)
madanalysis/UpdateNotes.txt (+52/-0)
madanalysis/build/makefile_writer.py (+2/-0)
madanalysis/build/setup_writer.py (+2/-0)
madanalysis/configuration/beauty_identification.py (+2/-1)
madanalysis/configuration/clustering_antikt.py (+3/-2)
madanalysis/configuration/clustering_cambridge.py (+3/-2)
madanalysis/configuration/clustering_cdfjetclu.py (+2/-1)
madanalysis/configuration/clustering_cdfmidpoint.py (+2/-1)
madanalysis/configuration/clustering_configuration.py (+9/-3)
madanalysis/configuration/clustering_genkt.py (+3/-2)
madanalysis/configuration/clustering_gridjet.py (+2/-1)
madanalysis/configuration/clustering_kt.py (+3/-2)
madanalysis/configuration/clustering_siscone.py (+3/-2)
madanalysis/configuration/delphesMA5tune_configuration.py (+2/-1)
madanalysis/configuration/delphes_configuration.py (+2/-1)
madanalysis/configuration/fastsim_configuration.py (+4/-3)
madanalysis/configuration/fom_configuration.py (+3/-2)
madanalysis/configuration/isolation_cone.py (+2/-1)
madanalysis/configuration/isolation_configuration.py (+2/-1)
madanalysis/configuration/isolation_sumpt.py (+2/-1)
madanalysis/configuration/merging_configuration.py (+2/-1)
madanalysis/configuration/recast_configuration.py (+27/-9)
madanalysis/configuration/tau_identification.py (+2/-1)
madanalysis/core/expert_mode.py (+4/-3)
madanalysis/core/launcher.py (+8/-6)
madanalysis/core/library_builder.py (+1/-1)
madanalysis/core/main.py (+8/-2)
madanalysis/core/script_stack.py (+2/-2)
madanalysis/dataset/dataset.py (+2/-1)
madanalysis/dataset/dataset_collection.py (+6/-3)
madanalysis/dataset/sample_info.py (+1/-1)
madanalysis/enumeration/argument_type.py (+8/-6)
madanalysis/enumeration/backstyle_type.py (+20/-17)
madanalysis/enumeration/color_type.py (+29/-25)
madanalysis/enumeration/combination_type.py (+18/-14)
madanalysis/enumeration/connector_type.py (+18/-15)
madanalysis/enumeration/cut_type.py (+12/-9)
madanalysis/enumeration/detect_status_type.py (+7/-5)
madanalysis/enumeration/font_type.py (+18/-15)
madanalysis/enumeration/graphic_render_type.py (+11/-8)
madanalysis/enumeration/linestyle_type.py (+17/-13)
madanalysis/enumeration/ma5_running_type.py (+8/-5)
madanalysis/enumeration/normalize_type.py (+8/-5)
madanalysis/enumeration/observable_type.py (+64/-53)
madanalysis/enumeration/operator_type.py (+20/-17)
madanalysis/enumeration/report_format_type.py (+21/-17)
madanalysis/enumeration/sb_ratio_type.py (+12/-9)
madanalysis/enumeration/script_type.py (+24/-21)
madanalysis/enumeration/special_particle.py (+8/-5)
madanalysis/enumeration/stacking_method_type.py (+8/-5)
madanalysis/enumeration/uncertainty_type.py (+8/-5)
madanalysis/fastsim/ast.py (+6/-3)
madanalysis/fastsim/ast_leaf.py (+1/-0)
madanalysis/fastsim/fastsim.py (+79/-11)
madanalysis/fastsim/recoefficiency.py (+5/-4)
madanalysis/fastsim/scaling.py (+104/-0)
madanalysis/fastsim/smearer.py (+9/-8)
madanalysis/fastsim/tagger.py (+4/-3)
madanalysis/install/detector_manager.py (+1/-0)
madanalysis/install/install_delphes.py (+49/-8)
madanalysis/install/install_fastjet.py (+1/-0)
madanalysis/install/install_fastjetcontrib.py (+1/-0)
madanalysis/install/install_gnuplot.py (+1/-0)
madanalysis/install/install_manager.py (+1/-0)
madanalysis/install/install_matplotlib.py (+1/-0)
madanalysis/install/install_numpy.py (+1/-0)
madanalysis/install/install_pad.py (+83/-110)
madanalysis/install/install_pyhf.py (+30/-30)
madanalysis/install/install_root.py (+1/-0)
madanalysis/install/install_samples.py (+2/-1)
madanalysis/install/install_service.py (+22/-23)
madanalysis/install/install_zlib.py (+1/-0)
madanalysis/interpreter/cmd_base.py (+2/-0)
madanalysis/interpreter/cmd_cut.py (+3/-1)
madanalysis/interpreter/cmd_define.py (+20/-3)
madanalysis/interpreter/cmd_define_region.py (+1/-0)
madanalysis/interpreter/cmd_display.py (+4/-3)
madanalysis/interpreter/cmd_display_datasets.py (+1/-0)
madanalysis/interpreter/cmd_display_multiparticles.py (+1/-0)
madanalysis/interpreter/cmd_display_particles.py (+1/-0)
madanalysis/interpreter/cmd_display_regions.py (+1/-0)
madanalysis/interpreter/cmd_import.py (+6/-2)
madanalysis/interpreter/cmd_install.py (+50/-14)
madanalysis/interpreter/cmd_open.py (+1/-0)
madanalysis/interpreter/cmd_plot.py (+3/-1)
madanalysis/interpreter/cmd_remove.py (+3/-1)
madanalysis/interpreter/cmd_reset.py (+3/-1)
madanalysis/interpreter/cmd_selection_base.py (+4/-0)
madanalysis/interpreter/cmd_set.py (+25/-0)
madanalysis/interpreter/cmd_submit.py (+5/-8)
madanalysis/interpreter/cmd_swap.py (+2/-0)
madanalysis/interpreter/history.py (+1/-0)
madanalysis/interpreter/interpreter.py (+9/-6)
madanalysis/interpreter/interpreter_base.py (+3/-1)
madanalysis/interpreter/ma5_interpreter.py (+16/-5)
madanalysis/interpreter/timer.py (+1/-0)
madanalysis/job/job_candidate_cut.py (+2/-0)
madanalysis/job/job_event_cut.py (+3/-1)
madanalysis/job/job_execute.py (+2/-0)
madanalysis/job/job_finalize.py (+1/-0)
madanalysis/job/job_header.py (+5/-7)
madanalysis/job/job_initialize.py (+1/-0)
madanalysis/job/job_main.py (+1/-0)
madanalysis/job/job_particle.py (+2/-0)
madanalysis/job/job_plot.py (+2/-0)
madanalysis/job/job_smearer_reco_header.py (+69/-13)
madanalysis/job/job_smearer_reco_main.py (+99/-5)
madanalysis/job/job_tagger_header.py (+11/-0)
madanalysis/layout/cut_info.py (+1/-0)
madanalysis/layout/cutflow.py (+2/-0)
madanalysis/layout/cutflow_for_dataset.py (+2/-0)
madanalysis/layout/fom_calculation.py (+1/-0)
madanalysis/layout/histogram.py (+2/-0)
madanalysis/layout/histogram_core.py (+2/-0)
madanalysis/layout/histogram_frequency.py (+2/-0)
madanalysis/layout/histogram_frequency_core.py (+1/-0)
madanalysis/layout/histogram_logx.py (+2/-0)
madanalysis/layout/layout.py (+2/-0)
madanalysis/layout/measure.py (+1/-0)
madanalysis/layout/merging_plots.py (+24/-10)
madanalysis/layout/merging_plots_for_dataset.py (+1/-0)
madanalysis/layout/plotflow.py (+26/-11)
madanalysis/layout/plotflow_for_dataset.py (+2/-0)
madanalysis/misc/freeze_environment.py (+1/-0)
madanalysis/misc/histfactory_reader.py (+53/-48)
madanalysis/misc/run_recast.py (+440/-319)
madanalysis/misc/simplified_likelihood.py (+3/-0)
madanalysis/multiparticle/extraparticle.py (+2/-1)
madanalysis/multiparticle/multiparticle.py (+2/-0)
madanalysis/multiparticle/multiparticle_collection.py (+10/-6)
madanalysis/multiparticle/particle_combination.py (+2/-0)
madanalysis/multiparticle/particle_object.py (+2/-0)
madanalysis/observable/observable_base.py (+1/-0)
madanalysis/observable/observable_list.py (+120/-0)
madanalysis/observable/observable_manager.py (+4/-3)
madanalysis/region/region.py (+1/-0)
madanalysis/region/region_collection.py (+4/-1)
madanalysis/selection/condition_connector.py (+1/-0)
madanalysis/selection/condition_sequence.py (+2/-0)
madanalysis/selection/condition_type.py (+2/-0)
madanalysis/selection/cut.py (+4/-3)
madanalysis/selection/histogram.py (+8/-5)
madanalysis/selection/instance_name.py (+3/-3)
madanalysis/selection/selection.py (+5/-2)
madanalysis/system/architecture_info.py (+7/-4)
madanalysis/system/checkup.py (+1/-0)
madanalysis/system/config_checker.py (+3/-3)
madanalysis/system/detect_dvipdf.py (+1/-1)
madanalysis/system/detect_fastjet.py (+1/-1)
madanalysis/system/detect_gnuplot.py (+1/-1)
madanalysis/system/detect_gpp.py (+1/-1)
madanalysis/system/detect_latex.py (+1/-1)
madanalysis/system/detect_make.py (+1/-1)
madanalysis/system/detect_manager.py (+1/-0)
madanalysis/system/detect_matplotlib.py (+1/-1)
madanalysis/system/detect_pad.py (+6/-10)
madanalysis/system/detect_pdflatex.py (+1/-1)
madanalysis/system/detect_pyhf.py (+7/-11)
madanalysis/system/detect_python.py (+8/-8)
madanalysis/system/detect_root.py (+3/-2)
madanalysis/system/detect_root_graphical.py (+1/-1)
madanalysis/system/detect_scipy.py (+1/-1)
madanalysis/system/detect_zlib.py (+1/-1)
madanalysis/system/session_info.py (+1/-0)
madanalysis/system/user_info.py (+1/-0)
tools/ReportGenerator/Core/job_reader.py (+1/-1)
tools/ReportGenerator/Core/layout.py (+2/-0)
tools/ReportGenerator/Core/main.py (+5/-2)
tools/ReportGenerator/Services/chronometer.py (+1/-0)
tools/ReportGenerator/Services/colored_log.py (+1/-0)
tools/ReportGenerator/Services/fom_type.py (+1/-0)
tools/ReportGenerator/Services/shell_command.py (+14/-4)
tools/ReportGenerator/Services/string_tools.py (+2/-0)
tools/SampleAnalyzer/Commons/Base/Configuration.cpp (+2/-2)
tools/SampleAnalyzer/Commons/Base/SmearerBase.cpp (+207/-0)
tools/SampleAnalyzer/Commons/Base/SmearerBase.h (+169/-93)
tools/SampleAnalyzer/Commons/DataFormat/MCParticleFormat.h (+25/-7)
tools/SampleAnalyzer/Commons/DataFormat/ParticleBaseFormat.h (+28/-2)
tools/SampleAnalyzer/Commons/DataFormat/RecEventFormat.h (+3/-0)
tools/SampleAnalyzer/Commons/DataFormat/RecLeptonFormat.h (+23/-30)
tools/SampleAnalyzer/Commons/DataFormat/RecParticleFormat.h (+10/-1)
tools/SampleAnalyzer/Commons/Vector/MARotation3axis.h (+2/-0)
tools/SampleAnalyzer/Interfaces/delphes/DelphesTreeReader.cpp (+0/-5)
tools/SampleAnalyzer/Process/JetClustering/JetClusterer.cpp (+74/-5)
tools/SampleAnalyzer/Process/JetClustering/JetClusterer.h (+1/-0)
tools/SampleAnalyzer/Process/JetClustering/NullSmearer.h (+2/-61)
tools/SampleAnalyzer/Process/Reader/HEPMCReader.cpp (+3/-4)
tools/SampleAnalyzer/Process/Reader/LHEReader.cpp (+20/-3)
tools/SampleAnalyzer/newAnalyzer.py (+17/-14)
Text conflict in bin/ma5
Text conflict in madanalysis/misc/run_recast.py
To merge this branch: bzr merge lp:~ma5dev/madanalysis5/pyhf_update
Reviewer Review Type Date Requested Status
MadAnalysisTeam Pending
Review via email: mp+404953@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2021-06-30 09:39:51 +0000
4@@ -0,0 +1,24 @@
5+*.pyc
6+*.log
7+.ma5history
8+tools/PADForSFS
9+.DS_Store
10+*.sh
11+*.csh
12+Makefile_*
13+*.tgz
14+tools/pyhf
15+tools/zlib
16+tools/architecture.ma5
17+pyhf_test
18+history.ma5
19+tools/SampleAnalyzer/ExternalSymLink
20+tools/SampleAnalyzer/Bin/PortabilityCheckup
21+tools/SampleAnalyzer/Bin/TestCommons
22+tools/SampleAnalyzer/Bin/TestFastjet
23+tools/SampleAnalyzer/Bin/TestSampleAnalyzer
24+tools/SampleAnalyzer/Bin/TestZlib
25+tools/SampleAnalyzer/Commons/Makefile
26+tools/SampleAnalyzer/Commons/Base/PortabilityTags.h
27+tools/SampleAnalyzer/Configuration/Makefile
28+tools/SampleAnalyzer/Process/Makefile
29
30=== modified file 'bin/ma5'
31--- bin/ma5 2020-11-02 21:02:08 +0000
32+++ bin/ma5 2021-06-30 09:39:51 +0000
33@@ -1,4 +1,4 @@
34-#!/usr/bin/env python
35+#!/usr/bin/env python3
36
37 ################################################################################
38 #
39@@ -33,15 +33,14 @@
40
41 # Checking if the correct release of Python is installed
42 import sys
43-if not sys.version_info[0] == 2 or sys.version_info[1] < 6:
44+if sys.version_info[1] < 7:
45 sys.exit('Python release '+ sys.version + ' is detected.\n' + \
46- 'MadAnalysis 5 works only with python 2.6 ' + \
47- 'or later (but not python 3.X).\n' + \
48+ 'MadAnalysis 5 works only with python 2.7 ' + \
49+ 'or python 3.7 and later.\n' + \
50 'Please upgrade your version of python.')
51
52 # Getting the parent directory (ma5 root dir) of the script real path (bin)
53 import os
54-import commands
55 import optparse
56 ma5dir = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0]
57 if not os.path.isdir(ma5dir):
58@@ -62,8 +61,13 @@
59
60 # Release version
61 # Do not touch it !!!!!
62+<<<<<<< TREE
63 version = "1.8.59"
64 date = "2020/11/02"
65+=======
66+version = "1.9.24"
67+date = "2021/06/15"
68+>>>>>>> MERGE-SOURCE
69
70 # Loading the MadAnalysis session
71 import madanalysis.core.launcher
72
73=== modified file 'madanalysis/IOinterface/delphescard_checker.py'
74--- madanalysis/IOinterface/delphescard_checker.py 2020-07-03 08:05:49 +0000
75+++ madanalysis/IOinterface/delphescard_checker.py 2021-06-30 09:39:51 +0000
76@@ -22,8 +22,10 @@
77 ################################################################################
78
79
80+from __future__ import absolute_import
81 import logging
82 import os
83+from six.moves import input
84
85 class DelphesModule():
86
87@@ -69,7 +71,7 @@
88 allowed_answers=['n','no','y','yes']
89 answer=""
90 while answer not in allowed_answers:
91- answer=raw_input("Answer: ")
92+ answer=input("Answer: ")
93 answer=answer.lower()
94 if answer=="no" or answer=="n":
95 return True
96@@ -91,7 +93,7 @@
97 allowed_answers=['n','no','y','yes']
98 answer=""
99 while answer not in allowed_answers:
100- answer=raw_input("Answer: ")
101+ answer=input("Answer: ")
102 answer=answer.lower()
103 if answer=="no" or answer=="n":
104 return False # no, give up
105
106=== modified file 'madanalysis/IOinterface/folder_writer.py'
107--- madanalysis/IOinterface/folder_writer.py 2020-07-03 08:05:49 +0000
108+++ madanalysis/IOinterface/folder_writer.py 2021-06-30 09:39:51 +0000
109@@ -22,9 +22,11 @@
110 ################################################################################
111
112
113+from __future__ import absolute_import
114 import os
115 import shutil
116 import logging
117+from six.moves import input
118
119 class FolderWriter:
120
121@@ -43,7 +45,7 @@
122 allowed_answers=['n','no','y','yes']
123 answer=""
124 while answer not in allowed_answers:
125- answer=raw_input("Answer: ")
126+ answer=input("Answer: ")
127 answer=answer.lower()
128 if answer=="no" or answer=="n":
129 return False, True
130@@ -78,7 +80,7 @@
131 allowed_answers=['n','no','y','yes']
132 answer=""
133 while answer not in allowed_answers:
134- answer=raw_input("Answer: ")
135+ answer=input("Answer: ")
136 answer=answer.lower()
137 if answer=="no" or answer=="n":
138 return False
139
140=== modified file 'madanalysis/IOinterface/histo_matplotlib_producer.py'
141--- madanalysis/IOinterface/histo_matplotlib_producer.py 2020-07-03 08:05:49 +0000
142+++ madanalysis/IOinterface/histo_matplotlib_producer.py 2021-06-30 09:39:51 +0000
143@@ -22,13 +22,13 @@
144 ################################################################################
145
146
147+from __future__ import absolute_import
148 from string_tools import StringTools
149 from shell_command import ShellCommand
150 import logging
151 import shutil
152 import os
153 import sys
154-import commands
155
156 class HistoMatplotlibProducer():
157
158@@ -54,12 +54,12 @@
159 output.write('import '+item.split('/')[-1][:-3]+'\n')
160 output.write('\n')
161 output.write('# Producing each histograms\n')
162- output.write('print "BEGIN-STAMP"\n')
163+ output.write('print("BEGIN-STAMP")\n')
164 for item in self.filenames:
165 myname=item.split('/')[-1][:-3]
166- output.write('print "- Producing histo '+myname+'..."\n')
167+ output.write('print("- Producing histo '+myname+'...")\n')
168 output.write(myname+'.'+myname+'()\n')
169- output.write('print "END-STAMP"\n')
170+ output.write('print("END-STAMP")\n')
171 output.close()
172 return True
173
174
175=== modified file 'madanalysis/IOinterface/histo_root_producer.py'
176--- madanalysis/IOinterface/histo_root_producer.py 2020-07-03 08:05:49 +0000
177+++ madanalysis/IOinterface/histo_root_producer.py 2021-06-30 09:39:51 +0000
178@@ -22,12 +22,12 @@
179 ################################################################################
180
181
182+from __future__ import absolute_import
183 from string_tools import StringTools
184 from shell_command import ShellCommand
185 import logging
186 import shutil
187 import os
188-import commands
189
190 class HistoRootProducer():
191
192@@ -73,7 +73,7 @@
193 import stat
194
195 # Commands
196- output = file(self.histo_path+'/Makefile','w')
197+ output = open(self.histo_path+'/Makefile','w')
198 output.write('CXX = `$(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/root-config --cxx`\n')
199 output.write('CFLAGS = `$(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/root-config --cflags`\n')
200 output.write('LIBS = `$(MA5_BASE)/tools/SampleAnalyzer/ExternalSymLink/Bin/root-config --libs`\n')
201@@ -129,7 +129,7 @@
202 return ok
203
204 # Reading log file
205- input = file(self.histo_path+'/launch_root.log')
206+ input = open(self.histo_path+'/launch_root.log')
207 ok1 = False
208 ok2 = False
209 for line in input:
210
211=== modified file 'madanalysis/IOinterface/html_report_writer.py'
212--- madanalysis/IOinterface/html_report_writer.py 2020-07-03 08:05:49 +0000
213+++ madanalysis/IOinterface/html_report_writer.py 2021-06-30 09:39:51 +0000
214@@ -22,6 +22,7 @@
215 ################################################################################
216
217
218+from __future__ import absolute_import
219 import madanalysis.IOinterface.text_file_writer as TextFileWriter
220 from madanalysis.IOinterface.html_style_writer import HTMLCSSWriter
221 from madanalysis.enumeration.color_type import ColorType
222@@ -34,6 +35,7 @@
223 import logging
224 import time
225 import pwd
226+from six.moves import range
227
228 class HTMLReportWriter(TextFileWriter.TextFileWriter):
229 """Generate HTML report"""
230@@ -184,7 +186,9 @@
231 self.page.append(" </caption>\n")
232 self.page.append(' <tr>\n')
233
234- def NewCell(self,color=ColorType.WHITE,span=1):
235+ def NewCell(self,color=None,span=1):
236+ if color is None:
237+ color=ColorType.WHITE
238 size=0
239 for ii in range(0,span):
240 size += self.col_size[self.current_col+ii]
241
242=== modified file 'madanalysis/IOinterface/html_style_writer.py'
243--- madanalysis/IOinterface/html_style_writer.py 2020-07-03 08:05:49 +0000
244+++ madanalysis/IOinterface/html_style_writer.py 2021-06-30 09:39:51 +0000
245@@ -22,6 +22,7 @@
246 ################################################################################
247
248
249+from __future__ import absolute_import
250 import madanalysis.IOinterface.text_file_writer as TextFileWriter
251 class HTMLCSSWriter(TextFileWriter.TextFileWriter):
252 """Generate HTML CSS page sheet"""
253
254=== modified file 'madanalysis/IOinterface/job_reader.py'
255--- madanalysis/IOinterface/job_reader.py 2020-07-03 08:05:49 +0000
256+++ madanalysis/IOinterface/job_reader.py 2021-06-30 09:39:51 +0000
257@@ -22,6 +22,7 @@
258 ################################################################################
259
260
261+from __future__ import absolute_import
262 from madanalysis.selection.instance_name import InstanceName
263 from madanalysis.dataset.sample_info import SampleInfo
264 from madanalysis.layout.cut_info import CutInfo
265@@ -33,7 +34,6 @@
266 import logging
267 import shutil
268 import os
269-import commands
270 import copy
271
272
273
274=== modified file 'madanalysis/IOinterface/job_writer.py'
275--- madanalysis/IOinterface/job_writer.py 2020-07-03 08:05:49 +0000
276+++ madanalysis/IOinterface/job_writer.py 2021-06-30 09:39:51 +0000
277@@ -22,17 +22,16 @@
278 ################################################################################
279
280
281+from __future__ import absolute_import
282 from madanalysis.selection.instance_name import InstanceName
283 from madanalysis.IOinterface.folder_writer import FolderWriter
284-from madanalysis.enumeration.ma5_running_type import MA5RunningType
285-from string_tools import StringTools
286 from shell_command import ShellCommand
287 import logging
288 import shutil
289 import os
290-import commands
291+import six
292
293-class JobWriter():
294+class JobWriter(object):
295
296 def __init__(self,main,jobdir,resubmit=False):
297 self.main = main
298@@ -43,7 +42,7 @@
299 self.merging = self.main.merging
300
301 @staticmethod
302- def CheckJobStructureMute(self,path,recastflag):
303+ def CheckJobStructureMute(session_info,path,recastflag):
304 if not os.path.isdir(path):
305 return False
306 if not recastflag:
307@@ -67,10 +66,10 @@
308 return False
309 if not os.path.isdir(path+"/Output/HTML"):
310 return False
311- if self.main.session_info.has_pdflatex:
312+ if session_info.has_pdflatex:
313 if not os.path.isdir(path+"/Output/PDF"):
314 return False
315- if self.main.session_info.has_latex:
316+ if session_info.has_latex:
317 if not os.path.isdir(path+"/Output/DVI"):
318 return False
319 elif not os.path.isdir(path+"/Input"):
320@@ -305,6 +304,7 @@
321 input = open(self.main.archi_info.ma5dir+"/tools/SampleAnalyzer/Interfaces/delphesMA5tune/"+cardname,'r')
322 except:
323 logging.getLogger('MA5').error("impossible to find "+self.main.archi_info.ma5dir+"/tools/SampleAnalyzer/Interfaces/delphes/"+cardname)
324+ return False
325 if "../../../.." in cardname:
326 cardname=cardname.split('/')[-1]
327
328@@ -339,6 +339,8 @@
329 except:
330 pass
331
332+ return True
333+
334
335 def CopyLHEAnalysis(self):
336 recast = (self.main.recasting.status=="on")
337@@ -355,13 +357,14 @@
338 logging.getLogger('MA5').error('Impossible to copy the file "newAnalyzer"')
339 return False
340 try:
341- os.chmod(self.path+"/Build/SampleAnalyzer/newAnalyzer.py",0755)
342+ os.chmod(self.path+"/Build/SampleAnalyzer/newAnalyzer.py",0o755)
343 except:
344 logging.getLogger('MA5').error('Impossible to make executable the file "newAnalyzer"')
345 return False
346
347 if self.main.fastsim.package in ["delphes","delphesMA5tune"]:
348- self.CreateDelphesCard()
349+ if not self.CreateDelphesCard():
350+ return False
351
352 if self.main.recasting.status=="on":
353 if not self.main.recasting.CreateCard(self.path):
354@@ -374,7 +377,7 @@
355 file.write('// \n')
356 file.write('// This file has been generated by MadAnalysis 5.\n')
357 file.write('// The MadAnalysis development team: <ma5team@iphc.cnrs.fr>\n')
358- file.write('// Eric Conte and Benjamin Fuks\n')
359+ file.write('// Jack Araz, Eric Conte and Benjamin Fuks\n')
360 file.write('// Official website: <https://launchpad.net/madanalysis5>\n')
361 file.write('// \n')
362 file.write('////////////////////////////////////////////////////////////////////////////////\n\n')
363@@ -460,17 +463,17 @@
364 file.write(' //Getting pointer to the clusterer\n')
365 file.write(' std::map<std::string, std::string> parametersC1;\n')
366 parameters = self.main.fastsim.SampleAnalyzerConfigString()
367- for k,v in sorted(parameters.iteritems(),\
368- key=lambda (k,v): (k,v)):
369+ for k,v in sorted(six.iteritems(parameters),\
370+ key=lambda k_v: (k_v[0],k_v[1])):
371 file.write(' parametersC1["'+k+'"]="'+v+'";\n')
372 file.write(' JetClusterer* cluster1 = \n')
373 file.write(' manager.InitializeJetClusterer("'+self.main.fastsim.clustering.algorithm+'",parametersC1);\n')
374 file.write(' if (cluster1==0) return 1;\n\n')
375- if self.main.superfastsim.smearer.rules!={} or self.main.superfastsim.reco.rules!={}:
376+ if self.main.superfastsim.isNewSmearerOn():
377 file.write(' // Declaration of the smearer\n')
378 file.write(' SmearerBase* mySmearer = new NewSmearer();\n')
379 file.write(' cluster1->LoadSmearer(mySmearer);\n\n')
380- if self.main.superfastsim.tagger.rules!={}:
381+ if self.main.superfastsim.isTaggerOn():
382 file.write(' // Declaration of a generic tagger\n')
383 file.write(' NewTagger* tagger = new NewTagger();\n\n')
384
385@@ -483,8 +486,8 @@
386 else:
387 cfg=self.main.fastsim.delphes
388 parameters = self.main.fastsim.SampleAnalyzerConfigString()
389- for k,v in sorted(parameters.iteritems(),\
390- key=lambda (k,v): (k,v)):
391+ for k,v in sorted(six.iteritems(parameters),\
392+ key=lambda k_v1: (k_v1[0],k_v1[1])):
393 file.write(' parametersD1["'+k+'"]="'+v+'";\n')
394 file.write(' DetectorBase* fastsim1 = \n')
395
396@@ -541,7 +544,7 @@
397 file.write(' if (!analyzer2->Execute(mySample,myEvent)) continue;\n')
398 if self.main.fastsim.package=="fastjet":
399 file.write(' cluster1->Execute(mySample,myEvent);\n')
400- if self.main.superfastsim.tagger.rules!={}:
401+ if self.main.superfastsim.isTaggerOn():
402 file.write(' tagger->Execute(mySample,myEvent);\n')
403 elif self.main.fastsim.package=="delphes":
404 file.write(' fastsim1->Execute(mySample,myEvent);\n')
405@@ -582,23 +585,27 @@
406 file.close()
407
408 ## Do we need a smearer?
409- if main.superfastsim.smearer.rules!={} or main.superfastsim.reco.rules!={}:
410+ if main.superfastsim.isNewSmearerOn():
411 file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/new_smearer_reco.h","w")
412 import madanalysis.job.job_smearer_reco_header as JobSmearerRecoHeader
413 job = JobSmearerRecoHeader.JobSmearerRecoHeader(main.superfastsim)
414 job.WriteNewSmearerRecoHeader(file)
415 file.close()
416- if main.superfastsim.smearer.rules!={}:
417+ if main.superfastsim.isSmearerOn():
418 file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/sigmas.h","w")
419 job.WriteNewSmearerEfficiencies(file)
420 file.close()
421- if main.superfastsim.reco.rules!={}:
422+ if main.superfastsim.isRecoOn():
423 file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/reco.h","w")
424 job.WriteNewRecoEfficiencies(file)
425 file.close()
426+ if main.superfastsim.isScalingOn():
427+ file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/scaling.h","w")
428+ job.WriteNewScales(file)
429+ file.close()
430
431 ## Do we need a tagger?
432- if main.superfastsim.tagger.rules!={}:
433+ if main.superfastsim.isTaggerOn():
434 file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/new_tagger.h","w")
435 import madanalysis.job.job_tagger_header as JobTaggerHeader
436 job = JobTaggerHeader.JobTaggerHeader(main.superfastsim)
437@@ -618,7 +625,7 @@
438 file.close()
439
440 ## Do we need a smearer?
441- if main.superfastsim.smearer.rules!={} or self.main.superfastsim.reco.rules!={}:
442+ if main.superfastsim.isRecoSmearerOn():
443 file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/new_smearer_reco.cpp","w")
444 import madanalysis.job.job_smearer_reco_main as JobSmearerRecoMain
445 job = JobSmearerRecoMain.JobSmearerRecoMain(main.superfastsim)
446@@ -626,7 +633,7 @@
447 file.close()
448
449 ## Do we need a tagger?
450- if main.superfastsim.tagger.rules!={}:
451+ if main.superfastsim.isTaggerOn():
452 file = open(self.path+"/Build/SampleAnalyzer/User/Analyzer/new_tagger.cpp","w")
453 import madanalysis.job.job_tagger_main as JobTaggerMain
454 job = JobTaggerMain.JobTaggerMain(main.superfastsim)
455
456=== modified file 'madanalysis/IOinterface/latex_report_writer.py'
457--- madanalysis/IOinterface/latex_report_writer.py 2020-07-03 08:05:49 +0000
458+++ madanalysis/IOinterface/latex_report_writer.py 2021-06-30 09:39:51 +0000
459@@ -22,6 +22,7 @@
460 ################################################################################
461
462
463+from __future__ import absolute_import
464 import madanalysis.IOinterface.text_file_writer as TextFileWriter
465 from madanalysis.enumeration.color_type import ColorType
466 from madanalysis.enumeration.font_type import FontType
467@@ -177,7 +178,9 @@
468 self.file.write("m{"+str(size)+"mm}|")
469 self.file.write("}\n \\hline\n")
470
471- def NewCell(self,color=ColorType.WHITE,span=1):
472+ def NewCell(self,color=None,span=1):
473+ if color is None:
474+ color=ColorType.WHITE
475 self.current_col=self.current_col+span
476
477 if self.current_col>self.number_col:
478
479=== modified file 'madanalysis/IOinterface/layout_writer.py'
480--- madanalysis/IOinterface/layout_writer.py 2020-07-03 08:05:49 +0000
481+++ madanalysis/IOinterface/layout_writer.py 2021-06-30 09:39:51 +0000
482@@ -22,6 +22,7 @@
483 ################################################################################
484
485
486+from __future__ import absolute_import
487 from madanalysis.selection.instance_name import InstanceName
488 from madanalysis.IOinterface.folder_writer import FolderWriter
489 from madanalysis.enumeration.ma5_running_type import MA5RunningType
490@@ -29,7 +30,6 @@
491 import logging
492 import shutil
493 import os
494-import commands
495
496 class LayoutWriter():
497
498
499=== modified file 'madanalysis/IOinterface/library_writer.py'
500--- madanalysis/IOinterface/library_writer.py 2020-07-03 08:05:49 +0000
501+++ madanalysis/IOinterface/library_writer.py 2021-06-30 09:39:51 +0000
502@@ -22,6 +22,7 @@
503 ################################################################################
504
505
506+from __future__ import absolute_import
507 from madanalysis.selection.instance_name import InstanceName
508 from madanalysis.IOinterface.folder_writer import FolderWriter
509 from madanalysis.IOinterface.job_writer import JobWriter
510@@ -30,8 +31,8 @@
511 import logging
512 import shutil
513 import os
514-import commands
515 import subprocess
516+from six.moves import input
517
518
519 class LibraryWriter():
520@@ -52,7 +53,7 @@
521 if not self.main.forced:
522 test=False
523 while(not test):
524- answer=raw_input(" Answer: ")
525+ answer=input(" Answer: ")
526 if answer=="":
527 test=True
528 ncores=nmaxcores
529@@ -81,7 +82,7 @@
530 if not self.main.forced:
531 test=False
532 while(not test):
533- answer=raw_input(" Answer: ")
534+ answer=input(" Answer: ")
535 if answer=="":
536 test=True
537 ncores=nmaxcores
538
539=== modified file 'madanalysis/IOinterface/madgraph_interface.py'
540--- madanalysis/IOinterface/madgraph_interface.py 2020-07-03 08:05:49 +0000
541+++ madanalysis/IOinterface/madgraph_interface.py 2021-06-30 09:39:51 +0000
542@@ -22,10 +22,13 @@
543 ################################################################################
544
545
546+from __future__ import absolute_import
547 from madanalysis.configuration.recast_configuration import RecastConfiguration
548 import itertools
549 import logging
550 import os
551+import six
552+from six.moves import range
553
554 class MadGraphInterface():
555
556@@ -94,6 +97,9 @@
557 self.logger.debug('pdgs = '+str(myline[3:]))
558 mypdgs= [self.get_pdg_code(prt) for prt in myline[3:]]
559 self.multiparticles[myline[1]]=sorted(sum([e if isinstance(e,list) else [e] for e in mypdgs],[]))
560+ for key, value in self.multiparticles.items():
561+ if len([x for x in value if x != '']) == 0:
562+ del self.multiparticles[key]
563 self.logger.debug(' >> ' + str(self.multiparticles))
564 self.logger.debug(' >> invisible: ' + str(self.invisible_particles))
565 if card_type=='parton':
566@@ -436,7 +442,7 @@
567 else:
568 return myprt['antiname']
569 else:
570- for key, value in self.multiparticles.iteritems():
571+ for key, value in six.iteritems(self.multiparticles):
572 self.logger.debug('new multiparticle ' + key + ' = ' + str(value))
573 if sorted(value)==sorted(pdg):
574 return key
575@@ -450,22 +456,21 @@
576 if isinstance( int(prt), int ):
577 return int(prt)
578 except:
579- for key, value in self.model.get('particle_dict').iteritems():
580+ for key, value in six.iteritems(self.model.get('particle_dict')):
581 if value['antiname']==prt and not value['is_part']:
582 return key
583 elif value['name']==prt and value['is_part']:
584 return key
585- if prt in self.multiparticles.keys():
586+ if prt in list(self.multiparticles.keys()):
587 return self.multiparticles[prt]
588 else:
589- self.logger.error(" ** Problem with the multiparticle definitions")
590- raise self.MultiParts(" ** Problem with the multiparticle definitions")
591+ return ''
592
593 # adding the particle definitions
594 def get_invisible(self, card_type='parton'):
595 do_parton = card_type=='parton'
596 # Do we have MET?
597- for key, value in self.model.get('particle_dict').iteritems():
598+ for key, value in six.iteritems(self.model.get('particle_dict')):
599 if value['width'] == 'ZERO' and value['color']==1 and value['charge']==0 and not value['name']=='a':
600 self.invisible_particles.append(value['name'])
601 self.invisible_particles.append(value['antiname'])
602@@ -478,7 +483,7 @@
603 self.card.append('define invisible = ' + ' '.join(list(set(self.invisible_pdgs))))
604
605 def write_multiparticles(self):
606- for key, value in self.multiparticles.iteritems():
607+ for key, value in six.iteritems(self.multiparticles):
608 if len([ x for x in value if x in [self.get_pdg_code(y) for y in self.invisible_particles] ])==len(value):
609 self.invisible_particles.append(key)
610 self.card.append('define ' + key + ' = ' + ' '.join([str(x) for x in value]))
611
612=== modified file 'madanalysis/IOinterface/multiparticle_reader.py'
613--- madanalysis/IOinterface/multiparticle_reader.py 2020-07-03 08:05:49 +0000
614+++ madanalysis/IOinterface/multiparticle_reader.py 2021-06-30 09:39:51 +0000
615@@ -22,6 +22,7 @@
616 ################################################################################
617
618
619+from __future__ import absolute_import
620 from madanalysis.enumeration.ma5_running_type import MA5RunningType
621 from madanalysis.core.main import Main
622 import logging
623
624=== modified file 'madanalysis/IOinterface/particle_reader.py'
625--- madanalysis/IOinterface/particle_reader.py 2020-07-03 08:05:49 +0000
626+++ madanalysis/IOinterface/particle_reader.py 2021-06-30 09:39:51 +0000
627@@ -22,6 +22,7 @@
628 ################################################################################
629
630
631+from __future__ import absolute_import
632 import madanalysis.core.main as Main
633 from madanalysis.enumeration.ma5_running_type import MA5RunningType
634 import logging
635
636=== modified file 'madanalysis/IOinterface/png_reader.py'
637--- madanalysis/IOinterface/png_reader.py 2020-07-03 08:05:49 +0000
638+++ madanalysis/IOinterface/png_reader.py 2021-06-30 09:39:51 +0000
639@@ -22,12 +22,15 @@
640 ################################################################################
641
642
643+from __future__ import absolute_import
644+from __future__ import print_function
645+import copy
646 import logging
647 import shutil
648 import os
649-import commands
650-import copy
651-
652+import sys
653+from six.moves import range
654+import six
655
656 class PngHeader():
657
658@@ -71,13 +74,13 @@
659
660
661 def Print(self):
662- print 'PNG file with width='+str(self.width)+\
663+ print('PNG file with width='+str(self.width)+\
664 ' height='+str(self.height)+\
665 ' bit_depth='+str(self.bit_depth)+\
666 ' color_type='+str(self.color_type)+\
667 ' compression_type='+str(self.compression_type)+\
668 ' filter_type='+str(self.filter_type)+\
669- ' interlace_type='+str(self.interlace_type)
670+ ' interlace_type='+str(self.interlace_type))
671
672
673
674@@ -124,7 +127,8 @@
675 # Check the PNG stamp
676 ok=True
677 for ind in range(0,len(head)):
678- if ord(head[ind])!=PngReader.png_header[ind]:
679+ if (sys.version_info[0]==2 and ord(head[ind])!=PngReader.png_header[ind]) or \
680+ (sys.version_info[0]==3 and head[ind]!=PngReader.png_header[ind]):
681 ok=False
682 break
683 if not ok:
684@@ -141,12 +145,13 @@
685 try:
686 head_length = self.input.read(4)
687 head_type = self.input.read(4)
688- except:
689+ except Exception as error:
690+ print(error)
691 logging.getLogger('MA5').error('The file "'+self.filename+'" does not contain a PNG header.')
692 return False
693
694 # Check the header begin
695- if head_type.upper()!='IHDR':
696+ if six.PY2 and head_type.upper()!='IHDR':
697 logging.getLogger('MA5').error('The file "'+self.filename+'" does not contain a PNG header.')
698 return False
699
700@@ -162,18 +167,24 @@
701 except:
702 logging.getLogger('MA5').error('Wrong PNG header for the file "'+self.filename+'".')
703 return False
704-
705+
706+ def decode(d):
707+ if six.PY2:
708+ return ord(d)
709+ else:
710+ return d
711+
712 # Decode the header
713- self.header.bit_depth = ord(bit_depth)
714- self.header.color_type = ord(color_type)
715- self.header.compression_type = ord(compression_type)
716- self.header.filter_type = ord(filter_type)
717- self.header.interlace_type = ord(interlace_type)
718+ self.header.bit_depth = decode(bit_depth)
719+ self.header.color_type = decode(color_type)
720+ self.header.compression_type = decode(compression_type)
721+ self.header.filter_type = decode(filter_type)
722+ self.header.interlace_type = decode(interlace_type)
723 self.header.width = 0
724 self.header.height = 0
725 for ind in range(0,4):
726- self.header.width += ord(width[ind]) *((2**8)**(3-ind))
727- self.header.height += ord(height[ind])*((2**8)**(3-ind))
728+ self.header.width += decode(width[ind]) *((2**8)**(3-ind))
729+ self.header.height += decode(height[ind])*((2**8)**(3-ind))
730
731 # Ok
732 return True
733
734=== modified file 'madanalysis/IOinterface/text_file_reader.py'
735--- madanalysis/IOinterface/text_file_reader.py 2020-07-03 08:05:49 +0000
736+++ madanalysis/IOinterface/text_file_reader.py 2021-06-30 09:39:51 +0000
737@@ -22,6 +22,7 @@
738 ################################################################################
739
740
741+from __future__ import absolute_import
742 import logging
743 class TextFileReader():
744
745
746=== modified file 'madanalysis/IOinterface/text_file_writer.py'
747--- madanalysis/IOinterface/text_file_writer.py 2020-07-03 08:05:49 +0000
748+++ madanalysis/IOinterface/text_file_writer.py 2021-06-30 09:39:51 +0000
749@@ -22,6 +22,7 @@
750 ################################################################################
751
752
753+from __future__ import absolute_import
754 import logging
755 class TextFileWriter():
756
757
758=== modified file 'madanalysis/IOinterface/text_report.py'
759--- madanalysis/IOinterface/text_report.py 2020-07-03 08:05:49 +0000
760+++ madanalysis/IOinterface/text_report.py 2021-06-30 09:39:51 +0000
761@@ -22,10 +22,12 @@
762 ################################################################################
763
764
765+from __future__ import absolute_import
766 from madanalysis.enumeration.color_type import ColorType
767 from madanalysis.enumeration.font_type import FontType
768 from madanalysis.enumeration.script_type import ScriptType
769 import logging
770+import six
771
772 class TextReport():
773
774@@ -42,7 +44,7 @@
775
776 def ReplaceAll(self,text,dic):
777 word = text
778- for i,j in dic.iteritems():
779+ for i,j in six.iteritems(dic):
780 word = word.replace(i,j)
781 return word
782
783
784=== modified file 'madanalysis/IOinterface/ufo_reader.py'
785--- madanalysis/IOinterface/ufo_reader.py 2020-07-03 08:05:49 +0000
786+++ madanalysis/IOinterface/ufo_reader.py 2021-06-30 09:39:51 +0000
787@@ -22,9 +22,11 @@
788 ################################################################################
789
790
791+from __future__ import absolute_import
792 import madanalysis.core.main as Main
793 import logging
794 import os
795+from six.moves import range
796
797
798 class UFOParticle:
799
800=== modified file 'madanalysis/UpdateNotes.txt'
801--- madanalysis/UpdateNotes.txt 2020-07-03 08:06:51 +0000
802+++ madanalysis/UpdateNotes.txt 2021-06-30 09:39:51 +0000
803@@ -1,5 +1,57 @@
804 Update notes for MadAnalysis 5 (in reverse time order)
805
806+154 (2021/06/15) fuks: Re-organising the way the PAD works (continued)
807+
808+153 (2021/06/15) fuks: Re-organising the way the PAD works
809+
810+152 (2021/06/15) fuks: Connecting all PADs to the dataverse and fixing a few minor bugs
811+ with the LHC recasting structure
812+
813+151 (2021/05/11) fuks: Bug fix (696972) in the MG5 interface
814+
815+150 (2021/05/03) fuks: Matplotlib compatibility with py2 and py3
816+
817+149 (2021/03/24) fuks: Adding a warning message when Python2 is used
818+
819+148 (2021/03/19) fuks: Upgrading to delphes 3.4.3
820+
821+147 (2021/02/19) fuks: Small bug fixes with the SFS/PADForSFS
822+
823+146 (2021/02/16) fuks: Small bug with the python3 compatibility
824+
825+145 (2021/02/16) fuks: Finalisation of the PYHF interface and fixing a few bugs fir the
826+ PADForSFS
827+
828+144 (2021/01/20) fuks: Small bug fix for the track module (SFS)
829+
830+143 (2021/01/12) fuks: Bug fix with the mg5 interface
831+
832+142 (2021/01/11) fuks: Bug-fixing delphes so that it works with the latest ROOT
833+
834+141 (2021/01/06) fuks: Changing the default jet radius from 1 to 0.4 in the fastjet
835+ interface
836+
837+140 (2020/12/16) fuks: Bug fixes in particle propagation
838+
839+139 (2020/12/10) fuks: Fixing bugs with the python3 compatibility; adding tracks and
840+ particle propagation in the SFS module
841+
842+138 (2020/11/30) fuks: Bug fix with the PAD/PADForSFS
843+
844+137 (2020/11/06) fuks: Bug fix with the LHE reader (see bug #1851196 on Launchpad)
845+
846+136 (2020/11/02) fuks: Small bug in the recasting facilities
847+
848+134 (2020/10/14) fuks: Bug fix with the HEPMC reader
849+
850+133 (2020/07/27) fuks: Small bug with the LLP developments is now fixed
851+
852+132 (2020/07/15) fuks: Upgrading the SFS-LLP functionalities
853+
854+131 (2020/07/13) fuks: Small fix (LLP support)
855+
856+130 (2020/07/13) fuks: Adding LLP support
857+
858 128 1.8 (2020/07/03) ma5team: - New simplified fast simulation (SFS) module for event reconstruction
859 (arxiv:2006.09387)
860 - Update of the recasting functionalities to handle SFS detector simulations
861
862=== modified file 'madanalysis/build/makefile_writer.py'
863--- madanalysis/build/makefile_writer.py 2020-07-03 08:05:49 +0000
864+++ madanalysis/build/makefile_writer.py 2021-06-30 09:39:51 +0000
865@@ -22,9 +22,11 @@
866 ################################################################################
867
868
869+from __future__ import absolute_import
870 import logging
871 from shell_command import ShellCommand
872 from string_tools import StringTools
873+from six.moves import range
874
875
876 class MakefileWriter():
877
878=== modified file 'madanalysis/build/setup_writer.py'
879--- madanalysis/build/setup_writer.py 2020-07-03 08:05:49 +0000
880+++ madanalysis/build/setup_writer.py 2021-06-30 09:39:51 +0000
881@@ -22,8 +22,10 @@
882 ################################################################################
883
884
885+from __future__ import absolute_import
886 import logging
887 from string_tools import StringTools
888+from six.moves import range
889
890
891 class SetupWriter():
892
893=== modified file 'madanalysis/configuration/beauty_identification.py'
894--- madanalysis/configuration/beauty_identification.py 2020-07-03 08:05:49 +0000
895+++ madanalysis/configuration/beauty_identification.py 2021-06-30 09:39:51 +0000
896@@ -22,6 +22,7 @@
897 ################################################################################
898
899
900+from __future__ import absolute_import
901 import logging
902 class BeautyIdentification():
903
904@@ -95,7 +96,7 @@
905
906
907 def user_GetParameters(self):
908- return BeautyIdentification.userVariables.keys()
909+ return list(BeautyIdentification.userVariables.keys())
910
911
912 def user_SetParameter(self,parameter,value):
913
914=== modified file 'madanalysis/configuration/clustering_antikt.py'
915--- madanalysis/configuration/clustering_antikt.py 2020-07-03 08:05:49 +0000
916+++ madanalysis/configuration/clustering_antikt.py 2021-06-30 09:39:51 +0000
917@@ -22,10 +22,11 @@
918 ################################################################################
919
920
921+from __future__ import absolute_import
922 import logging
923 class ClusteringAntiKt():
924
925- default_radius = 1.
926+ default_radius = 0.4
927 default_ptmin = 5.
928
929 userVariables = { "radius" : [str(default_radius)],\
930@@ -66,7 +67,7 @@
931
932
933 def user_GetParameters(self):
934- return ClusteringAntiKt.userVariables.keys()
935+ return list(ClusteringAntiKt.userVariables.keys())
936
937
938 def user_SetParameter(self,parameter,value):
939
940=== modified file 'madanalysis/configuration/clustering_cambridge.py'
941--- madanalysis/configuration/clustering_cambridge.py 2020-07-03 08:05:49 +0000
942+++ madanalysis/configuration/clustering_cambridge.py 2021-06-30 09:39:51 +0000
943@@ -22,10 +22,11 @@
944 ################################################################################
945
946
947+from __future__ import absolute_import
948 import logging
949 class ClusteringCambridge():
950
951- default_radius = 1.
952+ default_radius = 0.4
953 default_ptmin = 5.
954
955 userVariables = { "radius" : [str(default_radius)],\
956@@ -65,7 +66,7 @@
957
958
959 def user_GetParameters(self):
960- return ClusteringCambridge.userVariables.keys()
961+ return list(ClusteringCambridge.userVariables.keys())
962
963
964 def user_SetParameter(self,parameter,value):
965
966=== modified file 'madanalysis/configuration/clustering_cdfjetclu.py'
967--- madanalysis/configuration/clustering_cdfjetclu.py 2020-07-03 08:05:49 +0000
968+++ madanalysis/configuration/clustering_cdfjetclu.py 2021-06-30 09:39:51 +0000
969@@ -22,6 +22,7 @@
970 ################################################################################
971
972
973+from __future__ import absolute_import
974 import logging
975 class ClusteringCDFJetClu():
976
977@@ -86,7 +87,7 @@
978
979
980 def user_GetParameters(self):
981- return ClusteringCDFJetClu.userVariables.keys()
982+ return list(ClusteringCDFJetClu.userVariables.keys())
983
984
985 def user_SetParameter(self,parameter,value):
986
987=== modified file 'madanalysis/configuration/clustering_cdfmidpoint.py'
988--- madanalysis/configuration/clustering_cdfmidpoint.py 2020-07-03 08:05:49 +0000
989+++ madanalysis/configuration/clustering_cdfmidpoint.py 2021-06-30 09:39:51 +0000
990@@ -22,6 +22,7 @@
991 ################################################################################
992
993
994+from __future__ import absolute_import
995 import logging
996 class ClusteringCDFMidPoint():
997
998@@ -86,7 +87,7 @@
999
1000
1001 def user_GetParameters(self):
1002- return ClusteringCDFMidPoint.userVariables.keys()
1003+ return list(ClusteringCDFMidPoint.userVariables.keys())
1004
1005
1006 def user_SetParameter(self,parameter,value):
1007
1008=== modified file 'madanalysis/configuration/clustering_configuration.py'
1009--- madanalysis/configuration/clustering_configuration.py 2020-07-03 08:05:49 +0000
1010+++ madanalysis/configuration/clustering_configuration.py 2021-06-30 09:39:51 +0000
1011@@ -22,6 +22,7 @@
1012 ################################################################################
1013
1014
1015+from __future__ import absolute_import
1016 from madanalysis.configuration.clustering_kt import ClusteringKt
1017 from madanalysis.configuration.clustering_antikt import ClusteringAntiKt
1018 from madanalysis.configuration.clustering_genkt import ClusteringGenKt
1019@@ -42,8 +43,13 @@
1020 "siscone",\
1021 "cdfjetclu", "cdfmidpoint",\
1022 "none"],
1023- "exclusive_id" : ["true","false"],
1024- "jetrecomode" : ["jets","constituents"]
1025+ "exclusive_id" : ["true","false"],
1026+ "jetrecomode" : ["jets","constituents"],
1027+ "magneticfield" : ["3.8"],
1028+ "tracker_radius" : ["1.29"],
1029+ "half_length" : ["3.0"],
1030+ "particle_propagator" : ["on","off"]
1031+
1032 }
1033
1034 def __init__(self):
1035@@ -204,7 +210,7 @@
1036
1037 def user_GetParameters(self):
1038 if self.algorithm!="none":
1039- table = ClusteringConfiguration.userVariables.keys()
1040+ table = list(ClusteringConfiguration.userVariables.keys())
1041 table.extend(self.clustering.user_GetParameters())
1042 table.extend(self.beauty.user_GetParameters())
1043 table.extend(self.tau.user_GetParameters())
1044
1045=== modified file 'madanalysis/configuration/clustering_genkt.py'
1046--- madanalysis/configuration/clustering_genkt.py 2020-07-03 08:05:49 +0000
1047+++ madanalysis/configuration/clustering_genkt.py 2021-06-30 09:39:51 +0000
1048@@ -22,10 +22,11 @@
1049 ################################################################################
1050
1051
1052+from __future__ import absolute_import
1053 import logging
1054 class ClusteringGenKt():
1055
1056- default_radius = 1.
1057+ default_radius = 0.4
1058 default_exclusive = False
1059 default_ptmin = 5.
1060 default_P = -1.
1061@@ -93,7 +94,7 @@
1062
1063
1064 def user_GetParameters(self):
1065- return ClusteringGenKt.userVariables.keys()
1066+ return list(ClusteringGenKt.userVariables.keys())
1067
1068
1069 def user_SetParameter(self,parameter,value):
1070
1071=== modified file 'madanalysis/configuration/clustering_gridjet.py'
1072--- madanalysis/configuration/clustering_gridjet.py 2020-07-03 08:05:49 +0000
1073+++ madanalysis/configuration/clustering_gridjet.py 2021-06-30 09:39:51 +0000
1074@@ -22,6 +22,7 @@
1075 ################################################################################
1076
1077
1078+from __future__ import absolute_import
1079 import logging
1080 class ClusteringGridJet():
1081
1082@@ -72,7 +73,7 @@
1083
1084
1085 def user_GetParameters(self):
1086- return ClusteringGridJet.userVariables.keys()
1087+ return list(ClusteringGridJet.userVariables.keys())
1088
1089
1090 def user_SetParameter(self,parameter,value):
1091
1092=== modified file 'madanalysis/configuration/clustering_kt.py'
1093--- madanalysis/configuration/clustering_kt.py 2020-07-03 08:05:49 +0000
1094+++ madanalysis/configuration/clustering_kt.py 2021-06-30 09:39:51 +0000
1095@@ -22,10 +22,11 @@
1096 ################################################################################
1097
1098
1099+from __future__ import absolute_import
1100 import logging
1101 class ClusteringKt():
1102
1103- default_radius = 1.
1104+ default_radius = 0.4
1105 default_exclusive = False
1106 default_ptmin = 5.
1107
1108@@ -78,7 +79,7 @@
1109
1110
1111 def user_GetParameters(self):
1112- return ClusteringKt.userVariables.keys()
1113+ return list(ClusteringKt.userVariables.keys())
1114
1115
1116 def user_SetParameter(self,parameter,value):
1117
1118=== modified file 'madanalysis/configuration/clustering_siscone.py'
1119--- madanalysis/configuration/clustering_siscone.py 2020-07-03 08:05:49 +0000
1120+++ madanalysis/configuration/clustering_siscone.py 2021-06-30 09:39:51 +0000
1121@@ -22,10 +22,11 @@
1122 ################################################################################
1123
1124
1125+from __future__ import absolute_import
1126 import logging
1127 class ClusteringSisCone():
1128
1129- default_radius = 1.
1130+ default_radius = 0.4
1131 default_overlap = 0.5
1132 default_npassmax = 0
1133 default_input_ptmin = 0.
1134@@ -86,7 +87,7 @@
1135
1136
1137 def user_GetParameters(self):
1138- return ClusteringSisCone.userVariables.keys()
1139+ return list(ClusteringSisCone.userVariables.keys())
1140
1141
1142 def user_SetParameter(self,parameter,value):
1143
1144=== modified file 'madanalysis/configuration/delphesMA5tune_configuration.py'
1145--- madanalysis/configuration/delphesMA5tune_configuration.py 2020-07-03 08:05:49 +0000
1146+++ madanalysis/configuration/delphesMA5tune_configuration.py 2021-06-30 09:39:51 +0000
1147@@ -22,6 +22,7 @@
1148 ################################################################################
1149
1150
1151+from __future__ import absolute_import
1152 from madanalysis.enumeration.ma5_running_type import MA5RunningType
1153 import os
1154 import logging
1155@@ -160,7 +161,7 @@
1156
1157
1158 def user_GetParameters(self):
1159- return DelphesMA5tuneConfiguration.userVariables.keys()
1160+ return list(DelphesMA5tuneConfiguration.userVariables.keys())
1161
1162
1163 def user_GetValues(self,variable):
1164
1165=== modified file 'madanalysis/configuration/delphes_configuration.py'
1166--- madanalysis/configuration/delphes_configuration.py 2020-07-03 08:05:49 +0000
1167+++ madanalysis/configuration/delphes_configuration.py 2021-06-30 09:39:51 +0000
1168@@ -22,6 +22,7 @@
1169 ################################################################################
1170
1171
1172+from __future__ import absolute_import
1173 from madanalysis.enumeration.ma5_running_type import MA5RunningType
1174 import os
1175 import logging
1176@@ -262,7 +263,7 @@
1177
1178
1179 def user_GetParameters(self):
1180- return DelphesConfiguration.userVariables.keys()
1181+ return list(DelphesConfiguration.userVariables.keys())
1182
1183
1184 def user_GetValues(self,variable):
1185
1186=== modified file 'madanalysis/configuration/fastsim_configuration.py'
1187--- madanalysis/configuration/fastsim_configuration.py 2020-07-03 08:05:49 +0000
1188+++ madanalysis/configuration/fastsim_configuration.py 2021-06-30 09:39:51 +0000
1189@@ -22,6 +22,7 @@
1190 ################################################################################
1191
1192
1193+from __future__ import absolute_import
1194 from madanalysis.enumeration.ma5_running_type import MA5RunningType
1195 from madanalysis.configuration.clustering_configuration import ClusteringConfiguration
1196 from madanalysis.configuration.delphes_configuration import DelphesConfiguration
1197@@ -180,13 +181,13 @@
1198
1199 def user_GetParameters(self):
1200 if self.package=="fastjet":
1201- table = FastsimConfiguration.userVariables.keys()
1202+ table = list(FastsimConfiguration.userVariables.keys())
1203 table.extend(self.clustering.user_GetParameters())
1204 elif self.package=="delphes":
1205- table = FastsimConfiguration.userVariables.keys()
1206+ table = list(FastsimConfiguration.userVariables.keys())
1207 table.extend(self.delphes.user_GetParameters())
1208 elif self.package=="delphesMA5tune":
1209- table = FastsimConfiguration.userVariables.keys()
1210+ table = list(FastsimConfiguration.userVariables.keys())
1211 table.extend(self.delphesMA5tune.user_GetParameters())
1212 else:
1213 table = ["package"]
1214
1215=== modified file 'madanalysis/configuration/fom_configuration.py'
1216--- madanalysis/configuration/fom_configuration.py 2020-07-03 08:05:49 +0000
1217+++ madanalysis/configuration/fom_configuration.py 2021-06-30 09:39:51 +0000
1218@@ -22,6 +22,7 @@
1219 ################################################################################
1220
1221
1222+from __future__ import absolute_import
1223 import logging
1224 class FomConfiguration:
1225
1226@@ -86,14 +87,14 @@
1227
1228
1229 def user_GetParameters(self):
1230- table = FomConfiguration.userVariables.keys()
1231+ table = list(FomConfiguration.userVariables.keys())
1232 if self.IsX():
1233 table.extend("x")
1234 return table
1235
1236
1237 def user_GetValues(self,variable):
1238- if variable in FomConfiguration.userVariables.keys():
1239+ if variable in list(FomConfiguration.userVariables.keys()):
1240 table = FomConfiguration.userVariables[variable]
1241 if self.IsX() and variable=='x':
1242 table = ['0.']
1243
1244=== modified file 'madanalysis/configuration/isolation_cone.py'
1245--- madanalysis/configuration/isolation_cone.py 2020-07-03 08:05:49 +0000
1246+++ madanalysis/configuration/isolation_cone.py 2021-06-30 09:39:51 +0000
1247@@ -22,6 +22,7 @@
1248 ################################################################################
1249
1250
1251+from __future__ import absolute_import
1252 import logging
1253 class IsolationCone():
1254
1255@@ -53,7 +54,7 @@
1256
1257
1258 def user_GetParameters(self):
1259- return IsolationCone.userVariables.keys()
1260+ return list(IsolationCone.userVariables.keys())
1261
1262
1263 def user_SetParameter(self,parameter,value):
1264
1265=== modified file 'madanalysis/configuration/isolation_configuration.py'
1266--- madanalysis/configuration/isolation_configuration.py 2020-07-03 08:05:49 +0000
1267+++ madanalysis/configuration/isolation_configuration.py 2021-06-30 09:39:51 +0000
1268@@ -22,6 +22,7 @@
1269 ################################################################################
1270
1271
1272+from __future__ import absolute_import
1273 from madanalysis.configuration.isolation_cone import IsolationCone
1274 from madanalysis.configuration.isolation_sumpt import IsolationSumPt
1275 import logging
1276@@ -46,7 +47,7 @@
1277 self.isolation.user_DisplayParameter(parameter)
1278
1279 def user_GetParameters(self):
1280- table = IsolationConfiguration.userVariables.keys()
1281+ table = list(IsolationConfiguration.userVariables.keys())
1282 table.extend(self.isolation.user_GetParameters())
1283 return table
1284
1285
1286=== modified file 'madanalysis/configuration/isolation_sumpt.py'
1287--- madanalysis/configuration/isolation_sumpt.py 2020-07-03 08:05:49 +0000
1288+++ madanalysis/configuration/isolation_sumpt.py 2021-06-30 09:39:51 +0000
1289@@ -22,6 +22,7 @@
1290 ################################################################################
1291
1292
1293+from __future__ import absolute_import
1294 import logging
1295 class IsolationSumPt():
1296
1297@@ -58,7 +59,7 @@
1298
1299
1300 def user_GetParameters(self):
1301- return IsolationSumPt.userVariables.keys()
1302+ return list(IsolationSumPt.userVariables.keys())
1303
1304
1305 def user_SetParameter(self,parameter,value):
1306
1307=== modified file 'madanalysis/configuration/merging_configuration.py'
1308--- madanalysis/configuration/merging_configuration.py 2020-07-03 08:05:49 +0000
1309+++ madanalysis/configuration/merging_configuration.py 2021-06-30 09:39:51 +0000
1310@@ -22,6 +22,7 @@
1311 ################################################################################
1312
1313
1314+from __future__ import absolute_import
1315 from madanalysis.configuration.clustering_kt import ClusteringKt
1316 from madanalysis.configuration.clustering_antikt import ClusteringAntiKt
1317 from madanalysis.configuration.clustering_genkt import ClusteringGenKt
1318@@ -121,7 +122,7 @@
1319
1320
1321 def user_GetParameters(self):
1322- return MergingConfiguration.userVariables.keys()
1323+ return list(MergingConfiguration.userVariables.keys())
1324
1325
1326 def user_GetValues(self,variable):
1327
1328=== modified file 'madanalysis/configuration/recast_configuration.py'
1329--- madanalysis/configuration/recast_configuration.py 2020-07-03 08:05:49 +0000
1330+++ madanalysis/configuration/recast_configuration.py 2021-06-30 09:39:51 +0000
1331@@ -22,13 +22,10 @@
1332 ################################################################################
1333
1334
1335+from __future__ import absolute_import
1336 from madanalysis.enumeration.ma5_running_type import MA5RunningType
1337-from madanalysis.IOinterface.folder_writer import FolderWriter
1338-from shell_command import ShellCommand
1339-import glob
1340-import logging
1341-import shutil
1342-import os
1343+import glob, logging, shutil, os
1344+from six.moves import range
1345
1346 class RecastConfiguration:
1347
1348@@ -41,7 +38,8 @@
1349 "store_root" : ["True", "False"] , \
1350 "store_events" : ["True", "False"] , \
1351 "THerror_combination" : ["quadratic","linear"], \
1352- "error_extrapolation" : ["linear", "sqrt"]
1353+ "error_extrapolation" : ["linear", "sqrt"],
1354+ "global_likelihoods" : ["on","off"]
1355 }
1356
1357 def __init__(self):
1358@@ -53,6 +51,7 @@
1359 self.padsfs = False
1360 self.store_root = False
1361 self.store_events = False
1362+ self.global_likelihoods_switch = True
1363 self.systematics = []
1364 self.extrapolated_luminosities = []
1365 self.THerror_combination = "linear"
1366@@ -95,6 +94,7 @@
1367 self.user_DisplayParameter("systematics")
1368 self.user_DisplayParameter("THerror_combination")
1369 self.user_DisplayParameter("error_extrapolation")
1370+ self.user_DisplayParameter("global_likelihoods")
1371
1372 def user_DisplayParameter(self,parameter):
1373 if parameter=="status":
1374@@ -162,6 +162,10 @@
1375 else:
1376 self.logger.info(" * Relative error on the extrapolated background Nb taken as sqrt({:.2f}^2 + ({:.2f}/Nb)^2)".format(self.error_extrapolation[0],self.error_extrapolation[1]))
1377 return
1378+ elif parameter=="global_likelihoods":
1379+ self.logger.info(" * Global-Likelihoods will"+(not self.global_likelihoods_switch)*' not'+\
1380+ ' be calculated'+(self.global_likelihoods_switch)*', if available'+'.')
1381+ return
1382 return
1383
1384 def user_SetParameter(self,parameters,values,level,archi_info,session_info,datasets):
1385@@ -351,6 +355,17 @@
1386 error_message();
1387 return
1388
1389+ # Switch to turn off the global likelihood calculations
1390+ elif parameter=="global_likelihoods":
1391+ if self.status!="on":
1392+ self.logger.error("Please first set the recasting mode to 'on'.")
1393+ return
1394+ if value.lower() in ["on", "off"]:
1395+ self.global_likelihoods_switch = (value.lower()=="on")
1396+ else:
1397+ self.logger.error("You can only switch the global-likelihood machinery to 'on' or 'off'.")
1398+ return
1399+
1400 # other rejection if no algo specified
1401 else:
1402 self.logger.error("the recast module has no parameter called '"+str(parameter)+"'")
1403@@ -361,7 +376,8 @@
1404 if var == "add":
1405 table = ["extrapolated_luminosity", "systematics"]
1406 else:
1407- table = ["CLs_numofexps", "card_path", "store_events", "add", "THerror_combination", "error_extrapolation"]
1408+ table = ["CLs_numofexps", "card_path", "store_events", "add",
1409+ "THerror_combination", "error_extrapolation", "global_likelihoods"]
1410 else:
1411 table = []
1412 return table
1413@@ -383,6 +399,8 @@
1414 table.extend(RecastConfiguration.userVariables["THerror_combination"])
1415 elif variable =="error_extrapolation":
1416 table.extend(RecastConfiguration.userVariables["error_extrapolation"])
1417+ elif variable =="global_likelihoods":
1418+ table.extend(RecastConfiguration.userVariables["global_likelihoods"])
1419 return table
1420
1421
1422@@ -539,7 +557,7 @@
1423 if analysis not in analysislist:
1424 continue
1425 descr = 'UNKNOWN'
1426- if analysis in self.description.keys():
1427+ if analysis in list(self.description.keys()):
1428 descr = self.description[analysis]
1429 thecard.append(analysis.ljust(30,' ') + 'vSFS on ' + mycard.ljust(50, ' ')+\
1430 ' # '+descr)
1431
1432=== modified file 'madanalysis/configuration/tau_identification.py'
1433--- madanalysis/configuration/tau_identification.py 2020-07-03 08:05:49 +0000
1434+++ madanalysis/configuration/tau_identification.py 2021-06-30 09:39:51 +0000
1435@@ -22,6 +22,7 @@
1436 ################################################################################
1437
1438
1439+from __future__ import absolute_import
1440 import logging
1441 class TauIdentification():
1442
1443@@ -70,7 +71,7 @@
1444
1445
1446 def user_GetParameters(self):
1447- return TauIdentification.userVariables.keys()
1448+ return list(TauIdentification.userVariables.keys())
1449
1450
1451 def user_SetParameter(self,parameter,value):
1452
1453=== modified file 'madanalysis/core/expert_mode.py'
1454--- madanalysis/core/expert_mode.py 2020-07-03 08:05:49 +0000
1455+++ madanalysis/core/expert_mode.py 2021-06-30 09:39:51 +0000
1456@@ -22,14 +22,15 @@
1457 ################################################################################
1458
1459
1460+from __future__ import absolute_import
1461 from madanalysis.IOinterface.folder_writer import FolderWriter
1462 from madanalysis.IOinterface.job_writer import JobWriter
1463 import logging
1464 import glob
1465 import os
1466-import commands
1467 import sys
1468 import shutil
1469+from six.moves import input
1470
1471 class ExpertMode:
1472
1473@@ -46,7 +47,7 @@
1474 logging.getLogger('MA5').debug("Debug mode: no directory name is specified.")
1475 logging.getLogger('MA5').info("\nWelcome to the expert mode of MadAnalysis")
1476 logging.getLogger('MA5').info("Please enter a folder name for creating an empty SampleAnalyzer job")
1477- answer=raw_input("Answer: ")
1478+ answer=input("Answer: ")
1479 answer=answer.replace(' ','_')
1480 name =answer.replace('-','_')
1481 else:
1482@@ -120,7 +121,7 @@
1483 # Writing an empty analysis
1484 if name=="":
1485 logging.getLogger('MA5').info("Please enter a name for your analysis")
1486- title=raw_input("Answer: ")
1487+ title=input("Answer: ")
1488 if title=="":
1489 title="user"
1490 title=title.replace(' ', '_');
1491
1492=== modified file 'madanalysis/core/launcher.py'
1493--- madanalysis/core/launcher.py 2020-07-03 08:05:49 +0000
1494+++ madanalysis/core/launcher.py 2021-06-30 09:39:51 +0000
1495@@ -23,6 +23,8 @@
1496
1497
1498 # Setting global variables of MadAnalysis main
1499+from __future__ import absolute_import
1500+from __future__ import print_function
1501 from madanalysis.core.script_stack import ScriptStack
1502 from madanalysis.core.main import Main
1503 from string_tools import StringTools
1504@@ -53,7 +55,7 @@
1505 ################################################################################
1506 def DefaultInstallCard():
1507 logging.getLogger('MA5').info("Generate a default installation_options.dat file...")
1508- output = file('installation_options.dat','w')
1509+ output = open('installation_options.dat','w')
1510 output.write('# WARNING! MA5 SHOULD DETECT AUTOMATICALLY YOUR CONFIGURATION\n')
1511 output.write('# IF THIS AUTOMATED MODE FAILS, YOU CAN FORCE SOME \n')
1512 output.write('# OPTIONS THROUGH THIS FILE\n')
1513@@ -128,7 +130,7 @@
1514 ["partonlevel","hadronlevel","recolevel",\
1515 "expert","version","release","help",\
1516 "forced","script","debug","build","qmode","installcard"])
1517- except getopt.GetoptError, err:
1518+ except getopt.GetoptError as err:
1519 logging.getLogger('MA5').error(str(err))
1520 Usage()
1521 sys.exit()
1522@@ -159,9 +161,9 @@
1523 mode.build = True
1524 elif o in ["-q","--qmode"]:
1525 mode.developer_mode = True
1526- print ""
1527- print " **** DEVELOPER MODE DETECTED **** "
1528- print ""
1529+ print("")
1530+ print(" **** DEVELOPER MODE DETECTED **** ")
1531+ print("")
1532 elif o in ["-h","--help"]:
1533 Usage()
1534 sys.exit()
1535@@ -395,7 +397,7 @@
1536 try:
1537 import pyreadline as readline
1538 except:
1539- print "For tab completion and history, install module readline."
1540+ print("For tab completion and history, install module readline.")
1541 else:
1542 import rlcompleter
1543
1544
1545=== modified file 'madanalysis/core/library_builder.py'
1546--- madanalysis/core/library_builder.py 2020-07-03 08:05:49 +0000
1547+++ madanalysis/core/library_builder.py 2021-06-30 09:39:51 +0000
1548@@ -22,11 +22,11 @@
1549 ################################################################################
1550
1551
1552+from __future__ import absolute_import
1553 from madanalysis.system.architecture_info import ArchitectureInfo
1554 import logging
1555 import glob
1556 import os
1557-import commands
1558 import sys
1559
1560 class LibraryBuilder:
1561
1562=== modified file 'madanalysis/core/main.py'
1563--- madanalysis/core/main.py 2020-07-03 08:05:49 +0000
1564+++ madanalysis/core/main.py 2021-06-30 09:39:51 +0000
1565@@ -22,6 +22,7 @@
1566 ################################################################################
1567
1568
1569+from __future__ import absolute_import
1570 from madanalysis.multiparticle.multiparticle_collection import MultiParticleCollection
1571 from madanalysis.dataset.dataset_collection import DatasetCollection
1572 from madanalysis.selection.selection import Selection
1573@@ -50,6 +51,7 @@
1574 import os
1575 import sys
1576 import platform
1577+from six.moves import range
1578
1579 class Main():
1580
1581@@ -228,6 +230,7 @@
1582
1583
1584 def user_DisplayParameter(self,parameter):
1585+ print(type(self))
1586 if parameter=="currentdir":
1587 self.logger.info(" currentdir = "+self.get_currentdir())
1588 elif parameter=="stacking_method":
1589@@ -281,7 +284,7 @@
1590 return []
1591
1592 def user_GetParameters(self):
1593- return Main.userVariables.keys()
1594+ return list(Main.userVariables.keys())
1595
1596 def user_SetParameter(self,parameter,value):
1597 # currentdir
1598@@ -404,7 +407,10 @@
1599 os.chdir(theDir)
1600 except:
1601 self.logger.error("Impossible to access the directory : "+theDir)
1602- self.user_DisplayParameter("currentdir")
1603+ try:
1604+ self.user_DisplayParameter("currentdir")
1605+ except:
1606+ pass
1607
1608 currentdir = property(get_currentdir, set_currentdir)
1609
1610
1611=== modified file 'madanalysis/core/script_stack.py'
1612--- madanalysis/core/script_stack.py 2020-07-03 08:05:49 +0000
1613+++ madanalysis/core/script_stack.py 2021-06-30 09:39:51 +0000
1614@@ -22,10 +22,10 @@
1615 ################################################################################
1616
1617
1618+from __future__ import absolute_import
1619 import logging
1620 import glob
1621 import os
1622-import commands
1623 import sys
1624 import shutil
1625
1626@@ -68,7 +68,7 @@
1627 return False
1628 else:
1629 logging.getLogger('MA5').info("Executing the commands from the script")
1630- logging.getLogger('MA5').info(ScriptStack.stack[ScriptStack.main_index][0] + "...")
1631+ logging.getLogger('MA5').info(ScriptStack.stack[-1][0] + "...")
1632 ScriptStack.main_index+=1
1633 ScriptStack.sub_index=0
1634 else:
1635
1636=== modified file 'madanalysis/dataset/dataset.py'
1637--- madanalysis/dataset/dataset.py 2020-07-03 08:05:49 +0000
1638+++ madanalysis/dataset/dataset.py 2021-06-30 09:39:51 +0000
1639@@ -22,6 +22,7 @@
1640 ################################################################################
1641
1642
1643+from __future__ import absolute_import
1644 from madanalysis.enumeration.linestyle_type import LineStyleType
1645 from madanalysis.enumeration.backstyle_type import BackStyleType
1646 from madanalysis.enumeration.color_type import ColorType
1647@@ -83,7 +84,7 @@
1648 return []
1649
1650 def user_GetParameters(self):
1651- return Dataset.userVariables.keys()
1652+ return list(Dataset.userVariables.keys())
1653
1654 def user_SetParameter(self,variable,value,value2="",value3=""):
1655 #type
1656
1657=== modified file 'madanalysis/dataset/dataset_collection.py'
1658--- madanalysis/dataset/dataset_collection.py 2020-07-03 08:05:49 +0000
1659+++ madanalysis/dataset/dataset_collection.py 2021-06-30 09:39:51 +0000
1660@@ -22,8 +22,11 @@
1661 ################################################################################
1662
1663
1664+from __future__ import absolute_import
1665+from __future__ import print_function
1666 import logging
1667 import madanalysis.dataset.dataset as Dataset
1668+import six
1669
1670 class DatasetCollection:
1671
1672@@ -93,7 +96,7 @@
1673 return
1674
1675 # Looping over the branches of the tree
1676- for key, value in datasets.GetBranches().iteritems():
1677+ for key, value in six.iteritems(datasets.GetBranches()):
1678
1679 # Keeping only 'dataset' branches
1680 if key[0]!='dataset':
1681@@ -112,7 +115,7 @@
1682 # Getting physics parameters
1683 physics = value.GetBranch('physics',1)
1684 if physics==None:
1685- print "ERROR: no physics branch"
1686+ print("ERROR: no physics branch")
1687 continue
1688 else:
1689 background = physics.GetParameterToBool("background")
1690@@ -127,7 +130,7 @@
1691 # Getting layout parameters
1692 layout = value.GetBranch('layout',1)
1693 if layout==None:
1694- print "ERROR: no layout branch"
1695+ print("ERROR: no layout branch")
1696 continue
1697 else:
1698 title = layout.GetParameterToStringWithoutQuotes("title")
1699
1700=== modified file 'madanalysis/dataset/sample_info.py'
1701--- madanalysis/dataset/sample_info.py 2020-07-03 08:05:49 +0000
1702+++ madanalysis/dataset/sample_info.py 2021-06-30 09:39:51 +0000
1703@@ -26,6 +26,6 @@
1704 def __init__(self):
1705 self.xsection = 0.
1706 self.xerror = 0.
1707- self.nevents = 0L
1708+ self.nevents = 0
1709 self.sumw_positive = 0.
1710 self.sumw_negative = 0.
1711
1712=== modified file 'madanalysis/enumeration/argument_type.py'
1713--- madanalysis/enumeration/argument_type.py 2020-07-03 08:05:49 +0000
1714+++ madanalysis/enumeration/argument_type.py 2021-06-30 09:39:51 +0000
1715@@ -20,15 +20,17 @@
1716 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
1717 #
1718 ################################################################################
1719-
1720-
1721+import six
1722+
1723+class metaclass(type):
1724+
1725+ def __getattr__(self, name):
1726+ return list(self.values.keys()).index(name)
1727+
1728+@six.add_metaclass(metaclass)
1729 class ArgumentType(object):
1730 values = { 'COMBINATION' : [],\
1731 'PARTICLE' : [],\
1732 'INTEGER' : [],
1733 'FLOAT' : [] }
1734
1735- class __metaclass__(type):
1736-
1737- def __getattr__(self, name):
1738- return self.values.keys().index(name)
1739
1740=== modified file 'madanalysis/enumeration/backstyle_type.py'
1741--- madanalysis/enumeration/backstyle_type.py 2020-07-03 08:05:49 +0000
1742+++ madanalysis/enumeration/backstyle_type.py 2021-06-30 09:39:51 +0000
1743@@ -21,7 +21,26 @@
1744 #
1745 ################################################################################
1746
1747-
1748+import six
1749+
1750+class metaclass(type):
1751+
1752+ def __getattr__(self, name):
1753+ return list(self.values.keys()).index(name)
1754+
1755+ def convert2code(self,color):
1756+ name = list(self.values.keys())[color]
1757+ return self.values[name][0]
1758+
1759+ def convert2string(self,color):
1760+ name = list(self.values.keys())[color]
1761+ return self.values[name][1]
1762+
1763+ def convert2matplotlib(self,color):
1764+ name = list(self.values.keys())[color]
1765+ return self.values[name][2]
1766+
1767+@six.add_metaclass(metaclass)
1768 class BackStyleType(object):
1769 values = { 'AUTO' : [0, 'auto', 'None'],\
1770 'SOLID' : [1001,'solid', 'None'],\
1771@@ -32,19 +51,3 @@
1772
1773 # matplotlib -> hatch = ['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']
1774
1775- class __metaclass__(type):
1776-
1777- def __getattr__(self, name):
1778- return self.values.keys().index(name)
1779-
1780- def convert2code(self,color):
1781- name = self.values.keys()[color]
1782- return self.values[name][0]
1783-
1784- def convert2string(self,color):
1785- name = self.values.keys()[color]
1786- return self.values[name][1]
1787-
1788- def convert2matplotlib(self,color):
1789- name = self.values.keys()[color]
1790- return self.values[name][2]
1791
1792=== modified file 'madanalysis/enumeration/color_type.py'
1793--- madanalysis/enumeration/color_type.py 2020-07-03 08:05:49 +0000
1794+++ madanalysis/enumeration/color_type.py 2021-06-30 09:39:51 +0000
1795@@ -20,8 +20,35 @@
1796 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
1797 #
1798 ################################################################################
1799-
1800-
1801+import six
1802+
1803+class metaclass(type):
1804+
1805+ def __getattr__(self, name):
1806+ if (name)=='GRAY':
1807+ return list(self.values.keys()).index('GREY')
1808+ else:
1809+ return list(self.values.keys()).index(name)
1810+
1811+ def convert2string(self,color):
1812+ name = list(self.values.keys())[color]
1813+ return self.values[name][0]
1814+
1815+ def convert2hexa(self,color):
1816+ name = list(self.values.keys())[color]
1817+ return self.values[name][1]
1818+
1819+ def convert2rootcode(self,color):
1820+ name = list(self.values.keys())[color]
1821+ return self.values[name][2]
1822+
1823+ def convert2root(self,color,shade=0):
1824+ name = list(self.values.keys())[color]
1825+ return self.values[name][3][shade+4]
1826+
1827+
1828+
1829+@six.add_metaclass(metaclass)
1830 class ColorType(object):
1831 values = { 'AUTO' : ['auto', '', 0, \
1832 [0,0,0,0,0,0,0,0,0] ],\
1833@@ -48,26 +75,3 @@
1834 'WHITE' : ['white', '#FFFFFF', 10, \
1835 [10,10,10,10,10,19,18,17,16] ] }
1836
1837- class __metaclass__(type):
1838-
1839- def __getattr__(self, name):
1840- if (name)=='GRAY':
1841- return self.values.keys().index('GREY')
1842- else:
1843- return self.values.keys().index(name)
1844-
1845- def convert2string(self,color):
1846- name = self.values.keys()[color]
1847- return self.values[name][0]
1848-
1849- def convert2hexa(self,color):
1850- name = self.values.keys()[color]
1851- return self.values[name][1]
1852-
1853- def convert2rootcode(self,color):
1854- name = self.values.keys()[color]
1855- return self.values[name][2]
1856-
1857- def convert2root(self,color,shade=0):
1858- name = self.values.keys()[color]
1859- return self.values[name][3][shade+4]
1860
1861=== modified file 'madanalysis/enumeration/combination_type.py'
1862--- madanalysis/enumeration/combination_type.py 2020-07-03 08:05:49 +0000
1863+++ madanalysis/enumeration/combination_type.py 2021-06-30 09:39:51 +0000
1864@@ -20,21 +20,12 @@
1865 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
1866 #
1867 ################################################################################
1868-
1869-
1870-class CombinationType(object):
1871- values = { 'UNKNOWN' : [],\
1872- 'DEFAULT' : [''],\
1873- 'SUMSCALAR' : ['s'],\
1874- 'SUMVECTOR' : ['v'],\
1875- 'DIFFSCALAR' : ['ds','sd'],\
1876- 'DIFFVECTOR' : ['d','dv','vd'],\
1877- 'RATIO' : ['r'] }
1878-
1879- class __metaclass__(type):
1880+import six
1881+
1882+class metaclass(type):
1883
1884 def __getattr__(self, name):
1885- return self.values.keys().index(name)
1886+ return list(self.values.keys()).index(name)
1887
1888 def convert_from_string(self,lowerletters):
1889 for i,j in self.values.items():
1890@@ -46,5 +37,18 @@
1891 if index==self.__getattr__('UNKNOWN'):
1892 return 'ERROR'
1893 else:
1894- name = self.values.keys()[index]
1895+ name = list(self.values.keys())[index]
1896 return self.values[name][0]
1897+
1898+
1899+
1900+@six.add_metaclass(metaclass)
1901+class CombinationType(object):
1902+ values = { 'UNKNOWN' : [],\
1903+ 'DEFAULT' : [''],\
1904+ 'SUMSCALAR' : ['s'],\
1905+ 'SUMVECTOR' : ['v'],\
1906+ 'DIFFSCALAR' : ['ds','sd'],\
1907+ 'DIFFVECTOR' : ['d','dv','vd'],\
1908+ 'RATIO' : ['r'] }
1909+
1910
1911=== modified file 'madanalysis/enumeration/connector_type.py'
1912--- madanalysis/enumeration/connector_type.py 2020-07-03 08:05:49 +0000
1913+++ madanalysis/enumeration/connector_type.py 2021-06-30 09:39:51 +0000
1914@@ -20,27 +20,30 @@
1915 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
1916 #
1917 ################################################################################
1918-
1919-
1920-class ConnectorType(object):
1921- values = { 'OR' : ["or","||"],\
1922- 'AND' : ["and","&&"],\
1923- 'XOR' : ["xor",""],\
1924- 'UNKNOWN' : ["",""]
1925- }
1926-
1927- class __metaclass__(type):
1928+import six
1929+
1930+class metaclass(type):
1931
1932 def __getattr__(self, name):
1933- if name in self.values.keys():
1934- return self.values.keys().index(name)
1935+ if name in list(self.values.keys()):
1936+ return list(self.values.keys()).index(name)
1937 else:
1938- return self.values.keys().index('UNKNOWN')
1939+ return list(self.values.keys()).index('UNKNOWN')
1940
1941 def convert2string(self,op):
1942- name = self.values.keys()[op]
1943+ name = list(self.values.keys())[op]
1944 return self.values[name][0]
1945
1946 def convert2cpp(self,op):
1947- name = self.values.keys()[op]
1948+ name = list(self.values.keys())[op]
1949 return self.values[name][1]
1950+
1951+
1952+@six.add_metaclass(metaclass)
1953+class ConnectorType(object):
1954+ values = { 'OR' : ["or","||"],\
1955+ 'AND' : ["and","&&"],\
1956+ 'XOR' : ["xor",""],\
1957+ 'UNKNOWN' : ["",""]
1958+ }
1959+
1960
1961=== modified file 'madanalysis/enumeration/cut_type.py'
1962--- madanalysis/enumeration/cut_type.py 2020-07-03 08:05:49 +0000
1963+++ madanalysis/enumeration/cut_type.py 2021-06-30 09:39:51 +0000
1964@@ -20,19 +20,22 @@
1965 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
1966 #
1967 ################################################################################
1968-
1969-
1970-class CutType(object):
1971- values = { 'REJECT' : ['reject'],\
1972- 'SELECT' : ['select'] }
1973-
1974- class __metaclass__(type):
1975+import six
1976+
1977+class metaclass(type):
1978
1979 def __getattr__(self, name):
1980- return self.values.keys().index(name)
1981+ return list(self.values.keys()).index(name)
1982
1983 def convert2cmdname(self,cut):
1984- name = self.values.keys()[cut]
1985+ name = list(self.values.keys())[cut]
1986 return self.values[name][0]
1987
1988
1989+
1990+
1991+@six.add_metaclass(metaclass)
1992+class CutType(object):
1993+ values = { 'REJECT' : ['reject'],\
1994+ 'SELECT' : ['select'] }
1995+
1996
1997=== modified file 'madanalysis/enumeration/detect_status_type.py'
1998--- madanalysis/enumeration/detect_status_type.py 2020-07-03 08:05:49 +0000
1999+++ madanalysis/enumeration/detect_status_type.py 2021-06-30 09:39:51 +0000
2000@@ -20,12 +20,14 @@
2001 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2002 #
2003 ################################################################################
2004-
2005-
2006+import six
2007+
2008+class metaclass(type):
2009+ def __getattr__(self, name):
2010+ return self.values.index(name)
2011+
2012+@six.add_metaclass(metaclass)
2013 class DetectStatusType(object):
2014 values = ['FOUND','UNFOUND','ISSUE','VETOED','TOBUILD']
2015
2016- class __metaclass__(type):
2017- def __getattr__(self, name):
2018- return self.values.index(name)
2019
2020
2021=== modified file 'madanalysis/enumeration/font_type.py'
2022--- madanalysis/enumeration/font_type.py 2020-07-03 08:05:49 +0000
2023+++ madanalysis/enumeration/font_type.py 2021-06-30 09:39:51 +0000
2024@@ -20,31 +20,34 @@
2025 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2026 #
2027 ################################################################################
2028-
2029-
2030-class FontType(object):
2031- values = {'none' : ['','','',''],\
2032- 'IT' : ['\\textit{','}','<i>','</i>'],\
2033- 'BF' : ['\\textbf{','}','<b>','</b>'],\
2034- 'TT' : ['\\texttt{','}',' <tt>','</tt>'],\
2035- 'ITBF' : ['\\textit{\\textbf{','}}','<i><b>','</i></b>']}
2036-
2037- class __metaclass__(type):
2038+import six
2039+
2040+class metaclass(type):
2041 def __getattr__(self, name):
2042- return self.values.keys().index(name)
2043+ return list(self.values.keys()).index(name)
2044
2045 def convert2latex(self,font):
2046- name = self.values.keys()[font]
2047+ name = list(self.values.keys())[font]
2048 return self.values[name][0]
2049
2050 def convert2latexclose(self,font):
2051- name = self.values.keys()[font]
2052+ name = list(self.values.keys())[font]
2053 return self.values[name][1]
2054
2055 def convert2html(self,font):
2056- name = self.values.keys()[font]
2057+ name = list(self.values.keys())[font]
2058 return self.values[name][2]
2059
2060 def convert2htmlclose(self,font):
2061- name = self.values.keys()[font]
2062+ name = list(self.values.keys())[font]
2063 return self.values[name][3]
2064+
2065+@six.add_metaclass(metaclass)
2066+class FontType(object):
2067+ values = {'none' : ['','','',''],\
2068+ 'IT' : ['\\textit{','}','<i>','</i>'],\
2069+ 'BF' : ['\\textbf{','}','<b>','</b>'],\
2070+ 'TT' : ['\\texttt{','}',' <tt>','</tt>'],\
2071+ 'ITBF' : ['\\textit{\\textbf{','}}','<i><b>','</i></b>']}
2072+
2073+
2074
2075=== modified file 'madanalysis/enumeration/graphic_render_type.py'
2076--- madanalysis/enumeration/graphic_render_type.py 2020-07-03 08:05:49 +0000
2077+++ madanalysis/enumeration/graphic_render_type.py 2021-06-30 09:39:51 +0000
2078@@ -20,15 +20,18 @@
2079 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2080 #
2081 ################################################################################
2082-
2083-
2084-class GraphicRenderType(object):
2085- values = {'NONE' : ['none'] ,'ROOT':['Root'],'MATPLOTLIB':['Matplotlib']}
2086-
2087- class __metaclass__(type):
2088+import six
2089+
2090+class metaclass(type):
2091 def __getattr__(self, name):
2092- return self.values.keys().index(name)
2093+ return list(self.values.keys()).index(name)
2094
2095 def convert2string(self,index):
2096- name = self.values.keys()[index]
2097+ name = list(self.values.keys())[index]
2098 return self.values[name][0]
2099+
2100+@six.add_metaclass(metaclass)
2101+class GraphicRenderType(object):
2102+ values = {'NONE' : ['none'] ,'ROOT':['Root'],'MATPLOTLIB':['Matplotlib']}
2103+
2104+
2105
2106=== modified file 'madanalysis/enumeration/linestyle_type.py'
2107--- madanalysis/enumeration/linestyle_type.py 2020-07-03 08:05:49 +0000
2108+++ madanalysis/enumeration/linestyle_type.py 2021-06-30 09:39:51 +0000
2109@@ -20,27 +20,31 @@
2110 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2111 #
2112 ################################################################################
2113-
2114-
2115-class LineStyleType(object):
2116- values = { 'SOLID' : [1,'solid','"solid"'],\
2117- 'DASHED' : [2,'dashed','"dashed"'],\
2118- 'DOTTED' : [3,'dotted','"dotted"'],\
2119- 'DASHDOTTED' : [4,'dash-dotted','"dashdot"'] }
2120-
2121- class __metaclass__(type):
2122+import six
2123+
2124+
2125+class metaclass(type):
2126
2127 def __getattr__(self, name):
2128- return self.values.keys().index(name)
2129+ return list(self.values.keys()).index(name)
2130
2131 def convert2code(self,color):
2132- name = self.values.keys()[color]
2133+ name = list(self.values.keys())[color]
2134 return self.values[name][0]
2135
2136 def convert2string(self,color):
2137- name = self.values.keys()[color]
2138+ name = list(self.values.keys())[color]
2139 return self.values[name][1]
2140
2141 def convert2matplotlib(self,style):
2142- name = self.values.keys()[style]
2143+ name = list(self.values.keys())[style]
2144 return self.values[name][2]
2145+
2146+
2147+@six.add_metaclass(metaclass)
2148+class LineStyleType(object):
2149+ values = { 'SOLID' : [1,'solid','"solid"'],\
2150+ 'DASHED' : [2,'dashed','"dashed"'],\
2151+ 'DOTTED' : [3,'dotted','"dotted"'],\
2152+ 'DASHDOTTED' : [4,'dash-dotted','"dashdot"'] }
2153+
2154
2155=== modified file 'madanalysis/enumeration/ma5_running_type.py'
2156--- madanalysis/enumeration/ma5_running_type.py 2020-07-03 08:05:49 +0000
2157+++ madanalysis/enumeration/ma5_running_type.py 2021-06-30 09:39:51 +0000
2158@@ -20,12 +20,15 @@
2159 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2160 #
2161 ################################################################################
2162-
2163-
2164+import six
2165+
2166+class metaclass(type):
2167+ def __getattr__(self, name):
2168+ return self.values.index(name)
2169+
2170+@six.add_metaclass(metaclass)
2171 class MA5RunningType(object):
2172 values = ['PARTON','HADRON','RECO']
2173
2174- class __metaclass__(type):
2175- def __getattr__(self, name):
2176- return self.values.index(name)
2177+
2178
2179
2180=== modified file 'madanalysis/enumeration/normalize_type.py'
2181--- madanalysis/enumeration/normalize_type.py 2020-07-03 08:05:49 +0000
2182+++ madanalysis/enumeration/normalize_type.py 2021-06-30 09:39:51 +0000
2183@@ -20,12 +20,15 @@
2184 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2185 #
2186 ################################################################################
2187-
2188-
2189+import six
2190+
2191+class metaclass(type):
2192+ def __getattr__(self, name):
2193+ return self.values.index(name)
2194+
2195+@six.add_metaclass(metaclass)
2196 class NormalizeType(object):
2197 values = ['NONE','LUMI','LUMI_WEIGHT']
2198
2199- class __metaclass__(type):
2200- def __getattr__(self, name):
2201- return self.values.index(name)
2202+
2203
2204
2205=== modified file 'madanalysis/enumeration/observable_type.py'
2206--- madanalysis/enumeration/observable_type.py 2020-07-03 08:05:49 +0000
2207+++ madanalysis/enumeration/observable_type.py 2021-06-30 09:39:51 +0000
2208@@ -22,58 +22,27 @@
2209 ################################################################################
2210
2211
2212+from __future__ import absolute_import
2213 from madanalysis.enumeration.ma5_running_type import MA5RunningType
2214 import math
2215-
2216-class ObservableType(object):
2217-
2218- # name : accept_particles
2219- values = { 'UNKNOWN' : [False,'','','','',0,0,0,False,False],\
2220- 'SQRTS' : [False,'PHYSICS->SqrtS(event.mc())','PHYSICS->SqrtS(event.mc())','','GeV',100,0.,1000., True, False],\
2221- 'TET' : [False,'PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.rec())','GeV',100,0.,1000., True,False],\
2222- 'MET' : [False,'PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.rec())','GeV',100,0.,1000., True,False],\
2223- 'THT' : [False,'PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.rec())','GeV',100,0.,1000., True,False],\
2224- 'MHT' : [False,'PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.rec())','GeV',100,0.,1000.,True,False],\
2225- 'WEIGHTS' : [False,'PHYSICS->weights(event.mc())','PHYSICS->weights(event.mc())','','',100,0.,1., True,False],\
2226- 'NPID': [False,'NPID','NPID','NPID','',100,0.,100.,False,False],\
2227- 'NAPID': [False,'NAPID','NAPID','NAPID','',100,0.,100.,False,False],\
2228- 'E' : [True,'e()','e()','e()','GeV',100,0.,1000.,True,True],\
2229- 'M' : [True,'m()','m()','m()','GeV/c^{2}',100,0.,1000.,True,True],\
2230- 'P' : [True,'p()','p()','p()','GeV/c',100,0.,1000.,True,True],\
2231- 'ET' : [True,'et()','et()','et()','GeV',100,0.,1000.,True,True],\
2232- 'MT' : [True,'mt()','mt()','mt()','GeV/c^{2}',100,0.,1000.,True,True],\
2233- 'PT' : [True,'pt()','pt()','pt()','GeV/c',100,0.,1000.,True,True],\
2234- 'PX' : [True,'px()','px()','px()','GeV/c',100,-1000.,1000.,True,True],\
2235- 'PY' : [True,'py()','py()','py()','GeV/c',100,-1000.,1000.,True,True],\
2236- 'PZ' : [True,'pz()','pz()','pz()','GeV/c',100,-1000.,1000.,True,True],\
2237- 'R' : [True,'r()','r()','r()','',100,0.,1000.,True,True],\
2238- 'THETA' : [True,'theta()','theta()','theta()','',100,0.,2*math.pi+0.01,True,True],\
2239- 'ETA' : [True,'eta()','eta()','eta()','',100,-8.0,+8.0,True,True],\
2240- 'PHI' : [True,'phi()','phi()','phi()','',100,0.,2*math.pi+0.01,True,True],\
2241- 'Y' : [True,'y()','y()','y()','',100,-8.0,+8.0,True,True],\
2242- 'BETA' : [True,'beta()','beta()','beta()','',100,0.,1.,True,True],\
2243- 'GAMMA': [True,'gamma()','gamma()','gamma()','',100,1.,1000.,True,True],\
2244- 'N' : [True,'N()','N()','N()','',20,0.,20.,True,True],\
2245- 'ISOL' : [True,'','','isolated()','',2,0,1,True,False],\
2246- 'HE_EE': [True,'','','HEoverEE()','',100,0,100,True,False],\
2247- 'NTRACKS': [True,'','','ntracks()','',100,0,100,True,False] }
2248-
2249- class __metaclass__(type):
2250+import six
2251+
2252+class metaclass(type):
2253 def __getattr__(self, name):
2254- if name in self.values.keys():
2255- return self.values.keys().index(name)
2256+ if name in list(self.values.keys()):
2257+ return list(self.values.keys()).index(name)
2258 else:
2259- return self.values.keys().index('UNKNOWN')
2260+ return list(self.values.keys()).index('UNKNOWN')
2261
2262 def accept_particles(self, index):
2263- name = self.values.keys()[index]
2264+ name = list(self.values.keys())[index]
2265 return self.values[name][0]
2266
2267 def convert2string(self,index):
2268- return self.values.keys()[index]
2269+ return list(self.values.keys())[index]
2270
2271 def convert2job_string(self,index,level):
2272- name = self.values.keys()[index]
2273+ name = list(self.values.keys())[index]
2274 if level==MA5RunningType.PARTON:
2275 return self.values[name][1]
2276 elif level==MA5RunningType.HADRON:
2277@@ -83,33 +52,35 @@
2278 return ""
2279
2280 def convert2unit(self,index):
2281- name = self.values.keys()[index]
2282+ name = list(self.values.keys())[index]
2283 return self.values[name][4]
2284
2285 def convert2nbins(self,index):
2286- name = self.values.keys()[index]
2287+ name = list(self.values.keys())[index]
2288 return self.values[name][5]
2289
2290 def convert2xmin(self,index):
2291- name = self.values.keys()[index]
2292+ name = list(self.values.keys())[index]
2293 return self.values[name][6]
2294
2295 def convert2xmax(self,index):
2296- name = self.values.keys()[index]
2297+ name = list(self.values.keys())[index]
2298 return self.values[name][7]
2299
2300 def isCuttable(self,index):
2301- name = self.values.keys()[index]
2302+ name = list(self.values.keys())[index]
2303 return self.values[name][8]
2304
2305 def prefix(self,index):
2306- name = self.values.keys()[index]
2307+ name = list(self.values.keys())[index]
2308 return self.values[name][9]
2309
2310- def get_list(self,level=MA5RunningType.PARTON):
2311+ def get_list(self,level=None):
2312+ if level == None:
2313+ level = MA5RunningType.PARTON
2314 output = []
2315 for item in self.values.keys():
2316- x = ObservableType.convert2job_string(self.values.keys().index(item),level)
2317+ x = ObservableType.convert2job_string(list(self.values.keys()).index(item),level)
2318 if x=="":
2319 continue
2320 output.append(item)
2321@@ -124,13 +95,15 @@
2322 output.append('r'+item)
2323 return output
2324
2325- def get_cutlist1(self,level=MA5RunningType.PARTON):
2326+ def get_cutlist1(self,level=None):
2327+ if level is None:
2328+ level = MA5RunningType.PARTON
2329 output = []
2330 for item in self.values.keys():
2331 if item=="N":
2332 output.append(item)
2333 continue
2334- x = ObservableType.convert2job_string(self.values.keys().index(item),level)
2335+ x = ObservableType.convert2job_string(list(self.values.keys()).index(item),level)
2336 if x=="":
2337 continue
2338 if not self.values[item][8]:
2339@@ -140,10 +113,12 @@
2340 output.append(item)
2341 return output
2342
2343- def get_cutlist2(self,level=MA5RunningType.PARTON):
2344+ def get_cutlist2(self,level=None):
2345+ if level is None:
2346+ level = MA5RunningType.PARTON
2347 output = []
2348 for item in self.values.keys():
2349- x = ObservableType.convert2job_string(self.values.keys().index(item),level)
2350+ x = ObservableType.convert2job_string(list(self.values.keys()).index(item),level)
2351 if item=="N":
2352 continue
2353 if x=="":
2354@@ -169,3 +144,39 @@
2355
2356
2357
2358+
2359+
2360+@six.add_metaclass(metaclass)
2361+class ObservableType(object):
2362+
2363+ # name : accept_particles
2364+ values = { 'UNKNOWN' : [False,'','','','',0,0,0,False,False],\
2365+ 'SQRTS' : [False,'PHYSICS->SqrtS(event.mc())','PHYSICS->SqrtS(event.mc())','','GeV',100,0.,1000., True, False],\
2366+ 'TET' : [False,'PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.rec())','GeV',100,0.,1000., True,False],\
2367+ 'MET' : [False,'PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.rec())','GeV',100,0.,1000., True,False],\
2368+ 'THT' : [False,'PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.rec())','GeV',100,0.,1000., True,False],\
2369+ 'MHT' : [False,'PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.rec())','GeV',100,0.,1000.,True,False],\
2370+ 'WEIGHTS' : [False,'PHYSICS->weights(event.mc())','PHYSICS->weights(event.mc())','','',100,0.,1., True,False],\
2371+ 'NPID': [False,'NPID','NPID','NPID','',100,0.,100.,False,False],\
2372+ 'NAPID': [False,'NAPID','NAPID','NAPID','',100,0.,100.,False,False],\
2373+ 'E' : [True,'e()','e()','e()','GeV',100,0.,1000.,True,True],\
2374+ 'M' : [True,'m()','m()','m()','GeV/c^{2}',100,0.,1000.,True,True],\
2375+ 'P' : [True,'p()','p()','p()','GeV/c',100,0.,1000.,True,True],\
2376+ 'ET' : [True,'et()','et()','et()','GeV',100,0.,1000.,True,True],\
2377+ 'MT' : [True,'mt()','mt()','mt()','GeV/c^{2}',100,0.,1000.,True,True],\
2378+ 'PT' : [True,'pt()','pt()','pt()','GeV/c',100,0.,1000.,True,True],\
2379+ 'PX' : [True,'px()','px()','px()','GeV/c',100,-1000.,1000.,True,True],\
2380+ 'PY' : [True,'py()','py()','py()','GeV/c',100,-1000.,1000.,True,True],\
2381+ 'PZ' : [True,'pz()','pz()','pz()','GeV/c',100,-1000.,1000.,True,True],\
2382+ 'R' : [True,'r()','r()','r()','',100,0.,1000.,True,True],\
2383+ 'THETA' : [True,'theta()','theta()','theta()','',100,0.,2*math.pi+0.01,True,True],\
2384+ 'ETA' : [True,'eta()','eta()','eta()','',100,-8.0,+8.0,True,True],\
2385+ 'PHI' : [True,'phi()','phi()','phi()','',100,0.,2*math.pi+0.01,True,True],\
2386+ 'Y' : [True,'y()','y()','y()','',100,-8.0,+8.0,True,True],\
2387+ 'BETA' : [True,'beta()','beta()','beta()','',100,0.,1.,True,True],\
2388+ 'GAMMA': [True,'gamma()','gamma()','gamma()','',100,1.,1000.,True,True],\
2389+ 'N' : [True,'N()','N()','N()','',20,0.,20.,True,True],\
2390+ 'ISOL' : [True,'','','isolated()','',2,0,1,True,False],\
2391+ 'HE_EE': [True,'','','HEoverEE()','',100,0,100,True,False],\
2392+ 'NTRACKS': [True,'','','ntracks()','',100,0,100,True,False] }
2393+
2394
2395=== modified file 'madanalysis/enumeration/operator_type.py'
2396--- madanalysis/enumeration/operator_type.py 2020-07-03 08:05:49 +0000
2397+++ madanalysis/enumeration/operator_type.py 2021-06-30 09:39:51 +0000
2398@@ -20,8 +20,25 @@
2399 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2400 #
2401 ################################################################################
2402-
2403-
2404+import six
2405+
2406+class metaclass(type):
2407+
2408+ def __getattr__(self, name):
2409+ if name in list(self.values.keys()):
2410+ return list(self.values.keys()).index(name)
2411+ else:
2412+ return list(self.values.keys()).index('UNKNOWN')
2413+
2414+ def convert2string(self,op):
2415+ name = list(self.values.keys())[op]
2416+ return self.values[name][0]
2417+
2418+ def convert2cpp(self,op):
2419+ name = list(self.values.keys())[op]
2420+ return self.values[name][1]
2421+
2422+@six.add_metaclass(metaclass)
2423 class OperatorType(object):
2424 values = { 'GREATER' : [">",">"],\
2425 'GREATER_EQUAL' : [">=",">="],\
2426@@ -32,18 +49,4 @@
2427 'UNKNOWN' : ["",""]
2428 }
2429
2430- class __metaclass__(type):
2431-
2432- def __getattr__(self, name):
2433- if name in self.values.keys():
2434- return self.values.keys().index(name)
2435- else:
2436- return self.values.keys().index('UNKNOWN')
2437-
2438- def convert2string(self,op):
2439- name = self.values.keys()[op]
2440- return self.values[name][0]
2441-
2442- def convert2cpp(self,op):
2443- name = self.values.keys()[op]
2444- return self.values[name][1]
2445+
2446
2447=== modified file 'madanalysis/enumeration/report_format_type.py'
2448--- madanalysis/enumeration/report_format_type.py 2020-07-03 08:05:49 +0000
2449+++ madanalysis/enumeration/report_format_type.py 2021-06-30 09:39:51 +0000
2450@@ -20,26 +20,30 @@
2451 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2452 #
2453 ################################################################################
2454-
2455-
2456+import six
2457+
2458+class metaclass(type):
2459+
2460+ def __getattr__(self, name):
2461+ return list(self.values.keys()).index(name)
2462+
2463+ def convert2cmd(self,format):
2464+ name = list(self.values.keys())[format]
2465+ return self.values[name][0]
2466+
2467+ def convert2string(self,format):
2468+ return list(self.values.keys())[format]
2469+
2470+ def convert2filetype(self,format):
2471+ name = list(self.values.keys())[format]
2472+ return self.values[name][1]
2473+
2474+
2475+@six.add_metaclass(metaclass)
2476 class ReportFormatType(object):
2477 values = { 'LATEX' : ['generate_latex','eps'],\
2478 'PDFLATEX' : ['generate_pdflatex','png'],\
2479 'HTML' : ['generate_html','png'] }
2480
2481- class __metaclass__(type):
2482-
2483- def __getattr__(self, name):
2484- return self.values.keys().index(name)
2485-
2486- def convert2cmd(self,format):
2487- name = self.values.keys()[format]
2488- return self.values[name][0]
2489-
2490- def convert2string(self,format):
2491- return self.values.keys()[format]
2492-
2493- def convert2filetype(self,format):
2494- name = self.values.keys()[format]
2495- return self.values[name][1]
2496+
2497
2498
2499=== modified file 'madanalysis/enumeration/sb_ratio_type.py'
2500--- madanalysis/enumeration/sb_ratio_type.py 2020-07-03 08:05:49 +0000
2501+++ madanalysis/enumeration/sb_ratio_type.py 2021-06-30 09:39:51 +0000
2502@@ -20,20 +20,23 @@
2503 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2504 #
2505 ################################################################################
2506-
2507-
2508+import six
2509+
2510+class metaclass(type):
2511+ def __getattr__(self, name):
2512+ return list(self.values.keys()).index(name)
2513+
2514+ def convert2string(self,val):
2515+ name = list(self.values.keys())[val]
2516+ return self.values[name][0]
2517+
2518+@six.add_metaclass(metaclass)
2519 class SBratioType(object):
2520 values = {'S_OVER_B' : ['S/B'],\
2521 'B_OVER_S' : ['B/S'],\
2522 'S_OVER_SB': ['S/sqrt(S+B)']}
2523
2524- class __metaclass__(type):
2525- def __getattr__(self, name):
2526- return self.values.keys().index(name)
2527-
2528- def convert2string(self,val):
2529- name = self.values.keys()[val]
2530- return self.values[name][0]
2531+
2532
2533
2534
2535
2536=== modified file 'madanalysis/enumeration/script_type.py'
2537--- madanalysis/enumeration/script_type.py 2020-07-03 08:05:49 +0000
2538+++ madanalysis/enumeration/script_type.py 2021-06-30 09:39:51 +0000
2539@@ -20,29 +20,32 @@
2540 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2541 #
2542 ################################################################################
2543-
2544-
2545+import six
2546+
2547+class metaclass(type):
2548+ def __getattr__(self, name):
2549+ return list(self.values.keys()).index(name)
2550+
2551+ def latexscript(self,script):
2552+ name = list(self.values.keys())[script]
2553+ return self.values[name][0]
2554+
2555+ def latexscriptclose(self,script):
2556+ name = list(self.values.keys())[script]
2557+ return self.values[name][1]
2558+
2559+ def htmlscript(self,script):
2560+ name = list(self.values.keys())[script]
2561+ return self.values[name][2]
2562+
2563+ def htmlscriptclose(self,script):
2564+ name = list(self.values.keys())[script]
2565+ return self.values[name][3]
2566+
2567+
2568+@six.add_metaclass(metaclass)
2569 class ScriptType(object):
2570 values = {'none' : ['','','',''],\
2571 'SUB' : ['$_{','}$','<sub>','</sub>'],\
2572 'SUP' : ['$^{','}$','<sup>','</sup>']}
2573
2574- class __metaclass__(type):
2575- def __getattr__(self, name):
2576- return self.values.keys().index(name)
2577-
2578- def latexscript(self,script):
2579- name = self.values.keys()[script]
2580- return self.values[name][0]
2581-
2582- def latexscriptclose(self,script):
2583- name = self.values.keys()[script]
2584- return self.values[name][1]
2585-
2586- def htmlscript(self,script):
2587- name = self.values.keys()[script]
2588- return self.values[name][2]
2589-
2590- def htmlscriptclose(self,script):
2591- name = self.values.keys()[script]
2592- return self.values[name][3]
2593
2594=== modified file 'madanalysis/enumeration/special_particle.py'
2595--- madanalysis/enumeration/special_particle.py 2020-07-03 08:05:49 +0000
2596+++ madanalysis/enumeration/special_particle.py 2021-06-30 09:39:51 +0000
2597@@ -20,12 +20,15 @@
2598 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2599 #
2600 ################################################################################
2601-
2602-
2603+import six
2604+
2605+class metaclass(type):
2606+ def __getattr__(self, name):
2607+ return self.values.index(name)
2608+
2609+
2610+@six.add_metaclass(metaclass)
2611 class SpecialParticleType(object):
2612 values = ['NONE','ALL']
2613
2614- class __metaclass__(type):
2615- def __getattr__(self, name):
2616- return self.values.index(name)
2617
2618
2619=== modified file 'madanalysis/enumeration/stacking_method_type.py'
2620--- madanalysis/enumeration/stacking_method_type.py 2020-07-03 08:05:49 +0000
2621+++ madanalysis/enumeration/stacking_method_type.py 2021-06-30 09:39:51 +0000
2622@@ -20,12 +20,15 @@
2623 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2624 #
2625 ################################################################################
2626-
2627-
2628+import six
2629+
2630+class metaclass(type):
2631+ def __getattr__(self, name):
2632+ return self.values.index(name)
2633+
2634+@six.add_metaclass(metaclass)
2635 class StackingMethodType(object):
2636 values = ['AUTO','STACK','SUPERIMPOSE','NORMALIZE2ONE']
2637
2638- class __metaclass__(type):
2639- def __getattr__(self, name):
2640- return self.values.index(name)
2641+
2642
2643
2644=== modified file 'madanalysis/enumeration/uncertainty_type.py'
2645--- madanalysis/enumeration/uncertainty_type.py 2020-07-03 08:05:49 +0000
2646+++ madanalysis/enumeration/uncertainty_type.py 2021-06-30 09:39:51 +0000
2647@@ -20,11 +20,14 @@
2648 # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2649 #
2650 ################################################################################
2651-
2652-
2653+import six
2654+
2655+class metaclass(type):
2656+ def __getattr__(self, name):
2657+ return self.values.index(name)
2658+
2659+
2660+@six.add_metaclass(metaclass)
2661 class UncertaintyType(object):
2662 values = ['POISSON','BINOMIAL','IMPROVED']
2663
2664- class __metaclass__(type):
2665- def __getattr__(self, name):
2666- return self.values.index(name)
2667
2668=== modified file 'madanalysis/fastsim/ast.py'
2669--- madanalysis/fastsim/ast.py 2020-07-03 08:05:49 +0000
2670+++ madanalysis/fastsim/ast.py 2021-06-30 09:39:51 +0000
2671@@ -22,10 +22,13 @@
2672 ################################################################################
2673
2674
2675+from __future__ import absolute_import
2676+from __future__ import print_function
2677 import logging
2678 import re
2679 from madanalysis.fastsim.ast_leaf import Leaf
2680 import madanalysis.observable.observable_list as obs_list
2681+from six.moves import range
2682
2683
2684 class AST:
2685@@ -144,7 +147,7 @@
2686 reset=True
2687 break
2688 else:
2689- print frml[i]
2690+ print(frml[i])
2691 aieaieaaie
2692 if reset:
2693 continue
2694@@ -171,7 +174,7 @@
2695 replacement_done = True
2696 break
2697 else:
2698- print(frml, i, '->', frml[i])
2699+ print((frml, i, '->', frml[i]))
2700 aieaieaaie2
2701 if replacement_done:
2702 break
2703@@ -208,7 +211,7 @@
2704 new_formula.append(new_leaf)
2705 self.leaves.append(new_leaf)
2706 # unary operators
2707- elif elem.lower() in self.binary1_ops.keys():
2708+ elif elem.lower() in list(self.binary1_ops.keys()):
2709 new_leaf = Leaf(self.size(), 'bin1_op', elem.lower(), [], [])
2710 new_formula.append(new_leaf)
2711 self.leaves.append(new_leaf)
2712
2713=== modified file 'madanalysis/fastsim/ast_leaf.py'
2714--- madanalysis/fastsim/ast_leaf.py 2020-07-03 08:05:49 +0000
2715+++ madanalysis/fastsim/ast_leaf.py 2021-06-30 09:39:51 +0000
2716@@ -22,6 +22,7 @@
2717 ################################################################################
2718
2719
2720+from __future__ import absolute_import
2721 import logging
2722 class Leaf:
2723
2724
2725=== modified file 'madanalysis/fastsim/fastsim.py'
2726--- madanalysis/fastsim/fastsim.py 2020-07-03 08:05:49 +0000
2727+++ madanalysis/fastsim/fastsim.py 2021-06-30 09:39:51 +0000
2728@@ -22,11 +22,14 @@
2729 ################################################################################
2730
2731
2732+from __future__ import absolute_import
2733 import logging
2734 from madanalysis.fastsim.ast import AST
2735 from madanalysis.fastsim.tagger import Tagger
2736 from madanalysis.fastsim.smearer import Smearer
2737 from madanalysis.fastsim.recoefficiency import RecoEfficiency
2738+from madanalysis.fastsim.scaling import Scaling
2739+from six.moves import range
2740
2741
2742 class SuperFastSim:
2743@@ -37,7 +40,12 @@
2744 self.tagger = Tagger()
2745 self.smearer = Smearer()
2746 self.reco = RecoEfficiency()
2747+ self.scaling = Scaling()
2748 self.jetrecomode = 'jets'
2749+ self.mag_field = 1e-9
2750+ self.radius = 1e+99
2751+ self.half_length = 1e+99
2752+ self.propagator = False
2753 self.observables = ''
2754
2755 def InitObservables(self, obs_list):
2756@@ -46,23 +54,38 @@
2757 # Definition of a new tagging/smearing rule
2758 def define(self,args,prts):
2759 prts.Add('c',[4])
2760+ prts.Add('track',[]) # PDGID is not important
2761+ prts.Add('JES', []) # PDGID is not important
2762+ prts_remove = ['c','track','JES']
2763+
2764+ ## remove all initializations when this session is over
2765+ def remove_prts_def(prts_remove,prts):
2766+ for particle in prts_remove:
2767+ prts.Remove(particle, None)
2768+
2769 ## list of PDG codes associated with a a multiparticle
2770 def is_pdgcode(prt):
2771 return (prt[0] in ('-','+') and prt[1:].isdigit()) or prt.isdigit()
2772
2773 ## Checking the length of the argument list
2774 if (args[0]=='tagger' and len(args)<5) or (args[0]=='smearer' and len(args)<3) \
2775- or (args[0]=='reco_efficiency' and len(args)<3):
2776- self.logger.error('Not enough arguments for a tagger/smearer/reconstruction')
2777- prts.Remove('c', None)
2778+ or (args[0]=='reco_efficiency' and len(args)<3) or (args[0]=='jes' and len(args)<2) \
2779+ or (args[0]=='energy_scaling' and len(args)<3) or (args[0]=='scaling' and len(args)<4):
2780+ self.logger.error('Not enough arguments for tagging/smearing/reconstruction/scaling')
2781+ remove_prts_def(prts_remove,prts)
2782 return
2783
2784 ## Checking the first argument
2785- true_id = args[1]
2786+ if args[0]=='jes':
2787+ true_id = 'JES'
2788+ elif args[0]=='scaling':
2789+ true_id = args[3]
2790+ else:
2791+ true_id = args[1]
2792 #### First, do we have either a multiparticle or a PDG code
2793 if not (true_id in prts.GetNames() or is_pdgcode(true_id)):
2794 self.logger.error('the 1st argument must be a PDG code or (multi)particle label')
2795- prts.Remove('c', None)
2796+ remove_prts_def(prts_remove,prts)
2797 return
2798 #### Second let's check if we have a multiparticle associated with a unique PDGID
2799 if true_id in prts.GetNames() and len(list(set([abs(x) for x in prts[true_id]])))==1:
2800@@ -78,13 +101,13 @@
2801 if args[0]=='tagger':
2802 if args[2]!='as':
2803 self.logger.error('the 2nd argument must be the keyword \'as\'')
2804- prts.Remove('c', None)
2805+ remove_prts_def(prts_remove,prts)
2806 return
2807 reco_id = args[3]
2808 #### First, do we have either a multiparticle or a PDG code
2809 if not (reco_id in prts.GetNames() or is_pdgcode(reco_id)):
2810 self.logger.error('the 4th argument must be a PDG code or (multi)particle label')
2811- prts.Remove('c', None)
2812+ remove_prts_def(prts_remove,prts)
2813 return
2814 #### Second let's check if we have a multiparticle associated with a unique PDGID
2815 if reco_id in prts.GetNames() and len(list(set([abs(x) for x in prts[reco_id]])))==1:
2816@@ -101,12 +124,12 @@
2817 elif args[0] == 'smearer':
2818 if args[2]!='with':
2819 self.logger.error('the 2nd argument must be the keyword \'with\'')
2820- prts.Remove('c', None)
2821+ remove_prts_def(prts_remove,prts)
2822 return
2823 obs = args[3].upper()
2824 if not (obs in self.smearer.vars):
2825 self.logger.error('the 4th argument must be an observable in '+ ', '.join(self.smearer.vars))
2826- prts.Remove('c', None)
2827+ remove_prts_def(prts_remove,prts)
2828 return
2829 to_decode=args[4:]
2830
2831@@ -114,11 +137,30 @@
2832 elif args[0] == 'reco_efficiency':
2833 to_decode=args[2:]
2834
2835+ ## Jet energy scaling (and scaling in general)
2836+ elif args[0]=='jes':
2837+ to_decode=args[1:]
2838+ obs = 'E'
2839+ elif args[0]=='energy_scaling':
2840+ to_decode=args[2:]
2841+ obs = 'E'
2842+ elif args[0]=='scaling':
2843+ if args[2]!='for':
2844+ self.logger.error('Scaling - the 2nd argument must be the keyword \'for\'')
2845+ remove_prts_def(prts_remove,prts)
2846+ return
2847+ obs = args[1].upper()
2848+ if not (obs in self.scaling.vars):
2849+ self.logger.error('Scaling - the 1st argument must be an observable in '+ ', '.join(self.scaling.vars))
2850+ remove_prts_def(prts_remove,prts)
2851+ return
2852+ to_decode=args[4:]
2853+
2854 ## Getting the bounds and the function
2855 function, bounds = self.decode_args(to_decode)
2856 if function=='':
2857 self.logger.error('Cannot decode the function or the bounds - ' + args[0] + ' ignored.')
2858- prts.Remove('c', None)
2859+ remove_prts_def(prts_remove,prts)
2860 return
2861
2862 ## Adding a rule to a tagger/smearer
2863@@ -128,7 +170,9 @@
2864 self.smearer.add_rule(true_id,obs,function,bounds)
2865 elif args[0]=='reco_efficiency':
2866 self.reco.add_rule(true_id,function,bounds)
2867- prts.Remove('c', None)
2868+ elif args[0] in ['jes','energy_scaling','scaling']:
2869+ self.scaling.add_rule(true_id,obs,function,bounds)
2870+ remove_prts_def(prts_remove,prts)
2871 return
2872
2873
2874@@ -184,6 +228,8 @@
2875 ast_eff.feed(efficiency)
2876 return ast_eff, ast_bounds
2877
2878+
2879+
2880 # Display of a taggers/smearer
2881 def display(self,args):
2882 if args[0]=='tagger':
2883@@ -192,6 +238,28 @@
2884 self.smearer.display(self.jetrecomode)
2885 elif args[0]=='reco_efficiency':
2886 self.reco.display()
2887+ elif args[0] in ['jes','energy_scaling','scaling']:
2888+ self.scaling.display(self.jetrecomode)
2889 return
2890
2891
2892+
2893+ # On/off checks
2894+ def isRecoOn(self):
2895+ return self.reco.rules != {}
2896+ def isTaggerOn(self):
2897+ return self.tagger.rules != {}
2898+ def isSmearerOn(self):
2899+ return self.smearer.rules != {}
2900+ def isPropagatorOn(self):
2901+ return self.propagator
2902+ def isScalingOn(self):
2903+ return self.scaling.rules != {}
2904+ def isRecoSmearerOn(self):
2905+ # all modules that modifies new_smearer body
2906+ return (self.isScalingOn() or self.isSmearerOn() or self.isRecoOn())
2907+ def isNewSmearerOn(self):
2908+ # all modules that modifies new_smearer header
2909+ return (self.isRecoSmearerOn() or self.isPropagatorOn())
2910+ def isSFSOn(self):
2911+ return (self.isNewSmearerOn() or self.isTaggerOn())
2912
2913=== modified file 'madanalysis/fastsim/recoefficiency.py'
2914--- madanalysis/fastsim/recoefficiency.py 2020-07-03 08:05:49 +0000
2915+++ madanalysis/fastsim/recoefficiency.py 2021-06-30 09:39:51 +0000
2916@@ -22,6 +22,7 @@
2917 ################################################################################
2918
2919
2920+from __future__ import absolute_import
2921 import logging
2922 class RecoEfficiency:
2923
2924@@ -38,11 +39,11 @@
2925 if not self.is_supported(id_reco):
2926 return
2927 ## Checking whether the reco/true pair already exists
2928- key_number=len(self.rules.keys())+1
2929+ key_number=len(list(self.rules.keys()))+1
2930 for key, value in self.rules.items():
2931 if value['id_reco']==id_reco:
2932 key_number = key
2933- if not key_number in self.rules.keys():
2934+ if not key_number in list(self.rules.keys()):
2935 self.rules[key_number] = { 'id_reco':id_reco, 'efficiencies':{} }
2936
2937 ## Defining a new rule ID for an existing tagger
2938@@ -73,8 +74,8 @@
2939
2940
2941 def is_supported(self, id_reco):
2942- supported = {'e':'11', 'mu':'13', 'ta':'15', 'j':'21', 'a':'22'}
2943- if id_reco in (supported.keys()+supported.values()):
2944+ supported = {'e':'11', 'mu':'13', 'ta':'15', 'j':'21', 'a':'22', 'track':'track'}
2945+ if id_reco in (list(supported.keys())+list(supported.values())):
2946 return True
2947 self.logger.error('The reconstruction of such an object (' + id_reco + ') is currently not supported.'+\
2948 ' Reconstruction ignored.')
2949
2950=== added file 'madanalysis/fastsim/scaling.py'
2951--- madanalysis/fastsim/scaling.py 1970-01-01 00:00:00 +0000
2952+++ madanalysis/fastsim/scaling.py 2021-06-30 09:39:51 +0000
2953@@ -0,0 +1,104 @@
2954+################################################################################
2955+#
2956+# Copyright (C) 2012-2020 Jack Araz, Eric Conte & Benjamin Fuks
2957+# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
2958+#
2959+# This file is part of MadAnalysis 5.
2960+# Official website: <https://launchpad.net/madanalysis5>
2961+#
2962+# MadAnalysis 5 is free software: you can redistribute it and/or modify
2963+# it under the terms of the GNU General Public License as published by
2964+# the Free Software Foundation, either version 3 of the License, or
2965+# (at your option) any later version.
2966+#
2967+# MadAnalysis 5 is distributed in the hope that it will be useful,
2968+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2969+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2970+# GNU General Public License for more details.
2971+#
2972+# You should have received a copy of the GNU General Public License
2973+# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
2974+#
2975+################################################################################
2976+
2977+
2978+from __future__ import absolute_import
2979+import logging
2980+class Scaling:
2981+
2982+ # Initialization
2983+ def __init__(self):
2984+ self.logger = logging.getLogger('MA5');
2985+ self.rules = {}
2986+ self.vars = ['PT','ETA','PHI','E','PX','PY','PZ']
2987+
2988+
2989+ # Adding a rule to the tagger
2990+ # The bounds and function are written as ASTs
2991+ # JES option is to make sure that the jet scaling is only applied on
2992+ # clustered jets
2993+ def add_rule(self, id_true, obs, function, bounds):
2994+ ## Checking whether the smearer is supported
2995+ check, id_true = self.is_supported(id_true, obs)
2996+ if not check:
2997+ return
2998+ ## Checking whether the reco/true pair already exists
2999+ key_number=len(list(self.rules.keys()))+1
3000+ for key, value in self.rules.items():
3001+ if value['id_true']==id_true and value['obs']==obs:
3002+ key_number = key
3003+ if not key_number in list(self.rules.keys()):
3004+ self.rules[key_number] = { 'id_true':id_true, 'obs':obs,
3005+ 'efficiencies':{}}
3006+
3007+ ## Defining a new rule ID for an existing tagger
3008+ eff_key = len(self.rules[key_number]['efficiencies'])+1
3009+ self.rules[key_number]['efficiencies'][eff_key] = { 'function':function,
3010+ 'bounds': bounds }
3011+
3012+
3013+ def display(self, jetrecomode):
3014+ self.logger.info('*********************************')
3015+ self.logger.info(' Scaling information ')
3016+ self.logger.info('*********************************')
3017+ if list(self.rules.keys()) != []:
3018+ self.logger.info(' - Running in the '+jetrecomode+' reconstruction mode.')
3019+ for key in self.rules.keys():
3020+ myrule = self.rules[key]
3021+ if myrule['id_true'] == 'JES':
3022+ self.logger.info(str(key) + ' - Jet Energy Scaling')
3023+ else:
3024+ self.logger.info(str(key) + ' - Scaling an object of PDG ' + str(myrule['id_true']) + \
3025+ ' from the observable ' + str(myrule['obs']))
3026+ for eff_key in myrule['efficiencies'].keys():
3027+ cpp_name = 'scale_'+str(myrule['id_true'])+'_'+str(myrule['obs'])+\
3028+ '_'+str(eff_key)
3029+ bnd_name = 'bnd_'+str(myrule['id_true'])+'_'+str(myrule['obs'])+\
3030+ '_'+str(eff_key)
3031+ myeff = myrule['efficiencies'][eff_key]
3032+ self.logger.info(' ** function: ' + myeff['function'].tostring())
3033+ self.logger.info(' ** bounds: ' + myeff['bounds'].tostring())
3034+ self.logger.debug(' C++ version for the function: \n ' + \
3035+ myeff['function'].tocpp('MAdouble64', cpp_name).replace('\n','\n '))
3036+ self.logger.debug(' C++ version for the bounds: \n ' + \
3037+ myeff['bounds'].tocpp('MAbool', bnd_name).replace('\n','\n '))
3038+ self.logger.info(' --------------------')
3039+ self.logger.info(' --------------------')
3040+
3041+
3042+ def is_supported(self,id_true,obs):
3043+ supported = {'e':'11', 'mu':'13', 'ta':'15', 'j':'21', 'a':'22', 'track':'track', 'JES':'JES'}
3044+ if not obs in self.vars:
3045+ self.logger.error('Unsupported scaling. The scaling variable must be part of ' + \
3046+ ', '.join(self.vars))
3047+ self.logger.error('Scaling ignored')
3048+ return False, id_true
3049+ if id_true in list(supported.keys()):
3050+ return True, supported[id_true]
3051+ elif id_true in list(supported.values()):
3052+ return True, id_true
3053+ else:
3054+ self.logger.error('Unsupported scaling ('+id_true+'). Only the following objects can be scaled: '\
3055+ + ', '.join(list(supported.keys())))
3056+ self.logger.error('Scaling ignored')
3057+ return False, id_true
3058
3059=== modified file 'madanalysis/fastsim/smearer.py'
3060--- madanalysis/fastsim/smearer.py 2020-07-03 08:05:49 +0000
3061+++ madanalysis/fastsim/smearer.py 2021-06-30 09:39:51 +0000
3062@@ -22,6 +22,7 @@
3063 ################################################################################
3064
3065
3066+from __future__ import absolute_import
3067 import logging
3068 class Smearer:
3069
3070@@ -29,7 +30,7 @@
3071 def __init__(self):
3072 self.logger = logging.getLogger('MA5');
3073 self.rules = {}
3074- self.vars = ['PT','ETA','PHI','E','PX','PY','PZ']
3075+ self.vars = ['PT','ETA','PHI','E','PX','PY','PZ','D0','DZ']
3076
3077
3078 # Adding a rule to the tagger
3079@@ -40,11 +41,11 @@
3080 if not check:
3081 return
3082 ## Checking whether the reco/true pair already exists
3083- key_number=len(self.rules.keys())+1
3084+ key_number=len(list(self.rules.keys()))+1
3085 for key, value in self.rules.items():
3086 if value['id_true']==id_true and value['obs']==obs:
3087 key_number = key
3088- if not key_number in self.rules.keys():
3089+ if not key_number in list(self.rules.keys()):
3090 self.rules[key_number] = { 'id_true':id_true, 'obs':obs,
3091 'efficiencies':{} }
3092
3093@@ -58,7 +59,7 @@
3094 self.logger.info('*********************************')
3095 self.logger.info(' Smearer information ')
3096 self.logger.info('*********************************')
3097- if self.rules.keys() != []:
3098+ if list(self.rules.keys()) != []:
3099 self.logger.info(' - Running in the '+jetrecomode+' reconstruction mode.')
3100 for key in self.rules.keys():
3101 myrule = self.rules[key]
3102@@ -81,18 +82,18 @@
3103
3104
3105 def is_supported(self,id_true,obs):
3106- supported = {'e':'11', 'mu':'13', 'ta':'15', 'j':'21', 'a':'22'}
3107+ supported = {'e':'11', 'mu':'13', 'ta':'15', 'j':'21', 'a':'22', 'track':'track'}
3108 if not obs in self.vars:
3109 self.logger.error('Unsupported smearer. The smeared variable must be part of ' + \
3110 ', '.join(self.vars))
3111 self.logger.error('Smearer ignored')
3112 return False, id_true
3113- if id_true in supported.keys():
3114+ if id_true in list(supported.keys()):
3115 return True, supported[id_true]
3116- elif id_true in supported.values():
3117+ elif id_true in list(supported.values()):
3118 return True, id_true
3119 else:
3120 self.logger.error('Unsupported smearer ('+id_true+'). Only the following objects can be smeared: '\
3121- + ', '.join(supported.keys()))
3122+ + ', '.join(list(supported.keys())))
3123 self.logger.error('Smearer ignored')
3124 return False, id_true
3125
3126=== modified file 'madanalysis/fastsim/tagger.py'
3127--- madanalysis/fastsim/tagger.py 2020-07-03 08:05:49 +0000
3128+++ madanalysis/fastsim/tagger.py 2021-06-30 09:39:51 +0000
3129@@ -22,6 +22,7 @@
3130 ################################################################################
3131
3132
3133+from __future__ import absolute_import
3134 import logging
3135 class Tagger:
3136
3137@@ -38,11 +39,11 @@
3138 if not self.is_supported(id_true, id_reco):
3139 return
3140 ## Checking whether the reco/true pair already exists
3141- key_number=len(self.rules.keys())+1
3142+ key_number=len(list(self.rules.keys()))+1
3143 for key, value in self.rules.items():
3144 if value['id_true']==id_true and value['id_reco']==id_reco:
3145 key_number = key
3146- if not key_number in self.rules.keys():
3147+ if not key_number in list(self.rules.keys()):
3148 self.rules[key_number] = { 'id_true':id_true, 'id_reco':id_reco,
3149 'efficiencies':{} }
3150
3151@@ -80,7 +81,7 @@
3152 supported = { '5':['21','4','5'], '4':['21','4','5'], '15':['15','21'],
3153 '21' : ['11','13','22'], '11' : ['13','22', '21'],
3154 '13' : ['11','22'], '22' : ['11','13', '21']}
3155- if id_reco not in supported.keys() or id_true not in supported[id_reco]:
3156+ if id_reco not in list(supported.keys()) or id_true not in supported[id_reco]:
3157 self.logger.error('This tagger is currently not supported (tagging '+ id_true + ' as ' + id_reco + '). Tagger ignored.')
3158 return False
3159 return True
3160
3161=== modified file 'madanalysis/install/detector_manager.py'
3162--- madanalysis/install/detector_manager.py 2020-07-03 08:05:49 +0000
3163+++ madanalysis/install/detector_manager.py 2021-06-30 09:39:51 +0000
3164@@ -22,6 +22,7 @@
3165 ################################################################################
3166
3167
3168+from __future__ import absolute_import
3169 from madanalysis.install.install_manager import InstallManager
3170 class DetectorManager():
3171
3172
3173=== modified file 'madanalysis/install/install_delphes.py'
3174--- madanalysis/install/install_delphes.py 2020-07-03 08:05:49 +0000
3175+++ madanalysis/install/install_delphes.py 2021-06-30 09:39:51 +0000
3176@@ -22,6 +22,7 @@
3177 ################################################################################
3178
3179
3180+from __future__ import absolute_import
3181 from madanalysis.install.install_service import InstallService
3182 from madanalysis.system.user_info import UserInfo
3183 from madanalysis.system.config_checker import ConfigChecker
3184@@ -48,15 +49,12 @@
3185 self.downloaddir = self.main.session_info.downloaddir
3186 self.untardir = os.path.join(self.tmpdir, 'MA5_'+self.package)
3187 self.ncores = 1
3188-# self.files = {"delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.1.1.tar.gz"}
3189-# self.files = {"delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.3.0.tar.gz"}
3190-# self.files = {"delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.3.1.tar.gz"}
3191-# self.files = {"delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.3.3.tar.gz"}
3192 if package == 'delphesma5tune':
3193- self.files = {package+".tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.1.tar.gz"}
3194+ self.files = {package+".tar.gz" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/delphes-3.5.0.tar.gz"}
3195 else:
3196 # self.files = {package+".tar.gz" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/WikiStart/delphes342pre.tar.gz"} # Delphes for LLP not release yet
3197- self.files = {package+".tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.2.tar.gz"}
3198+# self.files = {package+".tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.2.tar.gz"}
3199+ self.files = {package+".tar.gz" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/delphes3.4.3.tar.gz"}
3200 self.logger = logging.getLogger('MA5')
3201
3202
3203@@ -406,6 +404,49 @@
3204 return True
3205
3206
3207+ def AddD0(self,filename):
3208+ # open input file
3209+ try:
3210+ input = open(filename)
3211+ except:
3212+ self.logger.error("impossible to read the file:" + filename)
3213+ return False
3214+
3215+ # open output file
3216+ try:
3217+ output = open(filename+'.savema5','w')
3218+ except:
3219+ self.logger.error("impossible to read the file:" + filename+'.savema5')
3220+ return False
3221+
3222+ # lines
3223+ for line in input:
3224+ line2=line.lstrip()
3225+ line2=line2.rstrip()
3226+ line2=line2.replace(' ','')
3227+ if line2.startswith('buffer.ReplaceAll("energy"'):
3228+ output.write(line)
3229+ output.write(' buffer.ReplaceAll("d0", "t");\n')
3230+ else:
3231+ output.write(line)
3232+
3233+ #close
3234+ input.close()
3235+ output.close()
3236+
3237+ try:
3238+ shutil.copy(filename+'.savema5',filename)
3239+ except:
3240+ self.logger.error("impossible to copy "+filename+'.savema5 in '+filename)
3241+ return False
3242+
3243+ return True
3244+
3245+
3246+
3247+
3248+
3249+
3250 def CopyFiles(self,filesToAdd):
3251
3252 for file in filesToAdd:
3253@@ -507,7 +548,7 @@
3254 # Updating the architecture
3255 deac_path = libpaths[0].replace(libpaths[0].split('/')[-1],"DEACT_"+libpaths[0].split('/')[-1])
3256 self.main.archi_info.toLDPATH1 = [x for x in self.main.archi_info.toLDPATH1 if not self.package in x]
3257- if key in self.main.archi_info.libraries.keys():
3258+ if key in list(self.main.archi_info.libraries.keys()):
3259 del self.main.archi_info.libraries[key]
3260
3261 # If the deactivated directory already exists -> suppression
3262@@ -618,7 +659,7 @@
3263 checkup = CheckUp(self.main.archi_info, self.main.session_info, False, self.main.script)
3264 for link in [x.split('/')[-1] for x in originals]:
3265 dest = os.path.join(self.main.archi_info.ma5dir,'tools','SampleAnalyzer', 'ExternalSymLink', link)
3266- if not checkup.CreateSymLink(x,dest):
3267+ if not checkup.CreateSymLink(link,dest):
3268 return -1
3269
3270 # Compiler setup
3271
3272=== modified file 'madanalysis/install/install_fastjet.py'
3273--- madanalysis/install/install_fastjet.py 2020-07-03 08:05:49 +0000
3274+++ madanalysis/install/install_fastjet.py 2021-06-30 09:39:51 +0000
3275@@ -22,6 +22,7 @@
3276 ################################################################################
3277
3278
3279+from __future__ import absolute_import
3280 from madanalysis.install.install_service import InstallService
3281 from shell_command import ShellCommand
3282 import os
3283
3284=== modified file 'madanalysis/install/install_fastjetcontrib.py'
3285--- madanalysis/install/install_fastjetcontrib.py 2020-07-03 08:05:49 +0000
3286+++ madanalysis/install/install_fastjetcontrib.py 2021-06-30 09:39:51 +0000
3287@@ -22,6 +22,7 @@
3288 ################################################################################
3289
3290
3291+from __future__ import absolute_import
3292 from madanalysis.install.install_service import InstallService
3293 from shell_command import ShellCommand
3294 import os
3295
3296=== modified file 'madanalysis/install/install_gnuplot.py'
3297--- madanalysis/install/install_gnuplot.py 2020-07-03 08:05:49 +0000
3298+++ madanalysis/install/install_gnuplot.py 2021-06-30 09:39:51 +0000
3299@@ -22,6 +22,7 @@
3300 ################################################################################
3301
3302
3303+from __future__ import absolute_import
3304 from madanalysis.install.install_service import InstallService
3305 from shell_command import ShellCommand
3306 import os
3307
3308=== modified file 'madanalysis/install/install_manager.py'
3309--- madanalysis/install/install_manager.py 2020-07-03 08:05:49 +0000
3310+++ madanalysis/install/install_manager.py 2021-06-30 09:39:51 +0000
3311@@ -22,6 +22,7 @@
3312 ################################################################################
3313
3314
3315+from __future__ import absolute_import
3316 import logging
3317 import sys
3318
3319
3320=== modified file 'madanalysis/install/install_matplotlib.py'
3321--- madanalysis/install/install_matplotlib.py 2020-07-03 08:05:49 +0000
3322+++ madanalysis/install/install_matplotlib.py 2021-06-30 09:39:51 +0000
3323@@ -22,6 +22,7 @@
3324 ################################################################################
3325
3326
3327+from __future__ import absolute_import
3328 from madanalysis.install.install_service import InstallService
3329 from shell_command import ShellCommand
3330 import os
3331
3332=== modified file 'madanalysis/install/install_numpy.py'
3333--- madanalysis/install/install_numpy.py 2020-07-03 08:05:49 +0000
3334+++ madanalysis/install/install_numpy.py 2021-06-30 09:39:51 +0000
3335@@ -22,6 +22,7 @@
3336 ################################################################################
3337
3338
3339+from __future__ import absolute_import
3340 from madanalysis.install.install_service import InstallService
3341 from shell_command import ShellCommand
3342 import os
3343
3344=== modified file 'madanalysis/install/install_pad.py'
3345--- madanalysis/install/install_pad.py 2020-07-03 08:05:49 +0000
3346+++ madanalysis/install/install_pad.py 2021-06-30 09:39:51 +0000
3347@@ -22,13 +22,11 @@
3348 ################################################################################
3349
3350
3351+from __future__ import absolute_import
3352 from madanalysis.install.install_service import InstallService
3353-from shell_command import ShellCommand
3354-import glob
3355-import os
3356-import sys
3357-import logging
3358-import shutil
3359+from shell_command import ShellCommand
3360+import glob, os, logging, shutil
3361+
3362
3363 class InstallPad:
3364
3365@@ -44,19 +42,20 @@
3366 self.untardir = ""
3367 self.ncores = 1
3368 self.files= {
3369- "pad.dat" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/pad2.dat",
3370- "bib_pad.dat": "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/bib_pad2.dat",
3371- "json_pad.dat":"http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/json_pad.dat"
3372+ "pad.dat" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/pad3.dat",
3373+ "bib_pad.dat": "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/bib_pad3.dat",
3374+ "json_pad.dat":"http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/json_pad3.dat"
3375 }
3376 if padname=='PADForMA5tune':
3377 self.files = {
3378- "padma5tune.dat" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/padma5tune.dat",
3379- "bib_padma5tune.dat": "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/bib_padma5tune.dat"
3380+ "padma5tune.dat" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/padma5tune3.dat",
3381+ "bib_padma5tune.dat": "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/bib_pad3.dat"
3382 }
3383 elif padname=='PADForSFS':
3384 self.files = {
3385- "padsfs.dat" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/SFS/padsfs.dat",
3386- "bib_padsfs.dat" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/SFS/bib_padsfs.dat"
3387+ "padsfs.dat" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/SFS/padsfs3.dat",
3388+ "bib_padsfs.dat" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/bib_pad3.dat",
3389+ "json_padsfs.dat": "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/SFS/json_padsfs3.dat"
3390 }
3391 self.analyses = []
3392 self.analysis_files = []
3393@@ -103,7 +102,7 @@
3394 if self.padname == 'PADForMA5tune':
3395 filename="cms_sus_13_011"
3396 elif self.padname == 'PADForSFS':
3397- filename="sfs_test"
3398+ filename="atlas_susy_2016_07"
3399 logging.getLogger('MA5').debug('Calling the expert mode for file ' + filename)
3400 logging.getLogger('MA5').debug('BEGIN ExpertMode')
3401 from madanalysis.core.expert_mode import ExpertMode
3402@@ -141,24 +140,12 @@
3403 # EXIT
3404 return True
3405
3406- # Formatting
3407- def formatting(self,analysis):
3408- new_analysis = analysis.replace('ATLAS_1604_07773' ,'atlas_exot_2015_03')
3409- new_analysis = new_analysis.replace('ATLAS_1711_03301' ,'atlas_exot_2016_27')
3410- new_analysis = new_analysis.replace('ATLAS_SUSY_16_07' ,'atlas_susy_2016_07')
3411- new_analysis = new_analysis.replace('atlas_1605_03814' ,'atlas_susy_2015_06')
3412- new_analysis = new_analysis.replace('CMS_EXO_16_012_2gamma','cms_exo_16_012')
3413- new_analysis = new_analysis.replace('atlas_1405_7875', 'atlas_susy_2013_02')
3414- new_analysis = new_analysis.replace('atlas_sus_13_05' ,'atlas_susy_2013_05')
3415- new_analysis = new_analysis.replace('-','_')
3416- return new_analysis.lower()
3417-
3418 def Download(self):
3419 # Checking connection with InSpire and the ma5 website
3420- if not InstallService.check_inspire():
3421- return False
3422 if not InstallService.check_ma5site():
3423 return False
3424+ if not InstallService.check_dataverse():
3425+ return False
3426
3427 # Downloading the files with the information on the implemented analyses
3428 logname = os.path.normpath(self.installdir+'/wget_mainfiles.log')
3429@@ -167,14 +154,17 @@
3430
3431 # Json information for pyhf
3432 json_dictionary = {}
3433- if self.padname=='PAD':
3434- logging.getLogger('MA5').debug(" ** Getting the list of pyhf-cpompatible analyses in " + self.downloaddir+"/json_pad.dat")
3435- json_input = open(os.path.join(self.downloaddir,'json_pad.dat'));
3436- for line in json_input:
3437- if len(line.strip())==0 or line.strip().startswith('#'):
3438- continue;
3439- json_dictionary[line.strip().split('|')[0].strip()] = line.strip().split('|')[1].split();
3440- json_input.close();
3441+ if self.padname in ['PAD', 'PADForSFS']:
3442+ json_struct_name = [x for x in self.files.keys() if 'json' in x]
3443+ if len(json_struct_name) == 1:
3444+ logging.getLogger('MA5').debug(" ** Getting the list of pyhf-compatible analyses in " +\
3445+ self.downloaddir+"/"+json_struct_name[0])
3446+ json_input = open(os.path.join(self.downloaddir,json_struct_name[0]));
3447+ for line in json_input:
3448+ if len(line.strip())==0 or line.strip().startswith('#'):
3449+ continue;
3450+ json_dictionary[line.strip().split('|')[0].strip()] = [ line.strip().split('|')[1].split(), line.strip().split('|')[2].split()];
3451+ json_input.close();
3452
3453 # Getting the analysis one by one (and creating first skeleton analyses for each of them)
3454 logging.getLogger('MA5').debug('Reading the analysis list in ' + \
3455@@ -194,59 +184,75 @@
3456 url = line.split('|')[1].strip()
3457 delphes = line.split('|')[2].strip()
3458 dscrptn = line.split('|')[3].strip()
3459- new_delphes = self.formatting(delphes)
3460- new_analysis = self.formatting(analysis)
3461+ # getting the dataverse URLs
3462+ delphes_url='';
3463+ if 'dataverse' in delphes:
3464+ delphes_url = 'https://dataverse.uclouvain.be/api/access/datafile/'+delphes.split()[-1][:-1];
3465+ if len(analysis)==0 and len(url)==0:
3466+ delphes = delphes.split()[1]
3467+ elif self.padname!='PADForSFS':
3468+ delphes = 'delphes_card_'+delphes.split()[1]+'.tcl';
3469+ else:
3470+ delphes = 'sfs_card_'+delphes.split()[1]+'.ma5';
3471 # filling the global vectors
3472 if len(analysis)==0 and len(url)==0:
3473 self.pileup_files.append(delphes)
3474- elif not new_delphes in self.delphes_cards:
3475- self.delphes_cards.append(new_delphes)
3476- delphes_dictionary[new_delphes] = [new_analysis]
3477+ elif not delphes in self.delphes_cards:
3478+ self.delphes_cards.append(delphes)
3479+ delphes_dictionary[delphes] = [analysis]
3480 else:
3481- delphes_dictionary[new_delphes].append(new_analysis)
3482+ delphes_dictionary[delphes].append(analysis)
3483 download_delphes = False
3484 logname = os.path.join(self.installdir,self.padname+'-'+analysis+'.log')
3485 files = {}
3486 # Making space in the PAD for the analysis and preparing to download the analysis files
3487 if len(analysis)!=0 and len(url)!=0:
3488- logging.getLogger('MA5').debug(" ** Getting the analysis " + new_analysis + ' located at ' + url)
3489+ logging.getLogger('MA5').debug(" ** Getting the analysis " + analysis + ' located at ' + url)
3490 ## Creating a skeleton if necessary (+ inclusion in the analysis list and in the main)
3491- if not new_analysis in ["cms_b2g_12_012", "cms_sus_13_011", "sfs_test"]:
3492- logging.getLogger('MA5').debug(' --> Creating a skeleton analysis for ' + new_analysis)
3493- TheCommand = ['./newAnalyzer.py', new_analysis, new_analysis]
3494+ if not (analysis in ["cms_b2g_12_012", "cms_sus_13_011"] or (analysis=="atlas_susy_2016_07" and self.padname=='PADForSFS')):
3495+ logging.getLogger('MA5').debug(' --> Creating a skeleton analysis for ' + analysis)
3496+ TheCommand = ['./newAnalyzer.py', analysis, analysis]
3497 logging.getLogger('MA5').debug(' --> ' + ' '.join(TheCommand))
3498- ok, out= ShellCommand.ExecuteWithLog(TheCommand,logname,self.installdir+'/Build/SampleAnalyzer',silent=False)
3499+ ok, out= ShellCommand.ExecuteWithLog(TheCommand,logname,
3500+ self.installdir+'/Build/SampleAnalyzer',
3501+ silent=False)
3502 if not ok:
3503 return False
3504 ## Making space for the new files
3505- for onefile in ['Build/SampleAnalyzer/User/Analyzer/'+new_analysis+'.cpp', 'Build/SampleAnalyzer/User/Analyzer/'+new_analysis+'.h', 'Build/Main/main.bak']:
3506+ for onefile in ['Build/SampleAnalyzer/User/Analyzer/'+analysis+'.cpp',
3507+ 'Build/SampleAnalyzer/User/Analyzer/'+analysis+'.h',
3508+ 'Build/Main/main.bak']:
3509 TheCommand = ['rm', '-f', os.path.join(self.installdir,onefile)]
3510 logging.getLogger('MA5').debug(' --> ' + ' '.join(TheCommand))
3511 ok= ShellCommand.Execute(TheCommand,self.main.archi_info.ma5dir+'/tools')
3512 if not ok:
3513 return False
3514 ## Preparing the download of the analysis files
3515- if url=='MA5-local':
3516- url='http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/'
3517- if self.padname == 'PADForSFS':
3518- url += 'SFS'
3519- else:
3520- url += 'MA5SandBox'
3521+ if 'dataverse' in url:
3522+ exts = ['cpp', 'h', 'info'];
3523+ anl_files = url.split(']')[0].split()[1:];
3524+ for i in range(len(anl_files)):
3525+ files[analysis+'.'+exts[i]] = 'https://dataverse.uclouvain.be/api/access/datafile/'+anl_files[i];
3526+ ## json files
3527+ if analysis in list(json_dictionary.keys()):
3528+ for i_json in range(len(json_dictionary[analysis][0])):
3529+ files[analysis+'_'+json_dictionary[analysis][0][i_json]+'.json'] =\
3530+ 'https://dataverse.uclouvain.be/api/access/datafile/' + json_dictionary[analysis][1][i_json]
3531+ self.json_cards.append(analysis+'_'+json_dictionary[analysis][0][i_json]+'.json')
3532+ self.analysis_files.append(analysis+'_'+json_dictionary[analysis][0][i_json]+'.json')
3533 else:
3534- url=os.path.join(url,'files')
3535- for extension in ['cpp', 'info', 'h']:
3536- if analysis=='cms_exo_12_048' and extension=='info':
3537- files[new_analysis+'.'+extension] = os.path.join(url,analysis+'.'+extension+'?version=1')
3538+ if url=='MA5-local':
3539+ url='http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/'
3540+ if self.padname == 'PADForSFS':
3541+ url += 'SFS'
3542+ else:
3543+ url += 'MA5SandBox'
3544 else:
3545- files[new_analysis+'.'+extension] = os.path.join(url,analysis+'.'+extension)
3546- self.analysis_files.append(new_analysis+'.'+extension)
3547- analysis_info[new_analysis] = dscrptn
3548- ## Preparing to downloading the necessary json files
3549- if analysis in json_dictionary.keys():
3550- for json in json_dictionary[analysis]:
3551- files[new_analysis+'_'+json+'.json'] = os.path.join(url,new_analysis+'_'+json+'.json')
3552- self.json_cards.append(new_analysis+'_'+json+'.json')
3553- self.analysis_files.append(new_analysis+'_'+json+'.json')
3554+ url=os.path.join(url,'files')
3555+ for extension in ['cpp', 'info', 'h']:
3556+ files[analysis+'.'+extension] = os.path.join(url,analysis+'.'+extension)
3557+ self.analysis_files.append(analysis+'.'+extension)
3558+ analysis_info[analysis] = dscrptn
3559 # Preparing to download the delphes card
3560 detector = "delphes"
3561 wiki_page = 'MA5SandBox'
3562@@ -254,14 +260,14 @@
3563 detector = "MA5-SFS"
3564 wiki_page = 'SFS'
3565 if len(delphes)!=0 and download_delphes:
3566- logging.getLogger('MA5').debug(" ** Getting the " + detector + " card " + new_delphes)
3567- if len(analysis)!=0:
3568- files[new_delphes] = os.path.join('http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/'+wiki_page, delphes)
3569- else:
3570+ logging.getLogger('MA5').debug(" ** Getting the " + detector + " card " + delphes)
3571+ if not 'dataverse' in delphes_url:
3572 files[delphes] = os.path.join('http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/'+wiki_page, delphes)
3573+ else:
3574+ files[delphes] = delphes_url;
3575 # download in a temporary folder
3576- if len(new_analysis)!=0:
3577- logging.getLogger('MA5').info(' --> Downloading the files for ' + new_analysis)
3578+ if len(analysis)!=0:
3579+ logging.getLogger('MA5').info(' --> Downloading the files for ' + analysis)
3580 else:
3581 logging.getLogger('MA5').info(' --> Downloading the pileup file ' + delphes)
3582 for onefile in files.values():
3583@@ -296,45 +302,12 @@
3584 return True
3585
3586 def Unpack(self):
3587- # Restoring the compatibility with MA5 versions posterior to v1.4
3588- logging.getLogger('MA5').debug(" ** Restoring the compatibility with MA5 versions posterior to v1.4")
3589+ # Copying the analysis files
3590 for analysis in self.analyses:
3591- new_analysis = self.formatting(analysis)
3592 for extension in ['h','cpp', 'info']:
3593- newfile=open(os.path.join(self.PADdir, new_analysis + '.'+extension),'w')
3594- oldfile=open(os.path.join(self.downloaddir, new_analysis + '.'+extension),'r')
3595- rootheaders=False
3596- for line in oldfile:
3597- if 'RootMainHeaders.h' in line:
3598- rootheaders=True
3599- if 'TLorentzVector' in line:
3600- if new_analysis=='atlas_susy_2013_05' and extension=='h' and self.padname=='PADForMA5tune':
3601- newfile.write(line.replace('TLorentzVector','MA5::MALorentzVector'))
3602- else:
3603- newfile.write(line.replace('TLorentzVector','MALorentzVector'))
3604- elif 'WARNING' in line:
3605- newfile.write(line.replace('WARNING','//WARNING'))
3606- elif new_analysis=='atlas_susy_2013_02' and 'pt() > 130' in line and '6jm' in line and not 'AddCut' in line:
3607- newfile.write('}}}}\n')
3608- newfile.write(line)
3609- elif new_analysis=='atlas_conf_2019_040' and 'if (signalJets.size()>=1' in line:
3610- newfile.write(' if (signalJets.size()>1)\n')
3611- elif new_analysis in ['atlas_exot_2014_06', 'cms_exo_12_047'] and 'preselection=' in line:
3612- newfile.write(line.replace('preselection=','preselection=myEventWeight*'))
3613- elif new_analysis in ['atlas_exot_2016_32'] and 'tight=' in line:
3614- newfile.write(line.replace('tight=','tight=myEventWeight*'))
3615- elif analysis in line:
3616- newfile.write(line.replace(analysis, new_analysis))
3617- else:
3618- newfile.write(line)
3619- newfile.close()
3620- oldfile.close()
3621- if (extension == 'h') and not rootheaders and self.padname != 'PADForSFS':
3622- with open(os.path.join(self.PADdir, new_analysis+'.'+extension), 'r+') as f:
3623- content = f.read()
3624- f.seek(0, 0)
3625- f.truncate()
3626- f.write(content.replace('#include','#include \"SampleAnalyzer/Interfaces/root/RootMainHeaders.h\"\n#include'))
3627+ newfile = os.path.join(self.PADdir, analysis + '.'+extension)
3628+ oldfile = os.path.join(self.downloaddir, analysis + '.'+extension)
3629+ shutil.copy(oldfile,newfile)
3630
3631 # json files fopr pyhf
3632 for json in self.json_cards:
3633
3634=== modified file 'madanalysis/install/install_pyhf.py'
3635--- madanalysis/install/install_pyhf.py 2020-07-03 08:05:49 +0000
3636+++ madanalysis/install/install_pyhf.py 2021-06-30 09:39:51 +0000
3637@@ -22,11 +22,10 @@
3638 ################################################################################
3639
3640
3641+from __future__ import absolute_import
3642 from madanalysis.install.install_service import InstallService
3643-from shell_command import ShellCommand
3644-import os
3645-import sys
3646-import logging
3647+import os, sys, logging
3648+
3649
3650 class Installpyhf:
3651 def __init__(self,main):
3652@@ -37,8 +36,12 @@
3653 self.downloaddir = self.main.session_info.downloaddir
3654 self.untardir = os.path.normpath(self.tmpdir + '/MA5_pyhf/')
3655 self.ncores = 1
3656- self.files = {"pyhf.tar.gz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/pyhf_v0.1.2.tar.gz"}
3657- self.pyhf_version= "0.1.2";
3658+ if sys.version_info[0] == 2:
3659+ self.files = {"pyhf_python2.tar.gz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/SRCombinations/pyhf_python2.tar.gz"}
3660+ self.pyhf_version= "0.1.2"
3661+ elif sys.version_info[0] > 2:
3662+ self.files = {"pyhf_py3.tgz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/SRCombinations/pyhf_py3.tgz"}
3663+ self.pyhf_version= "0.5.4"
3664
3665 def Detect(self):
3666 if not os.path.isdir(self.toolsdir):
3667@@ -82,29 +85,18 @@
3668 # Logname
3669 logname = os.path.normpath(self.installdir+'/unpack.log')
3670 # Unpacking the tarball
3671- ok, packagedir = InstallService.untar(logname, self.downloaddir, self.installdir,'pyhf.tar.gz')
3672- if not ok:
3673- return False
3674+ for key in self.files.keys():
3675+ ok, packagedir = InstallService.untar(logname, self.downloaddir, self.installdir, key)
3676+ if not ok:
3677+ return False
3678 # Ok: returning the good folder
3679 self.tmpdir=packagedir
3680 return True
3681
3682
3683 def Build(self):
3684- # Input
3685- theCommands=[sys.executable,'setup.py','build']
3686- logname=os.path.normpath(self.installdir+'/compilation.log')
3687- # Execute
3688- logging.getLogger('MA5').debug('shell command: '+' '.join(theCommands))
3689- ok, out= ShellCommand.ExecuteWithLog(theCommands,\
3690- logname,\
3691- self.tmpdir,\
3692- silent=False)
3693- # return result
3694- if not ok:
3695- logging.getLogger('MA5').error('impossible to build the project. For more details, see the log file:')
3696- logging.getLogger('MA5').error(logname)
3697- return ok
3698+ # all checks are done in Check function.
3699+ return True
3700
3701
3702 def Install(self):
3703@@ -114,14 +106,24 @@
3704 def Check(self):
3705 try:
3706 if os.path.isdir(self.installdir) and not self.installdir in sys.path:
3707- sys.path.append(self.installdir)
3708+ sys.path.insert(0, self.installdir+(sys.version_info[0] > 2)*'/src/')
3709 import pyhf
3710+ self.logger.debug("pyhf has been imported from "+" ".join(pyhf.__path__))
3711 if str(pyhf.__version__) != self.pyhf_version:
3712- logging.getLogger('MA5').error("Not using the right version of pyhf.")
3713+ if sys.version_info[0] > 2:
3714+ logging.getLogger('MA5').warning("An incorrect version of pyhf has been detected ("+str(pyhf.__version__)+")");
3715+ logging.getLogger('MA5').warning("Please note that MadAnalysis 5 currently supports pyhf version "+\
3716+ str(self.pyhf_version))
3717+ return True
3718+ logging.getLogger('MA5').error("An incorrect version of pyhf has been detected ("+str(pyhf.__version__)+")");
3719+ logging.getLogger('MA5').error("Please note that MadAnalysis 5 currently supports pyhf version "+\
3720+ str(self.pyhf_version))
3721 self.display_log()
3722 return False
3723- except:
3724- logging.getLogger('MA5').error("Cannot use pyhf. Please double check the required dependencies and/or (re-)install it.")
3725+ except ImportError as err:
3726+ logging.getLogger('MA5').error("The pyhf module cannot be used. Please check that all requirements are available and (re-)install it.")
3727+ logging.getLogger('MA5').error("Using phyf requires the click, tqdm, six, jsonschema, jsonpatch and pyyaml packages")
3728+ logging.getLogger('MA5').debug(err)
3729 self.display_log()
3730 return False
3731 return True
3732@@ -130,9 +132,7 @@
3733 logging.getLogger('MA5').error("More details can be found into the log files:")
3734 logging.getLogger('MA5').error(" - "+os.path.normpath(self.installdir+"/wget.log"))
3735 logging.getLogger('MA5').error(" - "+os.path.normpath(self.installdir+"/unpack.log"))
3736- logging.getLogger('MA5').error(" - "+os.path.normpath(self.installdir+"/configuration.log"))
3737- logging.getLogger('MA5').error(" - "+os.path.normpath(self.installdir+"/compilation.log"))
3738- logging.getLogger('MA5').error(" - "+os.path.normpath(self.installdir+"/installation.log"))
3739+
3740
3741 def NeedToRestart(self):
3742 return False
3743
3744=== modified file 'madanalysis/install/install_root.py'
3745--- madanalysis/install/install_root.py 2020-07-03 08:05:49 +0000
3746+++ madanalysis/install/install_root.py 2021-06-30 09:39:51 +0000
3747@@ -22,6 +22,7 @@
3748 ################################################################################
3749
3750
3751+from __future__ import absolute_import
3752 from madanalysis.install.install_service import InstallService
3753 from madanalysis.IOinterface.folder_writer import FolderWriter
3754 from shell_command import ShellCommand
3755
3756=== modified file 'madanalysis/install/install_samples.py'
3757--- madanalysis/install/install_samples.py 2020-07-03 08:05:49 +0000
3758+++ madanalysis/install/install_samples.py 2021-06-30 09:39:51 +0000
3759@@ -22,6 +22,7 @@
3760 ################################################################################
3761
3762
3763+from __future__ import absolute_import
3764 from madanalysis.install.install_service import InstallService
3765 from shell_command import ShellCommand
3766 import os
3767@@ -74,7 +75,7 @@
3768
3769 def Check(self):
3770
3771- filesToCheck = self.files.keys()
3772+ filesToCheck = list(self.files.keys())
3773 ok=True
3774 for item in filesToCheck:
3775 logging.getLogger('MA5').debug('checking file: '+item+ ' ...')
3776
3777=== modified file 'madanalysis/install/install_service.py'
3778--- madanalysis/install/install_service.py 2020-07-03 08:05:49 +0000
3779+++ madanalysis/install/install_service.py 2021-06-30 09:39:51 +0000
3780@@ -22,11 +22,15 @@
3781 ################################################################################
3782
3783
3784+from __future__ import absolute_import
3785 from shell_command import ShellCommand
3786 import logging
3787 import os
3788 import sys
3789 import shutil
3790+from six.moves import range
3791+from six.moves import input
3792+import six
3793
3794 class InstallService():
3795
3796@@ -89,7 +93,7 @@
3797 if not forced:
3798 test=False
3799 while(not test):
3800- answer=raw_input(" => Answer: ")
3801+ answer=input(" => Answer: ")
3802 if answer=="":
3803 test=True
3804 ncores=nmaxcores
3805@@ -196,7 +200,7 @@
3806 for file,url in filesToDownload.items():
3807 ind+=1
3808 result="OK"
3809- logging.getLogger('MA5').info(' - ' + str(ind)+"/"+str(len(filesToDownload.keys()))+" "+url+" ...")
3810+ logging.getLogger('MA5').info(' - ' + str(ind)+"/"+str(len(list(filesToDownload.keys())))+" "+url+" ...")
3811 output = installdir+'/'+file
3812
3813 # Try to connect the file
3814@@ -216,13 +220,16 @@
3815 # skip the file
3816 continue
3817
3818-
3819 # Decoding the size of the remote file
3820 logging.getLogger('MA5').debug('Decoding the size of the remote file...')
3821- sizeURLFile = 0
3822+ sizeURLFile = 0
3823 try:
3824- sizeURLFile = int(info.info().getheaders("Content-Length")[0])
3825- except:
3826+ if six.PY2:
3827+ sizeURLFile = int(info.info().getheaders("Content-Length")[0])
3828+ else:
3829+ sizeURLFile = int(info.info().get("Content-Length"))
3830+ except Exception as err:
3831+ print(err)
3832 logging.getLogger('MA5').debug('-> Problem to decode it')
3833 logging.getLogger('MA5').warning("Bad description for "+url)
3834 result="ERROR"
3835@@ -243,7 +250,7 @@
3836 logging.getLogger('MA5').debug("A file with the same name '"+output+"' has been found on the machine.")
3837
3838 ok=True
3839-
3840+
3841 # Decoding the size of the local file
3842 if ok:
3843 logging.getLogger('MA5').debug('Decoding the size of the local file...')
3844@@ -331,7 +338,7 @@
3845 @staticmethod
3846 def UrlAccess(url):
3847
3848- import urllib2
3849+ import six.moves.urllib.request, six.moves.urllib.error, six.moves.urllib.parse
3850 import ssl
3851 import time
3852
3853@@ -343,9 +350,7 @@
3854
3855 # ssl method for python v>2.7.9
3856 try:
3857- modeSSL = (sys.version_info[0]>=2 and \
3858- sys.version_info[1]>=7 and \
3859- sys.version_info[2]>=9 )
3860+ modeSSL = ( (sys.version_info[0]==2 and sys.version_info[1]>=7 and sys.version_info[2]>=9) or (sys.version_info[0]==3) )
3861 except:
3862 logging.getLogger('MA5').warning("Problem with Python version decoding!")
3863 modeSSL = False
3864@@ -360,9 +365,9 @@
3865 logging.getLogger('MA5').debug("Attempt "+str(nAttempt+1)+"/"+str(nMaxAttempts)+" to access the url")
3866 try:
3867 if modeSSL:
3868- info = urllib2.urlopen(url, context=ssl._create_unverified_context())
3869+ info = six.moves.urllib.request.urlopen(url, context=ssl._create_unverified_context())
3870 else:
3871- info = urllib2.urlopen(url)
3872+ info = six.moves.urllib.request.urlopen(url)
3873 except:
3874 logging.getLogger('MA5').warning("Impossible to access the url: "+url)
3875 ok=False
3876@@ -389,27 +394,21 @@
3877 def check_ma5site():
3878 url='http://madanalysis.irmp.ucl.ac.be'
3879 logging.getLogger('MA5').debug("Testing the access to MadAnalysis 5 website: "+url+" ...")
3880-
3881 info = InstallService.UrlAccess(url)
3882-
3883 # Close the access
3884 if info!=None:
3885 info.close()
3886- return True
3887+ return True
3888
3889-
3890 @staticmethod
3891- def check_inspire():
3892- url='http://inspirehep.net/'
3893- logging.getLogger('MA5').debug("Testing the access to InSpire: "+url+" ...")
3894-
3895+ def check_dataverse():
3896+ url='http://dataverse.uclouvain.be'
3897+ logging.getLogger('MA5').debug("Testing access to the MadAnalysis5 dataverse: "+url+" ...")
3898 info = InstallService.UrlAccess(url)
3899-
3900 # Close the access
3901 if info!=None:
3902 info.close()
3903 return True
3904-
3905
3906 @staticmethod
3907 def create_tools_folder(path):
3908
3909=== modified file 'madanalysis/install/install_zlib.py'
3910--- madanalysis/install/install_zlib.py 2020-07-03 08:05:49 +0000
3911+++ madanalysis/install/install_zlib.py 2021-06-30 09:39:51 +0000
3912@@ -22,6 +22,7 @@
3913 ################################################################################
3914
3915
3916+from __future__ import absolute_import
3917 from madanalysis.install.install_service import InstallService
3918 from shell_command import ShellCommand
3919 import os
3920
3921=== modified file 'madanalysis/interpreter/cmd_base.py'
3922--- madanalysis/interpreter/cmd_base.py 2020-07-03 08:05:49 +0000
3923+++ madanalysis/interpreter/cmd_base.py 2021-06-30 09:39:51 +0000
3924@@ -22,9 +22,11 @@
3925 ################################################################################
3926
3927
3928+from __future__ import absolute_import
3929 import logging
3930 import glob
3931 import os
3932+from six.moves import range
3933
3934 class CmdBase():
3935 """Command CMDBase"""
3936
3937=== modified file 'madanalysis/interpreter/cmd_cut.py'
3938--- madanalysis/interpreter/cmd_cut.py 2020-07-03 08:05:49 +0000
3939+++ madanalysis/interpreter/cmd_cut.py 2021-06-30 09:39:51 +0000
3940@@ -22,6 +22,7 @@
3941 ################################################################################
3942
3943
3944+from __future__ import absolute_import
3945 from madanalysis.interpreter.cmd_base import CmdBase
3946 from madanalysis.interpreter.cmd_selection_base import CmdSelectionBase
3947 from madanalysis.multiparticle.particle_object import ParticleObject
3948@@ -38,6 +39,7 @@
3949 from madanalysis.enumeration.argument_type import ArgumentType
3950 from madanalysis.observable.observable_base import ObservableBase
3951 import logging
3952+from six.moves import range
3953
3954
3955 class CmdCut(CmdBase,CmdSelectionBase):
3956@@ -678,7 +680,7 @@
3957
3958 # options mode
3959 if nbracket1==0 and nbracket2==1 and nbracket3==0:
3960- output=Cut.userShortcuts.keys()
3961+ output=list(Cut.userShortcuts.keys())
3962 output.append("]")
3963 return self.finalize_complete(text,output)
3964
3965
3966=== modified file 'madanalysis/interpreter/cmd_define.py'
3967--- madanalysis/interpreter/cmd_define.py 2020-07-03 08:05:49 +0000
3968+++ madanalysis/interpreter/cmd_define.py 2021-06-30 09:39:51 +0000
3969@@ -22,6 +22,7 @@
3970 ################################################################################
3971
3972
3973+from __future__ import absolute_import
3974 import madanalysis.interpreter.cmd_base as CmdBase
3975 from madanalysis.enumeration.ma5_running_type import MA5RunningType
3976 import logging
3977@@ -35,13 +36,13 @@
3978 def do(self,args):
3979
3980 # tagger / smearer
3981- if args[0] in ['tagger', 'smearer', 'reco_efficiency']:
3982+ if args[0] in ['tagger', 'smearer', 'reco_efficiency', 'jes', 'scaling', 'energy_scaling']:
3983 if self.main.mode != MA5RunningType.RECO:
3984- logging.getLogger('MA5').error("Smearing/tagging/reconstruction are only available in the RECO mode")
3985+ logging.getLogger('MA5').error("Smearing/tagging/reconstruction/scaling are only available in the RECO mode")
3986 logging.getLogger('MA5').error("Please restart the program with './bin/ma5 -R '")
3987 return
3988 if self.main.fastsim.package != 'fastjet':
3989- logging.getLogger('MA5').error("Smearing/tagging/reconstruction require fastjet as a fastsim package. ")
3990+ logging.getLogger('MA5').error("Smearing/tagging/reconstruction/scaling requires FastJet as a fastsim package. ")
3991 return
3992 self.main.superfastsim.define(args,self.main.multiparticles)
3993 return
3994@@ -122,6 +123,22 @@
3995 logging.getLogger('MA5').info(" Define the efficiency to reconstruct the object <p1>.")
3996 logging.getLogger('MA5').info(" The corresponding efficiency function is given by <function>.")
3997 logging.getLogger('MA5').info(" The bounds correspond to the domain the efficiency applies (pt > ..., eta < ..., etc.).")
3998+ logging.getLogger('MA5').info("")
3999+ logging.getLogger('MA5').info(" Syntax: define jes <function> [<bounds>]")
4000+ logging.getLogger('MA5').info(" Define the Jet Energy Scale (JES) corrections to apply to clustered jets.")
4001+ logging.getLogger('MA5').info(" The corresponding JES function is given by <function>.")
4002+ logging.getLogger('MA5').info(" The bounds correspond to the domain that JES applies (pt > ..., eta < ..., etc.).")
4003+ logging.getLogger('MA5').info("")
4004+ logging.getLogger('MA5').info(" Syntax: define energy_scaling <p1> <function> [<bounds>]")
4005+ logging.getLogger('MA5').info(" Define the rescaling corrections to apply to the energy of a reconstructed object <p1>.")
4006+ logging.getLogger('MA5').info(" The corresponding energy scaling function is given by <function>.")
4007+ logging.getLogger('MA5').info(" The bounds correspond to the domain that scaling function applies (pt > ..., eta < ..., etc.).")
4008+ # For the future:
4009+ # logging.getLogger('MA5').info("")
4010+ # logging.getLogger('MA5').info(" Syntax: define scaling <variable> for <p1> <function> [<bounds>]")
4011+ # logging.getLogger('MA5').info(" Define rescaling corrections to apply to a variable <variable> for a reconstructed object <p1>.")
4012+ # logging.getLogger('MA5').info(" The corresponding scaling function is given by <function>.")
4013+ # logging.getLogger('MA5').info(" The bounds correspond to the domain that scaling function applies (pt > ..., eta < ..., etc.).")
4014
4015
4016 def complete(self,text,line,begidx,endidx):
4017
4018=== modified file 'madanalysis/interpreter/cmd_define_region.py'
4019--- madanalysis/interpreter/cmd_define_region.py 2020-07-03 08:05:49 +0000
4020+++ madanalysis/interpreter/cmd_define_region.py 2021-06-30 09:39:51 +0000
4021@@ -22,6 +22,7 @@
4022 ################################################################################
4023
4024
4025+from __future__ import absolute_import
4026 import madanalysis.interpreter.cmd_base as CmdBase
4027 import logging
4028
4029
4030=== modified file 'madanalysis/interpreter/cmd_display.py'
4031--- madanalysis/interpreter/cmd_display.py 2020-07-03 08:05:49 +0000
4032+++ madanalysis/interpreter/cmd_display.py 2021-06-30 09:39:51 +0000
4033@@ -22,8 +22,10 @@
4034 ################################################################################
4035
4036
4037+from __future__ import absolute_import
4038 import madanalysis.interpreter.cmd_base as CmdBase
4039 import logging
4040+from six.moves import range
4041
4042 class CmdDisplay(CmdBase.CmdBase):
4043 """Command DISPLAY"""
4044@@ -34,7 +36,6 @@
4045 def do_other(self,object):
4046
4047 # Looking for one dot in the name
4048-# object = object.lower()
4049 object = object.replace('fastsim.bjet_id.','fastsim.bjet_idXXX')
4050 object = object.replace('fastsim.tau_id.','fastsim.tau_idXXX')
4051 objs = object.split('.')
4052@@ -148,7 +149,7 @@
4053
4054 def do(self,args):
4055 # Checking argument number
4056- if len(args)>0 and args[0].lower() in ['tagger','smearer', 'reco_efficiency']:
4057+ if len(args)>0 and args[0].lower() in ['tagger','smearer', 'reco_efficiency', 'jes', 'energy_scaling', 'scaling']:
4058 return self.main.superfastsim.display(args)
4059 elif len(args)==1:
4060 return self.do_other(args[0])
4061@@ -202,7 +203,7 @@
4062
4063 # Only object name
4064 if variable==None:
4065- output = ["main","selection","tagger","smearer", 'reco_efficiency']
4066+ output = ["main","selection","tagger","smearer", 'reco_efficiency', 'jes', 'energy_scaling', 'scaling']
4067 output.extend(self.main.datasets.GetNames())
4068 output.extend(self.main.multiparticles.GetNames())
4069 output.extend(self.main.regions.GetNames())
4070
4071=== modified file 'madanalysis/interpreter/cmd_display_datasets.py'
4072--- madanalysis/interpreter/cmd_display_datasets.py 2020-07-03 08:05:49 +0000
4073+++ madanalysis/interpreter/cmd_display_datasets.py 2021-06-30 09:39:51 +0000
4074@@ -22,6 +22,7 @@
4075 ################################################################################
4076
4077
4078+from __future__ import absolute_import
4079 import madanalysis.interpreter.cmd_base as CmdBase
4080 import logging
4081
4082
4083=== modified file 'madanalysis/interpreter/cmd_display_multiparticles.py'
4084--- madanalysis/interpreter/cmd_display_multiparticles.py 2020-07-03 08:05:49 +0000
4085+++ madanalysis/interpreter/cmd_display_multiparticles.py 2021-06-30 09:39:51 +0000
4086@@ -22,6 +22,7 @@
4087 ################################################################################
4088
4089
4090+from __future__ import absolute_import
4091 import madanalysis.interpreter.cmd_base as CmdBase
4092 import logging
4093
4094
4095=== modified file 'madanalysis/interpreter/cmd_display_particles.py'
4096--- madanalysis/interpreter/cmd_display_particles.py 2020-07-03 08:05:49 +0000
4097+++ madanalysis/interpreter/cmd_display_particles.py 2021-06-30 09:39:51 +0000
4098@@ -22,6 +22,7 @@
4099 ################################################################################
4100
4101
4102+from __future__ import absolute_import
4103 import madanalysis.interpreter.cmd_base as CmdBase
4104 import logging
4105
4106
4107=== modified file 'madanalysis/interpreter/cmd_display_regions.py'
4108--- madanalysis/interpreter/cmd_display_regions.py 2020-07-03 08:05:49 +0000
4109+++ madanalysis/interpreter/cmd_display_regions.py 2021-06-30 09:39:51 +0000
4110@@ -22,6 +22,7 @@
4111 ################################################################################
4112
4113
4114+from __future__ import absolute_import
4115 import madanalysis.interpreter.cmd_base as CmdBase
4116 import logging
4117
4118
4119=== modified file 'madanalysis/interpreter/cmd_import.py'
4120--- madanalysis/interpreter/cmd_import.py 2020-07-03 08:05:49 +0000
4121+++ madanalysis/interpreter/cmd_import.py 2021-06-30 09:39:51 +0000
4122@@ -22,6 +22,7 @@
4123 ################################################################################
4124
4125
4126+from __future__ import absolute_import
4127 from madanalysis.interpreter.cmd_define import CmdDefine
4128 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4129 from madanalysis.IOinterface.ufo_reader import UFOReader
4130@@ -37,6 +38,8 @@
4131 import glob
4132 import os
4133 import stat
4134+from six.moves import range
4135+from six.moves import input
4136
4137 class CmdImport(CmdBase.CmdBase):
4138 """Command IMPORT"""
4139@@ -75,7 +78,8 @@
4140
4141
4142 elif len(args)==1 and os.path.isdir(filename):
4143- if JobWriter.CheckJobStructureMute(filename,(self.main.recasting.status=='on')):
4144+ recastflag = self.main.recasting.status=='on'
4145+ if JobWriter.CheckJobStructureMute(self.main.session_info,path=filename,recastflag=recastflag):
4146 self.ImportJob(filename,myinterpreter,history)
4147 return
4148 elif UFOReader.CheckStructure(filename):
4149@@ -141,7 +145,7 @@
4150 allowed_answers=['n','no','y','yes']
4151 answer=""
4152 while answer not in allowed_answers:
4153- answer=raw_input("Answer: ")
4154+ answer=input("Answer: ")
4155 answer=answer.lower()
4156 if answer=="no" or answer=="n":
4157 return False
4158
4159=== modified file 'madanalysis/interpreter/cmd_install.py'
4160--- madanalysis/interpreter/cmd_install.py 2020-07-03 08:05:49 +0000
4161+++ madanalysis/interpreter/cmd_install.py 2021-06-30 09:39:51 +0000
4162@@ -22,16 +22,10 @@
4163 ################################################################################
4164
4165
4166+from __future__ import absolute_import
4167 from madanalysis.interpreter.cmd_base import CmdBase
4168 from madanalysis.install.install_manager import InstallManager
4169-from madanalysis.system.user_info import UserInfo
4170-from madanalysis.system.config_checker import ConfigChecker
4171-import logging
4172-import os
4173-import sys
4174-import shutil
4175-import urllib
4176-import pwd
4177+import logging, os
4178
4179 class CmdInstall(CmdBase):
4180 """Command INSTALL"""
4181@@ -73,9 +67,11 @@
4182 main.archi_info.toLDPATH1.append(dpath)
4183
4184 if os.path.isfile(os.path.join(dpath,libname+'.so')):
4185- mylib = os.path.join(dpath,libname+'.so')
4186+ mylib = os.path.join(dpath,libname+'.so')
4187 elif os.path.isfile(os.path.join(dpath,libname+'.dylib')):
4188- mylib = os.path.join(dpath,libname+'.dylib')
4189+ mylib = os.path.join(dpath,libname+'.dylib')
4190+ else:
4191+ return;
4192
4193 main.archi_info.libraries[to_activate]= mylib+":"+str(os.stat(mylib).st_mtime)
4194
4195@@ -141,13 +137,53 @@
4196 self.logger.warning('DelphesMA5tune is not installed... please exit the program and install the pad')
4197 return True
4198 elif args[0]=='PAD':
4199+ pad_install_check, padsfs_install_check = False, False
4200+ # PAD requires ma5 to be restarted; therefore we first install PADForSFS
4201+ if self.main.archi_info.has_fastjet:
4202+ padsfs_install_check = installer.Execute('PADForSFS')
4203+ else:
4204+ self.logger.warning("PADForSFS requires FastJet to be installed.")
4205+ self.logger.info("Would you like to install FastJet? [Y/N]")
4206+ while True:
4207+ answer = input("Answer : ")
4208+ if answer.lower() in ['y','n','yes','no']:
4209+ break
4210+ if answer.lower() in ['y','yes']:
4211+ if not installer.Execute('fastjet'):
4212+ return False
4213+ if not installer.Execute('fastjet-contrib'):
4214+ return False
4215+ if not installer.Execute('PADForSFS'):
4216+ return False
4217+ padsfs_install_check = 'restart'
4218 if inst_delphes(self.main,installer,'delphes',True):
4219- return installer.Execute('PAD')
4220+ pad_install_check = installer.Execute('PAD')
4221 else:
4222- self.logger.warning('Delphes is not installed... please exit the program and install the pad')
4223- return True
4224+ self.logger.warning('Delphes is not installed (and will be installed). '+
4225+ 'Then please exit MA5 and re-install the PAD')
4226+ if 'restart' in [pad_install_check, padsfs_install_check]:
4227+ return 'restart'
4228+ return any([pad_install_check, padsfs_install_check])
4229 elif args[0]=='PADForSFS':
4230- return installer.Execute('PADForSFS')
4231+ padsfs_install_check = False
4232+ if self.main.archi_info.has_fastjet:
4233+ padsfs_install_check = installer.Execute('PADForSFS')
4234+ else:
4235+ self.logger.warning("PADForSFS requires FastJet to be installed.")
4236+ self.logger.info("Would you like to install FastJet? [Y/N]")
4237+ while True:
4238+ answer = input("Answer : ")
4239+ if answer.lower() in ['y','n','yes','no']:
4240+ break
4241+ if answer.lower() in ['y','yes']:
4242+ if not installer.Execute('fastjet'):
4243+ return False
4244+ if not installer.Execute('fastjet-contrib'):
4245+ return False
4246+ if not installer.Execute('PADForSFS'):
4247+ return False
4248+ return 'restart'
4249+ return padsfs_install_check
4250 elif args[0]=='pyhf':
4251 return installer.Execute('pyhf')
4252 else:
4253
4254=== modified file 'madanalysis/interpreter/cmd_open.py'
4255--- madanalysis/interpreter/cmd_open.py 2020-07-03 08:05:49 +0000
4256+++ madanalysis/interpreter/cmd_open.py 2021-06-30 09:39:51 +0000
4257@@ -22,6 +22,7 @@
4258 ################################################################################
4259
4260
4261+from __future__ import absolute_import
4262 from madanalysis.interpreter.cmd_base import CmdBase
4263 from madanalysis.IOinterface.html_report_writer import HTMLReportWriter
4264 from madanalysis.IOinterface.latex_report_writer import LATEXReportWriter
4265
4266=== modified file 'madanalysis/interpreter/cmd_plot.py'
4267--- madanalysis/interpreter/cmd_plot.py 2020-07-03 08:05:49 +0000
4268+++ madanalysis/interpreter/cmd_plot.py 2021-06-30 09:39:51 +0000
4269@@ -22,6 +22,7 @@
4270 ################################################################################
4271
4272
4273+from __future__ import absolute_import
4274 from madanalysis.interpreter.cmd_base import CmdBase
4275 from madanalysis.interpreter.cmd_selection_base import CmdSelectionBase
4276 from madanalysis.multiparticle.particle_object import ParticleObject
4277@@ -31,6 +32,7 @@
4278 from madanalysis.enumeration.argument_type import ArgumentType
4279 from madanalysis.selection.histogram import Histogram
4280 import logging
4281+from six.moves import range
4282
4283
4284 class CmdPlot(CmdBase,CmdSelectionBase):
4285@@ -442,7 +444,7 @@
4286
4287 # options mode
4288 if nbracket1==0 and nbracket2==1 and nbracket3==0:
4289- output=Histogram.userShortcuts.keys()
4290+ output=list(Histogram.userShortcuts.keys())
4291 output.append("]")
4292 return self.finalize_complete(text,output)
4293
4294
4295=== modified file 'madanalysis/interpreter/cmd_remove.py'
4296--- madanalysis/interpreter/cmd_remove.py 2020-07-03 08:05:49 +0000
4297+++ madanalysis/interpreter/cmd_remove.py 2021-06-30 09:39:51 +0000
4298@@ -22,9 +22,11 @@
4299 ################################################################################
4300
4301
4302+from __future__ import absolute_import
4303 import madanalysis.interpreter.cmd_base as CmdBase
4304 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4305 import logging
4306+from six.moves import range
4307
4308 class CmdRemove(CmdBase.CmdBase):
4309 """Command REMOVE"""
4310@@ -42,7 +44,7 @@
4311 # Multiparticle removal
4312 if self.main.multiparticles.Find(name):
4313 theList = self.main.selection.GetItemsUsingMultiparticle(name)
4314- if len(theList) is 0:
4315+ if len(theList) == 0:
4316 self.main.multiparticles.Remove(name,self.main.mode)
4317 else:
4318 logging.getLogger('MA5').error("The Particle/Multiparticle '" + name + \
4319
4320=== modified file 'madanalysis/interpreter/cmd_reset.py'
4321--- madanalysis/interpreter/cmd_reset.py 2020-07-03 08:05:49 +0000
4322+++ madanalysis/interpreter/cmd_reset.py 2021-06-30 09:39:51 +0000
4323@@ -22,12 +22,14 @@
4324 ################################################################################
4325
4326
4327+from __future__ import absolute_import
4328 from madanalysis.IOinterface.particle_reader import ParticleReader
4329 from madanalysis.IOinterface.multiparticle_reader import MultiparticleReader
4330 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4331 from madanalysis.interpreter.cmd_define import CmdDefine
4332 from madanalysis.interpreter.cmd_base import CmdBase
4333 import logging
4334+from six.moves import input
4335
4336 class CmdReset(CmdBase):
4337 """Command RESET"""
4338@@ -52,7 +54,7 @@
4339 allowed_answers=['n','no','y','yes']
4340 answer=""
4341 while answer not in allowed_answers:
4342- answer=raw_input("Answer: ")
4343+ answer=input("Answer: ")
4344 answer=answer.lower()
4345 if answer=="no" or answer=="n":
4346 return False
4347
4348=== modified file 'madanalysis/interpreter/cmd_selection_base.py'
4349--- madanalysis/interpreter/cmd_selection_base.py 2020-07-03 08:05:49 +0000
4350+++ madanalysis/interpreter/cmd_selection_base.py 2021-06-30 09:39:51 +0000
4351@@ -22,6 +22,7 @@
4352 ################################################################################
4353
4354
4355+from __future__ import absolute_import
4356 from madanalysis.multiparticle.particle_object import ParticleObject
4357 from madanalysis.multiparticle.extraparticle import ExtraParticle
4358 from madanalysis.enumeration.operator_type import OperatorType
4359@@ -32,6 +33,7 @@
4360 from madanalysis.selection.condition_sequence import ConditionSequence
4361 from madanalysis.selection.condition_connector import ConditionConnector
4362 import logging
4363+from six.moves import range
4364
4365 class CmdSelectionBase():
4366
4367@@ -139,6 +141,8 @@
4368 # float value
4369 elif obsRef.args[iarg]==ArgumentType.FLOAT:
4370 result=self.extract_float(arguments[iarg])
4371+ else:
4372+ result=None
4373
4374 # checking result
4375 if result==None:
4376
4377=== modified file 'madanalysis/interpreter/cmd_set.py'
4378--- madanalysis/interpreter/cmd_set.py 2020-07-03 08:05:49 +0000
4379+++ madanalysis/interpreter/cmd_set.py 2021-06-30 09:39:51 +0000
4380@@ -22,6 +22,7 @@
4381 ################################################################################
4382
4383
4384+from __future__ import absolute_import
4385 from madanalysis.system.config_checker import ConfigChecker
4386 from madanalysis.system.user_info import UserInfo
4387 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4388@@ -30,6 +31,7 @@
4389 from madanalysis.interpreter.cmd_define import CmdDefine
4390 import madanalysis.interpreter.cmd_base as CmdBase
4391 import logging
4392+from six.moves import range
4393
4394 class CmdSet(CmdBase.CmdBase):
4395 """Command SET"""
4396@@ -144,6 +146,29 @@
4397 self.main.superfastsim.jetrecomode = args[2]
4398 else:
4399 logging.getLogger('MA5').error("Jet smearing can only be based on the jet ('jets') or on its constituents ('constituents').")
4400+ elif objs[2] == 'magneticfield':
4401+ try:
4402+ self.main.superfastsim.mag_field = float(args[2])
4403+ self.main.superfastsim.propagator = True
4404+ except:
4405+ logging.getLogger('MA5').error("The magnetic field has to be numerical (in Tesla).")
4406+ elif objs[2] == 'tracker_radius':
4407+ try:
4408+ self.main.superfastsim.radius = float(args[2])
4409+ self.main.superfastsim.propagator = True
4410+ except:
4411+ logging.getLogger('MA5').error("The tracker cylinder radius has to be numerical (in meters).")
4412+ elif objs[2] == 'half_length':
4413+ try:
4414+ self.main.superfastsim.half_length = float(args[2])
4415+ self.main.superfastsim.propagator = True
4416+ except:
4417+ logging.getLogger('MA5').error("The tracker cylinder half length needs to numerical (in meters).")
4418+ elif objs[2] == 'particle_propagator':
4419+ if args[2] in ['on', 'off']:
4420+ self.main.superfastsim.propagator = (args[2]=='on')
4421+ else:
4422+ logging.getLogger('MA5').error("Particle propagation can be either on or off (default: off).")
4423 else:
4424 user_info = UserInfo()
4425 user_info.ReadUserOptions(self.main.archi_info.ma5dir+'/madanalysis/input/installation_options.dat')
4426
4427=== modified file 'madanalysis/interpreter/cmd_submit.py'
4428--- madanalysis/interpreter/cmd_submit.py 2020-07-03 08:05:49 +0000
4429+++ madanalysis/interpreter/cmd_submit.py 2021-06-30 09:39:51 +0000
4430@@ -22,6 +22,7 @@
4431 ################################################################################
4432
4433
4434+from __future__ import absolute_import
4435 from madanalysis.interpreter.cmd_base import CmdBase
4436 from madanalysis.IOinterface.job_writer import JobWriter
4437 from madanalysis.IOinterface.layout_writer import LayoutWriter
4438@@ -40,8 +41,8 @@
4439 import logging
4440 import glob
4441 import os
4442-import commands
4443 import shutil
4444+from six.moves import range
4445
4446 class CmdSubmit(CmdBase):
4447 """Command SUBMIT"""
4448@@ -76,7 +77,7 @@
4449 self.logger.warning("Command 'resubmit' takes no argument. Any argument will be skipped.")
4450
4451 # Checking presence of a valid job
4452- if self.main.lastjob_name is "":
4453+ if self.main.lastjob_name == "":
4454 self.logger.error("an analysis must be defined and ran before using the resubmit command.")
4455 return False
4456
4457@@ -363,12 +364,8 @@
4458 if not Recaster.init():
4459 return False
4460 self.main.recasting.delphesruns = Recaster.delphes_runcard
4461- ### fastsim
4462- if not Recaster.fastsim():
4463- self.logger.error("job submission aborted.")
4464- return False
4465- ### Analyses
4466- if not Recaster.analysis():
4467+ ### Executing the PAD
4468+ if not Recaster.execute():
4469 self.logger.error("job submission aborted.")
4470 return False
4471 # Otherwise, standard job
4472
4473=== modified file 'madanalysis/interpreter/cmd_swap.py'
4474--- madanalysis/interpreter/cmd_swap.py 2020-07-03 08:05:49 +0000
4475+++ madanalysis/interpreter/cmd_swap.py 2021-06-30 09:39:51 +0000
4476@@ -22,8 +22,10 @@
4477 ################################################################################
4478
4479
4480+from __future__ import absolute_import
4481 from madanalysis.interpreter.cmd_base import CmdBase
4482 import logging
4483+from six.moves import range
4484
4485 class CmdSwap(CmdBase):
4486 """Command SWAP"""
4487
4488=== modified file 'madanalysis/interpreter/history.py'
4489--- madanalysis/interpreter/history.py 2020-07-03 08:05:49 +0000
4490+++ madanalysis/interpreter/history.py 2021-06-30 09:39:51 +0000
4491@@ -23,6 +23,7 @@
4492
4493
4494 # Python import
4495+from __future__ import absolute_import
4496 import os
4497
4498
4499
4500=== modified file 'madanalysis/interpreter/interpreter.py'
4501--- madanalysis/interpreter/interpreter.py 2020-07-03 08:05:49 +0000
4502+++ madanalysis/interpreter/interpreter.py 2021-06-30 09:39:51 +0000
4503@@ -28,6 +28,8 @@
4504
4505
4506 # Import Interpreter core
4507+from __future__ import absolute_import
4508+from __future__ import print_function
4509 from madanalysis.interpreter.interpreter_base import InterpreterBase
4510
4511 # Import MadAnalysis main class
4512@@ -60,6 +62,7 @@
4513 import logging
4514 import readline
4515 import os
4516+from six.moves import input
4517
4518
4519 #===============================================================================
4520@@ -219,7 +222,7 @@
4521 allowed_answers=['n','no','y','yes']
4522 answer=""
4523 while answer not in allowed_answers:
4524- answer=raw_input("Answer: ")
4525+ answer=input("Answer: ")
4526 answer=answer.lower()
4527 if answer=="no" or answer=="n":
4528 YES=False
4529@@ -440,9 +443,9 @@
4530
4531 self.stdout.write(self.prompt+readline.get_line_buffer())
4532 self.stdout.flush()
4533- except Exception, error:
4534+ except Exception as error:
4535 if __debug__:
4536- print error
4537+ print(error)
4538
4539 def getTerminalSize(self):
4540 def ioctl_GWINSZ(fd):
4541@@ -521,8 +524,8 @@
4542 data = compfunc(Ntext, line, Nbegidx, endidx)
4543 self.completion_matches = [p[to_rm:] for p in data
4544 if len(p)>to_rm]
4545- except Exception, error:
4546- print error
4547+ except Exception as error:
4548+ print(error)
4549 else:
4550 self.completion_prefix = ''
4551 self.completion_matches = compfunc(text, line, begidx, endidx)
4552@@ -533,7 +536,7 @@
4553
4554 try:
4555 return self.completion_matches[state]
4556- except IndexError, error:
4557+ except IndexError as error:
4558 #if __debug__:
4559 # print '\n Completion ERROR:'
4560 # print error
4561
4562=== modified file 'madanalysis/interpreter/interpreter_base.py'
4563--- madanalysis/interpreter/interpreter_base.py 2020-07-03 08:05:49 +0000
4564+++ madanalysis/interpreter/interpreter_base.py 2021-06-30 09:39:51 +0000
4565@@ -23,6 +23,7 @@
4566
4567
4568 """ A file containing different extension of the cmd basic python library"""
4569+from __future__ import absolute_import
4570 from madanalysis.IOinterface.text_file_reader import TextFileReader
4571 from madanalysis.core.script_stack import ScriptStack
4572 from madanalysis.interpreter.history import History
4573@@ -35,6 +36,7 @@
4574 import traceback
4575 import subprocess
4576 import readline
4577+from six.moves import range
4578
4579
4580 #===============================================================================
4581@@ -295,7 +297,7 @@
4582 def do_shell(self, line):
4583 "run a shell command"
4584
4585- if line.strip() is '':
4586+ if line.strip() == '':
4587 self.help_shell()
4588 else:
4589 self.logger.info(" Running the shell command: " + line + ".")
4590
4591=== modified file 'madanalysis/interpreter/ma5_interpreter.py'
4592--- madanalysis/interpreter/ma5_interpreter.py 2020-07-03 08:05:49 +0000
4593+++ madanalysis/interpreter/ma5_interpreter.py 2021-06-30 09:39:51 +0000
4594@@ -24,6 +24,7 @@
4595 ################################################################################
4596
4597
4598+from __future__ import absolute_import
4599 import logging
4600 import os
4601 import shutil
4602@@ -84,9 +85,9 @@
4603 old_environ = dict(os.environ)
4604
4605 # Checking if the correct release of Python is installed and tab completion
4606- if not sys.version_info[0] == 2 or sys.version_info[1] < 6:
4607+ if sys.version_info[1] < 6:
4608 raise InvalidPython('Python release '+ sys.version + ' not supported.\n' + \
4609- 'MadAnalysis 5 works only with python 2.6 or later (but not python 3.X).')
4610+ 'MadAnalysis 5 works only with python 2.7 or python 3.7 and later.')
4611
4612 # Checking the MA5 path and adding it to sys.path
4613 if not os.path.isdir(ma5dir):
4614@@ -257,7 +258,7 @@
4615 # initialization
4616 install_delphes = False
4617 install_delphesMA5tune = False
4618- user_info = UserInfo()
4619+ user_info = UserInfo()
4620
4621 # A few useful methods
4622 def validate_bool_key(key):
4623@@ -285,7 +286,7 @@
4624 user_info.SetValue(usrkey,value,'')
4625 update_options(usrkey,value)
4626 if archi_reset != '':
4627- self.main.archi_info.__dict__[archi_reset.keys()[0]] = archi_reset.values()[0]
4628+ self.main.archi_info.__dict__[list(archi_reset.keys())[0]] = list(archi_reset.values())[0]
4629 elif opts[key] not in [True,None]:
4630 self.logger.warning('Non-existing ' + key.replace('with-','') + \
4631 ' path. Automatic detection used.')
4632@@ -326,8 +327,10 @@
4633 install_delphes = validate_bool_key(key)
4634 elif key=='with-delphesMA5tune':
4635 install_delphesMA5tune = validate_bool_key(key)
4636+ elif key in ['with-PADForSFS','with-padforsfs','PADForSFS']:
4637+ install_padforsfs = value
4638 else:
4639- raise UNK_OPT('Unknown options for further_install')
4640+ raise UNK_OPT('Unknown options for further_install : '+str(key))
4641
4642 # Muting the logger
4643 lvl = self.logger.getEffectiveLevel()
4644@@ -367,6 +370,14 @@
4645 self.logger.error('Impossible to install fastjet.')
4646 return False
4647
4648+ # If FastJet is installed, install PADForSFS
4649+ if self.main.archi_info.has_fastjet and install_padforsfs:
4650+ self.logger.info('Installing PAD for SFS')
4651+ installer=InstallManager(self.main)
4652+ if not installer.Execute('padforsfs'):
4653+ self.logger.error('Impossible to install PAD For SFS.')
4654+ return False
4655+
4656 # Delphes installation
4657 if self.main.archi_info.has_root and user_info.delphes_veto and install_delphes:
4658 self.logger.warning('Delphes has been both vetoed and non-vetoed. Ignoring veto.')
4659
4660=== modified file 'madanalysis/interpreter/timer.py'
4661--- madanalysis/interpreter/timer.py 2020-07-03 08:05:49 +0000
4662+++ madanalysis/interpreter/timer.py 2021-06-30 09:39:51 +0000
4663@@ -22,6 +22,7 @@
4664 ################################################################################
4665
4666
4667+from __future__ import absolute_import
4668 import threading
4669 import time
4670
4671
4672=== modified file 'madanalysis/job/job_candidate_cut.py'
4673--- madanalysis/job/job_candidate_cut.py 2020-07-03 08:05:49 +0000
4674+++ madanalysis/job/job_candidate_cut.py 2021-06-30 09:39:51 +0000
4675@@ -22,6 +22,7 @@
4676 ################################################################################
4677
4678
4679+from __future__ import absolute_import
4680 from madanalysis.selection.histogram import Histogram
4681 from madanalysis.selection.instance_name import InstanceName
4682 from madanalysis.enumeration.observable_type import ObservableType
4683@@ -33,6 +34,7 @@
4684 from madanalysis.enumeration.combination_type import CombinationType
4685 import logging
4686 import copy
4687+from six.moves import range
4688
4689 def GetConditions(current,table):
4690
4691
4692=== modified file 'madanalysis/job/job_event_cut.py'
4693--- madanalysis/job/job_event_cut.py 2020-07-03 08:05:49 +0000
4694+++ madanalysis/job/job_event_cut.py 2021-06-30 09:39:51 +0000
4695@@ -22,6 +22,7 @@
4696 ################################################################################
4697
4698
4699+from __future__ import absolute_import
4700 from madanalysis.selection.histogram import Histogram
4701 from madanalysis.selection.instance_name import InstanceName
4702 from madanalysis.enumeration.observable_type import ObservableType
4703@@ -32,6 +33,7 @@
4704 from madanalysis.interpreter.cmd_cut import CmdCut
4705 from madanalysis.enumeration.combination_type import CombinationType
4706 import logging
4707+from six.moves import range
4708
4709
4710 def GetConditions(current,table):
4711@@ -208,7 +210,7 @@
4712 for combi in range(len(combination)):
4713 file.write(' }\n')
4714 file.write(' }\n')
4715- file(' if ( Ncounter ')
4716+ open(' if ( Ncounter ')
4717 file.write(OperatorType.convert2cpp(condition.operator) + \
4718 str(condition.threshold) + \
4719 ') '+tagName+'['+tagIndex+']=true;\n')
4720
4721=== modified file 'madanalysis/job/job_execute.py'
4722--- madanalysis/job/job_execute.py 2020-07-03 08:05:49 +0000
4723+++ madanalysis/job/job_execute.py 2021-06-30 09:39:51 +0000
4724@@ -22,6 +22,7 @@
4725 ################################################################################
4726
4727
4728+from __future__ import absolute_import
4729 from madanalysis.selection.histogram import Histogram
4730 from madanalysis.selection.instance_name import InstanceName
4731 from madanalysis.enumeration.observable_type import ObservableType
4732@@ -29,6 +30,7 @@
4733 from madanalysis.interpreter.cmd_cut import CmdCut
4734 import logging
4735 import copy
4736+from six.moves import range
4737
4738 def WriteExecute(file,main,part_list):
4739
4740
4741=== modified file 'madanalysis/job/job_finalize.py'
4742--- madanalysis/job/job_finalize.py 2020-07-03 08:05:49 +0000
4743+++ madanalysis/job/job_finalize.py 2021-06-30 09:39:51 +0000
4744@@ -22,6 +22,7 @@
4745 ################################################################################
4746
4747
4748+from __future__ import absolute_import
4749 import logging
4750 def WriteJobFinalize(file,main):
4751
4752
4753=== modified file 'madanalysis/job/job_header.py'
4754--- madanalysis/job/job_header.py 2020-07-03 08:05:49 +0000
4755+++ madanalysis/job/job_header.py 2021-06-30 09:39:51 +0000
4756@@ -22,12 +22,10 @@
4757 ################################################################################
4758
4759
4760-from madanalysis.enumeration.argument_type import ArgumentType
4761+from __future__ import absolute_import
4762 from madanalysis.selection.instance_name import InstanceName
4763 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4764-from madanalysis.observable.observable_base import ObservableBase
4765-import logging
4766-import sys
4767+from six.moves import range
4768
4769 def WriteHeader(file,main):
4770 # Preprocessor commands
4771@@ -40,9 +38,9 @@
4772 if main.archi_info.has_root:
4773 file.write('#include "SampleAnalyzer/Interfaces/root/RootMainHeaders.h"\n')
4774 file.write('\n')
4775- if main.superfastsim.tagger.rules!={}:
4776+ if main.superfastsim.isTaggerOn():
4777 file.write('#include "new_tagger.h"\n')
4778- if main.superfastsim.smearer.rules!={} or main.superfastsim.reco.rules!={}:
4779+ if main.superfastsim.isNewSmearerOn():
4780 file.write('#include "new_smearer_reco.h"\n')
4781
4782 # Namespace
4783@@ -54,7 +52,7 @@
4784 file.write(' INIT_ANALYSIS(user,"MadAnalysis5job")\n\n')
4785 file.write(' public : \n')
4786 file.write(' virtual MAbool Initialize(const MA5::Configuration& cfg,\n')
4787- file.write(' const std::map<std::string,std::string>& parameters);\n')
4788+ file.write(' const std::map<std::string,std::string>& parameters);\n')
4789 file.write(' virtual void Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files);\n')
4790 file.write(' virtual MAbool Execute(SampleFormat& sample, const EventFormat& event);\n')
4791 file.write('\n private : \n')
4792
4793=== modified file 'madanalysis/job/job_initialize.py'
4794--- madanalysis/job/job_initialize.py 2020-07-03 08:05:49 +0000
4795+++ madanalysis/job/job_initialize.py 2021-06-30 09:39:51 +0000
4796@@ -22,6 +22,7 @@
4797 ################################################################################
4798
4799
4800+from __future__ import absolute_import
4801 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4802 import logging
4803
4804
4805=== modified file 'madanalysis/job/job_main.py'
4806--- madanalysis/job/job_main.py 2020-07-03 08:05:49 +0000
4807+++ madanalysis/job/job_main.py 2021-06-30 09:39:51 +0000
4808@@ -22,6 +22,7 @@
4809 ################################################################################
4810
4811
4812+from __future__ import absolute_import
4813 from madanalysis.selection.histogram import Histogram
4814 from madanalysis.selection.instance_name import InstanceName
4815 from madanalysis.enumeration.observable_type import ObservableType
4816
4817=== modified file 'madanalysis/job/job_particle.py'
4818--- madanalysis/job/job_particle.py 2020-07-03 08:05:49 +0000
4819+++ madanalysis/job/job_particle.py 2021-06-30 09:39:51 +0000
4820@@ -22,6 +22,7 @@
4821 ################################################################################
4822
4823
4824+from __future__ import absolute_import
4825 from madanalysis.enumeration.argument_type import ArgumentType
4826 from madanalysis.selection.instance_name import InstanceName
4827 from madanalysis.enumeration.ma5_running_type import MA5RunningType
4828@@ -29,6 +30,7 @@
4829 import copy
4830 import logging
4831 import sys
4832+from six.moves import range
4833
4834 def GetParticles(main):
4835
4836
4837=== modified file 'madanalysis/job/job_plot.py'
4838--- madanalysis/job/job_plot.py 2020-07-03 08:05:49 +0000
4839+++ madanalysis/job/job_plot.py 2021-06-30 09:39:51 +0000
4840@@ -22,6 +22,7 @@
4841 ################################################################################
4842
4843
4844+from __future__ import absolute_import
4845 from madanalysis.selection.histogram import Histogram
4846 from madanalysis.selection.instance_name import InstanceName
4847 from madanalysis.enumeration.observable_type import ObservableType
4848@@ -30,6 +31,7 @@
4849 from madanalysis.enumeration.combination_type import CombinationType
4850 from madanalysis.interpreter.cmd_cut import CmdCut
4851 import logging
4852+from six.moves import range
4853
4854
4855 def WritePlot(file,main,iabs,ihisto):
4856
4857=== modified file 'madanalysis/job/job_smearer_reco_header.py'
4858--- madanalysis/job/job_smearer_reco_header.py 2020-07-03 08:05:49 +0000
4859+++ madanalysis/job/job_smearer_reco_header.py 2021-06-30 09:39:51 +0000
4860@@ -32,6 +32,8 @@
4861 self.tau_smearing = False
4862 self.jet_smearing = False
4863 self.constituent_smearing = False
4864+ self.track_smearing = False
4865+ self.propagator = fastsim.propagator
4866 for key, val in self.fastsim.smearer.rules.items():
4867 if val['id_true'] in ['21','j']:
4868 self.jet_smearing = (self.fastsim.jetrecomode == 'jets')
4869@@ -44,6 +46,8 @@
4870 self.electron_smearing = True
4871 elif val['id_true'] in ['15','ta']:
4872 self.tau_smearing = True
4873+ elif val['id_true'] in ['track']:
4874+ self.track_smearing = True
4875 for key, val in self.fastsim.reco.rules.items():
4876 if val['id_reco'] in ['21','j']:
4877 self.jet_smearing = True
4878@@ -55,6 +59,26 @@
4879 self.electron_smearing = True
4880 elif val['id_reco'] in ['15','ta']:
4881 self.tau_smearing = True
4882+ elif val['id_reco'] in ['track']:
4883+ self.track_smearing = True
4884+ for key, val in self.fastsim.scaling.rules.items():
4885+ if val['id_true'] == 'JES':
4886+ self.jet_smearing = True
4887+ elif val['id_true'] in ['21','j']:
4888+ if self.fastsim.jetrecomode == 'jets':
4889+ self.jet_smearing = True
4890+ else:
4891+ self.constituent_smearing = True
4892+ elif val['id_true'] in ['22','a']:
4893+ self.photon_smearing = True
4894+ elif val['id_true'] in ['13','mu']:
4895+ self.muon_smearing = True
4896+ elif val['id_true'] in ['11','e']:
4897+ self.electron_smearing = True
4898+ elif val['id_true'] in ['15','ta']:
4899+ self.tau_smearing = True
4900+ elif val['id_true'] in ['track']:
4901+ self.track_smearing = True
4902
4903
4904 ## Writing NewSmearer.h
4905@@ -69,42 +93,54 @@
4906 file.write('{\n')
4907 file.write(' class NewSmearer: public SmearerBase\n')
4908 file.write(' {\n')
4909- file.write(' private:\n')
4910- file.write(' MCParticleFormat output_;\n')
4911 file.write(' public :\n')
4912 file.write(' /// Constructor without argument\n')
4913- file.write(' NewSmearer() {}\n')
4914+ file.write(' NewSmearer()\n')
4915+ file.write(' {\n')
4916+ file.write(' output_.Reset();\n')
4917+ file.write(' }\n')
4918 file.write(' /// Destructor\n')
4919 file.write(' ~NewSmearer() {}\n\n')
4920 file.write(' /// Smearer methods: \n')
4921+ file.write(' /// Set parameters\n')
4922+ file.write(' void SetParameters()\n')
4923+ file.write(' {\n')
4924+ file.write(' // Magnetic field along beam axis\n')
4925+ file.write(' Bz_ = {:.6E};\n'.format(self.fastsim.mag_field))
4926+ # Not in use at the moment
4927+ # file.write(' // Tracker cylinder radius\n')
4928+ # file.write(' Radius_ = {:.6E};\n'.format(self.fastsim.radius))
4929+ # file.write(' // Tracker half length\n')
4930+ # file.write(' HalfLength_ = {:.6E};\n'.format(self.fastsim.half_length))
4931+ file.write(' // Code-efficiency parameters\n')
4932+ file.write(' ParticlePropagator_ = '+(self.propagator*'true' + (not self.propagator)*'false')+';\n')
4933+ file.write(' MuonSmearer_ = '+(self.muon_smearing*'true' + (not self.muon_smearing)*'false')+';\n')
4934+ file.write(' ElectronSmearer_ = '+(self.electron_smearing*'true'+ (not self.electron_smearing)*'false')+';\n')
4935+ file.write(' PhotonSmearer_ = '+(self.photon_smearing*'true' + (not self.photon_smearing)*'false')+';\n')
4936+ file.write(' TauSmearer_ = '+(self.tau_smearing*'true' + (not self.tau_smearing)*'false')+';\n')
4937+ file.write(' JetSmearer_ = '+(self.jet_smearing*'true' + (not self.jet_smearing)*'false')+';\n')
4938+ file.write(' }\n\n')
4939 if self.electron_smearing:
4940 file.write(' /// Electron smearing method\n')
4941 file.write(' MCParticleFormat ElectronSmearer(const MCParticleFormat * part);\n\n')
4942- file.write(' // Boolean to check if electron smearer is on\n')
4943- file.write(' MAbool isElectronSmearerOn() {return true;}\n\n')
4944 if self.muon_smearing:
4945 file.write(' /// Muon smearing method\n')
4946 file.write(' MCParticleFormat MuonSmearer(const MCParticleFormat * part);\n\n')
4947- file.write(' // Boolean to check if muon smearer is on\n')
4948- file.write(' MAbool isMuonSmearerOn() {return true;}\n\n')
4949 if self.photon_smearing:
4950 file.write(' /// Photon smearing method\n')
4951 file.write(' MCParticleFormat PhotonSmearer(const MCParticleFormat * part);\n\n')
4952- file.write(' // Boolean to check if photon smearer is on\n')
4953- file.write(' MAbool isPhotonSmearerOn() {return true;}\n\n')
4954 if self.tau_smearing:
4955 file.write(' /// Hadronic Tau smearing method\n')
4956 file.write(' MCParticleFormat TauSmearer(const MCParticleFormat * part);\n\n')
4957- file.write(' // Boolean to check if tau smearer is on\n')
4958- file.write(' MAbool isTauSmearerOn() {return true;}\n\n')
4959 if self.jet_smearing:
4960 file.write(' /// Jet smearing method\n')
4961 file.write(' MCParticleFormat JetSmearer(const MCParticleFormat * part);\n\n')
4962- file.write(' // Boolean to check if jet smearer is on\n')
4963- file.write(' MAbool isJetSmearerOn() {return true;}\n\n')
4964 if self.constituent_smearing:
4965 file.write(' /// Jet Constituent smearing method\n')
4966 file.write(' MCParticleFormat ConstituentSmearer(const MCParticleFormat * part);\n\n')
4967+ if self.track_smearing:
4968+ file.write(' /// Track smearing method\n')
4969+ file.write(' MCParticleFormat TrackSmearer(const MCParticleFormat * part);\n\n')
4970 file.write(' };\n')
4971 file.write('}\n')
4972 file.write('#endif')
4973@@ -146,3 +182,23 @@
4974 file.write('#endif')
4975
4976
4977+ ## scales and bounds
4978+ def WriteNewScales(self,file):
4979+ file.write('#ifndef SC_H_INCLUDED\n')
4980+ file.write('#define SC_H_INCLUDED\n')
4981+ file.write('#include <cmath>\n')
4982+ file.write('#include <math.h>\n')
4983+ file.write('#include <iostream>\n')
4984+ for key, value in self.fastsim.scaling.rules.items():
4985+ for eff_key in value['efficiencies'].keys():
4986+ eff_fnc = value['efficiencies'][eff_key]['function']
4987+ eff_bnd = value['efficiencies'][eff_key]['bounds' ]
4988+ file.write(eff_fnc.tocpp('MAdouble64', 'scale_'+\
4989+ str(value['id_true']) + '_' + str(value['obs'])+'_'+\
4990+ str(eff_key))+'\n')
4991+ file.write(eff_bnd.tocpp('MAbool', \
4992+ 'scale_bnd_'+str(value['id_true']) +\
4993+ '_' + str(value['obs'])+'_'+\
4994+ str(eff_key)) + '\n')
4995+ file.write('#endif')
4996+
4997
4998=== modified file 'madanalysis/job/job_smearer_reco_main.py'
4999--- madanalysis/job/job_smearer_reco_main.py 2020-07-03 08:05:49 +0000
5000+++ madanalysis/job/job_smearer_reco_main.py 2021-06-30 09:39:51 +0000
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches