-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrHistogram.cc
More file actions
58 lines (45 loc) · 1.15 KB
/
TrHistogram.cc
File metadata and controls
58 lines (45 loc) · 1.15 KB
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
#include "TrHistogram.hh"
TrHistogram::TrHistogram() : bins(256) {
}
void TrHistogram::setBinValue(int bin, int value) {
bins[bin] = value;
}
int TrHistogram::getBinValue(int bin) {
return bins[bin];
}
void TrHistogram::fill(int bin) {
bins[bin]++;
}
void TrHistogram::convertFromBuffer(int* bufferPtr, int size) {
if (size != 256) {
}
else {
for (int i=0; i<size; i++) {
int word = (int)*bufferPtr;
bins[i] = word;
bufferPtr++;
}
}
}
int* TrHistogram::convertToBuffer() {
int *buffer = (int*)malloc(sizeof(int)*HISTOGRAMRANGE);
int *bufferStart = buffer;
for (unsigned int bin=0; bin<HISTOGRAMRANGE; bin++) {
*bufferStart = bins[bin];
++bufferStart;
}
return buffer;
}
void TrHistogram::add(TrHistogram* other) {
for (unsigned int i=0; i<bins.size(); i++){
bins[i] += other->getBinValue(i);
}
if (header.getChannelInfo() != other->getHeader()->getChannelInfo()) {
header.copy(other->getHeader());
//std::cout << "Had to copy header" << std::endl;
}
}
void TrHistogram::addHeader(TrHistogramHeader headerIn) {
header = headerIn;
//std::cout << std::hex << header.getChannelInfo() << " was added as a header " << std::endl;
}