CMS 3D CMS Logo

ReweightUserHooks.h
Go to the documentation of this file.
1 #include "Pythia8/Pythia.h"
2 #include "TF1.h"
3 
4 class PtHatReweightUserHook : public Pythia8::UserHooks {
5 public:
6  PtHatReweightUserHook(double _pt = 15, double _power = 4.5) : pt(_pt), power(_power) {}
7  ~PtHatReweightUserHook() override {}
8 
9  bool canBiasSelection() override { return true; }
10 
11  double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
12  const Pythia8::PhaseSpace* phaseSpacePtr,
13  bool inEvent) override {
14  //the variable selBias of the base class should be used;
15  if ((sigmaProcessPtr->nFinal() == 2)) {
16  selBias = pow(phaseSpacePtr->pTHat() / pt, power);
17  return selBias;
18  }
19  selBias = 1.;
20  return selBias;
21  }
22 
23 private:
24  double pt, power;
25 };
26 
27 class PtHatEmpReweightUserHook : public Pythia8::UserHooks {
28 public:
29  PtHatEmpReweightUserHook(const std::string& tuneName = "") {
30  if (tuneName == "CP5")
31  p = {7377.94700788, 8.38168461349, -4.70983112392, -0.0310148108446, -0.028798537937, 925.335472326};
32  //Default reweighting - works good for tune CUEPT8M1
33  else
34  p = {5.3571961909810e+13,
35  1.0907678218282e+01,
36  -2.5898069229451e+00,
37  -5.1575514014931e-01,
38  5.5951279807561e-02,
39  3.5e+02};
40  sigma = [this](double x) -> double {
41  return (p[0] * pow(x, p[2] + p[3] * log(0.01 * x) + p[4] * pow(log(0.01 * x), 2)) *
42  pow(1 - 2 * x / (13000. + p[5]), p[1])) *
43  x;
44  };
45  }
47 
48  bool canBiasSelection() override { return true; }
49 
50  double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
51  const Pythia8::PhaseSpace* phaseSpacePtr,
52  bool inEvent) override {
53  //the variable selBias of the base class should be used;
54  if ((sigmaProcessPtr->nFinal() == 2)) {
55  selBias = 1.0 / sigma(phaseSpacePtr->pTHat());
56  return selBias;
57  }
58  selBias = 1.;
59  return selBias;
60  }
61 
62 private:
63  std::vector<double> p;
64  std::function<double(double)> sigma;
65 };
66 
67 class RapReweightUserHook : public Pythia8::UserHooks {
68 public:
69  RapReweightUserHook(const std::string& _yLabsigma_func,
70  double _yLab_power,
71  const std::string& _yCMsigma_func,
72  double _yCM_power,
73  double _pTHatMin,
74  double _pTHatMax)
75  : yLabsigma_func(_yLabsigma_func),
76  yCMsigma_func(_yCMsigma_func),
77  yLab_power(_yLab_power),
78  yCM_power(_yCM_power),
79  pTHatMin(_pTHatMin),
80  pTHatMax(_pTHatMax) {
81  // empirical parametrizations defined in configuration file
82  yLabsigma = TF1("yLabsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
83  yCMsigma = TF1("yCMsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
84  }
85  ~RapReweightUserHook() override {}
86 
87  bool canBiasSelection() override { return true; }
88 
89  double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
90  const Pythia8::PhaseSpace* phaseSpacePtr,
91  bool inEvent) override {
92  //the variable selBias of the base class should be used;
93  if ((sigmaProcessPtr->nFinal() == 2)) {
94  double x1 = phaseSpacePtr->x1();
95  double x2 = phaseSpacePtr->x2();
96  double yLab = 0.5 * log(x1 / x2);
97  double yCM = 0.5 * log(phaseSpacePtr->tHat() / phaseSpacePtr->uHat());
98  double pTHat = phaseSpacePtr->pTHat();
99  double sigmaLab = yLabsigma.Eval(pTHat);
100  double sigmaCM = yCMsigma.Eval(pTHat);
101  // empirical reweighting function
102  selBias = exp(pow(fabs(yLab), yLab_power) / (2 * sigmaLab * sigmaLab) +
103  pow(fabs(yCM), yCM_power) / (2 * sigmaCM * sigmaCM));
104  return selBias;
105  }
106  selBias = 1.;
107  return selBias;
108  }
109 
110 private:
114 };
115 
116 class PtHatRapReweightUserHook : public Pythia8::UserHooks {
117 public:
118  PtHatRapReweightUserHook(const std::string& _yLabsigma_func,
119  double _yLab_power,
120  const std::string& _yCMsigma_func,
121  double _yCM_power,
122  double _pTHatMin,
123  double _pTHatMax,
124  double _pt = 15,
125  double _power = 4.5)
126  : yLabsigma_func(_yLabsigma_func),
127  yCMsigma_func(_yCMsigma_func),
128  yLab_power(_yLab_power),
129  yCM_power(_yCM_power),
130  pTHatMin(_pTHatMin),
131  pTHatMax(_pTHatMax),
132  pt(_pt),
133  power(_power) {
134  // empirical parametrizations defined in configuration file
135  yLabsigma = TF1("yLabsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
136  yCMsigma = TF1("yCMsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
137  }
139 
140  bool canBiasSelection() override { return true; }
141 
142  double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
143  const Pythia8::PhaseSpace* phaseSpacePtr,
144  bool inEvent) override {
145  //the variable selBias of the base class should be used;
146  if ((sigmaProcessPtr->nFinal() == 2)) {
147  double x1 = phaseSpacePtr->x1();
148  double x2 = phaseSpacePtr->x2();
149  double yLab = 0.5 * log(x1 / x2);
150  double yCM = 0.5 * log(phaseSpacePtr->tHat() / phaseSpacePtr->uHat());
151  double pTHat = phaseSpacePtr->pTHat();
152  double sigmaLab = yLabsigma.Eval(pTHat);
153  double sigmaCM = yCMsigma.Eval(pTHat);
154  // empirical reweighting function
155  selBias = pow(pTHat / pt, power) * exp(pow(fabs(yLab), yLab_power) / (2 * sigmaLab * sigmaLab) +
156  pow(fabs(yCM), yCM_power) / (2 * sigmaCM * sigmaCM));
157  return selBias;
158  }
159  selBias = 1.;
160  return selBias;
161  }
162 
163 private:
167 };
PtHatRapReweightUserHook::~PtHatRapReweightUserHook
~PtHatRapReweightUserHook() override
Definition: ReweightUserHooks.h:138
PtHatRapReweightUserHook::canBiasSelection
bool canBiasSelection() override
Definition: ReweightUserHooks.h:140
PtHatEmpReweightUserHook::~PtHatEmpReweightUserHook
~PtHatEmpReweightUserHook() override
Definition: ReweightUserHooks.h:46
RapReweightUserHook::yCMsigma_func
std::string yCMsigma_func
Definition: ReweightUserHooks.h:111
PtHatReweightUserHook::power
double power
Definition: ReweightUserHooks.h:24
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
PtHatReweightUserHook::pt
double pt
Definition: ReweightUserHooks.h:24
PtHatRapReweightUserHook::yCM_power
double yCM_power
Definition: ReweightUserHooks.h:165
PtHatRapReweightUserHook::pt
double pt
Definition: ReweightUserHooks.h:165
DDAxes::x
PtHatReweightUserHook::PtHatReweightUserHook
PtHatReweightUserHook(double _pt=15, double _power=4.5)
Definition: ReweightUserHooks.h:6
tools.TF1
TF1
Definition: tools.py:23
PtHatReweightUserHook::biasSelectionBy
double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent) override
Definition: ReweightUserHooks.h:11
RapReweightUserHook::~RapReweightUserHook
~RapReweightUserHook() override
Definition: ReweightUserHooks.h:85
RapReweightUserHook::RapReweightUserHook
RapReweightUserHook(const std::string &_yLabsigma_func, double _yLab_power, const std::string &_yCMsigma_func, double _yCM_power, double _pTHatMin, double _pTHatMax)
Definition: ReweightUserHooks.h:69
RapReweightUserHook::biasSelectionBy
double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent) override
Definition: ReweightUserHooks.h:89
RapReweightUserHook::yCMsigma
TF1 yCMsigma
Definition: ReweightUserHooks.h:113
PtHatRapReweightUserHook::power
double power
Definition: ReweightUserHooks.h:165
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
PtHatRapReweightUserHook::yLabsigma_func
std::string yLabsigma_func
Definition: ReweightUserHooks.h:164
PtHatReweightUserHook::canBiasSelection
bool canBiasSelection() override
Definition: ReweightUserHooks.h:9
RapReweightUserHook::yCM_power
double yCM_power
Definition: ReweightUserHooks.h:112
PtHatEmpReweightUserHook
Definition: ReweightUserHooks.h:27
PtHatRapReweightUserHook::yLabsigma
TF1 yLabsigma
Definition: ReweightUserHooks.h:166
PtHatEmpReweightUserHook::sigma
std::function< double(double)> sigma
Definition: ReweightUserHooks.h:64
PtHatEmpReweightUserHook::canBiasSelection
bool canBiasSelection() override
Definition: ReweightUserHooks.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PtHatRapReweightUserHook::pTHatMax
double pTHatMax
Definition: ReweightUserHooks.h:165
RapReweightUserHook::yLabsigma_func
std::string yLabsigma_func
Definition: ReweightUserHooks.h:111
RapReweightUserHook::canBiasSelection
bool canBiasSelection() override
Definition: ReweightUserHooks.h:87
PtHatRapReweightUserHook
Definition: ReweightUserHooks.h:116
PtHatRapReweightUserHook::PtHatRapReweightUserHook
PtHatRapReweightUserHook(const std::string &_yLabsigma_func, double _yLab_power, const std::string &_yCMsigma_func, double _yCM_power, double _pTHatMin, double _pTHatMax, double _pt=15, double _power=4.5)
Definition: ReweightUserHooks.h:118
PtHatEmpReweightUserHook::p
std::vector< double > p
Definition: ReweightUserHooks.h:63
PtHatEmpReweightUserHook::biasSelectionBy
double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent) override
Definition: ReweightUserHooks.h:50
PtHatRapReweightUserHook::yLab_power
double yLab_power
Definition: ReweightUserHooks.h:165
RapReweightUserHook
Definition: ReweightUserHooks.h:67
PtHatRapReweightUserHook::pTHatMin
double pTHatMin
Definition: ReweightUserHooks.h:165
PtHatRapReweightUserHook::biasSelectionBy
double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent) override
Definition: ReweightUserHooks.h:142
PtHatRapReweightUserHook::yCMsigma
TF1 yCMsigma
Definition: ReweightUserHooks.h:166
RapReweightUserHook::pTHatMax
double pTHatMax
Definition: ReweightUserHooks.h:112
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
PtHatEmpReweightUserHook::PtHatEmpReweightUserHook
PtHatEmpReweightUserHook(const std::string &tuneName="")
Definition: ReweightUserHooks.h:29
PtHatReweightUserHook
Definition: ReweightUserHooks.h:4
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
PtHatReweightUserHook::~PtHatReweightUserHook
~PtHatReweightUserHook() override
Definition: ReweightUserHooks.h:7
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
PtHatRapReweightUserHook::yCMsigma_func
std::string yCMsigma_func
Definition: ReweightUserHooks.h:164
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
RapReweightUserHook::pTHatMin
double pTHatMin
Definition: ReweightUserHooks.h:112
RapReweightUserHook::yLabsigma
TF1 yLabsigma
Definition: ReweightUserHooks.h:113
RapReweightUserHook::yLab_power
double yLab_power
Definition: ReweightUserHooks.h:112