1 from __future__
import print_function
2 from builtins
import range
10 if value<bins[0]
or value>bins[len(bins)-1]:
return False 11 for i
in range(0,len(bins)-1):
12 if value>bins[i]
and value<bins[i+1]:
27 self.
varNames = { 0:
'mult', 1:
'ptD', 2:
'axis2' }
33 print(
"[QGLikelihoodCalculator]: Initializing from file: " + filename)
35 f = ROOT.TFile.Open(filename)
36 if f.IsZombie() :
return False 39 self.
ptBins = f.Get(
"ptBins")
61 print(
"[QGLikelihoodCalculator]: Initialized binning of pdfs...")
63 keys = f.GetListOfKeys()
65 if key.IsFolder() ==
False:
continue 66 hists = key.ReadObj().GetListOfKeys()
68 pieces = hist.GetName().
split(
"_")
74 etaBin =
int(etaStr.split(
"eta")[1])
75 ptBin =
int( ptStr.split(
"pt") [1])
76 rhoBin =
int(rhoStr.split(
"rho")[1])
77 histogram = hist.ReadObj()
78 histogram.SetDirectory(0)
79 self.
pdfs[qgType][varName][etaBin][ptBin][rhoBin] = histogram
81 print(
"[QGLikelihoodCalculator]: pdfs initialized...")
91 if pt < self.
ptBins[0]:
return False 93 if rho < self.
rhoBins[0]:
return False 95 if math.fabs(eta) < self.
etaBins[0]:
return False 96 if math.fabs(eta) > self.
etaBins[len(self.
etaBins)-1]:
return False 105 if etaBin==-1:
return None 107 if ptBin==-1 :
return None 110 if rhoBin==-1 :
return None 112 return self.
pdfs[qgType][varName][etaBin][ptBin][rhoBin]
120 if self.
isValidRange(jet.pt(), rho, jet.eta())==
False:
return -1
123 vars = {0:jet.mult, 1:jet.ptd, 2:jet.axis2}
142 if qgEntry ==
None:
return -1
143 Qi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
144 mQ = qgEntry.GetMean()
150 if qgEntry ==
None:
return -1
151 Gi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
152 mG = qgEntry.GetMean()
157 if Qi <= epsilon
and Gi <= epsilon :
180 else :
return Q/(Q+G)
def isValidRange(self, pt, rho, eta)
def __init__(self, filename)
def computeQGLikelihood(self, jet, rho)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def findEntry(self, eta, pt, rho, qgType, varName)
def getBinNumber(bins, value)