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