27 #ifndef DECAYMOTHERS_H_
28 #define DECAYMOTHERS_H_
36 #include <thrust/tuple.h>
37 #include <thrust/iterator/zip_iterator.h>
53 fMasses(thrust::raw_pointer_cast(_masses.data())),
54 fNDaughters(_ndaughters),
63 GReal_t x = (a - b - c) * (a + b + c) * (a - b + c) * (a + b - c);
64 x = sqrt(x) / (2 * a);
71 for (
GInt_t c = 0; c < n; c++)
75 for (
GInt_t d = 0; d < n - c - 1; d++)
77 if (array[d] > array[d + 1])
80 array[d] = array[d + 1];
93 a = (a + 0x7ed55d16) + (a << 12);
94 a = (a ^ 0xc761c23c) ^ (a >> 19);
95 a = (a + 0x165667b1) + (a << 5);
96 a = (a + 0xd3a2646c) ^ (a << 9);
97 a = (a + 0xfd7046c5) + (a << 3);
98 a = (a ^ 0xb55a4f09) ^ (a >> 16);
106 thrust::random::default_random_engine randEng( hash(evt)*fSeed);
107 thrust::uniform_real_distribution<GReal_t> uniDist(0.0, 1.0);
109 GReal_t fTeCmTm = 0.0, fWtMax = 0.0;
111 fTeCmTm = particles[0]->
mass();
114 for (
size_t n = 0; n < fNDaughters; n++)
116 fTeCmTm -= fMasses[n];
119 GReal_t emmax = fTeCmTm + fMasses[0];
124 for (
size_t n = 1; n < fNDaughters; n++)
126 emmin += fMasses[n - 1];
128 wtmax *= pdk(emmax, emmin, fMasses[n]);
130 fWtMax = 1.0 / wtmax;
135 fBeta[0]=0, fBeta[1]=0, fBeta[2] = 0.0;
142 fBeta[0] = particles[0]->
get(0) * w;
143 fBeta[1] = particles[0]->
get(1) * w;
144 fBeta[2] = particles[0]->
get(2) * w;
153 for (
size_t n = 1; n < fNDaughters - 1; n++)
154 rno[n] = uniDist(randEng) ;
155 bbsort(&rno[1], fNDaughters - 2);
158 rno[fNDaughters - 1] = 1;
163 for (
size_t n = 0; n < fNDaughters; n++)
166 invMas[n] = rno[n] * fTeCmTm + sum;
178 for (
size_t n = 0; n < fNDaughters - 1; n++)
180 pd[n] = pdk(invMas[n + 1], invMas[n], fMasses[n + 1]);
188 particles[1]->
set(sqrt(pd[0] * pd[0] + fMasses[0] * fMasses[0]), 0.0,
192 for (
size_t i = 1; i < fNDaughters; i++)
195 particles[i + 1]->
set(
196 sqrt(pd[i - 1] * pd[i - 1] + fMasses[i] * fMasses[i]), 0.0,
199 GReal_t cZ = 2 * uniDist(randEng) -1 ;
200 GReal_t sZ = sqrt(1 - cZ * cZ);
201 GReal_t angY = 2.0 *
PI * uniDist(randEng);
204 for (
size_t j = 0; j <= i; j++)
209 particles[j + 1]->
set(1, cZ * x - sZ * y);
210 particles[j + 1]->
set(2, sZ * x + cZ * y);
212 x = particles[j + 1]->
get(1);
214 particles[j + 1]->
set(1, cY * x - sY * z);
215 particles[j + 1]->
set(3, sY * x + cY * z);
218 if (i == (fNDaughters - 1))
221 GReal_t beta = pd[i] / sqrt(pd[i] * pd[i] + invMas[i] * invMas[i]);
222 for (
size_t j = 0; j <= i; j++)
235 for (
size_t n = 0; n < fNDaughters; n++)
261 _Particles[0] = &thrust::get<0>(particles);
262 _Particles[1] = &thrust::get<1>(particles);
263 _Particles[2] = &thrust::get<2>(particles);
265 return process(evt, _Particles);
274 _Particles[0] = &thrust::get<0>(particles);
275 _Particles[1] = &thrust::get<1>(particles);
276 _Particles[2] = &thrust::get<2>(particles);
277 _Particles[3] = &thrust::get<3>(particles);
279 return process(evt, _Particles);
287 _Particles[0] = &thrust::get<0>(particles);
288 _Particles[1] = &thrust::get<1>(particles);
289 _Particles[2] = &thrust::get<2>(particles);
290 _Particles[3] = &thrust::get<3>(particles);
291 _Particles[4] = &thrust::get<4>(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);
306 _Particles[5] = &thrust::get<5>(particles);
308 return process(evt, _Particles);
316 _Particles[0] = &thrust::get<0>(particles);
317 _Particles[1] = &thrust::get<1>(particles);
318 _Particles[2] = &thrust::get<2>(particles);
319 _Particles[3] = &thrust::get<3>(particles);
320 _Particles[4] = &thrust::get<4>(particles);
321 _Particles[5] = &thrust::get<5>(particles);
322 _Particles[6] = &thrust::get<6>(particles);
324 return process(evt, _Particles);
332 _Particles[0] = &thrust::get<0>(particles);
333 _Particles[1] = &thrust::get<1>(particles);
334 _Particles[2] = &thrust::get<2>(particles);
335 _Particles[3] = &thrust::get<3>(particles);
336 _Particles[4] = &thrust::get<4>(particles);
337 _Particles[5] = &thrust::get<5>(particles);
338 _Particles[6] = &thrust::get<6>(particles);
339 _Particles[7] = &thrust::get<7>(particles);
341 return process(evt, _Particles);
349 _Particles[0] = &thrust::get<0>(particles);
350 _Particles[1] = &thrust::get<1>(particles);
351 _Particles[2] = &thrust::get<2>(particles);
352 _Particles[3] = &thrust::get<3>(particles);
353 _Particles[4] = &thrust::get<4>(particles);
354 _Particles[5] = &thrust::get<5>(particles);
355 _Particles[6] = &thrust::get<6>(particles);
356 _Particles[7] = &thrust::get<7>(particles);
357 _Particles[8] = &thrust::get<8>(particles);
359 return process(evt, _Particles);
367 _Particles[0] = &thrust::get<0>(particles);
368 _Particles[1] = &thrust::get<1>(particles);
369 _Particles[2] = &thrust::get<2>(particles);
370 _Particles[3] = &thrust::get<3>(particles);
371 _Particles[4] = &thrust::get<4>(particles);
372 _Particles[5] = &thrust::get<5>(particles);
373 _Particles[6] = &thrust::get<6>(particles);
374 _Particles[7] = &thrust::get<7>(particles);
375 _Particles[8] = &thrust::get<8>(particles);
376 _Particles[9] = &thrust::get<9>(particles);
378 return process(evt, _Particles);
__host__ __device__ GReal_t operator()(const GInt_t evt, GT9 &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__ void bbsort(GReal_t *array, GInt_t n)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT6 &particles)
unsigned int GUInt_t
Unsigned integer 4 bytes (unsigned int)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT3 &particles)
__host__ __device__ GReal_t d3mag() const
__host__ __device__ GReal_t operator()(const GInt_t evt, GT4 &particles)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT5 &particles)
Typedef for useful container classes used in MCBooster.
const GReal_t *__restrict__ fMasses
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 process(const GInt_t evt, Vector4R **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 pdk(const GReal_t a, const GReal_t b, const GReal_t c) const
__host__ __device__ GUInt_t hash(GUInt_t a)
__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, GT10 &particles)
DecayMothers(const mc_device_vector< GReal_t > &_masses, const GInt_t _ndaughters, const GInt_t _seed)
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, GT8 &particles)
__host__ __device__ GReal_t operator()(const GInt_t evt, GT7 &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 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 operator()(const GInt_t evt, GT2 &particles)