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::SuepShower ( double  mass,
double  temperature,
Pythia8::Rndm *  rndmPtr 
)

Definition at line 18 of file SuepShower.cc.

References darkmeson_mass_, first, fMaxwellBoltzmann(), fMaxwellBoltzmannPrime(), fRndmPtr_, lambda_minus_, lambda_plus_, logTestFunction(), EgHLTOffHistBins_cfi::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
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:19
double q_plus_
Definition: SuepShower.h:43
double p_plus_
Definition: SuepShower.h:39
const double fMaxwellBoltzmannPrime(double p)
Definition: SuepShower.cc:107
Log< level::Info, false > LogInfo
const double logTestFunction(double p)
Definition: SuepShower.cc:112
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:102

◆ ~SuepShower()

SuepShower::~SuepShower ( )

Definition at line 47 of file SuepShower.cc.

47 {}

Member Function Documentation

◆ fMaxwellBoltzmann()

const double SuepShower::fMaxwellBoltzmann ( double  p)
private

◆ fMaxwellBoltzmannPrime()

const double SuepShower::fMaxwellBoltzmannPrime ( double  p)
private

Definition at line 107 of file SuepShower.cc.

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

Referenced by SuepShower().

107  {
108  return exp(-mass_over_T_ * p * p / (1 + sqrt(1 + p * p))) * p * (2 - mass_over_T_ * p * p / sqrt(1 + p * p));
109 }
double mass_over_T_
Definition: SuepShower.h:27
T sqrt(T t)
Definition: SSEVec.h:19

◆ generateFourVector()

const Pythia8::Vec4 SuepShower::generateFourVector ( )
private

Definition at line 115 of file SuepShower.cc.

References funct::cos(), darkmeson_mass_, JetChargeProducer_cfi::exp, fMaxwellBoltzmann(), fRndmPtr_, mps_fire::i, lambda_minus_, lambda_plus_, dqm-mbProfile::log, M_PI, p_m_, p_minus_, p_plus_, phi, q_m_, q_minus_, q_plus_, funct::sin(), mathSSE::sqrt(), theta(), mitigatedMETSequence_cff::U, cms::cuda::V, X, and BeamSpotPI::Y.

Referenced by generateShower().

115  {
116  double en, phi, theta, momentum; //kinematic variables of the 4 std::vector
117 
118  // First do momentum, following naming of arxiv:1305.5226
119  double U, V, X, Y, E;
120  int i = 0;
121  while (i < 100) {
122  // Very rarely (<1e-5 events) takes more than one loop to converge, set to 100 for safety
123  U = fRndmPtr_->flat();
124  V = fRndmPtr_->flat();
125 
126  if (U < q_m_) {
127  Y = U / q_m_;
128  X = (1 - Y) * (p_minus_ + lambda_minus_) + Y * (p_plus_ - lambda_plus_);
129  if (V < fMaxwellBoltzmann(X) / fMaxwellBoltzmann(p_m_) && X > 0) {
130  break;
131  }
132  } else {
133  if (U < q_m_ + q_plus_) {
134  E = -log((U - q_m_) / q_plus_);
135  X = p_plus_ - lambda_plus_ * (1 - E);
136  if (V < exp(E) * fMaxwellBoltzmann(X) / fMaxwellBoltzmann(p_m_) && X > 0) {
137  break;
138  }
139  } else {
140  E = -log((U - (q_m_ + q_plus_)) / q_minus_);
141  X = p_minus_ + lambda_minus_ * (1 - E);
142  if (V < exp(E) * fMaxwellBoltzmann(X) / fMaxwellBoltzmann(p_m_) && X > 0) {
143  break;
144  }
145  }
146  }
147  }
148  // X is the dimensionless momentum, p/m
149  momentum = X * darkmeson_mass_;
150 
151  // now do the angles, isotropic
152  phi = 2.0 * M_PI * (fRndmPtr_->flat());
153  theta = acos(2.0 * (fRndmPtr_->flat()) - 1.0);
154 
155  // compose the 4 std::vector
156  en = sqrt(momentum * momentum + darkmeson_mass_ * darkmeson_mass_);
157  Pythia8::Vec4 daughterFourMomentum =
158  Pythia8::Vec4(momentum * cos(phi) * sin(theta), momentum * sin(phi) * sin(theta), momentum * sin(theta), en);
159  return daughterFourMomentum;
160 }
double darkmeson_mass_
Definition: SuepShower.h:26
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define X(str)
Definition: MuonsGrabber.cc:38
Pythia8::Rndm * fRndmPtr_
Definition: SuepShower.h:46
double p_m_
Definition: SuepShower.h:37
double lambda_plus_
Definition: SuepShower.h:41
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
T sqrt(T t)
Definition: SSEVec.h:19
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
ExtVec< T, 4 > Vec4
Definition: ExtVec.h:64
#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
Geom::Theta< T > theta() const
const double fMaxwellBoltzmann(double p)
Definition: SuepShower.cc:102

◆ generateShower()

std::vector< Pythia8::Vec4 > SuepShower::generateShower ( double  energy)

Definition at line 50 of file SuepShower.cc.

References pfMETCorrectionType0_cfi::correction, darkmeson_mass_, MillePedeFileConverter_cfg::e, HCALHighEnergyHPDFilter_cfi::energy, first, generateFourVector(), mediator_energy_, reballanceFunction(), L1EGammaClusterEmuProducer_cfi::scale, mathSSE::sqrt(), and tolerance_.

50  {
52  std::vector<Pythia8::Vec4> shower;
53  double shower_energy = 0.0;
54 
55  // Fill up shower record
56  while (shower_energy < mediator_energy_ || shower.size() < 2) {
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  double minscale = 0.0;
77  double maxscale = 2.0;
78  while (SuepShower::reballanceFunction(minscale, shower) * SuepShower::reballanceFunction(maxscale, shower) > 0) {
79  minscale = maxscale;
80  maxscale *= 2;
81  }
82 
83  scale =
84  (boost::math::tools::bisect(boost::bind(&SuepShower::reballanceFunction, this, boost::placeholders::_1, shower),
85  minscale,
86  maxscale,
87  tolerance_))
88  .first;
89 
90  for (auto& daughter : shower) {
91  daughter.px(daughter.px() * scale);
92  daughter.py(daughter.py() * scale);
93  daughter.pz(daughter.pz() * scale);
94  // Force everything to be on-shell
95  daughter.e(sqrt(daughter.pAbs2() + darkmeson_mass_ * darkmeson_mass_));
96  }
97  return shower;
98 }
double darkmeson_mass_
Definition: SuepShower.h:26
const double reballanceFunction(double scale, const std::vector< Pythia8::Vec4 > &shower)
Definition: SuepShower.cc:165
boost::math::tools::eps_tolerance< double > tolerance_
Definition: SuepShower.h:33
T sqrt(T t)
Definition: SSEVec.h:19
ExtVec< T, 4 > Vec4
Definition: ExtVec.h:64
const Pythia8::Vec4 generateFourVector()
Definition: SuepShower.cc:115
double mediator_energy_
Definition: SuepShower.h:30

◆ logTestFunction()

const double SuepShower::logTestFunction ( double  p)
private

Definition at line 112 of file SuepShower.cc.

References fMaxwellBoltzmann(), dqm-mbProfile::log, AlCaHLTBitMon_ParallelJobs::p, and p_m_.

Referenced by SuepShower().

112 { return log(fMaxwellBoltzmann(p) / fMaxwellBoltzmann(p_m_)) + 1.0; }
double p_m_
Definition: SuepShower.h:37
const double fMaxwellBoltzmann(double p)
Definition: SuepShower.cc:102

◆ reballanceFunction()

const double SuepShower::reballanceFunction ( double  scale,
const std::vector< Pythia8::Vec4 > &  shower 
)
private

Definition at line 165 of file SuepShower.cc.

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

Referenced by generateShower().

165  {
166  double showerEnergy = 0.0;
167  for (const auto& daughter : shower) {
168  showerEnergy += sqrt(scale * scale * daughter.pAbs2() + darkmeson_mass_ * darkmeson_mass_);
169  }
170  return showerEnergy - mediator_energy_;
171 }
double darkmeson_mass_
Definition: SuepShower.h:26
T sqrt(T t)
Definition: SSEVec.h:19
double mediator_energy_
Definition: SuepShower.h:30

Member Data Documentation

◆ darkmeson_mass_

double SuepShower::darkmeson_mass_
private

Definition at line 26 of file SuepShower.h.

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

◆ fRndmPtr_

Pythia8::Rndm* SuepShower::fRndmPtr_
private

Definition at line 46 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ lambda_minus_

double SuepShower::lambda_minus_
private

Definition at line 41 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ lambda_plus_

double SuepShower::lambda_plus_
private

Definition at line 41 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ mass_over_T_

double SuepShower::mass_over_T_
private

Definition at line 27 of file SuepShower.h.

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

◆ mediator_energy_

double SuepShower::mediator_energy_
private

Definition at line 30 of file SuepShower.h.

Referenced by generateShower(), and reballanceFunction().

◆ p_m_

double SuepShower::p_m_
private

Definition at line 37 of file SuepShower.h.

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

◆ p_minus_

double SuepShower::p_minus_
private

Definition at line 39 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ p_plus_

double SuepShower::p_plus_
private

Definition at line 39 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ q_m_

double SuepShower::q_m_
private

Definition at line 43 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ q_minus_

double SuepShower::q_minus_
private

Definition at line 43 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ q_plus_

double SuepShower::q_plus_
private

Definition at line 43 of file SuepShower.h.

Referenced by generateFourVector(), and SuepShower().

◆ tolerance_

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

Definition at line 33 of file SuepShower.h.

Referenced by generateShower(), and SuepShower().