Merge lp:~ma5/madanalysis5/v1.1.10beta into lp:madanalysis5
- v1.1.10beta
- Merge into madanalysis-development
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Eric Conte | Pending | ||
Review via email: mp+219948@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/ma5' |
2 | --- bin/ma5 2013-10-29 09:21:58 +0000 |
3 | +++ bin/ma5 2014-05-17 19:51:11 +0000 |
4 | @@ -24,6 +24,194 @@ |
5 | ################################################################################ |
6 | |
7 | |
8 | +def MainSession(): |
9 | + |
10 | + # Importing MadAnalysis main class |
11 | + from madanalysis.core.main import Main |
12 | + main = Main() |
13 | + main.ma5dir = ma5dir |
14 | + |
15 | + # Release version |
16 | + # Do not touch it !!!!! |
17 | + main.version = "1.1.10.35" |
18 | + main.date = "2014/05/09" |
19 | + |
20 | + # Checking arguments |
21 | + import getopt |
22 | + try: |
23 | + optlist, arglist = getopt.getopt(sys.argv[1:], \ |
24 | + "PHReEvhfmsb", \ |
25 | + ["partonlevel","hadronlevel","recolevel",\ |
26 | + "expert","version","release","help",\ |
27 | + "forced","script","mg5","autocheck","build"]) |
28 | + except getopt.GetoptError, err: |
29 | + logging.error(str(err)) |
30 | + usage() |
31 | + sys.exit() |
32 | + |
33 | + # Reading aguments |
34 | + partonlevel = False |
35 | + hadronlevel = False |
36 | + recolevel = False |
37 | + expertmode = False |
38 | + forcedmode = False |
39 | + mg5mode = False |
40 | + scriptmode = False |
41 | + autocheck = False |
42 | + build = False |
43 | + for o,a in optlist: |
44 | + if o in ("-P","--partonlevel"): |
45 | + partonlevel=True |
46 | + elif o in ("-H","--hadronlevel"): |
47 | + hadronlevel=True |
48 | + elif o in ("-R","--recolevel"): |
49 | + recolevel=True |
50 | + elif o in ("-E","-e","--expert"): |
51 | + expertmode=True |
52 | + elif o in ("-f","--forced"): |
53 | + forcedmode=True |
54 | + elif o in ("-m","--mg5"): |
55 | + mg5mode=True |
56 | + elif o in ("-s","--script"): |
57 | + scriptmode=True |
58 | + elif o in ("-v","--version","--release"): |
59 | + logging.info("MA5 release : " + main.version + " " + main.date + "\n") |
60 | + sys.exit() |
61 | + elif o in ("--autocheck"): |
62 | + autocheck = True |
63 | + elif o in ("-b","--build"): |
64 | + build = True |
65 | + elif o in ("-h","--help"): |
66 | + usage() |
67 | + sys.exit() |
68 | + |
69 | + # Checking compatibility between arguments |
70 | + if partonlevel and hadronlevel: |
71 | + logging.error("Parton mode and hadron mode cannot be set in a same time.\n" |
72 | + "Please choose only one of these modes.") |
73 | + sys.exit() |
74 | + elif partonlevel and recolevel: |
75 | + logging.error("Parton mode and reco mode cannot be set in a same time.\n" |
76 | + "Please choose only one of these modes.") |
77 | + sys.exit() |
78 | + |
79 | + elif hadronlevel and recolevel: |
80 | + logging.error("Hadron mode and reco mode cannot be set in a same time.\n" |
81 | + "Please choose only one of these modes.") |
82 | + sys.exit() |
83 | + if scriptmode: |
84 | + forcedmode=True |
85 | + |
86 | + # Setting argument in the main program |
87 | + from madanalysis.enumeration.ma5_running_type import MA5RunningType |
88 | + if partonlevel: |
89 | + main.mode=MA5RunningType.PARTON |
90 | + elif hadronlevel: |
91 | + main.mode=MA5RunningType.HADRON |
92 | + elif recolevel: |
93 | + main.mode=MA5RunningType.RECO |
94 | + from madanalysis.enumeration.normalize_type import NormalizeType |
95 | + main.normalize=NormalizeType.NONE |
96 | + |
97 | + # Re-initializing the list of observables (hadron-level or reco-level) |
98 | + if hadronlevel or recolevel: |
99 | + main.InitObservables(main.mode) |
100 | + |
101 | + main.forced = forcedmode |
102 | + Main.forced = forcedmode |
103 | + main.script = scriptmode |
104 | + main.mg5 = mg5mode |
105 | + |
106 | + # Setting batch mode for ROOT |
107 | + #sys.argv.append('-b-') |
108 | + |
109 | + # Displaying header |
110 | + logging.info("") |
111 | + logging.info(\ |
112 | + "*************************************************************\n" + \ |
113 | + "* *\n" + \ |
114 | + "* W E L C O M E to M A D A N A L Y S I S 5 *\n" + \ |
115 | + "* ______ ______ *\n" + \ |
116 | + "* /'\_/`\/\ __ \/\ ___\ *\n" + \ |
117 | + "* /\ \ \ \_\ \ \ \__/ *\n" + \ |
118 | + "* \ \ \__\ \ \ __ \ \___``\ *\n" + \ |
119 | + "* \ \ \_/\ \ \ \/\ \/\ \_\ \ *\n" + \ |
120 | + "* \ \_\\\ \_\ \_\ \_\ \____/ *\n" + \ |
121 | + "* \/_/ \/_/\/_/\/_/\/___/ *\n" + \ |
122 | + "* *\n" + \ |
123 | + "* MA5 release : " + \ |
124 | + "%-24s" % main.version + "%+15s" % main.date + " *\n" + \ |
125 | + "* *\n" + \ |
126 | + "* Comput. Phys. Commun. 184 (2013) 222-256 *\n" + \ |
127 | + "* *\n" + \ |
128 | + "* The MadAnalysis Development Team - Please visit us at *\n" + \ |
129 | + "* https://launchpad.net/madanalysis5 *\n" + \ |
130 | + "* *\n" + \ |
131 | + "* Type 'help' for in-line help. *\n" + \ |
132 | + "* *\n" + \ |
133 | + "*************************************************************") |
134 | + |
135 | + # Displaying special banner if auto-check mode is activated |
136 | + if autocheck: |
137 | + logging.info("") |
138 | + logging.info(" AUTO-CHECK MODE") |
139 | + logging.info("") |
140 | + |
141 | + # Checking the present linux configuration |
142 | + if not main.CheckLinuxConfig(detail=autocheck): |
143 | + sys.exit() |
144 | + |
145 | + # Building (if necesserary) the SampleAnalyzer library |
146 | + if not main.BuildLibrary(forced=build): |
147 | + sys.exit() |
148 | + |
149 | + logging.info("*************************************************************") |
150 | + |
151 | + |
152 | + # Auto-check mode |
153 | + if autocheck: |
154 | + pass |
155 | + |
156 | + # Expert mode |
157 | + elif expertmode: |
158 | + from madanalysis.core.expert_mode import ExpertMode |
159 | + main.expertmode = True |
160 | + expert = ExpertMode(main) |
161 | + if not expert.CreateDirectory(): |
162 | + sys.exit() |
163 | + if not expert.Copy(): |
164 | + sys.exit() |
165 | + expert.GiveAdvice() |
166 | + return False |
167 | + |
168 | + # Normal mode |
169 | + else: |
170 | + |
171 | + # Launching the interpreter |
172 | + from madanalysis.interpreter.interpreter import Interpreter |
173 | + interpreter = Interpreter(main) |
174 | + |
175 | + # Looking for script |
176 | + for arg in arglist: |
177 | + filename=os.path.expanduser(arg) |
178 | + filename=os.path.abspath(filename) |
179 | + interpreter.load(filename) |
180 | + |
181 | + # Exit if script mode activated |
182 | + if len(arglist)!=0 and main.script: |
183 | + interpreter.run_cmd("quit") |
184 | + return False |
185 | + |
186 | + # Interpreter loop |
187 | + else: |
188 | + interpreter.cmdloop() |
189 | + if main.repeatSession==True: |
190 | + return True |
191 | + else: |
192 | + return False |
193 | + |
194 | + |
195 | + |
196 | def usage(): |
197 | logging.info("\nUsage of MadAnalysis 5") |
198 | logging.info("------------------------") |
199 | @@ -50,6 +238,9 @@ |
200 | logging.info("This optional argument is a list of filenames containing a "+\ |
201 | "set of MadAnalysis 5 commands. The file name are handled as "+\ |
202 | "concatenated, and the commands are applied sequentially.\n") |
203 | + |
204 | + |
205 | + |
206 | |
207 | """This is the main executable, a simple frontend to set up the PYTHONPATH |
208 | and call immediately the command line interface scripts""" |
209 | @@ -105,182 +296,16 @@ |
210 | readline.__doc__ = 'GNU' |
211 | readline.parse_and_bind("tab: complete") |
212 | |
213 | - |
214 | -# Importing MadAnalysis main class |
215 | -from madanalysis.core.main import Main |
216 | -main = Main() |
217 | -main.ma5dir = ma5dir |
218 | - |
219 | -# Release version |
220 | -# Do not touch it !!!!! |
221 | -main.version = "1.1.9" |
222 | -main.date = "2013/10/29" |
223 | - |
224 | -# Checking arguments |
225 | -import getopt |
226 | -try: |
227 | - optlist, arglist = getopt.getopt(sys.argv[1:], \ |
228 | - "PHReEvhfmsb", \ |
229 | - ["partonlevel","hadronlevel","recolevel",\ |
230 | - "expert","version","release","help",\ |
231 | - "forced","script","mg5","autocheck","build"]) |
232 | -except getopt.GetoptError, err: |
233 | - logging.error(str(err)) |
234 | - usage() |
235 | - sys.exit() |
236 | - |
237 | -# Reading aguments |
238 | -partonlevel = False |
239 | -hadronlevel = False |
240 | -recolevel = False |
241 | -expertmode = False |
242 | -forcedmode = False |
243 | -mg5mode = False |
244 | -scriptmode = False |
245 | -autocheck = False |
246 | -build = False |
247 | -for o,a in optlist: |
248 | - if o in ("-P","--partonlevel"): |
249 | - partonlevel=True |
250 | - elif o in ("-H","--hadronlevel"): |
251 | - hadronlevel=True |
252 | - elif o in ("-R","--recolevel"): |
253 | - recolevel=True |
254 | - elif o in ("-E","-e","--expert"): |
255 | - expertmode=True |
256 | - elif o in ("-f","--forced"): |
257 | - forcedmode=True |
258 | - elif o in ("-m","--mg5"): |
259 | - mg5mode=True |
260 | - elif o in ("-s","--script"): |
261 | - scriptmode=True |
262 | - elif o in ("-v","--version","--release"): |
263 | - logging.info("MA5 release : " + main.version + " " + main.date + "\n") |
264 | - sys.exit() |
265 | - elif o in ("--autocheck"): |
266 | - autocheck = True |
267 | - elif o in ("-b","--build"): |
268 | - build = True |
269 | - elif o in ("-h","--help"): |
270 | - usage() |
271 | - sys.exit() |
272 | - |
273 | -# Checking compatibility between arguments |
274 | -if partonlevel and hadronlevel: |
275 | - logging.error("Parton mode and hadron mode cannot be set in a same time.\n" |
276 | - "Please choose only one of these modes.") |
277 | - sys.exit() |
278 | -elif partonlevel and recolevel: |
279 | - logging.error("Parton mode and reco mode cannot be set in a same time.\n" |
280 | - "Please choose only one of these modes.") |
281 | - sys.exit() |
282 | - |
283 | -elif hadronlevel and recolevel: |
284 | - logging.error("Hadron mode and reco mode cannot be set in a same time.\n" |
285 | - "Please choose only one of these modes.") |
286 | - sys.exit() |
287 | -if scriptmode: |
288 | - forcedmode=True |
289 | - |
290 | -# Setting argument in the main program |
291 | -from madanalysis.enumeration.ma5_running_type import MA5RunningType |
292 | -if partonlevel: |
293 | - main.mode=MA5RunningType.PARTON |
294 | -elif hadronlevel: |
295 | - main.mode=MA5RunningType.HADRON |
296 | -elif recolevel: |
297 | - main.mode=MA5RunningType.RECO |
298 | - from madanalysis.enumeration.normalize_type import NormalizeType |
299 | - main.normalize=NormalizeType.NONE |
300 | - |
301 | -# Re-initializing the list of observables (hadron-level or reco-level) |
302 | -if hadronlevel or recolevel: |
303 | - main.InitObservables(main.mode) |
304 | - |
305 | - |
306 | -main.forced = forcedmode |
307 | -Main.forced = forcedmode |
308 | -main.script = scriptmode |
309 | -main.mg5 = mg5mode |
310 | - |
311 | -# Setting batch mode for ROOT |
312 | -#sys.argv.append('-b-') |
313 | - |
314 | -# Displaying header |
315 | -logging.info("") |
316 | -logging.info(\ |
317 | -"*************************************************************\n" + \ |
318 | -"* *\n" + \ |
319 | -"* W E L C O M E to M A D A N A L Y S I S 5 *\n" + \ |
320 | -"* ______ ______ *\n" + \ |
321 | -"* /'\_/`\/\ __ \/\ ___\ *\n" + \ |
322 | -"* /\ \ \ \_\ \ \ \__/ *\n" + \ |
323 | -"* \ \ \__\ \ \ __ \ \___``\ *\n" + \ |
324 | -"* \ \ \_/\ \ \ \/\ \/\ \_\ \ *\n" + \ |
325 | -"* \ \_\\\ \_\ \_\ \_\ \____/ *\n" + \ |
326 | -"* \/_/ \/_/\/_/\/_/\/___/ *\n" + \ |
327 | -"* *\n" + \ |
328 | -"* MA5 release : " + \ |
329 | - "%-24s" % main.version + "%+15s" % main.date + " *\n" + \ |
330 | -"* *\n" + \ |
331 | -"* Comput. Phys. Commun. 184 (2013) 222-256 *\n" + \ |
332 | -"* *\n" + \ |
333 | -"* The MadAnalysis Development Team - Please visit us at *\n" + \ |
334 | -"* https://launchpad.net/madanalysis5 *\n" + \ |
335 | -"* *\n" + \ |
336 | -"* Type 'help' for in-line help. *\n" + \ |
337 | -"* *\n" + \ |
338 | -"*************************************************************") |
339 | - |
340 | -# Displaying special banner if auto-check mode is activated |
341 | -if autocheck: |
342 | - logging.info("") |
343 | - logging.info(" AUTO-CHECK MODE") |
344 | - logging.info("") |
345 | - |
346 | - |
347 | -# Checking the present linux configuration |
348 | -if not main.CheckLinuxConfig(detail=autocheck): |
349 | - sys.exit() |
350 | - |
351 | -# Building (if necesserary) the SampleAnalyzer library |
352 | -if not main.BuildLibrary(forced=build): |
353 | - sys.exit() |
354 | - |
355 | -logging.info("*************************************************************") |
356 | - |
357 | - |
358 | -# Auto-check mode |
359 | -if autocheck: |
360 | - pass |
361 | - |
362 | -# Expert mode |
363 | -elif expertmode: |
364 | - from madanalysis.core.expert_mode import ExpertMode |
365 | - expert = ExpertMode(main) |
366 | - if not expert.CreateDirectory(): |
367 | - sys.exit() |
368 | - if not expert.Copy(): |
369 | - sys.exit() |
370 | - expert.GiveAdvice() |
371 | - |
372 | -# Normal mode |
373 | -else: |
374 | - |
375 | - # Launching the interpreter |
376 | - from madanalysis.interpreter.interpreter import Interpreter |
377 | - interpreter = Interpreter(main) |
378 | - |
379 | - # Looking for script |
380 | - for arg in arglist: |
381 | - filename=os.path.expanduser(arg) |
382 | - filename=os.path.abspath(filename) |
383 | - interpreter.load(filename) |
384 | - |
385 | - # Exit if script mode activated |
386 | - if len(arglist)!=0 and main.script: |
387 | - interpreter.run_cmd("quit") |
388 | - |
389 | - # Interpreter loop |
390 | - else: |
391 | - interpreter.cmdloop() |
392 | +# Loop over MA5 sessions |
393 | +# Goal: allowing to restart |
394 | +while True: |
395 | + repeat = MainSession() |
396 | + if not repeat: |
397 | + # Normal end |
398 | + break |
399 | + from madanalysis.core.string_tools import StringTools |
400 | + logging.info("") |
401 | + logging.info(StringTools.Fill('-',40)) |
402 | + logging.info(StringTools.Center('RESTART THE MADANALYSIS 5 SESSION',40)) |
403 | + logging.info(StringTools.Fill('-',40)) |
404 | + logging.info("") |
405 | |
406 | === added file 'madanalysis/IOinterface/delphes_migration.py' |
407 | --- madanalysis/IOinterface/delphes_migration.py 1970-01-01 00:00:00 +0000 |
408 | +++ madanalysis/IOinterface/delphes_migration.py 2014-05-17 19:51:11 +0000 |
409 | @@ -0,0 +1,81 @@ |
410 | +################################################################################ |
411 | +# |
412 | +# Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks |
413 | +# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr> |
414 | +# |
415 | +# This file is part of MadAnalysis 5. |
416 | +# Official website: <https://launchpad.net/madanalysis5> |
417 | +# |
418 | +# MadAnalysis 5 is free software: you can redistribute it and/or modify |
419 | +# it under the terms of the GNU General Public License as published by |
420 | +# the Free Software Foundation, either version 3 of the License, or |
421 | +# (at your option) any later version. |
422 | +# |
423 | +# MadAnalysis 5 is distributed in the hope that it will be useful, |
424 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
425 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
426 | +# GNU General Public License for more details. |
427 | +# |
428 | +# You should have received a copy of the GNU General Public License |
429 | +# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/> |
430 | +# |
431 | +################################################################################ |
432 | + |
433 | + |
434 | +from madanalysis.selection.instance_name import InstanceName |
435 | +from madanalysis.IOinterface.folder_writer import FolderWriter |
436 | +from madanalysis.enumeration.ma5_running_type import MA5RunningType |
437 | +from madanalysis.core.string_tools import StringTools |
438 | +import logging |
439 | +import shutil |
440 | +import os |
441 | +import commands |
442 | +import glob |
443 | + |
444 | +class DelphesMigration(): |
445 | + |
446 | + def __init__(self,main): |
447 | + self.main = main |
448 | + |
449 | + def Migrate(self): |
450 | + self.ChangeTreeNames() |
451 | + self.ApplyPatch() |
452 | + |
453 | + def ApplyPatch(self): |
454 | + os.system('cp '+self.main.ma5dir+'/tools/SampleAnalyzer/Detector/patch_delfes.tgz '+\ |
455 | + self.main.ma5dir+'/tools/delfes/') |
456 | + os.system('cd '+ self.main.ma5dir + '/tools/delfes/; tar xzf patch_delfes.tgz') |
457 | + |
458 | + |
459 | + def ChangeTreeNames(self): |
460 | + myfiles = glob.glob(self.main.ma5dir+'/tools/delfes/readers/Delphes*.cpp') |
461 | + for myfile in myfiles: |
462 | + self.ChangeTreeName(myfile) |
463 | + |
464 | + def ChangeTreeName(self,filename): |
465 | + |
466 | + try: |
467 | + input = open(filename) |
468 | + except: |
469 | + return False |
470 | + |
471 | + try: |
472 | + output = open(filename+"~","w") |
473 | + except: |
474 | + return False |
475 | + |
476 | + for line in input: |
477 | + if line.find("treeWriter")!=-1 and line.find("ExRootTreeWriter")!=1: |
478 | + line = line.replace('"Delphes"','"Delfes"') |
479 | + output.write(line) |
480 | + |
481 | + output.close() |
482 | + input.close() |
483 | + os.system("mv "+filename+"~ "+filename) |
484 | + return True |
485 | + |
486 | + |
487 | + |
488 | + |
489 | + |
490 | + |
491 | |
492 | === modified file 'madanalysis/IOinterface/job_reader.py' |
493 | --- madanalysis/IOinterface/job_reader.py 2013-07-28 14:10:33 +0000 |
494 | +++ madanalysis/IOinterface/job_reader.py 2014-05-17 19:51:11 +0000 |
495 | @@ -293,9 +293,9 @@ |
496 | beginTag.activate() |
497 | elif words[0].lower()=='</safheader>': |
498 | beginTag.desactivate() |
499 | - if words[0].lower()=='<saffoot>': |
500 | + if words[0].lower()=='<saffooter>': |
501 | endTag.activate() |
502 | - elif words[0].lower()=='</saffoot>': |
503 | + elif words[0].lower()=='</saffooter>': |
504 | endTag.desactivate() |
505 | if words[0].lower()=='<sampleglobalinfo>': |
506 | globalTag.activate() |
507 | @@ -573,7 +573,7 @@ |
508 | logging.error("SAF header <SAFheader> and </SAFheader> is not "+\ |
509 | "found.") |
510 | if endTag.Nactivated==0 or endTag.activated: |
511 | - logging.error("SAF foot <SAFfoot> and </SAFfoot> is not "+\ |
512 | + logging.error("SAF footer <SAFfooter> and </SAFfooter> is not "+\ |
513 | "found.") |
514 | if globalTag.Nactivated==0 or globalTag.activated: |
515 | logging.error("Information corresponding to the block "+\ |
516 | |
517 | === modified file 'madanalysis/IOinterface/job_writer.py' |
518 | --- madanalysis/IOinterface/job_writer.py 2013-10-29 09:21:58 +0000 |
519 | +++ madanalysis/IOinterface/job_writer.py 2014-05-17 19:51:11 +0000 |
520 | @@ -26,6 +26,7 @@ |
521 | from madanalysis.IOinterface.folder_writer import FolderWriter |
522 | from madanalysis.enumeration.ma5_running_type import MA5RunningType |
523 | from madanalysis.core.string_tools import StringTools |
524 | +from madanalysis.IOinterface.shell_command import ShellCommand |
525 | import logging |
526 | import shutil |
527 | import os |
528 | @@ -40,6 +41,7 @@ |
529 | self.resubmit = resubmit |
530 | self.libZIP = self.main.libZIP |
531 | self.libDelphes = self.main.libDelphes |
532 | + self.libDelfes = self.main.libDelfes |
533 | self.output = self.main.output |
534 | self.libFastjet = self.main.libFastJet |
535 | self.fastsim = self.main.fastsim |
536 | @@ -60,8 +62,6 @@ |
537 | return False |
538 | elif not os.path.isdir(path+"/Build/SampleAnalyzer/Analyzer"): |
539 | return False |
540 | - elif not os.path.isdir(path+"/Build/SampleAnalyzer/Filter"): |
541 | - return False |
542 | elif not os.path.isdir(path+"/Build/Main"): |
543 | return False |
544 | elif not os.path.isdir(path+"/Output"): |
545 | @@ -99,11 +99,6 @@ |
546 | logging.error("Impossible to create the folder 'Build/SampleAnalyzer/Analyzer'") |
547 | return False |
548 | try: |
549 | - os.mkdir(path+"/Build/SampleAnalyzer/Filter") |
550 | - except: |
551 | - logging.error("Impossible to create the folder 'Build/SampleAnalyzer/Filter'") |
552 | - return False |
553 | - try: |
554 | os.mkdir(path+"/Build/Log") |
555 | except: |
556 | logging.error("Impossible to create the folder 'Build/Log'") |
557 | @@ -143,9 +138,6 @@ |
558 | elif not os.path.isdir(self.path+"/Build/SampleAnalyzer/Analyzer"): |
559 | logging.error("folder '"+self.path+"/Build/SampleAnalyzer/Analyzer' is not found") |
560 | return False |
561 | - elif not os.path.isdir(self.path+"/Build/SampleAnalyzer/Filter"): |
562 | - logging.error("folder '"+self.path+"/Build/SampleAnalyzer/Filter' is not found") |
563 | - return False |
564 | elif not os.path.isdir(self.path+"/Build/Main"): |
565 | logging.error("folder '"+self.path+"/Build/Main' is not found") |
566 | return False |
567 | @@ -170,19 +162,18 @@ |
568 | |
569 | def CreateDelphesCard(self): |
570 | |
571 | - if self.fastsim.delphes.pileup=="": |
572 | - if self.fastsim.delphes.detector=='cms': |
573 | - cardname = 'delphes_card_CMS.tcl' |
574 | - elif self.fastsim.delphes.detector=='atlas': |
575 | - cardname ='delphes_card_ATLAS.tcl' |
576 | + if self.main.fastsim.package=="delphes": |
577 | + cardname = self.main.fastsim.delphes.card |
578 | + elif self.main.fastsim.package=="delfes": |
579 | + cardname = self.main.fastsim.delfes.card |
580 | + |
581 | + if self.main.fastsim.package=="delfes": |
582 | + cfg=self.main.fastsim.delfes |
583 | else: |
584 | - if self.fastsim.delphes.detector=='cms': |
585 | - cardname = 'delphes_card_CMS_PileUp.tcl' |
586 | - elif self.fastsim.delphes.detector=='atlas': |
587 | - cardname ='delphes_card_ATLAS_PileUp.tcl' |
588 | + cfg=self.main.fastsim.delphes |
589 | |
590 | try: |
591 | - input = open(self.ma5dir+"/tools/SampleAnalyzer/"+cardname,'r') |
592 | + input = open(self.ma5dir+"/tools/SampleAnalyzer/Detector/"+cardname,'r') |
593 | except: |
594 | pass |
595 | |
596 | @@ -191,18 +182,18 @@ |
597 | except: |
598 | pass |
599 | |
600 | - if self.main.fastsim.delphes.pileup!="": |
601 | + if cfg.pileup!="": |
602 | # Getting current dir |
603 | theDir = os.getcwd() |
604 | |
605 | # Adding file |
606 | - if self.main.fastsim.delphes.pileup.startswith('/'): |
607 | - theFile = self.main.fastsim.delphes.pileup |
608 | + if cfg.pileup.startswith('/'): |
609 | + theFile = cfg.pileup |
610 | else: |
611 | - theFile = os.path.normpath(theDir+"/"+self.main.fastsim.delphes.pileup) |
612 | + theFile = os.path.normpath(theDir+"/"+cfg.pileup) |
613 | |
614 | for line in input: |
615 | - if self.main.fastsim.delphes.pileup!="": |
616 | + if cfg.pileup!="": |
617 | line=line.replace('MinBias.pileup',theFile) |
618 | output.write(line) |
619 | |
620 | @@ -234,22 +225,8 @@ |
621 | except: |
622 | logging.error('Impossible to make executable the file "newAnalyzer"') |
623 | return False |
624 | - try: |
625 | - shutil.copyfile\ |
626 | - (\ |
627 | - self.ma5dir+"/tools/SampleAnalyzer/newFilter.py",\ |
628 | - self.path+"/Build/SampleAnalyzer/newFilter.py"\ |
629 | - ) |
630 | - except: |
631 | - logging.error('Impossible to copy the file "newFilter"') |
632 | - return False |
633 | - try: |
634 | - os.chmod(self.path+"/Build/SampleAnalyzer/newFilter.py",0755) |
635 | - except: |
636 | - logging.error('Impossible to make executable the file "newFilter.py"') |
637 | - return False |
638 | |
639 | - if self.main.fastsim.package=="delphes": |
640 | + if self.main.fastsim.package in ["delphes","delfes"]: |
641 | self.CreateDelphesCard() |
642 | |
643 | return True |
644 | @@ -267,7 +244,8 @@ |
645 | |
646 | def PrintIncludes(self,file): |
647 | file.write('// SampleHeader header\n') |
648 | - file.write('#include \"SampleAnalyzer/Core/SampleAnalyzer.h\"\n') |
649 | + file.write('#include "SampleAnalyzer/Core/SampleAnalyzer.h"\n') |
650 | + file.write('#include "SampleAnalyzer/Analyzer/analysisList.h"\n') |
651 | file.write('using namespace MA5;\n\n') |
652 | return |
653 | |
654 | @@ -278,7 +256,9 @@ |
655 | file.write('int main(int argc, char *argv[])\n') |
656 | file.write('{\n') |
657 | file.write(' // Creating a manager\n') |
658 | - file.write(' SampleAnalyzer manager;\n\n') |
659 | + file.write(' SampleAnalyzer manager;\n') |
660 | + file.write(' BuildUserTable(manager.AnalyzerList());\n') |
661 | + file.write('\n') |
662 | |
663 | # Initializing |
664 | file.write(' // ---------------------------------------------------\n') |
665 | @@ -286,7 +266,11 @@ |
666 | file.write(' // ---------------------------------------------------\n') |
667 | file.write(' INFO << " * Initializing all components" << endmsg;\n\n') |
668 | file.write(' // Initializing the manager\n') |
669 | - file.write(' if (!manager.Initialize(argc,argv,"pdg.ma5")) '+\ |
670 | + if self.main.expertmode: |
671 | + file.write(' if (!manager.Initialize(argc,argv,"pdg.ma5",true)) '+\ |
672 | + 'return 1;\n\n') |
673 | + else: |
674 | + file.write(' if (!manager.Initialize(argc,argv,"pdg.ma5")) '+\ |
675 | 'return 1;\n\n') |
676 | file.write(' // Creating data format for storing data\n') |
677 | file.write(' EventFormat myEvent;\n') |
678 | @@ -314,39 +298,48 @@ |
679 | |
680 | # Fast-Simulation detector |
681 | # + Case Fastsim |
682 | - if self.fastsim.package=="fastjet": |
683 | + if self.main.fastsim.package=="fastjet": |
684 | file.write(' //Getting pointer to the clusterer\n') |
685 | file.write(' std::map<std::string, std::string> parametersC1;\n') |
686 | - parameters = self.fastsim.SampleAnalyzerConfigString() |
687 | + parameters = self.main.fastsim.SampleAnalyzerConfigString() |
688 | for k,v in sorted(parameters.iteritems(),\ |
689 | key=lambda (k,v): (k,v)): |
690 | file.write(' parametersC1["'+k+'"]="'+v+'";\n') |
691 | file.write(' JetClustererBase* cluster1 = \n') |
692 | - file.write(' manager.InitializeJetClusterer("'+self.fastsim.clustering.algorithm+'",parametersC1);\n') |
693 | + file.write(' manager.InitializeJetClusterer("'+self.main.fastsim.clustering.algorithm+'",parametersC1);\n') |
694 | file.write(' if (cluster1==0) return 1;\n\n') |
695 | |
696 | # + Case Delphes |
697 | - if self.fastsim.package=="delphes": |
698 | + if self.main.fastsim.package in ["delphes","delfes"]: |
699 | file.write(' //Getting pointer to fast-simulation package\n') |
700 | file.write(' std::map<std::string, std::string> parametersD1;\n') |
701 | - parameters = self.fastsim.SampleAnalyzerConfigString() |
702 | + if self.fastsim.package=="delfes": |
703 | + cfg=self.main.fastsim.delfes |
704 | + else: |
705 | + cfg=self.main.fastsim.delphes |
706 | + parameters = self.main.fastsim.SampleAnalyzerConfigString() |
707 | for k,v in sorted(parameters.iteritems(),\ |
708 | key=lambda (k,v): (k,v)): |
709 | file.write(' parametersD1["'+k+'"]="'+v+'";\n') |
710 | file.write(' DetectorBase* fastsim1 = \n') |
711 | - if self.fastsim.delphes.pileup=="": |
712 | - if self.fastsim.delphes.detector=='cms': |
713 | - cardname = 'delphes_card_CMS.tcl' |
714 | - elif self.fastsim.delphes.detector=='atlas': |
715 | - cardname ='delphes_card_ATLAS.tcl' |
716 | + |
717 | + if self.main.fastsim.package=="delphes": |
718 | + cardname = self.main.fastsim.delphes.card |
719 | + elif self.main.fastsim.package=="delfes": |
720 | + cardname = self.main.fastsim.delfes.card |
721 | + |
722 | + if self.main.fastsim.package=="delphes": |
723 | + file.write(' manager.InitializeDetector("delphes","../../Input/'+cardname+'",parametersD1);\n') |
724 | else: |
725 | - if self.fastsim.delphes.detector=='cms': |
726 | - cardname = 'delphes_card_CMS_PileUp.tcl' |
727 | - elif self.fastsim.delphes.detector=='atlas': |
728 | - cardname ='delphes_card_ATLAS_PileUp.tcl' |
729 | - file.write(' manager.InitializeDetector("delphes","../../Input/'+cardname+'",parametersD1);\n') |
730 | + file.write(' manager.InitializeDetector("delfes","../../Input/'+cardname+'",parametersD1);\n') |
731 | + |
732 | file.write(' if (fastsim1==0) return 1;\n\n') |
733 | |
734 | + # Post intialization (crating the output directory structure) |
735 | + file.write(' // Post initialization (creates the new output directory structure)\n') |
736 | + file.write(' if(!manager.PostInitialize()) return 1;\n\n') |
737 | + |
738 | + |
739 | # Loop |
740 | file.write(' // ---------------------------------------------------\n') |
741 | file.write(' // EXECUTION\n') |
742 | @@ -377,9 +370,11 @@ |
743 | file.write(' manager.UpdateProgressBar();\n') |
744 | if self.merging.enable: |
745 | file.write(' analyzer2->Execute(mySample,myEvent);\n') |
746 | - if self.fastsim.package=="fastjet": |
747 | + if self.main.fastsim.package=="fastjet": |
748 | file.write(' cluster1->Execute(mySample,myEvent);\n') |
749 | - elif self.fastsim.package=="delphes": |
750 | + elif self.main.fastsim.package=="delphes": |
751 | + file.write(' fastsim1->Execute(mySample,myEvent);\n') |
752 | + elif self.main.fastsim.package=="delfes": |
753 | file.write(' fastsim1->Execute(mySample,myEvent);\n') |
754 | file.write(' analyzer1->Execute(mySample,myEvent);\n') |
755 | if self.output!="": |
756 | @@ -394,15 +389,6 @@ |
757 | file.write(' INFO << " * Finalizing all components ..." << endmsg;\n\n') |
758 | file.write(' // Finalizing all components\n') |
759 | file.write(' manager.Finalize(mySamples,myEvent);\n') |
760 | - |
761 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(12);\n') |
762 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(-12);\n') |
763 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(14);\n') |
764 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(-14);\n') |
765 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(16);\n') |
766 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(-16);\n') |
767 | -# file.write(' PHYSICS->mcConfig().AddInvisibleId(1000022);\n\n') |
768 | - |
769 | file.write(' return 0;\n') |
770 | file.write('}\n') |
771 | return |
772 | @@ -425,23 +411,6 @@ |
773 | file.close() |
774 | return True |
775 | |
776 | - def WriteEmptyFilterSource(self,main): |
777 | - file = open(self.path+"/Build/SampleAnalyzer/Filter/filterList.cpp","w") |
778 | - file.write('#include "SampleAnalyzer/Filter/FilterManager.h"\n') |
779 | - file.write('using namespace MA5;\n') |
780 | - file.write('#include <stdlib.h>\n\n') |
781 | - file.write('// ------------------------------------------' +\ |
782 | - '-----------------------------------\n') |
783 | - file.write('// BuildUserTable\n') |
784 | - file.write('// ------------------------------------------' +\ |
785 | - '-----------------------------------\n') |
786 | - file.write('void FilterManager::BuildUserTable()\n') |
787 | - file.write('{\n') |
788 | - file.write('}\n') |
789 | - file.close() |
790 | - |
791 | - return True |
792 | - |
793 | def WriteSelectionSource(self,main): |
794 | main.selection.RefreshStat(); |
795 | file = open(self.path+"/Build/SampleAnalyzer/Analyzer/user.cpp","w") |
796 | @@ -450,23 +419,22 @@ |
797 | job.WriteSource() |
798 | file.close() |
799 | |
800 | - file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.cpp","w") |
801 | + file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.h","w") |
802 | file.write('#include "SampleAnalyzer/Analyzer/AnalyzerManager.h"\n') |
803 | file.write('#include "SampleAnalyzer/Analyzer/user.h"\n') |
804 | file.write('#include "SampleAnalyzer/Service/LogStream.h"\n') |
805 | - file.write('using namespace MA5;\n') |
806 | - file.write('#include <stdlib.h>\n\n') |
807 | + file.write('\n') |
808 | file.write('// ------------------------------------------' +\ |
809 | '-----------------------------------\n') |
810 | file.write('// BuildUserTable\n') |
811 | file.write('// ------------------------------------------' +\ |
812 | '-----------------------------------\n') |
813 | - file.write('void AnalyzerManager::BuildUserTable()\n') |
814 | + file.write('void BuildUserTable(MA5::AnalyzerManager& manager)\n') |
815 | file.write('{\n') |
816 | - file.write(' Add("MadAnalysis5job", new user);\n') |
817 | + file.write(' using namespace MA5;\n') |
818 | + file.write(' manager.Add("MadAnalysis5job", new user);\n') |
819 | file.write('}\n') |
820 | file.close() |
821 | - self.WriteEmptyFilterSource(main) |
822 | return True |
823 | |
824 | def CreateShowerDir(self,mode): |
825 | @@ -505,18 +473,20 @@ |
826 | |
827 | # Compilators |
828 | file.write('# Compilators\n') |
829 | - file.write('GCC = g++\n') |
830 | + file.write('CXX = g++\n') |
831 | file.write('\n') |
832 | |
833 | # Options for compilation |
834 | file.write('# Options for compilation\n') |
835 | if self.libFastjet: |
836 | file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n') |
837 | - file.write('CXXFLAGS = -Wall -O3 -I./ -I./../ -I' + '$(MA5_BASE)/tools/') |
838 | + file.write('CXXFLAGS = -Wall -O3 -fPIC -I./ -I./../ -I' + '$(MA5_BASE)/tools/') |
839 | if self.libZIP: |
840 | file.write(' -DZIP_USE') |
841 | if self.libDelphes: |
842 | - file.write(' -DDELPHES_USE') |
843 | + file.write(' -DROOT_USE -DDELPHES_USE') |
844 | + if self.libDelfes: |
845 | + file.write(' -DROOT_USE -DDELFES_USE') |
846 | if self.libFastjet: |
847 | file.write(' -DFASTJET_USE') |
848 | file.write(' $(CXXFASTJET)') |
849 | @@ -530,16 +500,9 @@ |
850 | file.write('OBJS = $(SRCS:.cpp=.o)\n') |
851 | file.write('\n') |
852 | |
853 | - # Files for filters |
854 | - file.write('# Files for filters\n') |
855 | - file.write('SRCS2 = $(wildcard Filter/*.cpp)\n') |
856 | - file.write('HDRS2 = $(wildcard Filter/*.h)\n') |
857 | - file.write('OBJS2 = $(SRCS2:.cpp=.o)\n') |
858 | - file.write('\n') |
859 | - |
860 | # Name of the library |
861 | file.write('# Name of the library\n') |
862 | - file.write('PROGRAM = SampleAnalyzerBld\n') |
863 | + file.write('PROGRAM = UserPackage_for_ma5\n') |
864 | file.write('\n') |
865 | |
866 | # All |
867 | @@ -549,21 +512,19 @@ |
868 | |
869 | # Compilation |
870 | file.write('# Compile target\n') |
871 | - file.write('compile: $(OBJS) $(OBJS2)\n') |
872 | + file.write('compile: $(OBJS)\n') |
873 | file.write('\n') |
874 | file.write('# Object file target\n') |
875 | file.write('$(OBJS): $(HDRS)\n') |
876 | - file.write('$(OBJS2): $(HDRS2)\n') |
877 | file.write('\n') |
878 | |
879 | # Linking |
880 | file.write('# Link target\n') |
881 | - file.write('link: $(OBJS) $(OBJS2)\n') |
882 | - file.write('\tcp ' +\ |
883 | - '$(MA5_BASE)/tools/SampleAnalyzer/Lib/libSampleAnalyzer.a ' +\ |
884 | - '../../Build/Lib/lib$(PROGRAM).a\n') |
885 | - file.write('\tar -ruc ../../Build/Lib/lib$(PROGRAM).a $(OBJS) $(OBJS2)\n') |
886 | - file.write('\tranlib ../../Build/Lib/lib$(PROGRAM).a\n') |
887 | + file.write('link: $(OBJS)\n') |
888 | + if self.main.isMAC: |
889 | + file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o ../../Build/Lib/lib$(PROGRAM).so $(OBJS)\n') |
890 | + else: |
891 | + file.write('\t$(CXX) -shared -o ../../Build/Lib/lib$(PROGRAM).so $(OBJS)\n') |
892 | file.write('\n') |
893 | |
894 | # Phony target |
895 | @@ -577,7 +538,7 @@ |
896 | file.write('\n') |
897 | file.write('# Do clean target\n') |
898 | file.write('do_clean:\n') |
899 | - file.write('\t@rm -f $(OBJS) $(OBJS2)\n') |
900 | + file.write('\t@rm -f $(OBJS)\n') |
901 | file.write('\n') |
902 | |
903 | # Mr Proper |
904 | @@ -586,7 +547,7 @@ |
905 | file.write('\n') |
906 | file.write('# Do clean target\n') |
907 | file.write('do_mrproper: do_clean\n') |
908 | - file.write('\t@rm -f ../../Build/Lib/lib$(PROGRAM).a\n') |
909 | + file.write('\t@rm -f ../../Build/Lib/lib$(PROGRAM).so\n') |
910 | file.write('\t@rm -f *~ */*~ \n') |
911 | file.write('\n') |
912 | |
913 | @@ -615,9 +576,9 @@ |
914 | def WriteMakefiles(self,option=""): |
915 | |
916 | # Writing sub-Makefiles |
917 | - self.WriteSampleAnalyzerMakefile(option) |
918 | - if self.shwrmode!='': |
919 | - self.WriteShoweringMakefile(option) |
920 | + #self.WriteSampleAnalyzerMakefile(option) |
921 | + #if self.shwrmode!='': |
922 | + # self.WriteShoweringMakefile(option) |
923 | |
924 | # Opening the main Makefile |
925 | file = open(self.path+"/Build/Makefile","w") |
926 | @@ -630,61 +591,79 @@ |
927 | |
928 | # Compilators |
929 | file.write('# Compilators\n') |
930 | - file.write('GCC = g++\n') |
931 | + file.write('CXX = g++\n') |
932 | file.write('\n') |
933 | |
934 | - # Options for compilation |
935 | + # Options for compilation : CXXFLAGS |
936 | file.write('# Options for compilation\n') |
937 | - if self.libFastjet: |
938 | - file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n') |
939 | - |
940 | - file.write('FASTJETLIB = $(shell fastjet-config --libs --plugins)\n') |
941 | - file.write('CXXFLAGS = -Wall -O3 -I./ -I$(MA5_BASE)/tools/') |
942 | - if self.shwrmode!='': |
943 | - file.write(' -I$(MA5_BASE)' + \ |
944 | - '/tools/MCatNLO-utilities/MCatNLO/include') |
945 | + options = [] |
946 | + options.extend(['-Wall','-O3','-I./','-I./SampleAnalyzer/','-I$(MA5_BASE)/tools/','-I'+self.main.configLinux.root_inc_path]) |
947 | if self.libZIP: |
948 | - file.write(' -DZIP_USE') |
949 | + options.extend(['-DZIP_USE']) |
950 | if self.libDelphes: |
951 | - file.write(' -DDELPHES_USE') |
952 | + options.extend(['-DROOT_USE','-DDELPHES_USE']) |
953 | + if self.libDelfes: |
954 | + options.extend(['-DROOT_USE','-DDELFES_USE']) |
955 | if self.libFastjet: |
956 | - file.write(' -DFASTJET_USE') |
957 | - file.write(' $(CXXFASTJET)') |
958 | + options.extend(['-DROOT_USE','-DFASTJET_USE'])#,'$(shell fastjet-config --cxxflags --plugins)']) |
959 | + file.write('CXXFLAGS = '+' '.join(options)) |
960 | file.write('\n') |
961 | - file.write('LIBFLAGS = -LLib -lSampleAnalyzerBld -lGpad -lHist ' + |
962 | - '-lGraf -lGraf3d ' +\ |
963 | - '-lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lEG ' +\ |
964 | - '-lRIO -lNet -lThread -lCore -lCint -pthread -lm -ldl '+\ |
965 | - '-rdynamic') |
966 | + |
967 | + # Options for compilation : LIBFLAGS |
968 | + |
969 | + # - Root |
970 | + libs=[] |
971 | + libs.extend(['-L'+self.main.configLinux.root_lib_path, \ |
972 | + '-lGpad','-lHist','-lGraf','-lGraf3d','-lTree', \ |
973 | + '-lRint','-lPostscript','-lMatrix','-lPhysics', \ |
974 | + '-lMathCore','-lEG', '-lRIO','-lNet','-lThread', \ |
975 | + '-lCore','-lCint','-pthread','-lm','-ldl','-rdynamic']) |
976 | + |
977 | + # - SampleAnalyzer |
978 | + libs.extend(['-L$(MA5_BASE)/tools/SampleAnalyzer/Lib/','-lSampleAnalyzer']) |
979 | if self.libZIP: |
980 | - file.write(' -lz') |
981 | + libs.extend(['-L'+self.main.configLinux.zlib_lib_path,'-lz','-lzlib_for_ma5']) |
982 | if self.libDelphes: |
983 | - file.write(' -lDelphes') |
984 | + libs.extend(['-L'+self.main.configLinux.delphes_lib_paths[0],'-lDelphes','-ldelphes_for_ma5']) |
985 | + if self.libDelfes: |
986 | + libs.extend(['-L'+self.main.configLinux.delfes_lib_paths[0],'-lDelphes','-ldelfes_for_ma5']) |
987 | if self.fortran: |
988 | - file.write(' -lgfortran') |
989 | - if self.libFastjet: |
990 | - file.write(' $(FASTJETLIB)') |
991 | - if self.shwrmode!='': |
992 | - file.write(' -lShowering -lstdhep -lFmcfio') |
993 | - file.write('\n\n') |
994 | - |
995 | - # Files |
996 | - file.write('# Files\n') |
997 | - file.write('SRCS = $(wildcard Main/*.cpp)\n') |
998 | - file.write('HDRS = $(wildcard Main/*.h)\n') |
999 | - file.write('OBJS = $(SRCS:.cpp=.o)\n') |
1000 | - file.write('LIBS = Lib/libSampleAnalyzerBld.a') |
1001 | - if self.shwrmode!='': |
1002 | - file.write(' Lib/libShowering.a') |
1003 | - file.write('\n') |
1004 | - file.write('PRES = $(MA5_BASE)/tools/' +\ |
1005 | - 'SampleAnalyzer/Lib/libSampleAnalyzer.a') |
1006 | - file.write('\n') |
1007 | - |
1008 | - # Name of the executable |
1009 | - file.write('#Name of the executable\n') |
1010 | - file.write('PROGRAM = MadAnalysis5Job\n') |
1011 | - file.write('\n') |
1012 | + libs.extend(['-lgfortran']) |
1013 | + if self.libFastjet: |
1014 | + libs.extend(['$(shell fastjet-config --libs --plugins --rpath=no)','-lfastjet_for_ma5']) |
1015 | + file.write('LIBFLAGS = '+' '.join(libs)+'\n') |
1016 | + file.write('\n') |
1017 | + |
1018 | + # Files to process |
1019 | + file.write('# Files to process\n') |
1020 | + file.write('SRCS = $(wildcard Main/*.cpp)\n') |
1021 | + file.write('SRCS += $(wildcard SampleAnalyzer/Analyzer/*.cpp)\n') |
1022 | + file.write('HDRS = $(wildcard Main/*.h)\n') |
1023 | + file.write('HDRS += $(wildcard SampleAnalyzer/Analyzer/*.h)\n') |
1024 | + file.write('\n') |
1025 | + |
1026 | + # Files to generate |
1027 | + file.write('# Files to generate\n') |
1028 | + file.write('OBJS = $(SRCS:.cpp=.o)\n') |
1029 | + file.write('PROGRAM = MadAnalysis5job\n') |
1030 | + file.write('\n') |
1031 | + |
1032 | + # Lib to check |
1033 | + file.write('# Requirements to check before building\n') |
1034 | + libs=[] |
1035 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so') |
1036 | + if self.libZIP: |
1037 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so') |
1038 | + if self.libDelphes: |
1039 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so') |
1040 | + if self.libDelfes: |
1041 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so') |
1042 | + if self.libFastjet: |
1043 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so') |
1044 | + for ind in range(0,len(libs)): |
1045 | + file.write('REQUIRED'+str(ind+1)+' = '+libs[ind]+'\n') |
1046 | + file.write('\n') |
1047 | + |
1048 | |
1049 | # Defining colours for shell |
1050 | file.write('# Defining colours\n') |
1051 | @@ -703,16 +682,18 @@ |
1052 | file.write('\n') |
1053 | |
1054 | # Check library |
1055 | - file.write('# Check library\n') |
1056 | - file.write('library_check:\n') |
1057 | - file.write('ifeq ($(wildcard $(PRES)),)\n') |
1058 | - file.write('\t@echo -e $(RED)"The static library "$(PRES)" is not found"\n') |
1059 | - file.write('\t@echo -e $(RED)" 1) Please check that MadAnalysis 5 is installed in the folder : "$(MA5_BASE)\n') |
1060 | - file.write('\t@echo -e $(RED)" 2) Launch MadAnalysis 5 in normal mode in order to build this library."\n') |
1061 | - file.write('\t@echo -e $(NORMAL)\n') |
1062 | - file.write('\t@false\n') |
1063 | - file.write('endif\n') |
1064 | - file.write('\n') |
1065 | + if len(libs)!=0: |
1066 | + file.write('# Check library\n') |
1067 | + file.write('library_check:\n') |
1068 | + for ind in range(0,len(libs)): |
1069 | + file.write('ifeq ($(wildcard $(REQUIRED'+str(ind+1)+')),)\n') |
1070 | + file.write('\t@echo -e $(RED)"The shared library "$(REQUIRED'+str(ind+1)+')" is not found"\n') |
1071 | + file.write('\t@echo -e $(RED)" 1) Please check that MadAnalysis 5 is installed in the folder : "$(MA5_BASE)\n') |
1072 | + file.write('\t@echo -e $(RED)" 2) Launch MadAnalysis 5 in normal mode in order to build this library."\n') |
1073 | + file.write('\t@echo -e $(NORMAL)\n') |
1074 | + file.write('\t@false\n') |
1075 | + file.write('endif\n') |
1076 | + file.write('\n') |
1077 | |
1078 | # Header target |
1079 | file.write('# Header target\n') |
1080 | @@ -756,7 +737,7 @@ |
1081 | |
1082 | # Compile target |
1083 | file.write('# Compile target\n') |
1084 | - file.write('compile: $(LIBS) $(OBJS)\n') |
1085 | + file.write('compile: $(OBJS)\n') |
1086 | file.write('\n') |
1087 | |
1088 | # Object file target |
1089 | @@ -766,34 +747,18 @@ |
1090 | |
1091 | # Link target |
1092 | file.write('# Link target\n') |
1093 | - file.write('link: $(OBJS) $(LIBS)\n') |
1094 | - file.write('\t$(GCC) $(CXXFLAGS) $(OBJS) ') |
1095 | + file.write('link: $(OBJS)\n') |
1096 | + file.write('\t$(CXX) $(CXXFLAGS) $(OBJS) ') |
1097 | file.write('$(LIBFLAGS) -o $(PROGRAM)\n') |
1098 | file.write('\n') |
1099 | |
1100 | - # Library to build |
1101 | - file.write('# SampleAnalyzer library target\n') |
1102 | - file.write('$(LIBS):\n') |
1103 | - file.write('\t@(cd SampleAnalyzer/ && $(MAKE))\n') |
1104 | - file.write('\n') |
1105 | - |
1106 | - # Library to build |
1107 | - if self.shwrmode!='': |
1108 | - file.write('# Showering library target\n') |
1109 | - file.write('Lib/libShowering.a:\n') |
1110 | - file.write('\t@(cd Showering/ && $(MAKE))\n') |
1111 | - file.write('\n') |
1112 | - |
1113 | # Clean target |
1114 | file.write('# Clean target\n') |
1115 | file.write('clean: clean_header do_clean\n') |
1116 | file.write('\n') |
1117 | file.write('# Do clean target\n') |
1118 | file.write('do_clean: \n') |
1119 | - file.write('\t@(cd SampleAnalyzer/ && $(MAKE) $@)\n') |
1120 | - if self.shwrmode!='': |
1121 | - file.write('\t@(cd Showering/ && $(MAKE) $@)\n') |
1122 | - file.write('\t@rm -f $(OBJS) $(LIBS)\n') |
1123 | + file.write('\t@rm -f $(OBJS)\n') |
1124 | file.write('\n') |
1125 | |
1126 | # Mr Proper target |
1127 | @@ -802,24 +767,21 @@ |
1128 | file.write('\n') |
1129 | file.write('# Do Mr Proper target \n') |
1130 | file.write('do_mrproper: do_clean\n') |
1131 | - file.write('\t@(cd SampleAnalyzer/ && $(MAKE) $@)\n') |
1132 | - if self.shwrmode!='': |
1133 | - file.write('\t@(cd Showering/ && $(MAKE) $@)\n') |
1134 | file.write('\t@rm -f $(PROGRAM) Log/compilation.log' + \ |
1135 | - ' linking.log *~ */*~ \n') |
1136 | + ' Log/linking.log Log/cleanup.log Log/mrproper.log *~ */*~ */*~ \n') |
1137 | file.write('\n') |
1138 | |
1139 | # Phony target |
1140 | file.write('# Phony target\n') |
1141 | - file.write('.PHONY: do_clean header link_header compile_header $(LIBS)\n') |
1142 | + file.write('.PHONY: do_clean header link_header compile_header\n') |
1143 | file.write('\n') |
1144 | |
1145 | # Closing the file |
1146 | file.close() |
1147 | |
1148 | - if not JobWriter.WriteSetupFile(True,self.path+'/Build/',self.ma5dir): |
1149 | + if not JobWriter.WriteSetupFile(True,self.path+'/Build/',self.ma5dir,True,self.main.configLinux,self.main.isMAC): |
1150 | return False |
1151 | - if not JobWriter.WriteSetupFile(False,self.path+'/Build/',self.ma5dir): |
1152 | + if not JobWriter.WriteSetupFile(False,self.path+'/Build/',self.ma5dir,True,self.main.configLinux,self.main.isMAC): |
1153 | return False |
1154 | |
1155 | return True |
1156 | @@ -855,7 +817,10 @@ |
1157 | |
1158 | |
1159 | @staticmethod |
1160 | - def WriteSetupFile(bash,path,ma5dir,MA5BASE=True): |
1161 | + def WriteSetupFile(bash,path,ma5dir,MA5BASE,configLinux,isMAC): |
1162 | + |
1163 | + # Variable to check at the end |
1164 | + toCheck=[] |
1165 | |
1166 | # Opening file in write-only mode |
1167 | if bash: |
1168 | @@ -904,59 +869,101 @@ |
1169 | if bash: |
1170 | file.write('export MA5_BASE=' + JobWriter.CleanPath(ma5dir)+'\n') |
1171 | else: |
1172 | - file.write('setenv MA5_BASE=' + JobWriter.CleanPath(ma5dir)+'\n') |
1173 | + file.write('setenv MA5_BASE ' + JobWriter.CleanPath(ma5dir)+'\n') |
1174 | + toCheck.append('MA5_BASE') |
1175 | file.write('\n') |
1176 | |
1177 | # Configuring PATH environment variable |
1178 | - file.write('# Configuring PATH environment variable\n') |
1179 | - if bash: |
1180 | - file.write('export PATH=' + JobWriter.CleanPath(os.environ['PATH'])+'\n') |
1181 | - else: |
1182 | - file.write('setenv PATH ' + JobWriter.CleanPath(os.environ['PATH'])+'\n') |
1183 | - file.write('\n') |
1184 | - |
1185 | - # Configuring LD_LIBRARY_PATH environment variable |
1186 | - file.write('# Configuring LD_LIBRARY_PATH environment variable\n') |
1187 | - if bash: |
1188 | - file.write('export LD_LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n') |
1189 | - else: |
1190 | - file.write('setenv LD_LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n') |
1191 | - file.write('\n') |
1192 | - |
1193 | - # Configuring LIBRARY_PATH environment variable |
1194 | - file.write('# Configuring LIBRARY_PATH environment variable\n') |
1195 | - if bash: |
1196 | - file.write('export LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n') |
1197 | - else: |
1198 | - file.write('setenv LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n') |
1199 | - file.write('\n') |
1200 | - |
1201 | - # Configuring DYLD_LIBRARY_PATH environment variable |
1202 | - file.write('# Configuring DYLD_LIBRARY_PATH environment variable\n') |
1203 | - if bash: |
1204 | - file.write('export DYLD_LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['DYLD_LIBRARY_PATH'])+'\n') |
1205 | - else: |
1206 | - file.write('setenv DYLD_LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['DYLD_LIBRARY_PATH'])+'\n') |
1207 | - file.write('\n') |
1208 | - |
1209 | - # Configuring CPLUS_INCLUDE_PATH environment variable |
1210 | - file.write('# Configuring CPLUS_INCLUDE_PATH environment variable\n') |
1211 | - if bash: |
1212 | - file.write('export CPLUS_INCLUDE_PATH=' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n') |
1213 | - else: |
1214 | - file.write('setenv CPLUS_INCLUDE_PATH ' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n') |
1215 | - file.write('\n') |
1216 | + if len(configLinux.toPATH)!=0: |
1217 | + file.write('# Configuring PATH environment variable\n') |
1218 | + if bash: |
1219 | + file.write('if [ $PATH ]; then\n') |
1220 | + file.write('export PATH=$PATH:' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n') |
1221 | + file.write('else\n') |
1222 | + file.write('export PATH=' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n') |
1223 | + file.write('fi\n') |
1224 | + else: |
1225 | + file.write('if ( $?PATH ) then\n') |
1226 | + file.write('setenv PATH "$PATH":' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n') |
1227 | + file.write('else\n') |
1228 | + file.write('setenv PATH ' + JobWriter.CleanPath(':'.join(configLinux.toPATH))+'\n') |
1229 | + file.write('endif\n') |
1230 | + toCheck.append('PATH') |
1231 | + file.write('\n') |
1232 | + |
1233 | + if len(configLinux.toLDPATH)!=0: |
1234 | + |
1235 | + # Configuring LD_LIBRARY_PATH environment variable |
1236 | + file.write('# Configuring LD_LIBRARY_PATH environment variable\n') |
1237 | + if bash: |
1238 | + file.write('if [ $LD_LIBRARY_PATH ]; then\n') |
1239 | + file.write('export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1240 | + file.write('else\n') |
1241 | + file.write('export LD_LIBRARY_PATH=' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1242 | + file.write('fi\n') |
1243 | + else: |
1244 | + file.write('if ( $?LD_LIBRARY_PATH ) then\n') |
1245 | + file.write('setenv LD_LIBRARY_PATH "$LD_LIBRARY_PATH":' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1246 | + file.write('else\n') |
1247 | + file.write('setenv LD_LIBRARY_PATH ' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1248 | + file.write('endif\n') |
1249 | + toCheck.append('LD_LIBRARY_PATH') |
1250 | + file.write('\n') |
1251 | + |
1252 | + # Configuring LIBRARY_PATH environment variable |
1253 | + #file.write('# Configuring LIBRARY_PATH environment variable\n') |
1254 | + #if bash: |
1255 | + # file.write('export LIBRARY_PATH=' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n') |
1256 | + #else: |
1257 | + # file.write('setenv LIBRARY_PATH ' + JobWriter.CleanPath(os.environ['LD_LIBRARY_PATH'])+'\n') |
1258 | + #file.write('\n') |
1259 | + |
1260 | + # Configuring DYLD_LIBRARY_PATH environment variable |
1261 | + if isMAC: |
1262 | + file.write('# Configuring DYLD_LIBRARY_PATH environment variable\n') |
1263 | + if bash: |
1264 | + file.write('if [ $DYLD_LIBRARY_PATH ]; then\n') |
1265 | + file.write('export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1266 | + file.write('else\n') |
1267 | + file.write('export DYLD_LIBRARY_PATH=' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1268 | + file.write('fi\n') |
1269 | + else: |
1270 | + file.write('if ( $?DYLD_LIBRARY_PATH ) then\n') |
1271 | + file.write('setenv DYLD_LIBRARY_PATH "$DYLD_LIBRARY_PATH":' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1272 | + file.write('else\n') |
1273 | + file.write('setenv DYLD_LIBRARY_PATH ' + JobWriter.CleanPath(':'.join(configLinux.toLDPATH))+'\n') |
1274 | + file.write('endif\n') |
1275 | + toCheck.append('DYLD_LIBRARY_PATH') |
1276 | + file.write('\n') |
1277 | + |
1278 | + # Configuring CPLUS_INCLUDE_PATH environment variable |
1279 | + #file.write('# Configuring CPLUS_INCLUDE_PATH environment variable\n') |
1280 | + #if bash: |
1281 | + # file.write('export CPLUS_INCLUDE_PATH=' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n') |
1282 | + #else: |
1283 | + # file.write('setenv CPLUS_INCLUDE_PATH ' + JobWriter.CleanPath(os.environ['CPLUS_INCLUDE_PATH'])+'\n') |
1284 | + #file.write('\n') |
1285 | |
1286 | # Checking that all environment variables are defined |
1287 | file.write('# Checking that all environment variables are defined\n') |
1288 | if bash: |
1289 | - file.write('if [[ $PATH && $LD_LIBRARY_PATH && $LIBRARY_PATH && $DYLD_LIBRARY_PATH && $CPLUS_INCLUDE_PATH ]]; then\n') |
1290 | + file.write('if [[ ') |
1291 | + for ind in range(0,len(toCheck)): |
1292 | + if ind!=0: |
1293 | + file.write(' && ') |
1294 | + file.write('$'+toCheck[ind]) |
1295 | + file.write(' ]]; then\n') |
1296 | file.write('echo -e $YELLOW"'+StringTools.Fill('-',56)+'"\n') |
1297 | file.write('echo -e "'+StringTools.Center('Your environment is properly configured for MA5',56)+'"\n') |
1298 | file.write('echo -e "'+StringTools.Fill('-',56)+'"$NORMAL\n') |
1299 | file.write('fi\n') |
1300 | else: |
1301 | - file.write('if ( $?PATH && $?LD_LIBRARY_PATH && $?LIBRARY_PATH && $?DYLD_LIBRARY_PATH && $?CPLUS_INCLUDE_PATH) then\n') |
1302 | + file.write('if ( \n') |
1303 | + for ind in range(0,len(toCheck)): |
1304 | + if ind!=0: |
1305 | + file.write(' && ') |
1306 | + file.write('$?'+toCheck[ind]) |
1307 | + file.write(' ) then\n') |
1308 | file.write('echo $YELLOW"'+StringTools.Fill('-',56)+'"\n') |
1309 | file.write('echo "'+StringTools.Center('Your environment is properly configured for MA5',56)+'"\n') |
1310 | file.write('echo "'+StringTools.Fill('-',56)+'"$NORMAL\n') |
1311 | @@ -972,33 +979,94 @@ |
1312 | |
1313 | return True |
1314 | |
1315 | + |
1316 | def CompileJob(self): |
1317 | - if self.resubmit: |
1318 | - res=commands.getstatusoutput("cd "\ |
1319 | - +self.path+"/Build/;"\ |
1320 | - +" make mrproper") |
1321 | - |
1322 | - res=commands.getstatusoutput("cd "\ |
1323 | - +self.path+"/Build/;"\ |
1324 | - +" make compile > Log/compilation.log 2>&1") |
1325 | - if res[0]==0: |
1326 | - return True |
1327 | - else: |
1328 | - logging.error("errors occured during compilation. " +\ |
1329 | - "For more details, see the file :") |
1330 | - logging.error(" "+self.path+"/Build/Log/compilation.log") |
1331 | - return False |
1332 | + |
1333 | + # folder |
1334 | + folder = self.path+'/Build' |
1335 | + |
1336 | + # log file name |
1337 | + logfile = folder+'/Log/compilation.log' |
1338 | + |
1339 | + # shell command |
1340 | + commands = ['make','compile'] |
1341 | + |
1342 | + # call |
1343 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1344 | + |
1345 | + # return result |
1346 | + if not result: |
1347 | + logging.error('impossible to compile the project. For more details, see the log file:') |
1348 | + logging.error(logfile) |
1349 | + |
1350 | + return result |
1351 | + |
1352 | + |
1353 | + def MrproperJob(self): |
1354 | + |
1355 | + # folder |
1356 | + folder = self.path+'/Build' |
1357 | + |
1358 | + # log file name |
1359 | + logfile = folder+'/Log/mrproper.log' |
1360 | + |
1361 | + # shell command |
1362 | + commands = ['make','mrproper'] |
1363 | + |
1364 | + # call |
1365 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1366 | + |
1367 | + # return result |
1368 | + if not result: |
1369 | + logging.error('impossible to clean the project. For more details, see the log file:') |
1370 | + logging.error(logfile) |
1371 | + |
1372 | + return result |
1373 | + |
1374 | + |
1375 | + def MrproperJob(self): |
1376 | + |
1377 | + # folder |
1378 | + folder = self.path+'/Build' |
1379 | + |
1380 | + # log file name |
1381 | + logfile = folder+'/Log/mrproper.log' |
1382 | + |
1383 | + # shell command |
1384 | + commands = ['make','mrproper'] |
1385 | + |
1386 | + # call |
1387 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1388 | + |
1389 | + # return result |
1390 | + if not result: |
1391 | + logging.error('impossible to clean the project. For more details, see the log file:') |
1392 | + logging.error(logfile) |
1393 | + |
1394 | + return result |
1395 | + |
1396 | |
1397 | def LinkJob(self): |
1398 | - res=commands.getstatusoutput("cd "\ |
1399 | - +self.path+"/Build/;"\ |
1400 | - +" make link > Log/linking.log 2>&1") |
1401 | - if res[0]==0: |
1402 | - return True |
1403 | - else: |
1404 | - logging.error("errors occured during compilation. For more details, see the file :") |
1405 | - logging.error(" "+self.path+"/Build/Log/linking.log") |
1406 | - return False |
1407 | + |
1408 | + # folder |
1409 | + folder = self.path+'/Build' |
1410 | + |
1411 | + # log file name |
1412 | + logfile = folder+'/Log/linking.log' |
1413 | + |
1414 | + # shell command |
1415 | + commands = ['make','link'] |
1416 | + |
1417 | + # call |
1418 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1419 | + |
1420 | + # return result |
1421 | + if not result: |
1422 | + logging.error('impossible to link the project. For more details, see the log file:') |
1423 | + logging.error(logfile) |
1424 | + |
1425 | + return result |
1426 | + |
1427 | |
1428 | def WriteHistory(self,history,firstdir): |
1429 | file = open(self.path+"/history.ma5","w") |
1430 | @@ -1029,6 +1097,7 @@ |
1431 | file.write("\n") |
1432 | file.close() |
1433 | |
1434 | + |
1435 | def RunJob(self,dataset): |
1436 | |
1437 | # Getting the dataset name |
1438 | @@ -1038,23 +1107,26 @@ |
1439 | if not os.path.isdir(self.path+"/Output/"+name): |
1440 | os.mkdir(self.path+"/Output/"+name) |
1441 | |
1442 | + # folder where the program is launched |
1443 | + folder = self.path+'/Output/'+name |
1444 | + |
1445 | + # shell command |
1446 | + commands = ['../../Build/MadAnalysis5job'] |
1447 | + |
1448 | # Weighted events |
1449 | - weighted_events="" |
1450 | if not dataset.weighted_events: |
1451 | - weighted_events=" --no_event_weight" |
1452 | + commands.append('--no_event_weight') |
1453 | |
1454 | # Release |
1455 | - release = ' --ma5_version="' + self.main.version + ';' + self.main.date + '"' |
1456 | - |
1457 | - # Running SampleAnalyzer |
1458 | - res=os.system('cd '\ |
1459 | - +self.path+'/Output/'+name+';'\ |
1460 | - +' ../../Build/'\ |
1461 | - +'MadAnalysis5Job '+weighted_events +\ |
1462 | - release +\ |
1463 | - ' ../../Input/'+name+'.list') |
1464 | - |
1465 | - return True |
1466 | + commands.append('--ma5_version="'+self.main.version+';'+self.main.date+'"') |
1467 | + |
1468 | + # Inputs |
1469 | + commands.append('../../Input/'+name+'.list') |
1470 | + |
1471 | + # Running SampleAnalyzer |
1472 | + result = ShellCommand.Execute(commands,folder) |
1473 | + |
1474 | + return result |
1475 | |
1476 | |
1477 | |
1478 | |
1479 | === modified file 'madanalysis/IOinterface/library_writer.py' |
1480 | --- madanalysis/IOinterface/library_writer.py 2013-06-14 15:26:04 +0000 |
1481 | +++ madanalysis/IOinterface/library_writer.py 2014-05-17 19:51:11 +0000 |
1482 | @@ -26,22 +26,27 @@ |
1483 | from madanalysis.IOinterface.folder_writer import FolderWriter |
1484 | from madanalysis.IOinterface.job_writer import JobWriter |
1485 | from madanalysis.core.string_tools import StringTools |
1486 | +from madanalysis.IOinterface.shell_command import ShellCommand |
1487 | import logging |
1488 | import shutil |
1489 | import os |
1490 | import commands |
1491 | +import subprocess |
1492 | + |
1493 | |
1494 | class LibraryWriter(): |
1495 | |
1496 | - def __init__(self,ma5dir,jobdir,libZIP,libFASTJET,forced,fortran,delphes): |
1497 | + def __init__(self,ma5dir,jobdir,libZIP,libFastJet,forced,fortran,delphes,delfes,main): |
1498 | self.ma5dir = ma5dir |
1499 | self.jobdir = jobdir |
1500 | self.path = os.path.normpath(ma5dir+"/tools/") |
1501 | self.libZIP = libZIP |
1502 | - self.libFASTJET = libFASTJET |
1503 | + self.libFastJet = libFastJet |
1504 | self.forced = forced |
1505 | self.fortran = fortran |
1506 | self.libDelphes = delphes |
1507 | + self.libDelfes = delfes |
1508 | + self.main = main |
1509 | |
1510 | def get_ncores(self): |
1511 | # Number of cores |
1512 | @@ -72,9 +77,211 @@ |
1513 | str(ncores)) |
1514 | return ncores |
1515 | |
1516 | + def get_ncores2(self): |
1517 | + # Number of cores |
1518 | + import multiprocessing |
1519 | + nmaxcores=multiprocessing.cpu_count() |
1520 | + logging.info(" How many cores for the compiling? default = max = " +\ |
1521 | + str(nmaxcores)+"") |
1522 | + |
1523 | + if not self.forced: |
1524 | + test=False |
1525 | + while(not test): |
1526 | + answer=raw_input(" Answer: ") |
1527 | + if answer=="": |
1528 | + test=True |
1529 | + ncores=nmaxcores |
1530 | + break |
1531 | + try: |
1532 | + ncores=int(answer) |
1533 | + except: |
1534 | + test=False |
1535 | + continue |
1536 | + if ncores<=nmaxcores and ncores>0: |
1537 | + test=True |
1538 | + |
1539 | + else: |
1540 | + ncores=nmaxcores |
1541 | + logging.info(" => Number of cores used for the compilation = " +\ |
1542 | + str(ncores)) |
1543 | + return ncores |
1544 | + |
1545 | + |
1546 | def Open(self): |
1547 | return FolderWriter.CreateDirectory(self.path,overwrite=True) |
1548 | |
1549 | + def WriteMakefileForInterfaces(self,package): |
1550 | + |
1551 | + # Open the file |
1552 | + try: |
1553 | + file = open(self.path + "/SampleAnalyzer/Interfaces/Makefile_" + package,"w") |
1554 | + except: |
1555 | + logging.error('impossible to write the file '+ self.path + "/SampleAnalyzer/Makefile_" + package) |
1556 | + return False |
1557 | + |
1558 | + # Header |
1559 | + file.write(StringTools.Fill('#',80)+'\n') |
1560 | + file.write('#'+StringTools.Center('MAKEFILE DEVOTED TO THE INTERFACE TO '+package.upper(),78)+'#\n') |
1561 | + file.write(StringTools.Fill('#',80)+'\n') |
1562 | + file.write('\n') |
1563 | + |
1564 | + # Options for C++ compilation |
1565 | + file.write('# Options for C++ compilation\n') |
1566 | + file.write('CXX = g++\n') |
1567 | + if package=='fastjet': |
1568 | + file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n') |
1569 | + file.write('CXXFLAGS = -Wall -O3 -DROOT_USE -fPIC -I'+self.main.configLinux.root_inc_path+' -I./../../') |
1570 | + if package=='zlib': |
1571 | + file.write(' -I'+self.main.configLinux.zlib_inc_path) |
1572 | + if package=='delphes': |
1573 | + for header in self.main.configLinux.delphes_inc_paths: |
1574 | + file.write(' -I'+header) |
1575 | + if package=='delfes': |
1576 | + for header in self.main.configLinux.delfes_inc_paths: |
1577 | + file.write(' -I'+header) |
1578 | + if package=='fastjet': |
1579 | + file.write(' $(CXXFASTJET)') |
1580 | + file.write('\n') |
1581 | + |
1582 | + # Options for C++ compilation |
1583 | + if self.fortran: |
1584 | + file.write('# Options for Fortran compilation\n') |
1585 | + file.write('FC = gfortran\n') |
1586 | + file.write('FCFLAGS = -Wall -O3 -fPIC\n') |
1587 | + file.write('\n') |
1588 | + |
1589 | + # Files for analyzers |
1590 | + file.write('# Files\n') |
1591 | + file.write('SRCS = $(wildcard '+package+'/*.cpp)\n') |
1592 | + file.write('HDRS = $(wildcard '+package+'/*.h)\n') |
1593 | + file.write('OBJS = $(SRCS:.cpp=.o)\n') |
1594 | + if self.fortran: |
1595 | + file.write('FORTRAN_SRCS = $(wildcard '+package+'/*.f)\n') |
1596 | + file.write('FORTRAN_OBJS = $(FORTRAN_SRCS:.f=.o)\n') |
1597 | + file.write('\n') |
1598 | + |
1599 | + # Name of the library |
1600 | + file.write('# Name of the library\n') |
1601 | + file.write('PROGRAM = '+package+'_for_ma5\n') |
1602 | + file.write('\n') |
1603 | + |
1604 | + # Defining colours for shell |
1605 | + file.write('# Defining colours\n') |
1606 | + file.write('GREEN = "\\\\033[1;32m"\n') |
1607 | + file.write('RED = "\\\\033[1;31m"\n') |
1608 | + file.write('PINK = "\\\\033[1;35m"\n') |
1609 | + file.write('BLUE = "\\\\033[1;34m"\n') |
1610 | + file.write('YELLOW = "\\\\033[1;33m"\n') |
1611 | + file.write('CYAN = "\\\\033[1;36m"\n') |
1612 | + file.write('NORMAL = "\\\\033[0;39m"\n') |
1613 | + file.write('\n') |
1614 | + |
1615 | + # All |
1616 | + file.write('# All target\n') |
1617 | + file.write('all: header compile_header compile link_header link\n') |
1618 | + file.write('\n') |
1619 | + |
1620 | + # Header target |
1621 | + file.write('# Header target\n') |
1622 | + file.write('header:\n') |
1623 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
1624 | + file.write('\t@echo -e "'+StringTools.Center('Building SampleAnalyzer library',50)+'"\n') |
1625 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
1626 | + file.write('\n') |
1627 | + |
1628 | + # Compile_header target |
1629 | + file.write('# Compile_header target\n') |
1630 | + file.write('compile_header:\n') |
1631 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
1632 | + file.write('\t@echo -e "'+StringTools.Center('Compilation',50)+'"\n') |
1633 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
1634 | + file.write('\n') |
1635 | + |
1636 | + # Linking_header target |
1637 | + file.write('# Link_header target\n') |
1638 | + file.write('link_header:\n') |
1639 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
1640 | + file.write('\t@echo -e "'+StringTools.Center('Final linking',50)+'"\n') |
1641 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
1642 | + file.write('\n') |
1643 | + |
1644 | + # Clean_header target |
1645 | + file.write('# clean_header target\n') |
1646 | + file.write('clean_header:\n') |
1647 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
1648 | + file.write('\t@echo -e "'+StringTools.Center('Removing intermediate files from building',50)+'"\n') |
1649 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
1650 | + file.write('\n') |
1651 | + |
1652 | + # Mrproper_header target |
1653 | + file.write('# mrproper_header target\n') |
1654 | + file.write('mrproper_header:\n') |
1655 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
1656 | + file.write('\t@echo -e "'+StringTools.Center('Cleaning all the project',50)+'"\n') |
1657 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
1658 | + file.write('\n') |
1659 | + |
1660 | + # Precompile |
1661 | + file.write('# Precompile target\n') |
1662 | + file.write('precompile:\n') |
1663 | + file.write('\n') |
1664 | + |
1665 | + # Precompile |
1666 | + file.write('# Compile target\n') |
1667 | + if self.fortran: |
1668 | + file.write('compile: precompile $(OBJS) $(FORTRAN_OBJS)\n') |
1669 | + else: |
1670 | + file.write('compile: precompile $(OBJS)\n') |
1671 | + file.write('\n') |
1672 | + |
1673 | + # Precompile |
1674 | + file.write('# Link target\n') |
1675 | + if self.fortran: |
1676 | + file.write('link: $(OBJS) $(FORTRAN_OBJS)\n') |
1677 | + if self.main.isMAC: |
1678 | + file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o ../Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n') |
1679 | + else: |
1680 | + file.write('\t$(CXX) -shared -o ../Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n') |
1681 | + else: |
1682 | + file.write('link: $(OBJS)\n') |
1683 | + if self.main.isMAC: |
1684 | + file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o ../Lib/lib$(PROGRAM).so $(OBJS)\n') |
1685 | + else: |
1686 | + file.write('\t$(CXX) -shared -o ../Lib/lib$(PROGRAM).so $(OBJS)\n') |
1687 | + file.write('\n') |
1688 | + |
1689 | + # Phony target |
1690 | + file.write('# Phony target\n') |
1691 | + file.write('.PHONY: do_clean header compile_header link_header\n') |
1692 | + file.write('\n') |
1693 | + |
1694 | + # Cleaning |
1695 | + file.write('# Clean target\n') |
1696 | + file.write('clean: clean_header do_clean\n') |
1697 | + file.write('\n') |
1698 | + file.write('# Do clean target\n') |
1699 | + file.write('do_clean: \n') |
1700 | + file.write('\t@rm -f $(OBJS)\n') |
1701 | + if self.fortran: |
1702 | + file.write('\t@rm -f $(FORTRAN_OBJS)\n') |
1703 | + file.write('\n') |
1704 | + |
1705 | + # Mr Proper |
1706 | + file.write('# Mr Proper target \n') |
1707 | + file.write('mrproper: mrproper_header do_mrproper\n') |
1708 | + file.write('\n') |
1709 | + file.write('# Do Mr Proper target \n') |
1710 | + file.write('do_mrproper: do_clean\n') |
1711 | + file.write('\t@rm -f ../Lib/lib$(PROGRAM).so\n') |
1712 | + file.write('\t@rm -f compilation.log linking.log cleanup.log mrproper.log *~ */*~\n') |
1713 | + file.write('\n') |
1714 | + |
1715 | + # Closing the file |
1716 | + file.close() |
1717 | + |
1718 | + return True |
1719 | + |
1720 | + |
1721 | def WriteMakefile(self,option=""): |
1722 | |
1723 | # Open the file |
1724 | @@ -88,23 +295,26 @@ |
1725 | |
1726 | # Compilators |
1727 | file.write('# Compilators\n') |
1728 | - file.write('GCC = g++\n') |
1729 | + file.write('CXX = g++\n') |
1730 | if self.fortran: |
1731 | file.write('FC = gfortran\n') |
1732 | file.write('\n') |
1733 | |
1734 | # Options for compilation |
1735 | file.write('# Options for compilation\n') |
1736 | - if self.libFASTJET: |
1737 | - file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n') |
1738 | - file.write('CXXFLAGS = -Wall -O3 $(shell root-config --cflags) -I./../') |
1739 | +# if self.libFastJet: |
1740 | +# file.write('CXXFASTJET = $(shell fastjet-config --cxxflags --plugins)\n') |
1741 | + # BENJ FIX file.write('CXXFLAGS = -Wall -O3 -fPIC $(shell root-config --cflags) -I./../') |
1742 | + file.write('CXXFLAGS = -Wall -O3 -DROOT_USE -fPIC -I'+self.main.configLinux.root_inc_path+' -I./../') |
1743 | if self.libZIP: |
1744 | file.write(' -DZIP_USE') |
1745 | if self.libDelphes: |
1746 | file.write(' -DDELPHES_USE') |
1747 | - if self.libFASTJET: |
1748 | + if self.libDelfes: |
1749 | + file.write(' -DDELFES_USE') |
1750 | + if self.libFastJet: |
1751 | file.write(' -DFASTJET_USE') |
1752 | - file.write(' $(CXXFASTJET)') |
1753 | + # file.write(' $(CXXFASTJET)') |
1754 | file.write('\n') |
1755 | if self.fortran: |
1756 | file.write('FC = gfortran\n') |
1757 | @@ -114,6 +324,7 @@ |
1758 | # Files for analyzers |
1759 | file.write('# Files\n') |
1760 | file.write('SRCS = $(wildcard */*.cpp)\n') |
1761 | +# file.write('SRCS += $(wildcard */*/*.cpp)\n') |
1762 | file.write('HDRS = $(wildcard */*.h)\n') |
1763 | file.write('OBJS = $(SRCS:.cpp=.o)\n') |
1764 | if self.fortran: |
1765 | @@ -199,10 +410,18 @@ |
1766 | file.write('# Link target\n') |
1767 | if self.fortran: |
1768 | file.write('link: $(OBJS) $(FORTRAN_OBJS)\n') |
1769 | - file.write('\tar -ruc Lib/lib$(PROGRAM).a $(OBJS) $(FORTRAN_OBJS)\n') |
1770 | + if self.main.isMAC: |
1771 | + file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n') |
1772 | + else: |
1773 | + file.write('\t$(CXX) -shared -o Lib/lib$(PROGRAM).so $(OBJS) $(FORTRAN_OBJS)\n') |
1774 | else: |
1775 | file.write('link: $(OBJS)\n') |
1776 | - file.write('\tar -ruc Lib/lib$(PROGRAM).a $(OBJS)\n') |
1777 | + if self.main.isMAC: |
1778 | + file.write('\t$(CXX) -shared -flat_namespace -dynamiclib -undefined suppress -o Lib/lib$(PROGRAM).so $(OBJS)\n') |
1779 | + else: |
1780 | + file.write('\t$(CXX) -shared -o Lib/lib$(PROGRAM).so $(OBJS)\n') |
1781 | + |
1782 | +# file.write('\tar -ruc Lib/lib$(PROGRAM).a $(OBJS)\n') |
1783 | file.write('\n') |
1784 | |
1785 | # Phony target |
1786 | @@ -216,7 +435,7 @@ |
1787 | file.write('\n') |
1788 | file.write('# Do clean target\n') |
1789 | file.write('do_clean: \n') |
1790 | - file.write('\t@rm -f $(OBJS) Reader/FACdict.*\n') |
1791 | + file.write('\t@rm -f $(OBJS)\n') |
1792 | file.write('\n') |
1793 | |
1794 | # Mr Proper |
1795 | @@ -225,54 +444,394 @@ |
1796 | file.write('\n') |
1797 | file.write('# Do Mr Proper target \n') |
1798 | file.write('do_mrproper: do_clean\n') |
1799 | - file.write('\t@rm -f Lib/lib$(PROGRAM).a\n') |
1800 | - file.write('\t@rm -f compilation.log linking.log cleanup.log *~ */*~\n') |
1801 | + file.write('\t@rm -f Lib/lib$(PROGRAM).so\n') |
1802 | + file.write('\t@rm -f compilation.log linking.log cleanup.log mrproper.log *~ */*~\n') |
1803 | file.write('\n') |
1804 | |
1805 | # Closing the file |
1806 | file.close() |
1807 | |
1808 | - JobWriter.WriteSetupFile(True,self.path+'/SampleAnalyzer',self.ma5dir,False) |
1809 | - JobWriter.WriteSetupFile(False,self.path+'/SampleAnalyzer',self.ma5dir,False) |
1810 | + JobWriter.WriteSetupFile(True,self.path+'/SampleAnalyzer',self.ma5dir,False,self.main.configLinux,self.main.isMAC) |
1811 | + JobWriter.WriteSetupFile(False,self.path+'/SampleAnalyzer',self.ma5dir,False,self.main.configLinux,self.main.isMAC) |
1812 | |
1813 | return True |
1814 | |
1815 | |
1816 | - def Compile(self): |
1817 | + def Compile(self,ncores,package,folder): |
1818 | + |
1819 | + # number of cores |
1820 | strcores='' |
1821 | - ncores = self.get_ncores() |
1822 | if ncores>1: |
1823 | strcores='-j'+str(ncores) |
1824 | - res=commands.getstatusoutput("cd "\ |
1825 | - +self.path+"/SampleAnalyzer/;"\ |
1826 | - +" make compile "+strcores+" > compilation.log 2>&1") |
1827 | - if res[0]==0: |
1828 | - return True |
1829 | - else: |
1830 | - logging.error("errors occured during compilation. For more details, see the file :") |
1831 | - logging.error(" "+self.path+"/SampleAnalyzer/compilation.log") |
1832 | - return False |
1833 | - |
1834 | - def Link(self): |
1835 | - res=commands.getstatusoutput("cd "\ |
1836 | - +self.path+"/SampleAnalyzer/;"\ |
1837 | - +" make link > linking.log 2>&1") |
1838 | - if res[0]==0: |
1839 | - return True |
1840 | - else: |
1841 | - logging.error("errors occured during compilation. For more details, see the file :") |
1842 | - logging.error(" "+self.path+"/SampleAnalyzer/linking.log") |
1843 | - return False |
1844 | - |
1845 | - |
1846 | - def Clean(self): |
1847 | - res=commands.getstatusoutput("cd "\ |
1848 | - +self.path+"/SampleAnalyzer/;"\ |
1849 | - +" make clean > cleanup.log 2>&1") |
1850 | - return True |
1851 | - |
1852 | - def MrProper(self): |
1853 | - res=commands.getstatusoutput("cd "\ |
1854 | - +self.path+"/SampleAnalyzer/;"\ |
1855 | - +" make mrproper > cleanup.log 2>&1") |
1856 | - return True |
1857 | + |
1858 | + # log file name |
1859 | + if package == 'SampleAnalyzer': |
1860 | + logfile = folder+'/compilation.log' |
1861 | + else: |
1862 | + logfile = folder+'/compilation_'+package+'.log' |
1863 | + |
1864 | + # makefile |
1865 | + if package == 'SampleAnalyzer': |
1866 | + makefile = 'Makefile' |
1867 | + else: |
1868 | + makefile = 'Makefile_'+package |
1869 | + |
1870 | + # shell command |
1871 | + commands = ['make','compile',strcores,'--file='+makefile] |
1872 | + |
1873 | + # call |
1874 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1875 | + |
1876 | + # return result |
1877 | + if not result: |
1878 | + logging.error('impossible to compile the project. For more details, see the log file:') |
1879 | + logging.error(logfile) |
1880 | + |
1881 | + return result |
1882 | + |
1883 | + |
1884 | + def Link(self,package,folder): |
1885 | + |
1886 | + # log file name |
1887 | + if package == 'SampleAnalyzer': |
1888 | + logfile = folder+'/linking.log' |
1889 | + else: |
1890 | + logfile = folder+'/linking_'+package+'.log' |
1891 | + |
1892 | + # makefile |
1893 | + if package == 'SampleAnalyzer': |
1894 | + makefile = 'Makefile' |
1895 | + else: |
1896 | + makefile = 'Makefile_'+package |
1897 | + |
1898 | + # shell command |
1899 | + commands = ['make','link','--file='+makefile] |
1900 | + |
1901 | + # call |
1902 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1903 | + |
1904 | + # return result |
1905 | + if not result: |
1906 | + logging.error('impossible to link the project. For more details, see the log file:') |
1907 | + logging.error(logfile) |
1908 | + |
1909 | + return result |
1910 | + |
1911 | + |
1912 | + def Clean(self,package,folder): |
1913 | + |
1914 | + # log file name |
1915 | + if package == 'SampleAnalyzer': |
1916 | + logfile = folder+'/cleanup.log' |
1917 | + else: |
1918 | + logfile = folder+'/cleanup_'+package+'.log' |
1919 | + |
1920 | + # makefile |
1921 | + if package == 'SampleAnalyzer': |
1922 | + makefile = 'Makefile' |
1923 | + else: |
1924 | + makefile = 'Makefile_'+package |
1925 | + |
1926 | + # shell command |
1927 | + commands = ['make','clean','--file='+makefile] |
1928 | + |
1929 | + # call |
1930 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1931 | + |
1932 | + # return result |
1933 | + if not result: |
1934 | + logging.error('impossible to clean the project. For more details, see the log file:') |
1935 | + logging.error(logfile) |
1936 | + |
1937 | + return result |
1938 | + |
1939 | + |
1940 | + def MrProper(self,package,folder): |
1941 | + |
1942 | + # log file name |
1943 | + if package == 'SampleAnalyzer': |
1944 | + logfile = folder+'/mrproper.log' |
1945 | + else: |
1946 | + logfile = folder+'/mrproper_'+package+'.log' |
1947 | + |
1948 | + # makefile |
1949 | + if package == 'SampleAnalyzer': |
1950 | + makefile = 'Makefile' |
1951 | + else: |
1952 | + makefile = 'Makefile_'+package |
1953 | + |
1954 | + # shell command |
1955 | + commands = ['make','mrproper','--file='+makefile] |
1956 | + |
1957 | + # call |
1958 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder) |
1959 | + |
1960 | + # return result |
1961 | + if not result: |
1962 | + logging.error('impossible to clean the project. For more details, see the log file:') |
1963 | + logging.error(logfile) |
1964 | + |
1965 | + return result |
1966 | + |
1967 | + |
1968 | + def Run(self,program,args,folder,silent=False): |
1969 | + |
1970 | + # shell command |
1971 | + commands = ['./'+program] |
1972 | + commands.extend(args) |
1973 | + |
1974 | + # logfile |
1975 | + logfile = folder+'/'+program+'.log' |
1976 | + |
1977 | + # call |
1978 | + result, out = ShellCommand.ExecuteWithLog(commands,logfile,folder,silent) |
1979 | + |
1980 | + # return result |
1981 | + if not result and not silent: |
1982 | + logging.error('impossible to run the project. For more details, see the log file:') |
1983 | + logging.error(logfile) |
1984 | + |
1985 | + return result |
1986 | + |
1987 | + |
1988 | + def CheckRun(self,logfile,silent=False): |
1989 | + |
1990 | + # Open |
1991 | + try: |
1992 | + input = open(logfile) |
1993 | + except: |
1994 | + logging.error('impossible to open the file:'+logfile) |
1995 | + return False |
1996 | + |
1997 | + end=False |
1998 | + begin=False |
1999 | + |
2000 | + # Loop over the logfile |
2001 | + for line in input: |
2002 | + line=line.lstrip() |
2003 | + line=line.rstrip() |
2004 | + if line=='BEGIN-SAMPLEANALYZER-TEST': |
2005 | + begin=True |
2006 | + elif line=='END-SAMPLEANALYZER-TEST': |
2007 | + end=True |
2008 | + |
2009 | + # Close |
2010 | + try: |
2011 | + input.close() |
2012 | + except: |
2013 | + logging.error('impossible to close the file:'+logfile) |
2014 | + return False |
2015 | + |
2016 | + # CrossCheck |
2017 | + if not (begin and end) and not silent: |
2018 | + logging.error('expected program output is not found. More details, see the log file:') |
2019 | + logging.error(logfile) |
2020 | + return False |
2021 | + |
2022 | + return True |
2023 | + |
2024 | + |
2025 | + def WriteMakefileForTest(self): |
2026 | + |
2027 | + # Open the file |
2028 | + filename = self.path + "/SampleAnalyzer/Test/Makefile_test" |
2029 | + try: |
2030 | + file = open(filename,"w") |
2031 | + except: |
2032 | + logging.error('impossible to write the file '+filenameself.path) |
2033 | + return False |
2034 | + |
2035 | + # Writing header |
2036 | + file.write(StringTools.Fill('#',80)+'\n') |
2037 | + file.write('#'+StringTools.Center('MAKEFILE FOR SAMPLEANALYZER TEST',78)+'#\n') |
2038 | + file.write(StringTools.Fill('#',80)+'\n') |
2039 | + file.write('\n') |
2040 | + |
2041 | + # Compilators |
2042 | + file.write('# Compilators\n') |
2043 | + file.write('CXX = g++\n') |
2044 | + file.write('\n') |
2045 | + |
2046 | + # Options for compilation : CXXFLAGS |
2047 | + file.write('# Options for compilation\n') |
2048 | + options = [] |
2049 | + options.extend(['-Wall','-O3','-I$(MA5_BASE)/tools/','-I'+self.main.configLinux.root_inc_path]) |
2050 | + if self.libZIP: |
2051 | + options.extend(['-DZIP_USE']) |
2052 | + if self.libDelphes: |
2053 | + options.extend(['-DROOT_USE','-DDELPHES_USE']) |
2054 | + if self.libDelfes: |
2055 | + options.extend(['-DROOT_USE','-DDELFES_USE']) |
2056 | + if self.libFastJet: |
2057 | + options.extend(['-DROOT_USE','-DFASTJET_USE']) |
2058 | + file.write('CXXFLAGS = '+' '.join(options)) |
2059 | + file.write('\n') |
2060 | + |
2061 | + # Options for compilation : LIBFLAGS |
2062 | + |
2063 | + # - Root |
2064 | + libs=[] |
2065 | + libs.extend(['-L'+self.main.configLinux.root_lib_path, \ |
2066 | + '-lGpad','-lHist','-lGraf','-lGraf3d','-lTree', \ |
2067 | + '-lRint','-lPostscript','-lMatrix','-lPhysics', \ |
2068 | + '-lMathCore','-lEG', '-lRIO','-lNet','-lThread', \ |
2069 | + '-lCore','-lCint','-pthread','-lm','-ldl','-rdynamic']) |
2070 | + |
2071 | + # - SampleAnalyzer |
2072 | + libs.extend(['-L$(MA5_BASE)/tools/SampleAnalyzer/Lib/','-lSampleAnalyzer']) |
2073 | + if self.libZIP: |
2074 | + libs.extend(['-L'+self.main.configLinux.zlib_lib_path,'-lz','-lzlib_for_ma5']) |
2075 | + if self.libDelphes: |
2076 | + libs.extend(['-L'+self.main.configLinux.delphes_lib_paths[0],'-lDelphes','-ldelphes_for_ma5']) |
2077 | + if self.libDelfes: |
2078 | + libs.extend(['-L'+self.main.configLinux.delfes_lib_paths[0],'-lDelphes','-ldelfes_for_ma5']) |
2079 | + if self.fortran: |
2080 | + libs.extend(['-lgfortran']) |
2081 | + if self.libFastJet: |
2082 | + libs.extend(['$(shell fastjet-config --libs --plugins --rpath=no)','-lfastjet_for_ma5']) |
2083 | + file.write('LIBFLAGS = '+' '.join(libs)+'\n') |
2084 | + file.write('\n') |
2085 | + |
2086 | + # Files to process |
2087 | + file.write('# Files to process\n') |
2088 | + file.write('SRCS = $(wildcard Test.cpp)\n') |
2089 | + file.write('\n') |
2090 | + |
2091 | + # Files to generate |
2092 | + file.write('# Files to generate\n') |
2093 | + file.write('OBJS = $(SRCS:.cpp=.o)\n') |
2094 | + file.write('PROGRAM = SampleAnalyzerTest\n') |
2095 | + file.write('\n') |
2096 | + |
2097 | + # Lib to check |
2098 | + file.write('# Requirements to check before building\n') |
2099 | + libs=[] |
2100 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so') |
2101 | + if self.libZIP: |
2102 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so') |
2103 | + if self.libDelphes: |
2104 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so') |
2105 | + if self.libDelfes: |
2106 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so') |
2107 | + if self.libFastJet: |
2108 | + libs.append('$(MA5_BASE)/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so') |
2109 | + for ind in range(0,len(libs)): |
2110 | + file.write('REQUIRED'+str(ind+1)+' = '+libs[ind]+'\n') |
2111 | + file.write('\n') |
2112 | + |
2113 | + |
2114 | + # Defining colours for shell |
2115 | + file.write('# Defining colours\n') |
2116 | + file.write('GREEN = "\\\\033[1;32m"\n') |
2117 | + file.write('RED = "\\\\033[1;31m"\n') |
2118 | + file.write('PINK = "\\\\033[1;35m"\n') |
2119 | + file.write('BLUE = "\\\\033[1;34m"\n') |
2120 | + file.write('YELLOW = "\\\\033[1;33m"\n') |
2121 | + file.write('CYAN = "\\\\033[1;36m"\n') |
2122 | + file.write('NORMAL = "\\\\033[0;39m"\n') |
2123 | + file.write('\n') |
2124 | + |
2125 | + # All target |
2126 | + file.write('# All target\n') |
2127 | + file.write('all: header library_check compile_header compile link_header link\n') |
2128 | + file.write('\n') |
2129 | + |
2130 | + # Check library |
2131 | + if len(libs)!=0: |
2132 | + file.write('# Check library\n') |
2133 | + file.write('library_check:\n') |
2134 | + for ind in range(0,len(libs)): |
2135 | + file.write('ifeq ($(wildcard $(REQUIRED'+str(ind+1)+')),)\n') |
2136 | + file.write('\t@echo -e $(RED)"The shared library "$(REQUIRED'+str(ind+1)+')" is not found"\n') |
2137 | + file.write('\t@echo -e $(RED)" 1) Please check that MadAnalysis 5 is installed in the folder : "$(MA5_BASE)\n') |
2138 | + file.write('\t@echo -e $(RED)" 2) Launch MadAnalysis 5 in normal mode in order to build this library."\n') |
2139 | + file.write('\t@echo -e $(NORMAL)\n') |
2140 | + file.write('\t@false\n') |
2141 | + file.write('endif\n') |
2142 | + file.write('\n') |
2143 | + |
2144 | + # Header target |
2145 | + file.write('# Header target\n') |
2146 | + file.write('header:\n') |
2147 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
2148 | + file.write('\t@echo -e "'+StringTools.Center('Building MA5 job',50)+'"\n') |
2149 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
2150 | + file.write('\n') |
2151 | + |
2152 | + # Compile_header target |
2153 | + file.write('# Compile_header target\n') |
2154 | + file.write('compile_header:\n') |
2155 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
2156 | + file.write('\t@echo -e "'+StringTools.Center('Compilation',50)+'"\n') |
2157 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
2158 | + file.write('\n') |
2159 | + |
2160 | + # Linking_header target |
2161 | + file.write('# Link_header target\n') |
2162 | + file.write('link_header:\n') |
2163 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
2164 | + file.write('\t@echo -e "'+StringTools.Center('Final linking',50)+'"\n') |
2165 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
2166 | + file.write('\n') |
2167 | + |
2168 | + # Clean_header target |
2169 | + file.write('# clean_header target\n') |
2170 | + file.write('clean_header:\n') |
2171 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
2172 | + file.write('\t@echo -e "'+StringTools.Center('Removing intermediate files from building',50)+'"\n') |
2173 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
2174 | + file.write('\n') |
2175 | + |
2176 | + # Mrproper_header target |
2177 | + file.write('# mrproper_header target\n') |
2178 | + file.write('mrproper_header:\n') |
2179 | + file.write('\t@echo -e $(YELLOW)"'+StringTools.Fill('-',50)+'"\n') |
2180 | + file.write('\t@echo -e "'+StringTools.Center('Cleaning all the project',50)+'"\n') |
2181 | + file.write('\t@echo -e "'+StringTools.Fill('-',50)+'"$(NORMAL)\n') |
2182 | + file.write('\n') |
2183 | + |
2184 | + # Compile target |
2185 | + file.write('# Compile target\n') |
2186 | + file.write('compile: $(OBJS)\n') |
2187 | + file.write('\n') |
2188 | + |
2189 | + # Object file target |
2190 | + file.write('# Object file target\n') |
2191 | + file.write('$(OBJS): \n') |
2192 | + file.write('\n') |
2193 | + |
2194 | + # Link target |
2195 | + file.write('# Link target\n') |
2196 | + file.write('link: $(OBJS)\n') |
2197 | + file.write('\t$(CXX) $(CXXFLAGS) $(OBJS) $(LIBFLAGS) -o $(PROGRAM)\n') |
2198 | + file.write('\n') |
2199 | + |
2200 | + # Clean target |
2201 | + file.write('# Clean target\n') |
2202 | + file.write('clean: clean_header do_clean\n') |
2203 | + file.write('\n') |
2204 | + file.write('# Do clean target\n') |
2205 | + file.write('do_clean: \n') |
2206 | + file.write('\t@rm -f $(OBJS)\n') |
2207 | + file.write('\n') |
2208 | + |
2209 | + # Mr Proper target |
2210 | + file.write('# Mr Proper target \n') |
2211 | + file.write('mrproper: mrproper_header do_mrproper\n') |
2212 | + file.write('\n') |
2213 | + file.write('# Do Mr Proper target \n') |
2214 | + file.write('do_mrproper: do_clean\n') |
2215 | + file.write('\t@rm -f $(PROGRAM) compilation_test.log' + \ |
2216 | + ' linking_test.log cleanup_test.log mrproper_test.log *~ */*~ */*~ \n') |
2217 | + file.write('\n') |
2218 | + |
2219 | + # Phony target |
2220 | + file.write('# Phony target\n') |
2221 | + file.write('.PHONY: do_clean header link_header compile_header\n') |
2222 | + file.write('\n') |
2223 | + |
2224 | + # Closing the file |
2225 | + file.close() |
2226 | + |
2227 | + return True |
2228 | + |
2229 | |
2230 | === added file 'madanalysis/IOinterface/shell_command.py' |
2231 | --- madanalysis/IOinterface/shell_command.py 1970-01-01 00:00:00 +0000 |
2232 | +++ madanalysis/IOinterface/shell_command.py 2014-05-17 19:51:11 +0000 |
2233 | @@ -0,0 +1,82 @@ |
2234 | +################################################################################ |
2235 | +# |
2236 | +# Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks |
2237 | +# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr> |
2238 | +# |
2239 | +# This file is part of MadAnalysis 5. |
2240 | +# Official website: <https://launchpad.net/madanalysis5> |
2241 | +# |
2242 | +# MadAnalysis 5 is free software: you can redistribute it and/or modify |
2243 | +# it under the terms of the GNU General Public License as published by |
2244 | +# the Free Software Foundation, either version 3 of the License, or |
2245 | +# (at your option) any later version. |
2246 | +# |
2247 | +# MadAnalysis 5 is distributed in the hope that it will be useful, |
2248 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2249 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2250 | +# GNU General Public License for more details. |
2251 | +# |
2252 | +# You should have received a copy of the GNU General Public License |
2253 | +# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/> |
2254 | +# |
2255 | +################################################################################ |
2256 | + |
2257 | + |
2258 | +import logging |
2259 | +import shutil |
2260 | +import os |
2261 | +import commands |
2262 | +import subprocess |
2263 | + |
2264 | + |
2265 | +class ShellCommand(): |
2266 | + |
2267 | + @staticmethod |
2268 | + def ExecuteWithLog(theCommands,logfile,path,silent=False): |
2269 | + |
2270 | + # Open the log file |
2271 | + try: |
2272 | + output = open(logfile,'w') |
2273 | + except: |
2274 | + if not silent: |
2275 | + logging.error('impossible to write the file '+logfile) |
2276 | + return False, None |
2277 | + |
2278 | + # Launching the commands |
2279 | + try: |
2280 | + result=subprocess.Popen(theCommands, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=path) |
2281 | + except: |
2282 | + if not silent: |
2283 | + logging.error('impossible to execute the commands: '+' '.join(theCommands)) |
2284 | + return False, None |
2285 | + |
2286 | + # Getting stdout |
2287 | + out, err = result.communicate() |
2288 | + if out!=None: |
2289 | + for line in out: |
2290 | + output.write(line) |
2291 | + |
2292 | + # Close the log file |
2293 | + output.close() |
2294 | + |
2295 | + # Return results |
2296 | + return (result.returncode==0), out |
2297 | + |
2298 | + |
2299 | + |
2300 | + @staticmethod |
2301 | + def Execute(theCommands,path): |
2302 | + |
2303 | + # Launching the commands |
2304 | + try: |
2305 | + result=subprocess.Popen(theCommands, cwd=path) |
2306 | + except: |
2307 | + logging.error('impossible to execute the commands: '+' '.join(theCommands)) |
2308 | + return False, None |
2309 | + |
2310 | + # Getting stdout |
2311 | + out, err = result.communicate() |
2312 | + |
2313 | + # Return results |
2314 | + return (result.returncode==0) |
2315 | + |
2316 | |
2317 | === modified file 'madanalysis/UpdateNotes.txt' |
2318 | --- madanalysis/UpdateNotes.txt 2013-10-29 09:21:58 +0000 |
2319 | +++ madanalysis/UpdateNotes.txt 2014-05-17 19:51:11 +0000 |
2320 | @@ -1,5 +1,89 @@ |
2321 | Update notes for MadAnalysis 5 (in reverse time order) |
2322 | |
2323 | +123 1.1.10.35 (2014/05/09) fuks: Still a missing foot->footer replacement |
2324 | + |
2325 | +122 1.1.10.34 (2014/05/07) fuks: saffoot -> saffooter |
2326 | + |
2327 | +116 1.1.10.33 (2014/04/30) fuks: Moving ToRestFrame to the MCParticleFormat class |
2328 | + |
2329 | +115 1.1.10.32 (2014/04/29) fuks: Splitting the physics services in subcategories |
2330 | + |
2331 | +114 1.1.10.31 (2014/04/22) fuks: Renaming Daughter into daughter in sampleanalyzer |
2332 | + |
2333 | +113 1.1.10.30 (2014/03/10) fuks: Fixing bug in the mewanalyzer script |
2334 | + |
2335 | +112 1.1.10.29 (2014/03/10) fuks: updating the newanalyzer script |
2336 | + |
2337 | +110 1.1.10.28 (2014/02/11) fuks: Fixing minor bug when providing the wrong number of arguments to an |
2338 | + observable (thanks to B.Dumont) |
2339 | + |
2340 | +109 1.1.10.27 (2014/02/11) fuks: Removing the old filter infrastructure |
2341 | + |
2342 | +108 1.1.10.26 (2014/02/11) fuks: Updating the expert mode: adding new analyses to an existing |
2343 | + template directory |
2344 | + |
2345 | +107 1.1.10.25 (2014/02/06) fuks: Creation of an analysis template - changes in the file naming |
2346 | + |
2347 | +106 1.1.10.24 (2014/02/06) fuks: problems with wgetting fastjet on some machines |
2348 | + |
2349 | +105 1.1.10.23 (2014/02/05) fuks: Few bugs corrected in the mt2w implementation (thanks to Jeremy |
2350 | + Bernon and Beranger Dumont) |
2351 | + |
2352 | +104 1.1.10.22 (2014/01/31) fuks: Implementation of the MT2W variable + sorting functions |
2353 | + |
2354 | +103 1.1.10.21 (2014/01/29) fuks: new methods :dphi_0_pi and sphi_0_2pi (both at the python and c++ |
2355 | + levels) |
2356 | + |
2357 | +102 1.1.10.20 (2014/01/28) fuks: Cleaning conflicts between delfes and delphes |
2358 | + |
2359 | +97 1.1.10.19 (2014/01/17) bfuks: Beranger's suggestion for a IsSurviving function to be called from |
2360 | + the manager |
2361 | + |
2362 | +96 1.1.10.18 (2014/01/17) bfuks: Beranger's suggestion for adding cuts/histos with one single RS: |
2363 | + added |
2364 | + |
2365 | +95 1.1.10.17 (2014/01/16) bfuks: Bug with the "AllSurviving" function fixed |
2366 | + |
2367 | +90 1.1.10.16 (2014/01/09) bfuks: Charge is now a int and not a float anymore. Small related fixes |
2368 | + |
2369 | +89 1.1.10.15 (2014/01/06) bfuks: small bug fix |
2370 | + |
2371 | +88 1.1.10.14 (2013/12/12) bfuks: Check added in the case one wants to fill a histo for which some |
2372 | + (but not all) SRs fails the cuts applied so far (thanks to Beranger) |
2373 | + |
2374 | +87 1.1.10.13 (2013/12/12) bfuks: Extended expert mode output: cleaning (cf. discussions with Chris) |
2375 | + |
2376 | +86 1.1.10.12 (2013/12/11) bfuks: Updating output format for the histo headers (extended expert mode) |
2377 | + |
2378 | +85 1.1.10.11 (2013/12/05) bfuks: Second Bug fix related to question #233529 |
2379 | + |
2380 | +84 1.1.10.10 (2013/12/04) bfuks: Bug fix related to question #233529 |
2381 | + |
2382 | +83 1.1.10.9 (2013/12/03) bfuks: Small bug in the MT2 routine (thanks to J. Bernon) |
2383 | + |
2384 | +81 1.1.10.8 (2013/12/02) bfuks: New output structure dedicated to multianalyses; few bug fixes |
2385 | + |
2386 | +80 1.1.10.7 (2013/11/29) bfuks: Bug in jetclustering + allowing for defining invisible particles via |
2387 | + the invisible multiparticle in the reco mode |
2388 | + |
2389 | +79 1.1.10.6 (2013/11/28) bfuks: Problem with the MET in the simplified LHE format used by madgraph |
2390 | + (question #239543) |
2391 | + |
2392 | +78 1.1.10.5 (2013/11/28) bfuks: Fixing clang issue (bug #1250337) |
2393 | + |
2394 | +76 1.1.10.4 (2013/11/28) bfuks: updating the versioning for the development version |
2395 | + |
2396 | +75 1.1.10.3 (2013/11/28) bfuks: MT2 variable + macos change of stdc++ library + cleaning of the |
2397 | + welcome message |
2398 | + |
2399 | +74 1.1.10.2 (2013/11/19) bfuks: MultiAnalyses are now possible in the expert mode; output still to |
2400 | + be implemented |
2401 | + |
2402 | +72 1.1.10.1 (2013/11/14) bfuks: small modifications in the view of including the signal region |
2403 | + object |
2404 | + |
2405 | +71 1.1.10.0 (2013/11/04) bfuks: use of names with the counters |
2406 | + |
2407 | 80 1.1.9 (2013/10/28) ma5team: - adding Delphes interface + CMS/ATLAS cards |
2408 | - adding Delphes cards including pile-up |
2409 | - the electric charge is now an integer at the reco level |
2410 | |
2411 | === added file 'madanalysis/configuration/delfes_configuration.py' |
2412 | --- madanalysis/configuration/delfes_configuration.py 1970-01-01 00:00:00 +0000 |
2413 | +++ madanalysis/configuration/delfes_configuration.py 2014-05-17 19:51:11 +0000 |
2414 | @@ -0,0 +1,156 @@ |
2415 | +################################################################################ |
2416 | +# |
2417 | +# Copyright (C) 2012-2013 Eric Conte, Benjamin Fuks |
2418 | +# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr> |
2419 | +# |
2420 | +# This file is part of MadAnalysis 5. |
2421 | +# Official website: <https://launchpad.net/madanalysis5> |
2422 | +# |
2423 | +# MadAnalysis 5 is free software: you can redistribute it and/or modify |
2424 | +# it under the terms of the GNU General Public License as published by |
2425 | +# the Free Software Foundation, either version 3 of the License, or |
2426 | +# (at your option) any later version. |
2427 | +# |
2428 | +# MadAnalysis 5 is distributed in the hope that it will be useful, |
2429 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2430 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2431 | +# GNU General Public License for more details. |
2432 | +# |
2433 | +# You should have received a copy of the GNU General Public License |
2434 | +# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/> |
2435 | +# |
2436 | +################################################################################ |
2437 | + |
2438 | + |
2439 | +from madanalysis.enumeration.ma5_running_type import MA5RunningType |
2440 | +import os |
2441 | +import logging |
2442 | + |
2443 | +class DelfesConfiguration: |
2444 | + |
2445 | + userVariables = { "detector" : ["cms","atlas"],\ |
2446 | + "output": ["true","false"],\ |
2447 | + "pileup": ["none"] } |
2448 | + |
2449 | + def __init__(self): |
2450 | + self.detector = "cms" |
2451 | + self.output = True |
2452 | + self.pileup = "" |
2453 | + self.card = "" |
2454 | + self.SetCard() |
2455 | + |
2456 | + def SetCard(self): |
2457 | + if self.detector=='cms' and self.pileup=="": |
2458 | + self.card = "delfes_card_CMS.tcl" |
2459 | + elif self.detector=='cms' and self.pileup!="": |
2460 | + self.card = "delfes_card_CMS_PileUp.tcl" |
2461 | + elif self.detector=='atlas' and self.pileup=="": |
2462 | + self.card = "delfes_card_ATLAS.tcl" |
2463 | + elif self.detector=='atlas' and self.pileup!="": |
2464 | + self.card = "delfes_card_ATLAS_PileUp.tcl" |
2465 | + |
2466 | + def Display(self): |
2467 | + self.user_DisplayParameter("detector") |
2468 | + self.user_DisplayParameter("output") |
2469 | + self.user_DisplayParameter("pileup") |
2470 | + |
2471 | + |
2472 | + def user_DisplayParameter(self,parameter): |
2473 | + if parameter=="detector": |
2474 | + logging.info(" detector : "+self.detector) |
2475 | + return |
2476 | + elif parameter=="output": |
2477 | + if self.output: |
2478 | + msg="true" |
2479 | + else: |
2480 | + msg="false" |
2481 | + logging.info(" ROOT output : "+msg) |
2482 | + return |
2483 | + elif parameter=="pileup": |
2484 | + if self.pileup=="": |
2485 | + msg="none" |
2486 | + else: |
2487 | + msg='"'+self.pileup+'"' |
2488 | + logging.info(" pile-up source = "+msg) |
2489 | + |
2490 | + def SampleAnalyzerConfigString(self): |
2491 | + mydict = {} |
2492 | + if self.output: |
2493 | + mydict['output'] = '1' |
2494 | + else: |
2495 | + mydict['output'] = '0' |
2496 | + return mydict |
2497 | + |
2498 | + def user_SetParameter(self,parameter,value,datasets,level): |
2499 | + |
2500 | + # algorithm |
2501 | + if parameter=="detector": |
2502 | + |
2503 | + if value.lower()=="cms": |
2504 | + self.detector=value |
2505 | + self.SetCard() |
2506 | + elif value.lower()=="atlas": |
2507 | + self.detector=value |
2508 | + self.SetCard() |
2509 | + else: |
2510 | + logging.error("algorithm called '"+value+"' is not found.") |
2511 | + return |
2512 | + |
2513 | + # output |
2514 | + elif parameter=="output": |
2515 | + |
2516 | + if value.lower()=="true": |
2517 | + self.output = True |
2518 | + elif value.lower()=="false": |
2519 | + self.output = False |
2520 | + else: |
2521 | + logging.error("allowed values for output are: true false") |
2522 | + return |
2523 | + |
2524 | + # pileup |
2525 | + elif parameter=="pileup": |
2526 | + quoteTag=False |
2527 | + if value.startswith("'") and value.endswith("'"): |
2528 | + quoteTag=True |
2529 | + if value.startswith('"') and value.endswith('"'): |
2530 | + quoteTag=True |
2531 | + if quoteTag: |
2532 | + value=value[1:-1] |
2533 | + valuemin = value.lower() |
2534 | + |
2535 | + # none |
2536 | + if valuemin=="none": |
2537 | + self.pileup = "" |
2538 | + self.SetCard() |
2539 | + |
2540 | + # .pileup |
2541 | + elif valuemin.endswith(".pileup"): |
2542 | + if not os.path.isfile(value): |
2543 | + logging.error('File called "'+value+'" is not found') |
2544 | + return |
2545 | + self.pileup = value |
2546 | + self.SetCard() |
2547 | + return |
2548 | + |
2549 | + # other case: error |
2550 | + else: |
2551 | + logging.error("The file format for the pile-up source is not known. Only files with .pileup extension can be used.") |
2552 | + return False |
2553 | + |
2554 | + else: |
2555 | + logging.error("parameter called '"+parameter+"' does not exist") |
2556 | + return |
2557 | + |
2558 | + |
2559 | + def user_GetParameters(self): |
2560 | + return DelfesConfiguration.userVariables.keys() |
2561 | + |
2562 | + |
2563 | + def user_GetValues(self,variable): |
2564 | + table = [] |
2565 | + try: |
2566 | + table.extend(DelfesConfiguration.userVariables[variable]) |
2567 | + except: |
2568 | + pass |
2569 | + return table |
2570 | + |
2571 | |
2572 | === modified file 'madanalysis/configuration/delphes_configuration.py' |
2573 | --- madanalysis/configuration/delphes_configuration.py 2013-10-27 21:05:18 +0000 |
2574 | +++ madanalysis/configuration/delphes_configuration.py 2014-05-17 19:51:11 +0000 |
2575 | @@ -36,7 +36,18 @@ |
2576 | self.detector = "cms" |
2577 | self.output = True |
2578 | self.pileup = "" |
2579 | + self.card = "" |
2580 | + self.SetCard() |
2581 | |
2582 | + def SetCard(self): |
2583 | + if self.detector=='cms' and self.pileup=="": |
2584 | + self.card = "delphes_card_CMS.tcl" |
2585 | + elif self.detector=='cms' and self.pileup!="": |
2586 | + self.card = "delphes_card_CMS_PileUp.tcl" |
2587 | + elif self.detector=='atlas' and self.pileup=="": |
2588 | + self.card = "delphes_card_ATLAS.tcl" |
2589 | + elif self.detector=='atlas' and self.pileup!="": |
2590 | + self.card = "delphes_card_ATLAS_PileUp.tcl" |
2591 | |
2592 | def Display(self): |
2593 | self.user_DisplayParameter("detector") |
2594 | @@ -77,8 +88,10 @@ |
2595 | |
2596 | if value.lower()=="cms": |
2597 | self.detector=value |
2598 | + self.SetCard() |
2599 | elif value.lower()=="atlas": |
2600 | self.detector=value |
2601 | + self.SetCard() |
2602 | else: |
2603 | logging.error("algorithm called '"+value+"' is not found.") |
2604 | return |
2605 | @@ -108,6 +121,7 @@ |
2606 | # none |
2607 | if valuemin=="none": |
2608 | self.pileup = "" |
2609 | + self.SetCard() |
2610 | |
2611 | # .pileup |
2612 | elif valuemin.endswith(".pileup"): |
2613 | @@ -115,6 +129,7 @@ |
2614 | logging.error('File called "'+value+'" is not found') |
2615 | return |
2616 | self.pileup = value |
2617 | + self.SetCard() |
2618 | return |
2619 | |
2620 | # other case: error |
2621 | |
2622 | === modified file 'madanalysis/configuration/fastsim_configuration.py' |
2623 | --- madanalysis/configuration/fastsim_configuration.py 2013-09-29 22:12:23 +0000 |
2624 | +++ madanalysis/configuration/fastsim_configuration.py 2014-05-17 19:51:11 +0000 |
2625 | @@ -22,18 +22,20 @@ |
2626 | ################################################################################ |
2627 | |
2628 | |
2629 | -from madanalysis.enumeration.ma5_running_type import MA5RunningType |
2630 | +from madanalysis.enumeration.ma5_running_type import MA5RunningType |
2631 | from madanalysis.configuration.clustering_configuration import ClusteringConfiguration |
2632 | -from madanalysis.configuration.delphes_configuration import DelphesConfiguration |
2633 | +from madanalysis.configuration.delphes_configuration import DelphesConfiguration |
2634 | +from madanalysis.configuration.delfes_configuration import DelfesConfiguration |
2635 | import logging |
2636 | |
2637 | class FastsimConfiguration: |
2638 | |
2639 | - userVariables = { "package" : ["fastjet","delphes","none"] } |
2640 | + userVariables = { "package" : ["fastjet","delphes","delfes","none"] } |
2641 | |
2642 | def __init__(self): |
2643 | self.clustering = 0 |
2644 | self.delphes = 0 |
2645 | + self.delfes = 0 |
2646 | self.package = "none" |
2647 | |
2648 | |
2649 | @@ -43,6 +45,8 @@ |
2650 | self.clustering.Display() |
2651 | elif self.package=="delphes": |
2652 | self.delphes.Display() |
2653 | + elif self.package=="delfes": |
2654 | + self.delfes.Display() |
2655 | |
2656 | |
2657 | def user_DisplayParameter(self,parameter): |
2658 | @@ -53,6 +57,8 @@ |
2659 | self.clustering.user_DisplayParameter(parameter) |
2660 | elif self.package=="delphes": |
2661 | self.delphes.user_DisplayParameter(parameter) |
2662 | + elif self.package=="delfes": |
2663 | + self.delfes.user_DisplayParameter(parameter) |
2664 | |
2665 | |
2666 | def SampleAnalyzerConfigString(self): |
2667 | @@ -64,11 +70,15 @@ |
2668 | mydict = {} |
2669 | mydict.update(self.delphes.SampleAnalyzerConfigString()) |
2670 | return mydict |
2671 | + elif self.package=="delfes": |
2672 | + mydict = {} |
2673 | + mydict.update(self.delfes.SampleAnalyzerConfigString()) |
2674 | + return mydict |
2675 | else: |
2676 | return {} |
2677 | |
2678 | |
2679 | - def user_SetParameter(self,parameter,value,datasets,level,fastjet,delphes): |
2680 | + def user_SetParameter(self,parameter,value,datasets,level,fastjet,delphes,delfes): |
2681 | |
2682 | # algorithm |
2683 | if parameter=="package": |
2684 | @@ -89,11 +99,12 @@ |
2685 | test=False |
2686 | break |
2687 | if not test: |
2688 | - logging.error("some datasets contain partonic/hadronic file format. Fast-simulation package cannot be switched off.") |
2689 | + logging.error("some datasets contain partonic/hadronic file format. "+\ |
2690 | + "Fast-simulation package cannot be switched off.") |
2691 | return |
2692 | |
2693 | # Switch on the clustering |
2694 | - elif value in ["fastjet","delphes"]: |
2695 | + elif value in ["fastjet","delphes","delfes"]: |
2696 | |
2697 | # Only in reco mode |
2698 | if level!=MA5RunningType.RECO: |
2699 | @@ -110,6 +121,11 @@ |
2700 | logging.error("delphes library is not installed. This fast-simulation package is not available.") |
2701 | return |
2702 | |
2703 | + # Delfes ? |
2704 | + if value=='delfes' and not delfes: |
2705 | + logging.error("delfes library is not installed. This fast-simulation package is not available.") |
2706 | + return |
2707 | + |
2708 | test=True |
2709 | for dataset in datasets: |
2710 | if not test: |
2711 | @@ -128,14 +144,22 @@ |
2712 | self.package="fastjet" |
2713 | self.clustering = ClusteringConfiguration() |
2714 | self.delphes = 0 |
2715 | + self.delfes = 0 |
2716 | elif value=="delphes": |
2717 | self.package="delphes" |
2718 | self.clustering = 0 |
2719 | self.delphes = DelphesConfiguration() |
2720 | + self.delfes = 0 |
2721 | + elif value=="delfes": |
2722 | + self.package="delfes" |
2723 | + self.clustering = 0 |
2724 | + self.delphes = 0 |
2725 | + self.delfes = DelfesConfiguration() |
2726 | elif value=="none": |
2727 | self.package="none" |
2728 | self.clustering = 0 |
2729 | self.delphes = 0 |
2730 | + self.delfes = 0 |
2731 | else: |
2732 | logging.error("parameter called '"+value+"' is not found.") |
2733 | return |
2734 | @@ -150,6 +174,8 @@ |
2735 | return self.clustering.user_SetParameter(parameter,value,datasets,level) |
2736 | elif self.package=="delphes": |
2737 | return self.delphes.user_SetParameter(parameter,value,datasets,level) |
2738 | + elif self.package=="delfes": |
2739 | + return self.delfes.user_SetParameter(parameter,value,datasets,level) |
2740 | |
2741 | |
2742 | def user_GetParameters(self): |
2743 | @@ -159,6 +185,9 @@ |
2744 | elif self.package=="delphes": |
2745 | table = FastsimConfiguration.userVariables.keys() |
2746 | table.extend(self.delphes.user_GetParameters()) |
2747 | + elif self.package=="delfes": |
2748 | + table = FastsimConfiguration.userVariables.keys() |
2749 | + table.extend(self.delfes.user_GetParameters()) |
2750 | else: |
2751 | table = ["package"] |
2752 | return table |
2753 | @@ -184,6 +213,15 @@ |
2754 | table.extend(self.delphes.user_GetValues(variable)) |
2755 | except: |
2756 | pass |
2757 | + elif self.package=="delfes": |
2758 | + try: |
2759 | + table.extend(FastsimConfiguration.userVariables[variable]) |
2760 | + except: |
2761 | + pass |
2762 | + try: |
2763 | + table.extend(self.delfes.user_GetValues(variable)) |
2764 | + except: |
2765 | + pass |
2766 | else: |
2767 | if variable=="package": |
2768 | table.extend(FastsimConfiguration.userVariables["package"]) |
2769 | |
2770 | === modified file 'madanalysis/core/config_checker.py' |
2771 | --- madanalysis/core/config_checker.py 2013-10-27 21:36:24 +0000 |
2772 | +++ madanalysis/core/config_checker.py 2014-05-17 19:51:11 +0000 |
2773 | @@ -39,9 +39,10 @@ |
2774 | container.append(item) |
2775 | |
2776 | |
2777 | - def __init__(self,configLinux,ma5dir,script=False): |
2778 | + def __init__(self,configLinux,ma5dir,script=False,isMAC=False): |
2779 | |
2780 | # Getting parameter from the main program |
2781 | + self.isMAC=isMAC |
2782 | self.configLinux=configLinux |
2783 | self.ma5dir=ma5dir |
2784 | self.script=script |
2785 | @@ -56,6 +57,74 @@ |
2786 | self.fillHeaders() |
2787 | |
2788 | |
2789 | + def ReadUserOptions(self): |
2790 | + |
2791 | + # Open the user options |
2792 | + filename = self.ma5dir+'/madanalysis/input/installation_options.dat' |
2793 | + try: |
2794 | + input = open(filename) |
2795 | + except: |
2796 | + logging.error('impossible to open the file: '+filename) |
2797 | + return False |
2798 | + |
2799 | + # Loop over the file |
2800 | + for rawline in input: |
2801 | + |
2802 | + if '#' in rawline: |
2803 | + line = rawline.split('#')[0] |
2804 | + if line=='': |
2805 | + continue |
2806 | + words=line.split('=') |
2807 | + if len(words)!=2: |
2808 | + logging.warning(filename+': the following line is incorrect and is skipped:') |
2809 | + logging.warning(line) |
2810 | + words[0]=words[0].lstrip() |
2811 | + words[0]=words[0].rstrip() |
2812 | + words[1]=words[1].lstrip() |
2813 | + words[1]=words[1].rstrip() |
2814 | + |
2815 | + if words[0]=='root_includes': |
2816 | + self.configLinux.useroptions.root_includes==words[1] |
2817 | + elif words[0]=='root_libs': |
2818 | + self.configLinux.useroptions.root_libs=words[1] |
2819 | + elif words[0]=='delphes_veto': |
2820 | + self.configLinux.useroptions.delphes_veto=words[1] |
2821 | + elif words[0]=='delphes_includes': |
2822 | + self.configLinux.useroptions.delphes_includes=words[1] |
2823 | + elif words[0]=='delphes_libs': |
2824 | + self.configLinux.useroptions.delphes_libs=words[1] |
2825 | + elif words[0]=='delfes_veto': |
2826 | + self.configLinux.useroptions.delfes_veto=words[1] |
2827 | + elif words[0]=='delfes_includes': |
2828 | + self.configLinux.useroptions.delfes_includes=words[1] |
2829 | + elif words[0]=='delfes_libs': |
2830 | + self.configLinux.useroptions.delfes_libs=words[1] |
2831 | + elif words[0]=='zlib_veto': |
2832 | + self.configLinux.useroptions.zlib_veto=words[1] |
2833 | + elif words[0]=='zlib_includes': |
2834 | + self.configLinux.useroptions.zlib_includes=words[1] |
2835 | + elif words[0]=='zlib_libs': |
2836 | + self.configLinux.useroptions.zlib_libs=words[1] |
2837 | + elif words[0]=='fastjet_veto': |
2838 | + self.configLinux.useroptions.fastjet_veto=words[1] |
2839 | + elif words[0]=='fastjet_bin_path': |
2840 | + self.configLinux.useroptions.fastjet_bin_path=words[1] |
2841 | + elif words[0]=='pdflatex_veto': |
2842 | + self.configLinux.useroptions.pdflatex_veto=words[1] |
2843 | + elif words[0]=='latex_veto': |
2844 | + self.configLinux.useroptions.latex_veto=words[1] |
2845 | + elif words[0]=='dvipdf_veto': |
2846 | + self.configLinux.useroptions.dvipdf_veto=words[1] |
2847 | + else: |
2848 | + logging.warning(filename+': the options called "'+words[0]+'" is not found') |
2849 | + |
2850 | + # Close the file |
2851 | + input.close() |
2852 | + |
2853 | + # Ok |
2854 | + return True |
2855 | + |
2856 | + |
2857 | def FillMA5Path(self): |
2858 | os.environ['MA5_BASE']=self.ma5dir |
2859 | |
2860 | @@ -89,6 +158,7 @@ |
2861 | |
2862 | |
2863 | def fillHeaders(self): |
2864 | + |
2865 | # Filling container with paths included in CPLUS_INCLUDE_PATH |
2866 | try: |
2867 | cplus_include_path = os.environ['CPLUS_INCLUDE_PATH'].split(':') |
2868 | @@ -146,76 +216,74 @@ |
2869 | # Checking if ROOT is present |
2870 | self.PrintLibrary('Root') |
2871 | |
2872 | + # Does the user force the ROOT path |
2873 | + force1=False |
2874 | + force2=False |
2875 | + if self.configLinux.useroptions.root_includes!='0': |
2876 | + self.configLinux.root_inc_path=self.configLinux.useroptions.root_includes |
2877 | + force1=True |
2878 | + if self.configLinux.useroptions.root_libs!='0': |
2879 | + self.configLinux.root_lib_path=self.configLinux.useroptions.root_libs |
2880 | + force2=True |
2881 | + force=force1 and force2 |
2882 | + |
2883 | # Trying to call root-config |
2884 | - rootdirs = commands.getstatusoutput('root-config --libdir --incdir') |
2885 | - if rootdirs[0]>0: |
2886 | - self.PrintFAIL(warning=False) |
2887 | - logging.error('ROOT module called "root-config" is not detected.\n'\ |
2888 | - +'Two explanations :n'\ |
2889 | - +' - ROOT is not installed. You can download it '\ |
2890 | - +'from http://root.cern.ch\n'\ |
2891 | - +' - ROOT binary folder must be placed in the '\ |
2892 | - +'global environment variable $PATH') |
2893 | - return False |
2894 | - |
2895 | - # Extracting ROOT library and header path |
2896 | - root_tmp = rootdirs[1].split() |
2897 | - self.includes.append(root_tmp[1]) |
2898 | - self.libs.append(root_tmp[0]) |
2899 | - os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
2900 | - ":" + root_tmp[0] |
2901 | - os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \ |
2902 | - ":" + root_tmp[0] |
2903 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
2904 | - ":" + root_tmp[0] |
2905 | - os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + \ |
2906 | - ":" + root_tmp[1] |
2907 | + if not force: |
2908 | + |
2909 | + # Using root-config |
2910 | + rootdirs = commands.getstatusoutput('root-config --libdir --incdir') |
2911 | + if rootdirs[0]>0: |
2912 | + self.PrintFAIL(warning=False) |
2913 | + logging.error('ROOT module called "root-config" is not detected.\n'\ |
2914 | + +'Two explanations :n'\ |
2915 | + +' - ROOT is not installed. You can download it '\ |
2916 | + +'from http://root.cern.ch\n'\ |
2917 | + +' - ROOT binary folder must be placed in the '\ |
2918 | + +'global environment variable $PATH') |
2919 | + return False |
2920 | + |
2921 | + # Extracting ROOT library and header path |
2922 | + root_tmp = rootdirs[1].split() |
2923 | + self.configLinux.root_inc_path = root_tmp[1] |
2924 | + self.configLinux.root_lib_path = root_tmp[0] |
2925 | |
2926 | # Adding ROOT library path to Python path |
2927 | - sys.path.append(root_tmp[0]) |
2928 | - |
2929 | - # Looking for libPyROOT.so |
2930 | - find=False |
2931 | - for item in self.libs: |
2932 | - files=glob.glob(item+"/libPyROOT.so") |
2933 | - if len(files)!=0: |
2934 | - self.configLinux.libraries['PyROOT']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
2935 | - find=True |
2936 | - break |
2937 | - if not find: |
2938 | - self.PrintFAIL(warning=False) |
2939 | - logging.error("ROOT library called 'libPyROOT.so' not found. Please check that ROOT is properly installed.") |
2940 | - return False |
2941 | - |
2942 | - # Looking for ROOT.py |
2943 | - find=False |
2944 | - for item in self.libs: |
2945 | - files=glob.glob(item+"/ROOT.py") |
2946 | - if len(files)!=0: |
2947 | - self.configLinux.libraries['ROOT']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
2948 | - find=True |
2949 | - break |
2950 | - if not find: |
2951 | - self.PrintFAIL(warning=False) |
2952 | - logging.error("ROOT file called 'ROOT.py' not found. Please check that ROOT is properly installed.") |
2953 | - return False |
2954 | - |
2955 | - # Looking for TH1F.h |
2956 | - find=False |
2957 | - for item in self.includes: |
2958 | - files=glob.glob(item+"/TH1F.h") |
2959 | - if len(files)!=0: |
2960 | - self.configLinux.headers['ROOT']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
2961 | - find=True |
2962 | - break |
2963 | - if not find: |
2964 | - self.PrintFAIL(warning=False) |
2965 | - logging.error("ROOT headers are not found. " +\ |
2966 | - "Please check that ROOT is properly installed.") |
2967 | - return False |
2968 | + sys.path.append(self.configLinux.root_lib_path) |
2969 | + |
2970 | + # Check: looking for files |
2971 | + FilesToFind=[self.configLinux.root_lib_path+'/libPyROOT.so', \ |
2972 | + self.configLinux.root_inc_path+'/TH1F.h'] |
2973 | + for file in FilesToFind: |
2974 | + if os.path.isfile(file): |
2975 | + self.configLinux.libraries[file.split('/')[-1]]=file+":"+str(os.stat(file).st_mtime) |
2976 | + else: |
2977 | + self.PrintFAIL(warning=False) |
2978 | + logging.error("ROOT file called '"+file+"' is not found") |
2979 | + logging.error("Please check that ROOT is properly installed.") |
2980 | + return False |
2981 | + |
2982 | + # Check: looking for files |
2983 | + FilesToFind=[self.configLinux.root_lib_path+'/ROOT.py', \ |
2984 | + self.configLinux.root_lib_path+'/ROOT.pyc'] |
2985 | + found=False |
2986 | + for file in FilesToFind: |
2987 | + if os.path.isfile(file): |
2988 | + self.configLinux.libraries[file.split('/')[-1]]=file+":"+str(os.stat(file).st_mtime) |
2989 | + found=True |
2990 | + break |
2991 | + if not found: |
2992 | + self.PrintFAIL(warning=False) |
2993 | + logging.error("ROOT file called 'ROOT.py' or 'ROOT.pyc' is not found") |
2994 | + logging.error("Please check that ROOT is properly installed.") |
2995 | + return False |
2996 | + |
2997 | + # Root Install |
2998 | self.PrintOK() |
2999 | - |
3000 | - |
3001 | + return True |
3002 | + |
3003 | + |
3004 | + def checkPyROOT(self): |
3005 | + |
3006 | # Loading ROOT library |
3007 | self.PrintLibrary("PyRoot libraries") |
3008 | try : |
3009 | @@ -272,6 +340,29 @@ |
3010 | return True |
3011 | |
3012 | |
3013 | + def checkMake(self): |
3014 | + # Checking GNU Make |
3015 | + self.PrintLibrary('GNU Make') |
3016 | + make_version = commands.getstatusoutput('make --version') |
3017 | + if make_version[0]>0: |
3018 | + self.PrintFAIL(warning=False) |
3019 | + logging.error('GNU Make not found. Please install it before ' + \ |
3020 | + 'using MadAnalysis 5') |
3021 | + return False |
3022 | + else: |
3023 | + self.PrintOK() |
3024 | + lines=make_version[1].split('\n') |
3025 | + if len(lines)==0: |
3026 | + logging.error('command "make --version" seems to not give the GNU Make version') |
3027 | + return False |
3028 | + line=lines[0] |
3029 | + line=line.replace(' ','') |
3030 | + line=line.lstrip() |
3031 | + line=line.rstrip() |
3032 | + self.configLinux.make_version = line |
3033 | + return True |
3034 | + |
3035 | + |
3036 | def checkGF(self): |
3037 | self.PrintLibrary("gfortran") |
3038 | gfortran_version = commands.getstatusoutput('gfortran -dumpversion') |
3039 | @@ -285,14 +376,12 @@ |
3040 | gfortran_version = gfor.group(1) |
3041 | else: |
3042 | self.PrintFAIL(warning=True) |
3043 | - logging.warning('gfortran compiler not found.' + \ |
3044 | - ' aMCatNLO cannot be used.') |
3045 | + logging.warning('gfortran compiler not found.') |
3046 | return True |
3047 | ver = gfortran_version.split('.') |
3048 | if (int(ver[0])<4) or (int(ver[0])==4 and int(ver[1])<4): |
3049 | self.PrintFAIL(warning=True) |
3050 | - logging.warning('gfortran ' + gfortran_version + ' not recent enough (< 4.4.0).' +\ |
3051 | - ' aMCatNLO cannot be used.') |
3052 | + logging.warning('gfortran ' + gfortran_version + ' older than 4.4.0.') |
3053 | return True |
3054 | |
3055 | self.configLinux.gfortran_version = gfortran_version |
3056 | @@ -300,73 +389,112 @@ |
3057 | return True |
3058 | |
3059 | |
3060 | + def FindLibraryWithPattern(self,pattern,files): |
3061 | + return self.FindFilesWithPattern(self.libs,pattern,files) |
3062 | + |
3063 | + def FindHeader(self,file): |
3064 | + return self.FindFilesWithPattern(self.includes,file,[file]) |
3065 | + |
3066 | + def FindFilesWithPattern(self,paths,pattern,targets): |
3067 | + result_files=[] |
3068 | + result_paths=[] |
3069 | + for path in paths: |
3070 | + rawfiles=glob.glob(path+"/"+pattern) |
3071 | + |
3072 | + filtered_files=[] |
3073 | + for file in rawfiles: |
3074 | + for target in targets: |
3075 | + if file.endswith('/'+target): |
3076 | + filtered_files.append(file) |
3077 | + |
3078 | + if len(filtered_files)!=0: |
3079 | + result_files.extend(filtered_files) |
3080 | + for item in filtered_files: |
3081 | + result_paths.append(path) |
3082 | + |
3083 | + if len(result_files)==0: |
3084 | + return "", "" |
3085 | + else: |
3086 | + return os.path.normpath(result_paths[0]), os.path.normpath(result_files[0]) |
3087 | + |
3088 | + |
3089 | def checkZLIB(self): |
3090 | |
3091 | self.PrintLibrary("zlib library") |
3092 | - |
3093 | - # Checking library libz.so |
3094 | - find=False |
3095 | - for item in self.libs: |
3096 | - files=glob.glob(item+"/libz.so") |
3097 | - files.extend(glob.glob(item+"/libz.a")) |
3098 | - files.extend(glob.glob(item+"/libz.dylib")) |
3099 | - if len(files)!=0: |
3100 | - self.configLinux.libraries['ZLib']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
3101 | - find=True |
3102 | - os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
3103 | - ":" + item |
3104 | - os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \ |
3105 | - ":" + item |
3106 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
3107 | - ":" + item |
3108 | - break |
3109 | - |
3110 | - # If not, test if it is there locally |
3111 | - if not find: |
3112 | - item = self.ma5dir+'/tools/zlib/lib/' |
3113 | - files=glob.glob(item+"/libz.so") |
3114 | - files.extend(glob.glob(item+"/libz.a")) |
3115 | - files.extend(glob.glob(item+"/libz.dylib")) |
3116 | - if len(files)!=0: |
3117 | - self.configLinux.libraries['ZLib']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
3118 | - find=True |
3119 | - os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
3120 | - ":" + item |
3121 | - os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \ |
3122 | - ":" + item |
3123 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
3124 | - ":" + item |
3125 | - # Not fail -> Warning |
3126 | - if not find: |
3127 | - self.PrintFAIL(warning=True) |
3128 | - logging.warning("Library called 'libz' not found. Gzip format will be disabled.") |
3129 | - logging.warning("To enable this format, please type 'install zlib' package.") |
3130 | - return False |
3131 | - |
3132 | - # Checking header file zlib.h |
3133 | - find=False |
3134 | - for item in self.includes: |
3135 | - files=glob.glob(item+"/zlib.h") |
3136 | - if len(files)!=0: |
3137 | - self.configLinux.headers['ZLib']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
3138 | - find=True |
3139 | - os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + item |
3140 | - break |
3141 | - |
3142 | - # If not, test if it is there locally |
3143 | - if not find: |
3144 | - find=os.path.isfile(self.ma5dir+'/tools/zlib/include/zlib.h') |
3145 | - if find: |
3146 | - os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + \ |
3147 | - self.ma5dir+'/tools/zlib/include/' |
3148 | - |
3149 | - if not find: |
3150 | - self.PrintFAIL(warning=True) |
3151 | - logging.warning("Header file called 'zlib.h' not found. Gzip format will be disabled.") |
3152 | - logging.warning("To enable this format, please type 'install zlib' package.") |
3153 | - return False |
3154 | - else: |
3155 | - self.PrintOK() |
3156 | + |
3157 | + # Name of the dynamic lib |
3158 | + libnames=['libz.so','libz.a'] |
3159 | + if self.isMAC: |
3160 | + libnames.append('libz.dylib') |
3161 | + |
3162 | + # User veto |
3163 | + if self.configLinux.useroptions.zlib_veto=='1': |
3164 | + self.PrintFAIL(warning=True) |
3165 | + logging.warning("Library called 'zlib' disabled. Gzip format will be disabled.") |
3166 | + return False |
3167 | + |
3168 | + # Does the user force the paths? |
3169 | + force1=False |
3170 | + force2=False |
3171 | + if self.configLinux.useroptions.zlib_includes!="0": |
3172 | + self.configLinux.zlib_inc_path=self.configLinux.useroptions.zlib_includes |
3173 | + force1=True |
3174 | + if self.configLinux.useroptions.zlib_libs!="0": |
3175 | + self.configLinux.zlib_lib_path=self.configLinux.useroptions.zlib_libraries |
3176 | + force2=True |
3177 | + force=force1 and force2 |
3178 | + |
3179 | + # Checking if zlib has been installed by MA5 |
3180 | + ma5installation = False |
3181 | + if not force: |
3182 | + if os.path.isdir(self.ma5dir+'/tools/zlib'): |
3183 | + self.configLinux.zlib_inc_path=self.ma5dir+'/tools/zlib/include/' |
3184 | + self.configLinux.zlib_lib_path=self.ma5dir+'/tools/zlib/lib/' |
3185 | + ma5installation = True |
3186 | + |
3187 | + # Check if the libraries and headers are available |
3188 | + if force or ma5installation: |
3189 | + |
3190 | + # header |
3191 | + if not os.path.isfile(self.configLinux.zlib_inc_path+'/zlib.h'): |
3192 | + self.PrintFAIL(warning=True) |
3193 | + logging.warning("Header file called '"+self.configLinux.zlib_inc_path+"'/zlib.h not found. Gzip format will be disabled.") |
3194 | + logging.warning("To enable this format, please type 'install zlib' package.") |
3195 | + return False |
3196 | + |
3197 | + # lib |
3198 | + mypath, myfile = self.FindFilesWithPattern([self.configLinux.zlib_lib_path],"libz.*",libnames) |
3199 | + self.configLinux.zlib_lib=myfile |
3200 | + if self.configLinux.zlib_lib=="": |
3201 | + self.PrintFAIL(warning=True) |
3202 | + logging.warning("Zlib library not found in "+self.configLinux.zlib_lib_path+" folder. Gzip format will be disabled.") |
3203 | + logging.warning("To enable this format, please type 'install zlib' package.") |
3204 | + return False |
3205 | + |
3206 | + # Checking zlib can be found in other folders |
3207 | + if not force and not ma5installation: |
3208 | + |
3209 | + # header |
3210 | + mypath, myfile = self.FindHeader('zlib.h') |
3211 | + self.configLinux.zlib_inc_path = mypath |
3212 | + if self.configLinux.zlib_inc_path=="": |
3213 | + self.PrintFAIL(warning=True) |
3214 | + logging.warning("Header file called 'zlib.h' not found. Gzip format will be disabled.") |
3215 | + logging.warning("To enable this format, please type 'install zlib' package.") |
3216 | + return False |
3217 | + |
3218 | + # lib |
3219 | + mypath, myfile = self.FindLibraryWithPattern('libz.*',libnames) |
3220 | + self.configLinux.zlib_lib_path = mypath |
3221 | + self.configLinux.zlib_lib = myfile |
3222 | + if self.configLinux.zlib_lib_path=="": |
3223 | + self.PrintFAIL(warning=True) |
3224 | + logging.warning("Library called 'zlib' not found. Gzip format will be disabled.") |
3225 | + logging.warning("To enable this format, please type 'install zlib' package.") |
3226 | + return False |
3227 | + |
3228 | + self.configLinux.libraries['ZLib']=self.configLinux.zlib_lib+":"+str(os.stat(self.configLinux.zlib_lib).st_mtime) |
3229 | + self.PrintOK() |
3230 | |
3231 | return True |
3232 | |
3233 | @@ -374,72 +502,169 @@ |
3234 | def checkDelphes(self): |
3235 | |
3236 | self.PrintLibrary("delphes library") |
3237 | - |
3238 | - # Checking library libDelphes.so |
3239 | - find=False |
3240 | - for item in self.libs: |
3241 | - files=glob.glob(item+"/libDelphes.so") |
3242 | - files.extend(glob.glob(item+"/libDelphes.a")) |
3243 | - files.extend(glob.glob(item+"/libDelphes.dylib")) |
3244 | - if len(files)!=0: |
3245 | - self.configLinux.libraries['Delphes']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
3246 | - find=True |
3247 | - os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
3248 | - ":" + item |
3249 | - os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \ |
3250 | - ":" + item |
3251 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
3252 | - ":" + item |
3253 | - break |
3254 | - |
3255 | - # If not, test if it is there locally |
3256 | - if not find: |
3257 | - item = self.ma5dir+'/tools/delphes/' |
3258 | - files=glob.glob(item+"/libDelphes.so") |
3259 | - files.extend(glob.glob(item+"/libDelphes.a")) |
3260 | - files.extend(glob.glob(item+"/libDelphes.dylib")) |
3261 | - if len(files)!=0: |
3262 | - self.configLinux.libraries['Delphes']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
3263 | - find=True |
3264 | - os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
3265 | - ":" + item |
3266 | - os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \ |
3267 | - ":" + item |
3268 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
3269 | - ":" + item |
3270 | - # Not fail -> Warning |
3271 | - if not find: |
3272 | - self.PrintFAIL(warning=True) |
3273 | - logging.warning("Library called 'delphes' not found. Delphes ROOT format will be disabled.") |
3274 | - logging.warning("To enable this format, please type 'install delphes'.") |
3275 | - return False |
3276 | - |
3277 | - # Checking header file |
3278 | - find=False |
3279 | - for item in self.includes: |
3280 | - files=glob.glob(item+"/modules/ParticlePropagator.h") |
3281 | - if len(files)!=0: |
3282 | - self.configLinux.headers['Delphes']=files[0]+":"+str(os.stat(files[0]).st_mtime) |
3283 | - find=True |
3284 | - os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + item |
3285 | - break |
3286 | - |
3287 | - # If not, test if it is there locally |
3288 | - if not find: |
3289 | - find=os.path.isfile(self.ma5dir+'/tools/delphes/modules/ParticlePropagator.h') |
3290 | - if find: |
3291 | - os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + \ |
3292 | - self.ma5dir+'/tools/delphes/' |
3293 | - os.environ['CPLUS_INCLUDE_PATH'] = os.environ['CPLUS_INCLUDE_PATH'] + ":" + \ |
3294 | - self.ma5dir+'/tools/delphes/external/' |
3295 | - |
3296 | - if not find: |
3297 | - self.PrintFAIL(warning=True) |
3298 | - logging.warning("Header file called 'modules/ParticlePropagator.h' not found. Delphes ROOT format will be disabled.") |
3299 | - logging.warning("To enable this format, please type 'install delphes' package.") |
3300 | - return False |
3301 | - else: |
3302 | - self.PrintOK() |
3303 | + |
3304 | + # Name of the dynamic lib |
3305 | + libnames=['libDelphes.so','libDelphes.a'] |
3306 | + if self.isMAC: |
3307 | + libnames.append('libDelphes.dylib') |
3308 | + |
3309 | + # User veto |
3310 | + if self.configLinux.useroptions.delphes_veto=='1': |
3311 | + self.PrintFAIL(warning=True) |
3312 | + logging.warning("Library called 'delphes' disabled. Delphes ROOT format will be disabled.") |
3313 | + return False |
3314 | + |
3315 | + # Does the user force the paths? |
3316 | + force1=False |
3317 | + force2=False |
3318 | + if self.configLinux.useroptions.delphes_includes!="0": |
3319 | + self.configLinux.delphes_inc_paths.append(self.configLinux.useroptions.delphes_includes) |
3320 | + self.configLinux.delphes_inc_paths.append(self.configLinux.useroptions.delphes_includes+'/external/') |
3321 | + force1=True |
3322 | + if self.configLinux.useroptions.delphes_libs!="0": |
3323 | + self.configLinux.delphes_lib_paths.append(self.configLinux.useroptions.delphes_libraries) |
3324 | + force2=True |
3325 | + force=force1 and force2 |
3326 | + |
3327 | + # Checking if Delphes has been installed by MA5 |
3328 | + ma5installation = False |
3329 | + if not force: |
3330 | + if os.path.isdir(self.ma5dir+'/tools/delphes') and \ |
3331 | + os.path.isdir(self.ma5dir+'/tools/delphes/external'): |
3332 | + self.configLinux.delphes_inc_paths.append(self.ma5dir+'/tools/delphes/') |
3333 | + self.configLinux.delphes_inc_paths.append(self.ma5dir+'/tools/delphes/external/') |
3334 | + self.configLinux.delphes_lib_paths.append(self.ma5dir+'/tools/delphes/') |
3335 | + ma5installation = True |
3336 | + |
3337 | + # Check if the libraries and headers are available |
3338 | + if force or ma5installation: |
3339 | + |
3340 | + # header |
3341 | + if not os.path.isfile(self.configLinux.delphes_inc_paths[0]+'/modules/ParticlePropagator.h'): |
3342 | + self.PrintFAIL(warning=True) |
3343 | + logging.warning("Header file called '"+self.configLinux.delphes_inc_paths[0]+"/modules/ParticlePropagator.h' not found." +\ |
3344 | + "Delphes ROOT format will be disabled.") |
3345 | + logging.warning("To enable this format, please type 'install delphes' package.") |
3346 | + return False |
3347 | + |
3348 | + # lib |
3349 | + mypath, myfile = self.FindFilesWithPattern(self.configLinux.delphes_lib_paths,"libDelphes.*",libnames) |
3350 | + self.configLinux.delphes_lib=myfile |
3351 | + if self.configLinux.delphes_lib=="": |
3352 | + self.PrintFAIL(warning=True) |
3353 | + logging.warning("Delphes library not found in "+self.configLinux.delphes_lib_paths[0]+" folder. Delphes ROOT format will be disabled.") |
3354 | + logging.warning("To enable this format, please type 'install delphes' package.") |
3355 | + return False |
3356 | + |
3357 | + # Checking Delphes can be found in other folders |
3358 | + if not force and not ma5installation: |
3359 | + |
3360 | + # header |
3361 | + mypath, myfile = self.FindHeader('/modules/ParticlePropagator.h') |
3362 | + self.delphes_inc_path = mypath |
3363 | + if self.delphes_inc_path=="": |
3364 | + self.PrintFAIL(warning=True) |
3365 | + logging.warning("Header file called '/modules/ParticlePropagator.h' not found. Delphes ROOT format will be disabled.") |
3366 | + logging.warning("To enable this format, please type 'install delphes' package.") |
3367 | + return False |
3368 | + |
3369 | + # lib |
3370 | + mypath, myfile = self.FindLibraryWithPattern('libDelphes.*',libnames) |
3371 | + self.configLinux.delphes_lib_path = mypath |
3372 | + self.configLinux.delphes_lib = myfile |
3373 | + if self.configLinux.delphes_lib_path=="": |
3374 | + self.PrintFAIL(warning=True) |
3375 | + logging.warning("Delphes library not found. Delphes format will be disabled.") |
3376 | + logging.warning("To enable this format, please type 'install delphes' package.") |
3377 | + return False |
3378 | + |
3379 | + self.configLinux.libraries['Delphes']=self.configLinux.delphes_lib+":"+str(os.stat(self.configLinux.delphes_lib).st_mtime) |
3380 | + self.PrintOK() |
3381 | + |
3382 | + return True |
3383 | + |
3384 | + |
3385 | + def checkDelfes(self): |
3386 | + |
3387 | +# self.PrintLibrary("delfes library") |
3388 | + |
3389 | + # Name of the dynamic lib |
3390 | + libnames=['libDelphes.so','libDelphes.a'] |
3391 | + if self.isMAC: |
3392 | + libnames.append('libDelphes.dylib') |
3393 | + |
3394 | + # User veto |
3395 | + if self.configLinux.useroptions.delfes_veto=='1': |
3396 | +# self.PrintFAIL(warning=True) |
3397 | +# logging.warning("Library called 'delfes' disabled. Delfes ROOT format will be disabled.") |
3398 | + return False |
3399 | + |
3400 | + # Does the user force the paths? |
3401 | + force1=False |
3402 | + force2=False |
3403 | + if self.configLinux.useroptions.delfes_includes!="0": |
3404 | + self.configLinux.delfes_inc_paths.append(self.configLinux.useroptions.delfes_includes) |
3405 | + self.configLinux.delfes_inc_paths.append(self.configLinux.useroptions.delfes_includes+'/external/') |
3406 | + force1=True |
3407 | + if self.configLinux.useroptions.delfes_libs!="0": |
3408 | + self.configLinux.delfes_lib_paths.append(self.configLinux.useroptions.delfes_libraries) |
3409 | + force2=True |
3410 | + force=force1 and force2 |
3411 | + |
3412 | + # Checking if delfes has been installed by MA5 |
3413 | + ma5installation = False |
3414 | + if not force: |
3415 | + if os.path.isdir(self.ma5dir+'/tools/delfes') and \ |
3416 | + os.path.isdir(self.ma5dir+'/tools/delfes/external'): |
3417 | + self.configLinux.delfes_inc_paths.append(self.ma5dir+'/tools/delfes/') |
3418 | + self.configLinux.delfes_inc_paths.append(self.ma5dir+'/tools/delfes/external/') |
3419 | + self.configLinux.delfes_lib_paths.append(self.ma5dir+'/tools/delfes/') |
3420 | + ma5installation = True |
3421 | + |
3422 | + # Check if the libraries and headers are available |
3423 | + if force or ma5installation: |
3424 | + |
3425 | + # header |
3426 | + if not os.path.isfile(self.configLinux.delfes_inc_paths[0]+'/modules/ParticlePropagator.h'): |
3427 | +# self.PrintFAIL(warning=True) |
3428 | +# logging.warning("Header file called '"+self.configLinux.delfes_inc_paths[0]+"/modules/ParticlePropagator.h' not found." +\ |
3429 | +# "Delfes ROOT format will be disabled.") |
3430 | +# logging.warning("To enable this format, please type 'install delfes' package.") |
3431 | + return False |
3432 | + |
3433 | + # lib |
3434 | + mypath, myfile = self.FindFilesWithPattern(self.configLinux.delfes_lib_paths,"libDelphes.*",libnames) |
3435 | + self.configLinux.delfes_lib=myfile |
3436 | + if self.configLinux.delfes_lib=="": |
3437 | +# self.PrintFAIL(warning=True) |
3438 | +# logging.warning("Delfes library not found in "+self.configLinux.delfes_lib_paths[0]+" folder. Delfes ROOT format will be disabled.") |
3439 | +# logging.warning("To enable this format, please type 'install delfes' package.") |
3440 | + return False |
3441 | + |
3442 | + # Checking Delfes can be found in other folders |
3443 | + if not force and not ma5installation: |
3444 | + |
3445 | + # header |
3446 | + mypath, myfile = self.FindHeader('/modules/ParticlePropagator.h') |
3447 | + self.delfes_inc_path = mypath |
3448 | + if self.delfes_inc_path=="": |
3449 | +# self.PrintFAIL(warning=True) |
3450 | +# logging.warning("Header file called '/modules/ParticlePropagator.h' not found. Delfes ROOT format will be disabled.") |
3451 | +# logging.warning("To enable this format, please type 'install delfes' package.") |
3452 | + return False |
3453 | + |
3454 | + # lib |
3455 | + mypath, myfile = self.FindLibraryWithPattern('libDelphes.*',libnames) |
3456 | + self.configLinux.delfes_lib_path = mypath |
3457 | + self.configLinux.delfes_lib = myfile |
3458 | + if self.configLinux.delfes_lib_path=="": |
3459 | +# self.PrintFAIL(warning=True) |
3460 | +# logging.warning("Delfes library not found. Delfes format will be disabled.") |
3461 | +# logging.warning("To enable this format, please type 'install delfes' package.") |
3462 | + return False |
3463 | + |
3464 | + self.configLinux.libraries['Delfes']=self.configLinux.delfes_lib+":"+str(os.stat(self.configLinux.delfes_lib).st_mtime) |
3465 | +# self.PrintOK() |
3466 | |
3467 | return True |
3468 | |
3469 | @@ -462,32 +687,58 @@ |
3470 | def checkFastJet(self): |
3471 | |
3472 | self.PrintLibrary("FastJet") |
3473 | - |
3474 | self.configLinux.fastjet_version = "none" |
3475 | |
3476 | - # Checking if fastjet is installed on the system |
3477 | - find = False |
3478 | - for item in self.paths: |
3479 | - files=glob.glob(item+"/fastjet-config") |
3480 | - files.extend(glob.glob(item+"/fastjet-config")) |
3481 | - if(len(files))!=0: |
3482 | - find = True |
3483 | - self.configLinux.fastjet_version = commands.getstatusoutput('fastjet-config --version')[1] |
3484 | - |
3485 | - # If not, test if it is there locally |
3486 | - if not find: |
3487 | - find=os.path.isfile(self.ma5dir+'/tools/fastjet/bin/fastjet-config') |
3488 | - |
3489 | - # If not there, print warning message; if there -> test it |
3490 | - if not find: |
3491 | + # User veto |
3492 | + if self.configLinux.useroptions.fastjet_veto=='1': |
3493 | self.PrintFAIL(warning=True) |
3494 | - logging.warning("The fastJet package not found. JetClustering algorithms are disabled.") |
3495 | - logging.warning("To enable this functionnality, please type 'install fastjet'.") |
3496 | + logging.warning("The FastJet package is disabled. JetClustering algorithms are disabled.") |
3497 | return False |
3498 | - else: |
3499 | - self.configLinux.fastjet_version = commands.getstatusoutput(self.ma5dir+'/tools/fastjet/bin/fastjet-config --version')[1] |
3500 | - os.environ['PATH'] = self.ma5dir+'/tools/fastjet/bin/:'+os.environ['PATH'] |
3501 | - self.PrintOK() |
3502 | + |
3503 | + # Does the user force the paths? |
3504 | + force=False |
3505 | + if self.configLinux.useroptions.fastjet_bin_path!="0": |
3506 | + self.configLinux.fastjet_bin_path.append(self.configLinux.useroptions.fastjet_bin_path) |
3507 | + force=True |
3508 | + |
3509 | + # Checking if FastJet has been installed by MA5 |
3510 | + ma5installation = False |
3511 | + if not force: |
3512 | + if os.path.isdir(self.ma5dir+'/tools/fastjet/bin'): |
3513 | + self.configLinux.fastjet_bin_path=self.ma5dir+'/tools/fastjet/bin/' |
3514 | + ma5installation = True |
3515 | + |
3516 | + # Check if the libraries and headers are available |
3517 | + if force or ma5installation: |
3518 | + |
3519 | + if not os.path.isfile(self.configLinux.fastjet_bin_path+'/fastjet-config'): |
3520 | + self.PrintFAIL(warning=True) |
3521 | + logging.warning("The FastJet package not found. JetClustering algorithms are disabled.") |
3522 | + logging.warning("To enable this functionnality, please type 'install fastjet'.") |
3523 | + return False |
3524 | + |
3525 | + # Checking FastJet can be found in other folders |
3526 | + if not force and not ma5installation: |
3527 | + |
3528 | + for item in self.paths: |
3529 | + files=glob.glob(item+"/fastjet-config") |
3530 | + files.extend(glob.glob(item+"/fastjet-config")) |
3531 | + if(len(files))!=0: |
3532 | + self.configLinux.fastjet_bin_path=item |
3533 | + break |
3534 | + if self.configLinux.fastjet_bin_path=='': |
3535 | + self.PrintFAIL(warning=True) |
3536 | + logging.warning("The FastJet package not found. JetClustering algorithms are disabled.") |
3537 | + logging.warning("To enable this functionnality, please type 'install fastjet'.") |
3538 | + return False |
3539 | + |
3540 | + self.configLinux.fastjet_version = commands.getstatusoutput(self.ma5dir+'/tools/fastjet/bin/fastjet-config --version')[1] |
3541 | + tmp = commands.getstatusoutput(self.ma5dir+'/tools/fastjet/bin/fastjet-config --libs --plugins')[1] |
3542 | + words = tmp.split() |
3543 | + for word in words: |
3544 | + if word.startswith('-L'): |
3545 | + self.configLinux.fastjet_lib_paths.append(word[2:]) |
3546 | + self.PrintOK() |
3547 | |
3548 | return True |
3549 | |
3550 | @@ -512,6 +763,11 @@ |
3551 | def checkPdfLatex(self): |
3552 | self.PrintLibrary('pdflatex') |
3553 | |
3554 | + if self.configLinux.useroptions.pdflatex_veto=='1': |
3555 | + self.PrintFAIL(warning=True) |
3556 | + logging.warning("pdflatex disabled. Reports under the pdf format will not be compiled.") |
3557 | + return False |
3558 | + |
3559 | pdflatex_version = commands.getstatusoutput('pdflatex -version') |
3560 | if 'not found' in str(pdflatex_version) or 'no such file' in str(pdflatex_version): |
3561 | self.PrintFAIL(warning=True) |
3562 | @@ -524,6 +780,11 @@ |
3563 | def checkLatex(self): |
3564 | self.PrintLibrary('latex') |
3565 | |
3566 | + if self.configLinux.useroptions.latex_veto=='1': |
3567 | + self.PrintFAIL(warning=True) |
3568 | + logging.warning("latex disabled. Reports under the dvi format will not be compiled.") |
3569 | + return False |
3570 | + |
3571 | latex_version = commands.getstatusoutput('latex -version') |
3572 | if 'not found' in str(latex_version) or 'no such file' in str(latex_version): |
3573 | self.PrintFAIL(warning=True) |
3574 | @@ -536,6 +797,11 @@ |
3575 | def checkdvipdf(self): |
3576 | self.PrintLibrary('dvipdf') |
3577 | |
3578 | + if self.configLinux.useroptions.dvipdf_veto=='1': |
3579 | + self.PrintFAIL(warning=True) |
3580 | + logging.warning("dvipdf disabled. DVI reports will not be converted to pdf files.") |
3581 | + return False |
3582 | + |
3583 | dvipdf_version = commands.getstatusoutput('dvipdf') |
3584 | if 'not found' in str(dvipdf_version) or 'no such file' in str(dvipdf_version): |
3585 | self.PrintFAIL(warning=True) |
3586 | |
3587 | === modified file 'madanalysis/core/expert_mode.py' |
3588 | --- madanalysis/core/expert_mode.py 2013-05-31 21:57:38 +0000 |
3589 | +++ madanalysis/core/expert_mode.py 2014-05-17 19:51:11 +0000 |
3590 | @@ -42,8 +42,10 @@ |
3591 | |
3592 | def CreateDirectory(self): |
3593 | logging.info("\nWelcome to the expert mode of MadAnalysis") |
3594 | - logging.info("Please enter a folder for creating an empty SampleAnalyzer job") |
3595 | + logging.info("Please enter a folder name for creating an empty SampleAnalyzer job") |
3596 | answer=raw_input("Answer: ") |
3597 | + answer=answer.replace(' ','_'); |
3598 | + answer=answer.replace('-','_'); |
3599 | self.path = os.path.expanduser(answer) |
3600 | if not self.path.startswith('/'): |
3601 | self.path = self.main.currentdir+'/'+self.path |
3602 | @@ -90,12 +92,17 @@ |
3603 | return False |
3604 | |
3605 | # Writing an empty analysis |
3606 | + logging.info("Please enter a name for your analysis") |
3607 | + title=raw_input("Answer: ") |
3608 | + if title=="": |
3609 | + title="user" |
3610 | + title=title.replace(' ', '_'); |
3611 | + title=title.replace('-', '_'); |
3612 | logging.info(" Writing an empty analysis...") |
3613 | - jobber.WriteEmptyFilterSource(self.main) |
3614 | - os.system("cd "+self.path+"/Build/SampleAnalyzer; python newAnalyzer.py user") |
3615 | + os.system("cd "+self.path+"/Build/SampleAnalyzer; python newAnalyzer.py " + title + " 1") |
3616 | |
3617 | # Extracting analysis name |
3618 | - file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.cpp") |
3619 | + file = open(self.path+"/Build/SampleAnalyzer/Analyzer/analysisList.h") |
3620 | title="" |
3621 | for line in file: |
3622 | if "Add" not in line: |
3623 | @@ -105,9 +112,7 @@ |
3624 | title=words[1] |
3625 | break |
3626 | file.close() |
3627 | - if title=="": |
3628 | - title="user" |
3629 | - |
3630 | + |
3631 | # Writing a Makefile |
3632 | logging.info(" Writing a 'Makefile'...") |
3633 | if not jobber.WriteMakefiles(): |
3634 | |
3635 | === modified file 'madanalysis/core/library_builder.py' |
3636 | --- madanalysis/core/library_builder.py 2013-05-17 06:19:22 +0000 |
3637 | +++ madanalysis/core/library_builder.py 2014-05-17 19:51:11 +0000 |
3638 | @@ -31,11 +31,15 @@ |
3639 | |
3640 | class LibraryBuilder: |
3641 | |
3642 | - def __init__(self,configLinux,ma5dir): |
3643 | + def __init__(self,configLinux,ma5dir,libZIP,libDelphes,libDelfes,libFastJet): |
3644 | |
3645 | self.configLinux=configLinux |
3646 | self.ma5dir=ma5dir |
3647 | self.configStore = LinuxArchitecture() |
3648 | + self.libZIP=libZIP |
3649 | + self.libDelphes=libDelphes |
3650 | + self.libDelfes=libDelfes |
3651 | + self.libFastJet=libFastJet |
3652 | |
3653 | |
3654 | def checkMA5(self): |
3655 | @@ -53,19 +57,33 @@ |
3656 | logging.error(" "+name) |
3657 | return False |
3658 | |
3659 | - # Look for shared library 'MadAnalysis' and 'config' file |
3660 | - if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.a') \ |
3661 | + # Look for the shared library 'MadAnalysis' and 'config' file |
3662 | + if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so') \ |
3663 | or not os.path.isfile(self.ma5dir+'/tools/architecture.ma5'): |
3664 | FirstUse=True |
3665 | + return True, False |
3666 | + |
3667 | + # Look for optional library |
3668 | + libraries = [] |
3669 | + if self.libFastJet: |
3670 | + libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so') |
3671 | + if self.libZIP: |
3672 | + libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so') |
3673 | + if self.libDelphes: |
3674 | + libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so') |
3675 | + if self.libDelfes: |
3676 | + libraries.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so') |
3677 | + for library in libraries: |
3678 | + if not os.path.isfile(library): |
3679 | + return False, True |
3680 | |
3681 | # Importing the configuration stored with the library |
3682 | if not FirstUse: |
3683 | if not self.configStore.Import(self.ma5dir+'/tools/architecture.ma5'): |
3684 | FirstUse=True |
3685 | + return True, False |
3686 | |
3687 | - if not FirstUse: |
3688 | - logging.info(' => MadAnalysis library found.') |
3689 | - return FirstUse |
3690 | + return FirstUse, False |
3691 | |
3692 | |
3693 | def compare(self): |
3694 | |
3695 | === modified file 'madanalysis/core/linux_architecture.py' |
3696 | --- madanalysis/core/linux_architecture.py 2013-10-27 21:36:24 +0000 |
3697 | +++ madanalysis/core/linux_architecture.py 2014-05-17 19:51:11 +0000 |
3698 | @@ -23,14 +23,121 @@ |
3699 | |
3700 | |
3701 | import logging |
3702 | + |
3703 | +class UserOptions: |
3704 | + |
3705 | + def __init__(self): |
3706 | + self.root_includes = '0' |
3707 | + self.root_libs = '0' |
3708 | + self.delphes_veto = '0' |
3709 | + self.delphes_includes = '0' |
3710 | + self.delphes_libs = '0' |
3711 | + self.delfes_veto = '0' |
3712 | + self.delfes_includes = '0' |
3713 | + self.delfes_libs = '0' |
3714 | + self.zlib_veto = '0' |
3715 | + self.zlib_includes = '0' |
3716 | + self.zlib_libs = '0' |
3717 | + self.fastjet_veto = '0' |
3718 | + self.fastjet_bin_path = '0' |
3719 | + self.pdflatex_veto = '0' |
3720 | + self.latex_veto = '0' |
3721 | + self.dvipdf_veto = '0' |
3722 | + |
3723 | + def Dump(self): |
3724 | + logging.info(" ROOT header path = " + str(self.root_includes)) |
3725 | + logging.info(" ROOT library path = " + str(self.root_libs)) |
3726 | + logging.info(" DELPHES veto = " + str(self.delphes_veto)) |
3727 | + logging.info(" DELPHES header path = " + str(self.delphes_includes)) |
3728 | + logging.info(" DELPHES library path = " + str(self.delphes_libs)) |
3729 | + logging.info(" DELFES veto = " + str(self.delfes_veto)) |
3730 | + logging.info(" DELFES header path = " + str(self.delfes_includes)) |
3731 | + logging.info(" DELFES library path = " + str(self.delfes_libs)) |
3732 | + logging.info(" ZLIB veto = " + str(self.zlib_veto)) |
3733 | + logging.info(" ZLIB header path = " + str(self.zlib_includes)) |
3734 | + logging.info(" ZLIB library path = " + str(self.zlib_libs)) |
3735 | + logging.info(" FASTJET veto = " + str(self.fastjet_veto)) |
3736 | + logging.info(" FASTJET bin path = " + str(self.fastjet_bin_path)) |
3737 | + logging.info(" PDFLATEX veto = " + str(self.pdflatex_veto)) |
3738 | + logging.info(" LATEX veto = " + str(self.latex_veto)) |
3739 | + logging.info(" DVIPDF veto = " + str(self.dvipdf_veto)) |
3740 | + |
3741 | + def Export(self,file): |
3742 | + file.write(self.root_includes+"\n") |
3743 | + file.write(self.root_libs+"\n") |
3744 | + file.write(self.delphes_veto+"\n") |
3745 | + file.write(self.delphes_includes+"\n") |
3746 | + file.write(self.delphes_libs+"\n") |
3747 | + file.write(self.delfes_veto+"\n") |
3748 | + file.write(self.delfes_includes+"\n") |
3749 | + file.write(self.delfes_libs+"\n") |
3750 | + file.write(self.zlib_veto+"\n") |
3751 | + file.write(self.zlib_includes+"\n") |
3752 | + file.write(self.zlib_libs+"\n") |
3753 | + file.write(self.fastjet_veto+"\n") |
3754 | + file.write(self.fastjet_bin_path+"\n") |
3755 | + file.write(self.pdflatex_veto+"\n") |
3756 | + file.write(self.latex_veto+"\n") |
3757 | + file.write(self.dvipdf_veto+"\n") |
3758 | + |
3759 | + def Import(self,file): |
3760 | + self.root_includes = file.readline().replace('\n','') |
3761 | + self.root_libs = file.readline().replace('\n','') |
3762 | + self.delphes_veto = file.readline().replace('\n','') |
3763 | + self.delphes_includes = file.readline().replace('\n','') |
3764 | + self.delphes_libs = file.readline().replace('\n','') |
3765 | + self.delfes_veto = file.readline().replace('\n','') |
3766 | + self.delfes_includes = file.readline().replace('\n','') |
3767 | + self.delfes_libs = file.readline().replace('\n','') |
3768 | + self.zlib_veto = file.readline().replace('\n','') |
3769 | + self.zlib_includes = file.readline().replace('\n','') |
3770 | + self.zlib_libs = file.readline().replace('\n','') |
3771 | + self.fastjet_veto = file.readline().replace('\n','') |
3772 | + self.fastjet_bin_path = file.readline().replace('\n','') |
3773 | + self.pdflatex_veto = file.readline().replace('\n','') |
3774 | + self.latex_veto = file.readline().replace('\n','') |
3775 | + self.dvipdf_veto = file.readline().replace('\n','') |
3776 | + |
3777 | + def Compare(self,other): |
3778 | + if self.root_includes != other.root_includes: |
3779 | + return False |
3780 | + if self.root_libs != other.root_libs: |
3781 | + return False |
3782 | + if self.delphes_veto != other.delphes_veto: |
3783 | + return False |
3784 | + if self.delphes_includes != other.delphes_includes: |
3785 | + return False |
3786 | + if self.delphes_libs != other.delphes_libs: |
3787 | + return False |
3788 | + if self.delfes_veto != other.delfes_veto: |
3789 | + return False |
3790 | + if self.delfes_includes != other.delfes_includes: |
3791 | + return False |
3792 | + if self.delfes_libs != other.delfes_libs: |
3793 | + return False |
3794 | + if self.zlib_veto != other.zlib_veto: |
3795 | + return False |
3796 | + if self.zlib_includes != other.zlib_includes: |
3797 | + return False |
3798 | + if self.zlib_libs != other.zlib_libs: |
3799 | + return False |
3800 | + if self.fastjet_veto != other.fastjet_veto: |
3801 | + return False |
3802 | + if self.fastjet_bin_path != other.fastjet_bin_path: |
3803 | + return False |
3804 | + return True |
3805 | + |
3806 | class LinuxArchitecture: |
3807 | |
3808 | def __init__(self): |
3809 | + self.useroptions = UserOptions() |
3810 | self.platform = "" |
3811 | + self.release = "" |
3812 | self.ma5_version = "" |
3813 | self.ma5_date = "" |
3814 | self.python_version = "" |
3815 | self.gcc_version = "" |
3816 | + self.make_version = "" |
3817 | self.gfortran_version = "" |
3818 | self.root_version = "" |
3819 | self.fastjet_version = "" |
3820 | @@ -38,13 +145,35 @@ |
3821 | self.headers = {} |
3822 | self.editor = "" |
3823 | |
3824 | + self.root_inc_path="" |
3825 | + self.root_lib_path="" |
3826 | + self.zlib_inc_path="" |
3827 | + self.zlib_lib_path="" |
3828 | + self.zlib_lib="" |
3829 | + self.delphes_inc_paths=[] |
3830 | + self.delphes_lib_paths=[] |
3831 | + self.delphes_lib="" |
3832 | + self.delfes_inc_paths=[] |
3833 | + self.delfes_lib_paths=[] |
3834 | + self.delfes_lib="" |
3835 | + self.fastjet_bin_path="" |
3836 | + self.fastjet_lib_paths=[] |
3837 | |
3838 | def Dump(self): |
3839 | - logging.info(" Linux distrib = " + self.platform) |
3840 | + logging.info(" User options") |
3841 | + logging.info(" ------------") |
3842 | + self.useroptions.Dump() |
3843 | + logging.info("") |
3844 | + |
3845 | + logging.info(" Architecture") |
3846 | + logging.info(" ------------") |
3847 | + logging.info(" Platform = " + self.platform) |
3848 | + logging.info(" Release platform = " + self.release) |
3849 | logging.info(" MA5 version = " + self.ma5_version) |
3850 | logging.info(" MA5 date = " + self.ma5_date) |
3851 | logging.info(" Python version = " + self.python_version) |
3852 | logging.info(" gcc version = " + self.gcc_version) |
3853 | + logging.info(" GNU Make version = " + self.make_version) |
3854 | logging.info(" gfortran version = " + self.gfortran_version) |
3855 | logging.info(" ROOT version = " + self.root_version) |
3856 | logging.info(" FastJet version = " + self.fastjet_version) |
3857 | @@ -57,7 +186,6 @@ |
3858 | logging.info( " Header '" + key + "' = " + \ |
3859 | value ) |
3860 | |
3861 | - |
3862 | def Export(self,filename): |
3863 | try: |
3864 | file = open(filename,"w") |
3865 | @@ -65,11 +193,15 @@ |
3866 | logging.error("impossible to write the configuration file '" + \ |
3867 | filename + "'") |
3868 | return False |
3869 | + |
3870 | + self.useroptions.Export(file) |
3871 | file.write(self.platform+"\n") |
3872 | + file.write(self.release+"\n") |
3873 | file.write(self.ma5_version+"\n") |
3874 | file.write(self.ma5_date+"\n") |
3875 | file.write(self.python_version+"\n") |
3876 | file.write(self.gcc_version+"\n") |
3877 | + file.write(self.make_version+"\n") |
3878 | file.write(self.gfortran_version+"\n") |
3879 | file.write(self.root_version+"\n") |
3880 | file.write(self.fastjet_version+"\n") |
3881 | @@ -92,12 +224,16 @@ |
3882 | logging.error("impossible to read the configuration file '" + \ |
3883 | filename + "'") |
3884 | return False |
3885 | + |
3886 | try: |
3887 | + self.useroptions.Import(file) |
3888 | self.platform = file.readline().replace('\n','') |
3889 | + self.release = file.readline().replace('\n','') |
3890 | self.ma5_version = file.readline().replace('\n','') |
3891 | self.ma5_date = file.readline().replace('\n','') |
3892 | self.python_version = file.readline().replace('\n','') |
3893 | self.gcc_version = file.readline().replace('\n','') |
3894 | + self.make_version = file.readline().replace('\n','') |
3895 | self.gfortran_version = file.readline().replace('\n','') |
3896 | self.root_version = file.readline().replace('\n','') |
3897 | self.fastjet_version = file.readline().replace('\n','') |
3898 | @@ -135,8 +271,13 @@ |
3899 | |
3900 | |
3901 | def Compare(self, other): |
3902 | + if not self.useroptions.Compare(other.useroptions): |
3903 | + return False |
3904 | + |
3905 | if self.platform != other.platform: |
3906 | return False |
3907 | + if self.release != other.release: |
3908 | + return False |
3909 | if self.ma5_version != other.ma5_version: |
3910 | return False |
3911 | if self.ma5_date != other.ma5_date: |
3912 | @@ -145,6 +286,8 @@ |
3913 | return False |
3914 | if self.gcc_version != other.gcc_version: |
3915 | return False |
3916 | + if self.make_version != other.make_version: |
3917 | + return False |
3918 | if self.gfortran_version != other.gfortran_version: |
3919 | return False |
3920 | if self.root_version != other.root_version: |
3921 | |
3922 | === modified file 'madanalysis/core/main.py' |
3923 | --- madanalysis/core/main.py 2013-10-27 21:36:24 +0000 |
3924 | +++ madanalysis/core/main.py 2014-05-17 19:51:11 +0000 |
3925 | @@ -43,7 +43,7 @@ |
3926 | import logging |
3927 | import os |
3928 | import sys |
3929 | - |
3930 | +import platform |
3931 | |
3932 | class Main(): |
3933 | |
3934 | @@ -79,6 +79,7 @@ |
3935 | self.mg5 = False |
3936 | self.libZIP = False |
3937 | self.libDelphes = False |
3938 | + self.libDelfes = False |
3939 | self.pdflatex = False |
3940 | self.latex = False |
3941 | self.dvipdf = False |
3942 | @@ -86,9 +87,11 @@ |
3943 | self.fortran = False |
3944 | self.observables = ObservableManager(self.mode) |
3945 | self.mcatnloutils = False |
3946 | + self.expertmode = False |
3947 | + self.isMAC = False |
3948 | + self.repeatSession = False |
3949 | self.ResetParameters() |
3950 | |
3951 | - |
3952 | def ResetParameters(self): |
3953 | self.merging = MergingConfiguration() |
3954 | self.fastsim = FastsimConfiguration() |
3955 | @@ -128,7 +131,7 @@ |
3956 | else: |
3957 | if self.fastsim.package=="none": |
3958 | samples.append('.lhco') |
3959 | - if self.libDelphes: |
3960 | + if self.libDelphes or self.libDelfes: |
3961 | samples.append('.root') |
3962 | else: |
3963 | samples.append('.lhe') |
3964 | @@ -405,8 +408,22 @@ |
3965 | self.configLinux.ma5_version = self.version |
3966 | self.configLinux.ma5_date = self.date |
3967 | self.configLinux.python_version = sys.version.replace('\n','') |
3968 | - self.configLinux.platform = sys.platform |
3969 | - |
3970 | + self.configLinux.platform = platform.system() |
3971 | + self.configLinux.release = platform.release() |
3972 | + |
3973 | + # Is Mac |
3974 | + sys.stdout.write("Platform: "+self.configLinux.platform+" "+self.configLinux.release+" ") |
3975 | + sys.stdout.flush() |
3976 | + if self.configLinux.platform.lower() in ['darwin','mac','macosx']: |
3977 | + self.isMAC = True |
3978 | + sys.stdout.write('\x1b[32m'+'[MAC/OSX mode]'+'\x1b[0m'+'\n') |
3979 | + sys.stdout.flush() |
3980 | + else: |
3981 | + self.isMAC = False |
3982 | + sys.stdout.write('\x1b[32m'+'[Linux mode]'+'\x1b[0m'+'\n') |
3983 | + sys.stdout.flush() |
3984 | + |
3985 | + |
3986 | if detail: |
3987 | logging.info("General Platform identifier : " + str(self.configLinux.platform)) |
3988 | import multiprocessing |
3989 | @@ -426,9 +443,13 @@ |
3990 | logging.info("") |
3991 | |
3992 | # Initializing the config checker |
3993 | - checker = ConfigChecker(self.configLinux,self.ma5dir,self.script) |
3994 | + checker = ConfigChecker(self.configLinux,self.ma5dir,self.script,self.isMAC) |
3995 | checker.checkTextEditor() |
3996 | |
3997 | + # Reading user options |
3998 | + if not checker.ReadUserOptions(): |
3999 | + return False |
4000 | + |
4001 | # Mandatory packages |
4002 | logging.info("Checking mandatory packages:") |
4003 | checker.PrintLibrary("python") |
4004 | @@ -437,90 +458,239 @@ |
4005 | return False |
4006 | if not checker.checkGPP(): |
4007 | return False |
4008 | + if not checker.checkMake(): |
4009 | + return False |
4010 | if not checker.checkROOT(): |
4011 | return False |
4012 | + if not checker.checkPyROOT(): |
4013 | + return False |
4014 | |
4015 | # Optional packages |
4016 | logging.info("Checking optional packages:") |
4017 | - if not checker.checkGF(): |
4018 | - return False |
4019 | - self.libZIP = checker.checkZLIB() |
4020 | + self.libGF = checker.checkGF() |
4021 | + self.libZIP = checker.checkZLIB() |
4022 | self.libDelphes = checker.checkDelphes() |
4023 | + self.libDelfes = checker.checkDelfes() |
4024 | self.libFastJet = checker.checkFastJet() |
4025 | - self.pdflatex = checker.checkPdfLatex() |
4026 | - self.latex = checker.checkLatex() |
4027 | + self.pdflatex = checker.checkPdfLatex() |
4028 | + self.latex = checker.checkLatex() |
4029 | if self.latex: |
4030 | self.dvipdf = checker.checkdvipdf() |
4031 | - self.mcatnloutils = checker.checkMCatNLOUtils() |
4032 | - |
4033 | + |
4034 | + # Set PATH variable |
4035 | + self.configLinux.toPATH=[] |
4036 | + self.configLinux.toLDPATH=[] |
4037 | + self.configLinux.toLDPATH.append(self.ma5dir+'/tools/SampleAnalyzer/Lib/') |
4038 | + self.configLinux.toLDPATH.append(self.configLinux.root_lib_path) |
4039 | + if self.libFastJet: |
4040 | + self.configLinux.toPATH.append(self.configLinux.fastjet_bin_path) |
4041 | + for path in self.configLinux.fastjet_lib_paths: |
4042 | + self.configLinux.toLDPATH.append(path) |
4043 | + if self.libZIP: |
4044 | + self.configLinux.toLDPATH.append(self.configLinux.zlib_lib_path) |
4045 | + if self.libDelphes: |
4046 | + for path in self.configLinux.delphes_lib_paths: |
4047 | + self.configLinux.toLDPATH.append(path) |
4048 | + if self.libDelfes: |
4049 | + for path in self.configLinux.delfes_lib_paths: |
4050 | + self.configLinux.toLDPATH.append(path) |
4051 | + |
4052 | + os.environ['PATH'] = os.environ['PATH'] + \ |
4053 | + ":" + ':'.join(self.configLinux.toPATH) |
4054 | os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
4055 | - ":" + self.ma5dir+'/tools/SampleAnalyzer/Lib/' |
4056 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
4057 | - ":" + self.ma5dir+'/tools/SampleAnalyzer/Lib/' |
4058 | + ":" + ':'.join(self.configLinux.toLDPATH) |
4059 | + if self.isMAC: |
4060 | + os.environ['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH'] + \ |
4061 | + ":" + ':'.join(self.configLinux.toLDPATH) |
4062 | |
4063 | - if self.mcatnloutils: |
4064 | - os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] + \ |
4065 | - ":" + self.ma5dir+'/tools/MCatNLO-utilities/MCatNLO/lib/' |
4066 | - os.environ['LIBRARY_PATH'] = os.environ['LIBRARY_PATH'] + \ |
4067 | - ":" + self.ma5dir+'/tools/MCatNLO-utilities/MCatNLO/lib/' |
4068 | - |
4069 | return True |
4070 | |
4071 | + def PrintOK(self): |
4072 | + sys.stdout.write('\x1b[32m'+'[OK]'+'\x1b[0m'+'\n') |
4073 | + sys.stdout.flush() |
4074 | + |
4075 | def BuildLibrary(self,forced=False): |
4076 | - builder = LibraryBuilder(self.configLinux,self.ma5dir) |
4077 | + builder = LibraryBuilder(self.configLinux,self.ma5dir,self.libZIP,self.libDelphes,self.libDelfes,self.libFastJet) |
4078 | + |
4079 | UpdateNeed=False |
4080 | - |
4081 | - FirstUse = builder.checkMA5() |
4082 | - if not FirstUse: |
4083 | + FirstUse, Missing = builder.checkMA5() |
4084 | + if not FirstUse and not Missing: |
4085 | UpdateNeed = not builder.compare() |
4086 | |
4087 | - rebuild = forced or FirstUse or UpdateNeed |
4088 | - if not rebuild: |
4089 | + rebuild = forced or FirstUse or UpdateNeed or Missing |
4090 | + |
4091 | + if not rebuild: |
4092 | + if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so'): |
4093 | + FirstUse=True |
4094 | + rebuild = forced or FirstUse or UpdateNeed or Missing |
4095 | + |
4096 | + if not rebuild: |
4097 | + logging.info(' => MadAnalysis libraries found.') |
4098 | + |
4099 | + # Test the program |
4100 | + if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest'): |
4101 | + FirstUse=True |
4102 | + |
4103 | + precompiler = LibraryWriter(self.ma5dir,'lib',self.libZIP,self.libFastJet,self.forced,self.fortran,self.libDelphes,self.libDelfes,self) |
4104 | + if not precompiler.Run('SampleAnalyzerTest',[],self.ma5dir+'/tools/SampleAnalyzer/Test',silent=True): |
4105 | + UpdateNeed=True |
4106 | + |
4107 | + if not precompiler.CheckRun(self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest.log',silent=True): |
4108 | + UpdateNeed=True |
4109 | + rebuild = forced or FirstUse or UpdateNeed or Missing |
4110 | + |
4111 | + if not rebuild: |
4112 | + logging.info(' => MadAnalysis test program works.') |
4113 | return True |
4114 | |
4115 | # Compile library |
4116 | if FirstUse: |
4117 | logging.info(" => First use of MadAnalysis (or the library is missing).") |
4118 | + elif Missing: |
4119 | + logging.info(" => Libraries are missing or system configuration has changed. Need to rebuild the library.") |
4120 | elif UpdateNeed: |
4121 | logging.info(" => System configuration has changed since the last use. Need to rebuild the library.") |
4122 | elif forced: |
4123 | logging.info(" => The user forces to rebuild the library.") |
4124 | |
4125 | # Initializing the JobWriter |
4126 | - compiler = LibraryWriter(self.ma5dir,'lib',self.libZIP,self.libFastJet,self.forced,self.fortran,self.libDelphes) |
4127 | + compiler = LibraryWriter(self.ma5dir,'lib',self.libZIP,self.libFastJet,self.forced,self.fortran,self.libDelphes,self.libDelfes,self) |
4128 | |
4129 | # Dumping architecture |
4130 | if not self.configLinux.Export(self.ma5dir+'/tools/architecture.ma5'): |
4131 | sys.exit() |
4132 | |
4133 | - logging.info(" Creating a 'Makefile'...") |
4134 | - if not compiler.WriteMakefile('shared'): |
4135 | - logging.error("library building aborted.") |
4136 | - sys.exit() |
4137 | - |
4138 | - if not compiler.MrProper(): |
4139 | - logging.error("impossible to remove temporary files created during the building.") |
4140 | - sys.exit() |
4141 | - |
4142 | - logging.info(" Compiling the MadAnalysis library...") |
4143 | - if not compiler.Compile(): |
4144 | - logging.error("library building aborted.") |
4145 | - sys.exit() |
4146 | - |
4147 | - logging.info(" Linking the MadAnalysis library...") |
4148 | - if not compiler.Link(): |
4149 | - logging.error("library building aborted.") |
4150 | - sys.exit() |
4151 | - |
4152 | - logging.info(" Checking the MadAnalysis library...") |
4153 | - |
4154 | - if not os.path.isfile(self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.a'): |
4155 | - logging.error("the library 'libSampleAnalyzer.a' is not produced.") |
4156 | - sys.exit() |
4157 | - |
4158 | - if not compiler.Clean(): |
4159 | - logging.error("impossible to remove temporary files created during the building.") |
4160 | - sys.exit() |
4161 | + # Library to compiles |
4162 | + libraries = [] |
4163 | + if self.libFastJet: |
4164 | + libraries.append(['FastJet', 'interface to FastJet', 'fastjet', self.ma5dir+'/tools/SampleAnalyzer/Lib/libfastjet_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces']) |
4165 | + if self.libZIP: |
4166 | + libraries.append(['zlib', 'interface to zlib', 'zlib', self.ma5dir+'/tools/SampleAnalyzer/Lib/libzlib_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces']) |
4167 | + if self.libDelphes: |
4168 | + libraries.append(['Delphes', 'interface to Delphes', 'delphes', self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelphes_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces']) |
4169 | + if self.libDelfes: |
4170 | + libraries.append(['Delfes', 'interface to Delfes', 'delfes', self.ma5dir+'/tools/SampleAnalyzer/Lib/libdelfes_for_ma5.so',self.ma5dir+'/tools/SampleAnalyzer/Interfaces']) |
4171 | + libraries.append(['SampleAnalyzer', 'general SampleAnalyzer component', 'SampleAnalyzer', self.ma5dir+'/tools/SampleAnalyzer/Lib/libSampleAnalyzer.so',self.ma5dir+'/tools/SampleAnalyzer']) |
4172 | + |
4173 | + # Writing the Makefiles |
4174 | + logging.info("") |
4175 | + logging.info(" **********************************************************") |
4176 | + logging.info(" Building SampleAnalyzer libraries ") |
4177 | + logging.info(" **********************************************************") |
4178 | + |
4179 | + |
4180 | + # Getting number of cores |
4181 | + ncores = compiler.get_ncores2() |
4182 | + |
4183 | + # Compiling the libraries |
4184 | + for ind in range(0,len(libraries)): |
4185 | + |
4186 | + logging.info(" **********************************************************") |
4187 | + logging.info(" Library "+str(ind+1)+"/"+str(len(libraries))+" - "+libraries[ind][1]) |
4188 | + |
4189 | + # Writing a Makefile |
4190 | + logging.info(" - Writing a Makefile ...") |
4191 | + if libraries[ind][0]=='SampleAnalyzer': |
4192 | + if not compiler.WriteMakefile(): |
4193 | + logging.error("library building aborted.") |
4194 | + sys.exit() |
4195 | + else: |
4196 | + if not compiler.WriteMakefileForInterfaces(libraries[ind][2]): |
4197 | + logging.error("library building aborted.") |
4198 | + sys.exit() |
4199 | + |
4200 | + # Cleaning the project |
4201 | + logging.info(" - Cleaning the project before building the library ...") |
4202 | + if not compiler.MrProper(libraries[ind][2],libraries[ind][4]): |
4203 | + logging.error("library building aborted.") |
4204 | + sys.exit() |
4205 | + |
4206 | + # Compiling |
4207 | + logging.info(" - Compiling the source files ...") |
4208 | + if not compiler.Compile(ncores,libraries[ind][2],libraries[ind][4]): |
4209 | + logging.error("library building aborted.") |
4210 | + sys.exit() |
4211 | + |
4212 | + # Linking |
4213 | + logging.info(" - Linking the library ...") |
4214 | + if not compiler.Link(libraries[ind][2],libraries[ind][4]): |
4215 | + logging.error("library building aborted.") |
4216 | + sys.exit() |
4217 | + |
4218 | + # Checking |
4219 | + logging.info(" - Checking that the library is properly built ...") |
4220 | + if not os.path.isfile(libraries[ind][3]): |
4221 | + logging.error("the library '"+libraries[ind][3]+"' is not produced.") |
4222 | + sys.exit() |
4223 | + |
4224 | + # Cleaning the project |
4225 | + logging.info(" - Cleaning the project after building the library ...") |
4226 | + if not compiler.Clean(libraries[ind][2],libraries[ind][4]): |
4227 | + logging.error("library building aborted.") |
4228 | + sys.exit() |
4229 | + |
4230 | + # Print Ok |
4231 | + sys.stdout.write(" => Status: ") |
4232 | + self.PrintOK() |
4233 | + |
4234 | + logging.info(" **********************************************************") |
4235 | + logging.info(" Test program ") |
4236 | + |
4237 | + # Writing a Makefile |
4238 | + logging.info(" - Writing a Makefile ...") |
4239 | + if not compiler.WriteMakefileForTest(): |
4240 | + logging.error("test program building aborted.") |
4241 | + sys.exit() |
4242 | + |
4243 | + # Cleaning the project |
4244 | + logging.info(" - Cleaning the project before building the program ...") |
4245 | + if not compiler.MrProper('test',self.ma5dir+'/tools/SampleAnalyzer/Test'): |
4246 | + logging.error("test program building aborted.") |
4247 | + sys.exit() |
4248 | + |
4249 | + # Compiling |
4250 | + logging.info(" - Compiling the source files ...") |
4251 | + if not compiler.Compile(ncores,'test',self.ma5dir+'/tools/SampleAnalyzer/Test'): |
4252 | + logging.error("test program building aborted.") |
4253 | + sys.exit() |
4254 | + |
4255 | + # Linking |
4256 | + logging.info(" - Linking the program ...") |
4257 | + if not compiler.Link('test',self.ma5dir+'/tools/SampleAnalyzer/Test'): |
4258 | + logging.error("test program building aborted.") |
4259 | + sys.exit() |
4260 | + |
4261 | + # Checking |
4262 | + logging.info(" - Checking that the program is properly built ...") |
4263 | + filename=self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest' |
4264 | + if not os.path.isfile(filename): |
4265 | + logging.error("the test program '"+filename+"' is not produced.") |
4266 | + sys.exit() |
4267 | + |
4268 | + # Cleaning the project |
4269 | + logging.info(" - Cleaning the project after building the program ...") |
4270 | + if not compiler.Clean('test',self.ma5dir+'/tools/SampleAnalyzer/Test'): |
4271 | + logging.error("test program building aborted.") |
4272 | + sys.exit() |
4273 | + |
4274 | + # Running the program test |
4275 | + logging.info(" - Running the test program ...") |
4276 | + if not compiler.Run('SampleAnalyzerTest',[],self.ma5dir+'/tools/SampleAnalyzer/Test'): |
4277 | + logging.error("the test is failed.") |
4278 | + sys.exit() |
4279 | + |
4280 | + # Checking the program output |
4281 | + logging.info(" - Checking the program output...") |
4282 | + if not compiler.CheckRun(self.ma5dir+'/tools/SampleAnalyzer/Test/SampleAnalyzerTest.log'): |
4283 | + logging.error("the test is failed.") |
4284 | + sys.exit() |
4285 | + |
4286 | + # Print Ok |
4287 | + sys.stdout.write(" => Status: ") |
4288 | + self.PrintOK() |
4289 | + |
4290 | + |
4291 | + logging.info("") |
4292 | |
4293 | return True |
4294 | |
4295 | |
4296 | === modified file 'madanalysis/enumeration/observable_type.py' |
4297 | --- madanalysis/enumeration/observable_type.py 2013-05-17 06:19:22 +0000 |
4298 | +++ madanalysis/enumeration/observable_type.py 2014-05-17 19:51:11 +0000 |
4299 | @@ -30,10 +30,10 @@ |
4300 | # name : accept_particles |
4301 | values = { 'UNKNOWN' : [False,'','','','',0,0,0,False,False],\ |
4302 | 'SQRTS' : [False,'PHYSICS->SqrtS(event.mc())','PHYSICS->SqrtS(event.mc())','','GeV',100,0.,1000., True, False],\ |
4303 | - 'TET' : [False,'PHYSICS->EventTET(event.mc())','PHYSICS->EventTET(event.mc())','PHYSICS->EventTET(event.rec())','GeV',100,0.,1000., True,False],\ |
4304 | - 'MET' : [False,'PHYSICS->EventMET(event.mc())','PHYSICS->EventMET(event.mc())','PHYSICS->EventMET(event.rec())','GeV',100,0.,1000., True,False],\ |
4305 | - 'THT' : [False,'PHYSICS->EventTHT(event.mc())','PHYSICS->EventTHT(event.mc())','PHYSICS->EventTHT(event.rec())','GeV',100,0.,1000., True,False],\ |
4306 | - 'MHT' : [False,'PHYSICS->EventMHT(event.mc())','PHYSICS->EventMHT(event.mc())','PHYSICS->EventMHT(event.rec())','GeV',100,0.,1000.,True,False],\ |
4307 | + 'TET' : [False,'PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.mc())','PHYSICS->Transverse->EventTET(event.rec())','GeV',100,0.,1000., True,False],\ |
4308 | + 'MET' : [False,'PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.mc())','PHYSICS->Transverse->EventMET(event.rec())','GeV',100,0.,1000., True,False],\ |
4309 | + 'THT' : [False,'PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.mc())','PHYSICS->Transverse->EventTHT(event.rec())','GeV',100,0.,1000., True,False],\ |
4310 | + 'MHT' : [False,'PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.mc())','PHYSICS->Transverse->EventMHT(event.rec())','GeV',100,0.,1000.,True,False],\ |
4311 | 'NPID': [False,'NPID','NPID','NPID','',100,0.,100.,False,False],\ |
4312 | 'NAPID': [False,'NAPID','NAPID','NAPID','',100,0.,100.,False,False],\ |
4313 | 'E' : [True,'e()','e()','e()','GeV',100,0.,1000.,True,True],\ |
4314 | |
4315 | === added file 'madanalysis/input/installation_options.dat' |
4316 | --- madanalysis/input/installation_options.dat 1970-01-01 00:00:00 +0000 |
4317 | +++ madanalysis/input/installation_options.dat 2014-05-17 19:51:11 +0000 |
4318 | @@ -0,0 +1,35 @@ |
4319 | +# WARNING MA5 SHOULD DETECT AUTOMATICALLY YOUR CONFIGURATION |
4320 | +# IF THIS AUTOMATED MODE FAILS, YOU CAN FORCE SOME |
4321 | +# OPTIONS THROUGH THIS FILE |
4322 | + |
4323 | +# -----ROOT----- |
4324 | +# root_includes = /home/toto/root/include |
4325 | +# root_libs = /home/toto/root/lib |
4326 | + |
4327 | +# -----DELPHES----- |
4328 | +# delphes_veto = 0 # 0=No, 1=Yes |
4329 | +# delphes_includes = /home/toto/delphes/include |
4330 | +# delphes_libs = /home/toto/delphes/lib |
4331 | + |
4332 | +# -----DELFES----- |
4333 | +# delfes_veto = 0 # 0=No, 1=Yes |
4334 | +# delfes_includes = /home/toto/delfes/include |
4335 | +# delfes_libs = /home/toto/delfes/lib |
4336 | + |
4337 | +# -----ZLIB----- |
4338 | +# zlib_veto = 0 # 0=No, 1=Yes |
4339 | +# zlib_includes = /home/toto/zlib/include |
4340 | +# zlib_libs = /home/toto/zlib/lib |
4341 | + |
4342 | +# -----FASTJET----- |
4343 | +# fastjet_veto = 0 # 0=No, 1=Yes |
4344 | +# fastjet_bin_path = /home/toto/fastjet/include |
4345 | + |
4346 | +# -----PDFLATEX----- |
4347 | +# pdflatex_veto = 0 # 0=No, 1=Yes |
4348 | + |
4349 | +# -----LATEX----- |
4350 | +# latex_veto = 0 # 0=No, 1=Yes |
4351 | + |
4352 | +# -----DVIPDF----- |
4353 | +# dvipdf_veto = 0 # 0=No, 1=Yes |
4354 | |
4355 | === modified file 'madanalysis/input/particles_name_default.txt' |
4356 | --- madanalysis/input/particles_name_default.txt 2013-07-12 13:09:17 +0000 |
4357 | +++ madanalysis/input/particles_name_default.txt 2014-05-17 19:51:11 +0000 |
4358 | @@ -50,9 +50,8 @@ |
4359 | 23 z |
4360 | 24 w+ |
4361 | -24 w- |
4362 | -# Note that we can't give a name to 25 here, |
4363 | -# since it is different in SM and MSSM. |
4364 | -# MSSM Higgs |
4365 | +# The Higgs boson is called h1 |
4366 | + 25 h1 |
4367 | 35 h2 |
4368 | 36 h3 |
4369 | 37 h+ |
4370 | |
4371 | === modified file 'madanalysis/interpreter/cmd_base.py' |
4372 | --- madanalysis/interpreter/cmd_base.py 2013-05-17 06:19:22 +0000 |
4373 | +++ madanalysis/interpreter/cmd_base.py 2014-05-17 19:51:11 +0000 |
4374 | @@ -29,7 +29,7 @@ |
4375 | class CmdBase(): |
4376 | """Command CMDBase""" |
4377 | |
4378 | - reserved_words=["exit","quit","eof","history","shell","from","as","all","or","and"] |
4379 | + reserved_words=["exit","quit","eof","history","shell","from","as","all","or","and","main"] |
4380 | |
4381 | def __init__(self,main,cmd_name): |
4382 | self.reserved_words.append(cmd_name) |
4383 | |
4384 | === modified file 'madanalysis/interpreter/cmd_install.py' |
4385 | --- madanalysis/interpreter/cmd_install.py 2013-10-27 21:05:18 +0000 |
4386 | +++ madanalysis/interpreter/cmd_install.py 2014-05-17 19:51:11 +0000 |
4387 | @@ -23,6 +23,7 @@ |
4388 | |
4389 | |
4390 | from madanalysis.interpreter.cmd_base import CmdBase |
4391 | +from madanalysis.IOinterface.delphes_migration import DelphesMigration |
4392 | import logging |
4393 | import os |
4394 | import sys |
4395 | @@ -86,6 +87,8 @@ |
4396 | return self.install_zlib() |
4397 | elif args[0]=='delphes': |
4398 | return self.install_delphes() |
4399 | + elif args[0]=='delfes': |
4400 | + return self.install_delfes() |
4401 | elif args[0]=='fastjet': |
4402 | return self.install_fastjet() |
4403 | elif args[0]=='MCatNLO-for-ma5': |
4404 | @@ -99,7 +102,7 @@ |
4405 | def help(self): |
4406 | logging.info(" Syntax: install <component>") |
4407 | logging.info(" Download and install a MadAnalysis component from the official site.") |
4408 | - logging.info(" List of available components : samples zlib fastjet MCatNLO-for-ma5 delphes") |
4409 | + logging.info(" List of available components : samples zlib fastjet MCatNLO-for-ma5 delphes delfes") |
4410 | |
4411 | |
4412 | def get_ncores(self): |
4413 | @@ -219,8 +222,7 @@ |
4414 | # End |
4415 | logging.info("Installation complete.") |
4416 | |
4417 | - |
4418 | - return True |
4419 | + return 'restart' |
4420 | |
4421 | |
4422 | def install_delphes(self): |
4423 | @@ -244,9 +246,11 @@ |
4424 | installdir = self.main.ma5dir + '/tools/delphes/' |
4425 | |
4426 | # List of files |
4427 | - files = { "delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.10.tar.gz" } |
4428 | + #files = { "delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.12.tar.gz" } |
4429 | + files = { "delphes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.1.1.tar.gz"} |
4430 | |
4431 | # Launching wget |
4432 | + logging.info("Configuring the package ...") |
4433 | if not self.wget(files,'delphes',installdir): |
4434 | return False |
4435 | |
4436 | @@ -287,8 +291,85 @@ |
4437 | # End |
4438 | logging.info("Installation complete.") |
4439 | |
4440 | - |
4441 | - return True |
4442 | + return 'restart' |
4443 | + |
4444 | + |
4445 | + def install_delfes(self): |
4446 | + |
4447 | + # Asking for number of cores |
4448 | + ncores = self.get_ncores() |
4449 | + |
4450 | + # Checking connection with MA5 web site |
4451 | + if not self.check_ma5site(): |
4452 | + return False |
4453 | + |
4454 | + # Creating tools folder |
4455 | + if not self.create_tools_folder(): |
4456 | + return False |
4457 | + |
4458 | + # Creating package folder |
4459 | + if not self.create_package_folder('delfes'): |
4460 | + return False |
4461 | + |
4462 | + # Directory to install |
4463 | + installdir = self.main.ma5dir + '/tools/delfes/' |
4464 | + |
4465 | + # List of files |
4466 | +# files = { "delfes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.0.12.tar.gz" } |
4467 | + files = { "delfes.tar.gz" : "http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.1.1.tar.gz"} |
4468 | + |
4469 | + # Launching wget |
4470 | + if not self.wget(files,'delfes',installdir): |
4471 | + return False |
4472 | + |
4473 | + # Detarring package |
4474 | + packagedir = self.untar(installdir,'delfes.tar.gz','delfes') |
4475 | + if packagedir == "": |
4476 | + return False |
4477 | + |
4478 | + # Changing the name of the directory |
4479 | + os.system("mv "+packagedir+"/* "+self.main.ma5dir+"/tools/delfes/") |
4480 | + packagedir = self.main.ma5dir+"/tools/delfes/" |
4481 | + |
4482 | + # Migration |
4483 | + logging.info("Applying the MadAnalysis 5 patch to the package ...") |
4484 | + migrator = DelphesMigration(self.main) |
4485 | + migrator.Migrate() |
4486 | + |
4487 | + # Configuring |
4488 | + logging.info("Configuring the package ...") |
4489 | + os.system("cd "+packagedir+" ; ./configure > "+self.main.ma5dir+"/tools/delfes/"+"configuration.log 2>&1") |
4490 | + |
4491 | + # Compiling |
4492 | + logging.info("Compiling the package ...") |
4493 | + os.system("cd "+packagedir+" ; make -j"+str(ncores)+" > "+self.main.ma5dir+"/tools/delfes/"+"compilation.log 2>&1") |
4494 | + |
4495 | + # Final check |
4496 | + logging.info("Checking installation ...") |
4497 | + if (not os.path.isdir(self.main.ma5dir+"/tools/delfes/modules")): |
4498 | + logging.error('package modules are missing.') |
4499 | + self.display_log('delfes') |
4500 | + return False |
4501 | + |
4502 | + if not os.path.isfile(self.main.ma5dir+'/tools/delfes/modules/ParticlePropagator.h'): |
4503 | + logging.error("header labeled 'modules/ParticlePropagator.h' is missing.") |
4504 | + self.display_log('delfes') |
4505 | + return False |
4506 | + |
4507 | + if not os.path.isfile(self.main.ma5dir+'/tools/delfes/libDelphes.so'): |
4508 | + logging.error("library labeled 'libdelphes.so' is missing.") |
4509 | + self.display_log('delfes') |
4510 | + return False |
4511 | + |
4512 | + if not os.path.isfile(self.main.ma5dir+'/tools/delfes/DelphesSTDHEP'): |
4513 | + logging.error("library labeled 'DelphesSTDHEP' is missing.") |
4514 | + self.display_log('delfes') |
4515 | + return False |
4516 | + |
4517 | + # End |
4518 | + logging.info("Installation complete.") |
4519 | + |
4520 | + return 'restart' |
4521 | |
4522 | |
4523 | def install_mcatnlo(self): |
4524 | @@ -423,7 +504,7 @@ |
4525 | for file,url in files.items(): |
4526 | ind+=1 |
4527 | result="OK" |
4528 | - logging.info(' * ' + str(ind)+"/"+str(len(files.keys()))+" Downloading the file '"+file+"' ...") |
4529 | + logging.info(' * ' + str(ind)+"/"+str(len(files.keys()))+" Downloading the file "+url+" ...") |
4530 | |
4531 | try: |
4532 | urllib.urlretrieve(url,installdir+'/'+file,CmdInstall.reporthook) |
4533 | @@ -473,7 +554,7 @@ |
4534 | return False |
4535 | |
4536 | # List of files |
4537 | - files = { "fastjet.tar.gz" : "https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/WikiStart/fastjet-3.0.3.tar.gz" } |
4538 | + files = { "fastjet.tar.gz" : "http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/WikiStart/fastjet-3.0.6.tar.gz" } |
4539 | |
4540 | # Launching wget |
4541 | if not self.wget(files,'fastjet',installdir): |
4542 | @@ -521,11 +602,10 @@ |
4543 | self.display_log('fastjet') |
4544 | return False |
4545 | |
4546 | - |
4547 | # End |
4548 | logging.info("Installation complete.") |
4549 | |
4550 | - return True |
4551 | + return 'restart' |
4552 | |
4553 | |
4554 | def install_samples(self): |
4555 | @@ -593,7 +673,7 @@ |
4556 | if nargs>2: |
4557 | return [] |
4558 | else: |
4559 | - output = ["samples","zlib","fastjet", "MCatNLO-for-ma5", "delphes" ] |
4560 | + output = ["samples","zlib","fastjet", "MCatNLO-for-ma5", "delphes", "delfes" ] |
4561 | return self.finalize_complete(text,output) |
4562 | |
4563 | |
4564 | |
4565 | === modified file 'madanalysis/interpreter/cmd_plot.py' |
4566 | --- madanalysis/interpreter/cmd_plot.py 2013-05-17 06:19:22 +0000 |
4567 | +++ madanalysis/interpreter/cmd_plot.py 2014-05-17 19:51:11 +0000 |
4568 | @@ -54,7 +54,6 @@ |
4569 | |
4570 | # Getting reference to observable |
4571 | obsRef=self.main.observables.get(obsName) |
4572 | - |
4573 | foundArguments = False |
4574 | foundOptions = False |
4575 | foundBinning = False |
4576 | @@ -80,7 +79,7 @@ |
4577 | Nbracket2-=1 |
4578 | if i==(len(args)-1): |
4579 | foundOptions=True |
4580 | - |
4581 | + |
4582 | if Nbracket1!=0: |
4583 | logging.error("number of opening-bracket '(' and number of " +\ |
4584 | "closing-braket ')' does not match.") |
4585 | @@ -168,6 +167,11 @@ |
4586 | arguments=self.extract_arguments(args[2:endArguments],obsName,obsRef) |
4587 | if arguments==None: |
4588 | return |
4589 | + elif len(obsRef.args) !=0: # checks whether arguments should have been provided |
4590 | + logging.error("the observable '"+obsName+"' requires "+ |
4591 | + str(len(obsRef.args))+" arguments whereas no arguments have been specified.") |
4592 | + return |
4593 | + |
4594 | |
4595 | # Creating histo |
4596 | histo = Histogram(obsRef,arguments,nbins,xmin,xmax) |
4597 | |
4598 | === modified file 'madanalysis/interpreter/cmd_set.py' |
4599 | --- madanalysis/interpreter/cmd_set.py 2013-09-26 12:30:50 +0000 |
4600 | +++ madanalysis/interpreter/cmd_set.py 2014-05-17 19:51:11 +0000 |
4601 | @@ -102,7 +102,7 @@ |
4602 | elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='merging': |
4603 | self.main.merging.user_SetParameter(objs[2],args[2],self.main.mode,self.main.libFastJet) |
4604 | elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='fastsim': |
4605 | - self.main.fastsim.user_SetParameter(objs[2],args[2],self.main.datasets,self.main.mode,self.main.libFastJet,self.main.libDelphes) |
4606 | + self.main.fastsim.user_SetParameter(objs[2],args[2],self.main.datasets,self.main.mode,self.main.libFastJet,self.main.libDelphes,self.main.libDelfes) |
4607 | elif len(objs)==3 and objs[0].lower()=='main' and objs[1].lower()=='shower': |
4608 | self.main.shower.user_SetParameter(objs[2],args[2],self.main.mode,self.main.mcatnloutils) |
4609 | else: |
4610 | |
4611 | === modified file 'madanalysis/interpreter/cmd_submit.py' |
4612 | --- madanalysis/interpreter/cmd_submit.py 2013-10-27 21:36:24 +0000 |
4613 | +++ madanalysis/interpreter/cmd_submit.py 2014-05-17 19:51:11 +0000 |
4614 | @@ -335,16 +335,10 @@ |
4615 | if answer=="no" or answer=="n": |
4616 | return |
4617 | else: |
4618 | - if self.main.fastsim.delphes.pileup=="": |
4619 | - if self.main.fastsim.delphes.detector=='cms': |
4620 | - cardname = 'delphes_card_CMS.tcl' |
4621 | - elif self.main.fastsim.delphes.detector=='atlas': |
4622 | - cardname ='delphes_card_ATLAS.tcl' |
4623 | - else: |
4624 | - if self.main.fastsim.delphes.detector=='cms': |
4625 | - cardname = 'delphes_card_CMS_PileUp.tcl' |
4626 | - elif self.main.fastsim.delphes.detector=='atlas': |
4627 | - cardname ='delphes_card_ATLAS_PileUp.tcl' |
4628 | + if self.main.fastsim.package=="delphes": |
4629 | + cardname = self.main.fastsim.delphes.card |
4630 | + elif self.main.fastsim.package=="delfes": |
4631 | + cardname = self.main.fastsim.delfes.card |
4632 | os.system(self.main.configLinux.editor+" "+dirname+"/Input/"+cardname) |
4633 | |
4634 | |
4635 | @@ -408,9 +402,15 @@ |
4636 | return False |
4637 | |
4638 | #edit the delphes cards |
4639 | - if self.main.fastsim.package=="delphes": |
4640 | + if self.main.fastsim.package in ["delphes","delfes"]: |
4641 | self.editDelphesCard(dirname) |
4642 | |
4643 | + if self.resubmit: |
4644 | + logging.info(" Cleaning 'SampleAnalyzer'...") |
4645 | + if not jobber.MrproperJob(): |
4646 | + logging.error("job submission aborted.") |
4647 | + return False |
4648 | + |
4649 | logging.info(" Compiling 'SampleAnalyzer'...") |
4650 | if not jobber.CompileJob(): |
4651 | logging.error("job submission aborted.") |
4652 | |
4653 | === modified file 'madanalysis/interpreter/interpreter.py' |
4654 | --- madanalysis/interpreter/interpreter.py 2013-05-31 21:57:38 +0000 |
4655 | +++ madanalysis/interpreter/interpreter.py 2014-05-17 19:51:11 +0000 |
4656 | @@ -26,6 +26,7 @@ |
4657 | Uses the cmd package for command interpretation and tab completion. |
4658 | """ |
4659 | |
4660 | +import logging |
4661 | import readline |
4662 | import os |
4663 | |
4664 | @@ -174,6 +175,38 @@ |
4665 | def complete_import(self,text,line,begidx,endidx): |
4666 | return self.cmd_import.complete(text,line,begidx,endidx) |
4667 | |
4668 | + # Restart |
4669 | + def do_restart(self, line): |
4670 | + """ sending a signal allowing to restart the interpreter """ |
4671 | + if self.main.script: |
4672 | + logging.warning("'restart' command is not allowed in script mode.") |
4673 | + else: |
4674 | + YES=False |
4675 | + # Asking the safety question |
4676 | + if not Main.forced: |
4677 | + logging.warning("Are you sure to restart the MadAnalysis 5 session? (Y/N)") |
4678 | + allowed_answers=['n','no','y','yes'] |
4679 | + answer="" |
4680 | + while answer not in allowed_answers: |
4681 | + answer=raw_input("Answer: ") |
4682 | + answer=answer.lower() |
4683 | + if answer=="no" or answer=="n": |
4684 | + YES=False |
4685 | + break |
4686 | + elif answer=='yes' or answer=='y': |
4687 | + YES=True |
4688 | + break |
4689 | + if YES: |
4690 | + self.main.repeatSession=True |
4691 | + return True |
4692 | + else: |
4693 | + pass |
4694 | + |
4695 | + def help_restart(self): |
4696 | + logging.info(" Syntax: restart ") |
4697 | + logging.info(" Quit the current MadAnalysis sessiona and open a new one.") |
4698 | + logging.info(" All the information will be discarded.") |
4699 | + |
4700 | def do_remove(self,line): |
4701 | self.cmd_remove.do(self.split_arg(line)) |
4702 | |
4703 | @@ -193,7 +226,11 @@ |
4704 | return self.cmd_swap.complete(text,line,begidx,endidx) |
4705 | |
4706 | def do_install(self,line): |
4707 | - self.cmd_install.do(self.split_arg(line)) |
4708 | + result = self.cmd_install.do(self.split_arg(line)) |
4709 | + if result=='restart': |
4710 | + logging.info(" ") |
4711 | + logging.info("MadAnalysis 5 must be restarted for taking into account the present installation.") |
4712 | + return self.do_restart('restart') |
4713 | |
4714 | def help_install(self): |
4715 | self.cmd_install.help() |
4716 | |
4717 | === modified file 'madanalysis/interpreter/interpreter_base.py' |
4718 | --- madanalysis/interpreter/interpreter_base.py 2013-05-24 13:05:09 +0000 |
4719 | +++ madanalysis/interpreter/interpreter_base.py 2014-05-17 19:51:11 +0000 |
4720 | @@ -190,7 +190,7 @@ |
4721 | """ exit the mainloop() """ |
4722 | logging.info("") |
4723 | return True |
4724 | - |
4725 | + |
4726 | # Aliases |
4727 | do_EOF = do_quit |
4728 | do_exit = do_quit |
4729 | |
4730 | === modified file 'madanalysis/job/job_candidate_cut.py' |
4731 | --- madanalysis/job/job_candidate_cut.py 2013-05-17 06:19:22 +0000 |
4732 | +++ madanalysis/job/job_candidate_cut.py 2014-05-17 19:51:11 +0000 |
4733 | @@ -212,7 +212,7 @@ |
4734 | # Bracket for begin |
4735 | file.write(' {\n') |
4736 | |
4737 | - file.write(' '+container2+'=PHYSICS->rankFilter('+\ |
4738 | + file.write(' '+container2+'=SORTER->rankFilter('+\ |
4739 | newcontainer2+','+str(other_part[0].PTrank)+','+\ |
4740 | 'PTordering'+');\n\n') |
4741 | |
4742 | @@ -305,8 +305,14 @@ |
4743 | # Case of one particle/multiparticle |
4744 | if len(combi1)==1: |
4745 | file.write(' if (') |
4746 | + if main.mode == MA5RunningType.PARTON: |
4747 | + TheObs=obs.code_parton[:-2] |
4748 | + elif main.mode == MA5RunningType.HADRON: |
4749 | + TheObs=obs.code_hadron[:-2] |
4750 | + else: |
4751 | + TheObs=obs.code_reco[:-2] |
4752 | file.write(containers1[0]+'[a]->' +\ |
4753 | - 'dr('+container+'[muf])' +\ |
4754 | + TheObs+'('+container+'[muf])' +\ |
4755 | OperatorType.convert2cpp(condition.operator) +\ |
4756 | str(condition.threshold) +\ |
4757 | ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n') |
4758 | @@ -338,8 +344,14 @@ |
4759 | |
4760 | # Result |
4761 | file.write(' if (q1.') |
4762 | - if obs.name in ['DELTAR','vDELTAR']: |
4763 | - file.write('dr('+container+'[muf])'+ OperatorType.convert2cpp(condition.operator) + \ |
4764 | + if obs.name in ['DELTAR','vDELTAR','DPHI_0_PI','DPHI_0_2PI']: |
4765 | + if main.mode == MA5RunningType.PARTON: |
4766 | + TheObs=obs.code_parton[:-2] |
4767 | + elif main.mode == MA5RunningType.HADRON: |
4768 | + TheObs=obs.code_hadron[:-2] |
4769 | + else: |
4770 | + TheObs=obs.code_reco[:-2] |
4771 | + file.write(TheObs+'('+container+'[muf])'+ OperatorType.convert2cpp(condition.operator) + \ |
4772 | str(condition.threshold) + \ |
4773 | ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n') |
4774 | else: |
4775 | |
4776 | === modified file 'madanalysis/job/job_event_cut.py' |
4777 | --- madanalysis/job/job_event_cut.py 2013-05-17 06:19:22 +0000 |
4778 | +++ madanalysis/job/job_event_cut.py 2014-05-17 19:51:11 +0000 |
4779 | @@ -243,9 +243,15 @@ |
4780 | |
4781 | # Case of one particle/multiparticle |
4782 | if len(combi1)==1 and len(combi2)==1: |
4783 | + if main.mode == MA5RunningType.PARTON: |
4784 | + TheObs=obs.code_parton[:-2] |
4785 | + elif main.mode == MA5RunningType.HADRON: |
4786 | + TheObs=obs.code_hadron[:-2] |
4787 | + else: |
4788 | + TheObs=obs.code_reco[:-2] |
4789 | file.write(' if (') |
4790 | file.write(containers1[0]+'['+iterator1+'[0]]->' +\ |
4791 | - 'dr('+containers2[0]+'['+iterator2+'[0]])' +\ |
4792 | + TheObs+'('+containers2[0]+'['+iterator2+'[0]])' +\ |
4793 | OperatorType.convert2cpp(condition.operator) +\ |
4794 | str(condition.threshold) +\ |
4795 | ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n') |
4796 | @@ -279,7 +285,13 @@ |
4797 | 'momentum();\n') |
4798 | |
4799 | # Result |
4800 | - file.write(' if (q1.dr(q2)'+\ |
4801 | + if main.mode == MA5RunningType.PARTON: |
4802 | + TheObs=obs.code_parton[:-2] |
4803 | + elif main.mode == MA5RunningType.HADRON: |
4804 | + TheObs=obs.code_hadron[:-2] |
4805 | + else: |
4806 | + TheObs=obs.code_reco[:-2] |
4807 | + file.write(' if (q1.'+TheObs+'(q2)'+\ |
4808 | ''+ OperatorType.convert2cpp(condition.operator) + \ |
4809 | str(condition.threshold) + \ |
4810 | ') {'+tagName+'['+str(tagIndex)+']=true; break;}\n') |
4811 | |
4812 | === modified file 'madanalysis/job/job_execute.py' |
4813 | --- madanalysis/job/job_execute.py 2013-10-03 16:02:40 +0000 |
4814 | +++ madanalysis/job/job_execute.py 2014-05-17 19:51:11 +0000 |
4815 | @@ -69,7 +69,7 @@ |
4816 | |
4817 | file.write(' // Sorting particle collection according to '+rank+'\n') |
4818 | file.write(' // for getting '+str(part.PTrank)+'th particle\n') |
4819 | - file.write(' '+container+'=PHYSICS->rankFilter('+\ |
4820 | + file.write(' '+container+'=SORTER->rankFilter('+\ |
4821 | newcontainer+','+str(part.PTrank)+','+rank+');\n\n') |
4822 | |
4823 | |
4824 | @@ -206,13 +206,13 @@ |
4825 | # Put isolated negative muon |
4826 | if part.particle.Find(130): |
4827 | file.write(' if ( (event.rec()->muons()[i].charge()<0) &&'+\ |
4828 | - ' PHYSICS->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\ |
4829 | + ' PHYSICS->Id->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\ |
4830 | container+'.push_back(&(event.rec()->muons()[i]));\n') |
4831 | |
4832 | # Put isolated positive muon |
4833 | if part.particle.Find(-130): |
4834 | file.write(' if ( (event.rec()->muons()[i].charge()>0) &&'+\ |
4835 | - ' PHYSICS->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\ |
4836 | + ' PHYSICS->Id->IsIsolatedMuon(event.rec()->muons()[i],event.rec()) ) '+\ |
4837 | container+'.push_back(&(event.rec()->muons()[i]));\n') |
4838 | |
4839 | |
4840 | |
4841 | === modified file 'madanalysis/job/job_header.py' |
4842 | --- madanalysis/job/job_header.py 2013-05-17 06:19:22 +0000 |
4843 | +++ madanalysis/job/job_header.py 2014-05-17 19:51:11 +0000 |
4844 | @@ -139,11 +139,11 @@ |
4845 | |
4846 | # FinalSate |
4847 | if status=="finalstate": |
4848 | - file.write(" if ( !PHYSICS->IsFinalState(part) ) return false;\n") |
4849 | + file.write(" if ( !PHYSICS->Id->IsFinalState(part) ) return false;\n") |
4850 | elif status=="initialstate": |
4851 | - file.write(" if ( !PHYSICS->IsInitialState(part) ) return false;\n") |
4852 | + file.write(" if ( !PHYSICS->Id->IsInitialState(part) ) return false;\n") |
4853 | elif status=="interstate": |
4854 | - file.write(" if ( !PHYSICS->IsInterState(part) ) return false;\n") |
4855 | + file.write(" if ( !PHYSICS->Id->IsInterState(part) ) return false;\n") |
4856 | |
4857 | # Id |
4858 | file.write(' if ( ') |
4859 | |
4860 | === modified file 'madanalysis/job/job_initialize.py' |
4861 | --- madanalysis/job/job_initialize.py 2013-07-12 13:09:17 +0000 |
4862 | +++ madanalysis/job/job_initialize.py 2014-05-17 19:51:11 +0000 |
4863 | @@ -428,6 +428,9 @@ |
4864 | file.write(' PHYSICS->mcConfig().AddInvisibleId(16);\n') |
4865 | file.write(' PHYSICS->mcConfig().AddInvisibleId(1000022);\n') |
4866 | file.write(' PHYSICS->mcConfig().AddInvisibleId(1000039);\n') |
4867 | + for item in main.multiparticles.Get("invisible"): |
4868 | + if item not in [-16,-14,-12,12,14,16,1000022,1000039]: |
4869 | + file.write(' PHYSICS->mcConfig().AddInvisibleId('+str(item)+');\n') |
4870 | file.write('\n') |
4871 | |
4872 | |
4873 | @@ -456,7 +459,12 @@ |
4874 | # Initializing array of cuts |
4875 | if Ncuts!=0: |
4876 | file.write(' // Initializing cut array\n') |
4877 | - file.write(' cuts_.Initialize('+str(Ncuts)+');\n') |
4878 | + icut=1 |
4879 | + for item in main.selection.table: |
4880 | + if item.__class__.__name__=="Cut": |
4881 | + file.write(" cuts_.InitCut(\""+item.conditions.GetStringDisplay()+"\");\n") |
4882 | + if Ncuts!=0: |
4883 | + file.write('\n') |
4884 | |
4885 | # Initializing each item |
4886 | ihisto = 0 |
4887 | |
4888 | === modified file 'madanalysis/job/job_plot.py' |
4889 | --- madanalysis/job/job_plot.py 2013-10-29 05:48:23 +0000 |
4890 | +++ madanalysis/job/job_plot.py 2014-05-17 19:51:11 +0000 |
4891 | @@ -72,11 +72,11 @@ |
4892 | file.write(' for (unsigned int i=0;i<event.mc()->particles().size();i++)\n') |
4893 | file.write(' {\n') |
4894 | if main.selection[iabs].statuscode=="finalstate": |
4895 | - file.write(' if (!PHYSICS->IsFinalState(event.mc()->particles()[i])) continue;\n') |
4896 | + file.write(' if (!PHYSICS->Id->IsFinalState(event.mc()->particles()[i])) continue;\n') |
4897 | elif main.selection[iabs].statuscode=="initialstate": |
4898 | - file.write(' if (!PHYSICS->IsInitialState(event.mc()->particles()[i])) continue;\n') |
4899 | + file.write(' if (!PHYSICS->Id->IsInitialState(event.mc()->particles()[i])) continue;\n') |
4900 | elif main.selection[iabs].statuscode=="interstate": |
4901 | - file.write(' if (!PHYSICS->IsInterState(event.mc()->particles()[i])) continue;\n') |
4902 | + file.write(' if (!PHYSICS->Id->IsInterState(event.mc()->particles()[i])) continue;\n') |
4903 | if npid: |
4904 | file.write(' H'+str(ihisto)+'_' +\ |
4905 | '->Fill(event.mc()->particles()[i].pdgid(),__event_weight__);\n') |
4906 | @@ -245,8 +245,14 @@ |
4907 | |
4908 | # Case of one particle/multiparticle |
4909 | if len(combi2)==1: |
4910 | + if main.mode == MA5RunningType.PARTON: |
4911 | + TheObs=obs.code_parton[:-2] |
4912 | + elif main.mode == MA5RunningType.HADRON: |
4913 | + TheObs=obs.code_hadron[:-2] |
4914 | + else: |
4915 | + TheObs=obs.code_reco[:-2] |
4916 | file.write(' H'+str(ihisto)+'_->Fill('\ |
4917 | - 'q1.dr('+containers2[0]+\ |
4918 | + 'q1.'+TheObs+'('+containers2[0]+\ |
4919 | '[b[0]]),__event_weight__);\n') |
4920 | |
4921 | # Operation : sum or diff |
4922 | @@ -275,8 +281,14 @@ |
4923 | 'momentum();\n') |
4924 | |
4925 | # Result |
4926 | + if main.mode == MA5RunningType.PARTON: |
4927 | + TheObs=obs.code_parton[:-2] |
4928 | + elif main.mode == MA5RunningType.HADRON: |
4929 | + TheObs=obs.code_hadron[:-2] |
4930 | + else: |
4931 | + TheObs=obs.code_reco[:-2] |
4932 | file.write(' H'+str(ihisto)+'_->Fill('+\ |
4933 | - 'q1.dr(q2),__event_weight__);\n') |
4934 | + 'q1.'+TheObs+'(q2),__event_weight__);\n') |
4935 | |
4936 | # End Loop |
4937 | WriteEndLoop(file,iabs,ihisto,combi2,main) |
4938 | @@ -317,8 +329,14 @@ |
4939 | |
4940 | # Case of one particle/multiparticle |
4941 | if len(combi1)==1: |
4942 | + if main.mode == MA5RunningType.PARTON: |
4943 | + TheObs=obs.code_parton[:-2] |
4944 | + elif main.mode == MA5RunningType.HADRON: |
4945 | + TheObs=obs.code_hadron[:-2] |
4946 | + else: |
4947 | + TheObs=obs.code_reco[:-2] |
4948 | file.write(' H'+str(ihisto)+'_->Fill('\ |
4949 | - 'q2.dr('+containers1[0]+\ |
4950 | + 'q2.'+TheObs+'('+containers1[0]+\ |
4951 | '[a[0]]),__event_weight__);\n') |
4952 | |
4953 | # Operation : sum or diff |
4954 | @@ -347,8 +365,14 @@ |
4955 | 'momentum();\n') |
4956 | |
4957 | # Result |
4958 | + if main.mode == MA5RunningType.PARTON: |
4959 | + TheObs=obs.code_parton[:-2] |
4960 | + elif main.mode == MA5RunningType.HADRON: |
4961 | + TheObs=obs.code_hadron[:-2] |
4962 | + else: |
4963 | + TheObs=obs.code_reco[:-2] |
4964 | file.write(' H'+str(ihisto)+'_->Fill('+\ |
4965 | - 'q1.dr(q2),__event_weight__);\n') |
4966 | + 'q1.'+TheObs+'(q2),__event_weight__);\n') |
4967 | |
4968 | # End Loop |
4969 | WriteEndLoop(file,iabs,ihisto,combi1,main) |
4970 | @@ -389,7 +413,13 @@ |
4971 | WriteEndLoop(file,ihisto,iabs,combi2,main) |
4972 | |
4973 | # After the two loops |
4974 | - file.write(' H'+str(ihisto)+'_->Fill(q1.dr(q2),__event_weight__);\n') |
4975 | + if main.mode == MA5RunningType.PARTON: |
4976 | + TheObs=obs.code_parton[:-2] |
4977 | + elif main.mode == MA5RunningType.HADRON: |
4978 | + TheObs=obs.code_hadron[:-2] |
4979 | + else: |
4980 | + TheObs=obs.code_reco[:-2] |
4981 | + file.write(' H'+str(ihisto)+'_->Fill(q1.'+TheObs+'(q2),__event_weight__);\n') |
4982 | |
4983 | |
4984 | def WriteBeforeLoop(file,iabs,ihisto,combination,main,value='value',q='q'): |
4985 | @@ -567,9 +597,15 @@ |
4986 | |
4987 | # Case of one particle/multiparticle |
4988 | if len(combi1)==1 and len(combi2)==1: |
4989 | + if main.mode == MA5RunningType.PARTON: |
4990 | + TheObs=obs.code_parton[:-2] |
4991 | + elif main.mode == MA5RunningType.HADRON: |
4992 | + TheObs=obs.code_hadron[:-2] |
4993 | + else: |
4994 | + TheObs=obs.code_reco[:-2] |
4995 | file.write(' H'+str(ihisto)+'_->Fill('+\ |
4996 | containers1[0]+'['+iterator1+'[0]]->'+\ |
4997 | - 'dr('+containers2[0]+'['+iterator2+'[0]]),__event_weight__);\n') |
4998 | + TheObs+'('+containers2[0]+'['+iterator2+'[0]]),__event_weight__);\n') |
4999 | return |
5000 |
The diff has been truncated for viewing.