CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
QGLikelihoodCalculator.QGLikelihoodCalculator Class Reference

Public Member Functions

def __init__
 
def computeQGLikelihood
 
def findEntry
 
def init
 
def isValidRange
 

Public Attributes

 etaBins
 
 pdfs
 
 ptBins
 
 qgNames
 
 rhoBins
 
 varNames
 

Detailed Description

Definition at line 18 of file QGLikelihoodCalculator.py.

Constructor & Destructor Documentation

def QGLikelihoodCalculator.QGLikelihoodCalculator.__init__ (   self,
  filename 
)

Member Function Documentation

def QGLikelihoodCalculator.QGLikelihoodCalculator.computeQGLikelihood (   self,
  jet,
  rho 
)

Definition at line 91 of file QGLikelihoodCalculator.py.

References AlignableDataIORoot.findEntry(), AlignmentParametersIORoot.findEntry(), HIPUserVariablesIORoot.findEntry(), EntryMgr.findEntry(), QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry(), and QGLikelihoodCalculator.QGLikelihoodCalculator.isValidRange().

91 
92  def computeQGLikelihood( self, jet, rho ):
93 
94  if self.isValidRange(jet.pt(), rho, jet.eta())==False: return -1
95 
96  vars = {0:jet.mult, 1:jet.ptd, 2:jet.axis2}
97 
98  Q=1.
99  G=1.
100 
101  #print "----------------------"
102  #if jet.partonFlavour()==21 :
103  # print "this jet is a GLUON"
104  #elif math.fabs(jet.partonFlavour())<4 and jet.partonFlavour()!=0:
105  # print "this jet is a QUARK"
106  #print "pt: " + str(jet.pt()) + " eta: " + str(jet.eta()) + " rho: " + str(rho)
107  #print "multi: " + str(jet.mult) + " ptd: " + str(jet.ptd) + " axis2: " + str(jet.axis2)
108 
109  for i in vars :
110 
111  #print self.varNames[i] + ": " + str(vars[i])
112  # quarks = 0
113  qgEntry = self.findEntry(jet.eta(), jet.pt(), rho, 0, i)
114 
115  if qgEntry == None: return -1
116  Qi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
117  mQ = qgEntry.GetMean()
118  #print "Qi: " + str(Qi)
119 
120  # gluons = 1
121  qgEntry = self.findEntry(jet.eta(), jet.pt(), rho, 1, i)
122 
123  if qgEntry == None: return -1
124  Gi = qgEntry.GetBinContent(qgEntry.FindBin(vars[i]))
125  mG = qgEntry.GetMean()
126  #print "Gi: " + str(Gi)
127 
128  epsilon=0.
129  delta=0.000001
130  if Qi <= epsilon and Gi <= epsilon :
131  if mQ>mG :
132  if vars[i] > mQ :
133  Qi = 1.-delta
134  Gi = delta
135  elif vars[i] < mG :
136  Qi = delta
137  Gi = 1.-delta
138  else :
139  if vars[i]<mQ :
140  Qi = 1.-delta
141  Gi = delta
142  elif vars[i]>mG :
143  Qi = delta
144  Gi = 1.-delta
145 
146  Q*=Qi
147  G*=Gi
148 
149 
150  #print "Q: " + str(Q)
151  #print "G: " + str(G)
152  if Q==0. : return 0.
153  else : return Q/(Q+G)
154 
def QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry (   self,
  eta,
  pt,
  rho,
  qgIndex,
  varIndex 
)

Definition at line 73 of file QGLikelihoodCalculator.py.

References QGLikelihoodCalculator.QGLikelihoodCalculator.etaBins, CSCTFConstants.etaBins, ElectronStudy.etaBins, ZMuMu_efficiencyAnalyzer.etaBins, QGLikelihoodCalculator.getBinNumber(), QGLikelihoodCalculator.QGLikelihoodCalculator.pdfs, PhysicsTools::Calibration::ProcLikelihood.pdfs, QGLikelihoodCalculator.QGLikelihoodCalculator.ptBins, ZMuMu_efficiencyAnalyzer.ptBins, QGLikelihoodCalculator.QGLikelihoodCalculator.qgNames, QGLikelihoodCalculator.QGLikelihoodCalculator.rhoBins, and QGLikelihoodCalculator.QGLikelihoodCalculator.varNames.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.computeQGLikelihood().

73 
74  def findEntry( self, eta, pt, rho, qgIndex, varIndex ) :
75 
76  etaBin = getBinNumber( self.etaBins, math.fabs(eta))
77  if etaBin==-1: return None
78  ptBin = getBinNumber( self.ptBins, pt )
79  if ptBin==-1 : return None
80 
81  rhoBin = getBinNumber( self.rhoBins, rho )
82  if rhoBin==-1 : return None
83 
84  histName = self.varNames[varIndex] + "_" + self.qgNames[qgIndex] + "_eta" + str(etaBin) + "_pt" + str(ptBin) + "_rho" + str(rhoBin)
85 
86  return self.pdfs[histName]
87 
88 
89 
90 
def QGLikelihoodCalculator.QGLikelihoodCalculator.init (   self,
  filename 
)

Definition at line 29 of file QGLikelihoodCalculator.py.

References QGLikelihoodCalculator.QGLikelihoodCalculator.etaBins, CSCTFConstants.etaBins, ElectronStudy.etaBins, ZMuMu_efficiencyAnalyzer.etaBins, QGLikelihoodCalculator.QGLikelihoodCalculator.pdfs, PhysicsTools::Calibration::ProcLikelihood.pdfs, QGLikelihoodCalculator.QGLikelihoodCalculator.ptBins, ZMuMu_efficiencyAnalyzer.ptBins, and QGLikelihoodCalculator.QGLikelihoodCalculator.rhoBins.

29 
30  def init(self, filename) :
31 
32  print "[QGLikelihoodCalculator]: Initializing from file: " + filename
33 
34  f = ROOT.TFile.Open(filename)
35  if f.IsZombie() : return False
36  try :
37  self.etaBins = f.Get("etaBins")
38  self.ptBins = f.Get("ptBins")
39  self.rhoBins = f.Get("rhoBins")
40  except :
41  return False
42 
43  print "[QGLikelihoodCalculator]: Initialized binning of pdfs..."
44 
45  keys = f.GetListOfKeys()
46  for key in keys :
47  if key.IsFolder() == False: continue
48  hists = key.ReadObj().GetListOfKeys()
49  for hist in hists :
50  histogram = hist.ReadObj()
51  histogram.SetDirectory(0)
52  self.pdfs[hist.GetName()] = histogram
53 
54  print "[QGLikelihoodCalculator]: pdfs initialized..."
55 
56  return True
57 
58 
59 
def QGLikelihoodCalculator.QGLikelihoodCalculator.isValidRange (   self,
  pt,
  rho,
  eta 
)

Definition at line 60 of file QGLikelihoodCalculator.py.

References QGLikelihoodCalculator.QGLikelihoodCalculator.etaBins, CSCTFConstants.etaBins, ElectronStudy.etaBins, ZMuMu_efficiencyAnalyzer.etaBins, QGLikelihoodCalculator.QGLikelihoodCalculator.ptBins, ZMuMu_efficiencyAnalyzer.ptBins, and QGLikelihoodCalculator.QGLikelihoodCalculator.rhoBins.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.computeQGLikelihood().

60 
61  def isValidRange( self, pt, rho, eta ) :
62 
63  if pt < self.ptBins[0]: return False
64  if pt > self.ptBins[len(self.ptBins)-1]: return False
65  if rho < self.rhoBins[0]: return False
66  if rho > self.rhoBins[len(self.rhoBins)-1]: return False
67  if math.fabs(eta) < self.etaBins[0]: return False
68  if math.fabs(eta) > self.etaBins[len(self.etaBins)-1]: return False
69  return True
70 
71 
72 

Member Data Documentation

QGLikelihoodCalculator.QGLikelihoodCalculator.etaBins

Definition at line 22 of file QGLikelihoodCalculator.py.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry(), QGLikelihoodCalculator.QGLikelihoodCalculator.init(), and QGLikelihoodCalculator.QGLikelihoodCalculator.isValidRange().

QGLikelihoodCalculator.QGLikelihoodCalculator.pdfs

Definition at line 21 of file QGLikelihoodCalculator.py.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry(), and QGLikelihoodCalculator.QGLikelihoodCalculator.init().

QGLikelihoodCalculator.QGLikelihoodCalculator.ptBins

Definition at line 23 of file QGLikelihoodCalculator.py.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry(), QGLikelihoodCalculator.QGLikelihoodCalculator.init(), and QGLikelihoodCalculator.QGLikelihoodCalculator.isValidRange().

QGLikelihoodCalculator.QGLikelihoodCalculator.qgNames

Definition at line 26 of file QGLikelihoodCalculator.py.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry().

QGLikelihoodCalculator.QGLikelihoodCalculator.rhoBins

Definition at line 24 of file QGLikelihoodCalculator.py.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry(), QGLikelihoodCalculator.QGLikelihoodCalculator.init(), and QGLikelihoodCalculator.QGLikelihoodCalculator.isValidRange().

QGLikelihoodCalculator.QGLikelihoodCalculator.varNames

Definition at line 25 of file QGLikelihoodCalculator.py.

Referenced by QGLikelihoodCalculator.QGLikelihoodCalculator.findEntry().