GooFit  v2.1.3
DalitzPlotHelpers.h
Go to the documentation of this file.
1 /*
2 04/05/2016 Christoph Hasse
3 DISCLAIMER:
4 
5 This code is not sufficently tested yet and still under heavy development!
6 See *.cu file for more details
7 */
8 
9 #pragma once
10 
11 #include <goofit/PDFs/GooPdf.h>
14 
15 #include <thrust/device_vector.h>
16 #include <thrust/iterator/constant_iterator.h>
17 
18 namespace GooFit {
19 
20 template <typename E>
21 constexpr typename std::underlying_type<E>::type enum_to_underlying(E e) {
22  return static_cast<typename std::underlying_type<E>::type>(e);
23 }
24 
25 __host__ __device__ bool inDalitz(
26  const fptype &m12, const fptype &m13, const fptype &bigM, const fptype &dm1, const fptype &dm2, const fptype &dm3);
27 
28 __device__ fpcomplex
29 getResonanceAmplitude(fptype m12, fptype m13, fptype m23, unsigned int functionIdx, unsigned int pIndex);
30 
31 __device__ void get4Vecs(fptype *Vecs,
32  const unsigned int &constants,
33  const fptype &m12,
34  const fptype &m34,
35  const fptype &cos12,
36  const fptype &cos34,
37  const fptype &phi);
38 
39 __device__ fptype getmass(const unsigned int &pair,
40  fptype &d1,
41  fptype &d2,
42  const fptype *vecs,
43  const fptype &m1,
44  const fptype &m2,
45  const fptype &m3,
46  const fptype &m4);
47 
48 // in case of 3 particles the first two are the resonance.
49 enum DP4Pair {
50  M_12 = 0,
68 };
70 
71 const int resonanceSize = 4; // Number of parameters to describe one resonance.
72 // Why not make this a static const member of ResonancePdf? Because the 'static'
73 // keyword (and 'extern' as well) interacts badly with some nvcc versions when the
74 // variable is used in device code.
75 
76 struct DecayInfo3 {
82 
83  std::vector<ResonancePdf *> resonances;
84 };
85 
86 struct DecayInfo3t : public DecayInfo3 {
90 
91  DecayInfo3t(Variable _tau, Variable _xmixing, Variable _ymixing)
92  : _tau(_tau)
93  , _xmixing(_xmixing)
94  , _ymixing(_ymixing) {}
95 };
96 
97 struct DecayInfo4 {
98  std::vector<fptype> particle_masses;
100 
101  std::vector<Amplitude *> amplitudes;
102  std::vector<Amplitude *> amplitudes_B;
103 };
104 
105 struct DecayInfo4t : public DecayInfo4 {
110 
111  DecayInfo4t(Variable _tau, Variable _xmixing, Variable _ymixing, Variable _SqWStoRSrate)
112  : _tau(_tau)
113  , _xmixing(_xmixing)
114  , _ymixing(_ymixing)
115  , _SqWStoRSrate(_SqWStoRSrate) {}
116 };
117 
118 // Copied from strided_range thrust example by Nathan Bell.
119 // Iterator to move forward by a specified number of steps
120 // in each iteration.
121 template <typename Iterator>
123  public:
124  typedef typename thrust::iterator_difference<Iterator>::type difference_type;
125 
126  struct stride_functor : public thrust::unary_function<difference_type, difference_type> {
127  difference_type stride;
128 
129  stride_functor(difference_type stride)
130  : stride(stride) {}
131 
132  __host__ __device__ difference_type operator()(const difference_type &i) const { return stride * i; }
133  };
134  typedef typename thrust::counting_iterator<difference_type> CountingIterator;
135  typedef typename thrust::transform_iterator<stride_functor, CountingIterator> TransformIterator;
136  typedef typename thrust::permutation_iterator<Iterator, TransformIterator> PermutationIterator;
137 
138  // type of the strided_range iterator
139  typedef PermutationIterator iterator;
140 
141  // construct strided_range for the range [first,last)
142  strided_range(Iterator first, Iterator last, difference_type stride)
143  : first(first)
144  , last(last)
145  , stride(stride) {}
146 
147  iterator begin() const {
148  return PermutationIterator(first, TransformIterator(CountingIterator(0), stride_functor(stride)));
149  }
150 
151  iterator end() const { return begin() + ((last - first) + (stride - 1)) / stride; }
152 
153  protected:
154  Iterator first;
155  Iterator last;
156  difference_type stride;
157 };
158 
159 } // namespace GooFit
double fptype
iterator begin() const
std::vector< ResonancePdf * > resonances
__device__ void get4Vecs(fptype *Vecs, const unsigned int &constants, const fptype &m12, const fptype &m34, const fptype &cos12, const fptype &cos34, const fptype &phi)
const int resonanceSize
PermutationIterator iterator
strided_range(Iterator first, Iterator last, difference_type stride)
thrust::transform_iterator< stride_functor, CountingIterator > TransformIterator
Observable * m12
thrust::complex< fptype > fpcomplex
Definition: Complex.h:8
DecayInfo4t(Variable _tau, Variable _xmixing, Variable _ymixing, Variable _SqWStoRSrate)
__device__ fptype getmass(const unsigned int &pair, fptype &d1, fptype &d2, const fptype *vecs, const fptype &m1, const fptype &m2, const fptype &m3, const fptype &m4)
Observable * m13
__host__ __device__ bool inDalitz(const fptype &m12, const fptype &m13, const fptype &bigM, const fptype &dm1, const fptype &dm2, const fptype &dm3)
thrust::iterator_difference< Iterator >::type difference_type
__device__ fpcomplex getResonanceAmplitude(fptype m12, fptype m13, fptype m23, unsigned int functionIdx, unsigned int pIndex)
thrust::counting_iterator< difference_type > CountingIterator
std::vector< fptype > particle_masses
__host__ __device__ difference_type operator()(const difference_type &i) const
constexpr std::underlying_type< E >::type enum_to_underlying(E e)
DecayInfo3t(Variable _tau, Variable _xmixing, Variable _ymixing)
std::vector< Amplitude * > amplitudes_B
std::vector< Amplitude * > amplitudes
thrust::permutation_iterator< Iterator, TransformIterator > PermutationIterator