1 from __future__
import print_function
9 if value<bins[0]
or value>bins[len(bins)-1]:
return False 10 for i
in range(0,len(bins)-1):
11 if value>bins[i]
and value<bins[i+1]:
26 self.
varNames = { 0:
'mult', 1:
'ptD', 2:
'axis2' }
32 print(
"[QGLikelihoodCalculator]: Initializing from file: " + filename)
34 f = ROOT.TFile.Open(filename)
35 if f.IsZombie() :
return False 38 self.
ptBins = f.Get(
"ptBins")
47 for it
in range(0,len(self.
qgNames)):
49 for iv
in range(0,len(self.
varNames)):
51 for ie
in range(0,len(self.
etaBins)):
53 for ip
in range(0,len(self.
ptBins)):
55 for ir
in range(0,len(self.
rhoBins)):
60 print(
"[QGLikelihoodCalculator]: Initialized binning of pdfs...")
62 keys = f.GetListOfKeys()
64 if key.IsFolder() ==
False:
continue 65 hists = key.ReadObj().GetListOfKeys()
67 pieces = hist.GetName().
split(
"_")
73 etaBin =
int(etaStr.split(
"eta")[1])
74 ptBin =
int( ptStr.split(
"pt") [1])
75 rhoBin =
int(rhoStr.split(
"rho")[1])
76 histogram = hist.ReadObj()
77 histogram.SetDirectory(0)
78 self.
pdfs[qgType][varName][etaBin][ptBin][rhoBin] = histogram
80 print(
"[QGLikelihoodCalculator]: pdfs initialized...")
90 if pt < self.
ptBins[0]:
return False 92 if rho < self.
rhoBins[0]:
return False 94 if math.fabs(eta) < self.
etaBins[0]:
return False 95 if math.fabs(eta) > self.
etaBins[len(self.
etaBins)-1]:
return False 104 if etaBin==-1:
return None 106 if ptBin==-1 :
return None 109 if rhoBin==-1 :
return None 111 return self.
pdfs[qgType][varName][etaBin][ptBin][rhoBin]
119 if self.
isValidRange(jet.pt(), rho, jet.eta())==
False:
return -1
122 vars = {0:jet.mult, 1:jet.ptd, 2:jet.axis2}
141 if qgEntry ==
None:
return -1
142 Qi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
143 mQ = qgEntry.GetMean()
149 if qgEntry ==
None:
return -1
150 Gi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
151 mG = qgEntry.GetMean()
156 if Qi <= epsilon
and Gi <= epsilon :
179 else :
return Q/(Q+G)
def isValidRange(self, pt, rho, eta)
def __init__(self, filename)
def computeQGLikelihood(self, jet, rho)
S & print(S &os, JobReport::InputFile const &f)
def findEntry(self, eta, pt, rho, qgType, varName)
def getBinNumber(bins, value)