Merge lp:~ma5/madanalysis5/v1.1.10beta into lp:madanalysis5

Proposed by Eric Conte
Status: Merged
Approved by: Eric Conte
Approved revision: 157
Merged at revision: 72
Proposed branch: lp:~ma5/madanalysis5/v1.1.10beta
Merge into: lp:madanalysis5
Diff against target: 22817 lines (+13099/-5975)
148 files modified
bin/ma5 (+204/-179)
madanalysis/IOinterface/delphes_migration.py (+81/-0)
madanalysis/IOinterface/job_reader.py (+3/-3)
madanalysis/IOinterface/job_writer.py (+349/-277)
madanalysis/IOinterface/library_writer.py (+609/-50)
madanalysis/IOinterface/shell_command.py (+82/-0)
madanalysis/UpdateNotes.txt (+84/-0)
madanalysis/configuration/delfes_configuration.py (+156/-0)
madanalysis/configuration/delphes_configuration.py (+15/-0)
madanalysis/configuration/fastsim_configuration.py (+44/-6)
madanalysis/core/config_checker.py (+489/-223)
madanalysis/core/expert_mode.py (+12/-7)
madanalysis/core/library_builder.py (+24/-6)
madanalysis/core/linux_architecture.py (+145/-2)
madanalysis/core/main.py (+227/-57)
madanalysis/enumeration/observable_type.py (+4/-4)
madanalysis/input/installation_options.dat (+35/-0)
madanalysis/input/particles_name_default.txt (+2/-3)
madanalysis/interpreter/cmd_base.py (+1/-1)
madanalysis/interpreter/cmd_install.py (+91/-11)
madanalysis/interpreter/cmd_plot.py (+6/-2)
madanalysis/interpreter/cmd_set.py (+1/-1)
madanalysis/interpreter/cmd_submit.py (+11/-11)
madanalysis/interpreter/interpreter.py (+38/-1)
madanalysis/interpreter/interpreter_base.py (+1/-1)
madanalysis/job/job_candidate_cut.py (+16/-4)
madanalysis/job/job_event_cut.py (+14/-2)
madanalysis/job/job_execute.py (+3/-3)
madanalysis/job/job_header.py (+3/-3)
madanalysis/job/job_initialize.py (+9/-1)
madanalysis/job/job_plot.py (+52/-10)
madanalysis/layout/cutflow.py (+0/-18)
madanalysis/observable/observable_list.py (+49/-16)
madanalysis/selection/histogram.py (+1/-1)
tools/SampleAnalyzer/Analyzer/AnalyzerBase.h (+22/-5)
tools/SampleAnalyzer/Analyzer/AnalyzerManager.cpp (+5/-3)
tools/SampleAnalyzer/Analyzer/AnalyzerManager.h (+0/-3)
tools/SampleAnalyzer/Core/Configuration.cpp (+6/-3)
tools/SampleAnalyzer/Core/Configuration.h (+8/-2)
tools/SampleAnalyzer/Core/SampleAnalyzer.cpp (+184/-71)
tools/SampleAnalyzer/Core/SampleAnalyzer.h (+24/-8)
tools/SampleAnalyzer/Core/castorstream.cpp (+0/-160)
tools/SampleAnalyzer/Counter/CounterManager.cpp (+8/-4)
tools/SampleAnalyzer/Counter/CounterManager.h (+9/-1)
tools/SampleAnalyzer/Counter/MultiRegionCounter.h (+85/-0)
tools/SampleAnalyzer/Counter/MultiRegionCounterManager.h (+89/-0)
tools/SampleAnalyzer/DataFormat/EventFormat.h (+0/-35)
tools/SampleAnalyzer/DataFormat/GeneratorInfo.h (+3/-2)
tools/SampleAnalyzer/DataFormat/IsolationConeType.h (+118/-0)
tools/SampleAnalyzer/DataFormat/MCEventFormat.h (+4/-2)
tools/SampleAnalyzer/DataFormat/MCParticleFormat.h (+24/-6)
tools/SampleAnalyzer/DataFormat/ParticleBaseFormat.h (+36/-3)
tools/SampleAnalyzer/DataFormat/RecEventFormat.h (+4/-2)
tools/SampleAnalyzer/DataFormat/RecJetFormat.h (+17/-1)
tools/SampleAnalyzer/DataFormat/RecLeptonFormat.h (+18/-2)
tools/SampleAnalyzer/DataFormat/RecMETFormat.h (+4/-2)
tools/SampleAnalyzer/DataFormat/RecParticleFormat.h (+6/-2)
tools/SampleAnalyzer/DataFormat/RecPhotonFormat.h (+16/-2)
tools/SampleAnalyzer/DataFormat/RecTauFormat.h (+6/-2)
tools/SampleAnalyzer/DataFormat/RecTrackFormat.h (+19/-1)
tools/SampleAnalyzer/DataFormat/SampleFormat.h (+4/-1)
tools/SampleAnalyzer/Detector/DetectorManager.cpp (+7/-1)
tools/SampleAnalyzer/Detector/delfes_card_ATLAS.tcl (+596/-0)
tools/SampleAnalyzer/Detector/delfes_card_ATLAS_PileUp.tcl (+713/-0)
tools/SampleAnalyzer/Detector/delfes_card_CMS.tcl (+609/-0)
tools/SampleAnalyzer/Detector/delfes_card_CMS_PileUp.tcl (+750/-0)
tools/SampleAnalyzer/Detector/delphes_card_ATLAS.tcl (+547/-0)
tools/SampleAnalyzer/Detector/delphes_card_ATLAS_PileUp.tcl (+665/-0)
tools/SampleAnalyzer/Detector/delphes_card_CMS.tcl (+559/-0)
tools/SampleAnalyzer/Detector/delphes_card_CMS_PileUp.tcl (+702/-0)
tools/SampleAnalyzer/Filter/FilterBase.h (+0/-143)
tools/SampleAnalyzer/Filter/FilterManager.cpp (+0/-49)
tools/SampleAnalyzer/Filter/FilterManager.h (+0/-63)
tools/SampleAnalyzer/Interfaces/delfes/DelfesTreeReader.cpp (+429/-0)
tools/SampleAnalyzer/Interfaces/delfes/DelfesTreeReader.h (+136/-0)
tools/SampleAnalyzer/Interfaces/delfes/DetectorDelfes.cpp (+357/-0)
tools/SampleAnalyzer/Interfaces/delfes/DetectorDelfes.h (+116/-0)
tools/SampleAnalyzer/Interfaces/delphes/DelphesTreeReader.cpp (+331/-0)
tools/SampleAnalyzer/Interfaces/delphes/DelphesTreeReader.h (+135/-0)
tools/SampleAnalyzer/Interfaces/delphes/DetectorDelphes.cpp (+1/-3)
tools/SampleAnalyzer/Interfaces/delphes/DetectorDelphes.h (+0/-2)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringCDFJetClu.cpp (+11/-5)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringCDFJetClu.h (+1/-5)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringCDFMidpoint.cpp (+11/-6)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringCDFMidpoint.h (+1/-6)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringFastJet.cpp (+27/-16)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringFastJet.h (+8/-11)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringGridJet.cpp (+12/-5)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringGridJet.h (+2/-5)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringPlugin.h (+6/-8)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringSISCone.cpp (+12/-5)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringSISCone.h (+1/-6)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringStandard.cpp (+37/-14)
tools/SampleAnalyzer/Interfaces/fastjet/JetClusteringStandard.h (+3/-5)
tools/SampleAnalyzer/Interfaces/fastjet/MergingPlots.cpp (+10/-5)
tools/SampleAnalyzer/Interfaces/fastjet/MergingPlots.h (+7/-8)
tools/SampleAnalyzer/Interfaces/zlib/gz_file.h (+62/-0)
tools/SampleAnalyzer/Interfaces/zlib/gz_istream.h (+1/-1)
tools/SampleAnalyzer/Interfaces/zlib/gz_ostream.h (+1/-1)
tools/SampleAnalyzer/Interfaces/zlib/gz_streambase.cpp (+32/-8)
tools/SampleAnalyzer/Interfaces/zlib/gz_streambase.h (+12/-14)
tools/SampleAnalyzer/JetClustering/JetClustererManager.cpp (+11/-11)
tools/SampleAnalyzer/JetClustering/TaggerBase.cpp (+2/-2)
tools/SampleAnalyzer/JetClustering/TauTagger.cpp (+22/-2)
tools/SampleAnalyzer/JetClustering/bTagger.cpp (+3/-3)
tools/SampleAnalyzer/JetClustering/cTagger.cpp (+4/-4)
tools/SampleAnalyzer/Plot/Histo.cpp (+18/-1)
tools/SampleAnalyzer/Plot/Histo.h (+23/-0)
tools/SampleAnalyzer/Plot/PlotBase.h (+4/-0)
tools/SampleAnalyzer/Plot/PlotManager.h (+22/-4)
tools/SampleAnalyzer/Reader/DelphesReader.cpp (+0/-410)
tools/SampleAnalyzer/Reader/DelphesReader.h (+0/-163)
tools/SampleAnalyzer/Reader/FACdataformat.cpp (+0/-39)
tools/SampleAnalyzer/Reader/HEPMCReader.cpp (+3/-3)
tools/SampleAnalyzer/Reader/LHEReader.cpp (+11/-5)
tools/SampleAnalyzer/Reader/ROOTReader.cpp (+92/-177)
tools/SampleAnalyzer/Reader/ROOTReader.h (+65/-23)
tools/SampleAnalyzer/Reader/ReaderManager.cpp (+2/-15)
tools/SampleAnalyzer/Reader/ReaderTextBase.cpp (+1/-13)
tools/SampleAnalyzer/Reader/ReaderTextBase.h (+1/-11)
tools/SampleAnalyzer/Reader/STDHEPreader.cpp (+99/-35)
tools/SampleAnalyzer/Reader/TreeReaderBase.h (+100/-0)
tools/SampleAnalyzer/RegionSelection/RegionSelection.cpp (+36/-0)
tools/SampleAnalyzer/RegionSelection/RegionSelection.h (+115/-0)
tools/SampleAnalyzer/RegionSelection/RegionSelectionManager.cpp (+127/-0)
tools/SampleAnalyzer/RegionSelection/RegionSelectionManager.h (+273/-0)
tools/SampleAnalyzer/Service/Identification.h (+270/-0)
tools/SampleAnalyzer/Service/LoopService.cpp (+1/-1)
tools/SampleAnalyzer/Service/LoopService.h (+2/-2)
tools/SampleAnalyzer/Service/MCconfig.h (+2/-1)
tools/SampleAnalyzer/Service/Physics.cpp (+9/-7)
tools/SampleAnalyzer/Service/Physics.h (+23/-668)
tools/SampleAnalyzer/Service/RECconfig.h (+1/-1)
tools/SampleAnalyzer/Service/SortingService.cpp (+27/-0)
tools/SampleAnalyzer/Service/SortingService.h (+279/-0)
tools/SampleAnalyzer/Service/TransverseVariables.cpp (+601/-0)
tools/SampleAnalyzer/Service/TransverseVariables.h (+216/-0)
tools/SampleAnalyzer/Test/test.cpp (+66/-0)
tools/SampleAnalyzer/Writer/SAFWriter.cpp (+18/-2)
tools/SampleAnalyzer/Writer/SAFWriter.h (+2/-5)
tools/SampleAnalyzer/Writer/WriterTextBase.cpp (+8/-3)
tools/SampleAnalyzer/Writer/WriterTextBase.h (+0/-6)
tools/SampleAnalyzer/delphes_card_ATLAS.tcl (+0/-536)
tools/SampleAnalyzer/delphes_card_ATLAS_PileUp.tcl (+0/-617)
tools/SampleAnalyzer/delphes_card_CMS.tcl (+0/-544)
tools/SampleAnalyzer/delphes_card_CMS_PileUp.tcl (+0/-626)
tools/SampleAnalyzer/newAnalyzer.py (+50/-15)
tools/SampleAnalyzer/newFilter.py (+0/-399)
To merge this branch: bzr merge lp:~ma5/madanalysis5/v1.1.10beta
Reviewer Review Type Date Requested Status
Eric Conte Pending
Review via email: mp+219948@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
=== modified file 'bin/ma5'
--- bin/ma5 2013-10-29 09:21:58 +0000
+++ bin/ma5 2014-05-17 19:51:11 +0000
@@ -24,6 +24,194 @@
24################################################################################24################################################################################
2525
2626
27def MainSession():
28
29 # Importing MadAnalysis main class
30 from madanalysis.core.main import Main
31 main = Main()
32 main.ma5dir = ma5dir
33
34 # Release version
35 # Do not touch it !!!!!
36 main.version = "1.1.10.35"
37 main.date = "2014/05/09"
38
39 # Checking arguments
40 import getopt
41 try:
42 optlist, arglist = getopt.getopt(sys.argv[1:], \
43 "PHReEvhfmsb", \
44 ["partonlevel","hadronlevel","recolevel",\
45 "expert","version","release","help",\
46 "forced","script","mg5","autocheck","build"])
47 except getopt.GetoptError, err:
48 logging.error(str(err))
49 usage()
50 sys.exit()
51
52 # Reading aguments
53 partonlevel = False
54 hadronlevel = False
55 recolevel = False
56 expertmode = False
57 forcedmode = False
58 mg5mode = False
59 scriptmode = False
60 autocheck = False
61 build = False
62 for o,a in optlist:
63 if o in ("-P","--partonlevel"):
64 partonlevel=True
65 elif o in ("-H","--hadronlevel"):
66 hadronlevel=True
67 elif o in ("-R","--recolevel"):
68 recolevel=True
69 elif o in ("-E","-e","--expert"):
70 expertmode=True
71 elif o in ("-f","--forced"):
72 forcedmode=True
73 elif o in ("-m","--mg5"):
74 mg5mode=True
75 elif o in ("-s","--script"):
76 scriptmode=True
77 elif o in ("-v","--version","--release"):
78 logging.info("MA5 release : " + main.version + " " + main.date + "\n")
79 sys.exit()
80 elif o in ("--autocheck"):
81 autocheck = True
82 elif o in ("-b","--build"):
83 build = True
84 elif o in ("-h","--help"):
85 usage()
86 sys.exit()
87
88 # Checking compatibility between arguments
89 if partonlevel and hadronlevel:
90 logging.error("Parton mode and hadron mode cannot be set in a same time.\n"
91 "Please choose only one of these modes.")
92 sys.exit()
93 elif partonlevel and recolevel:
94 logging.error("Parton mode and reco mode cannot be set in a same time.\n"
95 "Please choose only one of these modes.")
96 sys.exit()
97
98 elif hadronlevel and recolevel:
99 logging.error("Hadron mode and reco mode cannot be set in a same time.\n"
100 "Please choose only one of these modes.")
101 sys.exit()
102 if scriptmode:
103 forcedmode=True
104
105 # Setting argument in the main program
106 from madanalysis.enumeration.ma5_running_type import MA5RunningType
107 if partonlevel:
108 main.mode=MA5RunningType.PARTON
109 elif hadronlevel:
110 main.mode=MA5RunningType.HADRON
111 elif recolevel:
112 main.mode=MA5RunningType.RECO
113 from madanalysis.enumeration.normalize_type import NormalizeType
114 main.normalize=NormalizeType.NONE
115
116 # Re-initializing the list of observables (hadron-level or reco-level)
117 if hadronlevel or recolevel:
118 main.InitObservables(main.mode)
119
120 main.forced = forcedmode
121 Main.forced = forcedmode
122 main.script = scriptmode
123 main.mg5 = mg5mode
124
125 # Setting batch mode for ROOT
126 #sys.argv.append('-b-')
127
128 # Displaying header
129 logging.info("")
130 logging.info(\
131 "*************************************************************\n" + \
132 "* *\n" + \
133 "* W E L C O M E to M A D A N A L Y S I S 5 *\n" + \
134 "* ______ ______ *\n" + \
135 "* /'\_/`\/\ __ \/\ ___\ *\n" + \
136 "* /\ \ \ \_\ \ \ \__/ *\n" + \
137 "* \ \ \__\ \ \ __ \ \___``\ *\n" + \
138 "* \ \ \_/\ \ \ \/\ \/\ \_\ \ *\n" + \
139 "* \ \_\\\ \_\ \_\ \_\ \____/ *\n" + \
140 "* \/_/ \/_/\/_/\/_/\/___/ *\n" + \
141 "* *\n" + \
142 "* MA5 release : " + \
143 "%-24s" % main.version + "%+15s" % main.date + " *\n" + \
144 "* *\n" + \
145 "* Comput. Phys. Commun. 184 (2013) 222-256 *\n" + \
146 "* *\n" + \
147 "* The MadAnalysis Development Team - Please visit us at *\n" + \
148 "* https://launchpad.net/madanalysis5 *\n" + \
149 "* *\n" + \
150 "* Type 'help' for in-line help. *\n" + \
151 "* *\n" + \
152 "*************************************************************")
153
154 # Displaying special banner if auto-check mode is activated
155 if autocheck:
156 logging.info("")
157 logging.info(" AUTO-CHECK MODE")
158 logging.info("")
159
160 # Checking the present linux configuration
161 if not main.CheckLinuxConfig(detail=autocheck):
162 sys.exit()
163
164 # Building (if necesserary) the SampleAnalyzer library
165 if not main.BuildLibrary(forced=build):
166 sys.exit()
167
168 logging.info("*************************************************************")
169
170
171 # Auto-check mode
172 if autocheck:
173 pass
174
175 # Expert mode
176 elif expertmode:
177 from madanalysis.core.expert_mode import ExpertMode
178 main.expertmode = True
179 expert = ExpertMode(main)
180 if not expert.CreateDirectory():
181 sys.exit()
182 if not expert.Copy():
183 sys.exit()
184 expert.GiveAdvice()
185 return False
186
187 # Normal mode
188 else:
189
190 # Launching the interpreter
191 from madanalysis.interpreter.interpreter import Interpreter
192 interpreter = Interpreter(main)
193
194 # Looking for script
195 for arg in arglist:
196 filename=os.path.expanduser(arg)
197 filename=os.path.abspath(filename)
198 interpreter.load(filename)
199
200 # Exit if script mode activated
201 if len(arglist)!=0 and main.script:
202 interpreter.run_cmd("quit")
203 return False
204
205 # Interpreter loop
206 else:
207 interpreter.cmdloop()
208 if main.repeatSession==True:
209 return True
210 else:
211 return False
212
213
214
27def usage():215def usage():
28 logging.info("\nUsage of MadAnalysis 5")216 logging.info("\nUsage of MadAnalysis 5")
29 logging.info("------------------------")217 logging.info("------------------------")
@@ -50,6 +238,9 @@
50 logging.info("This optional argument is a list of filenames containing a "+\238 logging.info("This optional argument is a list of filenames containing a "+\
51 "set of MadAnalysis 5 commands. The file name are handled as "+\239 "set of MadAnalysis 5 commands. The file name are handled as "+\
52 "concatenated, and the commands are applied sequentially.\n")240 "concatenated, and the commands are applied sequentially.\n")
241
242
243
53 244
54"""This is the main executable, a simple frontend to set up the PYTHONPATH245"""This is the main executable, a simple frontend to set up the PYTHONPATH
55and call immediately the command line interface scripts"""246and call immediately the command line interface scripts"""
@@ -105,182 +296,16 @@
105 readline.__doc__ = 'GNU'296 readline.__doc__ = 'GNU'
106 readline.parse_and_bind("tab: complete")297 readline.parse_and_bind("tab: complete")
107298
108299# Loop over MA5 sessions
109# Importing MadAnalysis main class300# Goal: allowing to restart
110from madanalysis.core.main import Main301while True:
111main = Main()302 repeat = MainSession()
112main.ma5dir = ma5dir303 if not repeat:
113304 # Normal end
114# Release version305 break
115# Do not touch it !!!!! 306 from madanalysis.core.string_tools import StringTools
116main.version = "1.1.9"307 logging.info("")
117main.date = "2013/10/29"308 logging.info(StringTools.Fill('-',40))
118309 logging.info(StringTools.Center('RESTART THE MADANALYSIS 5 SESSION',40))
119# Checking arguments310 logging.info(StringTools.Fill('-',40))
120import getopt311 logging.info("")
121try:
122 optlist, arglist = getopt.getopt(sys.argv[1:], \
123 "PHReEvhfmsb", \
124 ["partonlevel","hadronlevel","recolevel",\
125 "expert","version","release","help",\
126 "forced","script","mg5","autocheck","build"])
127except getopt.GetoptError, err:
128 logging.error(str(err))
129 usage()
130 sys.exit()
131
132# Reading aguments
133partonlevel = False
134hadronlevel = False
135recolevel = False
136expertmode = False
137forcedmode = False
138mg5mode = False
139scriptmode = False
140autocheck = False
141build = False
142for o,a in optlist:
143 if o in ("-P","--partonlevel"):
144 partonlevel=True
145 elif o in ("-H","--hadronlevel"):
146 hadronlevel=True
147 elif o in ("-R","--recolevel"):
148 recolevel=True
149 elif o in ("-E","-e","--expert"):
150 expertmode=True
151 elif o in ("-f","--forced"):
152 forcedmode=True
153 elif o in ("-m","--mg5"):
154 mg5mode=True
155 elif o in ("-s","--script"):
156 scriptmode=True
157 elif o in ("-v","--version","--release"):
158 logging.info("MA5 release : " + main.version + " " + main.date + "\n")
159 sys.exit()
160 elif o in ("--autocheck"):
161 autocheck = True
162 elif o in ("-b","--build"):
163 build = True
164 elif o in ("-h","--help"):
165 usage()
166 sys.exit()
167
168# Checking compatibility between arguments
169if partonlevel and hadronlevel:
170 logging.error("Parton mode and hadron mode cannot be set in a same time.\n"
171 "Please choose only one of these modes.")
172 sys.exit()
173elif partonlevel and recolevel:
174 logging.error("Parton mode and reco mode cannot be set in a same time.\n"
175 "Please choose only one of these modes.")
176 sys.exit()
177
178elif hadronlevel and recolevel:
179 logging.error("Hadron mode and reco mode cannot be set in a same time.\n"
180 "Please choose only one of these modes.")
181 sys.exit()
182if scriptmode:
183 forcedmode=True
184
185# Setting argument in the main program
186from madanalysis.enumeration.ma5_running_type import MA5RunningType
187if partonlevel:
188 main.mode=MA5RunningType.PARTON
189elif hadronlevel:
190 main.mode=MA5RunningType.HADRON
191elif recolevel:
192 main.mode=MA5RunningType.RECO
193 from madanalysis.enumeration.normalize_type import NormalizeType
194 main.normalize=NormalizeType.NONE
195
196# Re-initializing the list of observables (hadron-level or reco-level)
197if hadronlevel or recolevel:
198 main.InitObservables(main.mode)
199
200
201main.forced = forcedmode
202Main.forced = forcedmode
203main.script = scriptmode
204main.mg5 = mg5mode
205
206# Setting batch mode for ROOT
207#sys.argv.append('-b-')
208
209# Displaying header
210logging.info("")
211logging.info(\
212"*************************************************************\n" + \
213"* *\n" + \
214"* W E L C O M E to M A D A N A L Y S I S 5 *\n" + \
215"* ______ ______ *\n" + \
216"* /'\_/`\/\ __ \/\ ___\ *\n" + \
217"* /\ \ \ \_\ \ \ \__/ *\n" + \
218"* \ \ \__\ \ \ __ \ \___``\ *\n" + \
219"* \ \ \_/\ \ \ \/\ \/\ \_\ \ *\n" + \
220"* \ \_\\\ \_\ \_\ \_\ \____/ *\n" + \
221"* \/_/ \/_/\/_/\/_/\/___/ *\n" + \
222"* *\n" + \
223"* MA5 release : " + \
224 "%-24s" % main.version + "%+15s" % main.date + " *\n" + \
225"* *\n" + \
226"* Comput. Phys. Commun. 184 (2013) 222-256 *\n" + \
227"* *\n" + \
228"* The MadAnalysis Development Team - Please visit us at *\n" + \
229"* https://launchpad.net/madanalysis5 *\n" + \
230"* *\n" + \
231"* Type 'help' for in-line help. *\n" + \
232"* *\n" + \
233"*************************************************************")
234
235# Displaying special banner if auto-check mode is activated
236if autocheck:
237 logging.info("")
238 logging.info(" AUTO-CHECK MODE")
239 logging.info("")
240
241
242# Checking the present linux configuration
243if not main.CheckLinuxConfig(detail=autocheck):
244 sys.exit()
245
246# Building (if necesserary) the SampleAnalyzer library
247if not main.BuildLibrary(forced=build):
248 sys.exit()
249
250logging.info("*************************************************************")
251
252
253# Auto-check mode
254if autocheck:
255 pass
256
257# Expert mode
258elif expertmode:
259 from madanalysis.core.expert_mode import ExpertMode
260 expert = ExpertMode(main)
261 if not expert.CreateDirectory():
262 sys.exit()
263 if not expert.Copy():
264 sys.exit()
265 expert.GiveAdvice()
266
267# Normal mode
268else:
269
270 # Launching the interpreter
271 from madanalysis.interpreter.interpreter import Interpreter
272 interpreter = Interpreter(main)
273
274 # Looking for script
275 for arg in arglist:
276 filename=os.path.expanduser(arg)
277 filename=os.path.abspath(filename)
278 interpreter.load(filename)
279
280 # Exit if script mode activated
281 if len(arglist)!=0 and main.script:
282 interpreter.run_cmd("quit")
283
284 # Interpreter loop
285 else:
286 interpreter.cmdloop()
287312
=== added file 'madanalysis/IOinterface/delphes_migration.py'
--- madanalysis/IOinterface/delphes_migration.py 1970-01-01 00:00:00 +0000
+++ madanalysis/IOinterface/delphes_migration.py 2014-05-17 19:51:11 +0000
@@ -0,0 +1,81 @@
1################################################################################
2#
3# Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks
4# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
5#
6# This file is part of MadAnalysis 5.
7# Official website: <https://launchpad.net/madanalysis5>
8#
9# MadAnalysis 5 is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# MadAnalysis 5 is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
21#
22################################################################################
23
24
25from madanalysis.selection.instance_name import InstanceName
26from madanalysis.IOinterface.folder_writer import FolderWriter
27from madanalysis.enumeration.ma5_running_type import MA5RunningType
28from madanalysis.core.string_tools import StringTools
29import logging
30import shutil
31import os
32import commands
33import glob
34
35class DelphesMigration():
36
37 def __init__(self,main):
38 self.main = main
39
40 def Migrate(self):
41 self.ChangeTreeNames()
42 self.ApplyPatch()
43
44 def ApplyPatch(self):
45 os.system('cp '+self.main.ma5dir+'/tools/SampleAnalyzer/Detector/patch_delfes.tgz '+\
46 self.main.ma5dir+'/tools/delfes/')
47 os.system('cd '+ self.main.ma5dir + '/tools/delfes/; tar xzf patch_delfes.tgz')
48
49
50 def ChangeTreeNames(self):
51 myfiles = glob.glob(self.main.ma5dir+'/tools/delfes/readers/Delphes*.cpp')
52 for myfile in myfiles:
53 self.ChangeTreeName(myfile)
54
55 def ChangeTreeName(self,filename):
56
57 try:
58 input = open(filename)
59 except:
60 return False
61
62 try:
63 output = open(filename+"~","w")
64 except:
65 return False
66
67 for line in input:
68 if line.find("treeWriter")!=-1 and line.find("ExRootTreeWriter")!=1:
69 line = line.replace('"Delphes"','"Delfes"')
70 output.write(line)
71
72 output.close()
73 input.close()
74 os.system("mv "+filename+"~ "+filename)
75 return True
76
77
78
79
80
81
082
=== modified file 'madanalysis/IOinterface/job_reader.py'
--- madanalysis/IOinterface/job_reader.py 2013-07-28 14:10:33 +0000
+++ madanalysis/IOinterface/job_reader.py 2014-05-17 19:51:11 +0000
@@ -293,9 +293,9 @@
293 beginTag.activate()293 beginTag.activate()
294 elif words[0].lower()=='</safheader>':294 elif words[0].lower()=='</safheader>':
295 beginTag.desactivate()295 beginTag.desactivate()
296 if words[0].lower()=='<saffoot>':296 if words[0].lower()=='<saffooter>':
297 endTag.activate()297 endTag.activate()
298 elif words[0].lower()=='</saffoot>':298 elif words[0].lower()=='</saffooter>':
299 endTag.desactivate()299 endTag.desactivate()
300 if words[0].lower()=='<sampleglobalinfo>':300 if words[0].lower()=='<sampleglobalinfo>':
301 globalTag.activate()301 globalTag.activate()
@@ -573,7 +573,7 @@
573 logging.error("SAF header <SAFheader> and </SAFheader> is not "+\573 logging.error("SAF header <SAFheader> and </SAFheader> is not "+\
574 "found.")574 "found.")
575 if endTag.Nactivated==0 or endTag.activated:575 if endTag.Nactivated==0 or endTag.activated:
576 logging.error("SAF foot <SAFfoot> and </SAFfoot> is not "+\576 logging.error("SAF footer <SAFfooter> and </SAFfooter> is not "+\
577 "found.")577 "found.")
578 if globalTag.Nactivated==0 or globalTag.activated:578 if globalTag.Nactivated==0 or globalTag.activated:
579 logging.error("Information corresponding to the block "+\579 logging.error("Information corresponding to the block "+\
580580
=== modified file 'madanalysis/IOinterface/job_writer.py'
--- madanalysis/IOinterface/job_writer.py 2013-10-29 09:21:58 +0000
+++ madanalysis/IOinterface/job_writer.py 2014-05-17 19:51:11 +0000
@@ -26,6 +26,7 @@
26from madanalysis.IOinterface.folder_writer import FolderWriter26from madanalysis.IOinterface.folder_writer import FolderWriter
27from madanalysis.enumeration.ma5_running_type import MA5RunningType27from madanalysis.enumeration.ma5_running_type import MA5RunningType
28from madanalysis.core.string_tools import StringTools28from madanalysis.core.string_tools import StringTools
29from madanalysis.IOinterface.shell_command import ShellCommand
29import logging30import logging
30import shutil31import shutil
31import os32import os
@@ -40,6 +41,7 @@
40 self.resubmit = resubmit41 self.resubmit = resubmit
41 self.libZIP = self.main.libZIP42 self.libZIP = self.main.libZIP
42 self.libDelphes = self.main.libDelphes43 self.libDelphes = self.main.libDelphes
44 self.libDelfes = self.main.libDelfes
43 self.output = self.main.output45 self.output = self.main.output
44 self.libFastjet = self.main.libFastJet46 self.libFastjet = self.main.libFastJet
45 self.fastsim = self.main.fastsim47 self.fastsim = self.main.fastsim
@@ -60,8 +62,6 @@
60 return False62 return False
61 elif not os.path.isdir(path+"/Build/SampleAnalyzer/Analyzer"):63 elif not os.path.isdir(path+"/Build/SampleAnalyzer/Analyzer"):
62 return False64 return False
63 elif not os.path.isdir(path+"/Build/SampleAnalyzer/Filter"):
64 return False
65 elif not os.path.isdir(path+"/Build/Main"):65 elif not os.path.isdir(path+"/Build/Main"):
66 return False66 return False
67 elif not os.path.isdir(path+"/Output"):67 elif not os.path.isdir(path+"/Output"):
@@ -99,11 +99,6 @@
99 logging.error("Impossible to create the folder 'Build/SampleAnalyzer/Analyzer'")99 logging.error("Impossible to create the folder 'Build/SampleAnalyzer/Analyzer'")
100 return False100 return False
101 try:101 try:
102 os.mkdir(path+"/Build/SampleAnalyzer/Filter")
103 except:
104 logging.error("Impossible to create the folder 'Build/SampleAnalyzer/Filter'")
105 return False
106 try:
107 os.mkdir(path+"/Build/Log")102 os.mkdir(path+"/Build/Log")
108 except:103 except:
109 logging.error("Impossible to create the folder 'Build/Log'")104 logging.error("Impossible to create the folder 'Build/Log'")
@@ -143,9 +138,6 @@
143 elif not os.path.isdir(self.path+"/Build/SampleAnalyzer/Analyzer"):138 elif not os.path.isdir(self.path+"/Build/SampleAnalyzer/Analyzer"):
144 logging.error("folder '"+self.path+"/Build/SampleAnalyzer/Analyzer' is not found")139 logging.error("folder '"+self.path+"/Build/SampleAnalyzer/Analyzer' is not found")
145 return False140 return False
146 elif not os.path.isdir(self.path+"/Build/SampleAnalyzer/Filter"):
147 logging.error("folder '"+self.path+"/Build/SampleAnalyzer/Filter' is not found")
148 return False
149 elif not os.path.isdir(self.path+"/Build/Main"):141 elif not os.path.isdir(self.path+"/Build/Main"):
150 logging.error("folder '"+self.path+"/Build/Main' is not found")142 logging.error("folder '"+self.path+"/Build/Main' is not found")
151 return False143 return False
@@ -170,19 +162,18 @@
170162
171 def CreateDelphesCard(self):163 def CreateDelphesCard(self):
172164
173 if self.fastsim.delphes.pileup=="":165 if self.main.fastsim.package=="delphes":
174 if self.fastsim.delphes.detector=='cms':166 cardname = self.main.fastsim.delphes.card
175 cardname = 'delphes_card_CMS.tcl'167 elif self.main.fastsim.package=="delfes":
176 elif self.fastsim.delphes.detector=='atlas':168 cardname = self.main.fastsim.delfes.card
177 cardname ='delphes_card_ATLAS.tcl'169
170 if self.main.fastsim.package=="delfes":
171 cfg=self.main.fastsim.delfes
178 else:172 else:
179 if self.fastsim.delphes.detector=='cms':173 cfg=self.main.fastsim.delphes
180 cardname = 'delphes_card_CMS_PileUp.tcl'
181 elif self.fastsim.delphes.detector=='atlas':
182 cardname ='delphes_card_ATLAS_PileUp.tcl'
183174
184 try:175 try:
185 input = open(self.ma5dir+"/tools/SampleAnalyzer/"+cardname,'r')176 input = open(self.ma5dir+"/tools/SampleAnalyzer/Detector/"+cardname,'r')
186 except:177 except:
187 pass178 pass
188179
@@ -191,18 +182,18 @@
191 except:182 except:
192 pass183 pass
193184
194 if self.main.fastsim.delphes.pileup!="":185 if cfg.pileup!="":
195 # Getting current dir186 # Getting current dir
196 theDir = os.getcwd()187 theDir = os.getcwd()
197188
198 # Adding file189 # Adding file
199 if self.main.fastsim.delphes.pileup.startswith('/'):190 if cfg.pileup.startswith('/'):
200 theFile = self.main.fastsim.delphes.pileup191 theFile = cfg.pileup
201 else: 192 else:
202 theFile = os.path.normpath(theDir+"/"+self.main.fastsim.delphes.pileup)193 theFile = os.path.normpath(theDir+"/"+cfg.pileup)
203194
204 for line in input:195 for line in input:
205 if self.main.fastsim.delphes.pileup!="":196 if cfg.pileup!="":
206 line=line.replace('MinBias.pileup',theFile)197 line=line.replace('MinBias.pileup',theFile)
207 output.write(line)198 output.write(line)
208199
@@ -234,22 +225,8 @@
234 except:225 except:
235 logging.error('Impossible to make executable the file "newAnalyzer"')226 logging.error('Impossible to make executable the file "newAnalyzer"')
236 return False227 return False
237 try:
238 shutil.copyfile\
239 (\
240 self.ma5dir+"/tools/SampleAnalyzer/newFilter.py",\
241 self.path+"/Build/SampleAnalyzer/newFilter.py"\
242 )
243 except:
244 logging.error('Impossible to copy the file "newFilter"')
245 return False
246 try:
247 os.chmod(self.path+"/Build/SampleAnalyzer/newFilter.py",0755)
248 except:
249 logging.error('Impossible to make executable the file "newFilter.py"')
250 return False
251228
252 if self.main.fastsim.package=="delphes":229 if self.main.fastsim.package in ["delphes","delfes"]:
253 self.CreateDelphesCard()230 self.CreateDelphesCard()
254231
255 return True232 return True
@@ -267,7 +244,8 @@
267244
268 def PrintIncludes(self,file):245 def PrintIncludes(self,file):
269 file.write('// SampleHeader header\n')246 file.write('// SampleHeader header\n')
270 file.write('#include \"SampleAnalyzer/Core/SampleAnalyzer.h\"\n')247 file.write('#include "SampleAnalyzer/Core/SampleAnalyzer.h"\n')
248 file.write('#include "SampleAnalyzer/Analyzer/analysisList.h"\n')
271 file.write('using namespace MA5;\n\n')249 file.write('using namespace MA5;\n\n')
272 return250 return
273251
@@ -278,7 +256,9 @@
278 file.write('int main(int argc, char *argv[])\n')256 file.write('int main(int argc, char *argv[])\n')
279 file.write('{\n')257 file.write('{\n')
280 file.write(' // Creating a manager\n')258 file.write(' // Creating a manager\n')
281 file.write(' SampleAnalyzer manager;\n\n')259 file.write(' SampleAnalyzer manager;\n')
260 file.write(' BuildUserTable(manager.AnalyzerList());\n')
261 file.write('\n')
282262
283 # Initializing263 # Initializing
284 file.write(' // ---------------------------------------------------\n')264 file.write(' // ---------------------------------------------------\n')
@@ -286,7 +266,11 @@
286 file.write(' // ---------------------------------------------------\n')266 file.write(' // ---------------------------------------------------\n')
287 file.write(' INFO << " * Initializing all components" << endmsg;\n\n')267 file.write(' INFO << " * Initializing all components" << endmsg;\n\n')
288 file.write(' // Initializing the manager\n')268 file.write(' // Initializing the manager\n')
289 file.write(' if (!manager.Initialize(argc,argv,"pdg.ma5")) '+\269 if self.main.expertmode:
270 file.write(' if (!manager.Initialize(argc,argv,"pdg.ma5",true)) '+\
271 'return 1;\n\n')
272 else:
273 file.write(' if (!manager.Initialize(argc,argv,"pdg.ma5")) '+\
290 'return 1;\n\n')274 'return 1;\n\n')
291 file.write(' // Creating data format for storing data\n')275 file.write(' // Creating data format for storing data\n')
292 file.write(' EventFormat myEvent;\n')276 file.write(' EventFormat myEvent;\n')
@@ -314,39 +298,48 @@
314298
315 # Fast-Simulation detector299 # Fast-Simulation detector
316 # + Case Fastsim300 # + Case Fastsim
317 if self.fastsim.package=="fastjet":301 if self.main.fastsim.package=="fastjet":
318 file.write(' //Getting pointer to the clusterer\n')302 file.write(' //Getting pointer to the clusterer\n')
319 file.write(' std::map<std::string, std::string> parametersC1;\n')303 file.write(' std::map<std::string, std::string> parametersC1;\n')
320 parameters = self.fastsim.SampleAnalyzerConfigString()304 parameters = self.main.fastsim.SampleAnalyzerConfigString()
321 for k,v in sorted(parameters.iteritems(),\305 for k,v in sorted(parameters.iteritems(),\
322 key=lambda (k,v): (k,v)):306 key=lambda (k,v): (k,v)):
323 file.write(' parametersC1["'+k+'"]="'+v+'";\n')307 file.write(' parametersC1["'+k+'"]="'+v+'";\n')
324 file.write(' JetClustererBase* cluster1 = \n')308 file.write(' JetClustererBase* cluster1 = \n')
325 file.write(' manager.InitializeJetClusterer("'+self.fastsim.clustering.algorithm+'",parametersC1);\n')309 file.write(' manager.InitializeJetClusterer("'+self.main.fastsim.clustering.algorithm+'",parametersC1);\n')
326 file.write(' if (cluster1==0) return 1;\n\n')310 file.write(' if (cluster1==0) return 1;\n\n')
327 311
328 # + Case Delphes312 # + Case Delphes
329 if self.fastsim.package=="delphes":313 if self.main.fastsim.package in ["delphes","delfes"]:
330 file.write(' //Getting pointer to fast-simulation package\n')314 file.write(' //Getting pointer to fast-simulation package\n')
331 file.write(' std::map<std::string, std::string> parametersD1;\n')315 file.write(' std::map<std::string, std::string> parametersD1;\n')
332 parameters = self.fastsim.SampleAnalyzerConfigString()316 if self.fastsim.package=="delfes":
317 cfg=self.main.fastsim.delfes
318 else:
319 cfg=self.main.fastsim.delphes
320 parameters = self.main.fastsim.SampleAnalyzerConfigString()
333 for k,v in sorted(parameters.iteritems(),\321 for k,v in sorted(parameters.iteritems(),\
334 key=lambda (k,v): (k,v)):322 key=lambda (k,v): (k,v)):
335 file.write(' parametersD1["'+k+'"]="'+v+'";\n')323 file.write(' parametersD1["'+k+'"]="'+v+'";\n')
336 file.write(' DetectorBase* fastsim1 = \n')324 file.write(' DetectorBase* fastsim1 = \n')
337 if self.fastsim.delphes.pileup=="":325
338 if self.fastsim.delphes.detector=='cms':326 if self.main.fastsim.package=="delphes":
339 cardname = 'delphes_card_CMS.tcl'327 cardname = self.main.fastsim.delphes.card
340 elif self.fastsim.delphes.detector=='atlas':328 elif self.main.fastsim.package=="delfes":
341 cardname ='delphes_card_ATLAS.tcl'329 cardname = self.main.fastsim.delfes.card
330
331 if self.main.fastsim.package=="delphes":
332 file.write(' manager.InitializeDetector("delphes","../../Input/'+cardname+'",parametersD1);\n')
342 else:333 else:
343 if self.fastsim.delphes.detector=='cms':334 file.write(' manager.InitializeDetector("delfes","../../Input/'+cardname+'",parametersD1);\n')
344 cardname = 'delphes_card_CMS_PileUp.tcl'335
345 elif self.fastsim.delphes.detector=='atlas':
346 cardname ='delphes_card_ATLAS_PileUp.tcl'
347 file.write(' manager.InitializeDetector("delphes","../../Input/'+cardname+'",parametersD1);\n')
348 file.write(' if (fastsim1==0) return 1;\n\n')336 file.write(' if (fastsim1==0) return 1;\n\n')
349337
338 # Post intialization (crating the output directory structure)
339 file.write(' // Post initialization (creates the new output directory structure)\n')
340 file.write(' if(!manager.PostInitialize()) return 1;\n\n')
341
342
350 # Loop343 # Loop
351 file.write(' // ---------------------------------------------------\n')344 file.write(' // ---------------------------------------------------\n')
352 file.write(' // EXECUTION\n')345 file.write(' // EXECUTION\n')
@@ -377,9 +370,11 @@
377 file.write(' manager.UpdateProgressBar();\n')370 file.write(' manager.UpdateProgressBar();\n')
378 if self.merging.enable:371 if self.merging.enable:
379 file.write(' analyzer2->Execute(mySample,myEvent);\n')372 file.write(' analyzer2->Execute(mySample,myEvent);\n')
380 if self.fastsim.package=="fastjet":373 if self.main.fastsim.package=="fastjet":
381 file.write(' cluster1->Execute(mySample,myEvent);\n')374 file.write(' cluster1->Execute(mySample,myEvent);\n')
382 elif self.fastsim.package=="delphes":375 elif self.main.fastsim.package=="delphes":
376 file.write(' fastsim1->Execute(mySample,myEvent);\n')
377 elif self.main.fastsim.package=="delfes":
383 file.write(' fastsim1->Execute(mySample,myEvent);\n')378 file.write(' fastsim1->Execute(mySample,myEvent);\n')
384 file.write(' analyzer1->Execute(mySample,myEvent);\n')379 file.write(' analyzer1->Execute(mySample,myEvent);\n')
385 if self.output!="":380 if self.output!="":
@@ -394,15 +389,6 @@
394 file.write(' INFO << " * Finalizing all components ..." << endmsg;\n\n')389 file.write(' INFO << " * Finalizing all components ..." << endmsg;\n\n')
395 file.write(' // Finalizing all components\n')390 file.write(' // Finalizing all components\n')
396 file.write(' manager.Finalize(mySamples,myEvent);\n')391 file.write(' manager.Finalize(mySamples,myEvent);\n')
397
398# file.write(' PHYSICS->mcConfig().AddInvisibleId(12);\n')
399# file.write(' PHYSICS->mcConfig().AddInvisibleId(-12);\n')
400# file.write(' PHYSICS->mcConfig().AddInvisibleId(14);\n')
401# file.write(' PHYSICS->mcConfig().AddInvisibleId(-14);\n')
402# file.write(' PHYSICS->mcConfig().AddInvisibleId(16);\n')
403# file.write(' PHYSICS->mcConfig().AddInvisibleId(-16);\n')
404# file.write(' PHYSICS->mcConfig().AddInvisibleId(1000022);\n\n')
405
406 file.write(' return 0;\n')392 file.write(' return 0;\n')
407 file.write('}\n')393 file.write('}\n')
408 return394 return
@@ -425,23 +411,6 @@
425 file.close()411 file.close()
426 return True412 return True
427413
428 def WriteEmptyFilterSource(self,main):
429 file = open(self.path+"/Build/SampleAnalyzer/Filter/filterList.cpp","w")
430 file.write('#include "SampleAnalyzer/Filter/FilterManager.h"\n')
431 file.write('using namespace MA5;\n')
432 file.write('#include <stdlib.h>\n\n')
433 file.write('// ------------------------------------------' +\
434 '-----------------------------------\n')
435 file.write('// BuildUserTable\n')
436 file.write('// ------------------------------------------' +\
437 '-----------------------------------\n')
438 file.write('void FilterManager::BuildUserTable()\n')
439 file.write('{\n')
440 file.write('}\n')
441 file.close()
442
443 return True
444
445 def WriteSelectionSource(self,main):414 def WriteSelectionSource(self,main):
446 main.selection.RefreshStat();415 main.selection.RefreshStat();
447 file = open(self.path+"/Build/SampleAnalyzer/Analyzer/user.cpp","w")416 file = open(self.path+"/Build/SampleAnalyzer/Analyzer/user.cpp","w")
@@ -450,23 +419,22 @@
450 job.WriteSource()419 job.WriteSource()
451 file.close()420 file.close()
452421
453 file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.cpp","w")422 file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.h","w")
454 file.write('#include "SampleAnalyzer/Analyzer/AnalyzerManager.h"\n')423 file.write('#include "SampleAnalyzer/Analyzer/AnalyzerManager.h"\n')
455 file.write('#include "SampleAnalyzer/Analyzer/user.h"\n')424 file.write('#include "SampleAnalyzer/Analyzer/user.h"\n')
456 file.write('#include "SampleAnalyzer/Service/LogStream.h"\n')425 file.write('#include "SampleAnalyzer/Service/LogStream.h"\n')
457 file.write('using namespace MA5;\n')426 file.write('\n')
458 file.write('#include <stdlib.h>\n\n')
459 file.write('// ------------------------------------------' +\427 file.write('// ------------------------------------------' +\
460 '-----------------------------------\n')428 '-----------------------------------\n')
461 file.write('// BuildUserTable\n')429 file.write('// BuildUserTable\n')
462 file.write('// ------------------------------------------' +\430 file.write('// ------------------------------------------' +\
463 '-----------------------------------\n')431 '-----------------------------------\n')
464 file.write('void AnalyzerManager::BuildUserTable()\n')432 file.write('void BuildUserTable(MA5::AnalyzerManager& manager)\n')
465 file.write('{\n')433 file.write('{\n')
466 file.write(' Add("MadAnalysis5job", new user);\n')434 file.write(' using namespace MA5;\n')
435 file.write(' manager.Add("MadAnalysis5job", new user);\n')
467 file.write('}\n')436 file.write('}\n')
468 file.close()437 file.close()
469 self.WriteEmptyFilterSource(main)
470 return True438 return True
471439
472 def CreateShowerDir(self,mode):440 def CreateShowerDir(self,mode):
@@ -505,18 +473,20 @@
505473
506 # Compilators474 # Compilators
507 file.write('# Compilators\n')475 file.write('# Compilators\n')
508 file.write('GCC = g++\n')476 file.write('CXX = g++\n')
509 file.write('\n')477 file.write('\n')
510478
511 # Options for compilation479 # Options for compilation
512 file.write('# Options for compilation\n')480 file.write('# Options for compilation\n')
513 if self.libFastjet:481 if self.libFastjet:
514 file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n')482 file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n')
515 file.write('CXXFLAGS = -Wall -O3 -I./ -I./../ -I' + '$(MA5_BASE)/tools/')483 file.write('CXXFLAGS = -Wall -O3 -fPIC -I./ -I./../ -I' + '$(MA5_BASE)/tools/')
516 if self.libZIP:484 if self.libZIP:
517 file.write(' -DZIP_USE')485 file.write(' -DZIP_USE')
518 if self.libDelphes:486 if self.libDelphes:
519 file.write(' -DDELPHES_USE')487 file.write(' -DROOT_USE -DDELPHES_USE')
488 if self.libDelfes:
489 file.write(' -DROOT_USE -DDELFES_USE')
520 if self.libFastjet:490 if self.libFastjet:
521 file.write(' -DFASTJET_USE')491 file.write(' -DFASTJET_USE')
522 file.write(' $(CXXFASTJET)')492 file.write(' $(CXXFASTJET)')
@@ -530,16 +500,9 @@
530 file.write('OBJS = $(SRCS:.cpp=.o)\n')500 file.write('OBJS = $(SRCS:.cpp=.o)\n')
531 file.write('\n')501 file.write('\n')
532502
533 # Files for filters
534 file.write('# Files for filters\n')
535 file.write('SRCS2 = $(wildcard Filter/*.cpp)\n')
536 file.write('HDRS2 = $(wildcard Filter/*.h)\n')
537 file.write('OBJS2 = $(SRCS2:.cpp=.o)\n')
538 file.write('\n')
539
540 # Name of the library503 # Name of the library
541 file.write('# Name of the library\n')504 file.write('# Name of the library\n')
542 file.write('PROGRAM = SampleAnalyzerBld\n')505 file.write('PROGRAM = UserPackage_for_ma5\n')
543 file.write('\n')506 file.write('\n')
544507
545 # All508 # All
@@ -549,21 +512,19 @@
549512
550 # Compilation513 # Compilation
551 file.write('# Compile target\n')514 file.write('# Compile target\n')
552 file.write('compile: $(OBJS) $(OBJS2)\n')515 file.write('compile: $(OBJS)\n')
553 file.write('\n')516 file.write('\n')
554 file.write('# Object file target\n')517 file.write('# Object file target\n')
555 file.write('$(OBJS): $(HDRS)\n')518 file.write('$(OBJS): $(HDRS)\n')
556 file.write('$(OBJS2): $(HDRS2)\n')
557 file.write('\n')519 file.write('\n')
558520
559 # Linking521 # Linking
560 file.write('# Link target\n')522 file.write('# Link target\n')
561 file.write('link: $(OBJS) $(OBJS2)\n')523 file.write('link: $(OBJS)\n')
562 file.write('\tcp ' +\524 if self.main.isMAC:
563 '$(MA5_BASE)/tools/SampleAnalyzer/Lib/libSampleAnalyzer.a ' +\525 file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o ../../Build/Lib/lib$(PROGRAM).so $(OBJS)\n')
564 '../../Build/Lib/lib$(PROGRAM).a\n')526 else:
565 file.write('\tar -ruc ../../Build/Lib/lib$(PROGRAM).a $(OBJS) $(OBJS2)\n')527 file.write('\t$(CXX) -shared -o ../../Build/Lib/lib$(PROGRAM).so $(OBJS)\n')
566 file.write('\tranlib ../../Build/Lib/lib$(PROGRAM).a\n')
567 file.write('\n')528 file.write('\n')
568529
569 # Phony target530 # Phony target
@@ -577,7 +538,7 @@
577 file.write('\n')538 file.write('\n')
578 file.write('# Do clean target\n')539 file.write('# Do clean target\n')
579 file.write('do_clean:\n')540 file.write('do_clean:\n')
580 file.write('\t@rm -f $(OBJS) $(OBJS2)\n')541 file.write('\t@rm -f $(OBJS)\n')
581 file.write('\n')542 file.write('\n')
582543
583 # Mr Proper544 # Mr Proper
@@ -586,7 +547,7 @@
586 file.write('\n')547 file.write('\n')
587 file.write('# Do clean target\n')548 file.write('# Do clean target\n')
588 file.write('do_mrproper: do_clean\n')549 file.write('do_mrproper: do_clean\n')
589 file.write('\t@rm -f ../../Build/Lib/lib$(PROGRAM).a\n')550 file.write('\t@rm -f ../../Build/Lib/lib$(PROGRAM).so\n')
590 file.write('\t@rm -f *~ */*~ \n')551 file.write('\t@rm -f *~ */*~ \n')
591 file.write('\n')552 file.write('\n')
592 553
@@ -615,9 +576,9 @@
615 def WriteMakefiles(self,option=""):576 def WriteMakefiles(self,option=""):
616577
617 # Writing sub-Makefiles578 # Writing sub-Makefiles
618 self.WriteSampleAnalyzerMakefile(option)579 #self.WriteSampleAnalyzerMakefile(option)
619 if self.shwrmode!='':580 #if self.shwrmode!='':
620 self.WriteShoweringMakefile(option)581 # self.WriteShoweringMakefile(option)
621582
622 # Opening the main Makefile 583 # Opening the main Makefile
623 file = open(self.path+"/Build/Makefile","w")584 file = open(self.path+"/Build/Makefile","w")
@@ -630,61 +591,79 @@
630591
631 # Compilators592 # Compilators
632 file.write('# Compilators\n')593 file.write('# Compilators\n')
633 file.write('GCC = g++\n')594 file.write('CXX = g++\n')
634 file.write('\n')595 file.write('\n')
635596
636 # Options for compilation597 # Options for compilation : CXXFLAGS
637 file.write('# Options for compilation\n')598 file.write('# Options for compilation\n')
638 if self.libFastjet:599 options = []
639 file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n')600 options.extend(['-Wall','-O3','-I./','-I./SampleAnalyzer/','-I$(MA5_BASE)/tools/','-I'+self.main.configLinux.root_inc_path])
640
641 file.write('FASTJETLIB = $(shell fastjet-config --libs --plugins)\n')
642 file.write('CXXFLAGS = -Wall -O3 -I./ -I$(MA5_BASE)/tools/')
643 if self.shwrmode!='':
644 file.write(' -I$(MA5_BASE)' + \
645 '/tools/MCatNLO-utilities/MCatNLO/include')
646 if self.libZIP:601 if self.libZIP:
647 file.write(' -DZIP_USE')602 options.extend(['-DZIP_USE'])
648 if self.libDelphes:603 if self.libDelphes:
649 file.write(' -DDELPHES_USE')604 options.extend(['-DROOT_USE','-DDELPHES_USE'])
605 if self.libDelfes:
606 options.extend(['-DROOT_USE','-DDELFES_USE'])
650 if self.libFastjet:607 if self.libFastjet:
651 file.write(' -DFASTJET_USE')608 options.extend(['-DROOT_USE','-DFASTJET_USE'])#,'$(shell fastjet-config --cxxflags --plugins)'])
652 file.write(' $(CXXFASTJET)')609 file.write('CXXFLAGS = '+' '.join(options))
653 file.write('\n')610 file.write('\n')
654 file.write('LIBFLAGS = -LLib -lSampleAnalyzerBld -lGpad -lHist ' + 611
655 '-lGraf -lGraf3d ' +\612 # Options for compilation : LIBFLAGS
656 '-lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lEG ' +\613
657 '-lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl '+\614 # - Root
658 '-rdynamic')615 libs=[]
616 libs.extend(['-L'+self.main.configLinux.root_lib_path, \
617 '-lGpad','-lHist','-lGraf','-lGraf3d','-lTree', \
618 '-lRint','-lPostscript','-lMatrix','-lPhysics', \
619 '-lMathCore','-lEG', '-lRIO','-lNet','-lThread', \
620 '-lCore','-lCint','-pthread','-lm','-ldl','-rdynamic'])
621
622 # - SampleAnalyzer
623 libs.extend(['-L$(MA5_BASE)/tools/SampleAnalyzer/Lib/','-lSampleAnalyzer'])
659 if self.libZIP:624 if self.libZIP:
660 file.write(' -lz')625 libs.extend(['-L'+self.main.configLinux.zlib_lib_path,'-lz','-lzlib_for_ma5'])
661 if self.libDelphes:626 if self.libDelphes:
662 file.write(' -lDelphes')627 libs.extend(['-L'+self.main.configLinux.delphes_lib_paths[0],'-lDelphes','-ldelphes_for_ma5'])
628 if self.libDelfes:
629 libs.extend(['-L'+self.main.configLinux.delfes_lib_paths[0],'-lDelphes','-ldelfes_for_ma5'])
663 if self.fortran:630 if self.fortran:
664 file.write(' -lgfortran')631 libs.extend(['-lgfortran'])
665 if self.libFastjet:632 if self.libFastjet:
666 file.write(' $(FASTJETLIB)')633 libs.extend(['$(shell fastjet-config --libs --plugins --rpath=no)','-lfastjet_for_ma5'])
667 if self.shwrmode!='':634 file.write('LIBFLAGS = '+' '.join(libs)+'\n')
668 file.write(' -lShowering -lstdhep -lFmcfio')635 file.write('\n')
669 file.write('\n\n')636
670637 # Files to process
671 # Files638 file.write('# Files to process\n')
672 file.write('# Files\n')639 file.write('SRCS = $(wildcard Main/*.cpp)\n')
673 file.write('SRCS = $(wildcard Main/*.cpp)\n')640 file.write('SRCS += $(wildcard SampleAnalyzer/Analyzer/*.cpp)\n')
674 file.write('HDRS = $(wildcard Main/*.h)\n')641 file.write('HDRS = $(wildcard Main/*.h)\n')
675 file.write('OBJS = $(SRCS:.cpp=.o)\n')642 file.write('HDRS += $(wildcard SampleAnalyzer/Analyzer/*.h)\n')
676 file.write('LIBS = Lib/libSampleAnalyzerBld.a')643 file.write('\n')
677 if self.shwrmode!='':644
678 file.write(' Lib/libShowering.a')645 # Files to generate
679 file.write('\n')646 file.write('# Files to generate\n')
680 file.write('PRES = $(MA5_BASE)/tools/' +\647 file.write('OBJS = $(SRCS:.cpp=.o)\n')
681 'SampleAnalyzer/Lib/libSampleAnalyzer.a')648 file.write('PROGRAM = MadAnalysis5job\n')
682 file.write('\n')649 file.write('\n')
683650
684 # Name of the executable651 # Lib to check
685 file.write('#Name of the executable\n')652 file.write('# Requirements to check before building\n')
686 file.write('PROGRAM = MadAnalysis5Job\n')653 libs=[]
687 file.write('\n')654 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so')
655 if self.libZIP:
656 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so')
657 if self.libDelphes:
658 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so')
659 if self.libDelfes:
660 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so')
661 if self.libFastjet:
662 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so')
663 for ind in range(0,len(libs)):
664 file.write('REQUIRED'+str(ind+1)+' = '+libs[ind]+'\n')
665 file.write('\n')
666
688667
689 # Defining colours for shell668 # Defining colours for shell
690 file.write('# Defining colours\n')669 file.write('# Defining colours\n')
@@ -703,16 +682,18 @@
703 file.write('\n')682 file.write('\n')
704683
705 # Check library684 # Check library
706 file.write('# Check library\n')685 if len(libs)!=0:
707 file.write('library_check:\n')686 file.write('# Check library\n')
708 file.write('ifeq ($(wildcard $(PRES)),)\n')687 file.write('library_check:\n')
709 file.write('\t@echo -e $(RED)"The static library "$(PRES)" is not found"\n')688 for ind in range(0,len(libs)):
710 file.write('\t@echo -e $(RED)" 1) Please check that MadAnalysis 5 is installed in the folder : "$(MA5_BASE)\n')689 file.write('ifeq ($(wildcard $(REQUIRED'+str(ind+1)+')),)\n')
711 file.write('\t@echo -e $(RED)" 2) Launch MadAnalysis 5 in normal mode in order to build this library."\n')690 file.write('\t@echo -e $(RED)"The shared library "$(REQUIRED'+str(ind+1)+')" is not found"\n')
712 file.write('\t@echo -e $(NORMAL)\n')691 file.write('\t@echo -e $(RED)" 1) Please check that MadAnalysis 5 is installed in the folder : "$(MA5_BASE)\n')
713 file.write('\t@false\n')692 file.write('\t@echo -e $(RED)" 2) Launch MadAnalysis 5 in normal mode in order to build this library."\n')
714 file.write('endif\n')693 file.write('\t@echo -e $(NORMAL)\n')
715 file.write('\n')694 file.write('\t@false\n')
695 file.write('endif\n')
696 file.write('\n')
716697
717 # Header target698 # Header target
718 file.write('# Header target\n')699 file.write('# Header target\n')
@@ -756,7 +737,7 @@
756737
757 # Compile target738 # Compile target
758 file.write('# Compile target\n')739 file.write('# Compile target\n')
759 file.write('compile: $(LIBS) $(OBJS)\n')740 file.write('compile: $(OBJS)\n')
760 file.write('\n')741 file.write('\n')
761742
762 # Object file target743 # Object file target
@@ -766,34 +747,18 @@
766747
767 # Link target748 # Link target
768 file.write('# Link target\n')749 file.write('# Link target\n')
769 file.write('link: $(OBJS) $(LIBS)\n')750 file.write('link: $(OBJS)\n')
770 file.write('\t$(GCC) $(CXXFLAGS) $(OBJS) ')751 file.write('\t$(CXX) $(CXXFLAGS) $(OBJS) ')
771 file.write('$(LIBFLAGS) -o $(PROGRAM)\n')752 file.write('$(LIBFLAGS) -o $(PROGRAM)\n')
772 file.write('\n')753 file.write('\n')
773754
774 # Library to build
775 file.write('# SampleAnalyzer library target\n')
776 file.write('$(LIBS):\n')
777 file.write('\t@(cd SampleAnalyzer/ && $(MAKE))\n')
778 file.write('\n')
779
780 # Library to build
781 if self.shwrmode!='':
782 file.write('# Showering library target\n')
783 file.write('Lib/libShowering.a:\n')
784 file.write('\t@(cd Showering/ && $(MAKE))\n')
785 file.write('\n')
786
787 # Clean target755 # Clean target
788 file.write('# Clean target\n')756 file.write('# Clean target\n')
789 file.write('clean: clean_header do_clean\n')757 file.write('clean: clean_header do_clean\n')
790 file.write('\n')758 file.write('\n')
791 file.write('# Do clean target\n')759 file.write('# Do clean target\n')
792 file.write('do_clean: \n')760 file.write('do_clean: \n')
793 file.write('\t@(cd SampleAnalyzer/ && $(MAKE) $@)\n')761 file.write('\t@rm -f $(OBJS)\n')
794 if self.shwrmode!='':
795 file.write('\t@(cd Showering/ && $(MAKE) $@)\n')
796 file.write('\t@rm -f $(OBJS) $(LIBS)\n')
797 file.write('\n')762 file.write('\n')
798763
799 # Mr Proper target764 # Mr Proper target
@@ -802,24 +767,21 @@
802 file.write('\n')767 file.write('\n')
803 file.write('# Do Mr Proper target \n')768 file.write('# Do Mr Proper target \n')
804 file.write('do_mrproper: do_clean\n')769 file.write('do_mrproper: do_clean\n')
805 file.write('\t@(cd SampleAnalyzer/ && $(MAKE) $@)\n')
806 if self.shwrmode!='':
807 file.write('\t@(cd Showering/ && $(MAKE) $@)\n')
808 file.write('\t@rm -f $(PROGRAM) Log/compilation.log' + \770 file.write('\t@rm -f $(PROGRAM) Log/compilation.log' + \
809 ' linking.log *~ */*~ \n')771 ' Log/linking.log Log/cleanup.log Log/mrproper.log *~ */*~ */*~ \n')
810 file.write('\n')772 file.write('\n')
811773
812 # Phony target774 # Phony target
813 file.write('# Phony target\n')775 file.write('# Phony target\n')
814 file.write('.PHONY: do_clean header link_header compile_header $(LIBS)\n')776 file.write('.PHONY: do_clean header link_header compile_header\n')
815 file.write('\n')777 file.write('\n')
816778
817 # Closing the file779 # Closing the file
818 file.close()780 file.close()
819781
820 if not JobWriter.WriteSetupFile(True,self.path+'/Build/',self.ma5dir):782 if not JobWriter.WriteSetupFile(True,self.path+'/Build/',self.ma5dir,True,self.main.configLinux,self.main.isMAC):
821 return False783 return False
822 if not JobWriter.WriteSetupFile(False,self.path+'/Build/',self.ma5dir):784 if not JobWriter.WriteSetupFile(False,self.path+'/Build/',self.ma5dir,True,self.main.configLinux,self.main.isMAC):
823 return False785 return False
824 786
825 return True787 return True
@@ -855,7 +817,10 @@
855817
856 818
857 @staticmethod819 @staticmethod
858 def WriteSetupFile(bash,path,ma5dir,MA5BASE=True):820 def WriteSetupFile(bash,path,ma5dir,MA5BASE,configLinux,isMAC):
821
822 # Variable to check at the end
823 toCheck=[]
859824
860 # Opening file in write-only mode825 # Opening file in write-only mode
861 if bash:826 if bash:
@@ -904,59 +869,101 @@
904 if bash:869 if bash:
905 file.write('export MA5_BASE=' + JobWriter.CleanPath(ma5dir)+'\n')870 file.write('export MA5_BASE=' + JobWriter.CleanPath(ma5dir)+'\n')
906 else:871 else:
907 file.write('setenv MA5_BASE=' + JobWriter.CleanPath(ma5dir)+'\n')872 file.write('setenv MA5_BASE ' + JobWriter.CleanPath(ma5dir)+'\n')
873 toCheck.append('MA5_BASE')
908 file.write('\n')874 file.write('\n')
909875
910 # Configuring PATH environment variable876 # Configuring PATH environment variable
911 file.write('# Configuring PATH environment variable\n')877 if len(configLinux.toPATH)!=0:
912 if bash:878 file.write('# Configuring PATH environment variable\n')
913 file.write('export PATH=' + JobWriter.CleanPath(os.environ['PATH'])+'\n')879 if bash:
914 else:880 file.write('if [ $PATH ]; then\n')
915 file.write('setenv PATH ' + JobWriter.CleanPath(os.environ['PATH'])+'\n')881 file.write('export PATH=$PATH:' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n')
916 file.write('\n')882 file.write('else\n')
917883 file.write('export PATH=' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n')
918 # Configuring LD_LIBRARY_PATH environment variable884 file.write('fi\n')
919 file.write('# Configuring LD_LIBRARY_PATH environment variable\n')885 else:
920 if bash:886 file.write('if ( $?PATH ) then\n')
921 file.write('export LD_LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n')887 file.write('setenv PATH "$PATH":' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n')
922 else:888 file.write('else\n')
923 file.write('setenv LD_LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n')889 file.write('setenv PATH ' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n')
924 file.write('\n')890 file.write('endif\n')
925891 toCheck.append('PATH')
926 # Configuring LIBRARY_PATH environment variable892 file.write('\n')
927 file.write('# Configuring LIBRARY_PATH environment variable\n')893
928 if bash:894 if len(configLinux.toLDPATH)!=0:
929 file.write('export LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n')895
930 else:896 # Configuring LD_LIBRARY_PATH environment variable
931 file.write('setenv LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n')897 file.write('# Configuring LD_LIBRARY_PATH environment variable\n')
932 file.write('\n')898 if bash:
933899 file.write('if [ $LD_LIBRARY_PATH ]; then\n')
934 # Configuring DYLD_LIBRARY_PATH environment variable900 file.write('export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
935 file.write('# Configuring DYLD_LIBRARY_PATH environment variable\n')901 file.write('else\n')
936 if bash:902 file.write('export LD_LIBRARY_PATH=' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
937 file.write('export DYLD_LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['DYLD_LIBRARY_PATH'])+'\n')903 file.write('fi\n')
938 else:904 else:
939 file.write('setenv DYLD_LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['DYLD_LIBRARY_PATH'])+'\n')905 file.write('if ( $?LD_LIBRARY_PATH ) then\n')
940 file.write('\n')906 file.write('setenv LD_LIBRARY_PATH "$LD_LIBRARY_PATH":' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
941907 file.write('else\n')
942 # Configuring CPLUS_INCLUDE_PATH environment variable908 file.write('setenv LD_LIBRARY_PATH ' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
943 file.write('# Configuring CPLUS_INCLUDE_PATH environment variable\n')909 file.write('endif\n')
944 if bash:910 toCheck.append('LD_LIBRARY_PATH')
945 file.write('export CPLUS_INCLUDE_PATH=' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n')911 file.write('\n')
946 else:912
947 file.write('setenv CPLUS_INCLUDE_PATH ' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n')913 # Configuring LIBRARY_PATH environment variable
948 file.write('\n')914 #file.write('# Configuring LIBRARY_PATH environment variable\n')
915 #if bash:
916 # file.write('export LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n')
917 #else:
918 # file.write('setenv LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n')
919 #file.write('\n')
920
921 # Configuring DYLD_LIBRARY_PATH environment variable
922 if isMAC:
923 file.write('# Configuring DYLD_LIBRARY_PATH environment variable\n')
924 if bash:
925 file.write('if [ $DYLD_LIBRARY_PATH ]; then\n')
926 file.write('export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
927 file.write('else\n')
928 file.write('export DYLD_LIBRARY_PATH=' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
929 file.write('fi\n')
930 else:
931 file.write('if ( $?DYLD_LIBRARY_PATH ) then\n')
932 file.write('setenv DYLD_LIBRARY_PATH "$DYLD_LIBRARY_PATH":' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
933 file.write('else\n')
934 file.write('setenv DYLD_LIBRARY_PATH ' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n')
935 file.write('endif\n')
936 toCheck.append('DYLD_LIBRARY_PATH')
937 file.write('\n')
938
939 # Configuring CPLUS_INCLUDE_PATH environment variable
940 #file.write('# Configuring CPLUS_INCLUDE_PATH environment variable\n')
941 #if bash:
942 # file.write('export CPLUS_INCLUDE_PATH=' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n')
943 #else:
944 # file.write('setenv CPLUS_INCLUDE_PATH ' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n')
945 #file.write('\n')
949946
950 # Checking that all environment variables are defined947 # Checking that all environment variables are defined
951 file.write('# Checking that all environment variables are defined\n')948 file.write('# Checking that all environment variables are defined\n')
952 if bash:949 if bash:
953 file.write('if [[ $PATH && $LD_LIBRARY_PATH && $LIBRARY_PATH && $DYLD_LIBRARY_PATH && $CPLUS_INCLUDE_PATH ]]; then\n')950 file.write('if [[ ')
951 for ind in range(0,len(toCheck)):
952 if ind!=0:
953 file.write(' && ')
954 file.write('$'+toCheck[ind])
955 file.write(' ]]; then\n')
954 file.write('echo -e $YELLOW"'+StringTools.Fill('-',56)+'"\n')956 file.write('echo -e $YELLOW"'+StringTools.Fill('-',56)+'"\n')
955 file.write('echo -e "'+StringTools.Center('Your environment is properly configured for MA5',56)+'"\n')957 file.write('echo -e "'+StringTools.Center('Your environment is properly configured for MA5',56)+'"\n')
956 file.write('echo -e "'+StringTools.Fill('-',56)+'"$NORMAL\n')958 file.write('echo -e "'+StringTools.Fill('-',56)+'"$NORMAL\n')
957 file.write('fi\n')959 file.write('fi\n')
958 else:960 else:
959 file.write('if ( $?PATH && $?LD_LIBRARY_PATH && $?LIBRARY_PATH && $?DYLD_LIBRARY_PATH && $?CPLUS_INCLUDE_PATH) then\n')961 file.write('if ( \n')
962 for ind in range(0,len(toCheck)):
963 if ind!=0:
964 file.write(' && ')
965 file.write('$?'+toCheck[ind])
966 file.write(' ) then\n')
960 file.write('echo $YELLOW"'+StringTools.Fill('-',56)+'"\n')967 file.write('echo $YELLOW"'+StringTools.Fill('-',56)+'"\n')
961 file.write('echo "'+StringTools.Center('Your environment is properly configured for MA5',56)+'"\n')968 file.write('echo "'+StringTools.Center('Your environment is properly configured for MA5',56)+'"\n')
962 file.write('echo "'+StringTools.Fill('-',56)+'"$NORMAL\n')969 file.write('echo "'+StringTools.Fill('-',56)+'"$NORMAL\n')
@@ -972,33 +979,94 @@
972979
973 return True980 return True
974981
982
975 def CompileJob(self):983 def CompileJob(self):
976 if self.resubmit:984
977 res=commands.getstatusoutput("cd "\985 # folder
978 +self.path+"/Build/;"\986 folder = self.path+'/Build'
979 +" make mrproper")987
980 988 # log file name
981 res=commands.getstatusoutput("cd "\989 logfile = folder+'/Log/compilation.log'
982 +self.path+"/Build/;"\990
983 +" make compile > Log/compilation.log 2>&1")991 # shell command
984 if res[0]==0:992 commands = ['make','compile']
985 return True993
986 else:994 # call
987 logging.error("errors occured during compilation. " +\995 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
988 "For more details, see the file :")996
989 logging.error(" "+self.path+"/Build/Log/compilation.log")997 # return result
990 return False998 if not result:
999 logging.error('impossible to compile the project. For more details, see the log file:')
1000 logging.error(logfile)
1001
1002 return result
1003
1004
1005 def MrproperJob(self):
1006
1007 # folder
1008 folder = self.path+'/Build'
1009
1010 # log file name
1011 logfile = folder+'/Log/mrproper.log'
1012
1013 # shell command
1014 commands = ['make','mrproper']
1015
1016 # call
1017 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
1018
1019 # return result
1020 if not result:
1021 logging.error('impossible to clean the project. For more details, see the log file:')
1022 logging.error(logfile)
1023
1024 return result
1025
1026
1027 def MrproperJob(self):
1028
1029 # folder
1030 folder = self.path+'/Build'
1031
1032 # log file name
1033 logfile = folder+'/Log/mrproper.log'
1034
1035 # shell command
1036 commands = ['make','mrproper']
1037
1038 # call
1039 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
1040
1041 # return result
1042 if not result:
1043 logging.error('impossible to clean the project. For more details, see the log file:')
1044 logging.error(logfile)
1045
1046 return result
1047
9911048
992 def LinkJob(self):1049 def LinkJob(self):
993 res=commands.getstatusoutput("cd "\1050
994 +self.path+"/Build/;"\1051 # folder
995 +" make link > Log/linking.log 2>&1")1052 folder = self.path+'/Build'
996 if res[0]==0:1053
997 return True1054 # log file name
998 else:1055 logfile = folder+'/Log/linking.log'
999 logging.error("errors occured during compilation. For more details, see the file :")1056
1000 logging.error(" "+self.path+"/Build/Log/linking.log")1057 # shell command
1001 return False1058 commands = ['make','link']
1059
1060 # call
1061 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
1062
1063 # return result
1064 if not result:
1065 logging.error('impossible to link the project. For more details, see the log file:')
1066 logging.error(logfile)
1067
1068 return result
1069
10021070
1003 def WriteHistory(self,history,firstdir):1071 def WriteHistory(self,history,firstdir):
1004 file = open(self.path+"/history.ma5","w")1072 file = open(self.path+"/history.ma5","w")
@@ -1029,6 +1097,7 @@
1029 file.write("\n")1097 file.write("\n")
1030 file.close() 1098 file.close()
10311099
1100
1032 def RunJob(self,dataset):1101 def RunJob(self,dataset):
10331102
1034 # Getting the dataset name 1103 # Getting the dataset name
@@ -1038,23 +1107,26 @@
1038 if not os.path.isdir(self.path+"/Output/"+name):1107 if not os.path.isdir(self.path+"/Output/"+name):
1039 os.mkdir(self.path+"/Output/"+name)1108 os.mkdir(self.path+"/Output/"+name)
1040 1109
1110 # folder where the program is launched
1111 folder = self.path+'/Output/'+name
1112
1113 # shell command
1114 commands = ['../../Build/MadAnalysis5job']
1115
1041 # Weighted events1116 # Weighted events
1042 weighted_events=""
1043 if not dataset.weighted_events:1117 if not dataset.weighted_events:
1044 weighted_events=" --no_event_weight"1118 commands.append('--no_event_weight')
10451119
1046 # Release1120 # Release
1047 release = ' --ma5_version="' + self.main.version + ';' + self.main.date + '"'1121 commands.append('--ma5_version="'+self.main.version+';'+self.main.date+'"')
10481122
1049 # Running SampleAnalyzer 1123 # Inputs
1050 res=os.system('cd '\1124 commands.append('../../Input/'+name+'.list')
1051 +self.path+'/Output/'+name+';'\1125
1052 +' ../../Build/'\1126 # Running SampleAnalyzer
1053 +'MadAnalysis5Job '+weighted_events +\1127 result = ShellCommand.Execute(commands,folder)
1054 release +\1128
1055 ' ../../Input/'+name+'.list')1129 return result
1056
1057 return True
10581130
1059 1131
1060 1132
10611133
=== modified file 'madanalysis/IOinterface/library_writer.py'
--- madanalysis/IOinterface/library_writer.py 2013-06-14 15:26:04 +0000
+++ madanalysis/IOinterface/library_writer.py 2014-05-17 19:51:11 +0000
@@ -26,22 +26,27 @@
26from madanalysis.IOinterface.folder_writer import FolderWriter26from madanalysis.IOinterface.folder_writer import FolderWriter
27from madanalysis.IOinterface.job_writer import JobWriter27from madanalysis.IOinterface.job_writer import JobWriter
28from madanalysis.core.string_tools import StringTools28from madanalysis.core.string_tools import StringTools
29from madanalysis.IOinterface.shell_command import ShellCommand
29import logging30import logging
30import shutil31import shutil
31import os32import os
32import commands33import commands
34import subprocess
35
3336
34class LibraryWriter():37class LibraryWriter():
3538
36 def __init__(self,ma5dir,jobdir,libZIP,libFASTJET,forced,fortran,delphes):39 def __init__(self,ma5dir,jobdir,libZIP,libFastJet,forced,fortran,delphes,delfes,main):
37 self.ma5dir = ma5dir40 self.ma5dir = ma5dir
38 self.jobdir = jobdir41 self.jobdir = jobdir
39 self.path = os.path.normpath(ma5dir+"/tools/")42 self.path = os.path.normpath(ma5dir+"/tools/")
40 self.libZIP = libZIP43 self.libZIP = libZIP
41 self.libFASTJET = libFASTJET44 self.libFastJet = libFastJet
42 self.forced = forced45 self.forced = forced
43 self.fortran = fortran46 self.fortran = fortran
44 self.libDelphes = delphes47 self.libDelphes = delphes
48 self.libDelfes = delfes
49 self.main = main
4550
46 def get_ncores(self):51 def get_ncores(self):
47 # Number of cores52 # Number of cores
@@ -72,9 +77,211 @@
72 str(ncores))77 str(ncores))
73 return ncores78 return ncores
7479
80 def get_ncores2(self):
81 # Number of cores
82 import multiprocessing
83 nmaxcores=multiprocessing.cpu_count()
84 logging.info(" How many cores for the compiling? default = max = " +\
85 str(nmaxcores)+"")
86
87 if not self.forced:
88 test=False
89 while(not test):
90 answer=raw_input(" Answer: ")
91 if answer=="":
92 test=True
93 ncores=nmaxcores
94 break
95 try:
96 ncores=int(answer)
97 except:
98 test=False
99 continue
100 if ncores<=nmaxcores and ncores>0:
101 test=True
102
103 else:
104 ncores=nmaxcores
105 logging.info(" => Number of cores used for the compilation = " +\
106 str(ncores))
107 return ncores
108
109
75 def Open(self):110 def Open(self):
76 return FolderWriter.CreateDirectory(self.path,overwrite=True)111 return FolderWriter.CreateDirectory(self.path,overwrite=True)
77112
113 def WriteMakefileForInterfaces(self,package):
114
115 # Open the file
116 try:
117 file = open(self.path + "/SampleAnalyzer/Interfaces/Makefile_" + package,"w")
118 except:
119 logging.error('impossible to write the file '+ self.path + "/SampleAnalyzer/Makefile_" + package)
120 return False
121
122 # Header
123 file.write(StringTools.Fill('#',80)+'\n')
124 file.write('#'+StringTools.Center('MAKEFILE DEVOTED TO THE INTERFACE TO '+package.upper(),78)+'#\n')
125 file.write(StringTools.Fill('#',80)+'\n')
126 file.write('\n')
127
128 # Options for C++ compilation
129 file.write('# Options for C++ compilation\n')
130 file.write('CXX = g++\n')
131 if package=='fastjet':
132 file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n')
133 file.write('CXXFLAGS = -Wall -O3 -DROOT_USE -fPIC -I'+self.main.configLinux.root_inc_path+' -I./../../')
134 if package=='zlib':
135 file.write(' -I'+self.main.configLinux.zlib_inc_path)
136 if package=='delphes':
137 for header in self.main.configLinux.delphes_inc_paths:
138 file.write(' -I'+header)
139 if package=='delfes':
140 for header in self.main.configLinux.delfes_inc_paths:
141 file.write(' -I'+header)
142 if package=='fastjet':
143 file.write(' $(CXXFASTJET)')
144 file.write('\n')
145
146 # Options for C++ compilation
147 if self.fortran:
148 file.write('# Options for Fortran compilation\n')
149 file.write('FC = gfortran\n')
150 file.write('FCFLAGS = -Wall -O3 -fPIC\n')
151 file.write('\n')
152
153 # Files for analyzers
154 file.write('# Files\n')
155 file.write('SRCS = $(wildcard '+package+'/*.cpp)\n')
156 file.write('HDRS = $(wildcard '+package+'/*.h)\n')
157 file.write('OBJS = $(SRCS:.cpp=.o)\n')
158 if self.fortran:
159 file.write('FORTRAN_SRCS = $(wildcard '+package+'/*.f)\n')
160 file.write('FORTRAN_OBJS = $(FORTRAN_SRCS:.f=.o)\n')
161 file.write('\n')
162
163 # Name of the library
164 file.write('# Name of the library\n')
165 file.write('PROGRAM = '+package+'_for_ma5\n')
166 file.write('\n')
167
168 # Defining colours for shell
169 file.write('# Defining colours\n')
170 file.write('GREEN = "\\\\033[1;32m"\n')
171 file.write('RED = "\\\\033[1;31m"\n')
172 file.write('PINK = "\\\\033[1;35m"\n')
173 file.write('BLUE = "\\\\033[1;34m"\n')
174 file.write('YELLOW = "\\\\033[1;33m"\n')
175 file.write('CYAN = "\\\\033[1;36m"\n')
176 file.write('NORMAL = "\\\\033[0;39m"\n')
177 file.write('\n')
178
179 # All
180 file.write('# All target\n')
181 file.write('all: header compile_header compile link_header link\n')
182 file.write('\n')
183
184 # Header target
185 file.write('# Header target\n')
186 file.write('header:\n')
187 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
188 file.write('\t@echo -e "'+StringTools.Center('Building SampleAnalyzer library',50)+'"\n')
189 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
190 file.write('\n')
191
192 # Compile_header target
193 file.write('# Compile_header target\n')
194 file.write('compile_header:\n')
195 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
196 file.write('\t@echo -e "'+StringTools.Center('Compilation',50)+'"\n')
197 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
198 file.write('\n')
199
200 # Linking_header target
201 file.write('# Link_header target\n')
202 file.write('link_header:\n')
203 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
204 file.write('\t@echo -e "'+StringTools.Center('Final linking',50)+'"\n')
205 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
206 file.write('\n')
207
208 # Clean_header target
209 file.write('# clean_header target\n')
210 file.write('clean_header:\n')
211 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
212 file.write('\t@echo -e "'+StringTools.Center('Removing intermediate files from building',50)+'"\n')
213 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
214 file.write('\n')
215
216 # Mrproper_header target
217 file.write('# mrproper_header target\n')
218 file.write('mrproper_header:\n')
219 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
220 file.write('\t@echo -e "'+StringTools.Center('Cleaning all the project',50)+'"\n')
221 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
222 file.write('\n')
223
224 # Precompile
225 file.write('# Precompile target\n')
226 file.write('precompile:\n')
227 file.write('\n')
228
229 # Precompile
230 file.write('# Compile target\n')
231 if self.fortran:
232 file.write('compile: precompile $(OBJS) $(FORTRAN_OBJS)\n')
233 else:
234 file.write('compile: precompile $(OBJS)\n')
235 file.write('\n')
236
237 # Precompile
238 file.write('# Link target\n')
239 if self.fortran:
240 file.write('link: $(OBJS) $(FORTRAN_OBJS)\n')
241 if self.main.isMAC:
242 file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o ../Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n')
243 else:
244 file.write('\t$(CXX) -shared -o ../Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n')
245 else:
246 file.write('link: $(OBJS)\n')
247 if self.main.isMAC:
248 file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o ../Lib/lib$(PROGRAM).so $(OBJS)\n')
249 else:
250 file.write('\t$(CXX) -shared -o ../Lib/lib$(PROGRAM).so $(OBJS)\n')
251 file.write('\n')
252
253 # Phony target
254 file.write('# Phony target\n')
255 file.write('.PHONY: do_clean header compile_header link_header\n')
256 file.write('\n')
257
258 # Cleaning
259 file.write('# Clean target\n')
260 file.write('clean: clean_header do_clean\n')
261 file.write('\n')
262 file.write('# Do clean target\n')
263 file.write('do_clean: \n')
264 file.write('\t@rm -f $(OBJS)\n')
265 if self.fortran:
266 file.write('\t@rm -f $(FORTRAN_OBJS)\n')
267 file.write('\n')
268
269 # Mr Proper
270 file.write('# Mr Proper target \n')
271 file.write('mrproper: mrproper_header do_mrproper\n')
272 file.write('\n')
273 file.write('# Do Mr Proper target \n')
274 file.write('do_mrproper: do_clean\n')
275 file.write('\t@rm -f ../Lib/lib$(PROGRAM).so\n')
276 file.write('\t@rm -f compilation.log linking.log cleanup.log mrproper.log *~ */*~\n')
277 file.write('\n')
278
279 # Closing the file
280 file.close()
281
282 return True
283
284
78 def WriteMakefile(self,option=""):285 def WriteMakefile(self,option=""):
79286
80 # Open the file287 # Open the file
@@ -88,23 +295,26 @@
88295
89 # Compilators296 # Compilators
90 file.write('# Compilators\n')297 file.write('# Compilators\n')
91 file.write('GCC = g++\n')298 file.write('CXX = g++\n')
92 if self.fortran:299 if self.fortran:
93 file.write('FC = gfortran\n')300 file.write('FC = gfortran\n')
94 file.write('\n')301 file.write('\n')
95302
96 # Options for compilation303 # Options for compilation
97 file.write('# Options for compilation\n')304 file.write('# Options for compilation\n')
98 if self.libFASTJET:305# if self.libFastJet:
99 file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n')306# file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n')
100 file.write('CXXFLAGS = -Wall -O3 $(shell root-config --cflags) -I./../')307 # BENJ FIX file.write('CXXFLAGS = -Wall -O3 -fPIC $(shell root-config --cflags) -I./../')
308 file.write('CXXFLAGS = -Wall -O3 -DROOT_USE -fPIC -I'+self.main.configLinux.root_inc_path+' -I./../')
101 if self.libZIP:309 if self.libZIP:
102 file.write(' -DZIP_USE')310 file.write(' -DZIP_USE')
103 if self.libDelphes:311 if self.libDelphes:
104 file.write(' -DDELPHES_USE')312 file.write(' -DDELPHES_USE')
105 if self.libFASTJET:313 if self.libDelfes:
314 file.write(' -DDELFES_USE')
315 if self.libFastJet:
106 file.write(' -DFASTJET_USE')316 file.write(' -DFASTJET_USE')
107 file.write(' $(CXXFASTJET)')317 # file.write(' $(CXXFASTJET)')
108 file.write('\n')318 file.write('\n')
109 if self.fortran:319 if self.fortran:
110 file.write('FC = gfortran\n')320 file.write('FC = gfortran\n')
@@ -114,6 +324,7 @@
114 # Files for analyzers324 # Files for analyzers
115 file.write('# Files\n')325 file.write('# Files\n')
116 file.write('SRCS = $(wildcard */*.cpp)\n')326 file.write('SRCS = $(wildcard */*.cpp)\n')
327# file.write('SRCS += $(wildcard */*/*.cpp)\n')
117 file.write('HDRS = $(wildcard */*.h)\n')328 file.write('HDRS = $(wildcard */*.h)\n')
118 file.write('OBJS = $(SRCS:.cpp=.o)\n')329 file.write('OBJS = $(SRCS:.cpp=.o)\n')
119 if self.fortran:330 if self.fortran:
@@ -199,10 +410,18 @@
199 file.write('# Link target\n')410 file.write('# Link target\n')
200 if self.fortran:411 if self.fortran:
201 file.write('link: $(OBJS) $(FORTRAN_OBJS)\n')412 file.write('link: $(OBJS) $(FORTRAN_OBJS)\n')
202 file.write('\tar -ruc Lib/lib$(PROGRAM).a $(OBJS) $(FORTRAN_OBJS)\n')413 if self.main.isMAC:
414 file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n')
415 else:
416 file.write('\t$(CXX) -shared -o Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n')
203 else:417 else:
204 file.write('link: $(OBJS)\n')418 file.write('link: $(OBJS)\n')
205 file.write('\tar -ruc Lib/lib$(PROGRAM).a $(OBJS)\n')419 if self.main.isMAC:
420 file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o Lib/lib$(PROGRAM).so $(OBJS)\n')
421 else:
422 file.write('\t$(CXX) -shared -o Lib/lib$(PROGRAM).so $(OBJS)\n')
423
424# file.write('\tar -ruc Lib/lib$(PROGRAM).a $(OBJS)\n')
206 file.write('\n')425 file.write('\n')
207426
208 # Phony target427 # Phony target
@@ -216,7 +435,7 @@
216 file.write('\n')435 file.write('\n')
217 file.write('# Do clean target\n')436 file.write('# Do clean target\n')
218 file.write('do_clean: \n')437 file.write('do_clean: \n')
219 file.write('\t@rm -f $(OBJS) Reader/FACdict.*\n')438 file.write('\t@rm -f $(OBJS)\n')
220 file.write('\n')439 file.write('\n')
221440
222 # Mr Proper441 # Mr Proper
@@ -225,54 +444,394 @@
225 file.write('\n')444 file.write('\n')
226 file.write('# Do Mr Proper target \n')445 file.write('# Do Mr Proper target \n')
227 file.write('do_mrproper: do_clean\n')446 file.write('do_mrproper: do_clean\n')
228 file.write('\t@rm -f Lib/lib$(PROGRAM).a\n')447 file.write('\t@rm -f Lib/lib$(PROGRAM).so\n')
229 file.write('\t@rm -f compilation.log linking.log cleanup.log *~ */*~\n')448 file.write('\t@rm -f compilation.log linking.log cleanup.log mrproper.log *~ */*~\n')
230 file.write('\n')449 file.write('\n')
231450
232 # Closing the file451 # Closing the file
233 file.close()452 file.close()
234453
235 JobWriter.WriteSetupFile(True,self.path+'/SampleAnalyzer',self.ma5dir,False)454 JobWriter.WriteSetupFile(True,self.path+'/SampleAnalyzer',self.ma5dir,False,self.main.configLinux,self.main.isMAC)
236 JobWriter.WriteSetupFile(False,self.path+'/SampleAnalyzer',self.ma5dir,False)455 JobWriter.WriteSetupFile(False,self.path+'/SampleAnalyzer',self.ma5dir,False,self.main.configLinux,self.main.isMAC)
237456
238 return True457 return True
239458
240459
241 def Compile(self):460 def Compile(self,ncores,package,folder):
461
462 # number of cores
242 strcores=''463 strcores=''
243 ncores = self.get_ncores()
244 if ncores>1:464 if ncores>1:
245 strcores='-j'+str(ncores)465 strcores='-j'+str(ncores)
246 res=commands.getstatusoutput("cd "\466
247 +self.path+"/SampleAnalyzer/;"\467 # log file name
248 +" make compile "+strcores+" > compilation.log 2>&1")468 if package == 'SampleAnalyzer':
249 if res[0]==0:469 logfile = folder+'/compilation.log'
250 return True470 else:
251 else:471 logfile = folder+'/compilation_'+package+'.log'
252 logging.error("errors occured during compilation. For more details, see the file :")472
253 logging.error(" "+self.path+"/SampleAnalyzer/compilation.log")473 # makefile
254 return False474 if package == 'SampleAnalyzer':
255475 makefile = 'Makefile'
256 def Link(self):476 else:
257 res=commands.getstatusoutput("cd "\477 makefile = 'Makefile_'+package
258 +self.path+"/SampleAnalyzer/;"\478
259 +" make link > linking.log 2>&1")479 # shell command
260 if res[0]==0:480 commands = ['make','compile',strcores,'--file='+makefile]
261 return True481
262 else:482 # call
263 logging.error("errors occured during compilation. For more details, see the file :")483 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
264 logging.error(" "+self.path+"/SampleAnalyzer/linking.log")484
265 return False485 # return result
266486 if not result:
267487 logging.error('impossible to compile the project. For more details, see the log file:')
268 def Clean(self):488 logging.error(logfile)
269 res=commands.getstatusoutput("cd "\489
270 +self.path+"/SampleAnalyzer/;"\490 return result
271 +" make clean > cleanup.log 2>&1")491
272 return True492
273493 def Link(self,package,folder):
274 def MrProper(self):494
275 res=commands.getstatusoutput("cd "\495 # log file name
276 +self.path+"/SampleAnalyzer/;"\496 if package == 'SampleAnalyzer':
277 +" make mrproper > cleanup.log 2>&1")497 logfile = folder+'/linking.log'
278 return True498 else:
499 logfile = folder+'/linking_'+package+'.log'
500
501 # makefile
502 if package == 'SampleAnalyzer':
503 makefile = 'Makefile'
504 else:
505 makefile = 'Makefile_'+package
506
507 # shell command
508 commands = ['make','link','--file='+makefile]
509
510 # call
511 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
512
513 # return result
514 if not result:
515 logging.error('impossible to link the project. For more details, see the log file:')
516 logging.error(logfile)
517
518 return result
519
520
521 def Clean(self,package,folder):
522
523 # log file name
524 if package == 'SampleAnalyzer':
525 logfile = folder+'/cleanup.log'
526 else:
527 logfile = folder+'/cleanup_'+package+'.log'
528
529 # makefile
530 if package == 'SampleAnalyzer':
531 makefile = 'Makefile'
532 else:
533 makefile = 'Makefile_'+package
534
535 # shell command
536 commands = ['make','clean','--file='+makefile]
537
538 # call
539 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
540
541 # return result
542 if not result:
543 logging.error('impossible to clean the project. For more details, see the log file:')
544 logging.error(logfile)
545
546 return result
547
548
549 def MrProper(self,package,folder):
550
551 # log file name
552 if package == 'SampleAnalyzer':
553 logfile = folder+'/mrproper.log'
554 else:
555 logfile = folder+'/mrproper_'+package+'.log'
556
557 # makefile
558 if package == 'SampleAnalyzer':
559 makefile = 'Makefile'
560 else:
561 makefile = 'Makefile_'+package
562
563 # shell command
564 commands = ['make','mrproper','--file='+makefile]
565
566 # call
567 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder)
568
569 # return result
570 if not result:
571 logging.error('impossible to clean the project. For more details, see the log file:')
572 logging.error(logfile)
573
574 return result
575
576
577 def Run(self,program,args,folder,silent=False):
578
579 # shell command
580 commands = ['./'+program]
581 commands.extend(args)
582
583 # logfile
584 logfile = folder+'/'+program+'.log'
585
586 # call
587 result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder,silent)
588
589 # return result
590 if not result and not silent:
591 logging.error('impossible to run the project. For more details, see the log file:')
592 logging.error(logfile)
593
594 return result
595
596
597 def CheckRun(self,logfile,silent=False):
598
599 # Open
600 try:
601 input = open(logfile)
602 except:
603 logging.error('impossible to open the file:'+logfile)
604 return False
605
606 end=False
607 begin=False
608
609 # Loop over the logfile
610 for line in input:
611 line=line.lstrip()
612 line=line.rstrip()
613 if line=='BEGIN-SAMPLEANALYZER-TEST':
614 begin=True
615 elif line=='END-SAMPLEANALYZER-TEST':
616 end=True
617
618 # Close
619 try:
620 input.close()
621 except:
622 logging.error('impossible to close the file:'+logfile)
623 return False
624
625 # CrossCheck
626 if not (begin and end) and not silent:
627 logging.error('expected program output is not found. More details, see the log file:')
628 logging.error(logfile)
629 return False
630
631 return True
632
633
634 def WriteMakefileForTest(self):
635
636 # Open the file
637 filename = self.path + "/SampleAnalyzer/Test/Makefile_test"
638 try:
639 file = open(filename,"w")
640 except:
641 logging.error('impossible to write the file '+filenameself.path)
642 return False
643
644 # Writing header
645 file.write(StringTools.Fill('#',80)+'\n')
646 file.write('#'+StringTools.Center('MAKEFILE FOR SAMPLEANALYZER TEST',78)+'#\n')
647 file.write(StringTools.Fill('#',80)+'\n')
648 file.write('\n')
649
650 # Compilators
651 file.write('# Compilators\n')
652 file.write('CXX = g++\n')
653 file.write('\n')
654
655 # Options for compilation : CXXFLAGS
656 file.write('# Options for compilation\n')
657 options = []
658 options.extend(['-Wall','-O3','-I$(MA5_BASE)/tools/','-I'+self.main.configLinux.root_inc_path])
659 if self.libZIP:
660 options.extend(['-DZIP_USE'])
661 if self.libDelphes:
662 options.extend(['-DROOT_USE','-DDELPHES_USE'])
663 if self.libDelfes:
664 options.extend(['-DROOT_USE','-DDELFES_USE'])
665 if self.libFastJet:
666 options.extend(['-DROOT_USE','-DFASTJET_USE'])
667 file.write('CXXFLAGS = '+' '.join(options))
668 file.write('\n')
669
670 # Options for compilation : LIBFLAGS
671
672 # - Root
673 libs=[]
674 libs.extend(['-L'+self.main.configLinux.root_lib_path, \
675 '-lGpad','-lHist','-lGraf','-lGraf3d','-lTree', \
676 '-lRint','-lPostscript','-lMatrix','-lPhysics', \
677 '-lMathCore','-lEG', '-lRIO','-lNet','-lThread', \
678 '-lCore','-lCint','-pthread','-lm','-ldl','-rdynamic'])
679
680 # - SampleAnalyzer
681 libs.extend(['-L$(MA5_BASE)/tools/SampleAnalyzer/Lib/','-lSampleAnalyzer'])
682 if self.libZIP:
683 libs.extend(['-L'+self.main.configLinux.zlib_lib_path,'-lz','-lzlib_for_ma5'])
684 if self.libDelphes:
685 libs.extend(['-L'+self.main.configLinux.delphes_lib_paths[0],'-lDelphes','-ldelphes_for_ma5'])
686 if self.libDelfes:
687 libs.extend(['-L'+self.main.configLinux.delfes_lib_paths[0],'-lDelphes','-ldelfes_for_ma5'])
688 if self.fortran:
689 libs.extend(['-lgfortran'])
690 if self.libFastJet:
691 libs.extend(['$(shell fastjet-config --libs --plugins --rpath=no)','-lfastjet_for_ma5'])
692 file.write('LIBFLAGS = '+' '.join(libs)+'\n')
693 file.write('\n')
694
695 # Files to process
696 file.write('# Files to process\n')
697 file.write('SRCS = $(wildcard Test.cpp)\n')
698 file.write('\n')
699
700 # Files to generate
701 file.write('# Files to generate\n')
702 file.write('OBJS = $(SRCS:.cpp=.o)\n')
703 file.write('PROGRAM = SampleAnalyzerTest\n')
704 file.write('\n')
705
706 # Lib to check
707 file.write('# Requirements to check before building\n')
708 libs=[]
709 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so')
710 if self.libZIP:
711 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so')
712 if self.libDelphes:
713 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so')
714 if self.libDelfes:
715 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so')
716 if self.libFastJet:
717 libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so')
718 for ind in range(0,len(libs)):
719 file.write('REQUIRED'+str(ind+1)+' = '+libs[ind]+'\n')
720 file.write('\n')
721
722
723 # Defining colours for shell
724 file.write('# Defining colours\n')
725 file.write('GREEN = "\\\\033[1;32m"\n')
726 file.write('RED = "\\\\033[1;31m"\n')
727 file.write('PINK = "\\\\033[1;35m"\n')
728 file.write('BLUE = "\\\\033[1;34m"\n')
729 file.write('YELLOW = "\\\\033[1;33m"\n')
730 file.write('CYAN = "\\\\033[1;36m"\n')
731 file.write('NORMAL = "\\\\033[0;39m"\n')
732 file.write('\n')
733
734 # All target
735 file.write('# All target\n')
736 file.write('all: header library_check compile_header compile link_header link\n')
737 file.write('\n')
738
739 # Check library
740 if len(libs)!=0:
741 file.write('# Check library\n')
742 file.write('library_check:\n')
743 for ind in range(0,len(libs)):
744 file.write('ifeq ($(wildcard $(REQUIRED'+str(ind+1)+')),)\n')
745 file.write('\t@echo -e $(RED)"The shared library "$(REQUIRED'+str(ind+1)+')" is not found"\n')
746 file.write('\t@echo -e $(RED)" 1) Please check that MadAnalysis 5 is installed in the folder : "$(MA5_BASE)\n')
747 file.write('\t@echo -e $(RED)" 2) Launch MadAnalysis 5 in normal mode in order to build this library."\n')
748 file.write('\t@echo -e $(NORMAL)\n')
749 file.write('\t@false\n')
750 file.write('endif\n')
751 file.write('\n')
752
753 # Header target
754 file.write('# Header target\n')
755 file.write('header:\n')
756 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
757 file.write('\t@echo -e "'+StringTools.Center('Building MA5 job',50)+'"\n')
758 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
759 file.write('\n')
760
761 # Compile_header target
762 file.write('# Compile_header target\n')
763 file.write('compile_header:\n')
764 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
765 file.write('\t@echo -e "'+StringTools.Center('Compilation',50)+'"\n')
766 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
767 file.write('\n')
768
769 # Linking_header target
770 file.write('# Link_header target\n')
771 file.write('link_header:\n')
772 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
773 file.write('\t@echo -e "'+StringTools.Center('Final linking',50)+'"\n')
774 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
775 file.write('\n')
776
777 # Clean_header target
778 file.write('# clean_header target\n')
779 file.write('clean_header:\n')
780 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
781 file.write('\t@echo -e "'+StringTools.Center('Removing intermediate files from building',50)+'"\n')
782 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
783 file.write('\n')
784
785 # Mrproper_header target
786 file.write('# mrproper_header target\n')
787 file.write('mrproper_header:\n')
788 file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n')
789 file.write('\t@echo -e "'+StringTools.Center('Cleaning all the project',50)+'"\n')
790 file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n')
791 file.write('\n')
792
793 # Compile target
794 file.write('# Compile target\n')
795 file.write('compile: $(OBJS)\n')
796 file.write('\n')
797
798 # Object file target
799 file.write('# Object file target\n')
800 file.write('$(OBJS): \n')
801 file.write('\n')
802
803 # Link target
804 file.write('# Link target\n')
805 file.write('link: $(OBJS)\n')
806 file.write('\t$(CXX) $(CXXFLAGS) $(OBJS) $(LIBFLAGS) -o $(PROGRAM)\n')
807 file.write('\n')
808
809 # Clean target
810 file.write('# Clean target\n')
811 file.write('clean: clean_header do_clean\n')
812 file.write('\n')
813 file.write('# Do clean target\n')
814 file.write('do_clean: \n')
815 file.write('\t@rm -f $(OBJS)\n')
816 file.write('\n')
817
818 # Mr Proper target
819 file.write('# Mr Proper target \n')
820 file.write('mrproper: mrproper_header do_mrproper\n')
821 file.write('\n')
822 file.write('# Do Mr Proper target \n')
823 file.write('do_mrproper: do_clean\n')
824 file.write('\t@rm -f $(PROGRAM) compilation_test.log' + \
825 ' linking_test.log cleanup_test.log mrproper_test.log *~ */*~ */*~ \n')
826 file.write('\n')
827
828 # Phony target
829 file.write('# Phony target\n')
830 file.write('.PHONY: do_clean header link_header compile_header\n')
831 file.write('\n')
832
833 # Closing the file
834 file.close()
835
836 return True
837
279838
=== added file 'madanalysis/IOinterface/shell_command.py'
--- madanalysis/IOinterface/shell_command.py 1970-01-01 00:00:00 +0000
+++ madanalysis/IOinterface/shell_command.py 2014-05-17 19:51:11 +0000
@@ -0,0 +1,82 @@
1################################################################################
2#
3# Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks
4# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
5#
6# This file is part of MadAnalysis 5.
7# Official website: <https://launchpad.net/madanalysis5>
8#
9# MadAnalysis 5 is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# MadAnalysis 5 is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
21#
22################################################################################
23
24
25import logging
26import shutil
27import os
28import commands
29import subprocess
30
31
32class ShellCommand():
33
34 @staticmethod
35 def ExecuteWithLog(theCommands,logfile,path,silent=False):
36
37 # Open the log file
38 try:
39 output = open(logfile,'w')
40 except:
41 if not silent:
42 logging.error('impossible to write the file '+logfile)
43 return False, None
44
45 # Launching the commands
46 try:
47 result=subprocess.Popen(theCommands, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=path)
48 except:
49 if not silent:
50 logging.error('impossible to execute the commands: '+' '.join(theCommands))
51 return False, None
52
53 # Getting stdout
54 out, err = result.communicate()
55 if out!=None:
56 for line in out:
57 output.write(line)
58
59 # Close the log file
60 output.close()
61
62 # Return results
63 return (result.returncode==0), out
64
65
66
67 @staticmethod
68 def Execute(theCommands,path):
69
70 # Launching the commands
71 try:
72 result=subprocess.Popen(theCommands, cwd=path)
73 except:
74 logging.error('impossible to execute the commands: '+' '.join(theCommands))
75 return False, None
76
77 # Getting stdout
78 out, err = result.communicate()
79
80 # Return results
81 return (result.returncode==0)
82
083
=== modified file 'madanalysis/UpdateNotes.txt'
--- madanalysis/UpdateNotes.txt 2013-10-29 09:21:58 +0000
+++ madanalysis/UpdateNotes.txt 2014-05-17 19:51:11 +0000
@@ -1,5 +1,89 @@
1Update notes for MadAnalysis 5 (in reverse time order)1Update notes for MadAnalysis 5 (in reverse time order)
22
3123 1.1.10.35 (2014/05/09) fuks: Still a missing foot->footer replacement
4
5122 1.1.10.34 (2014/05/07) fuks: saffoot -> saffooter
6
7116 1.1.10.33 (2014/04/30) fuks: Moving ToRestFrame to the MCParticleFormat class
8
9115 1.1.10.32 (2014/04/29) fuks: Splitting the physics services in subcategories
10
11114 1.1.10.31 (2014/04/22) fuks: Renaming Daughter into daughter in sampleanalyzer
12
13113 1.1.10.30 (2014/03/10) fuks: Fixing bug in the mewanalyzer script
14
15112 1.1.10.29 (2014/03/10) fuks: updating the newanalyzer script
16
17110 1.1.10.28 (2014/02/11) fuks: Fixing minor bug when providing the wrong number of arguments to an
18 observable (thanks to B.Dumont)
19
20109 1.1.10.27 (2014/02/11) fuks: Removing the old filter infrastructure
21
22108 1.1.10.26 (2014/02/11) fuks: Updating the expert mode: adding new analyses to an existing
23 template directory
24
25107 1.1.10.25 (2014/02/06) fuks: Creation of an analysis template - changes in the file naming
26
27106 1.1.10.24 (2014/02/06) fuks: problems with wgetting fastjet on some machines
28
29105 1.1.10.23 (2014/02/05) fuks: Few bugs corrected in the mt2w implementation (thanks to Jeremy
30 Bernon and Beranger Dumont)
31
32104 1.1.10.22 (2014/01/31) fuks: Implementation of the MT2W variable + sorting functions
33
34103 1.1.10.21 (2014/01/29) fuks: new methods :dphi_0_pi and sphi_0_2pi (both at the python and c++
35 levels)
36
37102 1.1.10.20 (2014/01/28) fuks: Cleaning conflicts between delfes and delphes
38
3997 1.1.10.19 (2014/01/17) bfuks: Beranger's suggestion for a IsSurviving function to be called from
40 the manager
41
4296 1.1.10.18 (2014/01/17) bfuks: Beranger's suggestion for adding cuts/histos with one single RS:
43 added
44
4595 1.1.10.17 (2014/01/16) bfuks: Bug with the "AllSurviving" function fixed
46
4790 1.1.10.16 (2014/01/09) bfuks: Charge is now a int and not a float anymore. Small related fixes
48
4989 1.1.10.15 (2014/01/06) bfuks: small bug fix
50
5188 1.1.10.14 (2013/12/12) bfuks: Check added in the case one wants to fill a histo for which some
52 (but not all) SRs fails the cuts applied so far (thanks to Beranger)
53
5487 1.1.10.13 (2013/12/12) bfuks: Extended expert mode output: cleaning (cf. discussions with Chris)
55
5686 1.1.10.12 (2013/12/11) bfuks: Updating output format for the histo headers (extended expert mode)
57
5885 1.1.10.11 (2013/12/05) bfuks: Second Bug fix related to question #233529
59
6084 1.1.10.10 (2013/12/04) bfuks: Bug fix related to question #233529
61
6283 1.1.10.9 (2013/12/03) bfuks: Small bug in the MT2 routine (thanks to J. Bernon)
63
6481 1.1.10.8 (2013/12/02) bfuks: New output structure dedicated to multianalyses; few bug fixes
65
6680 1.1.10.7 (2013/11/29) bfuks: Bug in jetclustering + allowing for defining invisible particles via
67 the invisible multiparticle in the reco mode
68
6979 1.1.10.6 (2013/11/28) bfuks: Problem with the MET in the simplified LHE format used by madgraph
70 (question #239543)
71
7278 1.1.10.5 (2013/11/28) bfuks: Fixing clang issue (bug #1250337)
73
7476 1.1.10.4 (2013/11/28) bfuks: updating the versioning for the development version
75
7675 1.1.10.3 (2013/11/28) bfuks: MT2 variable + macos change of stdc++ library + cleaning of the
77 welcome message
78
7974 1.1.10.2 (2013/11/19) bfuks: MultiAnalyses are now possible in the expert mode; output still to
80 be implemented
81
8272 1.1.10.1 (2013/11/14) bfuks: small modifications in the view of including the signal region
83 object
84
8571 1.1.10.0 (2013/11/04) bfuks: use of names with the counters
86
380 1.1.9 (2013/10/28) ma5team: - adding Delphes interface + CMS/ATLAS cards8780 1.1.9 (2013/10/28) ma5team: - adding Delphes interface + CMS/ATLAS cards
4 - adding Delphes cards including pile-up88 - adding Delphes cards including pile-up
5 - the electric charge is now an integer at the reco level 89 - the electric charge is now an integer at the reco level
690
=== added file 'madanalysis/configuration/delfes_configuration.py'
--- madanalysis/configuration/delfes_configuration.py 1970-01-01 00:00:00 +0000
+++ madanalysis/configuration/delfes_configuration.py 2014-05-17 19:51:11 +0000
@@ -0,0 +1,156 @@
1################################################################################
2#
3# Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks
4# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
5#
6# This file is part of MadAnalysis 5.
7# Official website: <https://launchpad.net/madanalysis5>
8#
9# MadAnalysis 5 is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# MadAnalysis 5 is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
21#
22################################################################################
23
24
25from madanalysis.enumeration.ma5_running_type import MA5RunningType
26import os
27import logging
28
29class DelfesConfiguration:
30
31 userVariables = { "detector" : ["cms","atlas"],\
32 "output": ["true","false"],\
33 "pileup": ["none"] }
34
35 def __init__(self):
36 self.detector = "cms"
37 self.output = True
38 self.pileup = ""
39 self.card = ""
40 self.SetCard()
41
42 def SetCard(self):
43 if self.detector=='cms' and self.pileup=="":
44 self.card = "delfes_card_CMS.tcl"
45 elif self.detector=='cms' and self.pileup!="":
46 self.card = "delfes_card_CMS_PileUp.tcl"
47 elif self.detector=='atlas' and self.pileup=="":
48 self.card = "delfes_card_ATLAS.tcl"
49 elif self.detector=='atlas' and self.pileup!="":
50 self.card = "delfes_card_ATLAS_PileUp.tcl"
51
52 def Display(self):
53 self.user_DisplayParameter("detector")
54 self.user_DisplayParameter("output")
55 self.user_DisplayParameter("pileup")
56
57
58 def user_DisplayParameter(self,parameter):
59 if parameter=="detector":
60 logging.info(" detector : "+self.detector)
61 return
62 elif parameter=="output":
63 if self.output:
64 msg="true"
65 else:
66 msg="false"
67 logging.info(" ROOT output : "+msg)
68 return
69 elif parameter=="pileup":
70 if self.pileup=="":
71 msg="none"
72 else:
73 msg='"'+self.pileup+'"'
74 logging.info(" pile-up source = "+msg)
75
76 def SampleAnalyzerConfigString(self):
77 mydict = {}
78 if self.output:
79 mydict['output'] = '1'
80 else:
81 mydict['output'] = '0'
82 return mydict
83
84 def user_SetParameter(self,parameter,value,datasets,level):
85
86 # algorithm
87 if parameter=="detector":
88
89 if value.lower()=="cms":
90 self.detector=value
91 self.SetCard()
92 elif value.lower()=="atlas":
93 self.detector=value
94 self.SetCard()
95 else:
96 logging.error("algorithm called '"+value+"' is not found.")
97 return
98
99 # output
100 elif parameter=="output":
101
102 if value.lower()=="true":
103 self.output = True
104 elif value.lower()=="false":
105 self.output = False
106 else:
107 logging.error("allowed values for output are: true false")
108 return
109
110 # pileup
111 elif parameter=="pileup":
112 quoteTag=False
113 if value.startswith("'") and value.endswith("'"):
114 quoteTag=True
115 if value.startswith('"') and value.endswith('"'):
116 quoteTag=True
117 if quoteTag:
118 value=value[1:-1]
119 valuemin = value.lower()
120
121 # none
122 if valuemin=="none":
123 self.pileup = ""
124 self.SetCard()
125
126 # .pileup
127 elif valuemin.endswith(".pileup"):
128 if not os.path.isfile(value):
129 logging.error('File called "'+value+'" is not found')
130 return
131 self.pileup = value
132 self.SetCard()
133 return
134
135 # other case: error
136 else:
137 logging.error("The file format for the pile-up source is not known. Only files with .pileup extension can be used.")
138 return False
139
140 else:
141 logging.error("parameter called '"+parameter+"' does not exist")
142 return
143
144
145 def user_GetParameters(self):
146 return DelfesConfiguration.userVariables.keys()
147
148
149 def user_GetValues(self,variable):
150 table = []
151 try:
152 table.extend(DelfesConfiguration.userVariables[variable])
153 except:
154 pass
155 return table
156
0157
=== modified file 'madanalysis/configuration/delphes_configuration.py'
--- madanalysis/configuration/delphes_configuration.py 2013-10-27 21:05:18 +0000
+++ madanalysis/configuration/delphes_configuration.py 2014-05-17 19:51:11 +0000
@@ -36,7 +36,18 @@
36 self.detector = "cms"36 self.detector = "cms"
37 self.output = True37 self.output = True
38 self.pileup = ""38 self.pileup = ""
39 self.card = ""
40 self.SetCard()
3941
42 def SetCard(self):
43 if self.detector=='cms' and self.pileup=="":
44 self.card = "delphes_card_CMS.tcl"
45 elif self.detector=='cms' and self.pileup!="":
46 self.card = "delphes_card_CMS_PileUp.tcl"
47 elif self.detector=='atlas' and self.pileup=="":
48 self.card = "delphes_card_ATLAS.tcl"
49 elif self.detector=='atlas' and self.pileup!="":
50 self.card = "delphes_card_ATLAS_PileUp.tcl"
40 51
41 def Display(self):52 def Display(self):
42 self.user_DisplayParameter("detector")53 self.user_DisplayParameter("detector")
@@ -77,8 +88,10 @@
7788
78 if value.lower()=="cms":89 if value.lower()=="cms":
79 self.detector=value90 self.detector=value
91 self.SetCard()
80 elif value.lower()=="atlas":92 elif value.lower()=="atlas":
81 self.detector=value93 self.detector=value
94 self.SetCard()
82 else:95 else:
83 logging.error("algorithm called '"+value+"' is not found.")96 logging.error("algorithm called '"+value+"' is not found.")
84 return97 return
@@ -108,6 +121,7 @@
108 # none121 # none
109 if valuemin=="none":122 if valuemin=="none":
110 self.pileup = ""123 self.pileup = ""
124 self.SetCard()
111 125
112 # .pileup126 # .pileup
113 elif valuemin.endswith(".pileup"):127 elif valuemin.endswith(".pileup"):
@@ -115,6 +129,7 @@
115 logging.error('File called "'+value+'" is not found')129 logging.error('File called "'+value+'" is not found')
116 return130 return
117 self.pileup = value131 self.pileup = value
132 self.SetCard()
118 return133 return
119134
120 # other case: error135 # other case: error
121136
=== modified file 'madanalysis/configuration/fastsim_configuration.py'
--- madanalysis/configuration/fastsim_configuration.py 2013-09-29 22:12:23 +0000
+++ madanalysis/configuration/fastsim_configuration.py 2014-05-17 19:51:11 +0000
@@ -22,18 +22,20 @@
22################################################################################22################################################################################
2323
2424
25from madanalysis.enumeration.ma5_running_type import MA5RunningType25from madanalysis.enumeration.ma5_running_type import MA5RunningType
26from madanalysis.configuration.clustering_configuration import ClusteringConfiguration26from madanalysis.configuration.clustering_configuration import ClusteringConfiguration
27from madanalysis.configuration.delphes_configuration import DelphesConfiguration27from madanalysis.configuration.delphes_configuration import DelphesConfiguration
28from madanalysis.configuration.delfes_configuration import DelfesConfiguration
28import logging29import logging
2930
30class FastsimConfiguration:31class FastsimConfiguration:
3132
32 userVariables = { "package" : ["fastjet","delphes","none"] }33 userVariables = { "package" : ["fastjet","delphes","delfes","none"] }
3334
34 def __init__(self):35 def __init__(self):
35 self.clustering = 036 self.clustering = 0
36 self.delphes = 037 self.delphes = 0
38 self.delfes = 0
37 self.package = "none"39 self.package = "none"
3840
39 41
@@ -43,6 +45,8 @@
43 self.clustering.Display()45 self.clustering.Display()
44 elif self.package=="delphes":46 elif self.package=="delphes":
45 self.delphes.Display()47 self.delphes.Display()
48 elif self.package=="delfes":
49 self.delfes.Display()
4650
4751
48 def user_DisplayParameter(self,parameter):52 def user_DisplayParameter(self,parameter):
@@ -53,6 +57,8 @@
53 self.clustering.user_DisplayParameter(parameter)57 self.clustering.user_DisplayParameter(parameter)
54 elif self.package=="delphes":58 elif self.package=="delphes":
55 self.delphes.user_DisplayParameter(parameter)59 self.delphes.user_DisplayParameter(parameter)
60 elif self.package=="delfes":
61 self.delfes.user_DisplayParameter(parameter)
5662
5763
58 def SampleAnalyzerConfigString(self):64 def SampleAnalyzerConfigString(self):
@@ -64,11 +70,15 @@
64 mydict = {}70 mydict = {}
65 mydict.update(self.delphes.SampleAnalyzerConfigString())71 mydict.update(self.delphes.SampleAnalyzerConfigString())
66 return mydict72 return mydict
73 elif self.package=="delfes":
74 mydict = {}
75 mydict.update(self.delfes.SampleAnalyzerConfigString())
76 return mydict
67 else:77 else:
68 return {}78 return {}
6979
7080
71 def user_SetParameter(self,parameter,value,datasets,level,fastjet,delphes):81 def user_SetParameter(self,parameter,value,datasets,level,fastjet,delphes,delfes):
7282
73 # algorithm83 # algorithm
74 if parameter=="package":84 if parameter=="package":
@@ -89,11 +99,12 @@
89 test=False99 test=False
90 break100 break
91 if not test:101 if not test:
92 logging.error("some datasets contain partonic/hadronic file format. Fast-simulation package cannot be switched off.")102 logging.error("some datasets contain partonic/hadronic file format. "+\
103 "Fast-simulation package cannot be switched off.")
93 return104 return
94105
95 # Switch on the clustering106 # Switch on the clustering
96 elif value in ["fastjet","delphes"]:107 elif value in ["fastjet","delphes","delfes"]:
97108
98 # Only in reco mode109 # Only in reco mode
99 if level!=MA5RunningType.RECO:110 if level!=MA5RunningType.RECO:
@@ -110,6 +121,11 @@
110 logging.error("delphes library is not installed. This fast-simulation package is not available.")121 logging.error("delphes library is not installed. This fast-simulation package is not available.")
111 return122 return
112123
124 # Delfes ?
125 if value=='delfes' and not delfes:
126 logging.error("delfes library is not installed. This fast-simulation package is not available.")
127 return
128
113 test=True129 test=True
114 for dataset in datasets:130 for dataset in datasets:
115 if not test:131 if not test:
@@ -128,14 +144,22 @@
128 self.package="fastjet"144 self.package="fastjet"
129 self.clustering = ClusteringConfiguration()145 self.clustering = ClusteringConfiguration()
130 self.delphes = 0146 self.delphes = 0
147 self.delfes = 0
131 elif value=="delphes":148 elif value=="delphes":
132 self.package="delphes"149 self.package="delphes"
133 self.clustering = 0150 self.clustering = 0
134 self.delphes = DelphesConfiguration()151 self.delphes = DelphesConfiguration()
152 self.delfes = 0
153 elif value=="delfes":
154 self.package="delfes"
155 self.clustering = 0
156 self.delphes = 0
157 self.delfes = DelfesConfiguration()
135 elif value=="none":158 elif value=="none":
136 self.package="none"159 self.package="none"
137 self.clustering = 0160 self.clustering = 0
138 self.delphes = 0161 self.delphes = 0
162 self.delfes = 0
139 else:163 else:
140 logging.error("parameter called '"+value+"' is not found.")164 logging.error("parameter called '"+value+"' is not found.")
141 return 165 return
@@ -150,6 +174,8 @@
150 return self.clustering.user_SetParameter(parameter,value,datasets,level)174 return self.clustering.user_SetParameter(parameter,value,datasets,level)
151 elif self.package=="delphes":175 elif self.package=="delphes":
152 return self.delphes.user_SetParameter(parameter,value,datasets,level)176 return self.delphes.user_SetParameter(parameter,value,datasets,level)
177 elif self.package=="delfes":
178 return self.delfes.user_SetParameter(parameter,value,datasets,level)
153179
154 180
155 def user_GetParameters(self):181 def user_GetParameters(self):
@@ -159,6 +185,9 @@
159 elif self.package=="delphes":185 elif self.package=="delphes":
160 table = FastsimConfiguration.userVariables.keys()186 table = FastsimConfiguration.userVariables.keys()
161 table.extend(self.delphes.user_GetParameters())187 table.extend(self.delphes.user_GetParameters())
188 elif self.package=="delfes":
189 table = FastsimConfiguration.userVariables.keys()
190 table.extend(self.delfes.user_GetParameters())
162 else:191 else:
163 table = ["package"]192 table = ["package"]
164 return table193 return table
@@ -184,6 +213,15 @@
184 table.extend(self.delphes.user_GetValues(variable))213 table.extend(self.delphes.user_GetValues(variable))
185 except:214 except:
186 pass215 pass
216 elif self.package=="delfes":
217 try:
218 table.extend(FastsimConfiguration.userVariables[variable])
219 except:
220 pass
221 try:
222 table.extend(self.delfes.user_GetValues(variable))
223 except:
224 pass
187 else:225 else:
188 if variable=="package":226 if variable=="package":
189 table.extend(FastsimConfiguration.userVariables["package"])227 table.extend(FastsimConfiguration.userVariables["package"])
190228
=== modified file 'madanalysis/core/config_checker.py'
--- madanalysis/core/config_checker.py 2013-10-27 21:36:24 +0000
+++ madanalysis/core/config_checker.py 2014-05-17 19:51:11 +0000
@@ -39,9 +39,10 @@
39 container.append(item)39 container.append(item)
40 40
4141
42 def __init__(self,configLinux,ma5dir,script=False):42 def __init__(self,configLinux,ma5dir,script=False,isMAC=False):
4343
44 # Getting parameter from the main program44 # Getting parameter from the main program
45 self.isMAC=isMAC
45 self.configLinux=configLinux46 self.configLinux=configLinux
46 self.ma5dir=ma5dir47 self.ma5dir=ma5dir
47 self.script=script48 self.script=script
@@ -56,6 +57,74 @@
56 self.fillHeaders()57 self.fillHeaders()
5758
5859
60 def ReadUserOptions(self):
61
62 # Open the user options
63 filename = self.ma5dir+'/madanalysis/input/installation_options.dat'
64 try:
65 input = open(filename)
66 except:
67 logging.error('impossible to open the file: '+filename)
68 return False
69
70 # Loop over the file
71 for rawline in input:
72
73 if '#' in rawline:
74 line = rawline.split('#')[0]
75 if line=='':
76 continue
77 words=line.split('=')
78 if len(words)!=2:
79 logging.warning(filename+': the following line is incorrect and is skipped:')
80 logging.warning(line)
81 words[0]=words[0].lstrip()
82 words[0]=words[0].rstrip()
83 words[1]=words[1].lstrip()
84 words[1]=words[1].rstrip()
85
86 if words[0]=='root_includes':
87 self.configLinux.useroptions.root_includes==words[1]
88 elif words[0]=='root_libs':
89 self.configLinux.useroptions.root_libs=words[1]
90 elif words[0]=='delphes_veto':
91 self.configLinux.useroptions.delphes_veto=words[1]
92 elif words[0]=='delphes_includes':
93 self.configLinux.useroptions.delphes_includes=words[1]
94 elif words[0]=='delphes_libs':
95 self.configLinux.useroptions.delphes_libs=words[1]
96 elif words[0]=='delfes_veto':
97 self.configLinux.useroptions.delfes_veto=words[1]
98 elif words[0]=='delfes_includes':
99 self.configLinux.useroptions.delfes_includes=words[1]
100 elif words[0]=='delfes_libs':
101 self.configLinux.useroptions.delfes_libs=words[1]
102 elif words[0]=='zlib_veto':
103 self.configLinux.useroptions.zlib_veto=words[1]
104 elif words[0]=='zlib_includes':
105 self.configLinux.useroptions.zlib_includes=words[1]
106 elif words[0]=='zlib_libs':
107 self.configLinux.useroptions.zlib_libs=words[1]
108 elif words[0]=='fastjet_veto':
109 self.configLinux.useroptions.fastjet_veto=words[1]
110 elif words[0]=='fastjet_bin_path':
111 self.configLinux.useroptions.fastjet_bin_path=words[1]
112 elif words[0]=='pdflatex_veto':
113 self.configLinux.useroptions.pdflatex_veto=words[1]
114 elif words[0]=='latex_veto':
115 self.configLinux.useroptions.latex_veto=words[1]
116 elif words[0]=='dvipdf_veto':
117 self.configLinux.useroptions.dvipdf_veto=words[1]
118 else:
119 logging.warning(filename+': the options called "'+words[0]+'" is not found')
120
121 # Close the file
122 input.close()
123
124 # Ok
125 return True
126
127
59 def FillMA5Path(self):128 def FillMA5Path(self):
60 os.environ['MA5_BASE']=self.ma5dir129 os.environ['MA5_BASE']=self.ma5dir
61130
@@ -89,6 +158,7 @@
89 158
90 159
91 def fillHeaders(self):160 def fillHeaders(self):
161
92 # Filling container with paths included in CPLUS_INCLUDE_PATH162 # Filling container with paths included in CPLUS_INCLUDE_PATH
93 try:163 try:
94 cplus_include_path = os.environ['CPLUS_INCLUDE_PATH'].split(':')164 cplus_include_path = os.environ['CPLUS_INCLUDE_PATH'].split(':')
@@ -146,76 +216,74 @@
146 # Checking if ROOT is present216 # Checking if ROOT is present
147 self.PrintLibrary('Root')217 self.PrintLibrary('Root')
148218
219 # Does the user force the ROOT path
220 force1=False
221 force2=False
222 if self.configLinux.useroptions.root_includes!='0':
223 self.configLinux.root_inc_path=self.configLinux.useroptions.root_includes
224 force1=True
225 if self.configLinux.useroptions.root_libs!='0':
226 self.configLinux.root_lib_path=self.configLinux.useroptions.root_libs
227 force2=True
228 force=force1 and force2
229
149 # Trying to call root-config230 # Trying to call root-config
150 rootdirs = commands.getstatusoutput('root-config --libdir --incdir')231 if not force:
151 if rootdirs[0]>0:232
152 self.PrintFAIL(warning=False)233 # Using root-config
153 logging.error('ROOT module called "root-config" is not detected.\n'\234 rootdirs = commands.getstatusoutput('root-config --libdir --incdir')
154 +'Two explanations :n'\235 if rootdirs[0]>0:
155 +' - ROOT is not installed. You can download it '\236 self.PrintFAIL(warning=False)
156 +'from http://root.cern.ch\n'\237 logging.error('ROOT module called "root-config" is not detected.\n'\
157 +' - ROOT binary folder must be placed in the '\238 +'Two explanations :n'\
158 +'global environment variable $PATH')239 +' - ROOT is not installed. You can download it '\
159 return False240 +'from http://root.cern.ch\n'\
160241 +' - ROOT binary folder must be placed in the '\
161 # Extracting ROOT library and header path242 +'global environment variable $PATH')
162 root_tmp = rootdirs[1].split() 243 return False
163 self.includes.append(root_tmp[1])244
164 self.libs.append(root_tmp[0])245 # Extracting ROOT library and header path
165 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \246 root_tmp = rootdirs[1].split()
166 ":" + root_tmp[0]247 self.configLinux.root_inc_path = root_tmp[1]
167 os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \248 self.configLinux.root_lib_path = root_tmp[0]
168 ":" + root_tmp[0]
169 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \
170 ":" + root_tmp[0]
171 os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + \
172 ":" + root_tmp[1]
173249
174 # Adding ROOT library path to Python path250 # Adding ROOT library path to Python path
175 sys.path.append(root_tmp[0])251 sys.path.append(self.configLinux.root_lib_path)
176252
177 # Looking for libPyROOT.so253 # Check: looking for files
178 find=False254 FilesToFind=[self.configLinux.root_lib_path+'/libPyROOT.so', \
179 for item in self.libs:255 self.configLinux.root_inc_path+'/TH1F.h']
180 files=glob.glob(item+"/libPyROOT.so")256 for file in FilesToFind:
181 if len(files)!=0:257 if os.path.isfile(file):
182 self.configLinux.libraries['PyROOT']=files[0]+":"+str(os.stat(files[0]).st_mtime)258 self.configLinux.libraries[file.split('/')[-1]]=file+":"+str(os.stat(file).st_mtime)
183 find=True259 else:
184 break260 self.PrintFAIL(warning=False)
185 if not find:261 logging.error("ROOT file called '"+file+"' is not found")
186 self.PrintFAIL(warning=False)262 logging.error("Please check that ROOT is properly installed.")
187 logging.error("ROOT library called 'libPyROOT.so' not found. Please check that ROOT is properly installed.")263 return False
188 return False264
189265 # Check: looking for files
190 # Looking for ROOT.py266 FilesToFind=[self.configLinux.root_lib_path+'/ROOT.py', \
191 find=False267 self.configLinux.root_lib_path+'/ROOT.pyc']
192 for item in self.libs:268 found=False
193 files=glob.glob(item+"/ROOT.py")269 for file in FilesToFind:
194 if len(files)!=0:270 if os.path.isfile(file):
195 self.configLinux.libraries['ROOT']=files[0]+":"+str(os.stat(files[0]).st_mtime)271 self.configLinux.libraries[file.split('/')[-1]]=file+":"+str(os.stat(file).st_mtime)
196 find=True272 found=True
197 break273 break
198 if not find:274 if not found:
199 self.PrintFAIL(warning=False)275 self.PrintFAIL(warning=False)
200 logging.error("ROOT file called 'ROOT.py' not found. Please check that ROOT is properly installed.")276 logging.error("ROOT file called 'ROOT.py' or 'ROOT.pyc' is not found")
201 return False277 logging.error("Please check that ROOT is properly installed.")
202278 return False
203 # Looking for TH1F.h279
204 find=False280 # Root Install
205 for item in self.includes:
206 files=glob.glob(item+"/TH1F.h")
207 if len(files)!=0:
208 self.configLinux.headers['ROOT']=files[0]+":"+str(os.stat(files[0]).st_mtime)
209 find=True
210 break
211 if not find:
212 self.PrintFAIL(warning=False)
213 logging.error("ROOT headers are not found. " +\
214 "Please check that ROOT is properly installed.")
215 return False
216 self.PrintOK()281 self.PrintOK()
217282 return True
218283
284
285 def checkPyROOT(self):
286
219 # Loading ROOT library287 # Loading ROOT library
220 self.PrintLibrary("PyRoot libraries")288 self.PrintLibrary("PyRoot libraries")
221 try :289 try :
@@ -272,6 +340,29 @@
272 return True340 return True
273341
274342
343 def checkMake(self):
344 # Checking GNU Make
345 self.PrintLibrary('GNU Make')
346 make_version = commands.getstatusoutput('make --version')
347 if make_version[0]>0:
348 self.PrintFAIL(warning=False)
349 logging.error('GNU Make not found. Please install it before ' + \
350 'using MadAnalysis 5')
351 return False
352 else:
353 self.PrintOK()
354 lines=make_version[1].split('\n')
355 if len(lines)==0:
356 logging.error('command "make --version" seems to not give the GNU Make version')
357 return False
358 line=lines[0]
359 line=line.replace(' ','')
360 line=line.lstrip()
361 line=line.rstrip()
362 self.configLinux.make_version = line
363 return True
364
365
275 def checkGF(self):366 def checkGF(self):
276 self.PrintLibrary("gfortran")367 self.PrintLibrary("gfortran")
277 gfortran_version = commands.getstatusoutput('gfortran -dumpversion')368 gfortran_version = commands.getstatusoutput('gfortran -dumpversion')
@@ -285,14 +376,12 @@
285 gfortran_version = gfor.group(1)376 gfortran_version = gfor.group(1)
286 else:377 else:
287 self.PrintFAIL(warning=True)378 self.PrintFAIL(warning=True)
288 logging.warning('gfortran compiler not found.' + \379 logging.warning('gfortran compiler not found.')
289 ' aMCatNLO cannot be used.')
290 return True380 return True
291 ver = gfortran_version.split('.')381 ver = gfortran_version.split('.')
292 if (int(ver[0])<4) or (int(ver[0])==4 and int(ver[1])<4):382 if (int(ver[0])<4) or (int(ver[0])==4 and int(ver[1])<4):
293 self.PrintFAIL(warning=True)383 self.PrintFAIL(warning=True)
294 logging.warning('gfortran ' + gfortran_version + ' not recent enough (< 4.4.0).' +\384 logging.warning('gfortran ' + gfortran_version + ' older than 4.4.0.')
295 ' aMCatNLO cannot be used.')
296 return True385 return True
297 386
298 self.configLinux.gfortran_version = gfortran_version387 self.configLinux.gfortran_version = gfortran_version
@@ -300,73 +389,112 @@
300 return True389 return True
301390
302391
392 def FindLibraryWithPattern(self,pattern,files):
393 return self.FindFilesWithPattern(self.libs,pattern,files)
394
395 def FindHeader(self,file):
396 return self.FindFilesWithPattern(self.includes,file,[file])
397
398 def FindFilesWithPattern(self,paths,pattern,targets):
399 result_files=[]
400 result_paths=[]
401 for path in paths:
402 rawfiles=glob.glob(path+"/"+pattern)
403
404 filtered_files=[]
405 for file in rawfiles:
406 for target in targets:
407 if file.endswith('/'+target):
408 filtered_files.append(file)
409
410 if len(filtered_files)!=0:
411 result_files.extend(filtered_files)
412 for item in filtered_files:
413 result_paths.append(path)
414
415 if len(result_files)==0:
416 return "", ""
417 else:
418 return os.path.normpath(result_paths[0]), os.path.normpath(result_files[0])
419
420
303 def checkZLIB(self):421 def checkZLIB(self):
304422
305 self.PrintLibrary("zlib library")423 self.PrintLibrary("zlib library")
306 424
307 # Checking library libz.so425 # Name of the dynamic lib
308 find=False426 libnames=['libz.so','libz.a']
309 for item in self.libs:427 if self.isMAC:
310 files=glob.glob(item+"/libz.so")428 libnames.append('libz.dylib')
311 files.extend(glob.glob(item+"/libz.a"))429
312 files.extend(glob.glob(item+"/libz.dylib"))430 # User veto
313 if len(files)!=0:431 if self.configLinux.useroptions.zlib_veto=='1':
314 self.configLinux.libraries['ZLib']=files[0]+":"+str(os.stat(files[0]).st_mtime)432 self.PrintFAIL(warning=True)
315 find=True433 logging.warning("Library called 'zlib' disabled. Gzip format will be disabled.")
316 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \434 return False
317 ":" + item435
318 os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \436 # Does the user force the paths?
319 ":" + item437 force1=False
320 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \438 force2=False
321 ":" + item439 if self.configLinux.useroptions.zlib_includes!="0":
322 break440 self.configLinux.zlib_inc_path=self.configLinux.useroptions.zlib_includes
323441 force1=True
324 # If not, test if it is there locally 442 if self.configLinux.useroptions.zlib_libs!="0":
325 if not find: 443 self.configLinux.zlib_lib_path=self.configLinux.useroptions.zlib_libraries
326 item = self.ma5dir+'/tools/zlib/lib/'444 force2=True
327 files=glob.glob(item+"/libz.so")445 force=force1 and force2
328 files.extend(glob.glob(item+"/libz.a"))446
329 files.extend(glob.glob(item+"/libz.dylib"))447 # Checking if zlib has been installed by MA5
330 if len(files)!=0:448 ma5installation = False
331 self.configLinux.libraries['ZLib']=files[0]+":"+str(os.stat(files[0]).st_mtime)449 if not force:
332 find=True450 if os.path.isdir(self.ma5dir+'/tools/zlib'):
333 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \451 self.configLinux.zlib_inc_path=self.ma5dir+'/tools/zlib/include/'
334 ":" + item452 self.configLinux.zlib_lib_path=self.ma5dir+'/tools/zlib/lib/'
335 os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \453 ma5installation = True
336 ":" + item454
337 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \455 # Check if the libraries and headers are available
338 ":" + item456 if force or ma5installation:
339 # Not fail -> Warning457
340 if not find:458 # header
341 self.PrintFAIL(warning=True)459 if not os.path.isfile(self.configLinux.zlib_inc_path+'/zlib.h'):
342 logging.warning("Library called 'libz' not found. Gzip format will be disabled.")460 self.PrintFAIL(warning=True)
343 logging.warning("To enable this format, please type 'install zlib' package.")461 logging.warning("Header file called '"+self.configLinux.zlib_inc_path+"'/zlib.h not found. Gzip format will be disabled.")
344 return False462 logging.warning("To enable this format, please type 'install zlib' package.")
345463 return False
346 # Checking header file zlib.h464
347 find=False465 # lib
348 for item in self.includes:466 mypath, myfile = self.FindFilesWithPattern([self.configLinux.zlib_lib_path],"libz.*",libnames)
349 files=glob.glob(item+"/zlib.h")467 self.configLinux.zlib_lib=myfile
350 if len(files)!=0:468 if self.configLinux.zlib_lib=="":
351 self.configLinux.headers['ZLib']=files[0]+":"+str(os.stat(files[0]).st_mtime)469 self.PrintFAIL(warning=True)
352 find=True470 logging.warning("Zlib library not found in "+self.configLinux.zlib_lib_path+" folder. Gzip format will be disabled.")
353 os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + item471 logging.warning("To enable this format, please type 'install zlib' package.")
354 break472 return False
355473
356 # If not, test if it is there locally 474 # Checking zlib can be found in other folders
357 if not find: 475 if not force and not ma5installation:
358 find=os.path.isfile(self.ma5dir+'/tools/zlib/include/zlib.h')476
359 if find:477 # header
360 os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + \478 mypath, myfile = self.FindHeader('zlib.h')
361 self.ma5dir+'/tools/zlib/include/'479 self.configLinux.zlib_inc_path = mypath
362480 if self.configLinux.zlib_inc_path=="":
363 if not find:481 self.PrintFAIL(warning=True)
364 self.PrintFAIL(warning=True)482 logging.warning("Header file called 'zlib.h' not found. Gzip format will be disabled.")
365 logging.warning("Header file called 'zlib.h' not found. Gzip format will be disabled.")483 logging.warning("To enable this format, please type 'install zlib' package.")
366 logging.warning("To enable this format, please type 'install zlib' package.")484 return False
367 return False485
368 else:486 # lib
369 self.PrintOK()487 mypath, myfile = self.FindLibraryWithPattern('libz.*',libnames)
488 self.configLinux.zlib_lib_path = mypath
489 self.configLinux.zlib_lib = myfile
490 if self.configLinux.zlib_lib_path=="":
491 self.PrintFAIL(warning=True)
492 logging.warning("Library called 'zlib' not found. Gzip format will be disabled.")
493 logging.warning("To enable this format, please type 'install zlib' package.")
494 return False
495
496 self.configLinux.libraries['ZLib']=self.configLinux.zlib_lib+":"+str(os.stat(self.configLinux.zlib_lib).st_mtime)
497 self.PrintOK()
370 498
371 return True499 return True
372500
@@ -374,72 +502,169 @@
374 def checkDelphes(self):502 def checkDelphes(self):
375503
376 self.PrintLibrary("delphes library")504 self.PrintLibrary("delphes library")
377 505
378 # Checking library libDelphes.so506 # Name of the dynamic lib
379 find=False507 libnames=['libDelphes.so','libDelphes.a']
380 for item in self.libs:508 if self.isMAC:
381 files=glob.glob(item+"/libDelphes.so")509 libnames.append('libDelphes.dylib')
382 files.extend(glob.glob(item+"/libDelphes.a"))510
383 files.extend(glob.glob(item+"/libDelphes.dylib"))511 # User veto
384 if len(files)!=0:512 if self.configLinux.useroptions.delphes_veto=='1':
385 self.configLinux.libraries['Delphes']=files[0]+":"+str(os.stat(files[0]).st_mtime)513 self.PrintFAIL(warning=True)
386 find=True514 logging.warning("Library called 'delphes' disabled. Delphes ROOT format will be disabled.")
387 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \515 return False
388 ":" + item516
389 os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \517 # Does the user force the paths?
390 ":" + item518 force1=False
391 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \519 force2=False
392 ":" + item520 if self.configLinux.useroptions.delphes_includes!="0":
393 break521 self.configLinux.delphes_inc_paths.append(self.configLinux.useroptions.delphes_includes)
394522 self.configLinux.delphes_inc_paths.append(self.configLinux.useroptions.delphes_includes+'/external/')
395 # If not, test if it is there locally 523 force1=True
396 if not find: 524 if self.configLinux.useroptions.delphes_libs!="0":
397 item = self.ma5dir+'/tools/delphes/'525 self.configLinux.delphes_lib_paths.append(self.configLinux.useroptions.delphes_libraries)
398 files=glob.glob(item+"/libDelphes.so")526 force2=True
399 files.extend(glob.glob(item+"/libDelphes.a"))527 force=force1 and force2
400 files.extend(glob.glob(item+"/libDelphes.dylib"))528
401 if len(files)!=0:529 # Checking if Delphes has been installed by MA5
402 self.configLinux.libraries['Delphes']=files[0]+":"+str(os.stat(files[0]).st_mtime)530 ma5installation = False
403 find=True531 if not force:
404 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \532 if os.path.isdir(self.ma5dir+'/tools/delphes') and \
405 ":" + item533 os.path.isdir(self.ma5dir+'/tools/delphes/external'):
406 os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \534 self.configLinux.delphes_inc_paths.append(self.ma5dir+'/tools/delphes/')
407 ":" + item535 self.configLinux.delphes_inc_paths.append(self.ma5dir+'/tools/delphes/external/')
408 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \536 self.configLinux.delphes_lib_paths.append(self.ma5dir+'/tools/delphes/')
409 ":" + item537 ma5installation = True
410 # Not fail -> Warning538
411 if not find:539 # Check if the libraries and headers are available
412 self.PrintFAIL(warning=True)540 if force or ma5installation:
413 logging.warning("Library called 'delphes' not found. Delphes ROOT format will be disabled.")541
414 logging.warning("To enable this format, please type 'install delphes'.")542 # header
415 return False543 if not os.path.isfile(self.configLinux.delphes_inc_paths[0]+'/modules/ParticlePropagator.h'):
416544 self.PrintFAIL(warning=True)
417 # Checking header file 545 logging.warning("Header file called '"+self.configLinux.delphes_inc_paths[0]+"/modules/ParticlePropagator.h' not found." +\
418 find=False546 "Delphes ROOT format will be disabled.")
419 for item in self.includes:547 logging.warning("To enable this format, please type 'install delphes' package.")
420 files=glob.glob(item+"/modules/ParticlePropagator.h")548 return False
421 if len(files)!=0:549
422 self.configLinux.headers['Delphes']=files[0]+":"+str(os.stat(files[0]).st_mtime)550 # lib
423 find=True551 mypath, myfile = self.FindFilesWithPattern(self.configLinux.delphes_lib_paths,"libDelphes.*",libnames)
424 os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + item552 self.configLinux.delphes_lib=myfile
425 break553 if self.configLinux.delphes_lib=="":
426554 self.PrintFAIL(warning=True)
427 # If not, test if it is there locally 555 logging.warning("Delphes library not found in "+self.configLinux.delphes_lib_paths[0]+" folder. Delphes ROOT format will be disabled.")
428 if not find: 556 logging.warning("To enable this format, please type 'install delphes' package.")
429 find=os.path.isfile(self.ma5dir+'/tools/delphes/modules/ParticlePropagator.h')557 return False
430 if find:558
431 os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + \559 # Checking Delphes can be found in other folders
432 self.ma5dir+'/tools/delphes/'560 if not force and not ma5installation:
433 os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + \561
434 self.ma5dir+'/tools/delphes/external/'562 # header
435563 mypath, myfile = self.FindHeader('/modules/ParticlePropagator.h')
436 if not find:564 self.delphes_inc_path = mypath
437 self.PrintFAIL(warning=True)565 if self.delphes_inc_path=="":
438 logging.warning("Header file called 'modules/ParticlePropagator.h' not found. Delphes ROOT format will be disabled.")566 self.PrintFAIL(warning=True)
439 logging.warning("To enable this format, please type 'install delphes' package.")567 logging.warning("Header file called '/modules/ParticlePropagator.h' not found. Delphes ROOT format will be disabled.")
440 return False568 logging.warning("To enable this format, please type 'install delphes' package.")
441 else:569 return False
442 self.PrintOK()570
571 # lib
572 mypath, myfile = self.FindLibraryWithPattern('libDelphes.*',libnames)
573 self.configLinux.delphes_lib_path = mypath
574 self.configLinux.delphes_lib = myfile
575 if self.configLinux.delphes_lib_path=="":
576 self.PrintFAIL(warning=True)
577 logging.warning("Delphes library not found. Delphes format will be disabled.")
578 logging.warning("To enable this format, please type 'install delphes' package.")
579 return False
580
581 self.configLinux.libraries['Delphes']=self.configLinux.delphes_lib+":"+str(os.stat(self.configLinux.delphes_lib).st_mtime)
582 self.PrintOK()
583
584 return True
585
586
587 def checkDelfes(self):
588
589# self.PrintLibrary("delfes library")
590
591 # Name of the dynamic lib
592 libnames=['libDelphes.so','libDelphes.a']
593 if self.isMAC:
594 libnames.append('libDelphes.dylib')
595
596 # User veto
597 if self.configLinux.useroptions.delfes_veto=='1':
598# self.PrintFAIL(warning=True)
599# logging.warning("Library called 'delfes' disabled. Delfes ROOT format will be disabled.")
600 return False
601
602 # Does the user force the paths?
603 force1=False
604 force2=False
605 if self.configLinux.useroptions.delfes_includes!="0":
606 self.configLinux.delfes_inc_paths.append(self.configLinux.useroptions.delfes_includes)
607 self.configLinux.delfes_inc_paths.append(self.configLinux.useroptions.delfes_includes+'/external/')
608 force1=True
609 if self.configLinux.useroptions.delfes_libs!="0":
610 self.configLinux.delfes_lib_paths.append(self.configLinux.useroptions.delfes_libraries)
611 force2=True
612 force=force1 and force2
613
614 # Checking if delfes has been installed by MA5
615 ma5installation = False
616 if not force:
617 if os.path.isdir(self.ma5dir+'/tools/delfes') and \
618 os.path.isdir(self.ma5dir+'/tools/delfes/external'):
619 self.configLinux.delfes_inc_paths.append(self.ma5dir+'/tools/delfes/')
620 self.configLinux.delfes_inc_paths.append(self.ma5dir+'/tools/delfes/external/')
621 self.configLinux.delfes_lib_paths.append(self.ma5dir+'/tools/delfes/')
622 ma5installation = True
623
624 # Check if the libraries and headers are available
625 if force or ma5installation:
626
627 # header
628 if not os.path.isfile(self.configLinux.delfes_inc_paths[0]+'/modules/ParticlePropagator.h'):
629# self.PrintFAIL(warning=True)
630# logging.warning("Header file called '"+self.configLinux.delfes_inc_paths[0]+"/modules/ParticlePropagator.h' not found." +\
631# "Delfes ROOT format will be disabled.")
632# logging.warning("To enable this format, please type 'install delfes' package.")
633 return False
634
635 # lib
636 mypath, myfile = self.FindFilesWithPattern(self.configLinux.delfes_lib_paths,"libDelphes.*",libnames)
637 self.configLinux.delfes_lib=myfile
638 if self.configLinux.delfes_lib=="":
639# self.PrintFAIL(warning=True)
640# logging.warning("Delfes library not found in "+self.configLinux.delfes_lib_paths[0]+" folder. Delfes ROOT format will be disabled.")
641# logging.warning("To enable this format, please type 'install delfes' package.")
642 return False
643
644 # Checking Delfes can be found in other folders
645 if not force and not ma5installation:
646
647 # header
648 mypath, myfile = self.FindHeader('/modules/ParticlePropagator.h')
649 self.delfes_inc_path = mypath
650 if self.delfes_inc_path=="":
651# self.PrintFAIL(warning=True)
652# logging.warning("Header file called '/modules/ParticlePropagator.h' not found. Delfes ROOT format will be disabled.")
653# logging.warning("To enable this format, please type 'install delfes' package.")
654 return False
655
656 # lib
657 mypath, myfile = self.FindLibraryWithPattern('libDelphes.*',libnames)
658 self.configLinux.delfes_lib_path = mypath
659 self.configLinux.delfes_lib = myfile
660 if self.configLinux.delfes_lib_path=="":
661# self.PrintFAIL(warning=True)
662# logging.warning("Delfes library not found. Delfes format will be disabled.")
663# logging.warning("To enable this format, please type 'install delfes' package.")
664 return False
665
666 self.configLinux.libraries['Delfes']=self.configLinux.delfes_lib+":"+str(os.stat(self.configLinux.delfes_lib).st_mtime)
667# self.PrintOK()
443 668
444 return True669 return True
445670
@@ -462,32 +687,58 @@
462 def checkFastJet(self):687 def checkFastJet(self):
463688
464 self.PrintLibrary("FastJet")689 self.PrintLibrary("FastJet")
465
466 self.configLinux.fastjet_version = "none"690 self.configLinux.fastjet_version = "none"
467691
468 # Checking if fastjet is installed on the system692 # User veto
469 find = False693 if self.configLinux.useroptions.fastjet_veto=='1':
470 for item in self.paths:
471 files=glob.glob(item+"/fastjet-config")
472 files.extend(glob.glob(item+"/fastjet-config"))
473 if(len(files))!=0:
474 find = True
475 self.configLinux.fastjet_version = commands.getstatusoutput('fastjet-config --version')[1]
476
477 # If not, test if it is there locally
478 if not find:
479 find=os.path.isfile(self.ma5dir+'/tools/fastjet/bin/fastjet-config')
480
481 # If not there, print warning message; if there -> test it
482 if not find:
483 self.PrintFAIL(warning=True)694 self.PrintFAIL(warning=True)
484 logging.warning("The fastJet package not found. JetClustering algorithms are disabled.")695 logging.warning("The FastJet package is disabled. JetClustering algorithms are disabled.")
485 logging.warning("To enable this functionnality, please type 'install fastjet'.")
486 return False696 return False
487 else:697
488 self.configLinux.fastjet_version = commands.getstatusoutput(self.ma5dir+'/tools/fastjet/bin/fastjet-config --version')[1]698 # Does the user force the paths?
489 os.environ['PATH'] = self.ma5dir+'/tools/fastjet/bin/:'+os.environ['PATH']699 force=False
490 self.PrintOK()700 if self.configLinux.useroptions.fastjet_bin_path!="0":
701 self.configLinux.fastjet_bin_path.append(self.configLinux.useroptions.fastjet_bin_path)
702 force=True
703
704 # Checking if FastJet has been installed by MA5
705 ma5installation = False
706 if not force:
707 if os.path.isdir(self.ma5dir+'/tools/fastjet/bin'):
708 self.configLinux.fastjet_bin_path=self.ma5dir+'/tools/fastjet/bin/'
709 ma5installation = True
710
711 # Check if the libraries and headers are available
712 if force or ma5installation:
713
714 if not os.path.isfile(self.configLinux.fastjet_bin_path+'/fastjet-config'):
715 self.PrintFAIL(warning=True)
716 logging.warning("The FastJet package not found. JetClustering algorithms are disabled.")
717 logging.warning("To enable this functionnality, please type 'install fastjet'.")
718 return False
719
720 # Checking FastJet can be found in other folders
721 if not force and not ma5installation:
722
723 for item in self.paths:
724 files=glob.glob(item+"/fastjet-config")
725 files.extend(glob.glob(item+"/fastjet-config"))
726 if(len(files))!=0:
727 self.configLinux.fastjet_bin_path=item
728 break
729 if self.configLinux.fastjet_bin_path=='':
730 self.PrintFAIL(warning=True)
731 logging.warning("The FastJet package not found. JetClustering algorithms are disabled.")
732 logging.warning("To enable this functionnality, please type 'install fastjet'.")
733 return False
734
735 self.configLinux.fastjet_version = commands.getstatusoutput(self.ma5dir+'/tools/fastjet/bin/fastjet-config --version')[1]
736 tmp = commands.getstatusoutput(self.ma5dir+'/tools/fastjet/bin/fastjet-config --libs --plugins')[1]
737 words = tmp.split()
738 for word in words:
739 if word.startswith('-L'):
740 self.configLinux.fastjet_lib_paths.append(word[2:])
741 self.PrintOK()
491742
492 return True743 return True
493744
@@ -512,6 +763,11 @@
512 def checkPdfLatex(self):763 def checkPdfLatex(self):
513 self.PrintLibrary('pdflatex')764 self.PrintLibrary('pdflatex')
514765
766 if self.configLinux.useroptions.pdflatex_veto=='1':
767 self.PrintFAIL(warning=True)
768 logging.warning("pdflatex disabled. Reports under the pdf format will not be compiled.")
769 return False
770
515 pdflatex_version = commands.getstatusoutput('pdflatex -version')771 pdflatex_version = commands.getstatusoutput('pdflatex -version')
516 if 'not found' in str(pdflatex_version) or 'no such file' in str(pdflatex_version):772 if 'not found' in str(pdflatex_version) or 'no such file' in str(pdflatex_version):
517 self.PrintFAIL(warning=True)773 self.PrintFAIL(warning=True)
@@ -524,6 +780,11 @@
524 def checkLatex(self):780 def checkLatex(self):
525 self.PrintLibrary('latex')781 self.PrintLibrary('latex')
526782
783 if self.configLinux.useroptions.latex_veto=='1':
784 self.PrintFAIL(warning=True)
785 logging.warning("latex disabled. Reports under the dvi format will not be compiled.")
786 return False
787
527 latex_version = commands.getstatusoutput('latex -version')788 latex_version = commands.getstatusoutput('latex -version')
528 if 'not found' in str(latex_version) or 'no such file' in str(latex_version):789 if 'not found' in str(latex_version) or 'no such file' in str(latex_version):
529 self.PrintFAIL(warning=True)790 self.PrintFAIL(warning=True)
@@ -536,6 +797,11 @@
536 def checkdvipdf(self):797 def checkdvipdf(self):
537 self.PrintLibrary('dvipdf')798 self.PrintLibrary('dvipdf')
538799
800 if self.configLinux.useroptions.dvipdf_veto=='1':
801 self.PrintFAIL(warning=True)
802 logging.warning("dvipdf disabled. DVI reports will not be converted to pdf files.")
803 return False
804
539 dvipdf_version = commands.getstatusoutput('dvipdf')805 dvipdf_version = commands.getstatusoutput('dvipdf')
540 if 'not found' in str(dvipdf_version) or 'no such file' in str(dvipdf_version):806 if 'not found' in str(dvipdf_version) or 'no such file' in str(dvipdf_version):
541 self.PrintFAIL(warning=True)807 self.PrintFAIL(warning=True)
542808
=== modified file 'madanalysis/core/expert_mode.py'
--- madanalysis/core/expert_mode.py 2013-05-31 21:57:38 +0000
+++ madanalysis/core/expert_mode.py 2014-05-17 19:51:11 +0000
@@ -42,8 +42,10 @@
42 42
43 def CreateDirectory(self):43 def CreateDirectory(self):
44 logging.info("\nWelcome to the expert mode of MadAnalysis")44 logging.info("\nWelcome to the expert mode of MadAnalysis")
45 logging.info("Please enter a folder for creating an empty SampleAnalyzer job")45 logging.info("Please enter a folder name for creating an empty SampleAnalyzer job")
46 answer=raw_input("Answer: ")46 answer=raw_input("Answer: ")
47 answer=answer.replace(' ','_');
48 answer=answer.replace('-','_');
47 self.path = os.path.expanduser(answer)49 self.path = os.path.expanduser(answer)
48 if not self.path.startswith('/'):50 if not self.path.startswith('/'):
49 self.path = self.main.currentdir+'/'+self.path51 self.path = self.main.currentdir+'/'+self.path
@@ -90,12 +92,17 @@
90 return False92 return False
9193
92 # Writing an empty analysis94 # Writing an empty analysis
95 logging.info("Please enter a name for your analysis")
96 title=raw_input("Answer: ")
97 if title=="":
98 title="user"
99 title=title.replace(' ', '_');
100 title=title.replace('-', '_');
93 logging.info(" Writing an empty analysis...")101 logging.info(" Writing an empty analysis...")
94 jobber.WriteEmptyFilterSource(self.main)102 os.system("cd "+self.path+"/Build/SampleAnalyzer; python newAnalyzer.py " + title + " 1")
95 os.system("cd "+self.path+"/Build/SampleAnalyzer; python newAnalyzer.py user")
96103
97 # Extracting analysis name104 # Extracting analysis name
98 file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.cpp")105 file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.h")
99 title=""106 title=""
100 for line in file:107 for line in file:
101 if "Add" not in line:108 if "Add" not in line:
@@ -105,9 +112,7 @@
105 title=words[1]112 title=words[1]
106 break113 break
107 file.close()114 file.close()
108 if title=="":115
109 title="user"
110
111 # Writing a Makefile116 # Writing a Makefile
112 logging.info(" Writing a 'Makefile'...")117 logging.info(" Writing a 'Makefile'...")
113 if not jobber.WriteMakefiles():118 if not jobber.WriteMakefiles():
114119
=== modified file 'madanalysis/core/library_builder.py'
--- madanalysis/core/library_builder.py 2013-05-17 06:19:22 +0000
+++ madanalysis/core/library_builder.py 2014-05-17 19:51:11 +0000
@@ -31,11 +31,15 @@
3131
32class LibraryBuilder:32class LibraryBuilder:
3333
34 def __init__(self,configLinux,ma5dir):34 def __init__(self,configLinux,ma5dir,libZIP,libDelphes,libDelfes,libFastJet):
3535
36 self.configLinux=configLinux36 self.configLinux=configLinux
37 self.ma5dir=ma5dir37 self.ma5dir=ma5dir
38 self.configStore = LinuxArchitecture()38 self.configStore = LinuxArchitecture()
39 self.libZIP=libZIP
40 self.libDelphes=libDelphes
41 self.libDelfes=libDelfes
42 self.libFastJet=libFastJet
3943
40 44
41 def checkMA5(self):45 def checkMA5(self):
@@ -53,19 +57,33 @@
53 logging.error(" "+name)57 logging.error(" "+name)
54 return False58 return False
5559
56 # Look for shared library 'MadAnalysis' and 'config' file60 # Look for the shared library 'MadAnalysis' and 'config' file
57 if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.a') \61 if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so') \
58 or not os.path.isfile(self.ma5dir+'/tools/architecture.ma5'):62 or not os.path.isfile(self.ma5dir+'/tools/architecture.ma5'):
59 FirstUse=True63 FirstUse=True
64 return True, False
65
66 # Look for optional library
67 libraries = []
68 if self.libFastJet:
69 libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so')
70 if self.libZIP:
71 libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so')
72 if self.libDelphes:
73 libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so')
74 if self.libDelfes:
75 libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so')
76 for library in libraries:
77 if not os.path.isfile(library):
78 return False, True
6079
61 # Importing the configuration stored with the library80 # Importing the configuration stored with the library
62 if not FirstUse:81 if not FirstUse:
63 if not self.configStore.Import(self.ma5dir+'/tools/architecture.ma5'):82 if not self.configStore.Import(self.ma5dir+'/tools/architecture.ma5'):
64 FirstUse=True83 FirstUse=True
84 return True, False
6585
66 if not FirstUse:86 return FirstUse, False
67 logging.info(' => MadAnalysis library found.')
68 return FirstUse
69 87
70 88
71 def compare(self):89 def compare(self):
7290
=== modified file 'madanalysis/core/linux_architecture.py'
--- madanalysis/core/linux_architecture.py 2013-10-27 21:36:24 +0000
+++ madanalysis/core/linux_architecture.py 2014-05-17 19:51:11 +0000
@@ -23,14 +23,121 @@
2323
2424
25import logging25import logging
26
27class UserOptions:
28
29 def __init__(self):
30 self.root_includes = '0'
31 self.root_libs = '0'
32 self.delphes_veto = '0'
33 self.delphes_includes = '0'
34 self.delphes_libs = '0'
35 self.delfes_veto = '0'
36 self.delfes_includes = '0'
37 self.delfes_libs = '0'
38 self.zlib_veto = '0'
39 self.zlib_includes = '0'
40 self.zlib_libs = '0'
41 self.fastjet_veto = '0'
42 self.fastjet_bin_path = '0'
43 self.pdflatex_veto = '0'
44 self.latex_veto = '0'
45 self.dvipdf_veto = '0'
46
47 def Dump(self):
48 logging.info(" ROOT header path = " + str(self.root_includes))
49 logging.info(" ROOT library path = " + str(self.root_libs))
50 logging.info(" DELPHES veto = " + str(self.delphes_veto))
51 logging.info(" DELPHES header path = " + str(self.delphes_includes))
52 logging.info(" DELPHES library path = " + str(self.delphes_libs))
53 logging.info(" DELFES veto = " + str(self.delfes_veto))
54 logging.info(" DELFES header path = " + str(self.delfes_includes))
55 logging.info(" DELFES library path = " + str(self.delfes_libs))
56 logging.info(" ZLIB veto = " + str(self.zlib_veto))
57 logging.info(" ZLIB header path = " + str(self.zlib_includes))
58 logging.info(" ZLIB library path = " + str(self.zlib_libs))
59 logging.info(" FASTJET veto = " + str(self.fastjet_veto))
60 logging.info(" FASTJET bin path = " + str(self.fastjet_bin_path))
61 logging.info(" PDFLATEX veto = " + str(self.pdflatex_veto))
62 logging.info(" LATEX veto = " + str(self.latex_veto))
63 logging.info(" DVIPDF veto = " + str(self.dvipdf_veto))
64
65 def Export(self,file):
66 file.write(self.root_includes+"\n")
67 file.write(self.root_libs+"\n")
68 file.write(self.delphes_veto+"\n")
69 file.write(self.delphes_includes+"\n")
70 file.write(self.delphes_libs+"\n")
71 file.write(self.delfes_veto+"\n")
72 file.write(self.delfes_includes+"\n")
73 file.write(self.delfes_libs+"\n")
74 file.write(self.zlib_veto+"\n")
75 file.write(self.zlib_includes+"\n")
76 file.write(self.zlib_libs+"\n")
77 file.write(self.fastjet_veto+"\n")
78 file.write(self.fastjet_bin_path+"\n")
79 file.write(self.pdflatex_veto+"\n")
80 file.write(self.latex_veto+"\n")
81 file.write(self.dvipdf_veto+"\n")
82
83 def Import(self,file):
84 self.root_includes = file.readline().replace('\n','')
85 self.root_libs = file.readline().replace('\n','')
86 self.delphes_veto = file.readline().replace('\n','')
87 self.delphes_includes = file.readline().replace('\n','')
88 self.delphes_libs = file.readline().replace('\n','')
89 self.delfes_veto = file.readline().replace('\n','')
90 self.delfes_includes = file.readline().replace('\n','')
91 self.delfes_libs = file.readline().replace('\n','')
92 self.zlib_veto = file.readline().replace('\n','')
93 self.zlib_includes = file.readline().replace('\n','')
94 self.zlib_libs = file.readline().replace('\n','')
95 self.fastjet_veto = file.readline().replace('\n','')
96 self.fastjet_bin_path = file.readline().replace('\n','')
97 self.pdflatex_veto = file.readline().replace('\n','')
98 self.latex_veto = file.readline().replace('\n','')
99 self.dvipdf_veto = file.readline().replace('\n','')
100
101 def Compare(self,other):
102 if self.root_includes != other.root_includes:
103 return False
104 if self.root_libs != other.root_libs:
105 return False
106 if self.delphes_veto != other.delphes_veto:
107 return False
108 if self.delphes_includes != other.delphes_includes:
109 return False
110 if self.delphes_libs != other.delphes_libs:
111 return False
112 if self.delfes_veto != other.delfes_veto:
113 return False
114 if self.delfes_includes != other.delfes_includes:
115 return False
116 if self.delfes_libs != other.delfes_libs:
117 return False
118 if self.zlib_veto != other.zlib_veto:
119 return False
120 if self.zlib_includes != other.zlib_includes:
121 return False
122 if self.zlib_libs != other.zlib_libs:
123 return False
124 if self.fastjet_veto != other.fastjet_veto:
125 return False
126 if self.fastjet_bin_path != other.fastjet_bin_path:
127 return False
128 return True
129
26class LinuxArchitecture:130class LinuxArchitecture:
27131
28 def __init__(self):132 def __init__(self):
133 self.useroptions = UserOptions()
29 self.platform = ""134 self.platform = ""
135 self.release = ""
30 self.ma5_version = ""136 self.ma5_version = ""
31 self.ma5_date = ""137 self.ma5_date = ""
32 self.python_version = ""138 self.python_version = ""
33 self.gcc_version = ""139 self.gcc_version = ""
140 self.make_version = ""
34 self.gfortran_version = ""141 self.gfortran_version = ""
35 self.root_version = ""142 self.root_version = ""
36 self.fastjet_version = ""143 self.fastjet_version = ""
@@ -38,13 +145,35 @@
38 self.headers = {}145 self.headers = {}
39 self.editor = ""146 self.editor = ""
40147
148 self.root_inc_path=""
149 self.root_lib_path=""
150 self.zlib_inc_path=""
151 self.zlib_lib_path=""
152 self.zlib_lib=""
153 self.delphes_inc_paths=[]
154 self.delphes_lib_paths=[]
155 self.delphes_lib=""
156 self.delfes_inc_paths=[]
157 self.delfes_lib_paths=[]
158 self.delfes_lib=""
159 self.fastjet_bin_path=""
160 self.fastjet_lib_paths=[]
41161
42 def Dump(self):162 def Dump(self):
43 logging.info(" Linux distrib = " + self.platform)163 logging.info(" User options")
164 logging.info(" ------------")
165 self.useroptions.Dump()
166 logging.info("")
167
168 logging.info(" Architecture")
169 logging.info(" ------------")
170 logging.info(" Platform = " + self.platform)
171 logging.info(" Release platform = " + self.release)
44 logging.info(" MA5 version = " + self.ma5_version)172 logging.info(" MA5 version = " + self.ma5_version)
45 logging.info(" MA5 date = " + self.ma5_date)173 logging.info(" MA5 date = " + self.ma5_date)
46 logging.info(" Python version = " + self.python_version)174 logging.info(" Python version = " + self.python_version)
47 logging.info(" gcc version = " + self.gcc_version)175 logging.info(" gcc version = " + self.gcc_version)
176 logging.info(" GNU Make version = " + self.make_version)
48 logging.info(" gfortran version = " + self.gfortran_version)177 logging.info(" gfortran version = " + self.gfortran_version)
49 logging.info(" ROOT version = " + self.root_version)178 logging.info(" ROOT version = " + self.root_version)
50 logging.info(" FastJet version = " + self.fastjet_version)179 logging.info(" FastJet version = " + self.fastjet_version)
@@ -57,7 +186,6 @@
57 logging.info( " Header '" + key + "' = " + \186 logging.info( " Header '" + key + "' = " + \
58 value )187 value )
59188
60
61 def Export(self,filename):189 def Export(self,filename):
62 try:190 try:
63 file = open(filename,"w")191 file = open(filename,"w")
@@ -65,11 +193,15 @@
65 logging.error("impossible to write the configuration file '" + \193 logging.error("impossible to write the configuration file '" + \
66 filename + "'")194 filename + "'")
67 return False195 return False
196
197 self.useroptions.Export(file)
68 file.write(self.platform+"\n")198 file.write(self.platform+"\n")
199 file.write(self.release+"\n")
69 file.write(self.ma5_version+"\n")200 file.write(self.ma5_version+"\n")
70 file.write(self.ma5_date+"\n")201 file.write(self.ma5_date+"\n")
71 file.write(self.python_version+"\n")202 file.write(self.python_version+"\n")
72 file.write(self.gcc_version+"\n")203 file.write(self.gcc_version+"\n")
204 file.write(self.make_version+"\n")
73 file.write(self.gfortran_version+"\n")205 file.write(self.gfortran_version+"\n")
74 file.write(self.root_version+"\n")206 file.write(self.root_version+"\n")
75 file.write(self.fastjet_version+"\n")207 file.write(self.fastjet_version+"\n")
@@ -92,12 +224,16 @@
92 logging.error("impossible to read the configuration file '" + \224 logging.error("impossible to read the configuration file '" + \
93 filename + "'")225 filename + "'")
94 return False226 return False
227
95 try:228 try:
229 self.useroptions.Import(file)
96 self.platform = file.readline().replace('\n','')230 self.platform = file.readline().replace('\n','')
231 self.release = file.readline().replace('\n','')
97 self.ma5_version = file.readline().replace('\n','')232 self.ma5_version = file.readline().replace('\n','')
98 self.ma5_date = file.readline().replace('\n','')233 self.ma5_date = file.readline().replace('\n','')
99 self.python_version = file.readline().replace('\n','')234 self.python_version = file.readline().replace('\n','')
100 self.gcc_version = file.readline().replace('\n','')235 self.gcc_version = file.readline().replace('\n','')
236 self.make_version = file.readline().replace('\n','')
101 self.gfortran_version = file.readline().replace('\n','')237 self.gfortran_version = file.readline().replace('\n','')
102 self.root_version = file.readline().replace('\n','')238 self.root_version = file.readline().replace('\n','')
103 self.fastjet_version = file.readline().replace('\n','')239 self.fastjet_version = file.readline().replace('\n','')
@@ -135,8 +271,13 @@
135271
136272
137 def Compare(self, other):273 def Compare(self, other):
274 if not self.useroptions.Compare(other.useroptions):
275 return False
276
138 if self.platform != other.platform:277 if self.platform != other.platform:
139 return False278 return False
279 if self.release != other.release:
280 return False
140 if self.ma5_version != other.ma5_version:281 if self.ma5_version != other.ma5_version:
141 return False282 return False
142 if self.ma5_date != other.ma5_date:283 if self.ma5_date != other.ma5_date:
@@ -145,6 +286,8 @@
145 return False286 return False
146 if self.gcc_version != other.gcc_version:287 if self.gcc_version != other.gcc_version:
147 return False288 return False
289 if self.make_version != other.make_version:
290 return False
148 if self.gfortran_version != other.gfortran_version:291 if self.gfortran_version != other.gfortran_version:
149 return False292 return False
150 if self.root_version != other.root_version:293 if self.root_version != other.root_version:
151294
=== modified file 'madanalysis/core/main.py'
--- madanalysis/core/main.py 2013-10-27 21:36:24 +0000
+++ madanalysis/core/main.py 2014-05-17 19:51:11 +0000
@@ -43,7 +43,7 @@
43import logging43import logging
44import os44import os
45import sys45import sys
4646import platform
47 47
48class Main():48class Main():
4949
@@ -79,6 +79,7 @@
79 self.mg5 = False79 self.mg5 = False
80 self.libZIP = False80 self.libZIP = False
81 self.libDelphes = False81 self.libDelphes = False
82 self.libDelfes = False
82 self.pdflatex = False83 self.pdflatex = False
83 self.latex = False84 self.latex = False
84 self.dvipdf = False85 self.dvipdf = False
@@ -86,9 +87,11 @@
86 self.fortran = False87 self.fortran = False
87 self.observables = ObservableManager(self.mode)88 self.observables = ObservableManager(self.mode)
88 self.mcatnloutils = False89 self.mcatnloutils = False
90 self.expertmode = False
91 self.isMAC = False
92 self.repeatSession = False
89 self.ResetParameters()93 self.ResetParameters()
9094
91
92 def ResetParameters(self):95 def ResetParameters(self):
93 self.merging = MergingConfiguration()96 self.merging = MergingConfiguration()
94 self.fastsim = FastsimConfiguration()97 self.fastsim = FastsimConfiguration()
@@ -128,7 +131,7 @@
128 else:131 else:
129 if self.fastsim.package=="none":132 if self.fastsim.package=="none":
130 samples.append('.lhco')133 samples.append('.lhco')
131 if self.libDelphes:134 if self.libDelphes or self.libDelfes:
132 samples.append('.root')135 samples.append('.root')
133 else:136 else:
134 samples.append('.lhe')137 samples.append('.lhe')
@@ -405,8 +408,22 @@
405 self.configLinux.ma5_version = self.version408 self.configLinux.ma5_version = self.version
406 self.configLinux.ma5_date = self.date409 self.configLinux.ma5_date = self.date
407 self.configLinux.python_version = sys.version.replace('\n','')410 self.configLinux.python_version = sys.version.replace('\n','')
408 self.configLinux.platform = sys.platform411 self.configLinux.platform = platform.system()
409412 self.configLinux.release = platform.release()
413
414 # Is Mac
415 sys.stdout.write("Platform: "+self.configLinux.platform+" "+self.configLinux.release+" ")
416 sys.stdout.flush()
417 if self.configLinux.platform.lower() in ['darwin','mac','macosx']:
418 self.isMAC = True
419 sys.stdout.write('\x1b[32m'+'[MAC/OSX mode]'+'\x1b[0m'+'\n')
420 sys.stdout.flush()
421 else:
422 self.isMAC = False
423 sys.stdout.write('\x1b[32m'+'[Linux mode]'+'\x1b[0m'+'\n')
424 sys.stdout.flush()
425
426
410 if detail:427 if detail:
411 logging.info("General Platform identifier : " + str(self.configLinux.platform))428 logging.info("General Platform identifier : " + str(self.configLinux.platform))
412 import multiprocessing429 import multiprocessing
@@ -426,9 +443,13 @@
426 logging.info("")443 logging.info("")
427444
428 # Initializing the config checker 445 # Initializing the config checker
429 checker = ConfigChecker(self.configLinux,self.ma5dir,self.script)446 checker = ConfigChecker(self.configLinux,self.ma5dir,self.script,self.isMAC)
430 checker.checkTextEditor()447 checker.checkTextEditor()
431448
449 # Reading user options
450 if not checker.ReadUserOptions():
451 return False
452
432 # Mandatory packages453 # Mandatory packages
433 logging.info("Checking mandatory packages:")454 logging.info("Checking mandatory packages:")
434 checker.PrintLibrary("python")455 checker.PrintLibrary("python")
@@ -437,90 +458,239 @@
437 return False458 return False
438 if not checker.checkGPP():459 if not checker.checkGPP():
439 return False460 return False
461 if not checker.checkMake():
462 return False
440 if not checker.checkROOT():463 if not checker.checkROOT():
441 return False464 return False
465 if not checker.checkPyROOT():
466 return False
442467
443 # Optional packages468 # Optional packages
444 logging.info("Checking optional packages:")469 logging.info("Checking optional packages:")
445 if not checker.checkGF():470 self.libGF = checker.checkGF()
446 return False471 self.libZIP = checker.checkZLIB()
447 self.libZIP = checker.checkZLIB()
448 self.libDelphes = checker.checkDelphes()472 self.libDelphes = checker.checkDelphes()
473 self.libDelfes = checker.checkDelfes()
449 self.libFastJet = checker.checkFastJet()474 self.libFastJet = checker.checkFastJet()
450 self.pdflatex = checker.checkPdfLatex()475 self.pdflatex = checker.checkPdfLatex()
451 self.latex = checker.checkLatex()476 self.latex = checker.checkLatex()
452 if self.latex:477 if self.latex:
453 self.dvipdf = checker.checkdvipdf()478 self.dvipdf = checker.checkdvipdf()
454 self.mcatnloutils = checker.checkMCatNLOUtils()479
455480 # Set PATH variable
481 self.configLinux.toPATH=[]
482 self.configLinux.toLDPATH=[]
483 self.configLinux.toLDPATH.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/')
484 self.configLinux.toLDPATH.append(self.configLinux.root_lib_path)
485 if self.libFastJet:
486 self.configLinux.toPATH.append(self.configLinux.fastjet_bin_path)
487 for path in self.configLinux.fastjet_lib_paths:
488 self.configLinux.toLDPATH.append(path)
489 if self.libZIP:
490 self.configLinux.toLDPATH.append(self.configLinux.zlib_lib_path)
491 if self.libDelphes:
492 for path in self.configLinux.delphes_lib_paths:
493 self.configLinux.toLDPATH.append(path)
494 if self.libDelfes:
495 for path in self.configLinux.delfes_lib_paths:
496 self.configLinux.toLDPATH.append(path)
497
498 os.environ['PATH'] = os.environ['PATH'] + \
499 ":" + ':'.join(self.configLinux.toPATH)
456 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \500 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \
457 ":" + self.ma5dir+'/tools/SampleAnalyzer/Lib/'501 ":" + ':'.join(self.configLinux.toLDPATH)
458 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \502 if self.isMAC:
459 ":" + self.ma5dir+'/tools/SampleAnalyzer/Lib/'503 os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \
504 ":" + ':'.join(self.configLinux.toLDPATH)
460505
461 if self.mcatnloutils:
462 os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \
463 ":" + self.ma5dir+'/tools/MCatNLO-utilities/MCatNLO/lib/'
464 os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \
465 ":" + self.ma5dir+'/tools/MCatNLO-utilities/MCatNLO/lib/'
466
467 return True 506 return True
468 507
508 def PrintOK(self):
509 sys.stdout.write('\x1b[32m'+'[OK]'+'\x1b[0m'+'\n')
510 sys.stdout.flush()
511
469 def BuildLibrary(self,forced=False):512 def BuildLibrary(self,forced=False):
470 builder = LibraryBuilder(self.configLinux,self.ma5dir)513 builder = LibraryBuilder(self.configLinux,self.ma5dir,self.libZIP,self.libDelphes,self.libDelfes,self.libFastJet)
514
471 UpdateNeed=False515 UpdateNeed=False
472 516 FirstUse, Missing = builder.checkMA5()
473 FirstUse = builder.checkMA5()517 if not FirstUse and not Missing:
474 if not FirstUse:
475 UpdateNeed = not builder.compare()518 UpdateNeed = not builder.compare()
476519
477 rebuild = forced or FirstUse or UpdateNeed520 rebuild = forced or FirstUse or UpdateNeed or Missing
478 if not rebuild:521
522 if not rebuild:
523 if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so'):
524 FirstUse=True
525 rebuild = forced or FirstUse or UpdateNeed or Missing
526
527 if not rebuild:
528 logging.info(' => MadAnalysis libraries found.')
529
530 # Test the program
531 if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest'):
532 FirstUse=True
533
534 precompiler = LibraryWriter(self.ma5dir,'lib',self.libZIP,self.libFastJet,self.forced,self.fortran,self.libDelphes,self.libDelfes,self)
535 if not precompiler.Run('SampleAnalyzerTest',[],self.ma5dir+'/tools/SampleAnalyzer/Test',silent=True):
536 UpdateNeed=True
537
538 if not precompiler.CheckRun(self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest.log',silent=True):
539 UpdateNeed=True
540 rebuild = forced or FirstUse or UpdateNeed or Missing
541
542 if not rebuild:
543 logging.info(' => MadAnalysis test program works.')
479 return True544 return True
480545
481 # Compile library546 # Compile library
482 if FirstUse:547 if FirstUse:
483 logging.info(" => First use of MadAnalysis (or the library is missing).")548 logging.info(" => First use of MadAnalysis (or the library is missing).")
549 elif Missing:
550 logging.info(" => Libraries are missing or system configuration has changed. Need to rebuild the library.")
484 elif UpdateNeed:551 elif UpdateNeed:
485 logging.info(" => System configuration has changed since the last use. Need to rebuild the library.")552 logging.info(" => System configuration has changed since the last use. Need to rebuild the library.")
486 elif forced:553 elif forced:
487 logging.info(" => The user forces to rebuild the library.")554 logging.info(" => The user forces to rebuild the library.")
488555
489 # Initializing the JobWriter556 # Initializing the JobWriter
490 compiler = LibraryWriter(self.ma5dir,'lib',self.libZIP,self.libFastJet,self.forced,self.fortran,self.libDelphes)557 compiler = LibraryWriter(self.ma5dir,'lib',self.libZIP,self.libFastJet,self.forced,self.fortran,self.libDelphes,self.libDelfes,self)
491 558
492 # Dumping architecture559 # Dumping architecture
493 if not self.configLinux.Export(self.ma5dir+'/tools/architecture.ma5'):560 if not self.configLinux.Export(self.ma5dir+'/tools/architecture.ma5'):
494 sys.exit()561 sys.exit()
495562
496 logging.info(" Creating a 'Makefile'...")563 # Library to compiles
497 if not compiler.WriteMakefile('shared'):564 libraries = []
498 logging.error("library building aborted.")565 if self.libFastJet:
499 sys.exit()566 libraries.append(['FastJet', 'interface to FastJet', 'fastjet', self.ma5dir+'/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces'])
500567 if self.libZIP:
501 if not compiler.MrProper():568 libraries.append(['zlib', 'interface to zlib', 'zlib', self.ma5dir+'/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces'])
502 logging.error("impossible to remove temporary files created during the building.")569 if self.libDelphes:
503 sys.exit()570 libraries.append(['Delphes', 'interface to Delphes', 'delphes', self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces'])
504571 if self.libDelfes:
505 logging.info(" Compiling the MadAnalysis library...")572 libraries.append(['Delfes', 'interface to Delfes', 'delfes', self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces'])
506 if not compiler.Compile():573 libraries.append(['SampleAnalyzer', 'general SampleAnalyzer component', 'SampleAnalyzer', self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so',self.ma5dir+'/tools/SampleAnalyzer'])
507 logging.error("library building aborted.")574
508 sys.exit()575 # Writing the Makefiles
509576 logging.info("")
510 logging.info(" Linking the MadAnalysis library...")577 logging.info(" **********************************************************")
511 if not compiler.Link():578 logging.info(" Building SampleAnalyzer libraries ")
512 logging.error("library building aborted.")579 logging.info(" **********************************************************")
513 sys.exit()580
514581
515 logging.info(" Checking the MadAnalysis library...")582 # Getting number of cores
516583 ncores = compiler.get_ncores2()
517 if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.a'):584
518 logging.error("the library 'libSampleAnalyzer.a' is not produced.")585 # Compiling the libraries
519 sys.exit()586 for ind in range(0,len(libraries)):
520 587
521 if not compiler.Clean():588 logging.info(" **********************************************************")
522 logging.error("impossible to remove temporary files created during the building.")589 logging.info(" Library "+str(ind+1)+"/"+str(len(libraries))+" - "+libraries[ind][1])
523 sys.exit()590
591 # Writing a Makefile
592 logging.info(" - Writing a Makefile ...")
593 if libraries[ind][0]=='SampleAnalyzer':
594 if not compiler.WriteMakefile():
595 logging.error("library building aborted.")
596 sys.exit()
597 else:
598 if not compiler.WriteMakefileForInterfaces(libraries[ind][2]):
599 logging.error("library building aborted.")
600 sys.exit()
601
602 # Cleaning the project
603 logging.info(" - Cleaning the project before building the library ...")
604 if not compiler.MrProper(libraries[ind][2],libraries[ind][4]):
605 logging.error("library building aborted.")
606 sys.exit()
607
608 # Compiling
609 logging.info(" - Compiling the source files ...")
610 if not compiler.Compile(ncores,libraries[ind][2],libraries[ind][4]):
611 logging.error("library building aborted.")
612 sys.exit()
613
614 # Linking
615 logging.info(" - Linking the library ...")
616 if not compiler.Link(libraries[ind][2],libraries[ind][4]):
617 logging.error("library building aborted.")
618 sys.exit()
619
620 # Checking
621 logging.info(" - Checking that the library is properly built ...")
622 if not os.path.isfile(libraries[ind][3]):
623 logging.error("the library '"+libraries[ind][3]+"' is not produced.")
624 sys.exit()
625
626 # Cleaning the project
627 logging.info(" - Cleaning the project after building the library ...")
628 if not compiler.Clean(libraries[ind][2],libraries[ind][4]):
629 logging.error("library building aborted.")
630 sys.exit()
631
632 # Print Ok
633 sys.stdout.write(" => Status: ")
634 self.PrintOK()
635
636 logging.info(" **********************************************************")
637 logging.info(" Test program ")
638
639 # Writing a Makefile
640 logging.info(" - Writing a Makefile ...")
641 if not compiler.WriteMakefileForTest():
642 logging.error("test program building aborted.")
643 sys.exit()
644
645 # Cleaning the project
646 logging.info(" - Cleaning the project before building the program ...")
647 if not compiler.MrProper('test',self.ma5dir+'/tools/SampleAnalyzer/Test'):
648 logging.error("test program building aborted.")
649 sys.exit()
650
651 # Compiling
652 logging.info(" - Compiling the source files ...")
653 if not compiler.Compile(ncores,'test',self.ma5dir+'/tools/SampleAnalyzer/Test'):
654 logging.error("test program building aborted.")
655 sys.exit()
656
657 # Linking
658 logging.info(" - Linking the program ...")
659 if not compiler.Link('test',self.ma5dir+'/tools/SampleAnalyzer/Test'):
660 logging.error("test program building aborted.")
661 sys.exit()
662
663 # Checking
664 logging.info(" - Checking that the program is properly built ...")
665 filename=self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest'
666 if not os.path.isfile(filename):
667 logging.error("the test program '"+filename+"' is not produced.")
668 sys.exit()
669
670 # Cleaning the project
671 logging.info(" - Cleaning the project after building the program ...")
672 if not compiler.Clean('test',self.ma5dir+'/tools/SampleAnalyzer/Test'):
673 logging.error("test program building aborted.")
674 sys.exit()
675
676 # Running the program test
677 logging.info(" - Running the test program ...")
678 if not compiler.Run('SampleAnalyzerTest',[],self.ma5dir+'/tools/SampleAnalyzer/Test'):
679 logging.error("the test is failed.")
680 sys.exit()
681
682 # Checking the program output
683 logging.info(" - Checking the program output...")
684 if not compiler.CheckRun(self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest.log'):
685 logging.error("the test is failed.")
686 sys.exit()
687
688 # Print Ok
689 sys.stdout.write(" => Status: ")
690 self.PrintOK()
691
692
693 logging.info("")
524694
525 return True 695 return True
526 696
527697
=== modified file 'madanalysis/enumeration/observable_type.py'
--- madanalysis/enumeration/observable_type.py 2013-05-17 06:19:22 +0000
+++ madanalysis/enumeration/observable_type.py 2014-05-17 19:51:11 +0000
@@ -30,10 +30,10 @@
30 # name : accept_particles 30 # name : accept_particles
31 values = { 'UNKNOWN' : [False,'','','','',0,0,0,False,False],\31 values = { 'UNKNOWN' : [False,'','','','',0,0,0,False,False],\
32 'SQRTS' : [False,'PHYSICS->SqrtS(event.mc())','PHYSICS->SqrtS(event.mc())','','GeV',100,0.,1000., True, False],\32 'SQRTS' : [False,'PHYSICS->SqrtS(event.mc())','PHYSICS->SqrtS(event.mc())','','GeV',100,0.,1000., True, False],\
33 'TET' : [False,'PHYSICS->EventTET(event.mc())','PHYSICS->EventTET(event.mc())','PHYSICS->EventTET(event.rec())','GeV',100,0.,1000., True,False],\33 'TET' : [False,'PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.rec())','GeV',100,0.,1000., True,False],\
34 'MET' : [False,'PHYSICS->EventMET(event.mc())','PHYSICS->EventMET(event.mc())','PHYSICS->EventMET(event.rec())','GeV',100,0.,1000., True,False],\34 'MET' : [False,'PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.rec())','GeV',100,0.,1000., True,False],\
35 'THT' : [False,'PHYSICS->EventTHT(event.mc())','PHYSICS->EventTHT(event.mc())','PHYSICS->EventTHT(event.rec())','GeV',100,0.,1000., True,False],\35 'THT' : [False,'PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.rec())','GeV',100,0.,1000., True,False],\
36 'MHT' : [False,'PHYSICS->EventMHT(event.mc())','PHYSICS->EventMHT(event.mc())','PHYSICS->EventMHT(event.rec())','GeV',100,0.,1000.,True,False],\36 'MHT' : [False,'PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.rec())','GeV',100,0.,1000.,True,False],\
37 'NPID': [False,'NPID','NPID','NPID','',100,0.,100.,False,False],\37 'NPID': [False,'NPID','NPID','NPID','',100,0.,100.,False,False],\
38 'NAPID': [False,'NAPID','NAPID','NAPID','',100,0.,100.,False,False],\38 'NAPID': [False,'NAPID','NAPID','NAPID','',100,0.,100.,False,False],\
39 'E' : [True,'e()','e()','e()','GeV',100,0.,1000.,True,True],\39 'E' : [True,'e()','e()','e()','GeV',100,0.,1000.,True,True],\
4040
=== added file 'madanalysis/input/installation_options.dat'
--- madanalysis/input/installation_options.dat 1970-01-01 00:00:00 +0000
+++ madanalysis/input/installation_options.dat 2014-05-17 19:51:11 +0000
@@ -0,0 +1,35 @@
1# WARNING MA5 SHOULD DETECT AUTOMATICALLY YOUR CONFIGURATION
2# IF THIS AUTOMATED MODE FAILS, YOU CAN FORCE SOME
3# OPTIONS THROUGH THIS FILE
4
5# -----ROOT-----
6# root_includes = /home/toto/root/include
7# root_libs = /home/toto/root/lib
8
9# -----DELPHES-----
10# delphes_veto = 0 # 0=No, 1=Yes
11# delphes_includes = /home/toto/delphes/include
12# delphes_libs = /home/toto/delphes/lib
13
14# -----DELFES-----
15# delfes_veto = 0 # 0=No, 1=Yes
16# delfes_includes = /home/toto/delfes/include
17# delfes_libs = /home/toto/delfes/lib
18
19# -----ZLIB-----
20# zlib_veto = 0 # 0=No, 1=Yes
21# zlib_includes = /home/toto/zlib/include
22# zlib_libs = /home/toto/zlib/lib
23
24# -----FASTJET-----
25# fastjet_veto = 0 # 0=No, 1=Yes
26# fastjet_bin_path = /home/toto/fastjet/include
27
28# -----PDFLATEX-----
29# pdflatex_veto = 0 # 0=No, 1=Yes
30
31# -----LATEX-----
32# latex_veto = 0 # 0=No, 1=Yes
33
34# -----DVIPDF-----
35# dvipdf_veto = 0 # 0=No, 1=Yes
036
=== modified file 'madanalysis/input/particles_name_default.txt'
--- madanalysis/input/particles_name_default.txt 2013-07-12 13:09:17 +0000
+++ madanalysis/input/particles_name_default.txt 2014-05-17 19:51:11 +0000
@@ -50,9 +50,8 @@
50 23 z50 23 z
51 24 w+51 24 w+
52 -24 w-52 -24 w-
53# Note that we can't give a name to 25 here,53# The Higgs boson is called h1
54# since it is different in SM and MSSM.54 25 h1
55# MSSM Higgs
56 35 h255 35 h2
57 36 h356 36 h3
58 37 h+57 37 h+
5958
=== modified file 'madanalysis/interpreter/cmd_base.py'
--- madanalysis/interpreter/cmd_base.py 2013-05-17 06:19:22 +0000
+++ madanalysis/interpreter/cmd_base.py 2014-05-17 19:51:11 +0000
@@ -29,7 +29,7 @@
29class CmdBase():29class CmdBase():
30 """Command CMDBase"""30 """Command CMDBase"""
3131
32 reserved_words=["exit","quit","eof","history","shell","from","as","all","or","and"]32 reserved_words=["exit","quit","eof","history","shell","from","as","all","or","and","main"]
3333
34 def __init__(self,main,cmd_name):34 def __init__(self,main,cmd_name):
35 self.reserved_words.append(cmd_name)35 self.reserved_words.append(cmd_name)
3636
=== modified file 'madanalysis/interpreter/cmd_install.py'
--- madanalysis/interpreter/cmd_install.py 2013-10-27 21:05:18 +0000
+++ madanalysis/interpreter/cmd_install.py 2014-05-17 19:51:11 +0000
@@ -23,6 +23,7 @@
2323
2424
25from madanalysis.interpreter.cmd_base import CmdBase25from madanalysis.interpreter.cmd_base import CmdBase
26from madanalysis.IOinterface.delphes_migration import DelphesMigration
26import logging27import logging
27import os28import os
28import sys29import sys
@@ -86,6 +87,8 @@
86 return self.install_zlib()87 return self.install_zlib()
87 elif args[0]=='delphes':88 elif args[0]=='delphes':
88 return self.install_delphes()89 return self.install_delphes()
90 elif args[0]=='delfes':
91 return self.install_delfes()
89 elif args[0]=='fastjet':92 elif args[0]=='fastjet':
90 return self.install_fastjet()93 return self.install_fastjet()
91 elif args[0]=='MCatNLO-for-ma5':94 elif args[0]=='MCatNLO-for-ma5':
@@ -99,7 +102,7 @@
99 def help(self):102 def help(self):
100 logging.info(" Syntax: install <component>")103 logging.info(" Syntax: install <component>")
101 logging.info(" Download and install a MadAnalysis component from the official site.")104 logging.info(" Download and install a MadAnalysis component from the official site.")
102 logging.info(" List of available components : samples zlib fastjet MCatNLO-for-ma5 delphes")105 logging.info(" List of available components : samples zlib fastjet MCatNLO-for-ma5 delphes delfes")
103106
104107
105 def get_ncores(self):108 def get_ncores(self):
@@ -219,8 +222,7 @@
219 # End222 # End
220 logging.info("Installation complete.")223 logging.info("Installation complete.")
221224
222225 return 'restart'
223 return True
224226
225227
226 def install_delphes(self):228 def install_delphes(self):
@@ -244,9 +246,11 @@
244 installdir = self.main.ma5dir + '/tools/delphes/'246 installdir = self.main.ma5dir + '/tools/delphes/'
245247
246 # List of files248 # List of files
247 files = { "delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.10.tar.gz" }249 #files = { "delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.12.tar.gz" }
250 files = { "delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.1.1.tar.gz"}
248 251
249 # Launching wget252 # Launching wget
253 logging.info("Configuring the package ...")
250 if not self.wget(files,'delphes',installdir):254 if not self.wget(files,'delphes',installdir):
251 return False255 return False
252256
@@ -287,8 +291,85 @@
287 # End291 # End
288 logging.info("Installation complete.")292 logging.info("Installation complete.")
289293
290294 return 'restart'
291 return True295
296
297 def install_delfes(self):
298
299 # Asking for number of cores
300 ncores = self.get_ncores()
301
302 # Checking connection with MA5 web site
303 if not self.check_ma5site():
304 return False
305
306 # Creating tools folder
307 if not self.create_tools_folder():
308 return False
309
310 # Creating package folder
311 if not self.create_package_folder('delfes'):
312 return False
313
314 # Directory to install
315 installdir = self.main.ma5dir + '/tools/delfes/'
316
317 # List of files
318# files = { "delfes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.12.tar.gz" }
319 files = { "delfes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.1.1.tar.gz"}
320
321 # Launching wget
322 if not self.wget(files,'delfes',installdir):
323 return False
324
325 # Detarring package
326 packagedir = self.untar(installdir,'delfes.tar.gz','delfes')
327 if packagedir == "":
328 return False
329
330 # Changing the name of the directory
331 os.system("mv "+packagedir+"/* "+self.main.ma5dir+"/tools/delfes/")
332 packagedir = self.main.ma5dir+"/tools/delfes/"
333
334 # Migration
335 logging.info("Applying the MadAnalysis 5 patch to the package ...")
336 migrator = DelphesMigration(self.main)
337 migrator.Migrate()
338
339 # Configuring
340 logging.info("Configuring the package ...")
341 os.system("cd "+packagedir+" ; ./configure > "+self.main.ma5dir+"/tools/delfes/"+"configuration.log 2>&1")
342
343 # Compiling
344 logging.info("Compiling the package ...")
345 os.system("cd "+packagedir+" ; make -j"+str(ncores)+" > "+self.main.ma5dir+"/tools/delfes/"+"compilation.log 2>&1")
346
347 # Final check
348 logging.info("Checking installation ...")
349 if (not os.path.isdir(self.main.ma5dir+"/tools/delfes/modules")):
350 logging.error('package modules are missing.')
351 self.display_log('delfes')
352 return False
353
354 if not os.path.isfile(self.main.ma5dir+'/tools/delfes/modules/ParticlePropagator.h'):
355 logging.error("header labeled 'modules/ParticlePropagator.h' is missing.")
356 self.display_log('delfes')
357 return False
358
359 if not os.path.isfile(self.main.ma5dir+'/tools/delfes/libDelphes.so'):
360 logging.error("library labeled 'libdelphes.so' is missing.")
361 self.display_log('delfes')
362 return False
363
364 if not os.path.isfile(self.main.ma5dir+'/tools/delfes/DelphesSTDHEP'):
365 logging.error("library labeled 'DelphesSTDHEP' is missing.")
366 self.display_log('delfes')
367 return False
368
369 # End
370 logging.info("Installation complete.")
371
372 return 'restart'
292373
293374
294 def install_mcatnlo(self):375 def install_mcatnlo(self):
@@ -423,7 +504,7 @@
423 for file,url in files.items():504 for file,url in files.items():
424 ind+=1505 ind+=1
425 result="OK"506 result="OK"
426 logging.info(' * ' + str(ind)+"/"+str(len(files.keys()))+" Downloading the file '"+file+"' ...")507 logging.info(' * ' + str(ind)+"/"+str(len(files.keys()))+" Downloading the file "+url+" ...")
427508
428 try:509 try:
429 urllib.urlretrieve(url,installdir+'/'+file,CmdInstall.reporthook)510 urllib.urlretrieve(url,installdir+'/'+file,CmdInstall.reporthook)
@@ -473,7 +554,7 @@
473 return False554 return False
474555
475 # List of files556 # List of files
476 files = { "fastjet.tar.gz" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/WikiStart/fastjet-3.0.3.tar.gz" }557 files = { "fastjet.tar.gz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/WikiStart/fastjet-3.0.6.tar.gz" }
477558
478 # Launching wget559 # Launching wget
479 if not self.wget(files,'fastjet',installdir):560 if not self.wget(files,'fastjet',installdir):
@@ -521,11 +602,10 @@
521 self.display_log('fastjet')602 self.display_log('fastjet')
522 return False603 return False
523 604
524
525 # End605 # End
526 logging.info("Installation complete.")606 logging.info("Installation complete.")
527607
528 return True608 return 'restart'
529609
530610
531 def install_samples(self):611 def install_samples(self):
@@ -593,7 +673,7 @@
593 if nargs>2:673 if nargs>2:
594 return []674 return []
595 else:675 else:
596 output = ["samples","zlib","fastjet", "MCatNLO-for-ma5", "delphes" ]676 output = ["samples","zlib","fastjet", "MCatNLO-for-ma5", "delphes", "delfes" ]
597 return self.finalize_complete(text,output)677 return self.finalize_complete(text,output)
598 678
599679
600680
=== modified file 'madanalysis/interpreter/cmd_plot.py'
--- madanalysis/interpreter/cmd_plot.py 2013-05-17 06:19:22 +0000
+++ madanalysis/interpreter/cmd_plot.py 2014-05-17 19:51:11 +0000
@@ -54,7 +54,6 @@
5454
55 # Getting reference to observable55 # Getting reference to observable
56 obsRef=self.main.observables.get(obsName)56 obsRef=self.main.observables.get(obsName)
57
58 foundArguments = False57 foundArguments = False
59 foundOptions = False58 foundOptions = False
60 foundBinning = False 59 foundBinning = False
@@ -80,7 +79,7 @@
80 Nbracket2-=179 Nbracket2-=1
81 if i==(len(args)-1):80 if i==(len(args)-1):
82 foundOptions=True81 foundOptions=True
83 82
84 if Nbracket1!=0:83 if Nbracket1!=0:
85 logging.error("number of opening-bracket '(' and number of " +\84 logging.error("number of opening-bracket '(' and number of " +\
86 "closing-braket ')' does not match.")85 "closing-braket ')' does not match.")
@@ -168,6 +167,11 @@
168 arguments=self.extract_arguments(args[2:endArguments],obsName,obsRef)167 arguments=self.extract_arguments(args[2:endArguments],obsName,obsRef)
169 if arguments==None:168 if arguments==None:
170 return169 return
170 elif len(obsRef.args) !=0: # checks whether arguments should have been provided
171 logging.error("the observable '"+obsName+"' requires "+
172 str(len(obsRef.args))+" arguments whereas no arguments have been specified.")
173 return
174
171175
172 # Creating histo176 # Creating histo
173 histo = Histogram(obsRef,arguments,nbins,xmin,xmax)177 histo = Histogram(obsRef,arguments,nbins,xmin,xmax)
174178
=== modified file 'madanalysis/interpreter/cmd_set.py'
--- madanalysis/interpreter/cmd_set.py 2013-09-26 12:30:50 +0000
+++ madanalysis/interpreter/cmd_set.py 2014-05-17 19:51:11 +0000
@@ -102,7 +102,7 @@
102 elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='merging':102 elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='merging':
103 self.main.merging.user_SetParameter(objs[2],args[2],self.main.mode,self.main.libFastJet)103 self.main.merging.user_SetParameter(objs[2],args[2],self.main.mode,self.main.libFastJet)
104 elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='fastsim':104 elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='fastsim':
105 self.main.fastsim.user_SetParameter(objs[2],args[2],self.main.datasets,self.main.mode,self.main.libFastJet,self.main.libDelphes) 105 self.main.fastsim.user_SetParameter(objs[2],args[2],self.main.datasets,self.main.mode,self.main.libFastJet,self.main.libDelphes,self.main.libDelfes)
106 elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='shower':106 elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='shower':
107 self.main.shower.user_SetParameter(objs[2],args[2],self.main.mode,self.main.mcatnloutils)107 self.main.shower.user_SetParameter(objs[2],args[2],self.main.mode,self.main.mcatnloutils)
108 else:108 else:
109109
=== modified file 'madanalysis/interpreter/cmd_submit.py'
--- madanalysis/interpreter/cmd_submit.py 2013-10-27 21:36:24 +0000
+++ madanalysis/interpreter/cmd_submit.py 2014-05-17 19:51:11 +0000
@@ -335,16 +335,10 @@
335 if answer=="no" or answer=="n":335 if answer=="no" or answer=="n":
336 return336 return
337 else:337 else:
338 if self.main.fastsim.delphes.pileup=="":338 if self.main.fastsim.package=="delphes":
339 if self.main.fastsim.delphes.detector=='cms':339 cardname = self.main.fastsim.delphes.card
340 cardname = 'delphes_card_CMS.tcl'340 elif self.main.fastsim.package=="delfes":
341 elif self.main.fastsim.delphes.detector=='atlas':341 cardname = self.main.fastsim.delfes.card
342 cardname ='delphes_card_ATLAS.tcl'
343 else:
344 if self.main.fastsim.delphes.detector=='cms':
345 cardname = 'delphes_card_CMS_PileUp.tcl'
346 elif self.main.fastsim.delphes.detector=='atlas':
347 cardname ='delphes_card_ATLAS_PileUp.tcl'
348 os.system(self.main.configLinux.editor+" "+dirname+"/Input/"+cardname)342 os.system(self.main.configLinux.editor+" "+dirname+"/Input/"+cardname)
349343
350344
@@ -408,9 +402,15 @@
408 return False402 return False
409403
410 #edit the delphes cards404 #edit the delphes cards
411 if self.main.fastsim.package=="delphes":405 if self.main.fastsim.package in ["delphes","delfes"]:
412 self.editDelphesCard(dirname)406 self.editDelphesCard(dirname)
413407
408 if self.resubmit:
409 logging.info(" Cleaning 'SampleAnalyzer'...")
410 if not jobber.MrproperJob():
411 logging.error("job submission aborted.")
412 return False
413
414 logging.info(" Compiling 'SampleAnalyzer'...")414 logging.info(" Compiling 'SampleAnalyzer'...")
415 if not jobber.CompileJob():415 if not jobber.CompileJob():
416 logging.error("job submission aborted.")416 logging.error("job submission aborted.")
417417
=== modified file 'madanalysis/interpreter/interpreter.py'
--- madanalysis/interpreter/interpreter.py 2013-05-31 21:57:38 +0000
+++ madanalysis/interpreter/interpreter.py 2014-05-17 19:51:11 +0000
@@ -26,6 +26,7 @@
26 Uses the cmd package for command interpretation and tab completion.26 Uses the cmd package for command interpretation and tab completion.
27"""27"""
2828
29import logging
29import readline30import readline
30import os31import os
3132
@@ -174,6 +175,38 @@
174 def complete_import(self,text,line,begidx,endidx):175 def complete_import(self,text,line,begidx,endidx):
175 return self.cmd_import.complete(text,line,begidx,endidx)176 return self.cmd_import.complete(text,line,begidx,endidx)
176177
178 # Restart
179 def do_restart(self, line):
180 """ sending a signal allowing to restart the interpreter """
181 if self.main.script:
182 logging.warning("'restart' command is not allowed in script mode.")
183 else:
184 YES=False
185 # Asking the safety question
186 if not Main.forced:
187 logging.warning("Are you sure to restart the MadAnalysis 5 session? (Y/N)")
188 allowed_answers=['n','no','y','yes']
189 answer=""
190 while answer not in allowed_answers:
191 answer=raw_input("Answer: ")
192 answer=answer.lower()
193 if answer=="no" or answer=="n":
194 YES=False
195 break
196 elif answer=='yes' or answer=='y':
197 YES=True
198 break
199 if YES:
200 self.main.repeatSession=True
201 return True
202 else:
203 pass
204
205 def help_restart(self):
206 logging.info(" Syntax: restart ")
207 logging.info(" Quit the current MadAnalysis sessiona and open a new one.")
208 logging.info(" All the information will be discarded.")
209
177 def do_remove(self,line):210 def do_remove(self,line):
178 self.cmd_remove.do(self.split_arg(line))211 self.cmd_remove.do(self.split_arg(line))
179212
@@ -193,7 +226,11 @@
193 return self.cmd_swap.complete(text,line,begidx,endidx)226 return self.cmd_swap.complete(text,line,begidx,endidx)
194227
195 def do_install(self,line):228 def do_install(self,line):
196 self.cmd_install.do(self.split_arg(line))229 result = self.cmd_install.do(self.split_arg(line))
230 if result=='restart':
231 logging.info(" ")
232 logging.info("MadAnalysis 5 must be restarted for taking into account the present installation.")
233 return self.do_restart('restart')
197234
198 def help_install(self):235 def help_install(self):
199 self.cmd_install.help()236 self.cmd_install.help()
200237
=== modified file 'madanalysis/interpreter/interpreter_base.py'
--- madanalysis/interpreter/interpreter_base.py 2013-05-24 13:05:09 +0000
+++ madanalysis/interpreter/interpreter_base.py 2014-05-17 19:51:11 +0000
@@ -190,7 +190,7 @@
190 """ exit the mainloop() """190 """ exit the mainloop() """
191 logging.info("")191 logging.info("")
192 return True192 return True
193 193
194 # Aliases194 # Aliases
195 do_EOF = do_quit195 do_EOF = do_quit
196 do_exit = do_quit196 do_exit = do_quit
197197
=== modified file 'madanalysis/job/job_candidate_cut.py'
--- madanalysis/job/job_candidate_cut.py 2013-05-17 06:19:22 +0000
+++ madanalysis/job/job_candidate_cut.py 2014-05-17 19:51:11 +0000
@@ -212,7 +212,7 @@
212 # Bracket for begin 212 # Bracket for begin
213 file.write(' {\n')213 file.write(' {\n')
214214
215 file.write(' '+container2+'=PHYSICS->rankFilter('+\215 file.write(' '+container2+'=SORTER->rankFilter('+\
216 newcontainer2+','+str(other_part[0].PTrank)+','+\216 newcontainer2+','+str(other_part[0].PTrank)+','+\
217 'PTordering'+');\n\n')217 'PTordering'+');\n\n')
218 218
@@ -305,8 +305,14 @@
305 # Case of one particle/multiparticle305 # Case of one particle/multiparticle
306 if len(combi1)==1:306 if len(combi1)==1:
307 file.write(' if (')307 file.write(' if (')
308 if main.mode == MA5RunningType.PARTON:
309 TheObs=obs.code_parton[:-2]
310 elif main.mode == MA5RunningType.HADRON:
311 TheObs=obs.code_hadron[:-2]
312 else:
313 TheObs=obs.code_reco[:-2]
308 file.write(containers1[0]+'[a]->' +\314 file.write(containers1[0]+'[a]->' +\
309 'dr('+container+'[muf])' +\315 TheObs+'('+container+'[muf])' +\
310 OperatorType.convert2cpp(condition.operator) +\316 OperatorType.convert2cpp(condition.operator) +\
311 str(condition.threshold) +\317 str(condition.threshold) +\
312 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')318 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')
@@ -338,8 +344,14 @@
338344
339 # Result 345 # Result
340 file.write(' if (q1.')346 file.write(' if (q1.')
341 if obs.name in ['DELTAR','vDELTAR']:347 if obs.name in ['DELTAR','vDELTAR','DPHI_0_PI','DPHI_0_2PI']:
342 file.write('dr('+container+'[muf])'+ OperatorType.convert2cpp(condition.operator) + \348 if main.mode == MA5RunningType.PARTON:
349 TheObs=obs.code_parton[:-2]
350 elif main.mode == MA5RunningType.HADRON:
351 TheObs=obs.code_hadron[:-2]
352 else:
353 TheObs=obs.code_reco[:-2]
354 file.write(TheObs+'('+container+'[muf])'+ OperatorType.convert2cpp(condition.operator) + \
343 str(condition.threshold) + \355 str(condition.threshold) + \
344 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')356 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')
345 else:357 else:
346358
=== modified file 'madanalysis/job/job_event_cut.py'
--- madanalysis/job/job_event_cut.py 2013-05-17 06:19:22 +0000
+++ madanalysis/job/job_event_cut.py 2014-05-17 19:51:11 +0000
@@ -243,9 +243,15 @@
243243
244 # Case of one particle/multiparticle244 # Case of one particle/multiparticle
245 if len(combi1)==1 and len(combi2)==1:245 if len(combi1)==1 and len(combi2)==1:
246 if main.mode == MA5RunningType.PARTON:
247 TheObs=obs.code_parton[:-2]
248 elif main.mode == MA5RunningType.HADRON:
249 TheObs=obs.code_hadron[:-2]
250 else:
251 TheObs=obs.code_reco[:-2]
246 file.write(' if (')252 file.write(' if (')
247 file.write(containers1[0]+'['+iterator1+'[0]]->' +\253 file.write(containers1[0]+'['+iterator1+'[0]]->' +\
248 'dr('+containers2[0]+'['+iterator2+'[0]])' +\254 TheObs+'('+containers2[0]+'['+iterator2+'[0]])' +\
249 OperatorType.convert2cpp(condition.operator) +\255 OperatorType.convert2cpp(condition.operator) +\
250 str(condition.threshold) +\256 str(condition.threshold) +\
251 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')257 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')
@@ -279,7 +285,13 @@
279 'momentum();\n')285 'momentum();\n')
280286
281 # Result 287 # Result
282 file.write(' if (q1.dr(q2)'+\288 if main.mode == MA5RunningType.PARTON:
289 TheObs=obs.code_parton[:-2]
290 elif main.mode == MA5RunningType.HADRON:
291 TheObs=obs.code_hadron[:-2]
292 else:
293 TheObs=obs.code_reco[:-2]
294 file.write(' if (q1.'+TheObs+'(q2)'+\
283 ''+ OperatorType.convert2cpp(condition.operator) + \295 ''+ OperatorType.convert2cpp(condition.operator) + \
284 str(condition.threshold) + \296 str(condition.threshold) + \
285 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')297 ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n')
286298
=== modified file 'madanalysis/job/job_execute.py'
--- madanalysis/job/job_execute.py 2013-10-03 16:02:40 +0000
+++ madanalysis/job/job_execute.py 2014-05-17 19:51:11 +0000
@@ -69,7 +69,7 @@
6969
70 file.write(' // Sorting particle collection according to '+rank+'\n')70 file.write(' // Sorting particle collection according to '+rank+'\n')
71 file.write(' // for getting '+str(part.PTrank)+'th particle\n')71 file.write(' // for getting '+str(part.PTrank)+'th particle\n')
72 file.write(' '+container+'=PHYSICS->rankFilter('+\72 file.write(' '+container+'=SORTER->rankFilter('+\
73 newcontainer+','+str(part.PTrank)+','+rank+');\n\n')73 newcontainer+','+str(part.PTrank)+','+rank+');\n\n')
7474
7575
@@ -206,13 +206,13 @@
206 # Put isolated negative muon206 # Put isolated negative muon
207 if part.particle.Find(130):207 if part.particle.Find(130):
208 file.write(' if ( (event.rec()->muons()[i].charge()<0) &&'+\208 file.write(' if ( (event.rec()->muons()[i].charge()<0) &&'+\
209 ' PHYSICS->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\209 ' PHYSICS->Id->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\
210 container+'.push_back(&(event.rec()->muons()[i]));\n')210 container+'.push_back(&(event.rec()->muons()[i]));\n')
211211
212 # Put isolated positive muon212 # Put isolated positive muon
213 if part.particle.Find(-130):213 if part.particle.Find(-130):
214 file.write(' if ( (event.rec()->muons()[i].charge()>0) &&'+\214 file.write(' if ( (event.rec()->muons()[i].charge()>0) &&'+\
215 ' PHYSICS->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\215 ' PHYSICS->Id->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\
216 container+'.push_back(&(event.rec()->muons()[i]));\n')216 container+'.push_back(&(event.rec()->muons()[i]));\n')
217217
218218
219219
=== modified file 'madanalysis/job/job_header.py'
--- madanalysis/job/job_header.py 2013-05-17 06:19:22 +0000
+++ madanalysis/job/job_header.py 2014-05-17 19:51:11 +0000
@@ -139,11 +139,11 @@
139139
140 # FinalSate140 # FinalSate
141 if status=="finalstate":141 if status=="finalstate":
142 file.write(" if ( !PHYSICS->IsFinalState(part) ) return false;\n")142 file.write(" if ( !PHYSICS->Id->IsFinalState(part) ) return false;\n")
143 elif status=="initialstate":143 elif status=="initialstate":
144 file.write(" if ( !PHYSICS->IsInitialState(part) ) return false;\n")144 file.write(" if ( !PHYSICS->Id->IsInitialState(part) ) return false;\n")
145 elif status=="interstate":145 elif status=="interstate":
146 file.write(" if ( !PHYSICS->IsInterState(part) ) return false;\n")146 file.write(" if ( !PHYSICS->Id->IsInterState(part) ) return false;\n")
147147
148 # Id148 # Id
149 file.write(' if ( ')149 file.write(' if ( ')
150150
=== modified file 'madanalysis/job/job_initialize.py'
--- madanalysis/job/job_initialize.py 2013-07-12 13:09:17 +0000
+++ madanalysis/job/job_initialize.py 2014-05-17 19:51:11 +0000
@@ -428,6 +428,9 @@
428 file.write(' PHYSICS->mcConfig().AddInvisibleId(16);\n')428 file.write(' PHYSICS->mcConfig().AddInvisibleId(16);\n')
429 file.write(' PHYSICS->mcConfig().AddInvisibleId(1000022);\n')429 file.write(' PHYSICS->mcConfig().AddInvisibleId(1000022);\n')
430 file.write(' PHYSICS->mcConfig().AddInvisibleId(1000039);\n')430 file.write(' PHYSICS->mcConfig().AddInvisibleId(1000039);\n')
431 for item in main.multiparticles.Get("invisible"):
432 if item not in [-16,-14,-12,12,14,16,1000022,1000039]:
433 file.write(' PHYSICS->mcConfig().AddInvisibleId('+str(item)+');\n')
431 file.write('\n')434 file.write('\n')
432435
433436
@@ -456,7 +459,12 @@
456 # Initializing array of cuts 459 # Initializing array of cuts
457 if Ncuts!=0:460 if Ncuts!=0:
458 file.write(' // Initializing cut array\n')461 file.write(' // Initializing cut array\n')
459 file.write(' cuts_.Initialize('+str(Ncuts)+');\n')462 icut=1
463 for item in main.selection.table:
464 if item.__class__.__name__=="Cut":
465 file.write(" cuts_.InitCut(\""+item.conditions.GetStringDisplay()+"\");\n")
466 if Ncuts!=0:
467 file.write('\n')
460468
461 # Initializing each item469 # Initializing each item
462 ihisto = 0470 ihisto = 0
463471
=== modified file 'madanalysis/job/job_plot.py'
--- madanalysis/job/job_plot.py 2013-10-29 05:48:23 +0000
+++ madanalysis/job/job_plot.py 2014-05-17 19:51:11 +0000
@@ -72,11 +72,11 @@
72 file.write(' for (unsigned int i=0;i<event.mc()->particles().size();i++)\n')72 file.write(' for (unsigned int i=0;i<event.mc()->particles().size();i++)\n')
73 file.write(' {\n')73 file.write(' {\n')
74 if main.selection[iabs].statuscode=="finalstate":74 if main.selection[iabs].statuscode=="finalstate":
75 file.write(' if (!PHYSICS->IsFinalState(event.mc()->particles()[i])) continue;\n')75 file.write(' if (!PHYSICS->Id->IsFinalState(event.mc()->particles()[i])) continue;\n')
76 elif main.selection[iabs].statuscode=="initialstate":76 elif main.selection[iabs].statuscode=="initialstate":
77 file.write(' if (!PHYSICS->IsInitialState(event.mc()->particles()[i])) continue;\n')77 file.write(' if (!PHYSICS->Id->IsInitialState(event.mc()->particles()[i])) continue;\n')
78 elif main.selection[iabs].statuscode=="interstate":78 elif main.selection[iabs].statuscode=="interstate":
79 file.write(' if (!PHYSICS->IsInterState(event.mc()->particles()[i])) continue;\n')79 file.write(' if (!PHYSICS->Id->IsInterState(event.mc()->particles()[i])) continue;\n')
80 if npid:80 if npid:
81 file.write(' H'+str(ihisto)+'_' +\81 file.write(' H'+str(ihisto)+'_' +\
82 '->Fill(event.mc()->particles()[i].pdgid(),__event_weight__);\n')82 '->Fill(event.mc()->particles()[i].pdgid(),__event_weight__);\n')
@@ -245,8 +245,14 @@
245245
246 # Case of one particle/multiparticle246 # Case of one particle/multiparticle
247 if len(combi2)==1:247 if len(combi2)==1:
248 if main.mode == MA5RunningType.PARTON:
249 TheObs=obs.code_parton[:-2]
250 elif main.mode == MA5RunningType.HADRON:
251 TheObs=obs.code_hadron[:-2]
252 else:
253 TheObs=obs.code_reco[:-2]
248 file.write(' H'+str(ihisto)+'_->Fill('\254 file.write(' H'+str(ihisto)+'_->Fill('\
249 'q1.dr('+containers2[0]+\255 'q1.'+TheObs+'('+containers2[0]+\
250 '[b[0]]),__event_weight__);\n')256 '[b[0]]),__event_weight__);\n')
251257
252 # Operation : sum or diff258 # Operation : sum or diff
@@ -275,8 +281,14 @@
275 'momentum();\n')281 'momentum();\n')
276282
277 # Result 283 # Result
284 if main.mode == MA5RunningType.PARTON:
285 TheObs=obs.code_parton[:-2]
286 elif main.mode == MA5RunningType.HADRON:
287 TheObs=obs.code_hadron[:-2]
288 else:
289 TheObs=obs.code_reco[:-2]
278 file.write(' H'+str(ihisto)+'_->Fill('+\290 file.write(' H'+str(ihisto)+'_->Fill('+\
279 'q1.dr(q2),__event_weight__);\n')291 'q1.'+TheObs+'(q2),__event_weight__);\n')
280292
281 # End Loop293 # End Loop
282 WriteEndLoop(file,iabs,ihisto,combi2,main)294 WriteEndLoop(file,iabs,ihisto,combi2,main)
@@ -317,8 +329,14 @@
317329
318 # Case of one particle/multiparticle330 # Case of one particle/multiparticle
319 if len(combi1)==1:331 if len(combi1)==1:
332 if main.mode == MA5RunningType.PARTON:
333 TheObs=obs.code_parton[:-2]
334 elif main.mode == MA5RunningType.HADRON:
335 TheObs=obs.code_hadron[:-2]
336 else:
337 TheObs=obs.code_reco[:-2]
320 file.write(' H'+str(ihisto)+'_->Fill('\338 file.write(' H'+str(ihisto)+'_->Fill('\
321 'q2.dr('+containers1[0]+\339 'q2.'+TheObs+'('+containers1[0]+\
322 '[a[0]]),__event_weight__);\n')340 '[a[0]]),__event_weight__);\n')
323341
324 # Operation : sum or diff342 # Operation : sum or diff
@@ -347,8 +365,14 @@
347 'momentum();\n')365 'momentum();\n')
348366
349 # Result 367 # Result
368 if main.mode == MA5RunningType.PARTON:
369 TheObs=obs.code_parton[:-2]
370 elif main.mode == MA5RunningType.HADRON:
371 TheObs=obs.code_hadron[:-2]
372 else:
373 TheObs=obs.code_reco[:-2]
350 file.write(' H'+str(ihisto)+'_->Fill('+\374 file.write(' H'+str(ihisto)+'_->Fill('+\
351 'q1.dr(q2),__event_weight__);\n')375 'q1.'+TheObs+'(q2),__event_weight__);\n')
352376
353 # End Loop377 # End Loop
354 WriteEndLoop(file,iabs,ihisto,combi1,main)378 WriteEndLoop(file,iabs,ihisto,combi1,main)
@@ -389,7 +413,13 @@
389 WriteEndLoop(file,ihisto,iabs,combi2,main)413 WriteEndLoop(file,ihisto,iabs,combi2,main)
390414
391 # After the two loops 415 # After the two loops
392 file.write(' H'+str(ihisto)+'_->Fill(q1.dr(q2),__event_weight__);\n')416 if main.mode == MA5RunningType.PARTON:
417 TheObs=obs.code_parton[:-2]
418 elif main.mode == MA5RunningType.HADRON:
419 TheObs=obs.code_hadron[:-2]
420 else:
421 TheObs=obs.code_reco[:-2]
422 file.write(' H'+str(ihisto)+'_->Fill(q1.'+TheObs+'(q2),__event_weight__);\n')
393 423
394424
395def WriteBeforeLoop(file,iabs,ihisto,combination,main,value='value',q='q'):425def WriteBeforeLoop(file,iabs,ihisto,combination,main,value='value',q='q'):
@@ -567,9 +597,15 @@
567597
568 # Case of one particle/multiparticle598 # Case of one particle/multiparticle
569 if len(combi1)==1 and len(combi2)==1:599 if len(combi1)==1 and len(combi2)==1:
600 if main.mode == MA5RunningType.PARTON:
601 TheObs=obs.code_parton[:-2]
602 elif main.mode == MA5RunningType.HADRON:
603 TheObs=obs.code_hadron[:-2]
604 else:
605 TheObs=obs.code_reco[:-2]
570 file.write(' H'+str(ihisto)+'_->Fill('+\606 file.write(' H'+str(ihisto)+'_->Fill('+\
571 containers1[0]+'['+iterator1+'[0]]->'+\607 containers1[0]+'['+iterator1+'[0]]->'+\
572 'dr('+containers2[0]+'['+iterator2+'[0]]),__event_weight__);\n')608 TheObs+'('+containers2[0]+'['+iterator2+'[0]]),__event_weight__);\n')
573 return609 return
574610
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: