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