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

◆ QGLikelihoodCalculator()

Definition at line 15 of file QGLikelihoodCalculator.h.

15 {};

◆ ~QGLikelihoodCalculator()

QGLikelihoodCalculator::~QGLikelihoodCalculator ( )
inline

Definition at line 16 of file QGLikelihoodCalculator.h.

16 {};

Member Function Documentation

◆ computeQGLikelihood()

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.

9  {
10  if (!isValidRange(pt, rho, eta, QGLParamsColl->qgValidRange))
11  return -1;
12 
13  float Q = 1., G = 1.;
14  for (unsigned int varIndex = 0; varIndex < vars.size(); ++varIndex) {
15  auto quarkEntry = findEntry(QGLParamsColl->data, eta, pt, rho, 0, varIndex);
16  auto gluonEntry = findEntry(QGLParamsColl->data, eta, pt, rho, 1, varIndex);
17  if (!quarkEntry || !gluonEntry)
18  return -2;
19 
20  int binQ = quarkEntry->histogram.findBin(vars[varIndex]);
21  float Qi = quarkEntry->histogram.binContent(binQ);
22 
23  int binG = gluonEntry->histogram.findBin(vars[varIndex]);
24  float Gi = gluonEntry->histogram.binContent(binG);
25 
26  Q *= Qi;
27  G *= Gi;
28  }
29 
30  if (Q == 0)
31  return 0;
32  return Q / (Q + G);
33 }

References QGLikelihoodObject::data, PVValHelper::eta, findEntry(), cmssw_cycle_finder::G, isValidRange(), DiDispStaMuonMonitor_cfi::pt, and QGLikelihoodObject::qgValidRange.

Referenced by QGTagger::produce().

◆ findEntry()

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 36 of file QGLikelihoodCalculator.cc.

41  {
43  myParameters.Rho = rho;
44  myParameters.Pt = pt;
45  myParameters.Eta = fabs(eta);
46  myParameters.QGIndex = qgIndex;
47  myParameters.VarIndex = varIndex;
48 
49  auto myDataObject = data.begin();
50  while (!(myParameters == myDataObject->category)) {
51  ++myDataObject;
52  if (myDataObject == data.end()) {
53  edm::LogWarning("QGLCategoryNotFound")
54  << "Jet passed qgValidRange criteria, but no category found with rho=" << rho << ", pt=" << pt
55  << ", eta=" << eta << "\nPlease contact cms-qg-workinggroup@cern.ch" << std::endl;
56  return nullptr;
57  }
58  }
59  return &*myDataObject;
60 }

References data, PVValHelper::eta, hydjet2DefaultParameters_cff::myParameters, and DiDispStaMuonMonitor_cfi::pt.

Referenced by computeQGLikelihood().

◆ isValidRange()

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 63 of file QGLikelihoodCalculator.cc.

66  {
67  if (pt < qgValidRange.PtMin)
68  return false;
69  if (pt > qgValidRange.PtMax)
70  return false;
71  if (rho < qgValidRange.RhoMin)
72  return false;
73  if (rho > qgValidRange.RhoMax)
74  return false;
75  if (fabs(eta) < qgValidRange.EtaMin)
76  return false;
77  if (fabs(eta) > qgValidRange.EtaMax)
78  return false;
79  return true;
80 }

References PVValHelper::eta, QGLikelihoodCategory::EtaMax, QGLikelihoodCategory::EtaMin, DiDispStaMuonMonitor_cfi::pt, QGLikelihoodCategory::PtMax, QGLikelihoodCategory::PtMin, QGLikelihoodCategory::RhoMax, and QGLikelihoodCategory::RhoMin.

Referenced by computeQGLikelihood().

◆ smearingFunction()

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 83 of file QGLikelihoodCalculator.cc.

83  {
84  float x = (x0 - min) / (max - min);
85  if (x < 0.)
86  x = 0.;
87  if (x > 1.)
88  x = 1.;
89 
90  float x1 = tanh(a * atanh(2. * x - 1.) + b) / 2. + .5;
91  if (x <= 0.)
92  x1 = 0.;
93  if (x >= 1.)
94  x1 = 1.;
95 
96  return x1 * (max - min) + min;
97 }

References a, b, SiStripPI::max, min(), and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by systematicSmearing().

◆ systematicSmearing()

float QGLikelihoodCalculator::systematicSmearing ( edm::ESHandle< QGLikelihoodSystematicsObject > &  QGLParamsColl,
float  pt,
float  eta,
float  rho,
float  qgValue,
int  qgIndex 
) const

Definition at line 100 of file QGLikelihoodCalculator.cc.

105  {
106  if (qgValue < 0 || qgValue > 1)
107  return -1.;
108 
110  myParameters.Rho = rho;
111  myParameters.Pt = pt;
112  myParameters.Eta = fabs(eta);
113  myParameters.QGIndex = qgIndex;
114  myParameters.VarIndex = -1;
115 
116  auto myDataObject = QGLSystematicsColl->data.begin();
117  while (!(myParameters == myDataObject->systCategory)) {
118  ++myDataObject;
119  if (myDataObject == QGLSystematicsColl->data.end())
120  return -1; //Smearing not available in the whole qgValidRange: do not throw warnings or errors
121  }
122  return smearingFunction(qgValue, myDataObject->a, myDataObject->b, myDataObject->lmin, myDataObject->lmax);
123 }

References QGLikelihoodSystematicsObject::data, PVValHelper::eta, hydjet2DefaultParameters_cff::myParameters, DiDispStaMuonMonitor_cfi::pt, and smearingFunction().

Referenced by QGTagger::produce().

QGLikelihoodObject::data
std::vector< Entry > data
Definition: QGLikelihoodObject.h:33
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
min
T min(T a, T b)
Definition: MathUtil.h:58
QGLikelihoodCategory::PtMin
float PtMin
Definition: QGLikelihoodObject.h:10
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
QGLikelihoodCalculator::isValidRange
bool isValidRange(float pt, float rho, float eta, const QGLikelihoodCategory &qgValidRange) const
Check the valid range of this qg tagger.
Definition: QGLikelihoodCalculator.cc:63
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
QGLikelihoodCategory::EtaMin
float EtaMin
Definition: QGLikelihoodObject.h:10
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
vars
vars
Definition: DeepTauId.cc:164
PVValHelper::eta
Definition: PVValidationHelpers.h:70
b
double b
Definition: hdecay.h:118
QGLikelihoodCategory::RhoMax
float RhoMax
Definition: QGLikelihoodObject.h:10
a
double a
Definition: hdecay.h:119
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
QGLikelihoodObject::qgValidRange
QGLikelihoodCategory qgValidRange
Definition: QGLikelihoodObject.h:32
QGLikelihoodCalculator::findEntry
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.
Definition: QGLikelihoodCalculator.cc:36
QGLikelihoodCategory::RhoMin
float RhoMin
Definition: QGLikelihoodObject.h:10
QGLikelihoodParameters
Parameters structure.
Definition: QGLikelihoodObject.h:16
genVertex_cff.x
x
Definition: genVertex_cff.py:13
QGLikelihoodCategory::EtaMax
float EtaMax
Definition: QGLikelihoodObject.h:10
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
hydjet2DefaultParameters_cff.myParameters
myParameters
Definition: hydjet2DefaultParameters_cff.py:354
QGLikelihoodCategory::PtMax
float PtMax
Definition: QGLikelihoodObject.h:10
QGLikelihoodCalculator::smearingFunction
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.
Definition: QGLikelihoodCalculator.cc:83
cmssw_cycle_finder.G
G
Definition: cmssw_cycle_finder.py:154