CMS 3D CMS Logo

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

#include <QGLikelihoodCalculator.h>

Public Member Functions

float computeQGLikelihood (edm::ESHandle< QGLikelihoodObject > &QGLParamsColl, float pt, float eta, float rho, std::vector< float > vars)
 Compute likelihood for a jet using the QGLikelihoodObject information and a set of variables. More...
 
 QGLikelihoodCalculator ()
 
float systematicSmearing (edm::ESHandle< QGLikelihoodSystematicsObject > &QGLParamsColl, float pt, float eta, float rho, float qgValue, int qgIndex)
 
 ~QGLikelihoodCalculator ()
 

Private Member Functions

const QGLikelihoodObject::EntryfindEntry (std::vector< QGLikelihoodObject::Entry > const &data, float eta, float pt, float rho, int qgIndex, int varIndex)
 Find matching entry in vector for a given eta, pt, rho, qgIndex and varIndex. More...
 
bool isValidRange (float pt, float rho, float eta, const QGLikelihoodCategory &qgValidRange)
 Check the valid range of this qg tagger. More...
 
float smearingFunction (float x0, float a, float b, float min, float max)
 Return the smeared qgLikelihood value, given input x0 and parameters a, b, min and max. More...
 

Detailed Description

The QGLikelihoodCalculater calculates the likelihood for a jet It takes information on the valid range of the tool, the binning of the categories, and their PDFs from the QGLikelihoodObject The variables in the vars vector should match with the variables in the QGLikelihoodObject, in which they are identified by the varIndex Authors: andre.nosp@m.a.ca.nosp@m.rlo.m.nosp@m.arin.nosp@m.i@cer.nosp@m.n.ch, tom.c.nosp@m.orne.nosp@m.lis@c.nosp@m.ern..nosp@m.ch, cms-q.nosp@m.g-wo.nosp@m.rking.nosp@m.grou.nosp@m.p@cer.nosp@m.n.ch

Definition at line 13 of file QGLikelihoodCalculator.h.

Constructor & Destructor Documentation

QGLikelihoodCalculator::QGLikelihoodCalculator ( )
inline

Definition at line 16 of file QGLikelihoodCalculator.h.

16 {};
QGLikelihoodCalculator::~QGLikelihoodCalculator ( )
inline

Definition at line 17 of file QGLikelihoodCalculator.h.

17 {};

Member Function Documentation

float QGLikelihoodCalculator::computeQGLikelihood ( edm::ESHandle< QGLikelihoodObject > &  QGLParamsColl,
float  pt,
float  eta,
float  rho,
std::vector< float >  vars 
)

Compute likelihood for a jet using the QGLikelihoodObject information and a set of variables.

Definition at line 8 of file QGLikelihoodCalculator.cc.

References delta, geometryDiff::epsilon, findEntry(), callgraph::G, and isValidRange().

Referenced by QGTagger::produce().

8  {
9  if(!isValidRange(pt, rho, eta, QGLParamsColl->qgValidRange)) return -1;
10 
11  float Q=1., G=1.;
12  for(unsigned int varIndex = 0; varIndex < vars.size(); ++varIndex){
13 
14  auto qgEntry = findEntry(QGLParamsColl->data, eta, pt, rho, 0, varIndex);
15  if(!qgEntry) return -1;
16  float Qi = qgEntry->histogram.binContent(qgEntry->histogram.findBin(vars[varIndex]));
17  float mQ = qgEntry->mean;
18 
19  qgEntry = findEntry(QGLParamsColl->data, eta, pt, rho, 1, varIndex);
20  if(!qgEntry) return -1;
21  float Gi = qgEntry->histogram.binContent(qgEntry->histogram.findBin(vars[varIndex]));
22  float mG = qgEntry->mean;
23 
24  float epsilon=0;
25  float delta=0.000001;
26  if(Qi <= epsilon && Gi <= epsilon){
27  if(mQ>mG){
28  if(vars[varIndex] > mQ){ Qi = 1-delta; Gi = delta;}
29  else if(vars[varIndex] < mG){ Qi = delta; Gi = 1-delta;}
30  }
31  else if(mQ<mG){
32  if(vars[varIndex]<mQ) { Qi = 1-delta; Gi = delta;}
33  else if(vars[varIndex]>mG){Qi = delta;Gi = 1-delta;}
34  }
35  }
36  Q*=Qi;
37  G*=Gi;
38  }
39 
40  if(Q==0) return 0;
41  return Q/(Q+G);
42 }
dbl * delta
Definition: mlp_gen.cc:36
Definition: DDAxes.h:10
T eta() const
tuple G
Definition: callgraph.py:12
const QGLikelihoodObject::Entry * findEntry(std::vector< QGLikelihoodObject::Entry > const &data, float eta, float pt, float rho, int qgIndex, int varIndex)
Find matching entry in vector for a given eta, pt, rho, qgIndex and varIndex.
bool isValidRange(float pt, float rho, float eta, const QGLikelihoodCategory &qgValidRange)
Check the valid range of this qg tagger.
const QGLikelihoodObject::Entry * QGLikelihoodCalculator::findEntry ( std::vector< QGLikelihoodObject::Entry > const &  data,
float  eta,
float  pt,
float  rho,
int  qgIndex,
int  varIndex 
)
private

Find matching entry in vector for a given eta, pt, rho, qgIndex and varIndex.

Definition at line 46 of file QGLikelihoodCalculator.cc.

References QGLikelihoodParameters::Eta, QGLikelihoodParameters::Pt, EnergyCorrector::pt, QGLikelihoodParameters::QGIndex, rho, QGLikelihoodParameters::Rho, and QGLikelihoodParameters::VarIndex.

Referenced by computeQGLikelihood().

46  {
47  QGLikelihoodParameters myParameters;
48  myParameters.Rho = rho;
49  myParameters.Pt = pt;
50  myParameters.Eta = fabs(eta);
51  myParameters.QGIndex = qgIndex;
52  myParameters.VarIndex = varIndex;
53 
54  auto myDataObject = data.begin();
55  while(!(myParameters == myDataObject->category)){
56  ++myDataObject;
57  if(myDataObject == data.end()){
58  edm::LogWarning("QGLCategoryNotFound") << "Jet passed qgValidRange criteria, but no category found with rho=" << rho << ", pt=" << pt << ", eta=" << eta
59  << "\nPlease contact cms-qg-workinggroup@cern.ch" << std::endl;
60  return nullptr;
61  }
62  }
63  return &*myDataObject;
64 }
Parameters structure.
Definition: DDAxes.h:10
T eta() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool QGLikelihoodCalculator::isValidRange ( float  pt,
float  rho,
float  eta,
const QGLikelihoodCategory qgValidRange 
)
private

Check the valid range of this qg tagger.

Definition at line 68 of file QGLikelihoodCalculator.cc.

References QGLikelihoodCategory::EtaMax, QGLikelihoodCategory::EtaMin, QGLikelihoodCategory::PtMax, QGLikelihoodCategory::PtMin, QGLikelihoodCategory::RhoMax, and QGLikelihoodCategory::RhoMin.

Referenced by computeQGLikelihood().

68  {
69  if(pt < qgValidRange.PtMin) return false;
70  if(pt > qgValidRange.PtMax) return false;
71  if(rho < qgValidRange.RhoMin) return false;
72  if(rho > qgValidRange.RhoMax) return false;
73  if(fabs(eta) < qgValidRange.EtaMin) return false;
74  if(fabs(eta) > qgValidRange.EtaMax) return false;
75  return true;
76 }
Definition: DDAxes.h:10
T eta() const
float QGLikelihoodCalculator::smearingFunction ( float  x0,
float  a,
float  b,
float  min,
float  max 
)
private

Return the smeared qgLikelihood value, given input x0 and parameters a, b, min and max.

Definition at line 80 of file QGLikelihoodCalculator.cc.

References min(), and x.

Referenced by systematicSmearing().

80  {
81  float x=(x0-min)/(max-min);
82  if(x<0.) x=0.;
83  if(x>1.) x=1.;
84 
85  float x1= tanh(a*atanh(2.*x-1.)+b)/2.+.5;
86  if(x<=0.) x1=0.;
87  if(x>=1.) x1=1.;
88 
89  return x1*(max-min)+min;
90 }
T min(T a, T b)
Definition: MathUtil.h:58
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
Definition: DDAxes.h:10
float QGLikelihoodCalculator::systematicSmearing ( edm::ESHandle< QGLikelihoodSystematicsObject > &  QGLParamsColl,
float  pt,
float  eta,
float  rho,
float  qgValue,
int  qgIndex 
)

Definition at line 93 of file QGLikelihoodCalculator.cc.

References QGLikelihoodParameters::Eta, QGLikelihoodParameters::Pt, EnergyCorrector::pt, QGLikelihoodParameters::QGIndex, rho, QGLikelihoodParameters::Rho, smearingFunction(), and QGLikelihoodParameters::VarIndex.

Referenced by QGTagger::produce().

93  {
94  if(qgValue < 0 || qgValue > 1) return -1.;
95 
96  QGLikelihoodParameters myParameters;
97  myParameters.Rho = rho;
98  myParameters.Pt = pt;
99  myParameters.Eta = fabs(eta);
100  myParameters.QGIndex = qgIndex;
101  myParameters.VarIndex = -1;
102 
103  auto myDataObject = QGLSystematicsColl->data.begin();
104  while(!(myParameters == myDataObject->systCategory)){
105  ++myDataObject;
106  if(myDataObject == QGLSystematicsColl->data.end()) return -1; //Smearing not available in the whole qgValidRange: do not throw warnings or errors
107  }
108  return smearingFunction(qgValue, myDataObject->a, myDataObject->b, myDataObject->lmin, myDataObject->lmax);
109 }
Parameters structure.
Definition: DDAxes.h:10
float smearingFunction(float x0, float a, float b, float min, float max)
Return the smeared qgLikelihood value, given input x0 and parameters a, b, min and max...
T eta() const