EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Distributor.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Distributor.cxx
1
10
#include "
eicsmear/smear/Distributor.h
"
11
12
#include <TF1.h>
13
#include <TRandom.h>
14
#include <TUUID.h>
15
16
namespace
Smear {
17
18
Distributor::Distributor
()
19
: mPlus(0.)
20
, mMinus(0.)
21
, mDistribution(NULL) {
22
}
23
24
Distributor::Distributor
(
const
TString& formula,
double
lower,
double
upper,
25
double
minimum,
double
maximum)
26
: mPlus(0.)
27
, mMinus(0.)
28
, mDistribution(new TF1(TUUID().
AsString
(), formula, minimum, maximum)) {
29
mDistribution
->SetParameters(0., 1.);
30
if
(lower > 0.) {
31
mMinus
= lower;
32
}
// if
33
if
(upper > 0.) {
34
mPlus
= upper;
35
}
// if
36
}
37
38
Distributor::~Distributor
() {
39
if
(
mDistribution
) {
40
delete
mDistribution
;
41
mDistribution
= NULL;
42
}
// if
43
}
44
45
double
Distributor::Generate
(
double
mean,
double
sigma) {
46
double
random(0.);
47
if
(!
mDistribution
) {
48
random = gRandom->Gaus(mean, sigma);
49
}
else
{
50
mDistribution
->SetParameters(mean, sigma);
51
if
(
mMinus
> 0. ||
mPlus
> 0.) {
52
random =
mDistribution
->GetRandom(mean -
mMinus
, mean +
mPlus
);
53
}
else
{
54
random =
mDistribution
->GetRandom();
55
}
// if
56
}
// if
57
return
random;
58
}
59
60
}
// namespace Smear
eic-smear
blob
master
src
smear
Distributor.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:32
using
1.8.2 with
EIC GitHub integration