CMS 3D CMS Logo

Public Member Functions | Public Attributes

ModelTools::ModelBuilderBase Class Reference

Inheritance diagram for ModelTools::ModelBuilderBase:
ModelTools::ModelBuilder ModelTools::CountingModelBuilder

List of all members.

Public Member Functions

def __init__
def doComment
def doObj
def doSet
def doVar
def factory_

Public Attributes

 options
 out

Detailed Description

This class defines the basic stuff for a model builder, and it's an interface on top of RooWorkspace::factory or HLF files

Definition at line 8 of file ModelTools.py.


Constructor & Destructor Documentation

def ModelTools::ModelBuilderBase::__init__ (   self,
  options 
)

Definition at line 10 of file ModelTools.py.

00011                               :
00012         self.options = options
00013         self.out = stdout
00014         if options.bin:
00015             if options.out == None: options.out = re.sub(".txt$","",options.fileName)+".root"
00016             options.baseDir = os.path.dirname(options.fileName)
00017             ROOT.gSystem.Load("libHiggsAnalysisCombinedLimit.so")
00018             self.out = ROOT.RooWorkspace("w","w");
00019             self.out._import = getattr(self.out,"import") # workaround: import is a python keyword
00020             self.out.dont_delete = []
00021             if options.verbose == 0:
00022                 ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.ERROR)
00023             elif options.verbose < 2:
00024                 ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.WARNING)
00025             if os.environ.has_key('ROOFITSYS'):
00026                 ROOT.gSystem.AddIncludePath(" -I%s/include " % os.environ['ROOFITSYS'])
00027         elif options.out != None:
00028             #stderr.write("Will save workspace to HLF file %s" % options.out)
00029             self.out = open(options.out, "w");
00030         if not options.bin:
00031             stderr.write("\nWARNING: You're not using binary mode. This is is DEPRECATED and NOT SUPPORTED anymore, and can give WRONG results.\n\n")
00032         if options.cexpr:
00033             global ROOFIT_EXPR;
            ROOFIT_EXPR = "cexpr"            

Member Function Documentation

def ModelTools::ModelBuilderBase::doComment (   self,
  X 
)

Definition at line 45 of file ModelTools.py.

00046                          :
        if not self.options.bin: self.out.write("// "+X+"\n");
def ModelTools::ModelBuilderBase::doObj (   self,
  name,
  type,
  X 
)

Definition at line 53 of file ModelTools.py.

00054                                :
00055         if self.options.bin: return self.factory_("%s::%s(%s)" % (type, name, X));
00056         else: self.out.write("%s = %s(%s);\n" % (name, type, X))

def ModelTools::ModelBuilderBase::doSet (   self,
  name,
  vars 
)

Definition at line 50 of file ModelTools.py.

00051                              :
00052         if self.options.bin: self.out.defineSet(name,vars)
        else: self.out.write("%s = set(%s);\n" % (name,vars));
def ModelTools::ModelBuilderBase::doVar (   self,
  vardef 
)

Definition at line 47 of file ModelTools.py.

00048                           :
00049         if self.options.bin: self.factory_(vardef);
        else: self.out.write(vardef+";\n");
def ModelTools::ModelBuilderBase::factory_ (   self,
  X 
)

Definition at line 34 of file ModelTools.py.

00035                         :
00036         if (len(X) > 1000):
00037             print "Executing factory with a string of length ",len(X)," > 1000, could trigger a bug: ",X
00038         ret = self.out.factory(X);
00039         if ret: 
00040             self.out.dont_delete.append(ret)
00041             return ret
00042         else:
00043             print "ERROR parsing '%s'" % X
00044             self.out.Print("V");
            raise RuntimeError, "Error in factory statement" 

Member Data Documentation

Definition at line 10 of file ModelTools.py.

Definition at line 10 of file ModelTools.py.