CMS 3D CMS Logo

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) const
 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) const
 
 ~QGLikelihoodCalculator ()
 

Private Member Functions

const QGLikelihoodObject::EntryfindEntry (std::vector< QGLikelihoodObject::Entry > const &data, float eta, float pt, float rho, int qgIndex, int varIndex) const
 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) const
 Check the valid range of this qg tagger. More...
 
float smearingFunction (float x0, float a, float b, float min, float max) const
 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

Definition at line 16 of file QGLikelihoodCalculator.h.

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

Member Function Documentation

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

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

Definition at line 8 of file QGLikelihoodCalculator.cc.

References QGLikelihoodObject::data, findEntry(), callgraph::G, isValidRange(), class-composition::Q, and QGLikelihoodObject::qgValidRange.

Referenced by QGTagger::produce(), and ~QGLikelihoodCalculator().

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 quarkEntry = findEntry(QGLParamsColl->data, eta, pt, rho, 0, varIndex);
15  auto gluonEntry = findEntry(QGLParamsColl->data, eta, pt, rho, 1, varIndex);
16  if(!quarkEntry || !gluonEntry) return -2;
17 
18  int binQ = quarkEntry->histogram.findBin(vars[varIndex]);
19  float Qi = quarkEntry->histogram.binContent(binQ);
20 
21  int binG = gluonEntry->histogram.findBin(vars[varIndex]);
22  float Gi = gluonEntry->histogram.binContent(binG);
23 
24  Q *= Qi;
25  G *= Gi;
26  }
27 
28  if(Q==0) return 0;
29  return Q/(Q+G);
30 }
bool isValidRange(float pt, float rho, float eta, const QGLikelihoodCategory &qgValidRange) const
Check the valid range of this qg tagger.
QGLikelihoodCategory qgValidRange
const QGLikelihoodObject::Entry * findEntry(std::vector< QGLikelihoodObject::Entry > const &data, float eta, float pt, float rho, int qgIndex, int varIndex) const
Find matching entry in vector for a given eta, pt, rho, qgIndex and varIndex.
std::vector< Entry > data
const QGLikelihoodObject::Entry * QGLikelihoodCalculator::findEntry ( std::vector< QGLikelihoodObject::Entry > const &  data,
float  eta,
float  pt,
float  rho,
int  qgIndex,
int  varIndex 
) const
private

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

Definition at line 34 of file QGLikelihoodCalculator.cc.

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

Referenced by computeQGLikelihood(), and ~QGLikelihoodCalculator().

34  {
35  QGLikelihoodParameters myParameters;
36  myParameters.Rho = rho;
37  myParameters.Pt = pt;
38  myParameters.Eta = fabs(eta);
39  myParameters.QGIndex = qgIndex;
40  myParameters.VarIndex = varIndex;
41 
42  auto myDataObject = data.begin();
43  while(!(myParameters == myDataObject->category)){
44  ++myDataObject;
45  if(myDataObject == data.end()){
46  edm::LogWarning("QGLCategoryNotFound") << "Jet passed qgValidRange criteria, but no category found with rho=" << rho << ", pt=" << pt << ", eta=" << eta
47  << "\nPlease contact cms-qg-workinggroup@cern.ch" << std::endl;
48  return nullptr;
49  }
50  }
51  return &*myDataObject;
52 }
Parameters structure.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool QGLikelihoodCalculator::isValidRange ( float  pt,
float  rho,
float  eta,
const QGLikelihoodCategory qgValidRange 
) const
private

Check the valid range of this qg tagger.

Definition at line 56 of file QGLikelihoodCalculator.cc.

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

Referenced by computeQGLikelihood(), and ~QGLikelihoodCalculator().

56  {
57  if(pt < qgValidRange.PtMin) return false;
58  if(pt > qgValidRange.PtMax) return false;
59  if(rho < qgValidRange.RhoMin) return false;
60  if(rho > qgValidRange.RhoMax) return false;
61  if(fabs(eta) < qgValidRange.EtaMin) return false;
62  if(fabs(eta) > qgValidRange.EtaMax) return false;
63  return true;
64 }
float QGLikelihoodCalculator::smearingFunction ( float  x0,
float  a,
float  b,
float  min,
float  max 
) const
private

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

Definition at line 68 of file QGLikelihoodCalculator.cc.

References min(), and x().

Referenced by systematicSmearing(), and ~QGLikelihoodCalculator().

68  {
69  float x=(x0-min)/(max-min);
70  if(x<0.) x=0.;
71  if(x>1.) x=1.;
72 
73  float x1= tanh(a*atanh(2.*x-1.)+b)/2.+.5;
74  if(x<=0.) x1=0.;
75  if(x>=1.) x1=1.;
76 
77  return x1*(max-min)+min;
78 }
T x() const
Cartesian x coordinate.
T min(T a, T b)
Definition: MathUtil.h:58
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
float QGLikelihoodCalculator::systematicSmearing ( edm::ESHandle< QGLikelihoodSystematicsObject > &  QGLParamsColl,
float  pt,
float  eta,
float  rho,
float  qgValue,
int  qgIndex 
) const

Definition at line 81 of file QGLikelihoodCalculator.cc.

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

Referenced by QGTagger::produce(), and ~QGLikelihoodCalculator().

81  {
82  if(qgValue < 0 || qgValue > 1) return -1.;
83 
84  QGLikelihoodParameters myParameters;
85  myParameters.Rho = rho;
86  myParameters.Pt = pt;
87  myParameters.Eta = fabs(eta);
88  myParameters.QGIndex = qgIndex;
89  myParameters.VarIndex = -1;
90 
91  auto myDataObject = QGLSystematicsColl->data.begin();
92  while(!(myParameters == myDataObject->systCategory)){
93  ++myDataObject;
94  if(myDataObject == QGLSystematicsColl->data.end()) return -1; //Smearing not available in the whole qgValidRange: do not throw warnings or errors
95  }
96  return smearingFunction(qgValue, myDataObject->a, myDataObject->b, myDataObject->lmin, myDataObject->lmax);
97 }
Parameters structure.
float smearingFunction(float x0, float a, float b, float min, float max) const
Return the smeared qgLikelihood value, given input x0 and parameters a, b, min and max...