RooParticle
Particle scattering simulator with ROOT
Loading...
Searching...
No Matches
inspector.hpp
Go to the documentation of this file.
1#ifndef H_INSPECTOR
2#define H_INSPECTOR 1;
3
4#include "TROOT.h"
5#include "particle.hpp"
6#include "event.hpp"
7
8class event;
9
29 public:
72
76 static methodID ParseMethod(TString name);
77
80 static TString MethodName(methodID id);
81
84 virtual ~inspector(){}
85
87 virtual Bool_t Inspect(){return kFALSE;}
88
90 virtual Double_t Evaluate(){return 0.;}
91
93 virtual Bool_t IsValid(){return kFALSE;}
94
96 void SetValue(Double_t val_){val=val_;}
97
103 void SetMethod(TString methodname){ftn=methodname; mtd=ParseMethod(methodname);}
104
106 void SetMethod(const char * methodname){SetMethod(TString(methodname));}
107
109 void SetMethod(methodID id_){mtd=id_; ftn=MethodName(id_);}
110
112 TString GetMethod(){return ftn;}
113
116
118 Double_t GetCriterion(){return val;}
119
122 void SetAbort(Bool_t abort_=kTRUE){abort=abort_;}
123
125 Bool_t IsAbort(){return abort;}
126
132 virtual TString Print(Bool_t element=kFALSE, Bool_t mechanics=kFALSE, Bool_t mute=kFALSE, Bool_t pprint=kFALSE);
133
135 virtual Bool_t IsInspectorP(){return kFALSE;}
136
138 virtual Bool_t IsInspectorE(){return kFALSE;}
139
140 protected:
141 TString ftn="";
143 Double_t val=-1;
144 Bool_t abort=kFALSE;
145
146 private:
147 // inspectorT(particle *p1_, particle *p2_, TString method_, Double_t val_=-1){};
148 // inspectorT(event* event_, TString method_, Double_t val_=-1){};
149
150};
151
185class inspectorP: public inspector{ //Calculator, Static
186 public:
196 inspectorP(particle *p1_, particle *p2_, TString method_, Double_t val_=-1);
197
199 inspectorP(particle *p1_, particle *p2_, methodID method_, Double_t val_=-1);
200
204 Bool_t Inspect();
205
209 Double_t Evaluate();
210
212 Bool_t IsValid();
213
215 void SetParticles(particle * p1_, particle * p2_){p1 = p1_; p2 = p2_;}
217 void SetParticle1(particle * p1_){p1 = p1_;}
219 void SetParticle2(particle * p2_){p2 = p2_;}
220
225
231 TString Print(Bool_t particles=kFALSE, Bool_t mechanics=kFALSE, Bool_t mute=kFALSE, Bool_t pprint=kFALSE);
232
233 // Bool_t SetInitial(Bool_t index=0, TString mtd="", Double_t var=0.1);
234
245 Bool_t SetInitial_D(Bool_t index=0, TString mtd="", Double_t var=0.1);
246
248 Bool_t IsInspectorP(){return kTRUE;}
249
250 protected:
252 Bool_t IsDegenerate(Bool_t needV=kTRUE);
254 Double_t CalculateCosine();
256 Double_t CalculateAngle(Bool_t rad=kFALSE);
258 Long_t CountDeriving();
260 Double_t CaculateSPD();
262 Double_t CalculateDistance();
264 Double_t CalculateRadialVelocity();
265
266 private:
268};
269
270
323class inspectorE: public inspector{
324 public:
329 inspectorE(event* event_, TString method_, Double_t val_=-1);
330
332 inspectorE(event* event_, methodID method_, Double_t val_=-1);
333
335 void SetEvent(event* event_){evt=event_; hasRef=kFALSE;}
336
338 event * GetEvent(){return evt;}
339
341 Bool_t Inspect();
342
344 Double_t Evaluate();
345
347 Bool_t IsValid();
348
350 void ResetReference(){hasRef=kFALSE;}
351
357 TString Print(Bool_t element=kFALSE, Bool_t mechanics=kFALSE, Bool_t mute=kFALSE, Bool_t pprint=kFALSE);
358
360 Bool_t IsInspectorE(){return kTRUE;}
361
362 protected:
363
364 private:
365 event *evt;
366 Double_t ref = 0.;
367 Bool_t hasRef = kFALSE;
368 // TString ftn=TString("");
369 // Double_t val=-1;
370
371};
372
373#endif
One simulated system: particles, pairwise forces, inspectors and the time integration.
Definition event.hpp:93
Inspector on the whole event.
TString Print(Bool_t element=kFALSE, Bool_t mechanics=kFALSE, Bool_t mute=kFALSE, Bool_t pprint=kFALSE)
Describe as text "[ Inspector Event: MTD, CRT, VAL, RST (, ABORT) ]".
Bool_t hasRef
E0 is set.
Bool_t IsValid()
Whether the method is one of the inspectorE methods.
Double_t ref
reference energy E0 of "EDG"/"EDL"
event * GetEvent()
The watched event.
Bool_t Inspect()
Whether the condition is satisfied now (kFALSE for an invalid method, with a message on stderr).
Bool_t IsInspectorE()
Always kTRUE.
void ResetReference()
Forget E0 of "EDG"/"EDL"; the next evaluation takes the present energy as E0.
event * evt
the watched event (not owned)
void SetEvent(event *event_)
Set the event to watch (forgets the reference energy E0).
Double_t Evaluate()
The compared quantity, see the table (the first "EDG"/"EDL" call sets E0 and gives 0).
Inspector on a pair of particles.
Double_t Evaluate()
The compared quantity: cosine, angle (degree or radian), step count, relative speed (c),...
Definition inspector.cpp:66
TString Print(Bool_t particles=kFALSE, Bool_t mechanics=kFALSE, Bool_t mute=kFALSE, Bool_t pprint=kFALSE)
Describe as text "[ Inspector Particle: MTD, CRT (criterion), VAL (value), RST (result) ]".
Bool_t SetInitial_D(Bool_t index=0, TString mtd="", Double_t var=0.1)
Move one particle back along its velocity so that the present condition is the one of the given angle...
Double_t CalculateRadialVelocity()
dX.dV/norm(dX) (c), positive when receding; NaN if dX = 0.
Double_t CalculateAngle(Bool_t rad=kFALSE)
Angle between dX and dV in degree (radian if rad), NaN for a zero vector.
particle * GetParticle2()
The second particle.
Bool_t IsValid()
Whether the method is one of the inspectorP methods.
Definition inspector.cpp:81
void SetParticles(particle *p1_, particle *p2_)
Set both particles.
particle * p1
void SetParticle1(particle *p1_)
Set the first particle.
Bool_t IsInspectorP()
Always kTRUE.
void SetParticle2(particle *p2_)
Set the second particle.
particle * p2
the two particles (not owned)
particle * GetParticle1()
The first particle.
Bool_t Inspect()
Whether the condition is satisfied now.
Definition inspector.cpp:85
Double_t CalculateCosine()
Cosine of the angle between dX and dV, clamped to [-1, 1] (NaN for a zero vector).
Double_t CaculateSPD()
Relative speed, norm of dV (c).
Bool_t IsDegenerate(Bool_t needV=kTRUE)
Whether dX (or, if needV, dV) is the zero vector.
Double_t CalculateDistance()
Distance, norm of dX (fm).
Long_t CountDeriving()
Smaller of the step counts of the two particles.
Inspector : one terminating condition of event::DeriveInspect().
Definition inspector.hpp:28
TString GetMethod()
The method name as given.
void SetValue(Double_t val_)
Set the criterion value to compare with (in the unit of the quantity).
Definition inspector.hpp:96
methodID GetMethodID()
The method identifier (kInvalid for an unknown name).
static methodID ParseMethod(TString name)
Parse a method name.
Definition inspector.cpp:40
Double_t GetCriterion()
The criterion value (default -1).
virtual ~inspector()
Definition inspector.hpp:84
virtual Bool_t IsInspectorP()
Whether this is an inspectorP.
methodID mtd
parsed method
void SetMethod(const char *methodname)
Set the method by C string (see SetMethod(TString)).
virtual Bool_t IsInspectorE()
Whether this is an inspectorE.
void SetMethod(TString methodname)
Set the method by name.
void SetMethod(methodID id_)
Set the method by identifier.
methodID
Method identifier.
Definition inspector.hpp:35
@ kPEL
"PEL": net potential energy < value
Definition inspector.hpp:52
@ kACG
"ACG": largest acceleration > value
Definition inspector.hpp:65
@ kKEG
"KEG": net kinetic energy > value
Definition inspector.hpp:49
@ kDSTL
"DSTL": distance < value
Definition inspector.hpp:45
@ kASYD
"ASYD": remaining deflection of every moving particle < value (rad), all pairs receding
Definition inspector.hpp:69
@ kCNT
"CNT": number of derived steps > value
Definition inspector.hpp:41
@ kDNL
"DNL": smallest step count < value
Definition inspector.hpp:62
@ kTML
"TML": evolved time < value
Definition inspector.hpp:58
@ kRAD
"RAD": angle between dX and dV in radian < value
Definition inspector.hpp:40
@ kDSTG
"DSTG": distance > value
Definition inspector.hpp:44
@ kDSL
"DSL": smallest distance between two particles < value
Definition inspector.hpp:64
@ kKEL
"KEL": net kinetic energy < value
Definition inspector.hpp:50
@ kVRL
"VRL": radial velocity < value
Definition inspector.hpp:47
@ kASYV
"ASYV": remaining relative velocity change of every moving particle < value, all pairs receding
Definition inspector.hpp:70
@ kDSG
"DSG": smallest distance between two particles > value
Definition inspector.hpp:63
@ kInvalid
unknown method name
Definition inspector.hpp:36
@ kVOUT
"VOUT": any moving particle is outside the volume
Definition inspector.hpp:67
@ kVRG
"VRG": radial velocity > value
Definition inspector.hpp:46
@ kCOS
"COS": cosine of the angle between dX and dV < value
Definition inspector.hpp:38
@ kDNG
"DNG": largest step count > value (Evaluate() gives the smallest, see inspectorE)
Definition inspector.hpp:61
@ kTMG
"TMG": evolved time > value
Definition inspector.hpp:57
@ kVOUTA
"VOUTA": all moving particles are outside the volume
Definition inspector.hpp:68
@ kEDL
"EDL": relative drift of the net energy < value
Definition inspector.hpp:56
@ kPKL
"PKL": abs(net PE / net KE) < value
Definition inspector.hpp:54
@ kDXG
"DXG": largest step count > value
Definition inspector.hpp:59
@ kPEG
"PEG": net potential energy > value
Definition inspector.hpp:51
@ kSPDL
"SPDL": relative speed < value
Definition inspector.hpp:43
@ kDEG
"DEG": angle between dX and dV in degree < value
Definition inspector.hpp:39
@ kPKG
"PKG": abs(net PE / net KE) > value
Definition inspector.hpp:53
@ kACL
"ACL": largest acceleration < value
Definition inspector.hpp:66
@ kSPDG
"SPDG": relative speed > value
Definition inspector.hpp:42
@ kEDG
"EDG": relative drift of the net energy > value
Definition inspector.hpp:55
@ kDXL
"DXL": smallest step count < value (Evaluate() gives the largest, see inspectorE)
Definition inspector.hpp:60
static TString MethodName(methodID id)
Name of a method identifier.
Definition inspector.cpp:47
virtual Bool_t Inspect()
Whether the condition is satisfied now (the base class : never).
Definition inspector.hpp:87
virtual Bool_t IsValid()
Whether the method name is defined for this kind of inspector (the base class : never).
Definition inspector.hpp:93
Double_t val
criterion value
void SetAbort(Bool_t abort_=kTRUE)
Make this inspector an abort inspector.
inspector()
Make an inspector without method (invalid until SetMethod()).
Definition inspector.hpp:83
Bool_t abort
abort inspector
TString ftn
method name as given
virtual TString Print(Bool_t element=kFALSE, Bool_t mechanics=kFALSE, Bool_t mute=kFALSE, Bool_t pprint=kFALSE)
Describe the inspector as text (the base class : empty).
virtual Double_t Evaluate()
The quantity that is compared with the criterion (the base class : 0).
Definition inspector.hpp:90
Bool_t IsAbort()
Whether this is an abort inspector.
A point body with mass, position, velocity, step count, time and an optional recorded path.
Definition particle.hpp:36
const char * name
Definition inspector.cpp:25