ATLAS Offline Software
Loading...
Searching...
No Matches
JetMonitoringConfig Namespace Reference

Classes

class  ConfigDict
class  EventHistoSpec
class  HistoSpec
class  JetMonAlgSpec
class  JetMonSpecException
class  SelectSpec
class  ToolSpec
class  VarSpec

Functions

 interpretManySelStr (selStr)
 interpretSelStr (selStr)
 findSelectIndex (name)
 retrieveVarToolConf (alias)
 retrieveEventVarToolConf (alias)
 retrieveHistoToolConf (alias)

Function Documentation

◆ findSelectIndex()

JetMonitoringConfig.findSelectIndex ( name)
interprets 'varName[X]' into ('varName',x) 

Definition at line 144 of file JetMonitoringConfig.py.

144def findSelectIndex( name):
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

◆ interpretManySelStr()

JetMonitoringConfig.interpretManySelStr ( selStr)

Definition at line 105 of file JetMonitoringConfig.py.

105def interpretManySelStr(selStr):
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

◆ interpretSelStr()

JetMonitoringConfig.interpretSelStr ( selStr)
Interpret a selection string in the form '12.3<var<42.0'
and returns a tuple.
 '12.3<var<42.0' -> returns (12.3, 'var', 42.)
 'var<42.0' -> returns (None, 'var', 42.)
 '12.3<var' -> returns (12.3, 'var', None)

Definition at line 113 of file JetMonitoringConfig.py.

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
void print(char *figname, TCanvas *c1)

◆ retrieveEventVarToolConf()

JetMonitoringConfig.retrieveEventVarToolConf ( alias)
Return a ToolSpec from alias : (now with EventInfo or JetContainer variables) 
    * if alias is a string build a ToolSpec, assuming alias is an attribute of type float.
    * if alias is a ToolSpec, returns it directly

Definition at line 605 of file JetMonitoringConfig.py.

605def retrieveEventVarToolConf(alias):
606 """Return a ToolSpec from alias : (now with EventInfo or JetContainer variables)
607 * if alias is a string build a ToolSpec, assuming alias is an attribute of type float.
608 * if alias is a ToolSpec, returns it directly
609 """
610 from JetMonitoring.JetStandardHistoSpecs import knownEventVar
611 if isinstance(alias, str): #check for existing event or jetcontainer specs
612 conf = knownEventVar.get(alias,None)
613 if conf is None: #assume it's an eventInfo variable
614 conf = ToolSpec('EventHistoVarTool', alias, Attribute=alias)
615 else: # assume it's a config dict
616 conf = alias
617 return conf
618
619

◆ retrieveHistoToolConf()

JetMonitoringConfig.retrieveHistoToolConf ( alias)
Return a HistoSpec from alias : 
    * if alias is a string look up in JetStandardHistoSpecs.knownHistos
      --> if found, return a full clone (so client can modify it safely)
      --> if not found and contain a ';' build a HistoSpec for a 2D histograms
    * if alias is a ToolSpec, returns it directly

Definition at line 620 of file JetMonitoringConfig.py.

620def retrieveHistoToolConf(alias):
621 """Return a HistoSpec from alias :
622 * if alias is a string look up in JetStandardHistoSpecs.knownHistos
623 --> if found, return a full clone (so client can modify it safely)
624 --> if not found and contain a ';' build a HistoSpec for a 2D histograms
625 * if alias is a ToolSpec, returns it directly
626 """
627 if isinstance(alias, ToolSpec):
628 return alias
629 elif isinstance(alias,str):
630 from JetMonitoring.JetStandardHistoSpecs import knownHistos
631 # get it from knownHistos
632 c = knownHistos.get(alias,None)
633 if c :
634 # found a knownHistos.
635 # we return a *clone* so that it can be modified without changing the standard spec.
636 return c.clone(c.name)
637 if ';' not in alias:
638 raise JetMonSpecException(" Unknown Histo specification : '{}' ".format(alias))
639 # print 'ERROR unknown Histo Filler specification ', alias
640 # return None
641 # we have a ';' : try to generate a 2D histo
642 aliases = alias.split(';')
643 aliasX, aliasY = aliases[0], aliases[1]
644 cX = knownHistos.get(aliasX,None)
645 cY = knownHistos.get(aliasY,None)
646 if len(aliases) == 2:
647 if None in (cX,cY):
648 print("ERROR unknown Histo Filler specification ", cX if cX is None else cY)
649 return None
650 # merge the spec
651 return cX.to2DSpec(cY)
652 else: # must be 3
653 aliasZ = aliases[2]
654 cZ = knownHistos.get(aliasZ,None)
655 if cZ is None:
656 # then we can try to build a dummy HistoSpec from a variable
657 # this is ok, since we're building a TProfile2D and we don't need
658 # binning info on the xAxis
659 vZ = retrieveVarToolConf(aliasZ)
660 cZ = HistoSpec(vZ.Name, (10,0,1) , title=vZ.Name+';'+vZ.Name+';', xvar=vZ )
661 return cX.to2DSpec(cY, zspec=cZ)
662
663 else:
664 # What is this :
665 print('ERROR can not instantiate a tool from ', alias)
666 return None
667
668

◆ retrieveVarToolConf()

JetMonitoringConfig.retrieveVarToolConf ( alias)
Return a VarSpec from alias : 
    * if alias is a string look up in JetStandardHistoSpecs.knownVar
      --> if not found build a VarSpec, assuming alias is an attribute of type float.
    * if alias is a VarSpec, returns it directly

Definition at line 589 of file JetMonitoringConfig.py.

589def retrieveVarToolConf(alias):
590 """Return a VarSpec from alias :
591 * if alias is a string look up in JetStandardHistoSpecs.knownVar
592 --> if not found build a VarSpec, assuming alias is an attribute of type float.
593 * if alias is a VarSpec, returns it directly
594 """
595 from JetMonitoring.JetStandardHistoSpecs import knownVar
596 if isinstance(alias, str):
597 conf = knownVar.get(alias,None)
598 if conf is None:
599 conf=VarSpec( Name=alias, Type='float')
600 else: # assume it's a config dict
601 conf = alias
602 return conf
603
604