forked from PMT-Test-Facilities/ptf-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper_demo.cpp
More file actions
59 lines (42 loc) · 1.7 KB
/
Copy pathwrapper_demo.cpp
File metadata and controls
59 lines (42 loc) · 1.7 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
59
#include <vector>
#include "wrapper.hpp"
using namespace std;
int main(void) {
// decide which PMTs we'd like
vector<PTF::PMT> activePMTs = {
{0,0,PTF::Hamamatsu_R3600_PMT} // this is saying we want pmt #0, which is on channel 0 and is the SK PMT.
};
// decide which phidgets we'd like to read
vector<int> phidgets = {1, 2, 5};
// decide which gantries we'd like to include
vector<PTF::Gantry> gantries = {PTF::Gantry0, PTF::Gantry1};
// initialize the wrapper
auto wrapper = PTF::Wrapper(
6000, // the maximum number of samples
70, // the size of one sample
activePMTs,
phidgets,
gantries,
PTF::PTF_CAEN_V1730 // which digitizer to use
);
// now we can open our file
wrapper.openFile("/path/to/file.root");
cout << "There are " << wrapper.getNumEntries() << " entries." << endl;
// we can iterate over all the entries
for (size_t i = 0; i < wrapper.getNumEntries(); i++) {
wrapper.setCurrentEntry(i);
// get data from phidget 3
PhidgetReading phidgetReading = wrapper.getReadingForPhidget(3);// looking at which phidget will be use int
// get data from gantry 1
GantryData gantryData = wrapper.getDataForCurrentEntry(PTF::Gantry1);
// see how many samples there are for the current entry
auto numSamples = wrapper.getNumSamples();
for (size_t sample = 0; sample < numSamples; sample++) {
// Gets a pointer to the data for PMT 1 for this sample
// It's an array with the length of one sample, set above, in this case 34.
double* data = getPmtSample(1, sample);
// do something with data
}
}
// wrapper is automatically deallocated when it goes out of scope here, and its destructor cleans up memory
}