forked from jnugent42/mcsframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Collection.h
77 lines (71 loc) · 1.5 KB
/
Collection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdlib.h>
#include <string>
#include <vector>
#include <cmath>
// #include "TMatrixD.h"
class Vars {
public:
double X;
double Y;
double Z;
double dXdz;
double dYdz;
double px;
double py;
double pz;
double TOF12;
double TOF01;
bool isgood;
int pid;
Vars operator+(const Vars& right);
Vars operator-(const Vars& right);
Vars operator*(const Vars& right);
Vars operator/(const Vars& right);
Vars operator*(const double right);
Vars operator/(const double right);
void Zero();
};
class Collection {
public:
Collection() {};
~Collection() {};
private:
std::vector<Vars> _Set;
Vars _mean;
// TMatrixD _cov;
std::vector<std::vector<double> > _cov;
double _emittance;
double _mass;
public:
std::vector<Vars> Set() { return _Set; }
int N() { return _Set.size();}
Vars E(int i) {return _Set.at(i); }
void append_instance(Vars instance) {
_Set.push_back(instance);
}
void init_mean();
void calc_mean();
void init_cov();
void calc_cov();
double Determinant(std::vector<std::vector<double> > a,int n);
void calc_emittance(int n, double mass);
Vars mean() {
_Set.size()>0 ? calc_mean() : init_mean();
return _mean;
}
std::vector<std::vector<double> > cov() {
_Set.size()>1 ? calc_cov() : init_cov();
return _cov;
}
double emittance(int n, double mass) {
if ( _Set.size() > 1 ){
calc_cov();
calc_emittance(n, mass);
return _emittance;
}
else {
init_cov();
return 0;
}
}
};