CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 
def __init__
 
def groupBy
 
def pythonTypeName
 
def reduce
 
def save
 
def saveAll
 

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

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

Definition at line 61 of file SpecificationBuilder_cfi.py.

61 
62  def __init__(self, conf = DefaultConf):
63  super(Specification, self).__init__()
64  # these are the steps passed down to C++. Will be filled later.
65  self.spec = cms.VPSet()
66  # this is currently only an additional enable flag. Might add topFolder or
67  # range there in the future.
68  self.conf = conf
69 
70  # these are onlly used during construction.
71  self._activeColumns = set()
72  self._state = FIRST

Member Function Documentation

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 
74  def __deepcopy__(self, memo):
75  # override deepcopy to not copy .conf: it should remain a reference
76  # w/o this it is not cleanly possible to build a per-module switch.
77  t = Specification(self.conf)
78  t.spec = deepcopy(self.spec, memo)
79  return t
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, alcazmumu_cfi.filter, SpecificationBuilder_cfi.Specification.spec, submitPVValidationJobs.split(), and SpecificationBuilder_cfi.val().

Referenced by SpecificationBuilder_cfi.Specification.saveAll().

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

266  def pythonTypeName(self):
267  return 'cms.PSet';
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, and SpecificationBuilder_cfi.Specification.spec.

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

Referenced by SpecificationBuilder_cfi.Specification.saveAll().

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

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

Member Data Documentation

SpecificationBuilder_cfi.Specification._activeColumns
private

Definition at line 70 of file SpecificationBuilder_cfi.py.

Referenced by SpecificationBuilder_cfi.Specification.groupBy().

SpecificationBuilder_cfi.Specification._lastColumns
private

Definition at line 141 of file SpecificationBuilder_cfi.py.

Referenced by SpecificationBuilder_cfi.Specification.groupBy(), and SpecificationBuilder_cfi.Specification.saveAll().

SpecificationBuilder_cfi.Specification._lastMode
private

Definition at line 142 of file SpecificationBuilder_cfi.py.

Referenced by SpecificationBuilder_cfi.Specification.saveAll().

SpecificationBuilder_cfi.Specification._state
private

Definition at line 71 of file SpecificationBuilder_cfi.py.

Referenced by SpecificationBuilder_cfi.Specification.groupBy(), SpecificationBuilder_cfi.Specification.reduce(), and SpecificationBuilder_cfi.Specification.save().

SpecificationBuilder_cfi.Specification._x
private

Definition at line 155 of file SpecificationBuilder_cfi.py.

Referenced by plotting.PlotText.Draw().

SpecificationBuilder_cfi.Specification._y
private

Definition at line 162 of file SpecificationBuilder_cfi.py.

Referenced by plotting.PlotText.Draw().

SpecificationBuilder_cfi.Specification._z
private

Definition at line 169 of file SpecificationBuilder_cfi.py.

SpecificationBuilder_cfi.Specification.conf

Definition at line 67 of file SpecificationBuilder_cfi.py.

Referenced by SpecificationBuilder_cfi.Specification.__deepcopy__().

SpecificationBuilder_cfi.Specification.spec

Definition at line 64 of file SpecificationBuilder_cfi.py.

Referenced by SpecificationBuilder_cfi.Specification.__deepcopy__(), SpecificationBuilder_cfi.Specification.groupBy(), and SpecificationBuilder_cfi.Specification.reduce().