icemc
 All Classes Namespaces Files Functions Variables Friends Macros Pages
Tools.h
Go to the documentation of this file.
1 
2 //namespace Tools:
4 
5 #ifndef TOOLS_H_
6 #define TOOLS_H_
7 
8 #include "TRandom3.h"
9 #include <vector>
10 
11 //using std::string;
12 //using std::vector;
13 
14 using namespace std;
15 
16 class TSpline5;
17 class TH1;
18 class TGraph;
19 class TH2F;
20 class TRandom3;
21 class TTree;
22 
24 namespace Tools {
25  double dMax(double,double);
26  double dMax(const double*,int);
27  double dvMax(const vector<double>);
28  double dsMax(TSpline5 *sp);
29  double dMin(const double*,int);
30  double dMinNotZero(const double*,int);
31  double dMin(double,double);
32  double getMaxMagnitude(vector<double> v);
33  int Getifreq(double freq,double freq_low,double freq_high,int n);
34  void InterpolateReal(double* array, const unsigned n);
35  void InterpolateComplex(double *array, const unsigned n);
36 
37  void four1(double *data, const int isign,int nsize);
38  void realft(double *data, const int isign, int nsize);
39 
40  void SWAP(double &a, double &b);// swaps two numbers
41  void NormalTimeOrdering(const int n,double *volts);
42  void ShiftLeft(double *x,const int n,int ishift);
43  void ShiftRight(double *x,const int n,int ishift);
44  double GetFWHM(TH1 *h1);
45  void MakeGraph(int index, int n,double *time,double *volts,TGraph *&mygraph,TH2F *&h2, double scalex,double scaley,string xaxistitle,string yaxistitle);
46 
47  double dDot(double*,double*,int);
48  void dCross(double*,double*,double*);
49  double dSquare(double*);
50  double Step(double x);
51  double dGetTheta(double*);
52  double dGetPhi(double*);
53  int WhichIsMax(double *x,int n);
54  int WhichIsMin(double *x,int n);
55 
56  double dSum(double*,int);
57  int iSum(int*,int);
58  void Print(double*,int);
59  void Print(int*,int);
60  void Zero(double *anarray,int n);
61  void Zero(int *anarray,int n);
62  int NonZero(double *anarray,int n); // how many bins are nonzero
63  void GetNumbersAsStringArray(ifstream& fin, ofstream& fout,vector<string>& vnumbers, int nelements);
64  void GetNext2NumbersAsString(ifstream& fin,ofstream& fout,string& number1,string& number2, string& stherest);
65  void GetNextNumberAsString(ifstream& fin,ofstream& fout,string& number);
66 
67  int findIndex(double *freqlab,double freq,int npoints,double min,double max); // this is the same thing but more general
68  void get_random_rician(double signal, double signal_phase, double sigma, double& amplitude, double &phase);
69  void get_circular_bivariate_normal_random_variable(double& rand_gauss_a, double& rand_gauss_b);
70  int round(double number);
71 
72  double AbbyPhiCalc(double x_abby, double y_abby);
73 
74  template <class T, class U> void vector_element_convert(const vector<T>& input, vector<U>& output){
75  output.clear();
76  for (unsigned int index = 0; index < input.size(); index++){
77  output.push_back(U (input[index]));
78  }
79  }
80 
81  template <class T, class U> void nested_vector_element_convert(const vector< vector<T> >& input, vector< vector<U> >& output){
82  output.clear();
83  for (unsigned int index = 0; index < input.size(); index++){
84  vector<U> temp;
85  vector_element_convert<T,U>(input[index], temp);
86  output.push_back(temp);
87  }
88  }
89 };
90 #endif