MCBooster  1.0.1
Tool to generate MC phase space samples in parallel.
Generate.h
Go to the documentation of this file.
1 /*-
2  * Generate.h
3  *
4  * Created on : Feb 25, 2016
5  * Author: Antonio Augusto Alves Junior
6  */
7 
8 /*
9  * This file is part of MCBooster.
10  *
11  * MCBooster is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * MCBooster is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with MCBooster. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
29 #ifndef GENERATE_H_
30 #define GENERATE_H_
31 
32 #include <vector>
33 #include <string>
34 #include <map>
35 #include <omp.h>
36 #include <iostream>
37 #include <ostream>
38 #include <algorithm>
39 #include <time.h>
40 #include <stdio.h>
41 //#include <math.h>
42 
43 #include <mcbooster/Config.h>
44 #include <mcbooster/Vector3R.h>
45 #include <mcbooster/Vector4R.h>
46 #include <mcbooster/GTypes.h>
47 #include <mcbooster/GContainers.h>
54 
55 #include <thrust/copy.h>
56 #include <thrust/device_vector.h>
57 #include <thrust/host_vector.h>
58 #include <thrust/transform.h>
59 #include <thrust/iterator/zip_iterator.h>
60 #include <thrust/iterator/counting_iterator.h>
61 #include <thrust/sequence.h>
62 #include <thrust/for_each.h>
63 #include <thrust/tuple.h>
64 #include <thrust/extrema.h>
65 #include <thrust/count.h>
66 #include <thrust/fill.h>
67 #include <thrust/sort.h>
68 #include <thrust/iterator/counting_iterator.h>
69 
70 #if !(THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_OMP || THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_TBB)
71 #include <thrust/system/cuda/execution_policy.h>
72 #endif
73 
74 #include <thrust/system/omp/execution_policy.h>
75 
76 #define TIMER CLOCK_REALTIME
77 
78 #define CUDA_CHECK_RETURN(value){ \
79  cudaError_t _m_cudaStat = value; \
80  if (_m_cudaStat != cudaSuccess) { \
81  fprintf(stderr, "Error %s at line %d in file %s\n", \
82  cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__); \
83  exit(1); \
84  } }
85 
86 using namespace std;
87 
88 namespace MCBooster {
92 timespec time_diff(timespec start, timespec end) {
93  timespec temp;
94  if ((end.tv_nsec - start.tv_nsec) < 0) {
95  temp.tv_sec = end.tv_sec - start.tv_sec - 1;
96  temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
97  } else {
98  temp.tv_sec = end.tv_sec - start.tv_sec;
99  temp.tv_nsec = end.tv_nsec - start.tv_nsec;
100  }
101  return temp;
102 }
103 
108 struct Events {
114  Particles_h fDaughters[kMAXP];
115 
119  Events(GInt_t ndaughters, GLong_t nevents) :
120  fNDaughters(ndaughters), fNEvents(nevents), fMaxWeight(0) {
121 
122  for (GInt_t d = 0; d < fNDaughters; d++) {
123  fDaughters[d].resize(fNEvents);
124  }
125 
126  fWeights.resize(fNEvents);
127  fAccRejFlags.resize(fNEvents);
128 
129  }
130 
131 };
132 
165 class PhaseSpace {
166 
167 public:
174  PhaseSpace(GReal_t _MotherMass, vector<GReal_t> _Masses, GLong_t _NEvents) :
175  fNDaughters(_Masses.size()), fNEvents(_NEvents),
176  fSeed(1),
177  fMaxWeight(0.0),
178  RND_Time(0.0), EVT_Time(0.0), EXP_Time(0.0), fNAccepted(0)
179  {
180 
181  if (_Masses.size() < 2 || _Masses.size() > 9) {
182  cout
183  << "The number of daughter particles can not be (< 2 || > 9) or masses and names need to have the same size."
184  << endl;
185  exit(1);
186 
187  }
188 
189  fMasses.resize(_Masses.size());
190  thrust::copy(_Masses.begin(), _Masses.end(), fMasses.begin());
191 
192  GReal_t fTeCmTm = 0.0;
193 
194  fTeCmTm = _MotherMass; // total energy in C.M. minus the sum of the masses
195 
196  for (size_t n = 0; n < fNDaughters; n++) {
197  fTeCmTm -= _Masses[n];
198  }
199  if (fTeCmTm < 0.0) {
200  cout << "Not enough energy for this decay. Exit." << endl;
201  exit(1);
202  }
203 
204  Allocate(fNEvents);
205 
206  } //decay
207 
212  fMasses.clear();
213  fMasses.shrink_to_fit();
214  FreeResources();
215 
216  }
217 
221  inline void FreeResources() {
222  for (GInt_t i = 0; i < fNDaughters; i++) {
223  fDaughters[i].clear();
224  fDaughters[i].shrink_to_fit();
225 
226  }
227 
228  fWeights.clear();
229  fWeights.shrink_to_fit();
230  //fRandNumbers.clear();
231  //fRandNumbers.shrink_to_fit();
232  fAccRejFlags.clear();
233  fAccRejFlags.shrink_to_fit();
234  }
235 
236  void Generate(Particles_d fMothers);
237  void Generate(const Vector4R fMother);
238 
244  return fDaughters[i];
245  }
249  inline GInt_t GetNDaughters() const {
250  return fNDaughters;
251  }
252 
256  inline GLong_t GetNEvents() const {
257  return fNEvents;
258  }
259 
260  inline GLong_t GetNAccepted() const {
261  return fNAccepted;
262  }
263 
267  inline const RealVector_d& GetWeights() const {
268  return fWeights;
269  }
270 
274  inline GReal_t GetEvtTime() const {
275  return EVT_Time;
276  }
277 
281  inline GReal_t GetExpTime() const {
282  return EXP_Time;
283  }
284 
288  inline GReal_t GetRndTime() const {
289  return RND_Time;
290  }
291 
296  inline GReal_t GetMaxWeight() const {
297  return fMaxWeight;
298  }
299 
300  inline GInt_t GetSeed() const {
301  return fSeed;
302  }
303 
304  inline void SetSeed(GInt_t _seed) {
305  fSeed=_seed;
306  }
307 
311  void Export(Events *_Events);
312  void ExportUnweighted(Events *_Events);
316  GULong_t Unweight();
317 
318  //
319 public:
320 
324  inline void Allocate(const GLong_t _nevents) {
325 
326  for (GInt_t i = 0; i < fNDaughters; i++)
327  fDaughters[i].resize(_nevents);
328  fWeights.resize(_nevents);
329  fAccRejFlags.resize(_nevents);
330  // fRandNumbers.resize((3 * fNDaughters - 2) * fNEvents);
331 
332  }
333 
337  GReal_t PDK(const GReal_t a, const GReal_t b, const GReal_t c) const {
338  //the PDK function
339  GReal_t x = (a - b - c) * (a + b + c) * (a - b + c) * (a + b - c);
340  x = sqrt(x) / (2 * a);
341  return x;
342  }
343 
344 private:
345 
346  GLong_t fNEvents;
347  GInt_t fNDaughters;
348  GInt_t fSeed;
349  GLong_t fNAccepted;
350  GReal_t RND_Time;
351  GReal_t EVT_Time;
352  GReal_t EXP_Time;
353  GReal_t fMaxWeight;
354  //device
355  RealVector_d fMasses;
356  RealVector_d fWeights;
357  BoolVector_d fAccRejFlags;
358  Particles_d fDaughters[kMAXP];
359 
360 
361 };
362 
363 GULong_t PhaseSpace::Unweight()
364 {
369  GULong_t count = 0;
370  if(fNDaughters==2)
371  {
372  thrust::fill(fAccRejFlags.begin(), fAccRejFlags.end(), kTrue);
373  count = fNEvents;
374  }
375  else
376  {
377 
378  // create iterators
379  thrust::counting_iterator<GLong_t> first(0);
380  thrust::counting_iterator<GLong_t> last = first + fNEvents;
381 
382 
383  thrust::transform(first, last, fWeights.begin(),
384  fAccRejFlags.begin(), FlagAcceptReject(fMaxWeight));
385 
386  count = thrust::count(fAccRejFlags.begin(), fAccRejFlags.end(),
387  kTrue);
388 
389  }
390  fNAccepted=count;
391  return count;
392 
393 }
394 
395 
396 
397 void PhaseSpace::ExportUnweighted(Events *_Events) {
402  if(!fNAccepted) Unweight();
403 
404 
405  _Events->fMaxWeight = fMaxWeight;
406 
407 #if THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_OMP || THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_TBB
408 
409 #pragma omp parallel num_threads( fNDaughters + 1 )
410  {
411 
412  if (omp_get_thread_num() < fNDaughters )
413  {
414  thrust::copy_if( fDaughters[omp_get_thread_num()].begin(),fDaughters[omp_get_thread_num()].end(),
415  fAccRejFlags.begin(),
416  _Events->fDaughters[omp_get_thread_num()].begin(), isAccepted() );
417  }
418 
419  if (omp_get_thread_num() == fNDaughters )
420  {
421  thrust::copy_if(fWeights.begin(), fWeights.end(),
422  fAccRejFlags.begin(),
423  _Events->fWeights.begin(), isAccepted() );
424 
425  thrust::copy_if(fAccRejFlags.begin(), fAccRejFlags.end(),
426  fAccRejFlags.begin(),
427  _Events->fAccRejFlags.begin(), isAccepted() );
428 
429  }
430 
431  }
432 
433 #else
434 
435  cudaStream_t s[fNDaughters + 1];
436 
437  for (GInt_t d = 0; d <= fNDaughters; d++) {
438 
440  cudaStreamCreateWithFlags(&s[d], cudaStreamNonBlocking));
441  }
442 
443 
444 
445  thrust::copy_if( thrust::cuda::par.on(s[fNDaughters]),
446  fWeights.begin(), fWeights.end(),
447  fAccRejFlags.begin(),
448  _Events->fWeights.begin(), isAccepted() );
449 
450 
451  thrust::copy_if( thrust::cuda::par.on(s[fNDaughters]),
452  fAccRejFlags.begin(), fAccRejFlags.end(),
453  fAccRejFlags.begin(),
454  _Events->fAccRejFlags.begin(), isAccepted() );
455 
456 
457  for (GInt_t d = 0; d < fNDaughters; d++) {
458 
459  thrust::copy_if( thrust::cuda::par.on(s[d]),
460  fDaughters[d].begin(),fDaughters[d].end(),
461  fAccRejFlags.begin(),
462  _Events->fDaughters[d].begin(), isAccepted() );
463 
464  }
465 
466  cudaDeviceSynchronize();
467  for (GInt_t d = 0; d <= fNDaughters; d++)
468  cudaStreamDestroy(s[d]);
469 
470 #endif
471 
472 }
473 
474 void PhaseSpace::Export(Events *_Events) {
478  _Events->fMaxWeight = fMaxWeight;
479 
480 #if THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_OMP || THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_TBB
481 
482 #pragma omp parallel num_threads( fNDaughters + 1 )
483  {
484 
485  if (omp_get_thread_num() < fNDaughters )
486  {
487  thrust::copy(fDaughters[omp_get_thread_num()].begin(),
488  fDaughters[omp_get_thread_num()].end(),
489  _Events->fDaughters[omp_get_thread_num()].begin());
490  }
491 
492  if (omp_get_thread_num() == fNDaughters )
493  {
494  thrust::copy(fWeights.begin(),
495  fWeights.end(), _Events->fWeights.begin());
496 
497  thrust::copy(fAccRejFlags.begin(),
498  fAccRejFlags.end(), _Events->fAccRejFlags.begin());
499 
500  }
501 
502  }
503 
504 #else
505 
506  cudaStream_t s[fNDaughters + 1];
507 
508  for (GInt_t d = 0; d <= fNDaughters; d++) {
509 
511  cudaStreamCreateWithFlags(&s[d], cudaStreamNonBlocking));
512  }
513 
514  cudaMemcpyAsync(thrust::raw_pointer_cast(_Events->fWeights.data()),
515  thrust::raw_pointer_cast(fWeights.data()),
516  fWeights.size() * sizeof(GReal_t), cudaMemcpyDeviceToHost,
517  s[fNDaughters]);
518 
519  cudaMemcpyAsync(thrust::raw_pointer_cast(_Events->fAccRejFlags.data()),
520  thrust::raw_pointer_cast(fAccRejFlags.data()),
521  fAccRejFlags.size() * sizeof(GBool_t), cudaMemcpyDeviceToHost,
522  s[fNDaughters]);
523 
524  for (GInt_t d = 0; d < fNDaughters; d++) {
525 
526  cudaMemcpyAsync(thrust::raw_pointer_cast(_Events->fDaughters[d].data()),
527  thrust::raw_pointer_cast(fDaughters[d].data()),
528  fDaughters[d].size() * sizeof(Vector4R), cudaMemcpyDeviceToHost,
529  s[d]);
530 
531  }
532 
533  cudaDeviceSynchronize();
534  for (GInt_t d = 0; d <= fNDaughters; d++)
535  cudaStreamDestroy(s[d]);
536 
537 #endif
538 
539 }
540 
541 void PhaseSpace::Generate(const Vector4R fMother) {
547 #if !(THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_OMP || THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_TBB)
548  cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
549 #endif
550  /* random number generation */
551 
552  RND_Time = 0;
553  // create iterators
554  thrust::counting_iterator<GLong_t> first(0);
555  thrust::counting_iterator<GLong_t> last = first + fNEvents;
556 
557  //Vai!!!
558 
559  /* event generation */
560  timespec time_event_start, time_event_end;
561  clock_gettime(TIMER, &time_event_start);
562 
563  switch (fNDaughters) {
564 
565  case 2:
566 
567  thrust::transform(first, last,
568  thrust::make_zip_iterator(
569  thrust::make_tuple(fDaughters[0].begin(),
570  fDaughters[1].begin())), fWeights.begin(),
571  DecayMother(fMother, fMasses, fNDaughters, fSeed));
572 
573  break;
574 
575  case 3:
576 
577  thrust::transform(first, last,
578  thrust::make_zip_iterator(
579  thrust::make_tuple(fDaughters[0].begin(),
580  fDaughters[1].begin(), fDaughters[2].begin())),
581  fWeights.begin(),
582  DecayMother(fMother, fMasses, fNDaughters, fSeed));
583 
584  break;
585  case 4:
586 
587  thrust::transform(first, last,
588  thrust::make_zip_iterator(
589  thrust::make_tuple(fDaughters[0].begin(),
590  fDaughters[1].begin(), fDaughters[2].begin(),
591  fDaughters[3].begin())), fWeights.begin(),
592  DecayMother(fMother, fMasses, fNDaughters, fSeed));
593 
594  break;
595  case 5:
596 
597  thrust::transform(first, last,
598  thrust::make_zip_iterator(
599  thrust::make_tuple(fDaughters[0].begin(),
600  fDaughters[1].begin(), fDaughters[2].begin(),
601  fDaughters[3].begin(), fDaughters[4].begin())),
602  fWeights.begin(),
603  DecayMother(fMother, fMasses, fNDaughters, fSeed));
604 
605  //}
606  break;
607  case 6:
608 
609  thrust::transform(first, last,
610  thrust::make_zip_iterator(
611  thrust::make_tuple(fDaughters[0].begin(),
612  fDaughters[1].begin(), fDaughters[2].begin(),
613  fDaughters[3].begin(), fDaughters[4].begin(),
614  fDaughters[5].begin())), fWeights.begin(),
615  DecayMother(fMother, fMasses, fNDaughters, fSeed));
616 
617  break;
618  case 7:
619 
620  thrust::transform(first, last,
621  thrust::make_zip_iterator(
622  thrust::make_tuple(fDaughters[0].begin(),
623  fDaughters[1].begin(), fDaughters[2].begin(),
624  fDaughters[3].begin(), fDaughters[4].begin(),
625  fDaughters[5].begin(), fDaughters[6].begin())),
626  fWeights.begin(),
627  DecayMother(fMother, fMasses, fNDaughters, fSeed));
628 
629  break;
630  case 8:
631 
632  thrust::transform(first, last,
633  thrust::make_zip_iterator(
634  thrust::make_tuple(fDaughters[0].begin(),
635  fDaughters[1].begin(), fDaughters[2].begin(),
636  fDaughters[3].begin(), fDaughters[4].begin(),
637  fDaughters[5].begin(), fDaughters[6].begin(),
638  fDaughters[7].begin())), fWeights.begin(),
639  DecayMother(fMother, fMasses, fNDaughters, fSeed));
640 
641  break;
642  case 9:
643 
644  thrust::transform(first, last,
645  thrust::make_zip_iterator(
646  thrust::make_tuple(fDaughters[0].begin(),
647  fDaughters[1].begin(), fDaughters[2].begin(),
648  fDaughters[3].begin(), fDaughters[4].begin(),
649  fDaughters[5].begin(), fDaughters[6].begin(),
650  fDaughters[7].begin(), fDaughters[8].begin())),
651  fWeights.begin(),
652  DecayMother(fMother, fMasses, fNDaughters, fSeed));
653 
654  break;
655 
656  }
657 
658  clock_gettime(TIMER, &time_event_end);
659  EVT_Time = ((GReal_t) (time_diff(time_event_start, time_event_end).tv_sec
660  + time_diff(time_event_start, time_event_end).tv_nsec * 1.0e-9));
661 
662  //setting maximum weight
663  RealVector_d::iterator w = thrust::max_element(fWeights.begin(),
664  fWeights.end());
665  fMaxWeight = *w;
666 
667 }
668 
669 void PhaseSpace::Generate(Particles_d fMothers) {
674 #if !(THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_OMP || THRUST_DEVICE_SYSTEM==THRUST_DEVICE_BACKEND_TBB)
675  cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
676 #endif
677 
678  if (fNEvents < fMothers.size())
679  cout << "fNEvents != fMothers.size()" << endl;
680 
681  /* random number generation */
682  /*
683  timespec time_rnd_start, time_rnd_end;
684  clock_gettime(TIMER, &time_rnd_start);
685 
686 
687  clock_gettime(TIMER, &time_rnd_end);
688 
689  RND_Time = ((GReal_t) (time_diff(time_rnd_start, time_rnd_end).tv_sec
690  + time_diff(time_rnd_start, time_rnd_end).tv_nsec * 1.0e-9));
691  */
692 
693  /* event generation */
694  timespec time_event_start, time_event_end;
695  clock_gettime(TIMER, &time_event_start);
696 
697  RND_Time = 0.0;
698  // create iterators
699  thrust::counting_iterator<GLong_t> first(0);
700  thrust::counting_iterator<GLong_t> last = first + fNEvents;
701 
702 
703  switch (fNDaughters) {
704 
705  case 2:
706 
707  thrust::transform(first, last,
708  thrust::make_zip_iterator(
709  thrust::make_tuple(fMothers.begin(),
710  fDaughters[0].begin(), fDaughters[1].begin())),
711  fWeights.begin(),
712  DecayMothers(fMasses, fNDaughters, fSeed));
713 
714  break;
715 
716  case 3:
717 
718  thrust::transform(first, last,
719  thrust::make_zip_iterator(
720  thrust::make_tuple(fMothers.begin(),
721  fDaughters[0].begin(), fDaughters[1].begin(),
722  fDaughters[2].begin())), fWeights.begin(),
723  DecayMothers(fMasses, fNDaughters, fSeed));
724 
725  break;
726  case 4:
727 
728  thrust::transform(first, last,
729  thrust::make_zip_iterator(
730  thrust::make_tuple(fMothers.begin(),
731  fDaughters[0].begin(), fDaughters[1].begin(),
732  fDaughters[2].begin(), fDaughters[3].begin())),
733  fWeights.begin(),
734  DecayMothers(fMasses, fNDaughters, fSeed));
735 
736  break;
737  case 5:
738 
739  thrust::transform(first, last,
740  thrust::make_zip_iterator(
741  thrust::make_tuple(fMothers.begin(),
742  fDaughters[0].begin(), fDaughters[1].begin(),
743  fDaughters[2].begin(), fDaughters[3].begin(),
744  fDaughters[4].begin())), fWeights.begin(),
745  DecayMothers(fMasses, fNDaughters, fSeed));
746 
747  break;
748  case 6:
749 
750  thrust::transform(first, last,
751  thrust::make_zip_iterator(
752  thrust::make_tuple(fMothers.begin(),
753  fDaughters[0].begin(), fDaughters[1].begin(),
754  fDaughters[2].begin(), fDaughters[3].begin(),
755  fDaughters[4].begin(), fDaughters[5].begin())),
756  fWeights.begin(),
757  DecayMothers(fMasses, fNDaughters, fSeed));
758 
759  break;
760  case 7:
761 
762  thrust::transform(first, last,
763  thrust::make_zip_iterator(
764  thrust::make_tuple(fMothers.begin(),
765  fDaughters[0].begin(), fDaughters[1].begin(),
766  fDaughters[2].begin(), fDaughters[3].begin(),
767  fDaughters[4].begin(), fDaughters[5].begin(),
768  fDaughters[6].begin())), fWeights.begin(),
769  DecayMothers(fMasses, fNDaughters, fSeed));
770 
771  break;
772  case 8:
773 
774  thrust::transform(first, last,
775  thrust::make_zip_iterator(
776  thrust::make_tuple(fMothers.begin(),
777  fDaughters[0].begin(), fDaughters[1].begin(),
778  fDaughters[2].begin(), fDaughters[3].begin(),
779  fDaughters[4].begin(), fDaughters[5].begin(),
780  fDaughters[6].begin(), fDaughters[7].begin())),
781  fWeights.begin(),
782  DecayMothers(fMasses, fNDaughters, fSeed));
783 
784  break;
785  case 9:
786 
787  thrust::transform(first, last,
788  thrust::make_zip_iterator(
789  thrust::make_tuple(fMothers.begin(),
790  fDaughters[0].begin(), fDaughters[1].begin(),
791  fDaughters[2].begin(), fDaughters[3].begin(),
792  fDaughters[4].begin(), fDaughters[5].begin(),
793  fDaughters[6].begin(), fDaughters[7].begin(),
794  fDaughters[8].begin())), fWeights.begin(),
795  DecayMothers(fMasses, fNDaughters, fSeed));
796 
797  break;
798 
799  }
800 
801  clock_gettime(TIMER, &time_event_end);
802  EVT_Time = ((GReal_t) (time_diff(time_event_start, time_event_end).tv_sec
803  + time_diff(time_event_start, time_event_end).tv_nsec * 1.0e-9));
804 
805  //setting maximum weight
806  RealVector_d::iterator w = thrust::max_element(fWeights.begin(),
807  fWeights.end());
808  fMaxWeight = *w;
809 
810 }
811 
812 }
813 #endif /* GENERATE_H_ */
GReal_t fMaxWeight
Maximum weight of the generated events.
Definition: Generate.h:111
long GLong_t
Signed long integer 4 bytes (long)
Definition: GTypes.h:39
Events is a container struct to hold all the information corresponding the generated events...
Definition: Generate.h:108
void FreeResources()
Free resources.
Definition: Generate.h:221
const GBool_t kTrue
Definition: GTypes.h:61
BoolVector_h fAccRejFlags
Vector of flags. Accepted events are flagged 1 and rejected 0.
Definition: Generate.h:112
bool GBool_t
Boolean (0=false, 1=true) (bool)
Definition: GTypes.h:45
void SetSeed(GInt_t _seed)
Definition: Generate.h:304
mc_host_vector< GReal_t > RealVector_h
Typedef for a GBool_t host vector.
Definition: GContainers.h:103
mc_device_vector< Vector4R > Particles_d
Typedef for a GComplex_t device vector.
Definition: GContainers.h:115
STL namespace.
Typedef for useful container classes used in MCBooster.
GLong_t GetNAccepted() const
Definition: Generate.h:260
unsigned long GULong_t
Definition: GTypes.h:40
Implements isAccepted.
GReal_t GetEvtTime() const
Returns the time spent in seconds to process the random numbers and set the phase space four-vectors...
Definition: Generate.h:274
PhaseSpace(GReal_t _MotherMass, vector< GReal_t > _Masses, GLong_t _NEvents)
PhaseSpace ctor.
Definition: Generate.h:174
GReal_t PDK(const GReal_t a, const GReal_t b, const GReal_t c) const
PDK function.
Definition: Generate.h:337
#define kMAXP
Definition: GTypes.h:65
const RealVector_d & GetWeights() const
Returns a device vector with the event weights.
Definition: Generate.h:267
Implementation of the event generator.
Definition: Generate.h:165
~PhaseSpace()
PhaseSpace() dtor.
Definition: Generate.h:211
Flags generated events as accepted (1) or rejected (0).
#define TIMER
Definition: Generate.h:76
Events(GInt_t ndaughters, GLong_t nevents)
Constructor takes as parameters the number of particles and number of events.
Definition: Generate.h:119
mc_device_vector< GBool_t > BoolVector_d
Typedef for a STL vector of pointers to host RealVector_h vectors.
Definition: GContainers.h:112
mc_host_vector< Vector4R > Particles_h
Typedef for a GComplex_t host vector.
Definition: GContainers.h:105
GLong_t GetNEvents() const
Returns the number of events.
Definition: Generate.h:256
GReal_t GetMaxWeight() const
Returns the max event weight that can be found in the generated sample.
Definition: Generate.h:296
GInt_t GetSeed() const
Definition: Generate.h:300
double GReal_t
Double 8 bytes or float 4 bytes.
Definition: GTypes.h:52
timespec time_diff(timespec start, timespec end)
Function to calculate time intervals in seconds.
Definition: Generate.h:92
void Allocate(const GLong_t _nevents)
Allocate resources on the device for event generation.
Definition: Generate.h:324
GLong_t fNEvents
Number of events.
Definition: Generate.h:110
GReal_t GetRndTime() const
Returns the time spent in seconds to generate the random numbers necessary for the calculation...
Definition: Generate.h:288
mc_host_vector< GBool_t > BoolVector_h
Vector3R host vector.
Definition: GContainers.h:102
Implements FlagAcceptReject.
GReal_t GetExpTime() const
Returns the time spent in seconds to export the generated events to a Events container.
Definition: Generate.h:281
GInt_t GetNDaughters() const
Returns the number of daughter particles.
Definition: Generate.h:249
int GInt_t
Signed integer 4 bytes (int)
Definition: GTypes.h:37
#define CUDA_CHECK_RETURN(value)
Definition: Generate.h:78
RealVector_h fWeights
Vector of event weights.
Definition: Generate.h:113
Particles_h fDaughters[kMAXP]
Array of daughter particle vectors.
Definition: Generate.h:114
Particles_d & GetDaughters(GInt_t i)
Get the daughter with index 'i' in the mass array.
Definition: Generate.h:243
mc_device_vector< GReal_t > RealVector_d
Typedef for a GBool_t device vector.
Definition: GContainers.h:113
GInt_t fNDaughters
Number of daughters.
Definition: Generate.h:109