ATLAS Offline Software
Loading...
Searching...
No Matches
JetMonitoringConfig.HistoSpec Class Reference
Inheritance diagram for JetMonitoringConfig.HistoSpec:
Collaboration diagram for JetMonitoringConfig.HistoSpec:

Public Member Functions

 __init__ (self, name, bins, xvar=None, yvar=None, zvar=None, profile=False, **args)
 groupName (self)
 clone (self, newname, bins=None, xvar=None, yvar=None, zvar=None, **hargs)
 to2DSpec (self, yspec, profile=False, zspec=None)
 toTool (self)
 defineHisto (self, parentAlg, monhelper, path)
 __getattr__ (self, attr)
 __setattr__ (self, attr, value)
 __setitem__ (self, attr, value)
 dump (self, out=None)

Public Attributes

str is1D = ';' not in name
int nVar = name.count(';')+1
bool isProfile = profile
 xvar = retrieveVarToolConf( xvar if xvar is not None else name)
 yvar = None
 zvar = None
 bins = bins
 hargs = ConfigDict( **args)
 name = name
 klass = klass

Protected Member Functions

 _dump (self, writeFunc)

Detailed Description

A dictionary specialized to contain a JetHistoAttributeFiller specification
Invocation is like : spec = HistoSpec( name, bins, ...optional args... ) where 
  - name : a string, from which the name of the Histogram is build.
           AND also the description of variables to be plotted IF none of xvar, yvar or zvar is in the optional args.
           The final name of histos is given by name.replace(':GeV','').replace(';','_')
       ex: 'eta'        --> histo name : 'eta', variable to plot is 'eta'
           'pt:GeV'     --> histo name : 'pt', variable to plot is 'pt' at GeV scale 
           'pt:GeV;eta' --> histo name : 'pt_eta', 2 variables to plot  'pt' at GeV scale on x axis and 'eta' on y axis
  - bins : the binning of the histogram in the form (nbin, min, max) or (nbinX, minX, maxX, nbinY, minY, maxY )
  - optionnal args are : 
     + xvar, yvar, zvar : strings specifying variables
     + profile : boolean, True if the histo is a TProfile (or TProfile2D)     
     + any other args (ex: title) will be forwarded to the mongroup.defineHistogram() function.

Definition at line 240 of file JetMonitoringConfig.py.

Constructor & Destructor Documentation

◆ __init__()

JetMonitoringConfig.HistoSpec.__init__ ( self,
name,
bins,
xvar = None,
yvar = None,
zvar = None,
profile = False,
** args )

Definition at line 255 of file JetMonitoringConfig.py.

255 def __init__(self, name , bins, xvar=None, yvar=None, zvar=None, profile=False,**args):
256 self.is1D = ';' not in name
257
258 self.nVar = name.count(';')+1
259 self.isProfile = profile
260 if self.nVar==1:
261 self.xvar = retrieveVarToolConf( xvar if xvar is not None else name)
262 self.yvar = None
263 self.zvar = None
264 elif self.nVar==2:
265 xv , yv = name.split(';')
266 self.xvar = retrieveVarToolConf( xvar if xvar is not None else xv)
267 self.yvar = yvar if yvar is not None else yv
268 self.zvar = None
269 else:
270 xv , yv, zv = name.split(';')
271 self.xvar = xvar if xvar is not None else xv
272 self.yvar = yvar if yvar is not None else yv
273 self.zvar = zvar if zvar is not None else zv
274 self.isProfile = True
275 self.name = name.replace(':GeV','')
276 self.bins = bins
277 self.hargs = ConfigDict( **args)
278 ConfigDict.__init__(self, **args)
279

Member Function Documentation

◆ __getattr__()

JetMonitoringConfig.ConfigDict.__getattr__ ( self,
attr )
inherited

Definition at line 47 of file JetMonitoringConfig.py.

47 def __getattr__(self, attr):
48 try:
49 return self[attr]
50 except KeyError:
51 dict.__getattribute__(self,attr)
52 #raise AttributeError(attr)
53

◆ __setattr__()

JetMonitoringConfig.ConfigDict.__setattr__ ( self,
attr,
value )
inherited

Definition at line 54 of file JetMonitoringConfig.py.

54 def __setattr__(self, attr, value):
55 if attr in ['keys', 'clear', 'update', 'pop', 'iteritems', 'values','setdefault','get','has_key','copy']:
56 print('ConfigDict ERROR can not assign attribute ', attr)
57 return
58 dict.__setitem__(self, attr, value)
59 dict.__setattr__(self, attr, value)
void print(char *figname, TCanvas *c1)

◆ __setitem__()

JetMonitoringConfig.ConfigDict.__setitem__ ( self,
attr,
value )
inherited

Definition at line 60 of file JetMonitoringConfig.py.

60 def __setitem__(self, attr, value):
61 if attr in ['keys', 'clear', 'update', 'pop', 'iteritems', 'values','setdefault','get','has_key','copy']:
62 print('ConfigDict ERROR can not assign attribute ', attr)
63 return
64 dict.__setitem__(self, attr, value)
65 dict.__setattr__(self, attr, value)
66
67

◆ _dump()

JetMonitoringConfig.HistoSpec._dump ( self,
writeFunc )
protected

Reimplemented from JetMonitoringConfig.ConfigDict.

Definition at line 374 of file JetMonitoringConfig.py.

374 def _dump(self, writeFunc):
375 def write(s): writeFunc(' '+s)
376 writeFunc('HistoSpec("'+self.name+'", '+str(self.bins) )
377 for k in [ 'xvar', 'yvar', 'zvar', 'isProfile' ]:
378 if self[k] is not None:
379 write(' '+k +' = '+str(self[k]))
380 write(')')
381
382

◆ clone()

JetMonitoringConfig.HistoSpec.clone ( self,
newname,
bins = None,
xvar = None,
yvar = None,
zvar = None,
** hargs )

Reimplemented from JetMonitoringConfig.ToolSpec.

Definition at line 284 of file JetMonitoringConfig.py.

284 def clone(self, newname, bins=None, xvar=None, yvar=None, zvar=None, **hargs):
285 c = ConfigDict.clone(self)
286 if xvar : c.xvar = xvar
287 if yvar : c.yvar = yvar
288 if zvar : c.zvar = zvar
289 if bins: c.bins = bins
290 c.hargs.update(**hargs)
291 c.name = newname
292 return c
293

◆ defineHisto()

JetMonitoringConfig.HistoSpec.defineHisto ( self,
parentAlg,
monhelper,
path )
 This function performs the standard monitoring config calls for this JetHisto tool.
      - group = monhelper.addGroup( ... )
      - group.defineHistogram( ... )

Reimplemented from JetMonitoringConfig.ToolSpec.

Definition at line 332 of file JetMonitoringConfig.py.

332 def defineHisto(self, parentAlg, monhelper , path):
333 """ This function performs the standard monitoring config calls for this JetHisto tool.
334 - group = monhelper.addGroup( ... )
335 - group.defineHistogram( ... )
336 """
337
338 # build the arguments to be passed to defineHistogram
339 hargs = ConfigDict()
340 bins = self.bins
341 if self.nVar==1:
342 hargs.update(xbins = bins[0],xmin = bins[1], xmax=bins[2],
343 type='TH1F',
344 )
345 elif self.nVar>1:
346 hargs.update(xbins = bins[0],xmin = bins[1], xmax=bins[2],
347 ybins = bins[3],ymin = bins[4], ymax=bins[5],
348 type='TH2F' if not self.isProfile else 'TProfile',
349 )
350 if self.nVar==3:
351 hargs.type = 'TProfile2D'
352 hargs.update( **self.hargs) # overwrite by user-given args if any
353
354 # we create one group for each histoFiller : self.groupName() are unique within a JetMonitoringAlg
355 bottomLevelDir = self.bottomLevelDir if self.bottomLevelDir != '' else parentAlg.JetContainerName.Path
356 group = monhelper.addGroup(parentAlg, self.groupName(), self.topLevelDir+bottomLevelDir)
357
358 # define the variables used by this tool
359 # we encode as 'varx,vary;alias' as requested ny standard monitoring config, see
360 # https://acode-browser1.usatlas.bnl.gov/lxr/source/athena/Control/AthenaMonitoring/python/GenericMonitoringTool.py
361 name = retrieveVarToolConf( self.xvar).vname()
362 if self.nVar>1:
363 name = name +"," + retrieveVarToolConf( self.yvar).vname()
364 if self.nVar>2:
365 name = name +"," + retrieveVarToolConf( self.zvar).vname()
366
367 name = name+";"+self.groupName()
368
369 #print(' uuuuuuuuuuu ', self.name , ' --> ', name, hargs)
370 # call the standard histo definition routine :
371 group.defineHistogram(name, path=path, **hargs)
372
373

◆ dump()

JetMonitoringConfig.ConfigDict.dump ( self,
out = None )
inherited
prints the content of this dict on stdout (default) or in the file 'out' 

Definition at line 76 of file JetMonitoringConfig.py.

76 def dump(self, out=None):
77 """ prints the content of this dict on stdout (default) or in the file 'out' """
78 if out is None :
79 from sys import stdout
80 out = stdout
81 _write = out.write
82 def write(s, e='\n'): _write(s+e)
83 self._dump(write)
84
-event-from-file

◆ groupName()

JetMonitoringConfig.HistoSpec.groupName ( self)

Definition at line 280 of file JetMonitoringConfig.py.

280 def groupName(self):
281 return self.name if self.nVar==1 else self.name.replace(';','_')
282
283
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ to2DSpec()

JetMonitoringConfig.HistoSpec.to2DSpec ( self,
yspec,
profile = False,
zspec = None )
Merge this histo spec and yspec into a new 2D histo spec

Definition at line 294 of file JetMonitoringConfig.py.

294 def to2DSpec(self, yspec, profile=False, zspec=None):
295 """ Merge this histo spec and yspec into a new 2D histo spec"""
296 tx, ax, _ = self.title.split(';')
297 ty, ay, _ = yspec.title.split(';')
298 title = ty+' vs '+tx+';'+ax+';'+ay
299 name = self.name+';'+yspec.name
300 if zspec is not None:
301 tz, az, _ = zspec.title.split(';')
302 title = tz+' vs '+tx+' and '+ty+';'+ax+';'+ay
303
304 name = name + ';'+zspec.name
305 s2d = HistoSpec( name, self.bins+yspec.bins,
306 xvar = self.xvar,
307 yvar = yspec.xvar, title=title, profile=profile
308 )
309 if zspec is not None:
310 s2d.zvar = zspec.xvar
311 return s2d
312
313
314
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ toTool()

JetMonitoringConfig.HistoSpec.toTool ( self)

Reimplemented from JetMonitoringConfig.ToolSpec.

Definition at line 315 of file JetMonitoringConfig.py.

315 def toTool(self):
316 from AthenaConfiguration.ComponentFactory import CompFactory
317 vx = retrieveVarToolConf( self.xvar)
318 tool = CompFactory.JetHistoAttributeFiller(self.groupName()+"hfiller",
319 VarX = vx.toTool(),
320 Group = self.groupName(),
321 )
322 if self.nVar>1:
323 tool.VarY = retrieveVarToolConf( self.yvar).toTool()
324 if self.nVar>2:
325 tool.VarZ = retrieveVarToolConf( self.zvar).toTool()
326 else: tool.VarZ = None
327 else : tool.VarY = None
328
329 return tool
330
331

Member Data Documentation

◆ bins

JetMonitoringConfig.HistoSpec.bins = bins

Definition at line 276 of file JetMonitoringConfig.py.

◆ hargs

JetMonitoringConfig.HistoSpec.hargs = ConfigDict( **args)

Definition at line 277 of file JetMonitoringConfig.py.

◆ is1D

str JetMonitoringConfig.HistoSpec.is1D = ';' not in name

Definition at line 256 of file JetMonitoringConfig.py.

◆ isProfile

bool JetMonitoringConfig.HistoSpec.isProfile = profile

Definition at line 259 of file JetMonitoringConfig.py.

◆ klass

JetMonitoringConfig.ToolSpec.klass = klass
inherited

Definition at line 163 of file JetMonitoringConfig.py.

◆ name

JetMonitoringConfig.ToolSpec.name = name
inherited

Definition at line 162 of file JetMonitoringConfig.py.

◆ nVar

int JetMonitoringConfig.HistoSpec.nVar = name.count(';')+1

Definition at line 258 of file JetMonitoringConfig.py.

◆ xvar

JetMonitoringConfig.HistoSpec.xvar = retrieveVarToolConf( xvar if xvar is not None else name)

Definition at line 261 of file JetMonitoringConfig.py.

◆ yvar

JetMonitoringConfig.HistoSpec.yvar = None

Definition at line 262 of file JetMonitoringConfig.py.

◆ zvar

JetMonitoringConfig.HistoSpec.zvar = None

Definition at line 263 of file JetMonitoringConfig.py.


The documentation for this class was generated from the following file: