-
Notifications
You must be signed in to change notification settings - Fork 0
/
Response.h
95 lines (79 loc) · 2.45 KB
/
Response.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// AngularResponse.h
#ifndef __NeutronDetectorSim__AngularResponse__
#define __NeutronDetectorSim__AngularResponse__
#include <string>
#include <vector>
#include <eigen3/Eigen/Dense>
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include <eigen3/unsupported/Eigen/LevenbergMarquardt>
#include <random>
#include <chrono>
#include <cmath>
#include "Extrap1d.h"
#include <exception>
using namespace std;
using namespace boost;
const double pi = 3.141592653589793;
class AngularResponse {
public:
AngularResponse(const std::vector<double> pulses, const std::vector<double> livetime, const std::vector<double> angle, const double bkg_cps);
AngularResponse operator=(const AngularResponse &setObj);
AngularResponse();
double operator()(const double &angle) const;
Eigen::ArrayXd operator()(const Eigen::ArrayXd &angle) const;
~AngularResponse();
void Randomize(double newBkg);
private:
bool noAngResp;
std::mt19937 rand;
void CreateResponseFunc();
vector<double> angles;
vector<double> measCounts;
vector<double> measTime;
Eigen::ArrayXd ang;
Eigen::ArrayXd cps;
boost::shared_ptr<Extrap1d> ext;
};
struct squareLawFunctor : Eigen::DenseFunctor<double> {
Eigen::ArrayXd xVals;
Eigen::ArrayXd yVals;
squareLawFunctor(Eigen::ArrayXd x, Eigen::ArrayXd y) : Eigen::DenseFunctor<double> (2, 3), xVals(x), yVals(y) {
}
int operator()(const Eigen::VectorXd &p, Eigen::VectorXd &diff) const {
diff = yVals - p[0] / (4.0 * pi * xVals.pow(p[1]));
return 0;
}
};
class BkgResponse {
public:
BkgResponse(const double pulses, const double livetime);
BkgResponse();
double GetCPS();
double GetRandomizedCPS();
private:
double pulses;
double livetime;
};
class DistResponse {
public:
DistResponse(const std::vector<double> pulses, const std::vector<double> livetime, const std::vector<double> dist, double bkg_cps, double activity, double activity_uncertainty, bool curve_fit = false); //curve_fit should probably default to false: fix me!
DistResponse();
DistResponse operator=(const DistResponse &setDist);
double operator()(const double &dist) const;
Eigen::ArrayXd operator()(const Eigen::ArrayXd &dist) const;
void Randomize(double newBkg);
private:
void FitData();
Eigen::ArrayXd measCounts;
Eigen::ArrayXd measTime;
Eigen::ArrayXd cpsData;
Eigen::ArrayXd distData;
double activity;
double activityUncertainty;
double p1, p2;
bool curve_fit;
std::mt19937 rand;
};
#endif /* defined(__NeutronDetectorSim__AngularResponse__) */