-
Notifications
You must be signed in to change notification settings - Fork 0
/
DetectorTypeA.cxx
82 lines (67 loc) · 1.62 KB
/
DetectorTypeA.cxx
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
// Simple detector class
#include "Podd.h"
#include "DetectorTypeA.h"
#include "Decoder.h"
#include <cmath>
using namespace std;
DetectorTypeA::DetectorTypeA( const string& name, int imod )
: Detector(name, imod)
{
type = "A";
}
DetectorTypeA::~DetectorTypeA()
{
DetectorTypeA::DefineVariables( kRemove );
}
void DetectorTypeA::Clear()
{
Detector::Clear();
nval = 0;
sum = mean = geom = 0;
min = 1e38;
max = -min;
}
unique_ptr<Detector> DetectorTypeA::Clone() const
{
return make_unique<DetectorTypeA>(*this);
}
int DetectorTypeA::Decode( Decoder& evdata )
{
int status = Detector::Decode( evdata );
if( status )
return status;
nval = evdata.GetNdata(imod);
return 0;
}
int DetectorTypeA::Analyze()
{
// This detector type computes some basic statistics of the raw data
if( !data.empty() ) {
auto n = double(data.size());
for( double x : data ) {
sum += x;
if( x < min ) min = x;
if( x > max ) max = x;
geom += log(fabs(x));
}
mean = sum/n;
geom = exp(geom/n);
}
return 0;
}
void DetectorTypeA::Print() const
{
Detector::Print();
}
int DetectorTypeA::DefineVariables( bool do_remove )
{
const vector<VarDef_t> defs = {
{"nval", "Number of data values processed", &nval},
{"sum", "Sum of data", &sum},
{"min", "Minimum of data", &min},
{"max", "Maximum of data", &max},
{"mean", "Mean of data", &mean},
{"geom", "Geometric mean of data", &geom}
};
return DefineVarsFromList(defs, GetName(), fVars, do_remove);
}