KaliVeda
Toolkit for HIC analysis
KVSubEventMaker.cpp
1 #include "KVSubEventMaker.h"
2 #include <random>
3 #include <algorithm>
5 
6 
11 
12 
14 void KVSubEventMaker::Copy(TObject& a) const
15 {
16  KVVarGlob::Copy(a);// copy attributes of KVVarGlob base object
17 
18  // Now copy any additional attributes specific to this class:
19  // To copy a specific field, do as follows:
20  //
21  // aglob.field=field;
22  //
23  // If setters and getters are available, you can also proceed as follows
24  //
25  // aglob.SetField(GetField());
26  //
27 }
28 
29 
32 
33 
35 
37 {
38 }
39 
40 
43 
44 
46 
48 {
49  particles.clear();
50 }
51 
52 
55 
56 
59 
61 {
62  // Set group for required fraction of particles (starting from the first one)
63 
64  auto mult = particles.size();
65  // perform a random shuffle of the particles in case there is a correlation
66  // between position in the event and type of particle, where it was detected,
67  // etc. etc.
68  std::random_device rd;
69  std::mt19937 g(rd());
70  std::shuffle(particles.begin(), particles.end(), g);
71 
72  auto required = mult * GetParameter("FRACTION");
73  // nothing guarantees that the required number of particles is a whole number
74  auto req_int = std::floor(required);
75  auto req_frac = required - req_int;
76  // if so, we use req_int particles with probability 1-req_frac and req_int+1
77  // particles with probability req_frac. The mean number of particles used
78  // is exactly the value 'required'.
79  if (req_frac > 1.e-10) {
80  if (gRandom->Uniform() < req_frac) ++req_int;
81  }
82  int i = 0;
83  for (auto p : particles) {
84  if (i < req_int) p->AddGroup(GetName());
85  ++i;
86  }
87 }
88 
89 
116 
117 
119 
121 {
122 
123  return 0;
124 }
125 
126 
127 
130 
132 {
133  // add to internal list
134  particles.push_back(const_cast<KVNucleus*>(n));
135 }
136 
137 
146 
147 
150 
152 {
153  // PRIVATE method
154  fType = KVVarGlob::kOneBody; // this is a N-body variable
155 }
156 
157 
158 
int Int_t
double Double_t
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
R__EXTERN TRandom * gRandom
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:126
Global variable for defining random subevents.
void Reset()
Reset internal variables, called before treatment of each event.
void fill(const KVNucleus *)
add to internal list
void Init()
Initialisation of internal variables, called once before beginning treatment.
std::vector< KVNucleus * > particles
void init()
PRIVATE method.
Double_t getvalue_int(Int_t) const
void Calculate()
Calculation of global variable value(s) after filling is finished.
void Copy(TObject &obj) const
Definition: KVVarGlob.h:346
Double_t GetParameter(const Char_t *par) const
Definition: KVVarGlob.h:580
Int_t fType
type of variable global; = kOneBody, kTwoBody or kNBody
Definition: KVVarGlob.h:243
const char * GetName() const override
virtual Double_t Uniform(Double_t x1, Double_t x2)
const Int_t n
TArc a
ClassImp(TPyArg)