1 |
pam-fi |
1.1.2.1 |
/* |
2 |
|
|
* OBTPktNumCut.cpp |
3 |
|
|
* |
4 |
|
|
* Created on: 18/mar/2010 |
5 |
|
|
* Author: Nicola Mori |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "OBTPktNumCut.h" |
9 |
|
|
|
10 |
pam-fi |
1.1.2.2 |
OBTPktNumCut::OBTPktNumCut(const char *cutName, vector<pair<unsigned int, unsigned int> > &list, bool verbose) : |
11 |
|
|
PamCut(cutName), _list(list), _verbose(verbose) { |
12 |
|
|
|
13 |
pam-fi |
1.1.2.1 |
} |
14 |
|
|
|
15 |
|
|
OBTPktNumCut::OBTPktNumCut(const char *cutName, TString listFileName) : |
16 |
|
|
PamCut(cutName) { |
17 |
|
|
ifstream listFile(listFileName); |
18 |
|
|
|
19 |
|
|
pair<unsigned int, unsigned int> buffer; |
20 |
|
|
|
21 |
|
|
/* File layout: |
22 |
|
|
* OBT PktNum */ |
23 |
|
|
while (listFile >> buffer.first >> buffer.second) { |
24 |
|
|
_list.push_back(buffer); |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
listFile.close(); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
int OBTPktNumCut::Check(PamLevel2 *event) { |
31 |
|
|
|
32 |
|
|
if (_list.size() == 0) |
33 |
|
|
return 0; // No more couples left in the list |
34 |
|
|
|
35 |
|
|
unsigned int OBT = event->GetOrbitalInfo()->OBT; |
36 |
|
|
unsigned int pktNum = event->GetOrbitalInfo()->pkt_num; |
37 |
|
|
|
38 |
|
|
vector<pair<unsigned int, unsigned int> >::iterator currPair = _list.begin(); |
39 |
pam-fi |
1.1.2.2 |
while (currPair->first != OBT || currPair->second != pktNum) { |
40 |
pam-fi |
1.1.2.1 |
currPair++; |
41 |
|
|
if (currPair > _list.end()) |
42 |
|
|
return 0; // Event not found in the list |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
_list.erase(currPair); // Don't search anymore for the current pair (already found) |
46 |
pam-fi |
1.1.2.2 |
if (_verbose) { |
47 |
|
|
cout << "** " << GetName() << ": event found. OBT: " << OBT << ", pktNum: " << pktNum << endl; |
48 |
|
|
} |
49 |
pam-fi |
1.1.2.1 |
|
50 |
|
|
return CUTOK; |
51 |
|
|
} |