3 from sys
import argv, stdout, stderr, exit, modules
4 from optparse
import OptionParser
9 ROOT.gROOT.SetBatch(
True)
17 parser = OptionParser(usage=
"usage: %prog [options] datacard.txt -o output \nrun with --help to get list of options")
19 parser.add_option(
"-P",
"--physics-model", dest=
"physModel", default=
"HiggsAnalysis.CombinedLimit.PhysicsModel:defaultModel", type=
"string", help=
"Physics model to use. It should be in the form (module name):(object name)")
20 parser.add_option(
"--PO",
"--physics-option", dest=
"physOpt", default=[], type=
"string", action=
"append", help=
"Pass a given option to the physics model (can specify multiple times)")
21 (options, args) = parser.parse_args()
27 options.fileName = args[0]
28 if options.fileName.endswith(
".gz"):
30 file = gzip.open(options.fileName,
"rb")
31 options.fileName = options.fileName[:-3]
33 file = open(options.fileName,
"r")
41 MB = ShapeBuilder(DC, options)
43 MB = CountingModelBuilder(DC, options)
46 (physModMod, physModName) = options.physModel.split(
":")
47 __import__(physModMod)
48 mod = modules[physModMod]
49 physics = getattr(mod, physModName)
50 if mod ==
None:
raise RuntimeError,
"Physics model module %s not found" % physModMod
51 if physics ==
None or not isinstance(physics, PhysicsModel):
52 raise RuntimeError,
"Physics model %s in module %s not found, or not inheriting from PhysicsModel" % (physModName, physModMod)
53 physics.setPhysicsOptions(options.physOpt)
55 MB.setPhysics(physics)
def addDatacardParserOptions