ATLAS Offline Software
Loading...
Searching...
No Matches
JetMonitoringConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3# #######################################
4
30
31from AthenaCommon import SystemOfUnits
32
33class ConfigDict(dict):
34 """A python dictionary extended so that each entry in the dict can also be accessed as
35 member attribute.
36 Ex:
37 d = ConfigDict(aKey = 4)
38 d.aKey # --> == 4 is the same as d["aKey"]
39 d.bKey = 12 # now d["bKey"] is existing and set to 12
40
41 all other usual methods of dictionary are working as expected.
42 """
43 def __init__(self, **kwargs):
44 dict.__init__(self, **kwargs)
45 for k,v in kwargs.items():
46 dict.__setattr__(self, k, v)
47 def __getattr__(self, attr):
48 try:
49 return self[attr]
50 except KeyError:
51 dict.__getattribute__(self,attr)
52 #raise AttributeError(attr)
53
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)
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
68 def clone(self, **kwargs):
69 from copy import deepcopy
70 c = deepcopy(self)
71 for k,v in kwargs.items():
72 setattr(c,k,v)
73 return c
74
75
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
85 def _dump(self, writeFunc):
86 def write(s, e='\n'): writeFunc(' '+s,e)
87 writeFunc(self.__class__.__name__+'(')
88 for k,v in sorted(self.items()):
89 if isinstance(v, ConfigDict):
90 write(k+' = ','')
91 v._dump(write)
92 else:
93 write(k+' = '+str(v))
94 writeFunc(')')
95
96
97
98
99# **********************************************************
100# **********************************************************
101# Helper functions
102# **********************************************************
103
104
106 selL = selStr.split('&')
107 interpL = [interpretSelStr( s ) for s in selL]
108 # interpL is in the form [ (min1,v1,max1), (min2,v2,max2),..]
109 # unpack it into 3 lists :
110 minL, varL, maxL = zip(*interpL)
111 return minL, varL, maxL
112
113def interpretSelStr(selStr):
114 """Interpret a selection string in the form '12.3<var<42.0'
115 and returns a tuple.
116 '12.3<var<42.0' -> returns (12.3, 'var', 42.)
117 'var<42.0' -> returns (None, 'var', 42.)
118 '12.3<var' -> returns (12.3, 'var', None)
119 """
120
121 if '>' in selStr:
122 print("JetMonitoring ERROR interpreting selection string ", selStr)
123 print("JetMonitoring ERROR can not interpret '>', please use only '<' ")
124
125 parts = selStr.split('<')
126 cmin, cmax = -3.4e38, 3.4e38 #we declare std::vector<float> for both on the c++ side, but will not necessarily pass actual values for them, so we use min/max float values in python as default (hardcoded numbers, because not easily accessible)
127 var = selStr
128 if len(parts)==2:
129 ismin = False
130 try :
131 var, cut = parts[0] , float(parts[1])
132 except ValueError:
133 cut, var = float(parts[0]) ,parts[1]
134 ismin=True
135 if ismin : cmin = cut
136 else: cmax = cut
137 elif len(parts)==3:
138 cmin, var, cmax = parts
139 cmin = float(cmin)
140 cmax = float(cmax)
141
142 return cmin, var, cmax
143
145 """ interprets 'varName[X]' into ('varName',x) """
146 try:
147 name, index = name.split('[')
148 except ValueError:
149 name, index = name, ''
150 if not index.endswith(']'):
151 return name, -1
152 index = int(index[:-1])
153 return name, index
154
155# **********************************************************
156
157
159 """A dictionary specialized for containing the specification of a Athena tool.
160 """
161 def __init__(self, klass, name, **args):
162 self.name = name
163 self.klass = klass
164 ConfigDict.__init__(self, **args)
165
166
167 def toTool(self):
168 from AthenaConfiguration.ComponentFactory import CompFactory
169 conf = self.clone(self.name)
170 klass = getattr(CompFactory,conf.pop('klass')) # remove 'klass'
171 conf.pop('name')
172 conf.pop('topLevelDir',None)
173 conf.pop('bottomLevelDir',None)
174 conf.pop('defineHistoFunc',None) # not used here.
175 for k, v in conf.items():
176 if isinstance(v,ToolSpec):
177 v.topLevelDir = self.topLevelDir
178 v.bottomLevelDir = self.bottomLevelDir
179 conf[k] = v.toTool()
180 if isinstance(v,list):
181 if v == []: continue
182 if isinstance(v[0],ToolSpec):
183 # assume we have k is a ToolHandleArray
184 toolInstances = []
185 for toolSpec in v:
186 toolSpec.topLevelDir=self.topLevelDir
187 toolSpec.bottomLevelDir=self.bottomLevelDir
188 toolInstances.append( toolSpec.toTool() )
189 conf[k] = toolInstances
190 return klass(**conf)
191
192 def clone(self, newname,**args):
193 return ConfigDict.clone(self, name=newname, **args)
194
195 def defineHisto(self, parentAlg, monhelper , path):
196 # Assume a helper function was given :
197 defineHistoFunc = self.defineHistoFunc
198 # call it :
199 defineHistoFunc(self, parentAlg, monhelper , path)
200
201
202
204 """A dictionary specialized to contain a jet variable specification"""
205 def __init__(self, Name , Type='float', Index=-1, Scale=1):
206 # by default we allow only the properties of a JetHistoVarTool
207 if Name.endswith(':GeV'):
208 Scale=1./SystemOfUnits.GeV
209 Name = Name[:-4]
210
211
212 Name , Index = findSelectIndex(Name)
213 if Index != -1:
214 if Type[:3] != 'vec': Type='vec'+Type
215 self.Name = Name
216 self.Type = Type
217 self.Scale = Scale
218 self.Index = Index
219 ConfigDict.__init__(self)
220
221
222 def toTool(self):
223 from AthenaConfiguration.ComponentFactory import CompFactory
224 self.pop('topLevelDir', None)
225 self.pop('bottomLevelDir', None)
226 return CompFactory.JetHistoVarTool(self.Name, **self)
227
228 def vname(self):
229 if self.Index ==-1: return self.Name
230 return self.Name+str(self.Index)
231
232
233 def __str__(self):
234 if self.Index==-1: return 'VarSpec("{n}",{t})'.format(n=self.Name, t=self.Type)
235 else: return 'VarSpec("{n}[{i}]",{t})'.format(n=self.Name, t=self.Type, i=self.Index)
236
237 def _dump(self, writeFunc):
238 writeFunc( str(self))
239
241 """A dictionary specialized to contain a JetHistoAttributeFiller specification
242 Invocation is like : spec = HistoSpec( name, bins, ...optional args... ) where
243 - name : a string, from which the name of the Histogram is build.
244 AND also the description of variables to be plotted IF none of xvar, yvar or zvar is in the optional args.
245 The final name of histos is given by name.replace(':GeV','').replace(';','_')
246 ex: 'eta' --> histo name : 'eta', variable to plot is 'eta'
247 'pt:GeV' --> histo name : 'pt', variable to plot is 'pt' at GeV scale
248 'pt:GeV;eta' --> histo name : 'pt_eta', 2 variables to plot 'pt' at GeV scale on x axis and 'eta' on y axis
249 - bins : the binning of the histogram in the form (nbin, min, max) or (nbinX, minX, maxX, nbinY, minY, maxY )
250 - optionnal args are :
251 + xvar, yvar, zvar : strings specifying variables
252 + profile : boolean, True if the histo is a TProfile (or TProfile2D)
253 + any other args (ex: title) will be forwarded to the mongroup.defineHistogram() function.
254 """
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
280 def groupName(self):
281 return self.name if self.nVar==1 else self.name.replace(';','_')
282
283
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
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
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
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
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
384 """A similar dictionary to HistoSpec above, but specialized to contain a
385 JetHistoEventLevelFiller specification.
386 Invocation is like : spec = EventHistoSpec( name, bins=(n,xlow,xhigh) )
387 """
388 def __init__(self, name, bins, **args):
389 ToolSpec.__init__(self, klass=None, name=name, **args) # we don't really need to pass a klass because we're specialized for JetHistoEventLevelFiller, see toTool()
390 self.bins = bins
391 self.hargs = ConfigDict( **args)
392
393 def histName(self):
394 from JetMonitoring.JetStandardHistoSpecs import knownEventVar
395 histname = self.name
396 while knownEventVar.get(histname,None) is None: #try to remove suffixes in the form of "_SelectionName" when using with external SelectSpecs
397 if "_" in histname:
398 histnamesplit = histname.split("_")
399 histname = histname.replace("_"+histnamesplit[-1],"")
400 else:
401 raise JetMonSpecException(" Unknown EventHisto specification : '{}' ".format(histname))
402 return histname
403
404 def toTool(self):
405 from AthenaConfiguration.ComponentFactory import CompFactory
406 from JetMonitoring.JetStandardHistoSpecs import knownEventVar
407 # force the property "VarName" to simply be the name of the variable specification:
408 v = knownEventVar[self.histName()]
409 v.VarName = v.name
410 tool = CompFactory.JetHistoEventLevelFiller( self.name+"hfiller",
411 Var = v.toTool(),
412 Group = self.name,
413 )
414 return tool
415
416 def defineHisto(self, parentAlg, monhelper , path):
417 hargs = dict(xbins = self.bins[0],xmin = self.bins[1], xmax=self.bins[2],
418 type='TH1F', )
419 hargs.update( **self.hargs)
420 # we create one group for each histoFiller : self.name() are unique within a JetMonitoringAlg
421 bottomLevelDir = self.bottomLevelDir if self.bottomLevelDir != '' else parentAlg.JetContainerName.Path
422 group = monhelper.addGroup(parentAlg, self.name, self.topLevelDir+bottomLevelDir)
423 group.defineHistogram(self.histName()+";"+self.name, path=path, **hargs) #give a recognisable histogram name in case of SelectSpec usage
424
425
427 """A dictionary specialized to contain a JetHistoSelectSort specification
428 Invocation is like : spec = SelectSpec( name, , expr, path ) where
429 - name : a string naming the selection being applied
430 - expr : s string, defining a selection in the form '0.123<var<4.567' where var is an attribute/variable
431 - path : optional string, giving the sub-directory into which histos for this selection will be put. if not set, defaults to name.
432 """
433 def __init__(self, selname, selexpr, path=None, **args):
434 path = selname if path is None else path
435 if '<' in selexpr:
436 # interpret it as a list of min<v<max
437 cminList , varList , cmaxList = interpretManySelStr(selexpr)
438 specname = '_'.join(varList)
439 if args.setdefault('isEventVariable', False) :
440 VarList = [retrieveEventVarToolConf(v) for v in varList]
441 selProp = 'EventSelector'
442 selSpec = ToolSpec('JetEventSelector', specname+'_sel', Var = VarList, )
443 else:
444 VarList = [retrieveVarToolConf(v) for v in varList]
445 selProp = 'Selector'
446 selSpec = ToolSpec('JetSelectorAttribute', specname+'_sel', Var = VarList, )
447 selSpec['CutMin'] = cminList
448 selSpec['CutMax'] = cmaxList
449 args[selProp] = selSpec
450 elif selexpr != '':
451 from JetMonitoring.JetStandardHistoSpecs import knownSelector
452 # assume it's a known pre-defined jet selector
453 selSpec = knownSelector.get(selexpr, None)
454 if selSpec is None :
455 print("ERROR ", selexpr , " is an unknown JetSelector ")
456 # should raise an exception ??
457 return
458 args['Selector'] = selSpec
459
460 self.name = selname
461 self.path = path
462 ConfigDict.__init__(self, **args)
463 tmpL = self.FillerTools
464 self.FillerTools = []
465 self.appendHistos(*tmpL)
466
467 def appendHistos(self, *hfillers):
468 tmpL = [retrieveHistoToolConf(hspec) for hspec in hfillers]
469 self.FillerTools += tmpL
470
471 def toTool(self):
472 from AthenaConfiguration.ComponentFactory import CompFactory
473 # conf = self.clone(self.name)
474 # name = conf.pop('name')
475 selTool = CompFactory.JetHistoSelectSort(self.name, SelectedIndex=self.get('SelectedIndex',-1), InverseJetSel=self.get('InverseJetSel',False))
476 if hasattr(self,'Selector'):
477 self.Selector.topLevelDir = self.topLevelDir
478 self.Selector.bottomLevelDir = self.bottomLevelDir
479 selTool.Selector = self.Selector.toTool()
480 if hasattr(self,'EventSelector'):
481 self.EventSelector.topLevelDir = self.topLevelDir
482 self.EventSelector.bottomLevelDir = self.bottomLevelDir
483 selTool.EventSelector = self.EventSelector.toTool()
484 if hasattr(self, 'SortVariable'):
485 selTool.SortVariable = retrieveVarToolConf(self.SortVariable)
486 suffix = '_'+self.name
487 for i,tconf in enumerate(self.FillerTools):
488 tconf.topLevelDir = self.topLevelDir
489 tconf.bottomLevelDir = self.bottomLevelDir
490 newname = tconf.name if suffix in tconf.name else tconf.name+suffix #prevent duplicating of Selection name when loading external SelectSpecs
491 tconf = tconf.clone(newname=newname)
492 self.FillerTools[i] = tconf # re-assign the modified conf so it's consistently re-used elsewhere
493 selTool.FillerTools += [ tconf.toTool() ] # assign a configured tool to the JetHistoSelectSort instance
494 return selTool
495
496 def defineHisto(self, parentAlg, monhelper , path):
497 # redefine path for sub-histos if needed :
498 path = path if self.path is None else self.path
499 # define histos for each subtools
500 for tconf in self.FillerTools:
501 tconf.defineHisto(parentAlg, monhelper, path)
502
503
504 def _dump(self, writeFunc):
505 def write(s,e='\n'): writeFunc(' '+s,e)
506 def write2(s,e='\n'): writeFunc(' '+s,e)
507 writeFunc('SelectSpec("'+self.name+'", path='+self.path+',')
508 if hasattr(self, 'Selector' ):
509 write(' Selector=','')
510 self.Selector._dump( write2)
511 if hasattr(self, 'EventSelector' ):
512 write(' EventSelector=','')
513 self.EventSelector._dump( write2)
514 write('FillerTools= [')
515 for hspec in self.FillerTools:
516 hspec._dump(write2)
517 write(']')
518 writeFunc(')')
519
521 """A dictionary specialized to contain a JetMonitoringAlg specification"""
522
523 def __init__(self, name , defaultPath='standardHistos/', TriggerChain='' ,**args):
524
525 self.name = name
526 args.setdefault('FillerTools',[])
527 args.setdefault('topLevelDir', 'Jets/')
528 args.setdefault('bottomLevelDir', '')
529 args.setdefault('failureOnMissingContainer', True)
530 args.setdefault('onlyPassingJets', True)
531 args.setdefault('eventFiresAnyJetChain',False)
532 args.setdefault('isExpressStreamJob', False)
533 ConfigDict.__init__(self, defaultPath=defaultPath, TriggerChain=TriggerChain, **args)
534 tmpL = self.FillerTools
535 self.FillerTools = []
536 self.appendHistos(*tmpL)
537
538 def appendHistos(self, *hfillers):
539 tmpL = [retrieveHistoToolConf(hspec) for hspec in hfillers]
540 self.FillerTools += tmpL
541
542 def toAlg(self, monhelper):
543 from AthenaConfiguration.ComponentFactory import CompFactory
544 alg = monhelper.addAlgorithm(CompFactory.JetMonitoringAlg, self.name)
545 alg.TriggerChain = self.TriggerChain
546 alg.JetContainerName = self.JetContainerName
547 alg.FailureOnMissingContainer = self.failureOnMissingContainer
548 alg.OnlyPassingJets = self.onlyPassingJets
549 alg.EventFiresAnyJetChain = self.eventFiresAnyJetChain
550 alg.EnforceExpressTriggers = self.isExpressStreamJob
551
552 path = self.defaultPath
553 tools = []
554 for tconf in self.FillerTools:
555 tconf.topLevelDir = self.topLevelDir
556 tconf.bottomLevelDir = self.bottomLevelDir
557 tools.append( tconf.toTool( ))
558 tconf.defineHisto(alg, monhelper, path)
559 alg.FillerTools = tools
560 return alg
561
562 def _dump(self, writeFunc):
563 def write(s,e='\n'): writeFunc(' '+s,e)
564 def write2(s,e='\n'): writeFunc(' '+s,e)
565 writeFunc(self.__class__.__name__+'(')
566 for k,v in sorted(self.items()):
567 if k == 'FillerTools':
568 write('FillerTools = [')
569 for hspec in v:
570 #print ' uuuu ', hspec
571 hspec._dump(write2)
572 write('')
573 write(']')
574 else:
575 write(k+' = '+str(v))
576 writeFunc(')')
577
578
579# **************************************
580
581class JetMonSpecException(Exception):
582 pass
583
585 """Return a VarSpec from alias :
586 * if alias is a string look up in JetStandardHistoSpecs.knownVar
587 --> if not found build a VarSpec, assuming alias is an attribute of type float.
588 * if alias is a VarSpec, returns it directly
589 """
590 from JetMonitoring.JetStandardHistoSpecs import knownVar
591 if isinstance(alias, str):
592 conf = knownVar.get(alias,None)
593 if conf is None:
594 conf=VarSpec( Name=alias, Type='float')
595 else: # assume it's a config dict
596 conf = alias
597 return conf
598
599
601 """Return a ToolSpec from alias : (now with EventInfo or JetContainer variables)
602 * if alias is a string build a ToolSpec, assuming alias is an attribute of type float.
603 * if alias is a ToolSpec, returns it directly
604 """
605 from JetMonitoring.JetStandardHistoSpecs import knownEventVar
606 if isinstance(alias, str): #check for existing event or jetcontainer specs
607 conf = knownEventVar.get(alias,None)
608 if conf is None: #assume it's an eventInfo variable
609 conf = ToolSpec('EventHistoVarTool', alias, Attribute=alias)
610 else: # assume it's a config dict
611 conf = alias
612 return conf
613
614
616 """Return a HistoSpec from alias :
617 * if alias is a string look up in JetStandardHistoSpecs.knownHistos
618 --> if found, return a full clone (so client can modify it safely)
619 --> if not found and contain a ';' build a HistoSpec for a 2D histograms
620 * if alias is a ToolSpec, returns it directly
621 """
622 if isinstance(alias, ToolSpec):
623 return alias
624 elif isinstance(alias,str):
625 from JetMonitoring.JetStandardHistoSpecs import knownHistos
626 # get it from knownHistos
627 c = knownHistos.get(alias,None)
628 if c :
629 # found a knownHistos.
630 # we return a *clone* so that it can be modified without changing the standard spec.
631 return c.clone(c.name)
632 if ';' not in alias:
633 raise JetMonSpecException(" Unknown Histo specification : '{}' ".format(alias))
634 # print 'ERROR unknown Histo Filler specification ', alias
635 # return None
636 # we have a ';' : try to generate a 2D histo
637 aliases = alias.split(';')
638 aliasX, aliasY = aliases[0], aliases[1]
639 cX = knownHistos.get(aliasX,None)
640 cY = knownHistos.get(aliasY,None)
641 if len(aliases) == 2:
642 if None in (cX,cY):
643 print("ERROR unknown Histo Filler specification ", cX if cX is None else cY)
644 return None
645 # merge the spec
646 return cX.to2DSpec(cY)
647 else: # must be 3
648 aliasZ = aliases[2]
649 cZ = knownHistos.get(aliasZ,None)
650 if cZ is None:
651 # then we can try to build a dummy HistoSpec from a variable
652 # this is ok, since we're building a TProfile2D and we don't need
653 # binning info on the xAxis
654 vZ = retrieveVarToolConf(aliasZ)
655 cZ = HistoSpec(vZ.Name, (10,0,1) , title=vZ.Name+';'+vZ.Name+';', xvar=vZ )
656 return cX.to2DSpec(cY, zspec=cZ)
657
658 else:
659 # What is this :
660 print('ERROR can not instantiate a tool from ', alias)
661 return None
662
663
void print(char *figname, TCanvas *c1)
defineHisto(self, parentAlg, monhelper, path)
clone(self, newname, bins=None, xvar=None, yvar=None, zvar=None, **hargs)
defineHisto(self, parentAlg, monhelper, path)
to2DSpec(self, yspec, profile=False, zspec=None)
__init__(self, name, bins, xvar=None, yvar=None, zvar=None, profile=False, **args)
__init__(self, name, defaultPath='standardHistos/', TriggerChain='', **args)
defineHisto(self, parentAlg, monhelper, path)
__init__(self, selname, selexpr, path=None, **args)
__init__(self, klass, name, **args)
defineHisto(self, parentAlg, monhelper, path)
__init__(self, Name, Type='float', Index=-1, Scale=1)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
-event-from-file