#include "hldgrepfilesource.h" |
HldGrepFileSource
class description - source file - inheritance tree (.pdf)
protected:
Int_t checkDir(TString dir)
Int_t decodeOption(TString opt)
Int_t getNewFile()
Int_t loopForNewFile()
static int selectFiles(const dirent* entry)
public:
HldGrepFileSource(TString dir, TString opt = Grep, Int_t grepInterval = 5, Int_t refId = -1, Int_t off = 5)
virtual ~HldGrepFileSource()
virtual void addFile(Text_t* fileName, Int_t refId = -1)
static TClass* Class()
virtual EDsState getNextEvent(Bool_t doUnpack = kTRUE)
virtual Bool_t getNextFile()
virtual Int_t getRunId(const Text_t* fileName)
virtual TClass* IsA() const
virtual Bool_t rewind()
void setMaxEventPerFile(Int_t n)
void setRefId(Int_t id = -1)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
void stop()
virtual void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
protected:
static time_t lastfile ! last modification time of last used file
static time_t timelimit ! time stamp for the search of new files (files should be newer)
static time_t tcurrent ! current time
static Int_t timeoffset ! offset in seconds required to t_current
static TString fullname ! full filename: path/file
static TString fullnamesort ! full filename for sorting: path/modtime_file
static TString path ! path to directory used for grep of new hld files
Int_t first ! flag : 0 if no file has be selected
Int_t mode ! flag : 1 take newest file , 1: start from given file/time than take the next in list
Int_t interval ! time interval in seconds for grep on dir
TStopwatch timer ! timer for grep interval
Int_t referenceId ! referrence ID for files
Bool_t dostop ! flag to stop the source from file reading (ckecked each event)
HldGrepFileSource
This "data source" reads the HLD data from files on disk.
The user provides a directory name and the source will grep
the newest files from the disk. If after a given check interval
a new file is found, the current one will be closed and the reading
continues with the new one. The source will run in an endless loop
and wait for new files. The user has to stop the source by calling
source->stop().
-----------------------------------------------------------------------------
There are several options to setup the source:
HldGrepFileSource(TString dir,TString opt,Int_t grepInterval,Int_t refId,Int_t off)
dir : directory where the hld files are located
opt : select between the 2 possible modes of the source
1. "Grep" (default) : search for the newest files in intervals
of grepInterval seconds
2. "Date: 02/05/2005 22:00:00" select all files newer than date
and read them sequentional
3. "File: myname.hld" select all files newer than this file and
read them sequentional
grepInterval : time interval for checking for new files
refId : -1 (default) reference run for init procedure
off : 5 s (default) selected files have to be older than off seconds
HldGrepFileSource(TString dir,TString opt,Int_t grepInterval,Int_t refId,Int_t off)
: HldFileSourceBase()
This "data source" reads the HLD data from files on disk.
The user provides a directory name and the source will grep
the newest files from the disk. If after a given check interval
a new file is found, the current one will be closed and the reading
continues with the new one. The source will run in an endless loop
and wait for new files. The user has to exit the program by himself.
dir : directory where the hld files are located
opt : select between the 2 possible modes of the source
1. "Grep" (default) : search for the newest files in intervals
of grepInterval seconds
2. "Date: 02/05/2005 22:00:00" select all files newer than date
and read them sequentional
3. "File: myname.hld" select all files newer than this file and
read them sequential
grepInterval : time interval for checking for new files
refId : -1 (default) reference run for init procedure
~HldGrepFileSource(void)
Destructor for a LMD file data source
Int_t getRunId(const Text_t *fileName)
Get the run Id from the file filename
In case of failure returns -1
EDsState getNextEvent(Bool_t doUnpack)
Tries to read a new event from the LMD file and put
the info into the HEvent structure.
The set directory is checked in interval seconds
for new files. If a new file is available
it is opened for reading. If the last event of
the current file is reached an endless loop
for new files on the disk is performed. The
loop ends only in case of success!
Int_t loopForNewFile()
check if a new file is on the disk.
performs endless loop until succes!
A sleep of the set time interval in seconds
is performed before next try.
int checkDir(TString dir)
Checks the directory dir. In case of empty
strings (default) or not existing directory
this function exit the program. No chance
to go on for lazy users ...Strategy of breaking
as soon as possible. If the directory name does
not end with "/" the slash is added
Int_t decodeOption(TString opt)
Decodes the option string. In case of not known
option or wrong format this function exit the program.
No chance to go on for lazy users ...Strategy of breaking
as soon as possible. Depending on the decoded option
the mode (=1 for "Grep", =2 for sequential reading) switch
is set.
opt : select between the 2 possible modes of the source
1. "Grep" (default) : search for the newest files in intervals
of grepInterval seconds
2. "Date: 02/05/2005 22:00:00" select all files newer than date
and read them sequentional
3. "File: myname.hld" select all files newer than this file and
read them sequential
Int_t selectFiles(const struct dirent *entry)
This is the select function called with scandir(.....)
Selects files going to the list of files for sorting/selection.
Returns 1 if a file is selected otherwise 0.
Only hld files and files newer or equal than the time stamp
lastfile are taken into account. Files smaller 500k are
ignored.
Int_t getNewFile()
Loops on the set directory for new hld files.
the dir is scanned with scandir(). The selected
files newer or equal time stamp lastfile goes
to the list of candidates. The list will be sorted
by last modification of the files.
In "Grep" mode (mode=1) the second newest file
is opened (preventing from reading a file which is
in writing process). The time stamp lastfile is set
to the selected files last modification time.
In "File/Date" mode (mode=2) the list is sequential
read.
Inline Functions
void setMaxEventPerFile(Int_t n)
void setRefId(Int_t id = -1)
void stop()
void addFile(Text_t* fileName, Int_t refId = -1)
Bool_t getNextFile()
Bool_t rewind()
TClass* Class()
TClass* IsA() const
void ShowMembers(TMemberInspector& insp, char* parent)
void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
Author: Jochen Markert
Last update: Mon Feb 5 16:54:21 2007
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.