-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathclustering_siscone.py
More file actions
156 lines (134 loc) · 5.85 KB
/
Copy pathclustering_siscone.py
File metadata and controls
156 lines (134 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
################################################################################
#
# Copyright (C) 2012-2026 Jack Araz, Eric Conte & Benjamin Fuks
# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
#
# This file is part of MadAnalysis 5.
# Official website: <https://github.com/MadAnalysis/madanalysis5>
#
# MadAnalysis 5 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MadAnalysis 5 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
#
################################################################################
from __future__ import absolute_import
import logging
class ClusteringSisCone():
default_radius = 0.4
default_overlap = 0.5
default_npassmax = 0
default_input_ptmin = 0.
default_ptmin = 5.
userVariables = { "radius" : [str(default_radius)],\
"overlap" : [str(default_overlap)],\
"npassmax" : [str(default_npassmax)],\
"input_ptmin" : [str(default_input_ptmin)],\
"ptmin" : [str(default_ptmin)] }
def __init__(self):
self.radius = ClusteringSisCone.default_radius
self.ptmin = ClusteringSisCone.default_ptmin
self.overlap = ClusteringSisCone.default_overlap
self.npassmax = ClusteringSisCone.default_npassmax
self.input_ptmin = ClusteringSisCone.default_input_ptmin
def Display(self):
self.user_DisplayParameter("radius")
self.user_DisplayParameter("overlap")
self.user_DisplayParameter("npassmax")
self.user_DisplayParameter("input_ptmin")
self.user_DisplayParameter("ptmin")
def user_DisplayParameter(self,parameter):
if parameter=="radius":
logging.getLogger('MA5').info(" + cone radius = "+str(self.radius))
elif parameter=="overlap":
logging.getLogger('MA5').info(" + overlap threshold = "+str(self.overlap))
elif parameter=="npassmax":
logging.getLogger('MA5').info(" + number max of pass = "+str(self.npassmax))
elif parameter=="ptmin":
logging.getLogger('MA5').info(" + PT min (GeV) for produced jets = "+str(self.ptmin))
elif parameter=="input_ptmin":
logging.getLogger('MA5').info(" + PT min (GeV) for input particles = "+str(self.input_ptmin))
else:
logging.getLogger('MA5').error("'clustering' has no parameter called '"+parameter+"'")
def SampleAnalyzerConfigString(self):
mydict = {}
mydict['cluster.R'] = str(self.radius)
mydict['cluster.PTmin'] = str(self.ptmin)
mydict['cluster.OverlapThreshold'] = str(self.overlap)
mydict['cluster.NPassMax'] = str(self.npassmax)
mydict['cluster.Protojet_ptmin'] = str(self.input_ptmin)
return mydict
def user_GetValues(self,variable):
try:
return ClusteringSisCone.userVariables[variable]
except:
return []
def user_GetParameters(self):
return list(ClusteringSisCone.userVariables.keys())
def user_SetParameter(self,parameter,value):
# radius
if parameter=="radius":
try:
number = float(value)
except:
logging.getLogger('MA5').error("the cone radius must be a float value.")
return False
if number<=0:
logging.getLogger('MA5').error("the cone radius cannot be negative or null.")
return False
self.radius=number
# overlap
elif parameter=="overlap":
try:
number = float(value)
except:
logging.getLogger('MA5').error("the overlap threshold must be a float value.")
return False
if number<0:
logging.getLogger('MA5').error("the overlap threshold cannot be negative.")
return False
self.overlap=number
# seed
elif parameter=="npassmax":
try:
number = int(value)
except:
logging.getLogger('MA5').error("the n max of pass must be an integer value.")
return False
if number<0:
logging.getLogger('MA5').error("the n max of pass cannot be negative.")
return False
self.npassmax=number
# input_ptmin
elif parameter=="input_ptmin":
try:
number = float(value)
except:
logging.getLogger('MA5').error("the input PT min must be a float value.")
return False
if number<0:
logging.getLogger('MA5').error("the input PT min cannot be negative.")
return False
self.areafraction=number
# ptmin
elif parameter=="ptmin":
try:
number = float(value)
except:
logging.getLogger('MA5').error("the ptmin must be a float value.")
return False
if number<0:
logging.getLogger('MA5').error("the ptmin cannot be negative.")
return False
self.ptmin=number
# other
else:
logging.getLogger('MA5').error("'clustering' has no parameter called '"+parameter+"'")