Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
JSIRENE::JSphericityTensor Struct Reference

Class for sphericity tensor calculations. More...

#include <JEventShapeVariables.hh>

Inheritance diagram for JSIRENE::JSphericityTensor:
JMATH::JMatrix3S JMATH::JMatrix3D JMATH::JMath< JMatrix3D > JLANG::JEquals< JFirst_t, JSecond_t >

Public Types

typedef JMatrix3S::eigen_values eigen_values
 

Public Member Functions

 JSphericityTensor ()
 Default constructor. More...
 
 JSphericityTensor (std::vector< Trk >::const_iterator __begin, std::vector< Trk >::const_iterator __end, const double r=2.0)
 Constructor. More...
 
 JSphericityTensor (const Evt &event, const double r=2.0)
 Constructor. More...
 
const eigen_valuesgetEigenValues () const
 Get eigenvalues. More...
 
double getSphericity () const
 Get sphericity. More...
 
double getAplanarity () const
 Get aplanarity. More...
 
double getCircularity () const
 Get circularity. More...
 
double getPlanarFlow () const
 Get planar flow. More...
 
double getC () const
 Get C-variable. More...
 
double getD () const
 Get D-variable. More...
 
void invert ()
 Invert matrix. More...
 
eigen_values getEigenValues (const double epsilon=1e-6) const
 Get eigen values. More...
 
JMatrix3DsetIdentity ()
 Set to identity matrix. More...
 
void set (const JMatrix3D &A)
 Set matrix. More...
 
JMatrix3Dreset ()
 Set matrix to the null matrix. More...
 
JMatrix3Dtranspose ()
 Transpose. More...
 
JMatrix3Dnegate ()
 Negate matrix. More...
 
JMatrix3Dadd (const JMatrix3D &A)
 Matrix addition. More...
 
JMatrix3Dsub (const JMatrix3D &A)
 Matrix subtraction. More...
 
JMatrix3Dmul (const double factor)
 Scale matrix. More...
 
JMatrix3Dmul (const JMatrix3D &A, const JMatrix3D &B)
 Matrix multiplication. More...
 
JMatrix3Dmul (const JSecond_t &object)
 Multiply with object. More...
 
JMatrix3Ddiv (const double factor)
 Scale matrix. More...
 
bool equals (const JMatrix3D &A, const double eps=std::numeric_limits< double >::min()) const
 Equality. More...
 
bool isIdentity (const double eps=std::numeric_limits< double >::min()) const
 Test identity. More...
 
double getDeterminant () const
 Get determinant of matrix. More...
 
void transform (double &__x, double &__y, double &__z) const
 Transform. More...
 

Static Public Member Functions

static const JMatrix3DgetInstance ()
 Get reference to unique instance of this class object. More...
 
static const JMatrix3DgetIdentity ()
 Get reference to unique instance of this class object. More...
 

Public Attributes

double a00
 
double a01
 
double a02
 
double a10
 
double a11
 
double a12
 
double a20
 
double a21
 
double a22
 

Private Attributes

eigen_values lambda
 sorted eigenvalues More...
 

Detailed Description

Class for sphericity tensor calculations.


The tensor is constructed following the definition in section 15.2.1 of arXiv:hep-ph/0603175v2.

Definition at line 236 of file JEventShapeVariables.hh.

Member Typedef Documentation

◆ eigen_values

Definition at line 239 of file JEventShapeVariables.hh.

Constructor & Destructor Documentation

◆ JSphericityTensor() [1/3]

JSIRENE::JSphericityTensor::JSphericityTensor ( )
inline

Default constructor.

Definition at line 245 of file JEventShapeVariables.hh.

246  {}

◆ JSphericityTensor() [2/3]

JSIRENE::JSphericityTensor::JSphericityTensor ( std::vector< Trk >::const_iterator  __begin,
std::vector< Trk >::const_iterator  __end,
const double  r = 2.0 
)
inline

Constructor.

Parameters
__beginbeginning of track data
__endend of track data
rthe power of the momentum-dependence

Definition at line 256 of file JEventShapeVariables.hh.

259  {
260  using namespace std;
261  using namespace JPP;
262 
263  double norm = 0.0;
264 
265  for (vector<Trk>::const_iterator i = __begin; i != __end; ++i) {
266 
267  if (is_finalstate(*i)) {
268 
269  const Vec p = getKineticEnergy(*i) * i->dir;
270 
271  const double c = pow(p.len(), r-2);
272 
273  a00 += c * p.x * p.x;
274  a01 += c * p.x * p.y;
275  a02 += c * p.x * p.z;
276 
277  a10 += c * p.y * p.x;
278  a11 += c * p.y * p.y;
279  a12 += c * p.y * p.z;
280 
281  a20 += c * p.z * p.x;
282  a21 += c * p.z * p.y;
283  a22 += c * p.z * p.z;
284 
285  norm += c * p.dot(p);
286  }
287  }
288 
289  this->div(norm);
290 
292  }
JMatrix3D & div(const double factor)
Scale matrix.
eigen_values getEigenValues(const double epsilon=1e-6) const
Get eigen values.
Definition: JMatrix3S.hh:227
double getKineticEnergy(const Trk &trk)
Get track kinetic energy.
bool is_finalstate(const Trk &track)
Test whether given track corresponds to a final state particle.
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
data_type r[M+1]
Definition: JPolint.hh:868
Definition: JSTDTypes.hh:14
eigen_values lambda
sorted eigenvalues
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:13
double len() const
Get length.
Definition: Vec.hh:145
double dot(const Vec &v) const
Get dot product.
Definition: Vec.hh:36
double z
Definition: Vec.hh:14
double x
Definition: Vec.hh:14
double y
Definition: Vec.hh:14

◆ JSphericityTensor() [3/3]

JSIRENE::JSphericityTensor::JSphericityTensor ( const Evt event,
const double  r = 2.0 
)
inline

Constructor.

Parameters
eventevent
rthe power of the momentum dependence

Definition at line 301 of file JEventShapeVariables.hh.

302  :
303  JSphericityTensor(event.mc_trks.begin(), event.mc_trks.end(), r)
304  {}
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
Definition: Evt.hh:49
JSphericityTensor()
Default constructor.

Member Function Documentation

◆ getEigenValues() [1/2]

const eigen_values& JSIRENE::JSphericityTensor::getEigenValues ( ) const
inline

Get eigenvalues.

Returns
eigenvalues

Definition at line 312 of file JEventShapeVariables.hh.

313  {
314  return lambda;
315  }

◆ getSphericity()

double JSIRENE::JSphericityTensor::getSphericity ( ) const
inline

Get sphericity.

Returns
sphericity

Definition at line 323 of file JEventShapeVariables.hh.

324  {
325  return 3 * (lambda[1] + lambda[2]) / 2.0;
326  }

◆ getAplanarity()

double JSIRENE::JSphericityTensor::getAplanarity ( ) const
inline

Get aplanarity.

Returns
aplanarity

Definition at line 334 of file JEventShapeVariables.hh.

335  {
336  return 3 * lambda[2] / 2.0;
337  }

◆ getCircularity()

double JSIRENE::JSphericityTensor::getCircularity ( ) const
inline

Get circularity.

Returns
circularity

Definition at line 345 of file JEventShapeVariables.hh.

346  {
347  return (fabs(lambda[0] + lambda[1]) > 0.0 ?
348  2 * lambda[1] / (lambda[0] + lambda[1]) : 0.0);
349  }

◆ getPlanarFlow()

double JSIRENE::JSphericityTensor::getPlanarFlow ( ) const
inline

Get planar flow.

Returns
planar flow

Definition at line 357 of file JEventShapeVariables.hh.

358  {
359  return 4 * lambda[0] * lambda[1] / (lambda[0] + lambda[1]) / (lambda[0] + lambda[1]);
360  }

◆ getC()

double JSIRENE::JSphericityTensor::getC ( ) const
inline

Get C-variable.

Returns
C

Definition at line 368 of file JEventShapeVariables.hh.

369  {
370  return 3 * (lambda[0]*lambda[1] + lambda[0]*lambda[2] + lambda[1]*lambda[2]);
371  }

◆ getD()

double JSIRENE::JSphericityTensor::getD ( ) const
inline

Get D-variable.

Returns
D

Definition at line 379 of file JEventShapeVariables.hh.

380  {
381  return 27 * lambda[0] * lambda[1] * lambda[2];
382  }

◆ invert()

void JMATH::JMatrix3S::invert ( )
inlineinherited

Invert matrix.

Definition at line 80 of file JMatrix3S.hh.

81  {
82  using std::swap;
83 
84  // LDU decomposition
85 
86  int p0 = 0; // permute row 0
87  int p1 = 0; // permute row 1
88 
89  double val;
90 
91  val = a00;
92 
93  if (fabs(a10) > fabs(val)) {
94  p0 = 1;
95  val = a10;
96  }
97 
98  if (fabs(a20) > fabs(val)) {
99  p0 = 2;
100  val = a20;
101  }
102 
103  switch (p0) {
104 
105  case 1:
106  swap(a00,a10);
107  swap(a01,a11);
108  swap(a02,a12);
109  break;
110 
111  case 2:
112  swap(a00,a20);
113  swap(a01,a21);
114  swap(a02,a22);
115  break;
116  }
117 
118  if (val == 0) {
119  throw JDivisionByZero("LDU decomposition zero pivot");
120  }
121 
122  a10 /= val;
123  a11 -= a10 * a01;
124  a12 -= a10 * a02;
125 
126  a20 /= val;
127  a21 -= a20 * a01;
128  a22 -= a20 * a02;
129 
130  val = a11;
131 
132  if (fabs(a21) > fabs(val)) {
133  p1 = 2;
134  val = a21;
135  }
136 
137  switch (p1) {
138 
139  case 2:
140  swap(a10,a20);
141  swap(a11,a21);
142  swap(a12,a22);
143  break;
144  }
145 
146  if (val == 0) {
147  throw JDivisionByZero("LDU decomposition zero pivot");
148  }
149 
150  a21 /= val;
151  a22 -= a21 * a12;
152 
153  // invert D
154 
155  if (a22 == 0) {
156  throw JDivisionByZero("D matrix not invertable");
157  }
158 
159  a00 = 1.0 / a00;
160  a11 = 1.0 / a11;
161  a22 = 1.0 / a22;
162 
163  // invert U
164 
165  a01 *= -a00;
166  a01 *= a11;
167 
168  a02 *= -a00;
169  a02 -= a01 * a12;
170  a02 *= a22;
171 
172  a12 *= -a11;
173  a12 *= a22;
174 
175  // invert L
176 
177  a21 = -a21;
178  a20 = -a20;
179  a20 -= a21 * a10;
180  a10 = -a10;
181 
182  // U^-1 x L^-1
183 
184  a00 += a01 * a10 + a02 * a20;
185  a01 += a02 * a21;
186  a10 *= a11;
187  a10 += a12 * a20;
188  a11 += a12 * a21;
189  a20 *= a22;
190  a21 *= a22;
191 
192  switch (p1) {
193 
194  case 2:
195  swap(a01,a02);
196  swap(a11,a12);
197  swap(a21,a22);
198  break;
199  }
200 
201  switch (p0) {
202 
203  case 1:
204  swap(a00,a01);
205  swap(a10,a11);
206  swap(a20,a21);
207  break;
208 
209  case 2:
210  swap(a00,a02);
211  swap(a10,a12);
212  swap(a20,a22);
213  break;
214  }
215  }
TPaveText * p1

◆ getEigenValues() [2/2]

eigen_values JMATH::JMatrix3S::getEigenValues ( const double  epsilon = 1e-6) const
inlineinherited

Get eigen values.


The eigen values sorted in decreasing order of absolute values.
Algorithm taken from "Eigenvalues of a symmetric 3x3 matrix"
by Oliver K. Smith; see reference.

Parameters
epsilonprecision
Returns
eigen values

Definition at line 227 of file JMatrix3S.hh.

228  {
229  using namespace std;
230 
231  eigen_values eigenvalues;
232 
233  const double p1 = a01*a01 + a02*a02 + a12*a12;
234 
235  if (fabs(p1 - 1.0) > epsilon) {
236 
237  const double q = (a00 + a11 + a22) / 3.0;
238  const double p2 = (a00 - q)*(a00 - q) + (a11 - q)*(a11 - q) + (a22 - q)*(a22 - q) + 2*p1;
239  const double p = sqrt(p2 / 6.0);
240 
241  JMatrix3S B(*this);
242 
243  B.sub(q * JMatrix3D::getIdentity());
244  B.div(p);
245 
246  const double r = B.getDeterminant() / 2.0;
247  const double phi = (r < -1.0 ? PI / 3.0 : (r > 1.0 ? 0.0 : acos(r) / 3.0));
248 
249  eigenvalues[0] = q + 2*p*cos(phi);
250  eigenvalues[2] = q + 2*p*cos(phi + 2*PI/3.0);
251  eigenvalues[1] = 3 * q - eigenvalues[0] - eigenvalues[2];
252 
253  } else {
254 
255  eigenvalues = eigen_values{ a00, a11, a12 };
256  }
257 
258  // sort absolute values in descending order
259 
260  if (fabs(eigenvalues[0]) < fabs(eigenvalues[1])) {
261  swap(eigenvalues[0], eigenvalues[1]);
262  }
263 
264  if (fabs(eigenvalues[1]) < fabs(eigenvalues[2])) {
265 
266  swap(eigenvalues[1], eigenvalues[2]);
267 
268  if (fabs(eigenvalues[0]) < fabs(eigenvalues[1])) {
269  swap(eigenvalues[0], eigenvalues[1]);
270  }
271  }
272 
273  return eigenvalues;
274  }
static const JMatrix3D & getIdentity()
Get reference to unique instance of this class object.
3 x 3 symmetric matrix
Definition: JMatrix3S.hh:31
std::array< double, 3 > eigen_values
Type definition of Eigen values.
Definition: JMatrix3S.hh:36
const double epsilon
Definition: JQuadrature.cc:21
static const double PI
Mathematical constants.

◆ getInstance()

static const JMatrix3D& JMATH::JMatrix3D::getInstance ( )
inlinestaticinherited

Get reference to unique instance of this class object.

Returns
zero matrix

Definition at line 78 of file JMath/JMatrix3D.hh.

79  {
80  static JMatrix3D matrix;
81 
82  return matrix;
83  }

◆ setIdentity()

JMatrix3D& JMATH::JMatrix3D::setIdentity ( )
inlineinherited

Set to identity matrix.

Returns
this matrix

Definition at line 91 of file JMath/JMatrix3D.hh.

92  {
93  a00 = 1.0; a01 = 0.0; a02 = 0.0;
94  a10 = 0.0; a11 = 1.0; a12 = 0.0;
95  a20 = 0.0; a21 = 0.0; a22 = 1.0;
96 
97  return *this;
98  }

◆ getIdentity()

static const JMatrix3D& JMATH::JMatrix3D::getIdentity ( )
inlinestaticinherited

Get reference to unique instance of this class object.

Returns
identity matrix

Definition at line 106 of file JMath/JMatrix3D.hh.

107  {
108  static JMatrix3D matrix(JMatrix3D().setIdentity());
109 
110  return matrix;
111  }
JMatrix3D()
Default constructor.
JMatrix3D & setIdentity()
Set to identity matrix.

◆ set()

void JMATH::JMatrix3D::set ( const JMatrix3D A)
inlineinherited

Set matrix.

Parameters
Amatrix

Definition at line 119 of file JMath/JMatrix3D.hh.

120  {
121  static_cast<JMatrix3D&>(*this) = A;
122  }

◆ reset()

JMatrix3D& JMATH::JMatrix3D::reset ( )
inlineinherited

Set matrix to the null matrix.

Returns
this matrix

Definition at line 130 of file JMath/JMatrix3D.hh.

131  {
132  *this = JMatrix3D();
133 
134  return *this;
135  }

◆ transpose()

JMatrix3D& JMATH::JMatrix3D::transpose ( )
inlineinherited

Transpose.

Returns
this matrix

Definition at line 143 of file JMath/JMatrix3D.hh.

144  {
145  using std::swap;
146 
147  swap(a10, a01);
148  swap(a20, a02);
149  swap(a21, a12);
150 
151  return *this;
152  }

◆ negate()

JMatrix3D& JMATH::JMatrix3D::negate ( )
inlineinherited

Negate matrix.

Returns
-this matrix

Definition at line 160 of file JMath/JMatrix3D.hh.

161  {
162  a00 = -a00; a01 = -a01; a02 = -a02;
163  a10 = -a10; a11 = -a11; a12 = -a12;
164  a20 = -a20; a21 = -a21; a22 = -a22;
165 
166  return *this;
167  }

◆ add()

JMatrix3D& JMATH::JMatrix3D::add ( const JMatrix3D A)
inlineinherited

Matrix addition.

Parameters
Amatrix
Returns
this matrix + A

Definition at line 176 of file JMath/JMatrix3D.hh.

177  {
178  a00 += A.a00; a01 += A.a01; a02 += A.a02;
179  a10 += A.a10; a11 += A.a11; a12 += A.a12;
180  a20 += A.a20; a21 += A.a21; a22 += A.a22;
181 
182  return *this;
183  }

◆ sub()

JMatrix3D& JMATH::JMatrix3D::sub ( const JMatrix3D A)
inlineinherited

Matrix subtraction.

Parameters
Amatrix
Returns
this matrix - A

Definition at line 192 of file JMath/JMatrix3D.hh.

193  {
194  a00 -= A.a00; a01 -= A.a01; a02 -= A.a02;
195  a10 -= A.a10; a11 -= A.a11; a12 -= A.a12;
196  a20 -= A.a20; a21 -= A.a21; a22 -= A.a22;
197 
198  return *this;
199  }

◆ mul() [1/3]

JMatrix3D& JMATH::JMatrix3D::mul ( const double  factor)
inlineinherited

Scale matrix.

Parameters
factorfactor
Returns
this matrix * factor

Definition at line 208 of file JMath/JMatrix3D.hh.

209  {
210  a00 *= factor; a01 *= factor; a02 *= factor;
211  a10 *= factor; a11 *= factor; a12 *= factor;
212  a20 *= factor; a21 *= factor; a22 *= factor;
213 
214  return *this;
215  }

◆ mul() [2/3]

JMatrix3D& JMATH::JMatrix3D::mul ( const JMatrix3D A,
const JMatrix3D B 
)
inlineinherited

Matrix multiplication.

Parameters
Amatrix
Bmatrix
Returns
this matrix

Definition at line 241 of file JMath/JMatrix3D.hh.

243  {
244  a00 = A.a00 * B.a00 + A.a01 * B.a10 + A.a02 * B.a20;
245  a01 = A.a00 * B.a01 + A.a01 * B.a11 + A.a02 * B.a21;
246  a02 = A.a00 * B.a02 + A.a01 * B.a12 + A.a02 * B.a22;
247 
248  a10 = A.a10 * B.a00 + A.a11 * B.a10 + A.a12 * B.a20;
249  a11 = A.a10 * B.a01 + A.a11 * B.a11 + A.a12 * B.a21;
250  a12 = A.a10 * B.a02 + A.a11 * B.a12 + A.a12 * B.a22;
251 
252  a20 = A.a20 * B.a00 + A.a21 * B.a10 + A.a22 * B.a20;
253  a21 = A.a20 * B.a01 + A.a21 * B.a11 + A.a22 * B.a21;
254  a22 = A.a20 * B.a02 + A.a21 * B.a12 + A.a22 * B.a22;
255 
256  return *this;
257  }

◆ mul() [3/3]

JMatrix3D & JMATH::JMath< JMatrix3D , JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }

◆ div()

JMatrix3D& JMATH::JMatrix3D::div ( const double  factor)
inlineinherited

Scale matrix.

Parameters
factorfactor
Returns
this matrix / factor

Definition at line 224 of file JMath/JMatrix3D.hh.

225  {
226  a00 /= factor; a01 /= factor; a02 /= factor;
227  a10 /= factor; a11 /= factor; a12 /= factor;
228  a20 /= factor; a21 /= factor; a22 /= factor;
229 
230  return *this;
231  }

◆ equals()

bool JMATH::JMatrix3D::equals ( const JMatrix3D A,
const double  eps = std::numeric_limits<double>::min() 
) const
inlineinherited

Equality.

Parameters
Amatrix
epsnumerical precision
Returns
true if matrices identical; else false

Definition at line 267 of file JMath/JMatrix3D.hh.

269  {
270  return (fabs(a00 - A.a00) <= eps &&
271  fabs(a01 - A.a01) <= eps &&
272  fabs(a02 - A.a02) <= eps &&
273  fabs(a10 - A.a10) <= eps &&
274  fabs(a11 - A.a11) <= eps &&
275  fabs(a12 - A.a12) <= eps &&
276  fabs(a20 - A.a20) <= eps &&
277  fabs(a21 - A.a21) <= eps &&
278  fabs(a22 - A.a22) <= eps);
279  }

◆ isIdentity()

bool JMATH::JMatrix3D::isIdentity ( const double  eps = std::numeric_limits<double>::min()) const
inlineinherited

Test identity.

Parameters
epsnumerical precision
Returns
true if identity matrix; else false

Definition at line 288 of file JMath/JMatrix3D.hh.

289  {
290  return equals(getIdentity(), eps);
291  }
bool equals(const JMatrix3D &A, const double eps=std::numeric_limits< double >::min()) const
Equality.

◆ getDeterminant()

double JMATH::JMatrix3D::getDeterminant ( ) const
inlineinherited

Get determinant of matrix.

Returns
determinant of matrix

Definition at line 299 of file JMath/JMatrix3D.hh.

300  {
301  double det = 0.0;
302 
303  det += a00 * (a11 * a22 - a21 * a12);
304  det -= a01 * (a10 * a22 - a20 * a12);
305  det += a02 * (a10 * a21 - a20 * a11);
306 
307  return det;
308  }

◆ transform()

void JMATH::JMatrix3D::transform ( double &  __x,
double &  __y,
double &  __z 
) const
inlineinherited

Transform.

Parameters
__xx value
__yy value
__zz value

Definition at line 318 of file JMath/JMatrix3D.hh.

319  {
320  const double x = a00 * __x + a01 * __y + a02 * __z;
321  const double y = a10 * __x + a11 * __y + a12 * __z;
322  const double z = a20 * __x + a21 * __y + a22 * __z;
323 
324  __x = x;
325  __y = y;
326  __z = z;
327  }

Member Data Documentation

◆ lambda

eigen_values JSIRENE::JSphericityTensor::lambda
private

sorted eigenvalues

Definition at line 387 of file JEventShapeVariables.hh.

◆ a00

double JMATH::JMatrix3D::a00
inherited

Definition at line 385 of file JMath/JMatrix3D.hh.

◆ a01

double JMATH::JMatrix3D::a01
inherited

Definition at line 385 of file JMath/JMatrix3D.hh.

◆ a02

double JMATH::JMatrix3D::a02
inherited

Definition at line 385 of file JMath/JMatrix3D.hh.

◆ a10

double JMATH::JMatrix3D::a10
inherited

Definition at line 386 of file JMath/JMatrix3D.hh.

◆ a11

double JMATH::JMatrix3D::a11
inherited

Definition at line 386 of file JMath/JMatrix3D.hh.

◆ a12

double JMATH::JMatrix3D::a12
inherited

Definition at line 386 of file JMath/JMatrix3D.hh.

◆ a20

double JMATH::JMatrix3D::a20
inherited

Definition at line 387 of file JMath/JMatrix3D.hh.

◆ a21

double JMATH::JMatrix3D::a21
inherited

Definition at line 387 of file JMath/JMatrix3D.hh.

◆ a22

double JMATH::JMatrix3D::a22
inherited

Definition at line 387 of file JMath/JMatrix3D.hh.


The documentation for this struct was generated from the following file: