Skip to content

Commit 4d01608

Browse files
committed
feat(r3bgen):Solved some compilation issues with the event generators
Added dispersion for incoming beta Minor change for R3BLOG
1 parent 98263f7 commit 4d01608

11 files changed

Lines changed: 110 additions & 199 deletions

r3bgen/R3BAsciiGenerator.cxx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,14 @@ R3BAsciiGenerator::R3BAsciiGenerator()
3030
, fFile()
3131
, fBuf()
3232
, fInput(&fBuf)
33-
, fX(0.)
34-
, fY(0.)
35-
, fZ(0.)
36-
, fPointVtxIsSet(false)
37-
, fDX(0.)
38-
, fDY(0.)
39-
, fDZ(0.)
40-
, fBoxVtxIsSet(false)
4133
{
4234
}
4335

44-
R3BAsciiGenerator::R3BAsciiGenerator(std::string fileName)
36+
R3BAsciiGenerator::R3BAsciiGenerator(const std::string& fileName)
4537
: fFileName(std::move(fileName))
4638
, fFile()
4739
, fBuf()
4840
, fInput(&fBuf)
49-
, fX(0.)
50-
, fY(0.)
51-
, fZ(0.)
52-
, fPointVtxIsSet(false)
53-
, fDX(0.)
54-
, fDY(0.)
55-
, fDZ(0.)
56-
, fBoxVtxIsSet(false)
5741
{
5842
RegisterIons();
5943
}
@@ -68,8 +52,6 @@ R3BAsciiGenerator::R3BAsciiGenerator(const char* fileName)
6852
{
6953
}
7054

71-
R3BAsciiGenerator::~R3BAsciiGenerator() {}
72-
7355
bool R3BAsciiGenerator::ReadEvent(FairPrimaryGenerator* primGen)
7456
{
7557
// Event variable to be read from file
@@ -265,4 +247,4 @@ void R3BAsciiGenerator::OpenOrRewindFile()
265247
}
266248
}
267249

268-
ClassImp(R3BAsciiGenerator);
250+
ClassImp(R3BAsciiGenerator)

r3bgen/R3BAsciiGenerator.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ class R3BAsciiGenerator : public FairGenerator
3232
/** Standard constructor.
3333
** @param fileName The input file name
3434
**/
35-
explicit R3BAsciiGenerator(std::string fileName);
35+
explicit R3BAsciiGenerator(const std::string& fileName);
3636
explicit R3BAsciiGenerator(const TString& fileName);
3737
explicit R3BAsciiGenerator(const char* fileName); // for old macros
3838

39-
/** Destructor. **/
40-
~R3BAsciiGenerator() override;
39+
// Destructor virtual
40+
virtual ~R3BAsciiGenerator() = default;
4141

4242
/** Reads on event from the input file and pushes the tracks onto
4343
** the stack. Abstract method in base class.
@@ -61,10 +61,11 @@ class R3BAsciiGenerator : public FairGenerator
6161

6262
void OpenOrRewindFile();
6363

64-
Double32_t fX, fY, fZ; // Point vertex coordinates [cm]
65-
bool fPointVtxIsSet; // True if point vertex is set
66-
Double32_t fDX, fDY, fDZ; // Point vertex coordinates [cm]
67-
bool fBoxVtxIsSet; // True if point vertex is set
64+
Double32_t fX = 0., fY = 0., fZ = 0.; // Point vertex coordinates [cm]
65+
bool fPointVtxIsSet = false; // True if point vertex is set
66+
Double32_t fDX = 0., fDY = 0., fDZ = 0.; // Point vertex coordinates [cm]
67+
bool fBoxVtxIsSet = false; // True if point vertex is set
6868

69-
ClassDefOverride(R3BAsciiGenerator, 0);
69+
public:
70+
ClassDefOverride(R3BAsciiGenerator, 0); // NOLINT
7071
};

r3bgen/R3BCALIFATestGenerator.cxx

Lines changed: 39 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,20 @@
1212
******************************************************************************/
1313

1414
#include "R3BCALIFATestGenerator.h"
15+
#include "R3BLogger.h"
1516

16-
#include "FairLogger.h"
17-
#include "FairPrimaryGenerator.h"
17+
#include <FairPrimaryGenerator.h>
1818

19-
#include "TDatabasePDG.h"
20-
#include "TMath.h"
21-
#include "TParticlePDG.h"
22-
#include "TRandom.h"
19+
#include <TDatabasePDG.h>
20+
#include <TMath.h>
21+
#include <TParticlePDG.h>
22+
#include <TRandom.h>
23+
#include <iomanip>
24+
#include <iostream>
25+
#include <sstream>
2326

2427
R3BCALIFATestGenerator::R3BCALIFATestGenerator()
25-
: fPDGType(0)
26-
, fMult(0)
27-
, fPDGMass(0)
28-
, fPtMin(0)
29-
, fPtMax(0)
30-
, fPhiMin(0)
31-
, fPhiMax(0)
32-
, fEtaMin(0)
33-
, fEtaMax(0)
34-
, fYMin(0)
35-
, fYMax(0)
36-
, fPMin(0)
37-
, fPMax(0)
38-
, fThetaMin(0)
39-
, fThetaMax(0)
40-
, fX(0)
41-
, fY(0)
42-
, fZ(0)
43-
, fX1(0)
44-
, fY1(0)
45-
, fZ1(0)
46-
, fX2(0)
47-
, fY2(0)
48-
, fZ2(0)
49-
, fEtaRangeIsSet(0)
50-
, fYRangeIsSet(0)
51-
, fThetaRangeIsSet(0)
52-
, fCosThetaIsSet(0)
53-
, fPtRangeIsSet(0)
54-
, fPRangeIsSet(0)
55-
, fPointVtxIsSet(0)
56-
, fBoxVtxIsSet(0)
57-
, fDebug(0)
58-
, fGammasDefinedInNuclearDecay(0)
59-
, fBetaOfEmittingFragment(0)
60-
, fGammaFactor(1)
61-
, fLorentzBoostIsSet(0)
62-
, fNuclearDecayChainIsSet(0)
28+
: R3BCALIFATestGenerator(22, 1)
6329
{
6430
// Default constructor
6531
}
@@ -111,38 +77,33 @@ R3BCALIFATestGenerator::R3BCALIFATestGenerator(Int_t pdgid, Int_t mult)
11177
Bool_t R3BCALIFATestGenerator::Init()
11278
{
11379
// Initialize generator
114-
115-
if (fPhiMax - fPhiMin > 360)
116-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: phi range is too wide: " << fPhiMin << "<phi<" << fPhiMax;
117-
if (fPRangeIsSet && fPtRangeIsSet)
118-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set P and Pt ranges simultaneously";
119-
if (fPRangeIsSet && fYRangeIsSet)
120-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set P and Y ranges simultaneously";
80+
R3BLOG_IF(fatal, fPhiMax - fPhiMin > 360, "phi range is too wide: " << fPhiMin << "<phi<" << fPhiMax);
81+
R3BLOG_IF(fatal, fPRangeIsSet && fPtRangeIsSet, "Cannot set P and Pt ranges simultaneously");
82+
R3BLOG_IF(fatal, fPRangeIsSet && fYRangeIsSet, "Cannot set P and Y ranges simultaneously");
12183
if ((fThetaRangeIsSet && fYRangeIsSet) || (fThetaRangeIsSet && fEtaRangeIsSet) || (fYRangeIsSet && fEtaRangeIsSet))
122-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set Y, Theta or Eta ranges simultaneously";
123-
if (fPointVtxIsSet && fBoxVtxIsSet)
124-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set point and box vertices simultaneously";
84+
{
85+
R3BLOG(fatal, "Cannot set Y, Theta or Eta ranges simultaneously");
86+
}
87+
R3BLOG_IF(fatal, fPointVtxIsSet && fBoxVtxIsSet, "Cannot set point and box vertices simultaneously");
12588

12689
// CALIFA specifics
127-
if (fBetaOfEmittingFragment > 1)
128-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: beta of fragment larger than 1!";
90+
R3BLOG_IF(fatal, fBetaOfEmittingFragment > 1, "beta of fragment larger than 1!");
12991

13092
Double32_t sumBranchingRatios = 0;
13193
for (Int_t i = 0; i < fGammasDefinedInNuclearDecay; i++)
13294
{
13395
if (fGammaBranchingRatios[i] > 1)
134-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: gamma branching ratio in position " << i
135-
<< " larger than 1!";
96+
{
97+
R3BLOG(fatal, "gamma branching ratio in position " << i << " larger than 1!");
98+
}
13699
sumBranchingRatios += fGammaBranchingRatios[i];
137100
}
138-
if (sumBranchingRatios > 1)
139-
LOG(fatal) << "Init(): R3BCALIFATestGenerator: gamma branching ratio sum larger than 1!";
101+
R3BLOG_IF(fatal, sumBranchingRatios > 1, "gamma branching ratio sum larger than 1!");
140102

141103
// Check for particle type
142104
TDatabasePDG* pdgBase = TDatabasePDG::Instance();
143105
TParticlePDG* particle = pdgBase->GetParticle(fPDGType);
144-
if (!particle)
145-
LOG(fatal) << "R3BCALIFATestGenerator: PDG code " << fPDGType << " not defined.";
106+
R3BLOG_IF(fatal, !particle, "PDG code " << fPDGType << " not defined.");
146107
fPDGMass = particle->Mass();
147108
return kTRUE;
148109
}
@@ -157,7 +118,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
157118

158119
Double32_t pabs = 0, phi, pt = 0, theta = 0, eta, y, mt, px, py, pz = 0;
159120
Double32_t br = 0;
160-
Bool_t doNotBoost = 0;
121+
bool doNotBoost = false;
161122

162123
// Generate particles
163124
for (Int_t k = 0; k < fMult; k++)
@@ -211,8 +172,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
211172

212173
if (fNuclearDecayChainIsSet)
213174
{
214-
if (fPDGType != 22)
215-
LOG(fatal) << "R3BCALIFATestGenerator: PDG code " << fPDGType << " is not a gamma!";
175+
LOG_IF(fatal, fPDGType != 22) << "PDG code " << fPDGType << " is not a gamma!";
216176
br = gRandom->Uniform();
217177
for (Int_t i = 0; i < fGammasDefinedInNuclearDecay; i++)
218178
{
@@ -226,7 +186,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
226186
}
227187
}
228188
// if Sum(branchingRatios)<1, the leftover probability (up to 1) is defined as environmental noise
229-
doNotBoost = 1;
189+
doNotBoost = true;
230190
}
231191
/*
232192
if (fLorentzBoostIsSet && !doNotBoost){
@@ -256,24 +216,24 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
256216
}
257217

258218
if (fDebug)
259-
printf("CALIFATestGen: kf=%d, p=(%.2f, %.2f, %.2f) GeV, x=(%.1f, %.1f, %.1f) cm\n",
260-
fPDGType,
261-
px,
262-
py,
263-
pz,
264-
fX,
265-
fY,
266-
fZ);
219+
{
220+
std::ostringstream oss;
221+
oss << "CALIFATestGen: kf=" << fPDGType << ", p=(" << std::fixed << std::setprecision(2) << px << ", " << py
222+
<< ", " << pz << ") GeV"
223+
<< ", x=(" << std::setprecision(1) << fX << ", " << fY << ", " << fZ << ") cm";
267224

225+
std::cout << oss.str() << std::endl;
226+
}
268227
primGen->AddTrack(fPDGType, px, py, pz, fX, fY, fZ);
269228
}
270229
return kTRUE;
271230
}
272231

273-
void R3BCALIFATestGenerator::SetFragmentVelocity(Double32_t beta)
232+
void R3BCALIFATestGenerator::SetFragmentVelocity(double beta, double dispersion)
274233
{
275234
// Sets the velocity and gamma factor of the fragment emitting the gammas
276-
fBetaOfEmittingFragment = beta;
235+
R3BLOG(info, "Set a beta of " << beta << " with a sigma dispersion of " << dispersion);
236+
fBetaOfEmittingFragment = gRandom->Gaus(beta, dispersion);
277237
fGammaFactor = TMath::Sqrt(1 - fBetaOfEmittingFragment * fBetaOfEmittingFragment);
278238
}
279239

@@ -283,13 +243,14 @@ void R3BCALIFATestGenerator::SetDecayChainPoint(Double32_t gammaEnergy, Double32
283243
//
284244
//
285245
if (fGammasDefinedInNuclearDecay > 7)
286-
printf("CALIFATestGen: Maximum number (8) of gammas defined in the chain\n");
246+
{
247+
R3BLOG(error, "Maximum number (8) of gammas defined in the chain\n");
248+
}
287249
else
288250
{
289251
fGammaEnergies[fGammasDefinedInNuclearDecay] = gammaEnergy;
290252
fGammaBranchingRatios[fGammasDefinedInNuclearDecay] = branchingRatio;
291253
fGammasDefinedInNuclearDecay++;
292254
}
293255
}
294-
295256
ClassImp(R3BCALIFATestGenerator)

r3bgen/R3BCALIFATestGenerator.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
* Derived from FairGenerator.
2121
**/
2222

23-
#ifndef FAIR_CALIFATESTGENERATOR_H
24-
#define FAIR_CALIFATESTGENERATOR_H
23+
#pragma once
2524

26-
#include "FairGenerator.h"
25+
#include <FairGenerator.h>
2726

2827
#include <iostream>
2928

@@ -32,7 +31,7 @@ class FairPrimaryGenerator;
3231
class R3BCALIFATestGenerator : public FairGenerator
3332
{
3433
public:
35-
/** Default constructor. **/
34+
// Default constructor
3635
R3BCALIFATestGenerator();
3736

3837
/** Constructor with PDG-ID, multiplicity
@@ -41,10 +40,10 @@ class R3BCALIFATestGenerator : public FairGenerator
4140
**/
4241
R3BCALIFATestGenerator(Int_t pdgid, Int_t mult = 1);
4342

44-
/** Destructor **/
45-
virtual ~R3BCALIFATestGenerator(){};
43+
// Destructor
44+
virtual ~R3BCALIFATestGenerator() = default;
4645

47-
/** Modifiers **/
46+
// Modifiers
4847
void SetPDGType(Int_t pdg) { fPDGType = pdg; };
4948

5049
void SetMultiplicity(Int_t mult) { fMult = mult; };
@@ -83,7 +82,7 @@ class R3BCALIFATestGenerator : public FairGenerator
8382
fYRangeIsSet = kTRUE;
8483
};
8584

86-
void SetThetaRange(Double32_t thetamin = 0, Double32_t thetamax = 90)
85+
void SetThetaRange(Double32_t thetamin = 0, Double32_t thetamax = 180)
8786
{
8887
fThetaMin = thetamin;
8988
fThetaMax = thetamax;
@@ -124,19 +123,19 @@ class R3BCALIFATestGenerator : public FairGenerator
124123
fLorentzBoostIsSet = kTRUE;
125124
};
126125

127-
void SetFragmentVelocity(Double32_t beta = 0);
126+
void SetFragmentVelocity(double beta = 0., double dispersion = 0.);
128127

129128
void SetNuclearDecayChain() { fNuclearDecayChainIsSet = kTRUE; };
130129

131130
void SetDecayChainPoint(Double32_t gammaEnergy = 0, Double32_t branchingRatio = 0);
132131

133132
/** Initializer **/
134-
virtual Bool_t Init();
133+
Bool_t Init() override;
135134

136135
/** Creates an event with given type and multiplicity.
137-
**@param primGen pointer to the FairPrimaryGenerator
136+
**@param primGen pointer to the FairPrimaryGenerator
138137
**/
139-
virtual Bool_t ReadEvent(FairPrimaryGenerator* primGen);
138+
Bool_t ReadEvent(FairPrimaryGenerator* primGen) override;
140139

141140
private:
142141
Int_t fPDGType; // Particle type (PDG encoding)
@@ -167,13 +166,12 @@ class R3BCALIFATestGenerator : public FairGenerator
167166
Double32_t fGammaEnergies[8]; // Gamma energies for the nuclear decay chain [GeV] TEST UNITS!
168167
Double32_t fGammaBranchingRatios[8]; // Gamma branching ratios for the nuclear decay chain
169168
Int_t fGammasDefinedInNuclearDecay; // Number of gammas defined (max 8)
170-
Double32_t fBetaOfEmittingFragment; // Velocity of the fragment emitting the gammas
171-
Double32_t fGammaFactor; // Velocity of the fragment emitting the gammas
169+
double fBetaOfEmittingFragment; // Velocity of the fragment emitting the gammas
170+
double fGammaFactor; // Velocity of the fragment emitting the gammas
172171

173172
Bool_t fLorentzBoostIsSet; // True if Lorentz Boost is set
174173
Bool_t fNuclearDecayChainIsSet; // True if a nuclear decay chain is set
175174

176-
ClassDef(R3BCALIFATestGenerator, 1);
175+
public:
176+
ClassDefOverride(R3BCALIFATestGenerator, 1); // NOLINT
177177
};
178-
179-
#endif

r3bgen/R3BCosmicGenerator.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
* Derived from R3BGenerator.
2626
**/
2727

28-
#ifndef R3B_COSMICGENERATOR_H
29-
#define R3B_COSMICGENERATOR_H
28+
#pragma once
3029

3130
#include "R3BDistribution.h"
3231

33-
#include "FairGenerator.h"
32+
#include <FairGenerator.h>
3433

35-
#include "TRandom3.h"
34+
#include <TRandom3.h>
3635

3736
#include <iostream>
3837

@@ -77,7 +76,6 @@ class R3BCosmicGenerator : public FairGenerator
7776

7877
Double_t fPDGMass; // Particle mass [GeV]
7978

80-
ClassDefOverride(R3BCosmicGenerator, 2)
79+
public:
80+
ClassDefOverride(R3BCosmicGenerator, 2);
8181
};
82-
83-
#endif

0 commit comments

Comments
 (0)