-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathBoxGenerator.cxx
More file actions
78 lines (69 loc) · 2.67 KB
/
BoxGenerator.cxx
File metadata and controls
78 lines (69 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \author Sandro Wenzel - April 2024
#include "Generators/BoxGenerator.h"
#include "TRandom.h"
#include "TDatabasePDG.h"
using namespace o2::eventgen;
double GetPDGMass(int pdg)
{
static TDatabasePDG* pid = TDatabasePDG::Instance();
TParticlePDG* p = pid->GetParticle(pdg);
if (p != nullptr) {
// LOG(info) << this->ClassName() << ": particle with PDG =" << GetPDGType() << " Found";
return p->Mass(); // fPDGMass = p->Mass();
}
// LOG(warn) << "pdg not known";
return 0.;
}
TParticle o2::eventgen::BoxGenerator::sampleParticle() const
{
// Primary particles are distributed uniformly along
// those kinematics variables which were limitted by setters.
// if SetCosTheta() function is used, the distribution will be uniform in
// cos(theta)
static double mass = GetPDGMass(mPDG);
double pabs = 0, phi, pt = 0, theta = 0, eta, y, mt, px, py, pz = 0;
phi = gRandom->Uniform(mPhiMin, mPhiMax) * TMath::DegToRad();
if (mPRangeIsSet) {
pabs = gRandom->Uniform(mPMin, mPMax);
} else if (mPtRangeIsSet) {
pt = gRandom->Uniform(mPtMin, mPtMax);
}
if (mThetaRangeIsSet) {
if (mCosThetaIsSet) {
theta = acos(gRandom->Uniform(cos(mThetaMin * TMath::DegToRad()), cos(mThetaMax * TMath::DegToRad())));
} else {
theta = gRandom->Uniform(mThetaMin, mThetaMax) * TMath::DegToRad();
}
} else if (mEtaRangeIsSet) {
eta = gRandom->Uniform(mEtaMin, mEtaMax);
theta = 2 * TMath::ATan(TMath::Exp(-eta));
} else if (mYRangeIsSet) {
y = gRandom->Uniform(mYMin, mYMax);
mt = TMath::Sqrt(mass * mass + pt * pt);
pz = mt * TMath::SinH(y);
}
if (mThetaRangeIsSet || mEtaRangeIsSet) {
if (mPRangeIsSet) {
pz = pabs * TMath::Cos(theta);
pt = pabs * TMath::Sin(theta);
} else if (mPtRangeIsSet) {
pz = pt / TMath::Tan(theta);
}
}
px = pt * TMath::Cos(phi);
py = pt * TMath::Sin(phi);
double vx = 0., vy = 0., vz = 0.;
double etot = TMath::Sqrt(px * px + py * py + pz * pz + mass * mass);
return TParticle(mPDG, 1 /*status*/, -1 /* mother1 */, -1 /* mother2 */,
-1 /* daughter1 */, -1 /* daughter2 */, px, py, pz, etot, vx, vy, vz, 0. /*time*/);
}