OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
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 - 2023, 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 
29 class Inform;
30 
31 class Beam: public Definition {
32 
33 public:
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 getNumberOfParticles() const;
54 
56  const PartData& getReference() const;
57 
59  double getCurrent() const;
60 
62  double getCharge() const;
63 
65  double getFrequency() const;
66 
68  std::string getParticleName() const;
69 
71  double getMass() const;
72 
74  double getChargePerParticle() const;
75 
77  double getMassPerParticle() const;
78 
80  virtual void update();
81 
82  void print(std::ostream& os) const;
83 
84 private:
85  // Not implemented.
86  Beam(const Beam&);
87  void operator=(const Beam&);
88 
89  // Clone constructor.
90  Beam(const std::string& name, Beam* parent);
91 
92  // The particle reference data.
94 };
95 
96 inline std::ostream &operator<<(std::ostream& os, const Beam& b) {
97  b.print(os);
98  return os;
99 }
100 
101 #endif // OPAL_Beam_HH
The base class for all OPAL objects.
Definition: Object.h:48
double getMassPerParticle() const
Mass per macro particle in GeV/c^2.
Definition: Beam.cpp:214
virtual Beam * clone(const std::string &name)
Make clone.
Definition: Beam.cpp:137
std::ostream & operator<<(std::ostream &os, const Attribute &attr)
Definition: Attribute.cpp:169
const PartData & getReference() const
Return the embedded CLASSIC PartData.
Definition: Beam.cpp:182
virtual void update()
Update the BEAM data.
Definition: Beam.cpp:218
size_t getNumberOfParticles() const
Return the number of (macro)particles.
Definition: Beam.cpp:173
virtual ~Beam()
Definition: Beam.cpp:127
std::string getParticleName() const
Return Particle&#39;s name.
Definition: Beam.cpp:200
void print(std::ostream &os) const
Print the object.
Definition: Beam.cpp:267
void operator=(const Beam &)
Definition: Inform.h:42
virtual void execute()
Check the BEAM data.
Definition: Beam.cpp:142
double getMass() const
Return Particle&#39;s rest mass in GeV.
Definition: Beam.cpp:196
static Beam * find(const std::string &name)
Find named BEAM.
Definition: Beam.cpp:163
double getChargePerParticle() const
Charge per macro particle in C.
Definition: Beam.cpp:208
const std::string name
double getCurrent() const
Return the beam current in A.
Definition: Beam.cpp:188
The base class for all OPAL definitions.
Definition: Definition.h:30
Beam()
Exemplar constructor.
Definition: Beam.cpp:55
Definition: Beam.h:31
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Definition: Beam.cpp:131
PartData reference
Definition: Beam.h:93
double getCharge() const
Return the charge number in elementary charge.
Definition: Beam.cpp:192
double getFrequency() const
Return the beam frequency in MHz.
Definition: Beam.cpp:204