CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
6  public:
7  PtHatReweightUserHook(double _pt = 15, double _power = 4.5) :
8  pt(_pt), power(_power) {}
9  virtual ~PtHatReweightUserHook() {}
10 
11  virtual bool canBiasSelection() { return true; }
12 
13  virtual double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
14  const Pythia8::PhaseSpace* phaseSpacePtr, bool inEvent)
15  {
16  //the variable selBias of the base class should be used;
17  if ((sigmaProcessPtr->nFinal() == 2)) {
18  selBias = pow(phaseSpacePtr->pTHat() / pt, power);
19  return selBias;
20  }
21  selBias = 1.;
22  return selBias;
23  }
24 
25  private:
26  double pt, power;
27 };
28 
29 
30 class RapReweightUserHook : public Pythia8::UserHooks
31 {
32  public:
33  RapReweightUserHook(const std::string& _yLabsigma_func, double _yLab_power,
34  const std::string& _yCMsigma_func, double _yCM_power,
35  double _pTHatMin, double _pTHatMax) :
36  yLabsigma_func(_yLabsigma_func), yCMsigma_func(_yCMsigma_func),
37  yLab_power(_yLab_power), yCM_power(_yCM_power),
38  pTHatMin(_pTHatMin), pTHatMax(_pTHatMax)
39  {
40  // empirical parametrizations defined in configuration file
41  yLabsigma = TF1("yLabsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
42  yCMsigma = TF1("yCMsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
43  }
44  virtual ~RapReweightUserHook() {}
45 
46  virtual bool canBiasSelection() { return true; }
47 
48  virtual double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
49  const Pythia8::PhaseSpace* phaseSpacePtr, bool inEvent)
50  {
51  //the variable selBias of the base class should be used;
52  if ((sigmaProcessPtr->nFinal() == 2)) {
53  double x1 = phaseSpacePtr->x1();
54  double x2 = phaseSpacePtr->x2();
55  double yLab = 0.5*log(x1/x2);
56  double yCM = 0.5*log( phaseSpacePtr->tHat() / phaseSpacePtr->uHat() );
57  double pTHat = phaseSpacePtr->pTHat();
58  double sigmaLab = yLabsigma.Eval(pTHat);
59  double sigmaCM = yCMsigma.Eval(pTHat);
60  // empirical reweighting function
61  selBias = exp( pow(fabs(yLab),yLab_power)/(2*sigmaLab*sigmaLab) +
62  pow(fabs(yCM),yCM_power)/(2*sigmaCM*sigmaCM) );
63  return selBias;
64  }
65  selBias = 1.;
66  return selBias;
67  }
68 
69  private:
73 };
74 
75 
76 class PtHatRapReweightUserHook : public Pythia8::UserHooks
77 {
78  public:
79  PtHatRapReweightUserHook(const std::string& _yLabsigma_func, double _yLab_power,
80  const std::string& _yCMsigma_func, double _yCM_power,
81  double _pTHatMin, double _pTHatMax,
82  double _pt = 15, double _power = 4.5) :
83  yLabsigma_func(_yLabsigma_func), yCMsigma_func(_yCMsigma_func),
84  yLab_power(_yLab_power), yCM_power(_yCM_power),
85  pTHatMin(_pTHatMin), pTHatMax(_pTHatMax), pt(_pt), power(_power)
86  {
87  // empirical parametrizations defined in configuration file
88  yLabsigma = TF1("yLabsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
89  yCMsigma = TF1("yCMsigma", yLabsigma_func.c_str(), pTHatMin, pTHatMax);
90  }
92 
93  virtual bool canBiasSelection() { return true; }
94 
95  virtual double biasSelectionBy(const Pythia8::SigmaProcess* sigmaProcessPtr,
96  const Pythia8::PhaseSpace* phaseSpacePtr, bool inEvent)
97  {
98  //the variable selBias of the base class should be used;
99  if ((sigmaProcessPtr->nFinal() == 2)) {
100  double x1 = phaseSpacePtr->x1();
101  double x2 = phaseSpacePtr->x2();
102  double yLab = 0.5*log(x1/x2);
103  double yCM = 0.5*log( phaseSpacePtr->tHat() / phaseSpacePtr->uHat() );
104  double pTHat = phaseSpacePtr->pTHat();
105  double sigmaLab = yLabsigma.Eval(pTHat);
106  double sigmaCM = yCMsigma.Eval(pTHat);
107  // empirical reweighting function
108  selBias = pow(pTHat / pt, power) * exp( pow(fabs(yLab),yLab_power)/(2*sigmaLab*sigmaLab) +
109  pow(fabs(yCM),yCM_power)/(2*sigmaCM*sigmaCM) );
110  return selBias;
111  }
112  selBias = 1.;
113  return selBias;
114  }
115 
116  private:
120 };
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)
virtual double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent)
virtual ~PtHatReweightUserHook()
virtual bool canBiasSelection()
PtHatReweightUserHook(double _pt=15, double _power=4.5)
virtual double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent)
std::string yLabsigma_func
virtual ~RapReweightUserHook()
virtual bool canBiasSelection()
RapReweightUserHook(const std::string &_yLabsigma_func, double _yLab_power, const std::string &_yCMsigma_func, double _yCM_power, double _pTHatMin, double _pTHatMax)
virtual bool canBiasSelection()
virtual double biasSelectionBy(const Pythia8::SigmaProcess *sigmaProcessPtr, const Pythia8::PhaseSpace *phaseSpacePtr, bool inEvent)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
tuple log
Definition: cmsBatch.py:347