CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SuepShower Class Reference

#include <SuepShower.h>

Public Member Functions

std::vector< Pythia8::Vec4generateShower (double energy)
 
 SuepShower (double mass, double temperature, Pythia8::Rndm *rndmPtr)
 
 ~SuepShower ()
 

Private Member Functions

const double fMaxwellBoltzmann (double p)
 
const double fMaxwellBoltzmannPrime (double p)
 
const Pythia8::Vec4 generateFourVector ()
 
const double logTestFunction (double p)
 
const double reballanceFunction (double scale, const std::vector< Pythia8::Vec4 > &shower)
 

Private Attributes

double darkmeson_mass_
 
Pythia8::Rndm * fRndmPtr_
 
double lambda_minus_
 
double lambda_plus_
 
double mass_over_T_
 
double mediator_energy_
 
double p_m_
 
double p_minus_
 
double p_plus_
 
double q_m_
 
double q_minus_
 
double q_plus_
 
boost::math::tools::eps_tolerance< double > tolerance_
 

Detailed Description

Definition at line 12 of file SuepShower.h.

Constructor & Destructor Documentation

SuepShower::SuepShower ( double  mass,
double  temperature,
Pythia8::Rndm *  rndmPtr 
)

Definition at line 18 of file SuepShower.cc.

References darkmeson_mass_, plotBeamSpotDB::first, fMaxwellBoltzmann(), fMaxwellBoltzmannPrime(), fRndmPtr_, lambda_minus_, lambda_plus_, logTestFunction(), ResonanceBuilder::mass, mass_over_T_, p_m_, p_minus_, p_plus_, q_m_, q_minus_, q_plus_, mathSSE::sqrt(), jvcParameters_cfi::temperature, and tolerance_.

18  {
19  edm::LogInfo("Pythia8Interface") << "Creating a SuepShower module";
20  // Parameter setup
22  fRndmPtr_ = rndmPtr;
23  // No need to save temperature, as everything depends on it through m/T
25 
26  // 128 bit numerical precision, i.e. take machine precision
27  tolerance_ = boost::math::tools::eps_tolerance<double>(128);
28 
29  // Median momentum
30  p_m_ = sqrt(2 / (mass_over_T_ * mass_over_T_) * (1 + sqrt(1 + mass_over_T_ * mass_over_T_)));
31  double pmax = sqrt(2 + 2 * sqrt(1 + mass_over_T_ * mass_over_T_)) / mass_over_T_;
32  // Find the two cases where f(p)/f(pmax) = 1/e, given MB distribution, one appears at each side of pmax always
33  p_plus_ = (boost::math::tools::bisect(
34  boost::bind(&SuepShower::logTestFunction, this, boost::placeholders::_1), pmax, 50.0, tolerance_))
35  .first; // first root
36  p_minus_ = (boost::math::tools::bisect(
37  boost::bind(&SuepShower::logTestFunction, this, boost::placeholders::_1), 0.0, pmax, tolerance_))
38  .first; // second root
39  // Define the auxiliar quantities for the random generation of momenta
44  q_m_ = 1 - (q_plus_ + q_minus_);
45 }
double darkmeson_mass_
Definition: SuepShower.h:26
Pythia8::Rndm * fRndmPtr_
Definition: SuepShower.h:46
double p_m_
Definition: SuepShower.h:37
double mass_over_T_
Definition: SuepShower.h:27
double lambda_plus_
Definition: SuepShower.h:41
boost::math::tools::eps_tolerance< double > tolerance_
Definition: SuepShower.h:33
T sqrt(T t)
Definition: SSEVec.h:18
double q_plus_
Definition: SuepShower.h:43
double p_plus_
Definition: SuepShower.h:39
const double fMaxwellBoltzmannPrime(double p)
Definition: SuepShower.cc:98
const double logTestFunction(double p)
Definition: SuepShower.cc:103
double q_minus_
Definition: SuepShower.h:43
double p_minus_
Definition: SuepShower.h:39
double q_m_
Definition: SuepShower.h:43
double lambda_minus_
Definition: SuepShower.h:41
const double fMaxwellBoltzmann(double p)
Definition: SuepShower.cc:93
SuepShower::~SuepShower ( )

Definition at line 47 of file SuepShower.cc.

47 {}

Member Function Documentation

const double SuepShower::fMaxwellBoltzmann ( double  p)
private

Definition at line 93 of file SuepShower.cc.

References JetChargeProducer_cfi::exp, mass_over_T_, and mathSSE::sqrt().

Referenced by generateFourVector(), logTestFunction(), and SuepShower().

93  {
94  return p * p * exp(-mass_over_T_ * p * p / (1 + sqrt(1 + p * p)));
95 }
double mass_over_T_
Definition: SuepShower.h:27
T sqrt(T t)
Definition: SSEVec.h:18
const double SuepShower::fMaxwellBoltzmannPrime ( double  p)
private

Definition at line 98 of file SuepShower.cc.

References JetChargeProducer_cfi::exp, mass_over_T_, and mathSSE::sqrt().

Referenced by SuepShower().

98  {
99  return exp(-mass_over_T_ * p * p / (1 + sqrt(1 + p * p))) * p * (2 - mass_over_T_ * p * p / sqrt(1 + p * p));
100 }
double mass_over_T_
Definition: SuepShower.h:27
T sqrt(T t)
Definition: SSEVec.h:18
const Pythia8::Vec4 SuepShower::generateFourVector ( )
private

Definition at line 106 of file SuepShower.cc.

References funct::cos(), darkmeson_mass_, JetChargeProducer_cfi::exp, fMaxwellBoltzmann(), fRndmPtr_, mps_fire::i, lambda_minus_, lambda_plus_, cmsBatch::log, M_PI, p_m_, p_minus_, p_plus_, phi, q_m_, q_minus_, q_plus_, funct::sin(), mathSSE::sqrt(), theta(), mitigatedMETSequence_cff::U, X, and DOFs::Y.

Referenced by generateShower().

106  {
107  double en, phi, theta, momentum; //kinematic variables of the 4 std::vector
108 
109  // First do momentum, following naming of arxiv:1305.5226
110  double U, V, X, Y, E;
111  int i = 0;
112  while (i < 100) {
113  // Very rarely (<1e-5 events) takes more than one loop to converge, set to 100 for safety
114  U = fRndmPtr_->flat();
115  V = fRndmPtr_->flat();
116 
117  if (U < q_m_) {
118  Y = U / q_m_;
119  X = (1 - Y) * (p_minus_ + lambda_minus_) + Y * (p_plus_ - lambda_plus_);
120  if (V < fMaxwellBoltzmann(X) / fMaxwellBoltzmann(p_m_) && X > 0) {
121  break;
122  }
123  } else {
124  if (U < q_m_ + q_plus_) {
125  E = -log((U - q_m_) / q_plus_);
126  X = p_plus_ - lambda_plus_ * (1 - E);
127  if (V < exp(E) * fMaxwellBoltzmann(X) / fMaxwellBoltzmann(p_m_) && X > 0) {
128  break;
129  }
130  } else {
131  E = -log((U - (q_m_ + q_plus_)) / q_minus_);
132  X = p_minus_ + lambda_minus_ * (1 - E);
133  if (V < exp(E) * fMaxwellBoltzmann(X) / fMaxwellBoltzmann(p_m_) && X > 0) {
134  break;
135  }
136  }
137  }
138  }
139  // X is the dimensionless momentum, p/m
140  momentum = X * darkmeson_mass_;
141 
142  // now do the angles, isotropic
143  phi = 2.0 * M_PI * (fRndmPtr_->flat());
144  theta = acos(2.0 * (fRndmPtr_->flat()) - 1.0);
145 
146  // compose the 4 std::vector
147  en = sqrt(momentum * momentum + darkmeson_mass_ * darkmeson_mass_);
148  Pythia8::Vec4 daughterFourMomentum =
149  Pythia8::Vec4(momentum * cos(phi) * sin(theta), momentum * sin(phi) * sin(theta), momentum * sin(theta), en);
150  return daughterFourMomentum;
151 }
double darkmeson_mass_
Definition: SuepShower.h:26
ExtVec< T, 4 > Vec4
Definition: ExtVec.h:62
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
#define X(str)
Definition: MuonsGrabber.cc:48
Pythia8::Rndm * fRndmPtr_
Definition: SuepShower.h:46
double p_m_
Definition: SuepShower.h:37
double lambda_plus_
Definition: SuepShower.h:41
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double q_plus_
Definition: SuepShower.h:43
double p_plus_
Definition: SuepShower.h:39
#define M_PI
double q_minus_
Definition: SuepShower.h:43
double p_minus_
Definition: SuepShower.h:39
double q_m_
Definition: SuepShower.h:43
double lambda_minus_
Definition: SuepShower.h:41
const double fMaxwellBoltzmann(double p)
Definition: SuepShower.cc:93
std::vector< Pythia8::Vec4 > SuepShower::generateShower ( double  energy)

Definition at line 50 of file SuepShower.cc.

References darkmeson_mass_, MillePedeFileConverter_cfg::e, plotBeamSpotDB::first, generateFourVector(), mediator_energy_, reballanceFunction(), Scenarios_cff::scale, mathSSE::sqrt(), and tolerance_.

50  {
51  mediator_energy_ = energy;
52  std::vector<Pythia8::Vec4> shower;
53  double shower_energy = 0.0;
54 
55  // Fill up shower record
56  while (shower_energy < mediator_energy_) {
57  shower.push_back(generateFourVector());
58  shower_energy += (shower.back()).e();
59  }
60 
61  // Reballance momenta to ensure conservation
62  // Correction starts at 0
63  Pythia8::Vec4 correction = Pythia8::Vec4(0., 0., 0., 0.);
64  for (const auto& daughter : shower) {
65  correction = correction + daughter;
66  }
67  correction = correction / shower.size();
68  // We only want to correct momenta first
69  correction.e(0);
70  for (auto& daughter : shower) {
71  daughter = daughter - correction;
72  }
73 
74  // With momentum conserved, balance energy. scale is the multiplicative factor needed such that sum_daughters((scale*p)^2+m^2) = E_parent, i.e. energy is conserved
75  double scale;
76  scale =
77  (boost::math::tools::bisect(
78  boost::bind(&SuepShower::reballanceFunction, this, boost::placeholders::_1, shower), 0.0, 2.0, tolerance_))
79  .first;
80 
81  for (auto& daughter : shower) {
82  daughter.px(daughter.px() * scale);
83  daughter.py(daughter.py() * scale);
84  daughter.pz(daughter.pz() * scale);
85  // Force everything to be on-shell
86  daughter.e(sqrt(daughter.pAbs2() + darkmeson_mass_ * darkmeson_mass_));
87  }
88  return shower;
89 }
double darkmeson_mass_
Definition: SuepShower.h:26
const double reballanceFunction(double scale, const std::vector< Pythia8::Vec4 > &shower)
Definition: SuepShower.cc:156
ExtVec< T, 4 > Vec4
Definition: ExtVec.h:62
boost::math::tools::eps_tolerance< double > tolerance_
Definition: SuepShower.h:33
T sqrt(T t)
Definition: SSEVec.h:18
const Pythia8::Vec4 generateFourVector()
Definition: SuepShower.cc:106
double mediator_energy_
Definition: SuepShower.h:30
const double SuepShower::logTestFunction ( double  p)
private

Definition at line 103 of file SuepShower.cc.

References fMaxwellBoltzmann(), cmsBatch::log, and p_m_.

Referenced by SuepShower().

103 { return log(fMaxwellBoltzmann(p) / fMaxwellBoltzmann(p_m_)) + 1.0; }
double p_m_
Definition: SuepShower.h:37
const double fMaxwellBoltzmann(double p)
Definition: SuepShower.cc:93
const double SuepShower::reballanceFunction ( double  scale,
const std::vector< Pythia8::Vec4 > &  shower 
)
private

Definition at line 156 of file SuepShower.cc.

References darkmeson_mass_, mediator_energy_, and mathSSE::sqrt().

Referenced by generateShower().

156  {
157  double showerEnergy = 0.0;
158  for (const auto& daughter : shower) {
159  showerEnergy += sqrt(scale * scale * daughter.pAbs2() + darkmeson_mass_ * darkmeson_mass_);
160  }
161  return showerEnergy - mediator_energy_;
162 }
double darkmeson_mass_
Definition: SuepShower.h:26
T sqrt(T t)
Definition: SSEVec.h:18
double mediator_energy_
Definition: SuepShower.h:30

Member Data Documentation

double SuepShower::darkmeson_mass_
private

Definition at line 26 of file SuepShower.h.

Referenced by generateFourVector(), generateShower(), reballanceFunction(), and SuepShower().

Pythia8::Rndm* SuepShower::fRndmPtr_
private

Definition at line 46 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::lambda_minus_
private

Definition at line 41 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::lambda_plus_
private

Definition at line 41 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::mass_over_T_
private

Definition at line 27 of file SuepShower.h.

Referenced by fMaxwellBoltzmann(), fMaxwellBoltzmannPrime(), and SuepShower().

double SuepShower::mediator_energy_
private

Definition at line 30 of file SuepShower.h.

Referenced by generateShower(), and reballanceFunction().

double SuepShower::p_m_
private

Definition at line 37 of file SuepShower.h.

Referenced by generateFourVector(), logTestFunction(), and SuepShower().

double SuepShower::p_minus_
private

Definition at line 39 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::p_plus_
private

Definition at line 39 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::q_m_
private

Definition at line 43 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::q_minus_
private

Definition at line 43 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

double SuepShower::q_plus_
private

Definition at line 43 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

boost::math::tools::eps_tolerance<double> SuepShower::tolerance_
private

Definition at line 33 of file SuepShower.h.

Referenced by generateShower(), and SuepShower().