def setupMinuitFitarg(pnames, pmins, pmaxs, LIMITFILE): ## Dictionary fitarg for iminuit farg = dict() ## Initial conditions --- use pos = center of hypercube, and step = range/10 # TODO: Optionally make an initial brute force scan to choose the Minuit starting point, using prof.scangrid assert len(pmins) == len(pmaxs) pmids = [(pmins[i] + pmaxs[i]) / 2. for i in xrange(len(pmins))] pranges = [(pmaxs[i] - pmins[i]) for i in xrange(len(pmins))] # This sets the start point for i, aname in enumerate(pnames): farg[aname] = pmids[i] farg['error_%s' % aname] = pranges[i] / 10. ## Fix parameters, set limits (with pname translation) import professor2 as prof limits, fixed = prof.read_limitsandfixed(LIMITFILE) for i, pname in enumerate(pnames): if pname in limits.keys(): farg['limit_%s' % pname] = limits[pname] if pname in fixed.keys(): # if not opts.QUIET: # print "Fixing", pname, "= %f"%fixed[pnames[i]] farg[pname] = fixed[pnames[i]] farg['fix_%s' % pname] = True return farg
def setLimits(self, fname): import professor2 as prof limits, fixed = prof.read_limitsandfixed(fname) for k, v in limits.iteritems(): self._limits[k] = (v[0], v[1]) # self._limits[k][1]=v[1] for k, v in fixed.iteritems(): for g in self._generators: g.fixParam(k, float(v)) self._fixed[k] = float(v)