KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVRunListCreator.cpp
1#include "KVRunListCreator.h"
2#include "TEnv.h"
3
4#include <KVSystemDirectory.h>
5#include <KVAvailableRunsFile.h>
6#include <KVSystemFile.h>
7
9
10
11
15
16KVRunListCreator::KVRunListCreator(const TString& dir, const TString& datatype, const TString& fmt)
17{
18 // Give directory to scan, optional format for runfile names
19 // "datatype" should correspond to a known plugin for reading raw data files,
20 // see available plugins for KVRawDataReader (output of method KVBase::GetListOfPluginURIs("KVRawDataReader"))
21
22 SetRunDir(dir);
23 if (fmt != "") SetFileFormat(fmt);
24 else SetFileFormat(gEnv->GetValue("DataSet.RunFileName.raw", "run_%04d.dat%*"));
25 fRunInfos.SetOwner();
26 fDataType = datatype;
27 ScanDirectory();
28 TFile f("runinfos.root", "recreate");
29 GetRunInfos().Write();
30 f.Close();
31}
32
33
34
37
39{
40 // Return number of runs found
41
42 KVSystemDirectory sysdir("rundir", GetRunDir());
43 TIter it(sysdir.GetListOfFiles());
44 KVSystemFile* sysfile;
45 int howmany = 0;
46 while ((sysfile = (KVSystemFile*)it())) {
47 int run_num;
48 if ((run_num = KVAvailableRunsFile::IsRunFileName(GetFileFormat(), sysfile->GetName()))) {
51 ++howmany;
53 infos->SetName(Form("run%010d", run_num));
54 infos->SetValue("Run", run_num);
55 infos->SetValue("Start", when.AsSQLString());
56 infos->SetValue("End", sysfile->GetDate());
57 Int_t x = sysfile->GetSize();
58 if (x == sysfile->GetSize())
59 infos->SetValue("Size", x);
60 else
61 infos->SetValue64bit("Size", sysfile->GetSize());
62 if (fDataType != "") {
63 fReader.reset(KVRawDataReader::OpenFile(fDataType, Form("%s/%s", sysdir.GetTitle(), sysfile->GetName())));
64 ULong64_t events = 0;
65 // correct start date/time from infos in file (GANIL/MFM data) ?
66 if (fReader->GetRunInfos().HasStringParameter("FileCreationTime")) {
67 when.SetGanacqNarvalDate(fReader->GetRunInfos().GetStringValue("FileCreationTime"));
68 infos->SetValue("Start", when.AsSQLString());
69 }
70 while (fReader->GetNextEvent()) ++events;
71
72 infos->SetValue64bit("Events", events);
73 }
74 infos->ls();
75 fRunInfos.Add(infos);
76 }
77 }
78 }
79 return howmany;
80}
81
82
int Int_t
#define f(i)
R__EXTERN TEnv * gEnv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void when
char * Form(const char *fmt,...)
Bool_t ExtractDateFromFileName(const Char_t *name, KVDatime &date)
Int_t IsRunFileName(const Char_t *filename)
Extension of TDatime to handle various useful date formats.
Definition KVDatime.h:33
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
virtual void ls(Option_t *opt="") const
void SetValue(const Char_t *name, value_type value)
void SetValue64bit(const Char_t *name, ULong64_t)
static KVRawDataReader * OpenFile(const TString &type, const TString &filename)
Set up a list of runs from a directory containing data files.
TString fDataType
type of data (KVRawDataReader plugin name)
KVUniqueNameList fRunInfos
const Char_t * GetFileFormat()
Int_t ScanDirectory()
Return number of runs found.
std::unique_ptr< KVRawDataReader > fReader
const Char_t * GetRunDir()
Extension of ROOT TSystemDirectory class, handling browsing directories on disk.
virtual TList * GetListOfFiles() const
Extended ROOT TSystemFile with added info on file size etc.
const Char_t * GetDate() const
Long64_t GetSize() const
virtual void Add(TObject *obj)
virtual const char * GetValue(const char *name, const char *dflt) const
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
unsigned long long ULong64_t
Double_t x[n]
ClassImp(TPyArg)