8 if value<bins[0]
or value>bins[len(bins)-1]:
return False
9 for i
in range(0,len(bins)-1):
10 if value>bins[i]
and value<bins[i+1]:
25 self.
varNames = { 0:
'mult', 1:
'ptD', 2:
'axis2' }
31 print "[QGLikelihoodCalculator]: Initializing from file: " + filename
33 f = ROOT.TFile.Open(filename)
34 if f.IsZombie() :
return False
37 self.
ptBins = f.Get(
"ptBins")
42 print "[QGLikelihoodCalculator]: Initialized binning of pdfs..."
44 keys = f.GetListOfKeys()
46 if key.IsFolder() ==
False:
continue
47 hists = key.ReadObj().GetListOfKeys()
49 histogram = hist.ReadObj()
50 histogram.SetDirectory(0)
51 self.
pdfs[hist.GetName()] = histogram
53 print "[QGLikelihoodCalculator]: pdfs initialized..."
62 if pt < self.
ptBins[0]:
return False
64 if rho < self.
rhoBins[0]:
return False
66 if math.fabs(eta) < self.
etaBins[0]:
return False
67 if math.fabs(eta) > self.
etaBins[len(self.
etaBins)-1]:
return False
73 def findEntry( self, eta, pt, rho, qgIndex, varIndex ) :
76 if etaBin==-1:
return None
78 if ptBin==-1 :
return None
81 if rhoBin==-1 :
return None
83 histName = self.
varNames[varIndex] +
"_" + self.
qgNames[qgIndex] +
"_eta" + str(etaBin) +
"_pt" + str(ptBin) +
"_rho" + str(rhoBin)
85 return self.
pdfs[histName]
93 if self.
isValidRange(jet.pt(), rho, jet.eta())==
False:
return -1
95 vars = {0:jet.mult, 1:jet.ptd, 2:jet.axis2}
112 qgEntry = self.
findEntry(jet.eta(), jet.pt(), rho, 0, i)
114 if qgEntry ==
None:
return -1
115 Qi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
116 mQ = qgEntry.GetMean()
120 qgEntry = self.
findEntry(jet.eta(), jet.pt(), rho, 1, i)
122 if qgEntry ==
None:
return -1
123 Gi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
124 mG = qgEntry.GetMean()
129 if Qi <= epsilon
and Gi <= epsilon :
152 else :
return Q/(Q+G)