27 #ifndef DECAYMOTHER_H_
28 #define DECAYMOTHER_H_
35 #include <thrust/tuple.h>
36 #include <thrust/iterator/zip_iterator.h>
37 #include <thrust/random.h>
61 fMasses(thrust::raw_pointer_cast(_masses.data())),
62 fNDaughters(_ndaughters),
69 for (
size_t n = 0; n < fNDaughters; n++)
71 _fTeCmTm -= _masses.data()[n];
74 GReal_t emmax = _fTeCmTm + _masses.data()[0];
77 for (
size_t n = 1; n < fNDaughters; n++)
79 emmin += _masses.data()[n - 1];
80 emmax += _masses.data()[n];
81 wtmax *= pdk(emmax, emmin, _masses.data()[n]);
90 fBeta0 = mother.
get(0) * w;
91 fBeta1 = mother.
get(1) * w;
92 fBeta2 = mother.
get(2) * w;
95 fBeta0 = fBeta1 = fBeta2 = 0.0;
107 GReal_t x = (a - b - c) * (a + b + c) * (a - b + c) * (a + b - c);
108 x = sqrt(x) / (2 * a);
116 for (
GInt_t c = 0; c < n; c++)
120 for (
GInt_t d = 0; d < n - c - 1; d++)
122 if (array[d] > array[d + 1])
125 array[d] = array[d + 1];
138 a = (a + 0x7ed55d16) + (a << 12);
139 a = (a ^ 0xc761c23c) ^ (a >> 19);
140 a = (a + 0x165667b1) + (a << 5);
141 a = (a + 0xd3a2646c) ^ (a << 9);
142 a = (a + 0xfd7046c5) + (a << 3);
143 a = (a ^ 0xb55a4f09) ^ (a >> 16);
150 thrust::random::default_random_engine randEng( hash(evt)*fSeed);
151 thrust::uniform_real_distribution<GReal_t> uniDist(0.0, 1.0);
155 rno[fNDaughters - 1] = 1.0;
160 for (
GInt_t n = 1; n < fNDaughters - 1; n++)
162 rno[n] = uniDist(randEng) ;
166 bbsort(&rno[1], fNDaughters -2);
174 for (
size_t n = 0; n < fNDaughters; n++)
177 invMas[n] = rno[n] * fTeCmTm + sum;
189 for (
size_t n = 0; n < fNDaughters - 1; n++)
191 pd[n] = pdk(invMas[n + 1], invMas[n], fMasses[n + 1]);
199 daugters[0]->
set(sqrt((
GReal_t) pd[0] * pd[0] + fMasses[0] * fMasses[0]), 0.0,
203 for (
size_t i = 1; i < fNDaughters; i++)
207 sqrt(pd[i - 1] * pd[i - 1] + fMasses[i] * fMasses[i]), 0.0,
210 GReal_t cZ = 2 * uniDist(randEng) -1 ;
211 GReal_t sZ = sqrt(1 - cZ * cZ);
215 for (
size_t j = 0; j <= i; j++)
220 daugters[j]->
set(1, cZ * x - sZ * y);
221 daugters[j]->
set(2, sZ * x + cZ * y);
223 x = daugters[j]->
get(1);
225 daugters[j]->
set(1, cY * x - sY * z);
226 daugters[j]->
set(3, sY * x + cY * z);
229 if (i == (fNDaughters - 1))
232 GReal_t beta = pd[i] / sqrt(pd[i] * pd[i] + invMas[i] * invMas[i]);
233 for (
size_t j = 0; j <= i; j++)
245 for (
size_t n = 0; n < fNDaughters; n++)
264 _Particles[0] = &thrust::get<0>(particles);
265 _Particles[1] = &thrust::get<1>(particles);
267 return process(evt, _Particles);
275 _Particles[0] = &thrust::get<0>(particles);
276 _Particles[1] = &thrust::get<1>(particles);
277 _Particles[2] = &thrust::get<2>(particles);
279 return process(evt, _Particles);
288 _Particles[0] = &thrust::get<0>(particles);
289 _Particles[1] = &thrust::get<1>(particles);
290 _Particles[2] = &thrust::get<2>(particles);
291 _Particles[3] = &thrust::get<3>(particles);
293 return process(evt, _Particles);
301 _Particles[0] = &thrust::get<0>(particles);
302 _Particles[1] = &thrust::get<1>(particles);
303 _Particles[2] = &thrust::get<2>(particles);
304 _Particles[3] = &thrust::get<3>(particles);
305 _Particles[4] = &thrust::get<4>(particles);
307 return process(evt, _Particles);
315 _Particles[0] = &thrust::get<0>(particles);
316 _Particles[1] = &thrust::get<1>(particles);
317 _Particles[2] = &thrust::get<2>(particles);
318 _Particles[3] = &thrust::get<3>(particles);
319 _Particles[4] = &thrust::get<4>(particles);
320 _Particles[5] = &thrust::get<5>(particles);
322 return process(evt, _Particles);
330 _Particles[0] = &thrust::get<0>(particles);
331 _Particles[1] = &thrust::get<1>(particles);
332 _Particles[2] = &thrust::get<2>(particles);
333 _Particles[3] = &thrust::get<3>(particles);
334 _Particles[4] = &thrust::get<4>(particles);
335 _Particles[5] = &thrust::get<5>(particles);
336 _Particles[6] = &thrust::get<6>(particles);
338 return process(evt, _Particles);
346 _Particles[0] = &thrust::get<0>(particles);
347 _Particles[1] = &thrust::get<1>(particles);
348 _Particles[2] = &thrust::get<2>(particles);
349 _Particles[3] = &thrust::get<3>(particles);
350 _Particles[4] = &thrust::get<4>(particles);
351 _Particles[5] = &thrust::get<5>(particles);
352 _Particles[6] = &thrust::get<6>(particles);
353 _Particles[7] = &thrust::get<7>(particles);
355 return process(evt, _Particles);
363 _Particles[0] = &thrust::get<0>(particles);
364 _Particles[1] = &thrust::get<1>(particles);
365 _Particles[2] = &thrust::get<2>(particles);
366 _Particles[3] = &thrust::get<3>(particles);
367 _Particles[4] = &thrust::get<4>(particles);
368 _Particles[5] = &thrust::get<5>(particles);
369 _Particles[6] = &thrust::get<6>(particles);
370 _Particles[7] = &thrust::get<7>(particles);
371 _Particles[8] = &thrust::get<8>(particles);
373 return process(evt, _Particles);
381 _Particles[0] = &thrust::get<0>(particles);
382 _Particles[1] = &thrust::get<1>(particles);
383 _Particles[2] = &thrust::get<2>(particles);
384 _Particles[3] = &thrust::get<3>(particles);
385 _Particles[4] = &thrust::get<4>(particles);
386 _Particles[5] = &thrust::get<5>(particles);
387 _Particles[6] = &thrust::get<6>(particles);
388 _Particles[7] = &thrust::get<7>(particles);
389 _Particles[8] = &thrust::get<8>(particles);
390 _Particles[9] = &thrust::get<9>(particles);
392 return process(evt, _Particles);
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type > GT5
GT5 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t get(GInt_t i) const
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type > GT3
GT3 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t process(const GInt_t evt, Vector4R **daugters)
unsigned int GUInt_t
Unsigned integer 4 bytes (unsigned int)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT7 &particles)
__host__ __device__ GReal_t d3mag() const
Typedef for useful container classes used in MCBooster.
__host__ __device__ GReal_t operator()(const GInt_t evt, GT9 &particles)
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type > GT2
GT2 iterator is a typedef for thrust::detail::tuple_of_iterator_references
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, thrust::null_type > GT9
GT9 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t operator()(const GInt_t evt, GT6 &particles)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT2 &particles)
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R & > GT10
GT10 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t operator()(const GInt_t evt, GT8 &particles)
__host__ __device__ void set(GInt_t i, GReal_t d)
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, thrust::null_type, thrust::null_type, thrust::null_type > GT7
GT7 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t operator()(const GInt_t evt, GT4 &particles)
double GReal_t
Double 8 bytes or float 4 bytes.
__host__ __device__ void applyBoostTo(const Vector4R &p4, bool inverse=false)
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type > GT4
GT4 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t operator()(const GInt_t evt, GT3 &particles)
int GInt_t
Signed integer 4 bytes (int)
thrust::host_vector< T > mc_device_vector
Generic template typedef for thrust::host_vector.
__host__ __device__ GReal_t operator()(const GInt_t evt, GT10 &particles)
__host__ __device__ GUInt_t hash(GUInt_t a)
DecayMother(const Vector4R mother, const mc_device_vector< GReal_t > &_masses, const GInt_t _ndaughters, const GInt_t _seed)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT5 &particles)
const GReal_t *__restrict__ fMasses
__host__ __device__ GReal_t mass() const
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, thrust::null_type, thrust::null_type, thrust::null_type, thrust::null_type > GT6
GT6 iterator is a typedef for thrust::detail::tuple_of_iterator_references
thrust::detail::tuple_of_iterator_references< Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, Vector4R &, thrust::null_type, thrust::null_type > GT8
GT8 iterator is a typedef for thrust::detail::tuple_of_iterator_references
__host__ __device__ GReal_t pdk(const GReal_t a, const GReal_t b, const GReal_t c) const
__host__ __device__ void bbsort(GReal_t *array, GInt_t n)