def test3AccessToGlobalsFromROOT(self): """Test creation and access of new ROOT globals""" import ROOT ROOT.gMyOwnGlobal = 3.1415 proxy = gROOT.GetGlobal('gMyOwnGlobal', 1) self.assertEqual(proxy.__get__(proxy), 3.1415)
def printPSet(bPrintPset, folderName="signalAnalysis"): ''' def printPSet(): Simple module that prints the parameters set in running the analysis ''' if bPrintPset: from ROOT import gROOT gDirectory = gROOT.GetGlobal("gDirectory") named = gDirectory.Get("%s/parameterSet" % (folderName)) print named.GetTitle() raw_input("*** Press \"any\" key to continue: ") else: return;
def test2AccessToGlobals(self): """Test overwritability of ROOT globals""" import ROOT oldval = ROOT.gDebug # get proxy before setting, otherwise the AutoLoader will have printout proxy = gROOT.GetGlobal('gDebug', 1) ROOT.gDebug = -1 self.assertEqual(proxy.__get__(proxy), -1) ROOT.gDebug = oldval
def test3AccessToGlobalsFromROOT(self): """Test creation and access of new ROOT globals""" import ROOT ROOT.gMyOwnGlobal = 3.1415 proxy = gROOT.GetGlobal('gMyOwnGlobal', 1) try: self.assertEqual(proxy.__get__(proxy), 3.1415) except AttributeError: # In the old PyROOT, if we try to bind a new global, # such global is defined on the C++ side too, but # only if its type is basic or string (see ROOT.py). # The new PyROOT will discontinue this feature. # Note that in the new PyROOT we can still define a # global in C++ and access/modify it from Python ROOT.gInterpreter.Declare("int gMyOwnGlobal2 = 1;") self.assertEqual(ROOT.gMyOwnGlobal2, 1) ROOT.gMyOwnGlobal2 = -1 self.assert_(gROOT.ProcessLine('gMyOwnGlobal2 == -1'))