/[PAMELA software]/PamCut/MiscCuts/OBTPktNumCut/OBTPktNumCut.cpp
ViewVC logotype

Diff of /PamCut/MiscCuts/OBTPktNumCut/OBTPktNumCut.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by pam-fi, Tue Jun 29 07:47:18 2010 UTC revision 1.2 by pam-fi, Thu Jul 8 14:00:11 2010 UTC
# Line 0  Line 1 
1    /*
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    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23