All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
MathOperator.hh
Go to the documentation of this file.
1 #ifndef _MathOperator_hh_
2 #define _MathOperator_hh_
3 #include <stdlib.h>
4 #include <cmath>
5 #include <vector>
6 #include <iostream>
7 namespace TTbarAnalysis
8 {
9  class MathOperator
10  {
11  public:
12  //
13  // Constants
14  //
15 
16  //
17  // Constructors
18  //
19  MathOperator ();
20  virtual ~MathOperator ();
21  //
22  // Methods
23  //
24  static float getModule(const std::vector< int > & v);
25  static float getModule(const std::vector< float > & v);
26  static float getModule(const double * vector1);
27 
28  static bool approximatelyEqual(const double * start1, const double * end, double p);
29  static bool approximatelyEqual(const double * start1, const float * end, double p);
30 
31  static float getDistance(const double * start, const double * end);
32  static float getDistance(const float * start, const float * end);
33 
34  static std::vector< float > * vectorProduct(const std::vector< float > & v1,const std::vector< float > & v2);
35 
36  static std::vector< float > getAngles(std::vector< float > & direction);
37  static float getAngle(const double * vector1, const double * vector2);
38 
39  static float getDistanceTo(const std::vector< int > & vectorPoint1,const std::vector< float > & vector1, const std::vector< int > * pointOfLine );
40  static float getDistanceTo(const double * vectorPoint1, std::vector< float > & vector1,const double * pointOfLine );
41 
42  static std::vector< float > getDirection(std::vector< int > & vectorPoint1, std::vector< int > & vectorPoint2);
43  static std::vector< float > getDirection(const double * vectorPoint1, const double * vectorPoint2);
44  static std::vector< float > getDirection(const double * vectorPoint1);
45  static std::vector< float > getDirection(const float * vectorPoint1);
46  static std::vector< std::vector< int > * > * GetMagicNumbers();
47  static std::vector< int > * getPoint(int x, int y, int z);
48  static float getPt(const double * momentum);
49  static float getRapidity(const double * momentum);
50  static double * getPtOnVector(const double * momentum, const float * target);
51  static double getMissingPt(std::vector< const double * > & vectors, const float * target);
52  static double * toDoubleArray(const float * target, int size);
53  //
54  // Templates
55  //
56  template<class T >
57  static std::vector< T * > * MergeVectors(std::vector< T * > * vector1, std::vector< T * > * vector2);
58 
59  private:
60  //
61  // Data
62  //
63  /* data */
64  //
65  // Private methods
66  //
67  static double * castIntToDouble(int * array);
68  };
69  template<class T >
70  std::vector< T * > * MathOperator::MergeVectors(std::vector< T * > * vector1, std::vector< T * > * vector2)
71  {
72  if (!vector1 || !vector2)
73  {
74  return NULL;
75  }
76  std::vector< T *> * result = new std::vector< T *>();
77  for (int i = 0; i < vector1->size(); i++)
78  {
79  result->push_back(vector1->at(i));
80  }
81  for (int i = 0; i < vector2->size(); i++)
82  {
83  result->push_back(vector2->at(i));
84  }
85  return result;
86 
87  }
88 }
89 #endif
static double * castIntToDouble(int *array)
static double * getPtOnVector(const double *momentum, const float *target)
static std::vector< float > getDirection(std::vector< int > &vectorPoint1, std::vector< int > &vectorPoint2)
static std::vector< float > * vectorProduct(const std::vector< float > &v1, const std::vector< float > &v2)
static float getModule(const std::vector< int > &v)
Definition: MathOperator.cc:52
static bool approximatelyEqual(const double *start1, const double *end, double p)
Definition: MathOperator.cc:5
static float getPt(const double *momentum)
static std::vector< std::vector< int > * > * GetMagicNumbers()
static std::vector< float > getAngles(std::vector< float > &direction)
Definition: MathOperator.cc:97
static double * toDoubleArray(const float *target, int size)
static double getMissingPt(std::vector< const double * > &vectors, const float *target)
static std::vector< int > * getPoint(int x, int y, int z)
static float getDistance(const double *start, const double *end)
Definition: MathOperator.cc:22
static std::vector< T * > * MergeVectors(std::vector< T * > *vector1, std::vector< T * > *vector2)
Definition: MathOperator.hh:70
static float getDistanceTo(const std::vector< int > &vectorPoint1, const std::vector< float > &vector1, const std::vector< int > *pointOfLine)
static float getAngle(const double *vector1, const double *vector2)
Definition: MathOperator.cc:82
static float getRapidity(const double *momentum)