Diana Software
MSorter.cc
Go to the documentation of this file.
1 /*
2  *
3  * Author: Laura Kogler <lkogler@berkeley.edu>
4  *
5  * Class MSorter: Sorts events based on an ordered list from a file
6  *
7 */
8 
9 
10 #include "MSorter.hh"
11 #include "QEvent.hh"
12 
14 
15 //using namespace std;
16 
17 
18 // ctor
19 MSorter::MSorter(QSequence *s) : QModule("Sorter",s) {
20 }
21 
22 // dtor
24 }
25 
26 // Init method is called before event loop
27 void MSorter::Init() {
28  fSortFilename = GetString("SortFile", "Sort.txt");
29  fEventVector = QVector(*((QVector*)SeqAuxData().GetQObject("EventList", fSortFilename)));
30 
31  if (fEventVector.Size() == 0)
32  Panic("Event list has no entries.");
33 
34  Info("Read event list. It has %d entries", fEventVector.Size());
35  fIndex = 0;
36  JumpToEvent((int)fEventVector[0]);
37 
38  fIndex++;
39 }
40 
41 // Doit method is called for each event, getting the event as argument
43 
44  if(fIndex < fEventVector.Size())
45  {
46  JumpToEvent((int)fEventVector[fIndex]);
47  fIndex++;
48  return ev;
49  }
50  else
51  {
52  return 0;
53  }
54 }
55 
56 // Done method is called after event loop
57 void MSorter::Done() {
58 
59  return;
60 
61 }
62 
63 
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
Module for sorting events based on an ordered list.
Definition: MSorter.hh:85
virtual QEvent * Do(QEvent *ev)
Definition: MSorter.cc:42
virtual void Done()
Done method is called after event loop.
Definition: MSorter.cc:57
QVector fEventVector
vector to store list of events
Definition: MSorter.hh:106
unsigned int fIndex
Index to tell which event we are on.
Definition: MSorter.hh:109
std::string fSortFilename
this is the name of the file where the sorted list is kept
Definition: MSorter.hh:103
virtual void Init()
Definition: MSorter.cc:27
virtual ~MSorter()
Definition: MSorter.cc:23
const std::string & GetString(const std::string &parname, const std::string &defVal, bool warnCfg=true) const
Get a string parameter from config file ( see GetDouble() )
Definition: QBaseModule.cc:297
void Info(const char *descr,...) const
Send an info message (information) with printf syntax.
Definition: QBaseModule.hh:218
void Panic(const char *descr,...) const
Send a panic message (stops the framework) with printf syntax.
Definition: QBaseModule.hh:248
diana event
Definition: QEvent.hh:46
Base class for diana modules.
Definition: QModule.hh:54
Diana Reconstruction program.
Definition: QSequence.hh:40
Interface for vectors in Diana analysis.
Definition: QVector.hh:30
UInt_t Size() const
size of QVector
Definition: QVector.hh:54