KaliVeda
Toolkit for HIC analysis
KVSubEventMaker.cpp
1 #include "KVSubEventMaker.h"
2 #include "TRandom.h"
3 #include <random>
4 #include <algorithm>
6 
7 
12 
13 
15 void KVSubEventMaker::Copy(TObject& a) const
16 {
17  KVVarGlob::Copy(a);// copy attributes of KVVarGlob base object
18 
19  // Now copy any additional attributes specific to this class:
20  // To copy a specific field, do as follows:
21  //
22  // aglob.field=field;
23  //
24  // If setters and getters are available, you can also proceed as follows
25  //
26  // aglob.SetField(GetField());
27  //
28 }
29 
30 
33 
34 
36 
38 {
39 }
40 
41 
44 
45 
47 
49 {
50  particles.clear();
51 }
52 
53 
56 
57 
60 
62 {
63  // Set group for required fraction of particles (starting from the first one)
64 
65  auto mult = particles.size();
66  // perform a random shuffle of the particles in case there is a correlation
67  // between position in the event and type of particle, where it was detected,
68  // etc. etc.
69  std::random_device rd;
70  std::mt19937 g(rd());
71  std::shuffle(particles.begin(), particles.end(), g);
72 
73  auto required = mult * GetParameter("FRACTION");
74  // nothing guarantees that the required number of particles is a whole number
75  auto req_int = std::floor(required);
76  auto req_frac = required - req_int;
77  // if so, we use req_int particles with probability 1-req_frac and req_int+1
78  // particles with probability req_frac. The mean number of particles used
79  // is exactly the value 'required'.
80  if (req_frac > 1.e-10) {
81  if (gRandom->Uniform() < req_frac) ++req_int;
82  }
83  int i = 0;
84  for (auto p : particles) {
85  if (i < req_int) p->AddGroup(GetName());
86  ++i;
87  }
88 }
89 
90 
117 
118 
120 
122 {
123 
124  return 0;
125 }
126 
127 
128 
131 
133 {
134  // add to internal list
135  particles.push_back(const_cast<KVNucleus*>(n));
136 }
137 
138 
147 
148 
151 
153 {
154  // PRIVATE method
155  fType = KVVarGlob::kOneBody; // this is a N-body variable
156 }
157 
158 
159 
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:123
Global variable for defining random subevents.
void Init() override
Initialisation of internal variables, called once before beginning treatment.
void Calculate() override
Calculation of global variable value(s) after filling is finished.
void fill(const KVNucleus *) override
add to internal list
std::vector< KVNucleus * > particles
Double_t getvalue_int(Int_t) const override
void Reset() override
Reset internal variables, called before treatment of each event.
void init()
PRIVATE method.
void Copy(TObject &obj) const override
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)