ATLAS Offline Software
Loading...
Searching...
No Matches
python.JetAnalysisCommon.ConfNameSpace Class Reference
Collaboration diagram for python.JetAnalysisCommon.ConfNameSpace:

Public Member Functions

 __init__ (self, name="")
 __getattr__ (self, t)
 getComp (self, classname)
 addNameSpaces (self, *nsList)

Public Attributes

str prefix = "" else ""

Detailed Description

A namespace able to automatically generate Configured when quering attributes :
Used to replace CompFactory so that expressions like :
  tool = CompFactory.Trk.SomeTrkTool("tname", Prop=2.345) 
  tool = CompFactory.getComp("Trk::SomeTrkTool")("tname", Prop=2.345) 
works. 
In the above 2 examples both CompFactory and Trk are ConfNameSpace

Definition at line 252 of file JetAnalysisCommon.py.

Constructor & Destructor Documentation

◆ __init__()

python.JetAnalysisCommon.ConfNameSpace.__init__ ( self,
name = "" )

Definition at line 260 of file JetAnalysisCommon.py.

260 def __init__(self, name=""):
261 self.prefix=name+"::" if name !="" else ""
262

Member Function Documentation

◆ __getattr__()

python.JetAnalysisCommon.ConfNameSpace.__getattr__ ( self,
t )

Definition at line 263 of file JetAnalysisCommon.py.

263 def __getattr__(self, t):
264 return self.getComp(t)
265

◆ addNameSpaces()

python.JetAnalysisCommon.ConfNameSpace.addNameSpaces ( self,
* nsList )

Definition at line 293 of file JetAnalysisCommon.py.

293 def addNameSpaces(self, *nsList):
294 for ns in nsList:
295 setattr(self, ns, ConfNameSpace(self.prefix+ns))
296
297
298
299# ----------------------------
300# A replacement for CompFactory

◆ getComp()

python.JetAnalysisCommon.ConfNameSpace.getComp ( self,
classname )
generates a new Configured class for the C++ class ROOT.classname .
 This implies there must be a dictionnary for classname.

Definition at line 266 of file JetAnalysisCommon.py.

266 def getComp(self, classname):
267 """generates a new Configured class for the C++ class ROOT.classname .
268 This implies there must be a dictionnary for classname.
269 """
270
271 # if we already generated the class, return it :
272 c = self.__dict__.get(classname, None)
273 if c is not None:
274 return c
275
276 # look for the c++ class from ROOT :
277 c=getattr(ROOT, self.prefix+classname, None)
278
279 if c is None:
280 print("JetAnalysisCommon ERROR : ",classname," is not a known C++ tool, alg, or namespace ")
281 raise
282
283 if hasattr(c,'getPropertyMgr'):
284 conf = generateConfigured(classname,c,self.prefix)
285 else:
286 # not a configurable. Must be a namespace
287 conf = ConfNameSpace(self.prefix+classname)
288
289 # save this new class onto self :
290 setattr(self, classname, conf)
291 return conf
292
void print(char *figname, TCanvas *c1)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

Member Data Documentation

◆ prefix

str python.JetAnalysisCommon.ConfNameSpace.prefix = "" else ""

Definition at line 261 of file JetAnalysisCommon.py.


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