![]() |
Diana Software
|
Base class for diana file writers. More...
Public Member Functions | |
| QFileWriter (const std::string &extension) | |
| constructor More... | |
| virtual | ~QFileWriter () |
| destructor More... | |
| virtual void | Require (const QEventInspector &evi) |
| optional method to set required QObjects, called before Open More... | |
| virtual void | Open (const std::string &filename, const QEventInspector &evi)=0 |
| Open File. More... | |
| virtual void | Dump (const QEventInspector &evi)=0 |
| Dump ev to file. More... | |
| virtual void | Close ()=0 |
| Close file. More... | |
Public Member Functions inherited from QWriter | |
| QWriter () | |
| constructor More... | |
| virtual | ~QWriter () |
| destructor More... | |
Public Member Functions inherited from QBaseModule | |
| QBaseModule (Type type) | |
| constructor More... | |
| virtual | ~QBaseModule () |
| constructor More... | |
| double | GetDouble (const std::string &parname, double defVal, bool warnCfg=true) const |
| Get a double parameter from config file. More... | |
| std::vector< double > | GetVectorDouble (const std::string &parname, std::vector< double > defVal, bool warnCfg=true) const |
| Get a std::vector<double> parameter from config file with syntax "{x,y,z}". More... | |
| int | GetInt (const std::string &parname, int defVal, bool warnCfg=true) const |
| Get an int parameter from config file ( see GetDouble() ) More... | |
| std::vector< int > | GetVectorInt (const std::string &parname, std::vector< int > defVal, bool warnCfg=true) const |
| Get an vector<int> parameter from config file ( see GetVectorDouble() ) More... | |
| bool | GetBool (const std::string &parname, bool defVal, bool warnCfg=true) const |
| Get a bool parameter from config file ( see GetDouble() ) More... | |
| std::vector< bool > | GetVectorBool (const std::string &parname, std::vector< bool > defVal, bool warnCfg=true) const |
| Get a vector<bool> parameter from config file ( see GetVectorDouble() ) More... | |
| 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() ) More... | |
| std::vector< std::string > | GetVectorString (const std::string &parname, std::vector< std::string > defVal, bool warnCfg=true) const |
| Get a vector<string> parameter from config file ( see GetVectorDouble() ) More... | |
| void | Debug (const char *descr,...) const |
| Send a debug message (used to debug the module) with printf syntax. More... | |
| void | Info (const char *descr,...) const |
| Send an info message (information) with printf syntax. More... | |
| void | Warn (const char *descr,...) const |
| Send a warning message (an error that the framework can recover) with printf syntax. More... | |
| void | Error (const char *descr,...) const |
| Send an error message (an error that the framework cannot recover) with printf syntax. More... | |
| void | Panic (const char *descr,...) const |
| Send a panic message (stops the framework) with printf syntax. More... | |
| const QGlobalDataManager & | GlobalData () const |
| interface for saving and loading global QObjects More... | |
| bool | GetRunAgain () const |
| Check if the sequence will be reiterated. More... | |
| void | SetRunAgain (bool b) |
| Set that the sequence will be reiterated. More... | |
| unsigned int | GetIteration () const |
| Get Current sequence iteration. More... | |
| unsigned int | GetOccurrence () const |
| get the number of times the same module is loaded inside a QSequence More... | |
| bool | isEnabled () const |
| check if module is enabled More... | |
| std::string | GetFullPath () const |
| Get Full Path of module "GetName() + "." + GetOccurrence". More... | |
| const std::string & | GetName () const |
| Get Module name. More... | |
| const std::string & | GetLabel () const |
| Get Module name + the optional ExtraLabel ("name_extralabel") More... | |
| MsgLevel | GetVerbosity () |
| get verbosity level set from config file More... | |
| const QSequence & | GetSequence () const |
| get reference to this sequence More... | |
| void | Update (QSequence *s, unsigned int occurrence) |
| set the occurrence in the same sequence. MV FIXME: should not be public More... | |
| bool | NeedNeighbours () |
| check wheter this module needs neighbours (available after the first event is processed) More... | |
| void | BeginBase (QEventAssembler &ev) |
| Begin Base method is called before event loop. More... | |
| bool | ProcessBase (QEventAssembler &ev, QEventList &evl, const bool exec, QEventList &ovl) |
| ProcessBase method is called for each event, getting the event and as argument. More... | |
| void | EndBase () |
| EndBase method is called after event loop. More... | |
| const std::vector< QEventLabel > & | GetRequiredLabels () const |
| Get labels of objects required by this module. More... | |
Static Public Member Functions | |
| static const std::list< std::string > & | GetFileList () |
| list of output files More... | |
Protected Member Functions | |
| virtual void | Init (QEventInspector &evi) |
| Init method called by the framework. More... | |
| virtual void | Done () |
| Done method called by the framework. More... | |
| void | WriteFilesList () |
| write list of files More... | |
| void | RemoveFilesList () |
| remove list of files More... | |
| virtual void | Do (QEventInspector &evi) |
| Do method called by the framework. More... | |
| virtual bool | IsToOpen (const Diana::QEvent &ev) const |
| Test to see if a new file needs to be opened. More... | |
| virtual const std::string & | GetCorrespondingReaderFileName (const Diana::QEvent &ev) const |
| Get the file from which this event was read. More... | |
| virtual void | BuildFileName (const QEvent &evi) |
| virtual int | IncrementPartial (const std::string &fileId) |
Protected Member Functions inherited from QBaseModule | |
| QModuleConfig & | GetConfig () |
| Get module config. More... | |
| void | SetNeedNeighbours (bool need) |
| set wheter this module needs neighbours More... | |
Protected Member Functions inherited from QModuleTimeProfiling | |
| QModuleTimeProfiling () | |
| ctor initialized internal variables More... | |
| virtual | ~QModuleTimeProfiling () |
| dtor does nothing More... | |
| void | SetTimeProfilingOn (bool val) |
| Set the time profiling on/off. More... | |
| bool | GetTimeProfilingOn () const |
| Check if the time profiling is on. More... | |
| void | ResetTimer () |
| Reset the timer to now. More... | |
| double | GetTimer () const |
| return the time since the last reset More... | |
| virtual void | StartProcessCall () |
| Start of a process call. More... | |
| virtual void | EndProcessCall () |
| End a process call and increment time and calls. More... | |
| unsigned long long | GetProcessCalls () const |
| Return the total number of process calls. More... | |
| double | GetTotalProcessTime () const |
| Return the total processing time. More... | |
| double | GetProcessCallTime () const |
| Return the average time of a single process call. More... | |
| std::string | GetTimeProfileReport (const std::string &prefix="") const |
| Report the time profiling. More... | |
Protected Attributes | |
| int | fEventNumber |
| current event number More... | |
| std::string | fFileExtension |
| file extension More... | |
| std::list< std::string > | fFilesList |
| List of the full paths of files opened. More... | |
| std::list< std::string > | fOldFilesList |
| List of files opened on the previous iteration. More... | |
| std::string | fFileNamePrefix |
| filename components More... | |
| std::string | fFileId |
| End of the file name to be tacked on to the prefix. More... | |
| std::string | fFileName |
| fFileName = fFileNamePrefix + fFileId More... | |
| std::string | fOutputDir |
| Directory that we are writing to. More... | |
| std::string | fFileFullPath |
| fFileFullPath = fOutputDir + "/" + fFileName + fFileExtension More... | |
| std::string | fFilesListName |
| bool | fUseEventCachedFileName |
| Flag to determine whether to use the file in the event cache. More... | |
| bool | fSetListForReader |
| std::string | fOldFilesListName |
| Name of the file list written in the previous iteration. More... | |
| std::string | fCurrFilesListName |
| Name of the file list for this iteration. More... | |
| std::string | fFileIdentifier |
| The file identifier (follows the prefix) More... | |
| bool | fWriteFilesList |
| Flag whether we are writing a files list. More... | |
| bool | fSaveTempFiles |
| Flag to say whether we save the temporary files created. More... | |
| int | fPartialSize |
| Partial size. When reached, automatically create a new file. More... | |
| bool | fSyncWithReader |
| Flag to synchronize the output files with the input. More... | |
| bool | fSyncWithRun |
| Flag to start a new file for each new run. More... | |
| bool | fDoGetTower |
| Flag to get the tower from the current event. More... | |
| int | fPartial |
| Partial number that we are currently working on. More... | |
| int | fCurrentRun |
| Current run being worked on. More... | |
| bool | fNewPartialOnRerun |
| Does rerunning the sequence create new files, or a new partial. More... | |
| bool | fOneFileOpenOnly |
| Can the writer open more than one file at a time? More... | |
| bool | fWarnRunData |
| If the run data is not valid, pass a warning. More... | |
| bool | fKeepFrameWorkConfig |
| Write the Sequence config data to the file. More... | |
| std::map< std::string, int > | fPartialsByFileId |
| Current partial file for a given file ID. More... | |
Protected Attributes inherited from QWriter | |
| QRWCommon * | fRWCommon |
| object to share file names with QReader More... | |
Protected Attributes inherited from QBaseModule | |
| bool | fExecuted |
Protected Attributes inherited from QModuleTimeProfiling | |
| bool | fTimeProfilingOn |
| Report the time profiling. More... | |
| unsigned long long int | fProcessCalls |
| NUmber of calls to the process. More... | |
| double | fProcessTime |
| Total time spent running the process. More... | |
Static Protected Attributes | |
| static std::list< std::string > | fFullPathFilesList |
| List of the full paths of files opened by all writers. More... | |
Additional Inherited Members | |
Public Types inherited from QBaseModule | |
| enum | Type { Module , Filter , Reader , Writer , Driver } |
Base class for diana file writers.
This class implements generic interfaces to handle output files. Inheriting classes must implement Open(), Dump() and Close() methods. The filename, filelists etc... are completely handled by methods of this class. Optionally, the Require() method can be implemented to set required QObjects into the QEvent. Config file Parameters defined by this class are:
Definition at line 66 of file QFileWriter.hh.
| QFileWriter::QFileWriter | ( | const std::string & | extension | ) |
constructor
Definition at line 25 of file QFileWriter.cc.
References fDoGetTower, fFileExtension, fOneFileOpenOnly, and fWarnRunData.
|
virtual |
destructor
Definition at line 32 of file QFileWriter.cc.
|
protectedvirtual |
Definition at line 268 of file QFileWriter.cc.
References RunType::AsString(), fCurrentRun, fCurrFilesListName, fDoGetTower, fFileExtension, fFileId, fFileIdentifier, fFileName, fFileNamePrefix, fFilesListName, fOutputDir, QRWCommon::fReaderCurrentFileName, QWriter::fRWCommon, QRunData::fType, fWarnRunData, QEvent::Get(), QGlobalDataManager::Get(), QBaseModule::GetString(), QBaseModule::GlobalData(), IncrementPartial(), QBaseModule::Panic(), QStringHandler::RandomString(), Re(), rHandle, and QBaseModule::Warn().
Referenced by Do().
|
pure virtual |
|
protectedvirtual |
Do method called by the framework.
Checks to see if a new file needs to be opened by calling IsToOpen(). If that returns true, this method creates a name for the new file using a pre-prescribed (i.e. hard coded) method. For a new file, write the Framework config.
Run Dump() and increment the event counter.
Implements QWriter.
Definition at line 101 of file QFileWriter.cc.
References BuildFileName(), Close(), QBaseModule::Debug(), dm, Dump(), fCurrentRun, fEventNumber, fFileFullPath, fFileName, fFilesList, QRWCommon::fFrameWorkConfigOld, fFullPathFilesList, fKeepFrameWorkConfig, QRunData::fNumber, fOneFileOpenOnly, fOutputDir, fPartial, fPartialsByFileId, QWriter::fRWCommon, fSyncWithRun, fWarnRunData, fWriteFilesList, ReadHandle< T >::Get(), GlobalHandle< Q >::Get(), QEvent::Get(), QGlobalDataManager::Get(), QEventInspector::GetEvent(), QBaseModule::GlobalData(), QBaseModule::Info(), IsToOpen(), QHandle< T >::IsValid(), GlobalHandle< Q >::IsValid(), Open(), rHandle, QBaseModule::Warn(), and WriteFilesList().
|
protectedvirtual |
Done method called by the framework.
Calls Close().
If we need to rewrite the files in another iteration, tack an extension on to the files, so that we dont overwrite them. If fNewPartialOnRerun, skip this.
Write a file list if we asked for one or if we are rerunning. Delete this file, if we didn't ask for it and we are not (or are finished) rerunning.
Implements QWriter.
Definition at line 170 of file QFileWriter.cc.
References Close(), QBaseModule::Debug(), fCurrFilesListName, fEventNumber, fFileNamePrefix, fFilesList, fFullPathFilesList, fNewPartialOnRerun, fOldFilesList, fOldFilesListName, fOutputDir, QWriter::fRWCommon, fSaveTempFiles, fSetListForReader, QRWCommon::fTempOutputFileList, fWriteFilesList, QBaseModule::GetIteration(), QBaseModule::GetRunAgain(), and WriteFilesList().
Referenced by QRootFileWriterBase::Done().
|
pure virtual |
|
protectedvirtual |
Get the file from which this event was read.
Some readers can store the originating file with the QEvent. If fUseEventCachedFileName is true, this method returns that. Otherwise, it will fall back to fRWCommon->fReaderCurrentFileName.
Definition at line 260 of file QFileWriter.cc.
References QRWCommon::fReaderCurrentFileName, QRWCommon::fReaderModuleName, QWriter::fRWCommon, fUseEventCachedFileName, and QEvent::Get().
|
inlinestatic |
list of output files
Definition at line 99 of file QFileWriter.hh.
References fFullPathFilesList.
Referenced by LGuiSessionWriter::SetQObject().
|
protectedvirtual |
Definition at line 352 of file QFileWriter.cc.
References fPartialsByFileId.
Referenced by BuildFileName().
|
protectedvirtual |
Init method called by the framework.
Reads config file options. Resets files lists. Sets the GlobalWriter name.
Implements QWriter.
Definition at line 34 of file QFileWriter.cc.
References QEvent::Contains(), fCurrentRun, fCurrFilesListName, fDoGetTower, fEventNumber, fFileExtension, fFileIdentifier, fFileNamePrefix, fFilesList, fFilesListName, fFullPathFilesList, fKeepFrameWorkConfig, fNewPartialOnRerun, fOutputDir, fPartial, fPartialSize, QRWCommon::fReaderModuleName, QWriter::fRWCommon, fSaveTempFiles, fSetListForReader, fSyncWithReader, fSyncWithRun, fUseEventCachedFileName, fWriteFilesList, QBaseModule::GetBool(), QEventInspector::GetEvent(), QGlobalWriterDispatcher::GetInstance(), QBaseModule::GetInt(), QBaseModule::GetIteration(), QBaseModule::GetString(), QBaseModule::Panic(), Q_CURRENT_WRITER, Require(), and QEvent::Require().
Referenced by MRootFileWriter::Init().
|
protectedvirtual |
Test to see if a new file needs to be opened.
Reasons to open a new file:
Definition at line 232 of file QFileWriter.cc.
References fCurrentRun, fEventNumber, fFilesList, fPartialSize, QRWCommon::fReaderFileNumber, QWriter::fRWCommon, fSyncWithReader, fSyncWithRun, ReadHandle< T >::Get(), QEvent::Get(), QHandle< T >::IsValid(), and QBaseModule::Warn().
Referenced by Do().
|
pure virtual |
|
protected |
remove list of files
Definition at line 228 of file QFileWriter.cc.
References fCurrFilesListName, and fWriteFilesList.
|
inlinevirtual |
optional method to set required QObjects, called before Open
Definition at line 75 of file QFileWriter.hh.
Referenced by Init().
|
protected |
write list of files
Definition at line 222 of file QFileWriter.cc.
References fCurrFilesListName, fFilesList, fOutputDir, QBaseModule::GetString(), and QFileList::Write().
|
protected |
Current run being worked on.
Definition at line 229 of file QFileWriter.hh.
Referenced by BuildFileName(), Do(), Init(), and IsToOpen().
|
protected |
Name of the file list for this iteration.
Definition at line 211 of file QFileWriter.hh.
Referenced by BuildFileName(), Done(), Init(), RemoveFilesList(), and WriteFilesList().
|
protected |
Flag to get the tower from the current event.
Definition at line 225 of file QFileWriter.hh.
Referenced by BuildFileName(), Init(), and QFileWriter().
|
protected |
current event number
Definition at line 105 of file QFileWriter.hh.
Referenced by Do(), Done(), Init(), and IsToOpen().
|
protected |
file extension
Definition at line 108 of file QFileWriter.hh.
Referenced by BuildFileName(), Init(), and QFileWriter().
|
protected |
fFileFullPath = fOutputDir + "/" + fFileName + fFileExtension
Definition at line 193 of file QFileWriter.hh.
Referenced by Do().
|
protected |
End of the file name to be tacked on to the prefix.
Definition at line 187 of file QFileWriter.hh.
Referenced by BuildFileName().
|
protected |
The file identifier (follows the prefix)
Definition at line 213 of file QFileWriter.hh.
Referenced by BuildFileName(), and Init().
|
protected |
fFileName = fFileNamePrefix + fFileId
Definition at line 189 of file QFileWriter.hh.
Referenced by BuildFileName(), and Do().
|
protected |
filename components
Definition at line 185 of file QFileWriter.hh.
Referenced by BuildFileName(), Done(), and Init().
|
protected |
List of the full paths of files opened.
Definition at line 180 of file QFileWriter.hh.
Referenced by Do(), Done(), Init(), IsToOpen(), and WriteFilesList().
|
protected |
Definition at line 195 of file QFileWriter.hh.
Referenced by BuildFileName(), and Init().
|
staticprotected |
List of the full paths of files opened by all writers.
Definition at line 178 of file QFileWriter.hh.
Referenced by Do(), Done(), GetFileList(), and Init().
|
protected |
Write the Sequence config data to the file.
Definition at line 237 of file QFileWriter.hh.
|
protected |
Does rerunning the sequence create new files, or a new partial.
Definition at line 231 of file QFileWriter.hh.
|
protected |
List of files opened on the previous iteration.
Definition at line 182 of file QFileWriter.hh.
Referenced by Done().
|
protected |
Name of the file list written in the previous iteration.
Definition at line 209 of file QFileWriter.hh.
Referenced by Done().
|
protected |
Can the writer open more than one file at a time?
Definition at line 233 of file QFileWriter.hh.
Referenced by Do(), and QFileWriter().
|
protected |
Directory that we are writing to.
Definition at line 191 of file QFileWriter.hh.
Referenced by BuildFileName(), Do(), Done(), Init(), and WriteFilesList().
|
protected |
Partial number that we are currently working on.
Definition at line 227 of file QFileWriter.hh.
|
protected |
Current partial file for a given file ID.
Definition at line 239 of file QFileWriter.hh.
Referenced by Do(), and IncrementPartial().
|
protected |
Partial size. When reached, automatically create a new file.
Definition at line 219 of file QFileWriter.hh.
Referenced by Init(), and IsToOpen().
|
protected |
Flag to say whether we save the temporary files created.
Definition at line 217 of file QFileWriter.hh.
|
protected |
Definition at line 207 of file QFileWriter.hh.
|
protected |
Flag to synchronize the output files with the input.
Definition at line 221 of file QFileWriter.hh.
Referenced by Init(), and IsToOpen().
|
protected |
Flag to start a new file for each new run.
Definition at line 223 of file QFileWriter.hh.
Referenced by Do(), Init(), and IsToOpen().
|
protected |
Flag to determine whether to use the file in the event cache.
Some readers can store the originating file with the QEvent. This flag specifies whether to use that. Otherwise, it will fall back to fRWCommon->fReaderCurrentFileName.
Definition at line 204 of file QFileWriter.hh.
Referenced by GetCorrespondingReaderFileName(), and Init().
|
protected |
If the run data is not valid, pass a warning.
Definition at line 235 of file QFileWriter.hh.
Referenced by BuildFileName(), Do(), and QFileWriter().
|
protected |
Flag whether we are writing a files list.
Definition at line 215 of file QFileWriter.hh.
Referenced by Do(), Done(), Init(), and RemoveFilesList().