1 import FWCore.ParameterSet.Config
as cms
2 from copy
import deepcopy
11 NO_TYPE = cms.int32(0)
12 GROUPBY = cms.int32(1)
13 EXTEND_X = cms.int32(2)
14 EXTEND_Y = cms.int32(3)
21 PROFILE = cms.int32(11)
26 NO_STAGE = cms.int32(0)
33 if hasattr(maybecms,
"value"):
34 return maybecms.value()
40 return "/".
join(parts[0:len(parts)-1])
43 DefaultConf = cms.PSet(enabled = cms.bool(
True))
62 super(Specification, self).
__init__()
77 t.spec = deepcopy(self.
spec, memo)
93 raise Exception(
"First grouping must be SUM")
95 cnames.remove(
"Event");
104 cname = self._activeColumns.difference(cnames)
106 raise Exception(
"EXTEND must drop exactly one column.")
108 if mode ==
"EXTEND_X":
109 self._x.type = EXTEND_X
110 self._x.columns = cms.vstring(cname)
111 elif mode ==
"EXTEND_Y":
112 self._y.type = EXTEND_Y
113 self._y.columns = cms.vstring(cname)
115 raise Exception(
"Only EXTEND_X or EXTEND_Y allowed here, not " + mode)
120 if s.stage == FIRST
and s.type == GROUPBY
and c
in s.columns:
123 self._activeColumns.remove(c)
125 self._lastColumns.remove(c)
131 if self._activeColumns.issubset(cname):
132 raise Exception(
"Harvesting GROUPBY must drop some columns")
133 if mode ==
"EXTEND_X":
138 raise Exception(
"Currently only EXTEND_X and SUM supported in harvesting, not " + mode)
144 self.spec.append(cms.PSet(
147 columns = cms.vstring(cname),
148 arg = cms.string(mode),
149 nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
154 if newstate == STAGE1
and self.
_state == FIRST:
156 type = USE_X, stage = STAGE1,
157 columns = cms.vstring(),
158 arg = cms.string(
""),
159 nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
161 self.spec.append(self.
_x)
163 type = USE_Y, stage = STAGE1,
164 columns = cms.vstring(),
165 arg = cms.string(
""),
166 nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
168 self.spec.append(self.
_y)
170 type = USE_Z, stage = STAGE1,
171 columns = cms.vstring(),
172 arg = cms.string(
""),
173 nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
175 self.spec.append(self.
_z)
188 raise Exception(
"First statement must be groupBy.")
189 self.
spec[0].type = COUNT
196 self.spec.append(cms.PSet(
197 type = PROFILE, stage = STAGE1,
198 columns = cms.vstring(), arg = cms.string(
""),
199 nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
204 raise Exception(
"Harvesting allows only reduce(MEAN) at the moment, not " + sort)
206 self.spec.append(cms.PSet(
209 columns = cms.vstring(),
210 arg = cms.string(sort),
211 nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
215 def save(self, nbins=-1, xmin=0, xmax=0):
217 raise Exception(
"First statement must be groupBy.")
222 if self._x.type == USE_X:
223 self._x.arg = cms.string(
str(n))
225 self._x.nbins = cms.int32(nbins)
226 self._x.xmin = cms.int32(xmin)
227 self._x.xmax = cms.int32(xmax)
228 if self._y.type == USE_Y:
229 self._y.arg = cms.string(
str(n))
231 self._y.nbins = cms.int32(nbins)
232 self._y.xmin = cms.int32(xmin)
233 self._y.xmax = cms.int32(xmax)
234 if self._z.type == USE_Z:
235 self._z.arg = cms.string(
str(n))
237 self._z.nbins = cms.int32(nbins)
238 self._z.xmin = cms.int32(xmin)
239 self._z.xmax = cms.int32(xmax)
258 for i
in range(len(columns)-1, 0, -1):
const uint16_t range(const Frame &aFrame)
static std::string join(char **cmd)