Diana Software
QFileWriter.hh
Go to the documentation of this file.
1 
56 #ifndef _Q_FILEWRITER_HH_
57 #define _Q_FILEWRITER_HH_
58 
59 #include "QWriter.hh"
60 #include <string>
61 #include <list>
62 #include <map>
63 
65 
66 class QFileWriter : public QWriter {
67 public:
69  QFileWriter(const std::string& extension);
70 
72  virtual ~QFileWriter();
73 
75  virtual void Require(const QEventInspector& evi) {};
76 
82  virtual void Open(const std::string& filename, const QEventInspector& evi)=0;
83 
89  virtual void Dump(const QEventInspector& evi) = 0;
90 
96  virtual void Close() = 0;
97 
99  static const std::list<std::string>& GetFileList()
100  { return fFullPathFilesList; }
101 
102 protected:
103 
106 
108  std::string fFileExtension;
109 
116  virtual void Init(QEventInspector& evi);
117 
132  virtual void Done();
134  void WriteFilesList();
136  void RemoveFilesList();
137 
148  virtual void Do(QEventInspector& evi);
149 
160  virtual bool IsToOpen(const Diana::QEvent& ev) const;
161 
170  virtual const std::string &GetCorrespondingReaderFileName(const Diana::QEvent &ev) const;
171 
172 
173  virtual void BuildFileName(const QEvent &evi);
174 
175  virtual int IncrementPartial(const std::string &fileId);
176 
178  static std::list<std::string> fFullPathFilesList;
180  std::list<std::string> fFilesList;
182  std::list<std::string> fOldFilesList;
183 
185  std::string fFileNamePrefix;
187  std::string fFileId;
189  std::string fFileName;
191  std::string fOutputDir;
193  std::string fFileFullPath;
194 
195  std::string fFilesListName;
196 
205 
206 
209  std::string fOldFilesListName;
211  std::string fCurrFilesListName;
213  std::string fFileIdentifier;
227  int fPartial;
239  std::map<std::string,int> fPartialsByFileId;
240 
241 };
242 
244 
245 #endif
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
Visitor class to inspect the QEvent content.
diana event
Definition: QEvent.hh:46
Base class for diana file writers.
Definition: QFileWriter.hh:66
std::string fOutputDir
Directory that we are writing to.
Definition: QFileWriter.hh:191
std::string fFileIdentifier
The file identifier (follows the prefix)
Definition: QFileWriter.hh:213
int fEventNumber
current event number
Definition: QFileWriter.hh:105
std::string fFileNamePrefix
filename components
Definition: QFileWriter.hh:185
void WriteFilesList()
write list of files
Definition: QFileWriter.cc:222
std::string fFileName
fFileName = fFileNamePrefix + fFileId
Definition: QFileWriter.hh:189
std::map< std::string, int > fPartialsByFileId
Current partial file for a given file ID.
Definition: QFileWriter.hh:239
std::string fFilesListName
Definition: QFileWriter.hh:195
int fPartial
Partial number that we are currently working on.
Definition: QFileWriter.hh:227
virtual void Init(QEventInspector &evi)
Init method called by the framework.
Definition: QFileWriter.cc:34
virtual void BuildFileName(const QEvent &evi)
Definition: QFileWriter.cc:268
bool fDoGetTower
Flag to get the tower from the current event.
Definition: QFileWriter.hh:225
std::list< std::string > fFilesList
List of the full paths of files opened.
Definition: QFileWriter.hh:180
virtual const std::string & GetCorrespondingReaderFileName(const Diana::QEvent &ev) const
Get the file from which this event was read.
Definition: QFileWriter.cc:260
int fPartialSize
Partial size. When reached, automatically create a new file.
Definition: QFileWriter.hh:219
static const std::list< std::string > & GetFileList()
list of output files
Definition: QFileWriter.hh:99
virtual void Done()
Done method called by the framework.
Definition: QFileWriter.cc:170
virtual bool IsToOpen(const Diana::QEvent &ev) const
Test to see if a new file needs to be opened.
Definition: QFileWriter.cc:232
virtual void Require(const QEventInspector &evi)
optional method to set required QObjects, called before Open
Definition: QFileWriter.hh:75
bool fSaveTempFiles
Flag to say whether we save the temporary files created.
Definition: QFileWriter.hh:217
bool fWarnRunData
If the run data is not valid, pass a warning.
Definition: QFileWriter.hh:235
bool fSetListForReader
Definition: QFileWriter.hh:207
virtual void Do(QEventInspector &evi)
Do method called by the framework.
Definition: QFileWriter.cc:101
bool fOneFileOpenOnly
Can the writer open more than one file at a time?
Definition: QFileWriter.hh:233
std::string fCurrFilesListName
Name of the file list for this iteration.
Definition: QFileWriter.hh:211
QFileWriter(const std::string &extension)
constructor
Definition: QFileWriter.cc:25
std::string fFileFullPath
fFileFullPath = fOutputDir + "/" + fFileName + fFileExtension
Definition: QFileWriter.hh:193
bool fSyncWithReader
Flag to synchronize the output files with the input.
Definition: QFileWriter.hh:221
std::string fOldFilesListName
Name of the file list written in the previous iteration.
Definition: QFileWriter.hh:209
bool fKeepFrameWorkConfig
Write the Sequence config data to the file.
Definition: QFileWriter.hh:237
static std::list< std::string > fFullPathFilesList
List of the full paths of files opened by all writers.
Definition: QFileWriter.hh:178
virtual void Open(const std::string &filename, const QEventInspector &evi)=0
Open File.
int fCurrentRun
Current run being worked on.
Definition: QFileWriter.hh:229
virtual void Close()=0
Close file.
std::list< std::string > fOldFilesList
List of files opened on the previous iteration.
Definition: QFileWriter.hh:182
virtual int IncrementPartial(const std::string &fileId)
Definition: QFileWriter.cc:352
bool fNewPartialOnRerun
Does rerunning the sequence create new files, or a new partial.
Definition: QFileWriter.hh:231
std::string fFileId
End of the file name to be tacked on to the prefix.
Definition: QFileWriter.hh:187
std::string fFileExtension
file extension
Definition: QFileWriter.hh:108
virtual void Dump(const QEventInspector &evi)=0
Dump ev to file.
bool fSyncWithRun
Flag to start a new file for each new run.
Definition: QFileWriter.hh:223
bool fUseEventCachedFileName
Flag to determine whether to use the file in the event cache.
Definition: QFileWriter.hh:204
bool fWriteFilesList
Flag whether we are writing a files list.
Definition: QFileWriter.hh:215
void RemoveFilesList()
remove list of files
Definition: QFileWriter.cc:228
virtual ~QFileWriter()
destructor
Definition: QFileWriter.cc:32
Abstract class for diana writers.
Definition: QWriter.hh:30