Diana Software
QReader.hh
Go to the documentation of this file.
1 
32 #ifndef _MQ_READER_HH_
33 #define _MQ_READER_HH_
34 
35 #include "QBaseModule.hh"
36 #include "QError.hh"
37 #include <string>
38 #include <vector>
39 #include "QRWCommon.hh"
40 
41 
43 
44 class QEventAssembler;
45 class QEventList;
46 class QNeighboursFiller;
48 
49 class QReader : public QBaseModule
50 {
51  public:
53  QReader();
55  virtual ~QReader();
56 
59  virtual void Init(QEventAssembler& eva) = 0;
60 
65  virtual bool Do(QEventAssembler& eva) = 0;
66 
69  virtual void Done() = 0;
70 
73  virtual const QError& JumpToEvent(Long64_t eventnumber);
74 
76  const int& GetFileNumber() {return fFileNumber;}
77 
79  static std::list<std::string> GetFilesList() { return fFullPathFilesList; }
80 
82  bool DoBase(QEventAssembler& eva);
83 
84  bool NeighboursOn() { return fNeighboursOn; }
85 
86  protected:
88  void InitFileManager();
90  void OpenNewFile(const std::string& fileName);
94  std::vector<std::string> fFileList;
96  static std::list<std::string> fFullPathFilesList;
100  std::string fFileListPath;
102  unsigned int fProcessedNumber;
109  private:
110 
112  void Begin(QEventAssembler& eva);
114  bool Process(QEventAssembler& eva, QEventList& neigh,const bool exec, QEventList& oneigh);
116  void End();
118  const QError& BaseJumpToEvent(Long64_t eventnumber);
120  void ReadFilesList(std::string path);
122  void NotifyOpenNewFile(const std::string &fileName);
123 
125  Long64_t fReadNumber;
126 
132  std::vector<std::string>::const_iterator fFileListIter;
135 
137  std::string fNextFileName;
139  std::map<unsigned int,std::string> fReadNumberAtFileOpen;
142 
143 
144  friend class QSequence;
145 };
146 
147 
148 #undef REGISTER_MODULE
149 #define REGISTER_MODULE(clazz) REGISTER_MOD(clazz,Diana::QReader)
150 
152 
153 
154 #endif
155 
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
Base class for modules.
Definition: QBaseModule.hh:57
error class with error type and description
Definition: QError.hh:115
Visitor class of QEvent that provides full handling of QEvent.
list of references to const QEvent (s)
Definition: QEventList.hh:21
Base class for diana event readers.
Definition: QReader.hh:50
virtual bool Do(QEventAssembler &eva)=0
Do method is called for each event, getting the QEventAssembler as argument. This method must be impl...
unsigned int fProcessedNumber
events processed
Definition: QReader.hh:102
std::map< unsigned int, std::string > fReadNumberAtFileOpen
Definition: QReader.hh:139
QNeighboursFiller * fNeighboursFiller
Neighbours filler.
Definition: QReader.hh:128
virtual void Done()=0
Done method is called after event loop. This method must be implemented by inheriting classes.
bool fReadFileList
read file list
Definition: QReader.hh:98
QRWCommon * fRWCommon
object to share file names with QWriter
Definition: QReader.hh:108
bool fNewFileOpen
Definition: QReader.hh:141
bool fNeighboursOn
Neighbours are on.
Definition: QReader.hh:134
void InitFileManager()
Initialize multiple and single file management.
Definition: QReader.cc:144
Long64_t fReadNumber
last event read
Definition: QReader.hh:125
static std::list< std::string > fFullPathFilesList
list of files
Definition: QReader.hh:96
std::vector< std::string >::const_iterator fFileListIter
Iterator on file names
Definition: QReader.hh:132
bool Process(QEventAssembler &eva, QEventList &neigh, const bool exec, QEventList &oneigh)
Process method is called for each event, and calls Do()
Definition: QReader.cc:62
std::string fFileListPath
file list path
Definition: QReader.hh:100
bool NeighboursOn()
Definition: QReader.hh:84
static std::list< std::string > GetFilesList()
list of input files
Definition: QReader.hh:79
void ReadFilesList(std::string path)
Parse the file that contain the files list.
Definition: QReader.cc:188
void OpenNewFile(const std::string &fileName)
Call it when opening new file.
Definition: QReader.cc:181
std::string fNextFileName
Definition: QReader.hh:137
void Begin(QEventAssembler &eva)
Begin method is called before event loop, and calls Init()
Definition: QReader.cc:28
QReader()
constructor
Definition: QReader.cc:18
virtual void Init(QEventAssembler &eva)=0
Init method is called before event loop, getting the QEventAssembler as argument This method must be ...
int fEventNumberPrintStep
print event number step
Definition: QReader.hh:104
QError fErr
Error returned by methods.
Definition: QReader.hh:106
bool DoBase(QEventAssembler &eva)
DoBase executes Do, and is called by QNeighboursFiller.
Definition: QReader.cc:85
const int & GetFileNumber()
Get Current file number, used by QWriter (throug QSequence)
Definition: QReader.hh:76
const QError & BaseJumpToEvent(Long64_t eventnumber)
Called when another module ask for a specific event number in the next Do(), calls JumpToEvent()
Definition: QReader.cc:134
std::vector< std::string > fFileList
list of files
Definition: QReader.hh:94
QReaderEventGeneratorFiller * fReaderEventGeneratorFiller
Event generator
Definition: QReader.hh:130
virtual const QError & JumpToEvent(Long64_t eventnumber)
Called when another module ask for a specific eventnumber in the next Do(). Implementation of this me...
Definition: QReader.cc:125
void NotifyOpenNewFile(const std::string &fileName)
Call it when opening new file.
Definition: QReader.cc:174
virtual ~QReader()
destructor
Definition: QReader.cc:24
int fFileNumber
current file number read
Definition: QReader.hh:92
void End()
End method is called after event loop, and calls Done()
Definition: QReader.cc:106
Diana Reconstruction program.
Definition: QSequence.hh:40