CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
SpecificationBuilder_cfi.Specification Class Reference
Inheritance diagram for SpecificationBuilder_cfi.Specification:

Public Member Functions

def __deepcopy__ (self, memo)
 
def __init__ (self, conf=DefaultConf)
 
def groupBy (self, cols, mode="SUM")
 
def pythonTypeName (self)
 
def reduce (self, sort)
 
def save (self, nbins=-1, xmin=0, xmax=0)
 
def saveAll (self)
 

Public Attributes

 conf
 
 spec
 

Private Attributes

 _activeColumns
 
 _lastColumns
 
 _lastMode
 
 _state
 
 _x
 
 _y
 
 _z
 

Detailed Description

Definition at line 60 of file SpecificationBuilder_cfi.py.

Constructor & Destructor Documentation

◆ __init__()

def SpecificationBuilder_cfi.Specification.__init__ (   self,
  conf = DefaultConf 
)

Definition at line 61 of file SpecificationBuilder_cfi.py.

61  def __init__(self, conf = DefaultConf):
62  super(Specification, self).__init__()
63  # these are the steps passed down to C++. Will be filled later.
64  self.spec = cms.VPSet()
65  # this is currently only an additional enable flag. Might add topFolder or
66  # range there in the future.
67  self.conf = conf
68 
69  # these are onlly used during construction.
70  self._activeColumns = set()
71  self._state = FIRST
72 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __deepcopy__()

def SpecificationBuilder_cfi.Specification.__deepcopy__ (   self,
  memo 
)

Definition at line 73 of file SpecificationBuilder_cfi.py.

References CondFormats_MFObjects::dictionary.conf, SpecificationBuilder_cfi.Specification.conf, and SpecificationBuilder_cfi.Specification.spec.

73  def __deepcopy__(self, memo):
74  # override deepcopy to not copy .conf: it should remain a reference
75  # w/o this it is not cleanly possible to build a per-module switch.
76  t = Specification(self.conf)
77  t.spec = deepcopy(self.spec, memo)
78  return t
79 

◆ groupBy()

def SpecificationBuilder_cfi.Specification.groupBy (   self,
  cols,
  mode = "SUM" 
)

Definition at line 80 of file SpecificationBuilder_cfi.py.

References SpecificationBuilder_cfi.Specification._activeColumns, SpecificationBuilder_cfi.Specification._lastColumns, hcaldqm::flag::Flag._state, SpecificationBuilder_cfi.Specification._state, PGeometricDet::Item._x, SpecificationBuilder_cfi.Specification._x, PGeometricDet::Item._y, SpecificationBuilder_cfi.Specification._y, ALCARECOTkAlBeamHalo_cff.filter, MatrixUtil.remove(), SpecificationBuilder_cfi.Specification.spec, submitPVValidationJobs.split(), and SpecificationBuilder_cfi.val().

Referenced by SpecificationBuilder_cfi.Specification.saveAll().

80  def groupBy(self, cols, mode = "SUM"):
81  cnames = list(filter(len, val(cols).split("/"))) # omit empty items
82  newstate = self._state
83 
84  # The behaviour of groupBy depends a lot on when it happens:
85  # - The first (or second, if there is per-event counting) are very special
86  # - others in STAGE1 have to be EXTEND, and they will be translated into a
87  # list of exactly 3 USE/EXTEND steps (one per dimension).
88  # - in STAGE2 they are just passed down to C++.
89 
90  if self._state == FIRST:
91  cname = cnames
92  if mode != "SUM":
93  raise Exception("First grouping must be SUM")
94  if "Event" in cnames:
95  cnames.remove("Event"); # per-Event grouping is done automatically
96  t = COUNT
97  mode = "COUNT"
98  newstate = FIRST
99  else:
100  t = GROUPBY
101  newstate = STAGE1
102 
103  if self._state == STAGE1:
104  cname = self._activeColumns.difference(cnames)
105  if len(cname) != 1:
106  raise Exception("EXTEND must drop exactly one column.")
107 
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)
114  else:
115  raise Exception("Only EXTEND_X or EXTEND_Y allowed here, not " + mode)
116 
117  # remove the column in the FIRST groupBy, we always re-extract in step1.
118  c = list(cname)[0]
119  for s in self.spec:
120  if s.stage == FIRST and s.type == GROUPBY and c in s.columns:
121  s.columns.remove(c)
122  if c in self._activeColumns:
123  self._activeColumns.remove(c)
124  if c in self._lastColumns:
125  self._lastColumns.remove(c)
126 
127  return self # done here, no new step to add
128 
129  if self._state == STAGE2:
130  cname = cnames
131  if self._activeColumns.issubset(cname):
132  raise Exception("Harvesting GROUPBY must drop some columns")
133  if mode == "EXTEND_X":
134  t = EXTEND_X
135  elif mode == "SUM":
136  t = GROUPBY
137  else:
138  raise Exception("Currently only EXTEND_X and SUM supported in harvesting, not " + mode)
139 
140  self._activeColumns = set(cnames)
141  self._lastColumns = cnames
142  self._lastMode = mode
143 
144  self.spec.append(cms.PSet(
145  type = t,
146  stage = self._state,
147  columns = cms.vstring(cname),
148  arg = cms.string(mode),
149  nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
150  ))
151 
152  # In the very beginning emit standard column assignments, they will be
153  # changed later (above and in save()) to reflect the EXTENDS given above.
154  if newstate == STAGE1 and self._state == FIRST:
155  self._x = cms.PSet(
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)
160  )
161  self.spec.append(self._x)
162  self._y = cms.PSet(
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)
167  )
168  self.spec.append(self._y)
169  self._z = cms.PSet(
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)
174  )
175  self.spec.append(self._z)
176 
177  self._state = newstate
178 
179  return self
180 
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:234

◆ pythonTypeName()

def SpecificationBuilder_cfi.Specification.pythonTypeName (   self)

Definition at line 265 of file SpecificationBuilder_cfi.py.

Referenced by Mixins._ParameterTypeBase.dumpPython(), Mixins._ValidatingParameterListBase.dumpPython(), and Types.PSet.dumpPython().

265  def pythonTypeName(self):
266  return 'cms.PSet';
267 

◆ reduce()

def SpecificationBuilder_cfi.Specification.reduce (   self,
  sort 
)

Definition at line 181 of file SpecificationBuilder_cfi.py.

References hcaldqm::flag::Flag._state, SpecificationBuilder_cfi.Specification._state, mps_setup.append, and SpecificationBuilder_cfi.Specification.spec.

181  def reduce(self, sort):
182  # reduce can be MEAN or COUNT. in STAGE2, just pass through.
183  # in STAGE1, MEAN (anywhere) means make a PROFILE
184  # COUNT can mean per-event counting or a occupancy plot, which is acheived
185  # by ignoring the values passed to fill() (like dimensions=0, TODO).
186  if self._state == FIRST:
187  if sort != "COUNT":
188  raise Exception("First statement must be groupBy.")
189  self.spec[0].type = COUNT # this is actually a noop
190  # groupBy already saw the "Event" column and set up counting.
191 
192  return self
193 
194  if self._state == STAGE1:
195  if sort == "MEAN":
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)
200  ))
201  return self
202 
203  if sort != "MEAN":
204  raise Exception("Harvesting allows only reduce(MEAN) at the moment, not " + sort)
205 
206  self.spec.append(cms.PSet(
207  type = REDUCE,
208  stage = self._state,
209  columns = cms.vstring(),
210  arg = cms.string(sort),
211  nbins = cms.int32(-1), xmin = cms.int32(0), xmax = cms.int32(0)
212  ))
213  return self
214 

◆ save()

def SpecificationBuilder_cfi.Specification.save (   self,
  nbins = -1,
  xmin = 0,
  xmax = 0 
)

Definition at line 215 of file SpecificationBuilder_cfi.py.

References hcaldqm::flag::Flag._state, SpecificationBuilder_cfi.Specification._state, PGeometricDet::Item._x, SpecificationBuilder_cfi.Specification._x, PGeometricDet::Item._y, SpecificationBuilder_cfi.Specification._y, PGeometricDet::Item._z, SpecificationBuilder_cfi.Specification._z, and str.

Referenced by SpecificationBuilder_cfi.Specification.saveAll().

215  def save(self, nbins=-1, xmin=0, xmax=0):
216  if self._state == FIRST:
217  raise Exception("First statement must be groupBy.")
218 
219  if self._state == STAGE1:
220  # end of STAGE1, fix the parameter assignments
221  n = 1
222  if self._x.type == USE_X:
223  self._x.arg = cms.string(str(n))
224  n = n+1
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))
230  n = n+1
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))
236  n = n+1
237  self._z.nbins = cms.int32(nbins)
238  self._z.xmin = cms.int32(xmin)
239  self._z.xmax = cms.int32(xmax)
240  # we don't know how many parameters the user wants to pass here, but the
241  # HistogramManager knows. So we just add 3.
242 
243  # SAVE is implicit in step1 and ignored in harvesting, so not really needed.
244  # self.spec.append(cms.PSet(
245  # type = SAVE,
246  # stage = self._state,
247  # columns = cms.vstring(),
248  # arg = cms.string(""),
249  # ))
250  self._state = STAGE2
251 
252  return self
253 
#define str(s)
save
Definition: cuy.py:1164

◆ saveAll()

def SpecificationBuilder_cfi.Specification.saveAll (   self)

Definition at line 254 of file SpecificationBuilder_cfi.py.

References SpecificationBuilder_cfi.Specification._lastColumns, SpecificationBuilder_cfi.Specification._lastMode, SpecificationBuilder_cfi.Specification.groupBy(), cond::persistency::Query< Types >.groupBy(), join(), isotrackApplyRegressor.range, l1t::WriterProxy.save(), PiecewiseScalingPolynomial.save(), l1t::WriterProxyT< Record, Type >.save(), HBHENegativeEFilter.save(), HBHEChannelGroups.save(), HcalIndexLookup.save(), TrackerMap.save(), cond::persistency::Logger.save(), OOTPileupCorrData.save(), SpecificationBuilder_cfi.Specification.save(), svgfig.SVG.save(), and TkAlMap.TkAlMap.save().

254  def saveAll(self):
255  # call groupBy() and save() until all colums are consumed.
256  self.save()
257  columns = self._lastColumns
258  for i in range(len(columns)-1, 0, -1):
259  cols = columns[0:i]
260  self.groupBy("/".join(cols), self._lastMode)
261  self.save()
262  return self
263 
static std::string join(char **cmd)
Definition: RemoteFile.cc:21

Member Data Documentation

◆ _activeColumns

SpecificationBuilder_cfi.Specification._activeColumns
private

◆ _lastColumns

SpecificationBuilder_cfi.Specification._lastColumns
private

◆ _lastMode

SpecificationBuilder_cfi.Specification._lastMode
private

◆ _state

◆ _x

SpecificationBuilder_cfi.Specification._x
private

◆ _y

SpecificationBuilder_cfi.Specification._y
private

◆ _z

SpecificationBuilder_cfi.Specification._z
private

◆ conf

SpecificationBuilder_cfi.Specification.conf

◆ spec