11 #include <TObjArray.h>
12 #include <TObjString.h>
92 std::stringstream currentWriterForGlobal;
95 SetCurrentWriterFilename(currentWriterForGlobal.str());
110 else Warn(
"No Header found, run number in filenames will be \"0\"");
121 Warn(
"No RunData found, run type in filenames will be \"Unknown\"");
122 Warn(
"No RunData found, tower in filenames will be 0");
155 Debug(
"Found valid FrameworkConfig");
176 std::list<std::string>::iterator filesListIter;
182 char iterBuf[4], pidBuf[32];
184 snprintf(pidBuf,32,
"%d",getpid());
186 filesListIter !=
fFilesList.end(); filesListIter++) {
187 std::string fileName = *filesListIter;
188 std::string tempFileName = std::string(iterBuf) +
"_" + *filesListIter ;
192 *filesListIter = tempFileName;
196 + std::string(iterBuf) +
"_"
210 std::string toBeRemoved =
fOutputDir +
"/" + *filesListIter;
211 Debug(
"Removing %s", toBeRemoved.c_str());
212 remove(toBeRemoved.c_str());
224 int FilePermissions = strtol(
GetString(
"FilePermissions",
"0644",
false).c_str(),NULL,8);
239 else Warn(
"No Header found, run number in filenames will be \"0\"");
265 return readerFileName;
278 Warn(
"No RunData found, run type in filenames will be \"Unknown\"");
279 Warn(
"No RunData found, tower in filenames will be 0");
300 Warn(
"No RunData found, tower in filenames will be 0");
303 Bool_t usingPartial=
true;
312 usingPartial =
false;
315 static TPRegexp
Re(
"_([0-9]+(_[0-9]+)?_[A-Z]_p[0-9]{3})");
317 if(matches->GetEntries()>0){
322 Warn(
"Could not parse reader file name for file ID! Will use random string"
323 " identifier %s -> %s.",
333 Panic(
"No valid file identifier provided! Output files will not be uniquely named!");
QRunDataHandle rHandle(753)
double Re(const Diana::QComplex &z)
Function to get the real part.
#define Q_BEGIN_NAMESPACE
template class to handle diana global QObject with QGlobalDataManager
bool IsValid() const
check QObject validity
const Q & Get() const
get the QObject
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() )
void Debug(const char *descr,...) const
Send a debug message (used to debug the module) with printf syntax.
void Warn(const char *descr,...) const
Send a warning message (an error that the framework can recover) with printf syntax.
unsigned int GetIteration() const
Get Current sequence iteration.
void Info(const char *descr,...) const
Send an info message (information) with printf syntax.
bool GetRunAgain() const
Check if the sequence will be reiterated.
void Panic(const char *descr,...) const
Send a panic message (stops the framework) with printf syntax.
int GetInt(const std::string &parname, int defVal, bool warnCfg=true) const
Get an int parameter from config file ( see GetDouble() )
bool GetBool(const std::string &parname, bool defVal, bool warnCfg=true) const
Get a bool parameter from config file ( see GetDouble() )
const QGlobalDataManager & GlobalData() const
interface for saving and loading global QObjects
Visitor class to inspect the QEvent content.
QEvent & GetEvent()
Get the event.
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
bool Contains(const char *owner, const char *name) const
Check to see if the event contains a particular object.
void Write(const std::string &fileListPath) const
std::string fOutputDir
Directory that we are writing to.
std::string fFileIdentifier
The file identifier (follows the prefix)
int fEventNumber
current event number
std::string fFileNamePrefix
filename components
void WriteFilesList()
write list of files
std::string fFileName
fFileName = fFileNamePrefix + fFileId
std::map< std::string, int > fPartialsByFileId
Current partial file for a given file ID.
std::string fFilesListName
int fPartial
Partial number that we are currently working on.
virtual void Init(QEventInspector &evi)
Init method called by the framework.
virtual void BuildFileName(const QEvent &evi)
bool fDoGetTower
Flag to get the tower from the current event.
std::list< std::string > fFilesList
List of the full paths of files opened.
virtual const std::string & GetCorrespondingReaderFileName(const Diana::QEvent &ev) const
Get the file from which this event was read.
int fPartialSize
Partial size. When reached, automatically create a new file.
virtual void Done()
Done method called by the framework.
virtual bool IsToOpen(const Diana::QEvent &ev) const
Test to see if a new file needs to be opened.
virtual void Require(const QEventInspector &evi)
optional method to set required QObjects, called before Open
bool fSaveTempFiles
Flag to say whether we save the temporary files created.
bool fWarnRunData
If the run data is not valid, pass a warning.
virtual void Do(QEventInspector &evi)
Do method called by the framework.
bool fOneFileOpenOnly
Can the writer open more than one file at a time?
std::string fCurrFilesListName
Name of the file list for this iteration.
QFileWriter(const std::string &extension)
constructor
std::string fFileFullPath
fFileFullPath = fOutputDir + "/" + fFileName + fFileExtension
bool fSyncWithReader
Flag to synchronize the output files with the input.
std::string fOldFilesListName
Name of the file list written in the previous iteration.
bool fKeepFrameWorkConfig
Write the Sequence config data to the file.
static std::list< std::string > fFullPathFilesList
List of the full paths of files opened by all writers.
virtual void Open(const std::string &filename, const QEventInspector &evi)=0
Open File.
int fCurrentRun
Current run being worked on.
virtual void Close()=0
Close file.
std::list< std::string > fOldFilesList
List of files opened on the previous iteration.
virtual int IncrementPartial(const std::string &fileId)
bool fNewPartialOnRerun
Does rerunning the sequence create new files, or a new partial.
std::string fFileId
End of the file name to be tacked on to the prefix.
std::string fFileExtension
file extension
virtual void Dump(const QEventInspector &evi)=0
Dump ev to file.
bool fSyncWithRun
Flag to start a new file for each new run.
bool fUseEventCachedFileName
Flag to determine whether to use the file in the event cache.
bool fWriteFilesList
Flag whether we are writing a files list.
void RemoveFilesList()
remove list of files
virtual ~QFileWriter()
destructor
Object to manage I/O (DB, file, or memory) of diana global quantities.
QError Get(const std::string &owner, GlobalHandle< Q > *gh, const std::string &inSource, bool printError=true) const
Get an object using a global handle.
static QGlobalWriterDispatcher & GetInstance()
virtual bool IsValid() const
Check object validity.
Raw event: bolometer channel, trigger positions and types.
QFrameWorkConfig fFrameWorkConfigOld
std::string fReaderCurrentFileName
std::string fTempOutputFileList
std::string fReaderModuleName
global handle for QRunData
string wrapped into a QObject
Abstract class for diana writers.
QRWCommon * fRWCommon
object to share file names with QReader
read handle to access QEvent QObject's.
const T & Get() const
Get Object.
std::string AsString() const
convert to string
std::string RandomString(UInt_t length, Bool_t caseSensitive=true, Bool_t startLetter=false)
Return a random string of lenght.