-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetCharges.cpp
More file actions
executable file
·96 lines (82 loc) · 2.33 KB
/
getCharges.cpp
File metadata and controls
executable file
·96 lines (82 loc) · 2.33 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
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
96
#include </raid/romulus/swong/VBF/VBF/VBankFileReader.h>
#include </raid/romulus/swong/VBF/VBF/VBankFileWriter.h>
#include </raid/romulus/swong/VBF/VBF/VPacket.h>
#include </raid/romulus/swong/VBF/VBF/VArrayEvent.h>
#include </raid/romulus/swong/VBF/VBF/VDatum.h>
#include </raid/romulus/swong/VBF/VBF/VConfigMaskUtil.h>
#include <iostream>
#include <fstream>
#include <exception>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;
vector<string> split (const string &s, char delim) {
vector<string> result;
stringstream ss (s);
string item;
while (getline (ss, item, delim)) {
result.push_back (item);
}
return result;
}
// declare that we're using the VConfigMaskUtil namespace, which gives us
// easy access to parseConfigMask().
using namespace VConfigMaskUtil;
vector< unsigned> events;
int main(int argc, char *argv[]){
string run = argv[1];
const char *ev = argv[2];
vector<string> events = split(ev,',');
vector<VPacket*> packets;
// read in file
VBankFileReader* reader = NULL;
std::string fVBFFileName= run;
reader = new VBankFileReader(fVBFFileName);
vector< bool > configMask=reader->getConfigMask();
// output file
std::ofstream outFile;
outFile.open("charges.txt");
//if (events.size == 0) cout << "ERROR: NO EVENTS GIVEN";
if (events.size() == 1){
if (events[0].compare("all") == 0){
unsigned npacks = reader->numPackets()-1;
for (unsigned i=0; i<npacks; i++){
packets.push_back(reader->readPacket(i));
}
}
else{
int e = atoi(ev);
packets.push_back(reader->readPacket((unsigned)e));
}
}
else{
for (unsigned i=0; i<events.size(); i++){
packets.push_back(reader->readPacket(i));
}
}
for (int i=0; i<packets.size(); i++){
if (packets[i]->hasArrayEvent()) {
VArrayEvent *ae=packets[i]->getArrayEvent();
unsigned long evNum = ae->getEventNumber();
outFile << evNum << " ";
for(unsigned j=0;j<4;j++){ //loop through each telescope
VEvent *event = ae->getEvent(j);
if (event == 0){
continue;
}
uword16 channels = event->getMaxNumChannels();
unsigned numchannels = (unsigned)channels;
for (unsigned k=0; k<numchannels; k++){
uword16 charge = event->getCharge(k);
outFile << charge << ",";
}
outFile << " ";
}
outFile << endl;
}
}
outFile.close();
return 0;
}