RooParticle
Particle scattering simulator with ROOT
Loading...
Searching...
No Matches
particle.hpp
Go to the documentation of this file.
1#ifndef H_PARTICLE
2#define H_PARTICLE 1;
3
4#include "TROOT.h"
5#include "TString.h"
6#include "TVector3.h"
7
8// #include "event.hpp"
9#include "path.hpp"
10
11class inspector;
12class event;
13
37public:
38 // particle();
39
49 particle(Double_t m0_ = 1,
50 //Double_t q_ = 1,
51 TVector3 x0_ = TVector3(),
52 TVector3 v0_ = TVector3(),
53 Bool_t Invincible_ = false,
54 Bool_t Record_ = false);
55
56 //Force Methods (Holding and Release)
57
63 particle(const particle & p);
64
66 ~particle(){if(Record)delete ppath;}
67
70 void holdForce(const TVector3 f);
71
77 void releaseForce(const Double_t dt);
78
80 void resetHold();
81
85 void finishStep(const Double_t dt);
86
98 TVector3 calculateCalibrateVelocity(event* ev_, Bool_t ignoreInvincible=kFALSE);
99
105 TVector3 calibrateVelocity(event* ev_, Bool_t ignoreInvincible=kFALSE, Bool_t verbose=kFALSE);
106
107 //Applying Methods
108 // The apply* setters below change the state directly: no step is counted, no time
109 // advances, nothing is recorded, and an invincible particle is not protected.
110
112 void applyMechanic(const TVector3 x_, const TVector3 v_){x = x_; v = v_;}
113
115 void applyX(const TVector3 x_){x=x_;}
116
118 void applyV(const TVector3 v_){v=v_;}
119
129 void applyForce(const TVector3 f, const Double_t dt=1., Bool_t SR=kFALSE);
130
132 void applyDX(const TVector3 dx){x += dx;}
133
135 void applyDV(const TVector3 dv){v += dv;}
136
138 void applyDelta(const TVector3 dx, const TVector3 dv){x += dx; v += dv;}
139
141 void SetName(const TString name_){name=name_;}
142
147
155 void SetRecordPeriod(Int_t n){recordPeriod = (n<1) ? 1 : n;}
156
159
161 TVector3 GetX(){return TVector3(x);}
162
164 TVector3 GetV(){return TVector3(v);}
165
169 TVector3 GetP(){return TVector3(v * GetM());}
170
173 TVector3 GetMomentum(Bool_t relativistic=kFALSE);
174
176 Long_t GetECNT(){return ecount;}
177
179 Double_t GetM0(){return m0;}
180
183 Double_t GetM(const Bool_t restmass=kTRUE);
184
186 Double_t GetGamma();
187
193 Double_t GetKE(const Bool_t SR=kFALSE){return 0.5*GetM(!SR)*(v.Mag2());}
194
199 Double_t GetQ(){return q;}
200
202 Double_t GetTime(){return etime;}
203
205 path* GetPath(){return ppath;}
206
208 Bool_t IsInvincible(){return Invincible;}
209
211 Bool_t IsRecording(){return Record;}
212
217 TString Print(Bool_t onlymechanic=kFALSE, Bool_t mute=kFALSE);
218
219 friend class inspectorP;
220
221protected:
222 Double_t q = 0;
223
224private:
225 TString name;
226 TVector3 x = TVector3();
227 TVector3 v = TVector3();
228 Double_t m0 = 1;
229
230 Bool_t Invincible = false;
231 Bool_t hold = false;
232 TVector3 hF = TVector3();
233
234 Double_t etime = 0.;
235 Long_t ecount = 0;
236
237 Bool_t Record = false;
238 Int_t recordPeriod = 1;
239 path* ppath = nullptr;
240
241 // Path record at the end of a step, following the record period.
243};
244
249class EMparticle : public particle{
250public:
251 // EMparticle(): particle(){};
252
260 EMparticle(Double_t m0_ = 1,
261 Double_t q_ = 1,
262 TVector3 x0_ = TVector3(),
263 TVector3 v0_ = TVector3(),
264 Bool_t Invincible_ = false,
265 Bool_t Record_ = false):
266 particle(m0_, x0_, v0_, Invincible_, Record_){
267 q = q_;
268 }
270 // GetQ() is inherited from particle.
271
272
273private:
274 // Double_t q;
275};
276
277#endif
A particle with a charge, for electromagnetic forces (coulombForce).
Definition particle.hpp:249
EMparticle(Double_t m0_=1, Double_t q_=1, TVector3 x0_=TVector3(), TVector3 v0_=TVector3(), Bool_t Invincible_=false, Bool_t Record_=false)
Make a charged particle.
Definition particle.hpp:260
One simulated system: particles, pairwise forces, inspectors and the time integration.
Definition event.hpp:93
Inspector on a pair of particles.
Inspector : one terminating condition of event::DeriveInspect().
Definition inspector.hpp:28
A point body with mass, position, velocity, step count, time and an optional recorded path.
Definition particle.hpp:36
Int_t GetRecordPeriod()
The record period (see SetRecordPeriod()).
Definition particle.hpp:158
TVector3 GetV()
Velocity in c (a copy).
Definition particle.hpp:164
void SetName(const TString name_)
Set a name for printing.
Definition particle.hpp:141
Bool_t Invincible
fixed particle
Definition particle.hpp:230
TString name
name for printing
Definition particle.hpp:225
Double_t GetKE(const Bool_t SR=kFALSE)
Kinetic energy in amu c^2.
Definition particle.hpp:193
void releaseForce(const Double_t dt)
Apply the held force for one step of dt (see applyForce()) and clear it.
Definition particle.cpp:70
TVector3 x
position in fm
Definition particle.hpp:226
void holdForce(const TVector3 f)
Add a force to the pending force of this particle.
Definition particle.cpp:60
TVector3 GetP()
Non-relativistic momentum in amu c (same as GetMomentum(kFALSE)).
Definition particle.hpp:169
Bool_t Record
records the path
Definition particle.hpp:237
TVector3 v
velocity in c
Definition particle.hpp:227
Int_t recordPeriod
a step is recorded when ecount is a multiple of it
Definition particle.hpp:238
Bool_t IsInvincible()
Whether the particle is fixed (invincible).
Definition particle.hpp:208
void applyDV(const TVector3 dv)
Add dv (c) to the velocity.
Definition particle.hpp:135
Double_t m0
rest mass in amu
Definition particle.hpp:228
~particle()
Destructor; deletes the path (not virtual: delete a particle through its own or its base type only,...
Definition particle.hpp:66
void applyV(const TVector3 v_)
Set the velocity (c).
Definition particle.hpp:118
void applyForce(const TVector3 f, const Double_t dt=1., Bool_t SR=kFALSE)
Move the particle for one step under a constant force (the original Taylor step).
Definition particle.cpp:117
Long_t GetECNT()
Number of derived steps ("evolved count"), counted also for an invincible particle.
Definition particle.hpp:176
void applyDelta(const TVector3 dx, const TVector3 dv)
Add dx (fm) to the position and dv (c) to the velocity.
Definition particle.hpp:138
TVector3 GetMomentum(Bool_t relativistic=kFALSE)
Momentum in amu c.
Definition particle.cpp:152
TVector3 calibrateVelocity(event *ev_, Bool_t ignoreInvincible=kFALSE, Bool_t verbose=kFALSE)
Apply calculateCalibrateVelocity() to this particle.
Definition particle.cpp:107
void AddRecord()
Append the present x, v and time to the path now, whatever the record period.
Definition particle.hpp:146
path * ppath
the path (owned)
Definition particle.hpp:239
Long_t ecount
number of derived steps
Definition particle.hpp:235
Double_t GetTime()
Evolved time in fm/c; does not advance for an invincible particle.
Definition particle.hpp:202
Double_t etime
evolved time in fm/c
Definition particle.hpp:234
Double_t GetM0()
Rest mass in amu.
Definition particle.hpp:179
TString Print(Bool_t onlymechanic=kFALSE, Bool_t mute=kFALSE)
Describe the particle as text "[ Particle x: [..], v: [..] ]".
Definition particle.cpp:173
void finishStep(const Double_t dt)
Close one integration step whose x, v were already updated by the event (step count,...
Definition particle.cpp:80
TVector3 calculateCalibrateVelocity(event *ev_, Bool_t ignoreInvincible=kFALSE)
Velocity change which makes the given velocity the one far from the other bodies.
Definition particle.cpp:90
void resetHold()
Discard the held force.
Definition particle.cpp:75
void applyDX(const TVector3 dx)
Add dx (fm) to the position.
Definition particle.hpp:132
path * GetPath()
The recorded path (owned by the particle; a null pointer if not recording).
Definition particle.hpp:205
Double_t GetM(const Bool_t restmass=kTRUE)
Mass in amu.
Definition particle.cpp:138
Bool_t hold
a force is held
Definition particle.hpp:231
Double_t q
charge in e
Definition particle.hpp:222
void recordStep()
Definition particle.hpp:242
void SetRecordPeriod(Int_t n)
Set the record period of the path.
Definition particle.hpp:155
TVector3 hF
held force in amu c^2/fm
Definition particle.hpp:232
Double_t GetQ()
Charge in e. 0 for a plain particle, set by EMparticle.
Definition particle.hpp:199
TVector3 GetX()
Position in fm (a copy).
Definition particle.hpp:161
void applyMechanic(const TVector3 x_, const TVector3 v_)
Set position and velocity (fm, c).
Definition particle.hpp:112
void applyX(const TVector3 x_)
Set the position (fm).
Definition particle.hpp:115
Double_t GetGamma()
Lorentz factor (v in c); NaN for speed above c.
Definition particle.cpp:146
Bool_t IsRecording()
Whether the particle records its path.
Definition particle.hpp:211
Time-ordered list of (position, velocity, time) samples of one particle.
Definition path.hpp:37
void AddRecord(TVector3 x_, TVector3 v_, Double_t time_)
Append one record at the end.
Definition path.cpp:42
Recorded trajectory of one particle (path) and distance-of-closest-approach helpers.