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_, dqmdumpme::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:98
Log< level::Info, false > LogInfo
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::~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 98 of file SuepShower.cc.

References JetChargeProducer_cfi::exp, mass_over_T_, AlCaHLTBitMon_ParallelJobs::p, 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:19

◆ generateFourVector()

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_, 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().

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
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:93

◆ 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, dqmdumpme::first, generateFourVector(), mediator_energy_, reballanceFunction(), pfClustersFromCombinedCaloHF_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_) {
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
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:106
double mediator_energy_
Definition: SuepShower.h:30

◆ logTestFunction()

const double SuepShower::logTestFunction ( double  p)
private

Definition at line 103 of file SuepShower.cc.

References fMaxwellBoltzmann(), dqm-mbProfile::log, AlCaHLTBitMon_ParallelJobs::p, 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

◆ reballanceFunction()

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_, pfClustersFromCombinedCaloHF_cfi::scale, 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: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().