OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Beam.h
Go to the documentation of this file.
1//
2// Class Beam
3// The class for the OPAL BEAM command.
4// A BEAM definition is used by most physics commands to define the
5// particle charge and the reference momentum, together with some other data.
6//
7// Copyright (c) 200x - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
8// All rights reserved
9//
10// This file is part of OPAL.
11//
12// OPAL is free software: you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation, either version 3 of the License, or
15// (at your option) any later version.
16//
17// You should have received a copy of the GNU General Public License
18// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
19//
20#ifndef OPAL_Beam_HH
21#define OPAL_Beam_HH
22
24#include "Algorithms/PartData.h"
25
26#include <ostream>
27#include <string>
28#include <vector>
29
30class Inform;
31
32class Beam : public Definition {
33public:
35 Beam();
36
37 virtual ~Beam();
38
40 // Can replace only by another BEAM.
41 virtual bool canReplaceBy(Object* object);
42
44 virtual Beam* clone(const std::string& name);
45
47 virtual void execute();
48
50 static Beam* find(const std::string& name);
51
53 size_t getNumAlloc() const;
54
56 const PartData& getReference() const;
57
59 double getCurrent() const;
60
62 double getBunchCharge() const;
63
65 double getCharge() const;
66
68 double getFrequency() const;
69
71 std::string getParticleName() const;
72
74 bool isPhoton() const;
75
77 double getMass() const;
78
79 // Returns Momentum in GeV/c
80 double getMomentum() const;
81
83 double getChargePerParticle() const;
84
86 double getMassPerParticle() const;
87
90 std::string getEmissionSourceListName() const;
91
93 std::vector<std::string> getGlobalProcessNames() const;
94
96 std::string getDaughterBeamName() const;
97
100 std::vector<double> getPolarization() const;
101
104 bool hasPolarization() const;
105
107 bool hasExplicitEnergy() const;
108
110 virtual void update();
111
112 void print(std::ostream& os) const;
113
114private:
115 // Not implemented.
116 Beam(const Beam&);
117 void operator=(const Beam&);
118
119 // Clone constructor.
120 Beam(const std::string& name, Beam* parent);
121
122 // Validate the POLARIZATION attribute (length, magnitude, muon-only).
123 void validatePolarization() const;
124
125 // The particle reference data.
127
128 // The converstion from GeV to eV.
129 static const double energy_scale;
130};
131
132inline std::ostream& operator<<(std::ostream& os, const Beam& b) {
133 b.print(os);
134 return os;
135}
136
137#endif // OPAL_Beam_HH
std::ostream & operator<<(std::ostream &os, const Beam &b)
Definition Beam.h:132
Definition Beam.h:32
std::string getParticleName() const
Return Particle's name.
Definition Beam.cpp:326
std::string getEmissionSourceListName() const
Definition Beam.cpp:254
double getCurrent() const
Return the beam current in A (legacy; no longer used in OPALX)
Definition Beam.cpp:316
void validatePolarization() const
Definition Beam.cpp:215
void operator=(const Beam &)
double getChargePerParticle() const
Charge per macro particle in C.
Definition Beam.cpp:334
bool hasPolarization() const
Definition Beam.cpp:286
virtual void execute()
Check the BEAM data.
Definition Beam.cpp:139
double getBunchCharge() const
Return the bunch charge in C.
Definition Beam.cpp:318
double getMomentum() const
Definition Beam.cpp:324
static Beam * find(const std::string &name)
Find named BEAM.
Definition Beam.cpp:290
double getCharge() const
Return the charge number in elementary charge.
Definition Beam.cpp:320
virtual Beam * clone(const std::string &name)
Make clone.
Definition Beam.cpp:137
bool isPhoton() const
True if this beam is configured as a photon beam.
Definition Beam.cpp:328
size_t getNumAlloc() const
Return the allocation size (macroparticles) for this beam.
Definition Beam.cpp:300
PartData reference
Definition Beam.h:126
double getFrequency() const
Return the beam frequency in MHz.
Definition Beam.cpp:330
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
Definition Beam.cpp:338
double getMass() const
Return Particle's rest mass in GeV.
Definition Beam.cpp:322
virtual void update()
Update the BEAM data.
Definition Beam.cpp:342
void print(std::ostream &os) const
Print the object.
Definition Beam.cpp:400
Beam()
Exemplar constructor.
Definition Beam.cpp:61
bool hasExplicitEnergy() const
True if PC, ENERGY, or GAMMA was explicitly provided by the user.
Definition Beam.cpp:332
const PartData & getReference() const
Return the embedded OPALX PartData.
Definition Beam.cpp:310
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Definition Beam.cpp:132
std::string getDaughterBeamName() const
Return the name of the daughter beam (for decay products), or empty if not set.
Definition Beam.cpp:274
Beam(const Beam &)
virtual ~Beam()
Definition Beam.cpp:130
std::vector< double > getPolarization() const
Definition Beam.cpp:278
std::vector< std::string > getGlobalProcessNames() const
Return the configured global process names for this beam.
Definition Beam.cpp:270
static const double energy_scale
Definition Beam.h:129
The base class for all OPAL definitions.
Definition Definition.h:29
The base class for all OPAL objects.
Definition Object.h:45
Particle reference data.
Definition PartData.h:37