YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHSP.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
20 
21 #ifndef yap_PHSP_h
22 #define yap_PHSP_h
23 
24 #include "fwd/FourVector.h"
25 
26 #include "FourMomenta.h"
27 #include "MassRange.h"
28 #include "Model.h"
29 
30 #include <algorithm>
31 #include <random>
32 #include <vector>
33 
34 namespace yap {
35 
43 template <class Generator>
44 const std::vector<FourVector<double> > phsp(const Model& M, double initial_mass, const MassAxes& A, const std::vector<MassRange>& R2, Generator& g, unsigned max_attempts)
45 {
46  static std::uniform_real_distribution<double> uniform(0, std::nextafter(1., 2.));
47 
48  // create vector to store invariant masses in
49  std::vector<double> m2(R2.size(), 0);
50  std::vector<FourVector<double> > P;
51 
52  for (unsigned n = 0; n < max_attempts && P.empty(); ++n) {
53  // generate random point in hypercube of mass ranges
54  std::transform(R2.begin(), R2.end(), m2.begin(), [&](const MassRange & r2) {return r2[0] + (r2[1] - r2[0]) * uniform(g);});
55  P = calculate_four_momenta(initial_mass, M, A, m2);
56  }
57  return P;
58 }
59 
60 }
61 
62 #endif
std::vector< FourVector< double > > calculate_four_momenta(double initial_mass, const FinalStateParticleVector &FPSs, const MassAxes &axes, const std::vector< double > &squared_masses)
Definition: FourMomenta.cxx:218
ParticleCombinationVector specialized to contain axes for defining a phase-space coordinate.
Definition: MassAxes.h:31
const std::vector< FourVector< double > > phsp(const Model &M, double initial_mass, const MassAxes &A, const std::vector< MassRange > &R2, Generator &g, unsigned max_attempts)
Definition: PHSP.h:44
Class implementing a PWA model.
Definition: Model.h:56