FairShip
Loading...
Searching...
No Matches
ParticleGunGenerator Class Reference

#include <ParticleGunGenerator.h>

Inheritance diagram for ParticleGunGenerator:
[legend]
Collaboration diagram for ParticleGunGenerator:
[legend]

Classes

struct  HistoEntry

Public Member Functions

 ParticleGunGenerator ()
 ParticleGunGenerator (Int_t pdgid, Int_t mult=1)
 ~ParticleGunGenerator () override
void SetPRange (Double32_t pmin=0, Double32_t pmax=10)
void SetPtRange (Double32_t ptmin=0, Double32_t ptmax=10)
void SetEkinRange (Double32_t kmin=0, Double32_t kmax=10)
void SetPhiRange (Double32_t phimin=0, Double32_t phimax=360)
void SetEtaRange (Double32_t etamin=-5, Double32_t etamax=7)
void SetYRange (Double32_t ymin=-5, Double32_t ymax=7)
void SetThetaRange (Double32_t thetamin=0, Double32_t thetamax=90)
void SetCosTheta ()
void SetBothCharges (bool flag, Double32_t fraction=0.5)
void SetPDGType (int pdgid)
void SetMultiplicity (int mult)
void SetCommonVertex (bool flag)
 Give all particles of an event the same vertex, drawn once per event.
int GenPDGType () const
int GetMultiplicity ()
void LoadHistoFromFile (const std::string &inFile, const std::string &inHisto, std::vector< std::string > varNames)
Double32_t GetPDGMass ()
void SetDebug (Bool_t)
Bool_t Init () override
Bool_t Init (const char *inFile) override
Bool_t Init (const char *inFile, int startEvent) override
Bool_t ReadEvent (FairPrimaryGenerator *primGen) override
FairGenerator * CloneGenerator () const override
void SetVertexModel (const std::string &model, std::vector< Double32_t > pars)
void SetMomentumModel (const int modelNo, std::vector< Double32_t > pars)
void PrintMomentumModels ()
void PrintVertexModels ()
virtual Bool_t Init (const std::vector< std::string > &inFiles, int startNumber)
virtual Bool_t Init (const std::vector< std::string > &inFiles)
Public Member Functions inherited from SHiP::Generator
 Generator ()=default
 ~Generator () override
virtual void UseExternalFile (std::string x, Int_t i)
virtual void UseExternalFile (std::vector< std::string > &inFiles, Int_t i)
void SetMaxTheta (Double_t thetaX, Double_t thetaY)
Int_t nrOfGeoRejections () const
Long64_t GetCounter (const std::string &name) const
void SetCounter (const std::string &name, Long64_t value)
void IncrementCounter (const std::string &name, Long64_t delta=1)

Protected Member Functions

 ParticleGunGenerator (const ParticleGunGenerator &)=default
ParticleGunGenerator & operator= (const ParticleGunGenerator &)=default
Protected Member Functions inherited from SHiP::Generator
bool IsInVesselAcceptance (Double_t px, Double_t py, Double_t pz) const

Private Member Functions

void GenVertexModel (ParticleGunParticle &p)
void GenMomentumModel (ParticleGunParticle &p)
ParticleGunParticle GenerateKinematics ()
void OverrideFromHistogram (ParticleGunParticle &p)
Double32_t & GetVar (ParticleGunParticle &p, const std::string &name)
void SetVar (ParticleGunParticle &p, const std::string &name, Double32_t value)

Private Attributes

Double32_t fPtMin {0}
Double32_t fPtMax {0}
Double32_t fPhiMin {0}
Double32_t fPhiMax {0}
Double32_t fEtaMin {0}
Double32_t fEtaMax {0}
Double32_t fYMin {0}
Double32_t fYMax {0}
Double32_t fPMin {0}
Double32_t fPMax {0}
Double32_t fThetaMin {0}
Double32_t fThetaMax {0}
Double32_t fEkinMin {0}
Double32_t fEkinMax {0}
Double32_t fVx {0}
Double32_t fVy {0}
Double32_t fVz {0}
Double32_t fVex {0}
Double32_t fVey {0}
Double32_t fVez {0}
Double32_t fPDGMass {0}
bool m_bothCharges {false}
Double32_t m_chargeFraction {1.}
std::vector< HistoEntry > fHistoEntries
Bool_t fEtaRangeIsSet {false}
Bool_t fYRangeIsSet {false}
Bool_t fThetaRangeIsSet {false}
Bool_t fCosThetaIsSet {false}
Bool_t fPtRangeIsSet {false}
Bool_t fPRangeIsSet {false}
Bool_t fEkinRangeIsSet {false}
int fMomentumModel {0}
std::string fVertexModel = "gaussian"
std::vector< Double32_t > fMomentumPars
std::vector< Double32_t > fVertexPars
int m_mult {1}
bool m_commonVertex {false}
int m_pdgid {0}

Additional Inherited Members

Protected Attributes inherited from SHiP::Generator
std::optional< std::string > fextFile
Int_t firstEvent = 0
Double_t fMaxThetaX = 0
Double_t fMaxThetaY = 0
bool fUseVesselAcceptance = false
Int_t fnGeoRejects = 0
std::unordered_map< std::string, int64_t > fCounters

Detailed Description

Definition at line 23 of file ParticleGunGenerator.h.

Constructor & Destructor Documentation

◆ ParticleGunGenerator() [1/3]

ParticleGunGenerator::ParticleGunGenerator ( )

Default constructor.

Definition at line 86 of file ParticleGunGenerator.cxx.

86 : SHiP::Generator() {
88}
void SetPhiRange(Double32_t phimin=0, Double32_t phimax=360)

◆ ParticleGunGenerator() [2/3]

ParticleGunGenerator::ParticleGunGenerator ( Int_t pdgid,
Int_t mult = 1 )
explicit

Constructor with PDG-ID, multiplicity

Parameters
pdgidParticle type (PDG encoding)
multMultiplicity (default is 1)

Definition at line 90 of file ParticleGunGenerator.cxx.

91 : SHiP::Generator() {
92 // Constructor. Set default kinematics limits
93 SetPDGType(pdgid);
94 SetMultiplicity(mult);
96}

◆ ~ParticleGunGenerator()

ParticleGunGenerator::~ParticleGunGenerator ( )
overridedefault

Destructor

◆ ParticleGunGenerator() [3/3]

ParticleGunGenerator::ParticleGunGenerator ( const ParticleGunGenerator & )
protecteddefault

Copy constructor.

Member Function Documentation

◆ CloneGenerator()

FairGenerator * ParticleGunGenerator::CloneGenerator ( ) const
override

Clone this object (used in MT mode only)

Definition at line 453 of file ParticleGunGenerator.cxx.

453 {
454 auto* clone = new ParticleGunGenerator(*this);
455 for (auto& entry : clone->fHistoEntries) {
456 entry.hist.reset(static_cast<TH1*>(entry.hist->Clone()));
457 entry.hist->SetDirectory(nullptr);
458 }
459 return clone;
460}

◆ GenerateKinematics()

ParticleGunParticle ParticleGunGenerator::GenerateKinematics ( )
private

Definition at line 280 of file ParticleGunGenerator.cxx.

280 {
281 ParticleGunParticle p;
282 // --- Vertex smearing ---
284 if (fMomentumModel > 0)
286 else {
287 Double32_t pabs = 0, pt = 0, theta = 0, eta, y, mt, pz = 0;
288 // Generate particles
289 const Double32_t phi =
290 gRandom->Uniform(fPhiMin, fPhiMax) * TMath::DegToRad();
291
292 if (fPRangeIsSet) {
293 pabs = gRandom->Uniform(fPMin, fPMax);
294 } else if (fPtRangeIsSet) {
295 pt = gRandom->Uniform(fPtMin, fPtMax);
296 }
297
298 if (fThetaRangeIsSet) {
299 if (fCosThetaIsSet)
300 theta = acos(gRandom->Uniform(cos(fThetaMax * TMath::DegToRad()),
301 cos(fThetaMin * TMath::DegToRad())));
302 else {
303 theta = gRandom->Uniform(fThetaMin, fThetaMax) * TMath::DegToRad();
304 }
305 } else if (fEtaRangeIsSet) {
306 eta = gRandom->Uniform(fEtaMin, fEtaMax);
307 theta = 2 * TMath::ATan(TMath::Exp(-eta));
308 } else if (fYRangeIsSet) {
309 y = gRandom->Uniform(fYMin, fYMax);
310 mt = TMath::Sqrt(GetPDGMass() * GetPDGMass() + pt * pt);
311 pz = mt * TMath::SinH(y);
312 }
313
315 if (fPRangeIsSet) {
316 pz = pabs * TMath::Cos(theta);
317 pt = pabs * TMath::Sin(theta);
318 } else if (fPtRangeIsSet) {
319 pz = pt / TMath::Tan(theta);
320 }
321 } else if (fPRangeIsSet) {
322 pz = pabs;
323 }
324 p.Px = pt * TMath::Cos(phi);
325 p.Py = pt * TMath::Sin(phi);
326 p.Pz = pz;
327 }
328 return p;
329}
void GenVertexModel(ParticleGunParticle &p)
void GenMomentumModel(ParticleGunParticle &p)

◆ GenMomentumModel()

void ParticleGunGenerator::GenMomentumModel ( ParticleGunParticle & p)
private

Definition at line 416 of file ParticleGunGenerator.cxx.

416 {
417 kMomentumModels().at(fMomentumModel).generate(p, fMomentumPars);
418}
std::vector< Double32_t > fMomentumPars

◆ GenPDGType()

int ParticleGunGenerator::GenPDGType ( ) const

Definition at line 251 of file ParticleGunGenerator.cxx.

251 {
252 if (m_bothCharges) {
253 float tPDG = gRandom->Uniform();
254 return (tPDG > m_chargeFraction) ? -m_pdgid : m_pdgid;
255 } else
256 return m_pdgid;
257}

◆ GenVertexModel()

void ParticleGunGenerator::GenVertexModel ( ParticleGunParticle & p)
private

Definition at line 412 of file ParticleGunGenerator.cxx.

412 {
413 kVertexModels().at(fVertexModel).generate(p, fVertexPars);
414}
std::vector< Double32_t > fVertexPars

◆ GetMultiplicity()

int ParticleGunGenerator::GetMultiplicity ( )
inline

Definition at line 89 of file ParticleGunGenerator.h.

◆ GetPDGMass()

Double32_t ParticleGunGenerator::GetPDGMass ( )
inline

Definition at line 94 of file ParticleGunGenerator.h.

94{ return fPDGMass; };

◆ GetVar()

Double32_t & ParticleGunGenerator::GetVar ( ParticleGunParticle & p,
const std::string & name )
private

Definition at line 434 of file ParticleGunGenerator.cxx.

435 {
436 if (name == "X") return p.X;
437 if (name == "Y") return p.Y;
438 if (name == "Z") return p.Z;
439 if (name == "Px") return p.Px;
440 if (name == "Py") return p.Py;
441 if (name == "Pz") return p.Pz;
442 LOG(fatal) << "ParticleGunGenerator: unknown variable name '" << name << "'";
443 throw std::runtime_error("ParticleGunGenerator: unknown variable name '" +
444 name + "'");
445 return p.X; // unreachable, silences compiler warning
446}

◆ Init() [1/5]

Bool_t ParticleGunGenerator::Init ( )
override

Definition at line 163 of file ParticleGunGenerator.cxx.

163 {
164 const auto& vertexSpec = kVertexModels().at(fVertexModel);
165
166 if (static_cast<int>(fVertexPars.size()) != vertexSpec.expectedPars) {
167 throw std::runtime_error(
168 "ParticleGunGenerator: vertex model " + fVertexModel + " requires " +
169 std::to_string(vertexSpec.expectedPars) + " parameters, got " +
170 std::to_string(fVertexPars.size()));
171 }
172
173 // Check for particle type
174 TDatabasePDG* pdgBase = TDatabasePDG::Instance();
175 TParticlePDG* particle = pdgBase->GetParticle(m_pdgid);
176
177 if (!particle) {
178 LOG(fatal) << "ParticleGunGenerator: PDG " << m_pdgid << " not defined";
179 return kFALSE;
180 }
181 LOG(info) << this->ClassName() << ": particle with PDG =" << m_pdgid
182 << " Found";
183 fPDGMass = particle->Mass();
184
185 if (fPhiMax - fPhiMin > 360) {
186 LOG(fatal) << "ParticleGunGenerator:Init(): phi range is too wide: "
187 << fPhiMin << "<phi<" << fPhiMax;
188 return kFALSE;
189 }
190 if (fEkinRangeIsSet) {
191 if (fPRangeIsSet) {
192 LOG(fatal) << "ParticleGunGenerator:Init(): Cannot set P and Ekin ranges "
193 "simultaneously";
194 return kFALSE;
195 } else {
196 fPMin = TMath::Sqrt(fEkinMin * (fEkinMin + 2 * fPDGMass));
197 fPMax = TMath::Sqrt(fEkinMax * (fEkinMax + 2 * fPDGMass));
198 fPRangeIsSet = kTRUE;
199 fEkinRangeIsSet = kFALSE;
200 }
201 }
203 LOG(fatal) << "ParticleGunGenerator:Init(): Cannot set P and Pt ranges "
204 "simultaneously";
205 return kFALSE;
206 }
207 if (fPRangeIsSet && fYRangeIsSet) {
208 LOG(fatal) << "ParticleGunGenerator:Init(): Cannot set P and Y ranges "
209 "simultaneously";
210 return kFALSE;
211 }
215 LOG(fatal) << "ParticleGunGenerator:Init(): Cannot set Y, Theta or Eta "
216 "ranges simultaneously";
217 return kFALSE;
218 }
219 return kTRUE;
220}

◆ Init() [2/5]

Bool_t ParticleGunGenerator::Init ( const char * inFile)
inlineoverridevirtual

Implements SHiP::Generator.

Definition at line 106 of file ParticleGunGenerator.h.

106{ return Init(inFile, 0); };

◆ Init() [3/5]

Bool_t ParticleGunGenerator::Init ( const char * inFile,
int startEvent )
inlineoverridevirtual

Implements SHiP::Generator.

Definition at line 108 of file ParticleGunGenerator.h.

108 {
109 LOG(warning) << "Init with files not implemented for ParticleGunGenerator. "
110 "Using default Init() instead";
111 return Init();
112 };

◆ Init() [4/5]

virtual Bool_t SHiP::Generator::Init ( const std::vector< std::string > & inFiles)
inlinevirtual

Initializer

Reimplemented from SHiP::Generator.

Definition at line 33 of file Generator.h.

33 {
34 LOG(warning) << "Multiple input files not implemented for this generator "
35 "- only taking the first!";
36 return Init(inFiles.at(0).c_str(), 0);
37 };

◆ Init() [5/5]

virtual Bool_t SHiP::Generator::Init ( const std::vector< std::string > & inFiles,
int startNumber )
inlinevirtual

Initializer

Reimplemented from SHiP::Generator.

Definition at line 27 of file Generator.h.

28 {
29 LOG(warning) << "Multiple input files not implemented for this generator "
30 "- only taking the first!";
31 return Init(inFiles.at(0).c_str(), startNumber);
32 };

◆ LoadHistoFromFile()

void ParticleGunGenerator::LoadHistoFromFile ( const std::string & inFile,
const std::string & inHisto,
std::vector< std::string > varNames )

Definition at line 100 of file ParticleGunGenerator.cxx.

102 {
103 TFile* loadFile = TFile::Open(inFile.c_str(), "READ");
104 if (!loadFile) {
105 delete loadFile;
106 LOG(fatal) << "ParticleGunGenerator: Cannot open file " << inFile;
107 throw std::runtime_error("ParticleGunGenerator: Cannot open file " +
108 inFile);
109 }
110
111 auto* raw = dynamic_cast<TH1*>(loadFile->Get(inHisto.c_str()));
112 if (!raw) {
113 loadFile->Close();
114 delete loadFile;
115 LOG(fatal) << "ParticleGunGenerator: Histogram " << inHisto
116 << " not found in file " << inFile;
117 throw std::runtime_error("ParticleGunGenerator: Histogram " + inHisto +
118 " not found in file " + inFile);
119 }
120 raw = static_cast<TH1*>(raw->Clone());
121 raw->SetDirectory(nullptr); // detach from ROOT's directory ownership
122 loadFile->Close();
123 delete loadFile;
124
125 const int dims = raw->GetDimension();
126 if (static_cast<int>(varNames.size()) != dims) {
127 LOG(fatal) << "ParticleGunGenerator: " << varNames.size()
128 << " variables given for a " << dims << "-D histogram";
129 throw std::runtime_error(
130 "ParticleGunGenerator: " + std::to_string(varNames.size()) +
131 " variables given for a " + std::to_string(dims) + "-D histogram");
132 } else {
133 ParticleGunParticle probe;
134 for (const auto& name : varNames) {
135 static_cast<void>(GetVar(probe, name));
136 }
137 }
138
139 // Check for variable name conflicts with already-loaded histograms
140 for (const auto& name : varNames) {
141 for (const auto& entry : fHistoEntries) {
142 for (const auto& existing : entry.varNames) {
143 if (existing == name) {
144 LOG(fatal)
145 << "ParticleGunGenerator: variable \"" << name
146 << "\" is already controlled by a previously loaded histogram";
147 throw std::runtime_error(
148 "ParticleGunGenerator: variable \"" + name +
149 "\" is already controlled by a previously loaded histogram");
150 }
151 }
152 }
153 }
154
155 fHistoEntries.push_back(
156 {std::shared_ptr<TH1>(raw), dims, std::move(varNames)});
157
158 LOG(info) << "ParticleGunGenerator: loaded " << dims << "-D histogram \""
159 << inHisto << "\" from " << inFile << " (" << fHistoEntries.size()
160 << " total)";
161}
std::vector< HistoEntry > fHistoEntries
Double32_t & GetVar(ParticleGunParticle &p, const std::string &name)

◆ operator=()

ParticleGunGenerator & ParticleGunGenerator::operator= ( const ParticleGunGenerator & )
protecteddefault

◆ OverrideFromHistogram()

void ParticleGunGenerator::OverrideFromHistogram ( ParticleGunParticle & p)
private

Definition at line 331 of file ParticleGunGenerator.cxx.

331 {
332 for (const auto& entry : fHistoEntries) {
333 switch (entry.dims) {
334 case 1:
335 SetVar(p, entry.varNames[0],
336 static_cast<TH1*>(entry.hist.get())->GetRandom());
337 break;
338 case 2:
339 static_cast<TH2*>(entry.hist.get())
340 ->GetRandom2(GetVar(p, entry.varNames[0]),
341 GetVar(p, entry.varNames[1]));
342 break;
343 case 3:
344 static_cast<TH3*>(entry.hist.get())
345 ->GetRandom3(GetVar(p, entry.varNames[0]),
346 GetVar(p, entry.varNames[1]),
347 GetVar(p, entry.varNames[2]));
348 break;
349 default:
350 LOG(error) << "ParticleGunGenerator: unsupported histogram dimension "
351 << entry.dims;
352 }
353 }
354}
void SetVar(ParticleGunParticle &p, const std::string &name, Double32_t value)

◆ PrintMomentumModels()

void ParticleGunGenerator::PrintMomentumModels ( )

Definition at line 427 of file ParticleGunGenerator.cxx.

427 {
428 LOG(info) << "Available momentum models:";
429 for (const auto& [id, spec] : kMomentumModels())
430 LOG(info) << " Model " << id << " (" << spec.expectedPars
431 << " pars): " << spec.description;
432}

◆ PrintVertexModels()

void ParticleGunGenerator::PrintVertexModels ( )

Definition at line 420 of file ParticleGunGenerator.cxx.

420 {
421 LOG(info) << "Available vertex models:";
422 for (const auto& [id, spec] : kVertexModels())
423 LOG(info) << " Model " << id << " (" << spec.expectedPars
424 << " pars): " << spec.description;
425}

◆ ReadEvent()

Bool_t ParticleGunGenerator::ReadEvent ( FairPrimaryGenerator * primGen)
override

Creates an event with given type and multiplicity.

Parameters
primGenpointer to the FairPrimaryGenerator

Definition at line 259 of file ParticleGunGenerator.cxx.

259 {
260 int pdg_type;
261 // With a common vertex, all particles of the event share the first one's
262 std::optional<ParticleGunParticle> vertex;
263 for (Int_t k = 0; k < GetMultiplicity(); k++) {
264 pdg_type = GenPDGType();
265 ParticleGunParticle p = GenerateKinematics();
266 if (m_commonVertex) {
267 if (!vertex) {
268 vertex = p;
269 }
270 p.X = vertex->X;
271 p.Y = vertex->Y;
272 p.Z = vertex->Z;
273 }
275 primGen->AddTrack(pdg_type, p.Px, p.Py, p.Pz, p.X, p.Y, p.Z);
276 }
277 return kTRUE;
278}
void OverrideFromHistogram(ParticleGunParticle &p)
ParticleGunParticle GenerateKinematics()

◆ SetBothCharges()

void ParticleGunGenerator::SetBothCharges ( bool flag,
Double32_t fraction = 0.5 )

Definition at line 222 of file ParticleGunGenerator.cxx.

222 {
223 if (flag && (!std::isfinite(fraction) || fraction < 0. || fraction > 1.)) {
224 LOG(fatal)
225 << "ParticleGunGenerator: charge fraction must be finite and in [0, 1]";
226 throw std::runtime_error(
227 "ParticleGunGenerator: charge fraction must be finite and in [0, 1]");
228 }
229 m_bothCharges = flag;
230 m_chargeFraction = flag ? fraction : 1.;
231 if (m_bothCharges) {
232 // Check for particle type
233 TDatabasePDG* pdgBase = TDatabasePDG::Instance();
234 TParticlePDG* particle = pdgBase->GetParticle(-m_pdgid);
235 if (!particle) {
236 LOG(warning) << "ParticleGunGenerator: PDG " << -m_pdgid
237 << " not defined. Only generating " << m_pdgid;
238 m_bothCharges = false;
239 m_chargeFraction = 1.;
240 } else
241 LOG(info)
242 << "ParticleGunGenerator: Setting to generate both charges, with "
243 "fraction of "
244 << m_pdgid << " set to " << m_chargeFraction;
245 } else
246 LOG(info) << "ParticleGunGenerator: Setting to only generate one charge "
247 "for PDG id"
248 << m_pdgid;
249}

◆ SetCommonVertex()

void ParticleGunGenerator::SetCommonVertex ( bool flag)
inline

Give all particles of an event the same vertex, drawn once per event.

Definition at line 87 of file ParticleGunGenerator.h.

87{ m_commonVertex = flag; };

◆ SetCosTheta()

void ParticleGunGenerator::SetCosTheta ( )
inline

Definition at line 80 of file ParticleGunGenerator.h.

80{ fCosThetaIsSet = kTRUE; }

◆ SetDebug()

void ParticleGunGenerator::SetDebug ( Bool_t )
inline

not used, for backward compatibility, please user FairLogger to set debug mode

Parameters

Definition at line 101 of file ParticleGunGenerator.h.

101{}

◆ SetEkinRange()

void ParticleGunGenerator::SetEkinRange ( Double32_t kmin = 0,
Double32_t kmax = 10 )
inline

Definition at line 51 of file ParticleGunGenerator.h.

51 {
52 fEkinMin = kmin;
53 fEkinMax = kmax;
54 fEkinRangeIsSet = kTRUE;
55 }

◆ SetEtaRange()

void ParticleGunGenerator::SetEtaRange ( Double32_t etamin = -5,
Double32_t etamax = 7 )
inline

Definition at line 62 of file ParticleGunGenerator.h.

62 {
63 fEtaMin = etamin;
64 fEtaMax = etamax;
65 fEtaRangeIsSet = kTRUE;
66 }

◆ SetMomentumModel()

void ParticleGunGenerator::SetMomentumModel ( const int modelNo,
std::vector< Double32_t > pars )

Definition at line 356 of file ParticleGunGenerator.cxx.

357 {
358 auto it = kMomentumModels().find(modelNo);
359 if (it == kMomentumModels().end()) {
360 LOG(fatal) << "ParticleGunGenerator: unknown momentum model " << modelNo;
361 throw std::runtime_error("ParticleGunGenerator: unknown momentum model " +
362 std::to_string(modelNo));
363 }
364
365 const auto& spec = it->second;
366 if (static_cast<int>(pars.size()) != spec.expectedPars) {
367 LOG(fatal) << "ParticleGunGenerator: momentum model " << modelNo << " ("
368 << spec.description << ") requires " << spec.expectedPars
369 << " parameters, got " << pars.size();
370 throw std::runtime_error("ParticleGunGenerator: momentum model " +
371 std::to_string(modelNo) + " (" + spec.description +
372 ") requires " + std::to_string(spec.expectedPars) +
373 " parameters, got " + std::to_string(pars.size()));
374 }
375
376 fMomentumModel = modelNo;
377 fMomentumPars = std::move(pars);
378 LOG(info) << "ParticleGunGenerator: momentum model " << modelNo << " ("
379 << spec.description << ")";
380}

◆ SetMultiplicity()

void ParticleGunGenerator::SetMultiplicity ( int mult)
inline

Definition at line 85 of file ParticleGunGenerator.h.

85{ m_mult = mult; };

◆ SetPDGType()

void ParticleGunGenerator::SetPDGType ( int pdgid)
inline

Definition at line 84 of file ParticleGunGenerator.h.

84{ m_pdgid = pdgid; };

◆ SetPhiRange()

void ParticleGunGenerator::SetPhiRange ( Double32_t phimin = 0,
Double32_t phimax = 360 )
inline

Definition at line 57 of file ParticleGunGenerator.h.

57 {
58 fPhiMin = phimin;
59 fPhiMax = phimax;
60 }

◆ SetPRange()

void ParticleGunGenerator::SetPRange ( Double32_t pmin = 0,
Double32_t pmax = 10 )
inline

Modifiers

Definition at line 39 of file ParticleGunGenerator.h.

39 {
40 fPMin = pmin;
41 fPMax = pmax;
42 fPRangeIsSet = kTRUE;
43 }

◆ SetPtRange()

void ParticleGunGenerator::SetPtRange ( Double32_t ptmin = 0,
Double32_t ptmax = 10 )
inline

Definition at line 45 of file ParticleGunGenerator.h.

45 {
46 fPtMin = ptmin;
47 fPtMax = ptmax;
48 fPtRangeIsSet = kTRUE;
49 }

◆ SetThetaRange()

void ParticleGunGenerator::SetThetaRange ( Double32_t thetamin = 0,
Double32_t thetamax = 90 )
inline

Definition at line 74 of file ParticleGunGenerator.h.

74 {
75 fThetaMin = thetamin;
76 fThetaMax = thetamax;
77 fThetaRangeIsSet = kTRUE;
78 }

◆ SetVar()

void ParticleGunGenerator::SetVar ( ParticleGunParticle & p,
const std::string & name,
Double32_t value )
private

Definition at line 448 of file ParticleGunGenerator.cxx.

449 {
450 GetVar(p, name) = value;
451}

◆ SetVertexModel()

void ParticleGunGenerator::SetVertexModel ( const std::string & model,
std::vector< Double32_t > pars )

Definition at line 382 of file ParticleGunGenerator.cxx.

383 {
384 // Normalise to lowercase so "Gaussian", "GAUSSIAN" etc. all work
385 std::string lower = model;
386 std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
387
388 auto it = kVertexModels().find(lower);
389 if (it == kVertexModels().end()) {
390 LOG(fatal) << "ParticleGunGenerator: unknown vertex model " << model;
391 throw std::runtime_error("ParticleGunGenerator: unknown vertex model " +
392 model);
393 }
394
395 const auto& spec = it->second;
396 if (static_cast<int>(pars.size()) != spec.expectedPars) {
397 LOG(fatal) << "ParticleGunGenerator: vertex model " << model << " ("
398 << spec.description << ") requires " << spec.expectedPars
399 << " parameters, got " << pars.size();
400 throw std::runtime_error("ParticleGunGenerator: vertex model " + model +
401 " (" + spec.description + ") requires " +
402 std::to_string(spec.expectedPars) +
403 " parameters, got " + std::to_string(pars.size()));
404 }
405
406 fVertexModel = lower;
407 fVertexPars = std::move(pars);
408 LOG(info) << "ParticleGunGenerator: vertex model " << lower << " ("
409 << spec.description << ")";
410}

◆ SetYRange()

void ParticleGunGenerator::SetYRange ( Double32_t ymin = -5,
Double32_t ymax = 7 )
inline

Definition at line 68 of file ParticleGunGenerator.h.

Member Data Documentation

◆ fCosThetaIsSet

Bool_t ParticleGunGenerator::fCosThetaIsSet {false}
private

Definition at line 168 of file ParticleGunGenerator.h.

168{false}; // True if uniform distribution in

◆ fEkinMax

Double32_t ParticleGunGenerator::fEkinMax {0}
private

Definition at line 150 of file ParticleGunGenerator.h.

150{0}; // Kinetic Energy range in lab system [GeV]

◆ fEkinMin

Double32_t ParticleGunGenerator::fEkinMin {0}
private

Definition at line 149 of file ParticleGunGenerator.h.

149{0},

◆ fEkinRangeIsSet

Bool_t ParticleGunGenerator::fEkinRangeIsSet {false}
private

Definition at line 172 of file ParticleGunGenerator.h.

172{false}; // True if kinetic energy range is set

◆ fEtaMax

Double32_t ParticleGunGenerator::fEtaMax {0}
private

Definition at line 144 of file ParticleGunGenerator.h.

144{0}, fEtaMax{0}; // Pseudorapidity range in lab system

◆ fEtaMin

Double32_t ParticleGunGenerator::fEtaMin {0}
private

Definition at line 144 of file ParticleGunGenerator.h.

144{0}, fEtaMax{0}; // Pseudorapidity range in lab system

◆ fEtaRangeIsSet

Bool_t ParticleGunGenerator::fEtaRangeIsSet {false}
private

Definition at line 165 of file ParticleGunGenerator.h.

165{false}; // True if eta range is set

◆ fHistoEntries

std::vector<HistoEntry> ParticleGunGenerator::fHistoEntries
private

Definition at line 163 of file ParticleGunGenerator.h.

◆ fMomentumModel

int ParticleGunGenerator::fMomentumModel {0}
private

Definition at line 174 of file ParticleGunGenerator.h.

174{0};

◆ fMomentumPars

std::vector<Double32_t> ParticleGunGenerator::fMomentumPars
private

Definition at line 176 of file ParticleGunGenerator.h.

◆ fPDGMass

Double32_t ParticleGunGenerator::fPDGMass {0}
private

Definition at line 153 of file ParticleGunGenerator.h.

153{0};

◆ fPhiMax

Double32_t ParticleGunGenerator::fPhiMax {0}
private

Definition at line 143 of file ParticleGunGenerator.h.

143{0}, fPhiMax{0}; // Azimuth angle range [degree]

◆ fPhiMin

Double32_t ParticleGunGenerator::fPhiMin {0}
private

Definition at line 143 of file ParticleGunGenerator.h.

143{0}, fPhiMax{0}; // Azimuth angle range [degree]

◆ fPMax

Double32_t ParticleGunGenerator::fPMax {0}
private

Definition at line 146 of file ParticleGunGenerator.h.

146{0}, fPMax{0}; // Momentum range in lab system

◆ fPMin

Double32_t ParticleGunGenerator::fPMin {0}
private

Definition at line 146 of file ParticleGunGenerator.h.

146{0}, fPMax{0}; // Momentum range in lab system

◆ fPRangeIsSet

Bool_t ParticleGunGenerator::fPRangeIsSet {false}
private

Definition at line 171 of file ParticleGunGenerator.h.

171{false}; // True if abs.momentum range is set

◆ fPtMax

Double32_t ParticleGunGenerator::fPtMax {0}
private

Definition at line 142 of file ParticleGunGenerator.h.

142{0}, fPtMax{0}; // Transverse momentum range [GeV]

◆ fPtMin

Double32_t ParticleGunGenerator::fPtMin {0}
private

Definition at line 142 of file ParticleGunGenerator.h.

142{0}, fPtMax{0}; // Transverse momentum range [GeV]

◆ fPtRangeIsSet

Bool_t ParticleGunGenerator::fPtRangeIsSet {false}
private

Definition at line 170 of file ParticleGunGenerator.h.

170{false}; // True if transverse momentum range is set

◆ fThetaMax

Double32_t ParticleGunGenerator::fThetaMax {0}
private

Definition at line 148 of file ParticleGunGenerator.h.

148{0}; // Polar angle range in lab system [degree]

◆ fThetaMin

Double32_t ParticleGunGenerator::fThetaMin {0}
private

Definition at line 147 of file ParticleGunGenerator.h.

147{0},

◆ fThetaRangeIsSet

Bool_t ParticleGunGenerator::fThetaRangeIsSet {false}
private

Definition at line 167 of file ParticleGunGenerator.h.

167{false}; // True if theta range is set

◆ fVertexModel

std::string ParticleGunGenerator::fVertexModel = "gaussian"
private

Definition at line 175 of file ParticleGunGenerator.h.

◆ fVertexPars

std::vector<Double32_t> ParticleGunGenerator::fVertexPars
private

Definition at line 177 of file ParticleGunGenerator.h.

◆ fVex

Double32_t ParticleGunGenerator::fVex {0}
private

Definition at line 152 of file ParticleGunGenerator.h.

◆ fVey

Double32_t ParticleGunGenerator::fVey {0}
private

Definition at line 152 of file ParticleGunGenerator.h.

152{0}, fVey{0}, fVez{0};

◆ fVez

Double32_t ParticleGunGenerator::fVez {0}
private

Definition at line 152 of file ParticleGunGenerator.h.

152{0}, fVey{0}, fVez{0};

◆ fVx

Double32_t ParticleGunGenerator::fVx {0}
private

Definition at line 151 of file ParticleGunGenerator.h.

◆ fVy

Double32_t ParticleGunGenerator::fVy {0}
private

Definition at line 151 of file ParticleGunGenerator.h.

151{0}, fVy{0}, fVz{0};

◆ fVz

Double32_t ParticleGunGenerator::fVz {0}
private

Definition at line 151 of file ParticleGunGenerator.h.

151{0}, fVy{0}, fVz{0};

◆ fYMax

Double32_t ParticleGunGenerator::fYMax {0}
private

Definition at line 145 of file ParticleGunGenerator.h.

145{0}, fYMax{0}; // Rapidity range in lab system

◆ fYMin

Double32_t ParticleGunGenerator::fYMin {0}
private

Definition at line 145 of file ParticleGunGenerator.h.

145{0}, fYMax{0}; // Rapidity range in lab system

◆ fYRangeIsSet

Bool_t ParticleGunGenerator::fYRangeIsSet {false}
private

Definition at line 166 of file ParticleGunGenerator.h.

166{false}; // True if rapidity range is set

◆ m_bothCharges

bool ParticleGunGenerator::m_bothCharges {false}
private

Definition at line 155 of file ParticleGunGenerator.h.

155{false};

◆ m_chargeFraction

Double32_t ParticleGunGenerator::m_chargeFraction {1.}
private

Definition at line 156 of file ParticleGunGenerator.h.

156{1.};

◆ m_commonVertex

bool ParticleGunGenerator::m_commonVertex {false}
private

Definition at line 179 of file ParticleGunGenerator.h.

179{false};

◆ m_mult

int ParticleGunGenerator::m_mult {1}
private

Definition at line 178 of file ParticleGunGenerator.h.

178{1};

◆ m_pdgid

int ParticleGunGenerator::m_pdgid {0}
private

Definition at line 180 of file ParticleGunGenerator.h.

180{0};

The documentation for this class was generated from the following files: