18 : RandomGenerator(seed), Seed(seed) {}
30 const std::vector<double> &FinalStateMasses_,
31 const std::vector<ComPWA::pid> &FinalStatePIDs_)
32 : CMSP4(CMSP4_), FinalStateMasses(FinalStateMasses_),
33 FinalStatePIDs(FinalStatePIDs_), CMSBoostVector(0.0, 0.0, 0.0) {
36 throw std::runtime_error(
37 "RootGenerator::RootGenerator() | one particle is not enough!");
40 <<
"RootGenerator::RootGenerator() | only 2 particles in the final" 41 " state! There are no degrees of freedom!";
47 std::vector<pid> InitialS, std::vector<pid> FinalS)
50 if (InitialS.size() != 1)
51 throw std::runtime_error(
52 "RootGenerator::RootGenerator() | More than one " 53 "particle in initial State! You need to specify a cms " 60 std::vector<double> fsm;
61 for (
auto ParticlePid : FinalS) {
62 fsm.push_back(
findParticle(PartL, ParticlePid).getMass().Value);
71 KinematicsInfo.getFinalStateMasses(),
72 KinematicsInfo.getFinalStatePIDs()) {}
81 throw std::runtime_error(
82 "RootGenerator::init(): not enough energy for this decay");
101 for (
unsigned int n = 1; n < FinalStateMasses.size(); ++n) {
102 emmin += FinalStateMasses[n - 1];
103 emmax += FinalStateMasses[n];
104 wtmax *=
PDK(emmax, emmin, FinalStateMasses[n]);
110 double w = W.Beta() / W.Rho();
120 for (
unsigned int iEvent = 0; iEvent < NumberOfEvents; ++iEvent) {
123 std::vector<double> OrderedRandomNumbers;
124 OrderedRandomNumbers.reserve(NumberOfFinalStateParticles);
125 OrderedRandomNumbers.push_back(0.0);
127 if (NumberOfFinalStateParticles > 2) {
128 for (
unsigned int n = 1; n < NumberOfFinalStateParticles - 1; ++n)
129 OrderedRandomNumbers.push_back(RandomGenerator());
130 std::sort(OrderedRandomNumbers.begin(), OrderedRandomNumbers.end());
132 OrderedRandomNumbers.push_back(1.0);
134 double invMas[NumberOfFinalStateParticles], sum = 0.0;
135 for (
unsigned int n = 0; n < NumberOfFinalStateParticles; ++n) {
142 double pd[NumberOfFinalStateParticles];
143 for (
unsigned int n = 0; n < NumberOfFinalStateParticles - 1; ++n) {
148 std::vector<TLorentzVector> FinalStateLorentzVectors(
152 FinalStateLorentzVectors[0].SetPxPyPzE(
158 FinalStateLorentzVectors[i].SetPxPyPzE(
159 0.0, -pd[i - 1], 0.0,
162 double cZ = 2.0 * RandomGenerator() - 1.0;
163 double sZ = std::sqrt(1.0 - std::pow(cZ, 2));
164 double angY = 2.0 * TMath::Pi() * RandomGenerator();
165 double cY = std::cos(angY);
166 double sY = std::sin(angY);
167 for (
unsigned int j = 0; j <= i; ++j) {
168 TLorentzVector &v(FinalStateLorentzVectors[j]);
173 v.SetPx(cY * (cZ * x - sZ * y) - sY * z);
174 v.SetPy(sZ * x + cZ * y);
175 v.SetPz(sY * (cZ * x - sZ * y) + cY * z);
177 if (i == NumberOfFinalStateParticles - 1)
180 double beta2 = 1.0 / (1.0 + std::pow(invMas[i] / pd[i], 2));
181 for (
unsigned int j = 0; j <= i; ++j) {
188 std::vector<FourMomentum> FourMomenta;
190 for (
unsigned int n = 0; n < NumberOfFinalStateParticles; ++n) {
193 FinalStateLorentzVectors[n].X(), FinalStateLorentzVectors[n].Y(),
194 FinalStateLorentzVectors[n].Z(), FinalStateLorentzVectors[n].E()));
196 GeneratedPhsp.Events.push_back(
ComPWA::Event{FourMomenta, 1.0});
198 return GeneratedPhsp;
202 double beta_squared)
const {
207 double gamma = 1.0 / std::sqrt(1.0 - beta_squared);
208 double betagamma = 1.0 / std::sqrt((1.0 - beta_squared) / beta_squared);
210 vec.SetY(gamma * y + betagamma * t);
211 vec.SetT(gamma * t + betagamma * y);
215 double x = (a - b - c) * (a + b + c) * (a - b + c) * (a + b - c);
216 return std::sqrt(x) / (2.0 * a);
ComPWA::EventCollection generate(unsigned int NumberOfEvents, UniformRealNumberGenerator &RandomGenerator) const final
ComPWA four momentum class.
double invariantMass() const
cmplx FADDEEVA() w(cmplx z, double relerr)
RootGenerator(const ComPWA::FourMomentum &CMSP4_, const std::vector< double > &FinalStateMasses_, const std::vector< ComPWA::pid > &FinalStatePIDs_)
Constructor for a three particle decay with given masses.
void BoostAlongY(TLorentzVector &vec, double beta_squared) const
const ParticleProperties & findParticle(const ParticleList &list, pid Pid)
std::set< ParticleProperties > ParticleList
double PDK(double a, double b, double c) const
These functions are copied from ROOT.
double CMSEnergyMinusMasses
std::vector< ComPWA::pid > FinalStatePIDs
Data structure containing all kinematic information of a physics event.
ComPWA::FourMomentum CMSP4
std::vector< double > FinalStateMasses