ComPWA
Common Partial-Wave-Analysis Framework
PhspVolume.cpp
Go to the documentation of this file.
1 // Copyright (c) 2013, 2017 The ComPWA Team.
2 // This file is part of the ComPWA framework, check
3 // https://github.com/ComPWA/ComPWA/license.txt for details.
4 
5 #include "Physics/PhspVolume.hpp"
6 #include "Core/Exceptions.hpp"
7 #include <algorithm>
8 #include <cmath>
9 #include <numeric>
10 
11 namespace ComPWA {
12 namespace Physics {
13 
14 class IntegrationSample : public std::vector<double> {
15 public:
16  IntegrationSample(double lower, double upper, std::size_t SampleSize = 100);
17  const double BinSize;
18 };
19 
20 IntegrationSample::IntegrationSample(double lower, double upper,
21  std::size_t nvalues)
22  : BinSize{(upper - lower) / (nvalues - 1)} {
23  this->resize(nvalues);
24  double bin_size = BinSize;
25  double start_value = lower - BinSize;
26  std::generate(begin(), end(),
27  [&start_value, &bin_size] { return start_value += bin_size; });
28 }
29 
30 std::pair<double, double> SRange(double s, std::vector<double> &masses) {
31  std::pair<double, double> s_range = {0., std::sqrt(s)};
32  // * Compute s lower
33  for (std::size_t i = 0; i < masses.size() - 1; ++i)
34  s_range.first += masses[i];
35  s_range.first *= s_range.first; // squared
36  // * Compute s upper
37  s_range.second -= masses.back();
38  s_range.second *= s_range.second; // squared
39  return s_range;
40 }
41 
42 std::pair<double, double> PhspVolume(double s, std::vector<double> &masses,
43  std::size_t SampleSize) {
44  if (masses.size() == 2)
45  return std::make_pair(PhspVolumeTwoParticles(s, masses[0], masses[1]), 0.);
46  else {
47  if (masses.size() > 2) {
48  // * Create integration sample
49  auto s_range = SRange(s, masses);
50  auto sample =
51  IntegrationSample(s_range.first, s_range.second, SampleSize + 1);
52  // * Create profile vector of phasespace for N - 1 particles
55  std::vector<double> previousPhsp(sample.size() - 1);
56  auto masses_new = masses;
57  masses_new.pop_back();
58  double mNsq = masses.back() * masses.back();
59  for (std::size_t i = 1; i < sample.size(); ++i) { // don't include s' = 0
60  previousPhsp[i - 1] = std::sqrt(KallenFunction(s, sample[i], mNsq));
61  previousPhsp[i - 1] *=
62  PhspVolume(sample[i], masses_new, SampleSize).first;
63  previousPhsp[i - 1] *= sample.BinSize;
64  }
65  // * Integrate that profile vector
66  double volume =
67  std::accumulate(previousPhsp.begin(), previousPhsp.end(), 0.) * M_PI /
68  s;
69  return std::make_pair(volume, 0.);
70  } else {
72  "Cannot compute a phasespace for only one mass in final state");
73  }
74  }
75 }
76 
77 double PhspVolumeTwoParticles(double s, double m1, double m2) {
78  return (2 * M_PI) * std::sqrt(KallenFunction(s, m1 * m1, m2 * m2)) / s;
79 }
80 
81 double KallenFunction(double x, double y, double z) {
82  double result = x * x + y * y + z * z - 2 * x * y - 2 * y * z - 2 * z * x;
83  if (result < 0.)
84  return 0.;
85  else
86  return result;
87 }
88 
89 } // namespace Physics
90 } // namespace ComPWA
double PhspVolumeTwoParticles(double s, double m1, double m2)
Phase space element for a two particle decay.
Definition: PhspVolume.cpp:77
IntegrationSample(double lower, double upper, std::size_t SampleSize=100)
Definition: PhspVolume.cpp:20
ComPWA exceptions.
std::pair< double, double > SRange(double s, std::vector< double > &masses)
Definition: PhspVolume.cpp:30
double KallenFunction(double x, double y, double z)
Original Källén function, that is, not having square values in its argument.
Definition: PhspVolume.cpp:81
std::pair< double, double > PhspVolume(double s, std::vector< double > &masses, std::size_t SampleSize)
Compute phasespace volume of momentum space for an arbitrary number of particles in the final state u...
Definition: PhspVolume.cpp:42
void resize(DataSet &set, size_t size)
Definition: DataSet.hpp:22
Parameter out of bound.
Definition: Exceptions.hpp:149
Function to calculate the available phase space volume of arbitrary decays.
EventCollection generate(unsigned int NumberOfEvents, const ComPWA::Kinematics &Kinematics, const ComPWA::PhaseSpaceEventGenerator &Generator, ComPWA::Intensity &Intensity, ComPWA::UniformRealNumberGenerator &RandomGenerator)
Definition: Generate.cpp:95