RooParticle
Particle scattering simulator with ROOT
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
inspectorP Class Reference

Inspector on a pair of particles. More...

#include <inspector.hpp>

Inheritance diagram for inspectorP:
inspector

Public Member Functions

 inspectorP (particle *p1_, particle *p2_, TString method_, Double_t val_=-1)
 Make an inspector on two particles, method by name.
 
 inspectorP (particle *p1_, particle *p2_, methodID method_, Double_t val_=-1)
 Make an inspector on two particles, method by enumerator (see above).
 
Bool_t Inspect ()
 Whether the condition is satisfied now.
 
Double_t Evaluate ()
 The compared quantity: cosine, angle (degree or radian), step count, relative speed (c), distance (fm) or radial velocity (c). NaN for a zero vector (angle, cosine, radial velocity); for an invalid method it prints a message and gives 0.
 
Bool_t IsValid ()
 Whether the method is one of the inspectorP methods.
 
void SetParticles (particle *p1_, particle *p2_)
 Set both particles.
 
void SetParticle1 (particle *p1_)
 Set the first particle.
 
void SetParticle2 (particle *p2_)
 Set the second particle.
 
particle * GetParticle1 ()
 The first particle.
 
particle * GetParticle2 ()
 The second particle.
 
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 (setting the initial position from the present state).
 
Bool_t IsInspectorP ()
 Always kTRUE.
 
- Public Member Functions inherited from inspector
 inspector ()
 Make an inspector without method (invalid until SetMethod()).
 
virtual ~inspector ()
 
void SetValue (Double_t val_)
 Set the criterion value to compare with (in the unit of the quantity).
 
void SetMethod (TString methodname)
 Set the method by name.
 
void SetMethod (const char *methodname)
 Set the method by C string (see SetMethod(TString)).
 
void SetMethod (methodID id_)
 Set the method by identifier.
 
TString GetMethod ()
 The method name as given.
 
methodID GetMethodID ()
 The method identifier (kInvalid for an unknown name).
 
Double_t GetCriterion ()
 The criterion value (default -1).
 
void SetAbort (Bool_t abort_=kTRUE)
 Make this inspector an abort inspector.
 
Bool_t IsAbort ()
 Whether this is an abort inspector.
 
virtual Bool_t IsInspectorE ()
 Whether this is an inspectorE.
 

Protected Member Functions

Bool_t IsDegenerate (Bool_t needV=kTRUE)
 Whether dX (or, if needV, dV) is the zero vector.
 
Double_t CalculateCosine ()
 Cosine of the angle between dX and dV, clamped to [-1, 1] (NaN for a zero vector).
 
Double_t CalculateAngle (Bool_t rad=kFALSE)
 Angle between dX and dV in degree (radian if rad), NaN for a zero vector.
 
Long_t CountDeriving ()
 Smaller of the step counts of the two particles.
 
Double_t CaculateSPD ()
 Relative speed, norm of dV (c).
 
Double_t CalculateDistance ()
 Distance, norm of dX (fm).
 
Double_t CalculateRadialVelocity ()
 dX.dV/norm(dX) (c), positive when receding; NaN if dX = 0.
 

Private Attributes

particle * p1
 
particle * p2
 the two particles (not owned)
 

Additional Inherited Members

- Public Types inherited from inspector
enum  methodID {
  kInvalid = 0 , kCOS , kDEG , kRAD ,
  kCNT , kSPDG , kSPDL , kDSTG ,
  kDSTL , kVRG , kVRL , kKEG ,
  kKEL , kPEG , kPEL , kPKG ,
  kPKL , kEDG , kEDL , kTMG ,
  kTML , kDXG , kDXL , kDNG ,
  kDNL , kDSG , kDSL , kACG ,
  kACL , kVOUT , kVOUTA , kASYD ,
  kASYV
}
 Method identifier. More...
 
- Static Public Member Functions inherited from inspector
static methodID ParseMethod (TString name)
 Parse a method name.
 
static TString MethodName (methodID id)
 Name of a method identifier.
 
- Protected Attributes inherited from inspector
TString ftn =""
 method name as given
 
methodID mtd =kInvalid
 parsed method
 
Double_t val =-1
 criterion value
 
Bool_t abort =kFALSE
 abort inspector
 

Detailed Description

Inspector on a pair of particles.

dX and dV are the relative position (fm) and velocity (c) of the two particles, \(\vec{dX} = \vec x_1 - \vec x_2\). With many bodies, each inspectorP looks only at its own two particles; the other bodies are ignored.

Method Satisfied when
"COS" cosine of the angle between dX and dV is less than the value
"DEG" angle between dX and dV, in degree, is less than the value
"RAD" angle between dX and dV, in radian, is less than the value
"CNT" number of derived steps is greater than the value
"SPDG" relative speed (norm of dV) is greater than the value
"SPDL" relative speed (norm of dV) is less than the value
"DSTG" distance (norm of dX) is greater than the value
"DSTL" distance (norm of dX) is less than the value
"VRG" radial velocity dX.dV/norm(dX) is greater than the value (value 0 : receding)
"VRL" radial velocity dX.dV/norm(dX) is less than the value (value 0 : approaching)

The enumerators are kCOS kDEG kRAD kCNT kSPDG kSPDL kDSTG kDSTL kVRG kVRL (inspector::methodID), so new inspectorP(p1, p2, inspector::kDEG, 1) is the same as new inspectorP(p1, p2, "DEG", 1).

The angle is \(\mathrm{atan2}(|\vec{dX}\times\vec{dV}|, \vec{dX}\cdot\vec{dV})\) : accurate also near 0 and 180 degree (acos of the cosine is not). "COS" is clamped to [-1, 1]. A small "DEG" means dX and dV are parallel, i.e. the particles fly apart: it is the asymptote condition after a scattering. "CNT" is the smaller of the step counts of the two particles (an invincible particle counts steps too).

Zero vectors
If dX or dV is exactly the zero vector the angle / cosine (and the radial velocity for dX = 0) is undefined: Evaluate() returns NaN and Inspect() is kFALSE, i.e. the inspector is simply not satisfied (also for the "<" methods).

Definition at line 185 of file inspector.hpp.

Constructor & Destructor Documentation

◆ inspectorP() [1/2]

inspectorP::inspectorP ( particle *  p1_,
particle *  p2_,
TString  method_,
Double_t  val_ = -1 
)

Make an inspector on two particles, method by name.

Parameters
p1_first particle (of the event)
p2_second particle (of the event)
method_method name, see the table
val_criterion value (angle in degree for "DEG", radian for "RAD", distance in fm, speed in c, count for "CNT")

The particles must belong to the event the inspector is added to (event::event(event&) relinks it by index).

Definition at line 54 of file inspector.cpp.

◆ inspectorP() [2/2]

inspectorP::inspectorP ( particle *  p1_,
particle *  p2_,
methodID  method_,
Double_t  val_ = -1 
)

Make an inspector on two particles, method by enumerator (see above).

Definition at line 60 of file inspector.cpp.

Member Function Documentation

◆ CaculateSPD()

Double_t inspectorP::CaculateSPD ( )
protected

Relative speed, norm of dV (c).

Definition at line 140 of file inspector.cpp.

◆ CalculateAngle()

Double_t inspectorP::CalculateAngle ( Bool_t  rad = kFALSE)
protected

Angle between dX and dV in degree (radian if rad), NaN for a zero vector.

Definition at line 131 of file inspector.cpp.

◆ CalculateCosine()

Double_t inspectorP::CalculateCosine ( )
protected

Cosine of the angle between dX and dV, clamped to [-1, 1] (NaN for a zero vector).

Definition at line 122 of file inspector.cpp.

◆ CalculateDistance()

Double_t inspectorP::CalculateDistance ( )
protected

Distance, norm of dX (fm).

Definition at line 110 of file inspector.cpp.

◆ CalculateRadialVelocity()

Double_t inspectorP::CalculateRadialVelocity ( )
protected

dX.dV/norm(dX) (c), positive when receding; NaN if dX = 0.

Definition at line 114 of file inspector.cpp.

◆ CountDeriving()

Long_t inspectorP::CountDeriving ( )
protected

Smaller of the step counts of the two particles.

Definition at line 144 of file inspector.cpp.

◆ Evaluate()

Double_t inspectorP::Evaluate ( )
virtual

The compared quantity: cosine, angle (degree or radian), step count, relative speed (c), distance (fm) or radial velocity (c). NaN for a zero vector (angle, cosine, radial velocity); for an invalid method it prints a message and gives 0.

Reimplemented from inspector.

Definition at line 66 of file inspector.cpp.

◆ GetParticle1()

particle * inspectorP::GetParticle1 ( )
inline

The first particle.

Definition at line 222 of file inspector.hpp.

◆ GetParticle2()

particle * inspectorP::GetParticle2 ( )
inline

The second particle.

Definition at line 224 of file inspector.hpp.

◆ Inspect()

Bool_t inspectorP::Inspect ( )
virtual

Whether the condition is satisfied now.

Returns
the comparison of Evaluate() with the criterion, in the direction given by the table; kFALSE for an invalid method or a zero vector.

Reimplemented from inspector.

Definition at line 85 of file inspector.cpp.

◆ IsDegenerate()

Bool_t inspectorP::IsDegenerate ( Bool_t  needV = kTRUE)
protected

Whether dX (or, if needV, dV) is the zero vector.

Definition at line 103 of file inspector.cpp.

◆ IsInspectorP()

Bool_t inspectorP::IsInspectorP ( )
inlinevirtual

Always kTRUE.

Reimplemented from inspector.

Definition at line 248 of file inspector.hpp.

◆ IsValid()

Bool_t inspectorP::IsValid ( )
virtual

Whether the method is one of the inspectorP methods.

Reimplemented from inspector.

Definition at line 81 of file inspector.cpp.

◆ Print()

TString inspectorP::Print ( Bool_t  particles = kFALSE,
Bool_t  mechanics = kFALSE,
Bool_t  mute = kFALSE,
Bool_t  pprint = kFALSE 
)
virtual

Describe as text "[ Inspector Particle: MTD, CRT (criterion), VAL (value), RST (result) ]".

Parameters
particleskTRUE also prints the two particles
mechanicsnot used
mutekFALSE (default) also prints to stdout
pprintnot used

Reimplemented from inspector.

Definition at line 214 of file inspector.cpp.

◆ SetInitial_D()

Bool_t inspectorP::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 (setting the initial position from the present state).

Parameters
indexfalse : move p2 ; true : move p1
mtd"COS", "DEG" or "RAD" (empty : the method of the inspector)
varthe target angle margin
Returns
kTRUE, or kFALSE for another method.
Warning
Unfinished and not trustworthy: the function itself prints "needs to be fixed. do not use without any instruction" on stderr. It changes the position of a particle.
Todo:
Fix or remove (see TODO.md).

(p0_->GetV().Norm2Sqr()));

Definition at line 149 of file inspector.cpp.

◆ SetParticle1()

void inspectorP::SetParticle1 ( particle *  p1_)
inline

Set the first particle.

Definition at line 217 of file inspector.hpp.

◆ SetParticle2()

void inspectorP::SetParticle2 ( particle *  p2_)
inline

Set the second particle.

Definition at line 219 of file inspector.hpp.

◆ SetParticles()

void inspectorP::SetParticles ( particle *  p1_,
particle *  p2_ 
)
inline

Set both particles.

Definition at line 215 of file inspector.hpp.

Member Data Documentation

◆ p1

particle* inspectorP::p1
private

Definition at line 267 of file inspector.hpp.

◆ p2

particle * inspectorP::p2
private

the two particles (not owned)

Definition at line 267 of file inspector.hpp.


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