Belle II Software  release-06-01-15
Sutool.h
1 // -*- C++ -*-
2 //
3 // Package: <package>
4 // Module: Sutool
5 //
6 // Description: <one line class summary>
7 //
8 // Usage:
9 // <usage>
10 //
11 // Author: Sadaharu Uehara
12 // Created: Thu May 8 15:09:38 JST 1997
13 // $Id$
14 //
15 // Revision history
16 // Modified to be suitable to Belle II style
17 //
18 // $Log$
19 
20 #include<TRandom.h>
21 #include<TLorentzVector.h>
22 #include<TVector3.h>
23 #include <fstream>
24 
25 #ifndef PACKAGE_SUTOOL_H_INCLUDED
26 #define PACKAGE_SUTOOL_H_INCLUDED
27 
28 namespace Belle2 {
34  class Sutool {
35  // friend classes and functions
36 
37  public:
38  // Constructors and destructor
39  Sutool() {};
40  ~Sutool() {};
41 
42  // member functions
43  void nextline(std::ifstream& infile)
44  // skip to end of line
45  {
46  char s ;
47  do { infile.get(s) ; } while (s != '\n');
48  };
49 
50  double p2bdy(double, double, double, int&);
51  int pdecy(double, double*, const TVector3&, TLorentzVector*, int);
52  void rotate(TLorentzVector&, double, double);
53  float interp(float, float, float, float, float);
54  int poisson(double);
55  };
56 
57 
58  class Interps {
59  public:
60  Interps(void) {};
61  Interps(double x1, double x2, int nd, double* yd)
62  {
63  xmin = x1; xmax = x2;
64  ndiv = nd; ydata = yd;
65  return;
66  };
67 
68  ~Interps(void) {};
69 
70  double get_val(double x)
71  {
72  double rn = (x - xmin) / (xmax - xmin) * (double)ndiv;
73  int irn = (int)rn;
74  if (irn <= 0) irn = 1;
75  else if (irn >= (ndiv - 1)) irn = ndiv - 2;
76 
77  double x1 = interp(&ydata[irn - 1], rn - (double)irn);
78  return x1 ;
79  };
80 
81  void change(double x1, double x2, int nd, double* yd)
82  {
83  xmin = x1; xmax = x2;
84  ndiv = nd; ydata = yd;
85  return;
86  };
87 
88  int check_xrange(double x)
89  {
90  if (x < xmin) return -1 ;
91  else if (x > xmax) return 1;
92  else return 0;
93  };
94 
95 
96  private:
97  double interp(double* y, double x)
98  {
99 
100  double a = y[1] - y[0];
101  double b = y[2] - y[1];
102  double c = y[3] - y[2];
103  double d = b - a;
104  double e = c - b;
105  double f = e - d;
106 
107  double b2 = 0.25 * x * (x - 1.);
108  double b3 = 2. / 3.*b2 * (x - 0.5);
109 
110  return y[1] + x * b + b2 * (d + e) + b3 * f;
111  };
112 
113  public:
114  double xmin, xmax;
115  int ndiv;
116  double* ydata;
117 
118 
119 
120 
121 
122  };
123 
125 }
126 #endif /* PACKAGE_SUTOOL_H_INCLUDED */
127 
TString rn()
Get random string.
Definition: tools.h:38
Abstract base class for different kinds of events.