|
1 | 1 | ################################################################################ |
2 | | -# |
| 2 | +# |
3 | 3 | # Copyright (C) 2012-2022 Jack Araz, Eric Conte & Benjamin Fuks |
4 | 4 | # The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr> |
5 | | -# |
| 5 | +# |
6 | 6 | # This file is part of MadAnalysis 5. |
7 | 7 | # Official website: <https://github.com/MadAnalysis/madanalysis5> |
8 | | -# |
| 8 | +# |
9 | 9 | # MadAnalysis 5 is free software: you can redistribute it and/or modify |
10 | 10 | # it under the terms of the GNU General Public License as published by |
11 | 11 | # the Free Software Foundation, either version 3 of the License, or |
12 | 12 | # (at your option) any later version. |
13 | | -# |
| 13 | +# |
14 | 14 | # MadAnalysis 5 is distributed in the hope that it will be useful, |
15 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | 17 | # GNU General Public License for more details. |
18 | | -# |
| 18 | +# |
19 | 19 | # You should have received a copy of the GNU General Public License |
20 | 20 | # along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/> |
21 | | -# |
| 21 | +# |
22 | 22 | ################################################################################ |
23 | 23 |
|
24 | 24 |
|
25 | 25 | from __future__ import absolute_import |
26 | 26 | from madanalysis.enumeration.ma5_running_type import MA5RunningType |
27 | | -class ObservableBase(): |
28 | | - def __init__(self, |
29 | | - name, args, combination, |
30 | | - plot_auto, plot_nbins, plot_xmin, |
31 | | - plot_xmax, plot_unitX_tlatex, plot_unitX_latex,\ |
32 | | - code_parton, code_hadron, code_reco, cut_event, \ |
33 | | - cut_candidate, tlatex, latex): |
34 | | - self.name = name |
35 | | - self.args = args |
36 | | - self.plot_auto = plot_auto |
37 | | - self.plot_nbins = plot_nbins |
38 | | - self.plot_xmin = plot_xmin |
39 | | - self.plot_xmax = plot_xmax |
40 | | - self.plot_unitX_tlatex = plot_unitX_tlatex |
41 | | - self.plot_unitX_latex = plot_unitX_latex |
42 | | - self.code_parton = code_parton |
43 | | - self.code_hadron = code_hadron |
44 | | - self.code_reco = code_reco |
45 | | - self.cut_event = cut_event |
46 | | - self.cut_candidate = cut_candidate |
47 | | - self.combination = combination |
48 | | - self.tlatex = tlatex |
49 | | - self.latex = latex |
50 | 27 |
|
51 | 28 |
|
52 | | - def code(self,level): |
53 | | - if level==MA5RunningType.PARTON: |
| 29 | +class ObservableBase: |
| 30 | + def __init__( |
| 31 | + self, |
| 32 | + name, |
| 33 | + args, |
| 34 | + combination, |
| 35 | + plot_auto, |
| 36 | + plot_nbins, |
| 37 | + plot_xmin, |
| 38 | + plot_xmax, |
| 39 | + plot_unitX_tlatex, |
| 40 | + plot_unitX_latex, |
| 41 | + code_parton, |
| 42 | + code_hadron, |
| 43 | + code_reco, |
| 44 | + cut_event, |
| 45 | + cut_candidate, |
| 46 | + tlatex, |
| 47 | + latex, |
| 48 | + ): |
| 49 | + self.name = name |
| 50 | + self.args = args |
| 51 | + self.plot_auto = plot_auto |
| 52 | + self.plot_nbins = plot_nbins |
| 53 | + self.plot_xmin = plot_xmin |
| 54 | + self.plot_xmax = plot_xmax |
| 55 | + self.plot_unitX_tlatex = plot_unitX_tlatex |
| 56 | + self.plot_unitX_latex = plot_unitX_latex |
| 57 | + self.code_parton = code_parton |
| 58 | + self.code_hadron = code_hadron |
| 59 | + self.code_reco = code_reco |
| 60 | + self.cut_event = cut_event |
| 61 | + self.cut_candidate = cut_candidate |
| 62 | + self.combination = combination |
| 63 | + self.tlatex = tlatex |
| 64 | + self.latex = latex |
| 65 | + |
| 66 | + def code(self, level): |
| 67 | + if level == MA5RunningType.PARTON: |
54 | 68 | return self.code_parton |
55 | | - elif level==MA5RunningType.HADRON: |
| 69 | + elif level == MA5RunningType.HADRON: |
56 | 70 | return self.code_hadron |
57 | | - elif level==MA5RunningType.RECO: |
| 71 | + elif level == MA5RunningType.RECO: |
58 | 72 | return self.code_reco |
59 | 73 | else: |
60 | 74 | return None |
61 | | - |
62 | 75 |
|
63 | 76 | @staticmethod |
64 | | - def Clone(obs, |
65 | | - name=None, args=None, combination=None, |
66 | | - plot_auto=None, plot_nbins=None, plot_xmin=None, |
67 | | - plot_xmax=None, plot_unitX_tlatex=None, plot_unitX_latex=None, code_parton=None, |
68 | | - code_hadron=None, code_reco=None, cut_event=None, \ |
69 | | - cut_candidate=None, tlatex=None, latex=None): |
| 77 | + def Clone( |
| 78 | + obs, |
| 79 | + name=None, |
| 80 | + args=None, |
| 81 | + combination=None, |
| 82 | + plot_auto=None, |
| 83 | + plot_nbins=None, |
| 84 | + plot_xmin=None, |
| 85 | + plot_xmax=None, |
| 86 | + plot_unitX_tlatex=None, |
| 87 | + plot_unitX_latex=None, |
| 88 | + code_parton=None, |
| 89 | + code_hadron=None, |
| 90 | + code_reco=None, |
| 91 | + cut_event=None, |
| 92 | + cut_candidate=None, |
| 93 | + tlatex=None, |
| 94 | + latex=None, |
| 95 | + ): |
70 | 96 |
|
71 | 97 | # create clone of obs |
72 | | - newobs = ObservableBase(obs.name, obs.args, obs.combination, |
73 | | - obs.plot_auto, obs.plot_nbins, obs.plot_xmin, |
74 | | - obs.plot_xmax, obs.plot_unitX_tlatex, obs.plot_unitX_latex, obs.code_parton, |
75 | | - obs.code_hadron, obs.code_reco, obs.cut_event,\ |
76 | | - obs.cut_candidate, obs.tlatex, obs.latex) |
| 98 | + newobs = ObservableBase( |
| 99 | + obs.name, |
| 100 | + obs.args, |
| 101 | + obs.combination, |
| 102 | + obs.plot_auto, |
| 103 | + obs.plot_nbins, |
| 104 | + obs.plot_xmin, |
| 105 | + obs.plot_xmax, |
| 106 | + obs.plot_unitX_tlatex, |
| 107 | + obs.plot_unitX_latex, |
| 108 | + obs.code_parton, |
| 109 | + obs.code_hadron, |
| 110 | + obs.code_reco, |
| 111 | + obs.cut_event, |
| 112 | + obs.cut_candidate, |
| 113 | + obs.tlatex, |
| 114 | + obs.latex, |
| 115 | + ) |
77 | 116 |
|
78 | 117 | # replace |
79 | | - if name!=None: |
80 | | - newobs.name=name |
81 | | - if args!=None: |
82 | | - newobs.args=args |
83 | | - if combination!=None: |
84 | | - newobs.combination=combination |
85 | | - if plot_auto!=None: |
86 | | - newobs.plot_auto=plot_auto |
87 | | - if plot_nbins!=None: |
88 | | - newobs.plot_nbins=plot_nbins |
89 | | - if plot_xmin!=None: |
90 | | - newobs.plot_xmin=plot_xmin |
91 | | - if plot_xmax!=None: |
92 | | - newobs.plot_xmax=plot_xmax |
93 | | - if plot_unitX_tlatex!=None: |
94 | | - newobs.plot_unitX_tlatex=plot_unitX_tlatex |
95 | | - if plot_unitX_latex!=None: |
96 | | - newobs.plot_unitX_tlatex=plot_unitX_latex |
97 | | - if code_parton!=None: |
98 | | - newobs.code_parton=codeparton |
99 | | - if code_hadron!=None: |
100 | | - newobs.code_hadron=code_hadron |
101 | | - if code_reco!=None: |
102 | | - newobs.code_reco=code_reco |
103 | | - if cut_event!=None: |
104 | | - newobs.cut_event=cut_event |
105 | | - if cut_candidate!=None: |
106 | | - newobs.cut_candidate=cut_candidate |
107 | | - if tlatex!=None: |
108 | | - newobs.tlatex=tlatex |
109 | | - if latex!=None: |
110 | | - newobs.latex=latex |
| 118 | + if name is not None: |
| 119 | + newobs.name = name |
| 120 | + if args is not None: |
| 121 | + newobs.args = args |
| 122 | + if combination is not None: |
| 123 | + newobs.combination = combination |
| 124 | + if plot_auto is not None: |
| 125 | + newobs.plot_auto = plot_auto |
| 126 | + if plot_nbins is not None: |
| 127 | + newobs.plot_nbins = plot_nbins |
| 128 | + if plot_xmin is not None: |
| 129 | + newobs.plot_xmin = plot_xmin |
| 130 | + if plot_xmax is not None: |
| 131 | + newobs.plot_xmax = plot_xmax |
| 132 | + if plot_unitX_tlatex is not None: |
| 133 | + newobs.plot_unitX_tlatex = plot_unitX_tlatex |
| 134 | + if plot_unitX_latex is not None: |
| 135 | + newobs.plot_unitX_tlatex = plot_unitX_latex |
| 136 | + if code_parton is not None: |
| 137 | + newobs.code_parton = code_parton |
| 138 | + if code_hadron is not None: |
| 139 | + newobs.code_hadron = code_hadron |
| 140 | + if code_reco is not None: |
| 141 | + newobs.code_reco = code_reco |
| 142 | + if cut_event is not None: |
| 143 | + newobs.cut_event = cut_event |
| 144 | + if cut_candidate is not None: |
| 145 | + newobs.cut_candidate = cut_candidate |
| 146 | + if tlatex is not None: |
| 147 | + newobs.tlatex = tlatex |
| 148 | + if latex is not None: |
| 149 | + newobs.latex = latex |
111 | 150 |
|
112 | 151 | # return the clone |
113 | 152 | return newobs |
114 | | - |
|
0 commit comments