Skip to content

Commit 649bf21

Browse files
cvilelahepkarabowi
authored andcommitted
feat(generators): Implement 3D box in FairBoxGenerator
With this commit, it is now possible to generate particles randomly within a 3D box. Previously, the depth of the box was hard-coded to zero and therefore it was only possible to generate particles within a rectangle in a plane.
1 parent 7d93ba4 commit 649bf21

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

fairroot/generators/FairBoxGenerator.cxx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -96,19 +96,36 @@ FairBoxGenerator::FairBoxGenerator(Int_t pdgid, Int_t mult)
9696
SetPhiRange();
9797
}
9898

99-
void FairBoxGenerator::SetXYZ(Double32_t x, Double32_t y, Double32_t z) { SetVertex(x, y, z, 0, 0, 0, kBox); }
99+
void FairBoxGenerator::SetXYZ(Double32_t x, Double32_t y, Double32_t z)
100+
{
101+
SetVertex(x, y, z, 0, 0, 0, kBox);
102+
}
100103

101104
void FairBoxGenerator::SetBoxXYZ(Double32_t x1, Double32_t y1, Double32_t x2, Double32_t y2, Double32_t z)
105+
{
106+
SetBoxXYZ(x1, y1, z, x2, y2, z);
107+
}
108+
109+
void FairBoxGenerator::SetBoxXYZ(Double32_t x1,
110+
Double32_t y1,
111+
Double32_t z1,
112+
Double32_t x2,
113+
Double32_t y2,
114+
Double32_t z2)
102115
{
103116
Double_t X1 = TMath::Min(x1, x2);
104117
Double_t X2 = TMath::Max(x1, x2);
105118
Double_t Y1 = TMath::Min(y1, y2);
106119
Double_t Y2 = TMath::Max(y1, y2);
120+
Double_t Z1 = TMath::Min(z1, z2);
121+
Double_t Z2 = TMath::Max(z1, z2);
107122
Double_t dX = 0.5 * (X2 - X1);
108123
Double_t dY = 0.5 * (Y2 - Y1);
124+
Double_t dZ = 0.5 * (Z2 - Z1);
109125
Double_t x = 0.5 * (X1 + X2);
110126
Double_t y = 0.5 * (Y1 + Y2);
111-
SetVertex(x, y, z, dX, dY, 0, kBox);
127+
Double_t z = 0.5 * (Z1 + Z2);
128+
SetVertex(x, y, z, dX, dY, dZ, kBox);
112129
}
113130

114131
Bool_t FairBoxGenerator::Init()

fairroot/generators/FairBoxGenerator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -112,6 +112,8 @@ class FairBoxGenerator : public FairBaseMCGenerator
112112

113113
void SetBoxXYZ(Double32_t x1 = 0, Double32_t y1 = 0, Double32_t x2 = 0, Double32_t y2 = 0, Double32_t z = 0);
114114

115+
void SetBoxXYZ(Double32_t x1, Double32_t y1, Double32_t z1, Double32_t x2, Double32_t y2, Double32_t z2);
116+
115117
/**
116118
* not used, for backward compatibility, please user FairLogger to set debug mode
117119
* @param

0 commit comments

Comments
 (0)