Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions r3bgen/R3BAsciiGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,14 @@ R3BAsciiGenerator::R3BAsciiGenerator()
, fFile()
, fBuf()
, fInput(&fBuf)
, fX(0.)
, fY(0.)
, fZ(0.)
, fPointVtxIsSet(false)
, fDX(0.)
, fDY(0.)
, fDZ(0.)
, fBoxVtxIsSet(false)
{
}

R3BAsciiGenerator::R3BAsciiGenerator(std::string fileName)
R3BAsciiGenerator::R3BAsciiGenerator(const std::string& fileName)
: fFileName(std::move(fileName))
, fFile()
, fBuf()
, fInput(&fBuf)
, fX(0.)
, fY(0.)
, fZ(0.)
, fPointVtxIsSet(false)
, fDX(0.)
, fDY(0.)
, fDZ(0.)
, fBoxVtxIsSet(false)
{
RegisterIons();
}
Expand All @@ -68,8 +52,6 @@ R3BAsciiGenerator::R3BAsciiGenerator(const char* fileName)
{
}

R3BAsciiGenerator::~R3BAsciiGenerator() {}

bool R3BAsciiGenerator::ReadEvent(FairPrimaryGenerator* primGen)
{
// Event variable to be read from file
Expand Down Expand Up @@ -265,4 +247,4 @@ void R3BAsciiGenerator::OpenOrRewindFile()
}
}

ClassImp(R3BAsciiGenerator);
ClassImp(R3BAsciiGenerator)
17 changes: 9 additions & 8 deletions r3bgen/R3BAsciiGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class R3BAsciiGenerator : public FairGenerator
/** Standard constructor.
** @param fileName The input file name
**/
explicit R3BAsciiGenerator(std::string fileName);
explicit R3BAsciiGenerator(const std::string& fileName);
explicit R3BAsciiGenerator(const TString& fileName);
explicit R3BAsciiGenerator(const char* fileName); // for old macros

/** Destructor. **/
~R3BAsciiGenerator() override;
// Destructor virtual
virtual ~R3BAsciiGenerator() = default;

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

void OpenOrRewindFile();

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

ClassDefOverride(R3BAsciiGenerator, 0);
public:
ClassDefOverride(R3BAsciiGenerator, 0); // NOLINT
};
117 changes: 39 additions & 78 deletions r3bgen/R3BCALIFATestGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,20 @@
******************************************************************************/

#include "R3BCALIFATestGenerator.h"
#include "R3BLogger.h"

#include "FairLogger.h"
#include "FairPrimaryGenerator.h"
#include <FairPrimaryGenerator.h>

#include "TDatabasePDG.h"
#include "TMath.h"
#include "TParticlePDG.h"
#include "TRandom.h"
#include <TDatabasePDG.h>
#include <TMath.h>
#include <TParticlePDG.h>
#include <TRandom.h>
#include <iomanip>
#include <iostream>
#include <sstream>

R3BCALIFATestGenerator::R3BCALIFATestGenerator()
: fPDGType(0)
, fMult(0)
, fPDGMass(0)
, fPtMin(0)
, fPtMax(0)
, fPhiMin(0)
, fPhiMax(0)
, fEtaMin(0)
, fEtaMax(0)
, fYMin(0)
, fYMax(0)
, fPMin(0)
, fPMax(0)
, fThetaMin(0)
, fThetaMax(0)
, fX(0)
, fY(0)
, fZ(0)
, fX1(0)
, fY1(0)
, fZ1(0)
, fX2(0)
, fY2(0)
, fZ2(0)
, fEtaRangeIsSet(0)
, fYRangeIsSet(0)
, fThetaRangeIsSet(0)
, fCosThetaIsSet(0)
, fPtRangeIsSet(0)
, fPRangeIsSet(0)
, fPointVtxIsSet(0)
, fBoxVtxIsSet(0)
, fDebug(0)
, fGammasDefinedInNuclearDecay(0)
, fBetaOfEmittingFragment(0)
, fGammaFactor(1)
, fLorentzBoostIsSet(0)
, fNuclearDecayChainIsSet(0)
: R3BCALIFATestGenerator(22, 1)
{
// Default constructor
}
Expand Down Expand Up @@ -111,38 +77,33 @@ R3BCALIFATestGenerator::R3BCALIFATestGenerator(Int_t pdgid, Int_t mult)
Bool_t R3BCALIFATestGenerator::Init()
{
// Initialize generator

if (fPhiMax - fPhiMin > 360)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: phi range is too wide: " << fPhiMin << "<phi<" << fPhiMax;
if (fPRangeIsSet && fPtRangeIsSet)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set P and Pt ranges simultaneously";
if (fPRangeIsSet && fYRangeIsSet)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set P and Y ranges simultaneously";
R3BLOG_IF(fatal, fPhiMax - fPhiMin > 360, "phi range is too wide: " << fPhiMin << "<phi<" << fPhiMax);
R3BLOG_IF(fatal, fPRangeIsSet && fPtRangeIsSet, "Cannot set P and Pt ranges simultaneously");
R3BLOG_IF(fatal, fPRangeIsSet && fYRangeIsSet, "Cannot set P and Y ranges simultaneously");
if ((fThetaRangeIsSet && fYRangeIsSet) || (fThetaRangeIsSet && fEtaRangeIsSet) || (fYRangeIsSet && fEtaRangeIsSet))
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set Y, Theta or Eta ranges simultaneously";
if (fPointVtxIsSet && fBoxVtxIsSet)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: Cannot set point and box vertices simultaneously";
{
R3BLOG(fatal, "Cannot set Y, Theta or Eta ranges simultaneously");
}
R3BLOG_IF(fatal, fPointVtxIsSet && fBoxVtxIsSet, "Cannot set point and box vertices simultaneously");

// CALIFA specifics
if (fBetaOfEmittingFragment > 1)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: beta of fragment larger than 1!";
R3BLOG_IF(fatal, fBetaOfEmittingFragment > 1, "beta of fragment larger than 1!");

Double32_t sumBranchingRatios = 0;
for (Int_t i = 0; i < fGammasDefinedInNuclearDecay; i++)
{
if (fGammaBranchingRatios[i] > 1)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: gamma branching ratio in position " << i
<< " larger than 1!";
{
R3BLOG(fatal, "gamma branching ratio in position " << i << " larger than 1!");
}
sumBranchingRatios += fGammaBranchingRatios[i];
}
if (sumBranchingRatios > 1)
LOG(fatal) << "Init(): R3BCALIFATestGenerator: gamma branching ratio sum larger than 1!";
R3BLOG_IF(fatal, sumBranchingRatios > 1, "gamma branching ratio sum larger than 1!");

// Check for particle type
TDatabasePDG* pdgBase = TDatabasePDG::Instance();
TParticlePDG* particle = pdgBase->GetParticle(fPDGType);
if (!particle)
LOG(fatal) << "R3BCALIFATestGenerator: PDG code " << fPDGType << " not defined.";
R3BLOG_IF(fatal, !particle, "PDG code " << fPDGType << " not defined.");
fPDGMass = particle->Mass();
return kTRUE;
}
Expand All @@ -157,7 +118,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)

Double32_t pabs = 0, phi, pt = 0, theta = 0, eta, y, mt, px, py, pz = 0;
Double32_t br = 0;
Bool_t doNotBoost = 0;
bool doNotBoost = false;

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

if (fNuclearDecayChainIsSet)
{
if (fPDGType != 22)
LOG(fatal) << "R3BCALIFATestGenerator: PDG code " << fPDGType << " is not a gamma!";
LOG_IF(fatal, fPDGType != 22) << "PDG code " << fPDGType << " is not a gamma!";
br = gRandom->Uniform();
for (Int_t i = 0; i < fGammasDefinedInNuclearDecay; i++)
{
Expand All @@ -226,7 +186,7 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
}
}
// if Sum(branchingRatios)<1, the leftover probability (up to 1) is defined as environmental noise
doNotBoost = 1;
doNotBoost = true;
}
/*
if (fLorentzBoostIsSet && !doNotBoost){
Expand Down Expand Up @@ -256,24 +216,24 @@ Bool_t R3BCALIFATestGenerator::ReadEvent(FairPrimaryGenerator* primGen)
}

if (fDebug)
printf("CALIFATestGen: kf=%d, p=(%.2f, %.2f, %.2f) GeV, x=(%.1f, %.1f, %.1f) cm\n",
fPDGType,
px,
py,
pz,
fX,
fY,
fZ);
{
std::ostringstream oss;
oss << "CALIFATestGen: kf=" << fPDGType << ", p=(" << std::fixed << std::setprecision(2) << px << ", " << py
<< ", " << pz << ") GeV"
<< ", x=(" << std::setprecision(1) << fX << ", " << fY << ", " << fZ << ") cm";

std::cout << oss.str() << std::endl;
}
primGen->AddTrack(fPDGType, px, py, pz, fX, fY, fZ);
}
return kTRUE;
}

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

Expand All @@ -283,13 +243,14 @@ void R3BCALIFATestGenerator::SetDecayChainPoint(Double32_t gammaEnergy, Double32
//
//
if (fGammasDefinedInNuclearDecay > 7)
printf("CALIFATestGen: Maximum number (8) of gammas defined in the chain\n");
{
R3BLOG(error, "Maximum number (8) of gammas defined in the chain\n");
}
else
{
fGammaEnergies[fGammasDefinedInNuclearDecay] = gammaEnergy;
fGammaBranchingRatios[fGammasDefinedInNuclearDecay] = branchingRatio;
fGammasDefinedInNuclearDecay++;
}
}

ClassImp(R3BCALIFATestGenerator)
32 changes: 15 additions & 17 deletions r3bgen/R3BCALIFATestGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
* Derived from FairGenerator.
**/

#ifndef FAIR_CALIFATESTGENERATOR_H
#define FAIR_CALIFATESTGENERATOR_H
#pragma once

#include "FairGenerator.h"
#include <FairGenerator.h>

#include <iostream>

Expand All @@ -32,7 +31,7 @@ class FairPrimaryGenerator;
class R3BCALIFATestGenerator : public FairGenerator
{
public:
/** Default constructor. **/
// Default constructor
R3BCALIFATestGenerator();

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

/** Destructor **/
virtual ~R3BCALIFATestGenerator(){};
// Destructor
virtual ~R3BCALIFATestGenerator() = default;

/** Modifiers **/
// Modifiers
void SetPDGType(Int_t pdg) { fPDGType = pdg; };

void SetMultiplicity(Int_t mult) { fMult = mult; };
Expand Down Expand Up @@ -83,7 +82,7 @@ class R3BCALIFATestGenerator : public FairGenerator
fYRangeIsSet = kTRUE;
};

void SetThetaRange(Double32_t thetamin = 0, Double32_t thetamax = 90)
void SetThetaRange(Double32_t thetamin = 0, Double32_t thetamax = 180)
{
fThetaMin = thetamin;
fThetaMax = thetamax;
Expand Down Expand Up @@ -124,19 +123,19 @@ class R3BCALIFATestGenerator : public FairGenerator
fLorentzBoostIsSet = kTRUE;
};

void SetFragmentVelocity(Double32_t beta = 0);
void SetFragmentVelocity(double beta = 0., double dispersion = 0.);

void SetNuclearDecayChain() { fNuclearDecayChainIsSet = kTRUE; };

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

/** Initializer **/
virtual Bool_t Init();
Bool_t Init() override;

/** Creates an event with given type and multiplicity.
**@param primGen pointer to the FairPrimaryGenerator
**@param primGen pointer to the FairPrimaryGenerator
**/
virtual Bool_t ReadEvent(FairPrimaryGenerator* primGen);
Bool_t ReadEvent(FairPrimaryGenerator* primGen) override;

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

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

ClassDef(R3BCALIFATestGenerator, 1);
public:
ClassDefOverride(R3BCALIFATestGenerator, 1); // NOLINT
};

#endif
12 changes: 5 additions & 7 deletions r3bgen/R3BCosmicGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
* Derived from R3BGenerator.
**/

#ifndef R3B_COSMICGENERATOR_H
#define R3B_COSMICGENERATOR_H
#pragma once

#include "R3BDistribution.h"

#include "FairGenerator.h"
#include <FairGenerator.h>

#include "TRandom3.h"
#include <TRandom3.h>

#include <iostream>

Expand Down Expand Up @@ -77,7 +76,6 @@ class R3BCosmicGenerator : public FairGenerator

Double_t fPDGMass; // Particle mass [GeV]

ClassDefOverride(R3BCosmicGenerator, 2)
public:
ClassDefOverride(R3BCosmicGenerator, 2);
};

#endif
Loading
Loading