KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVMFMDataFileReader.cpp
1//Created by KVClassFactory on Fri Apr 6 16:33:15 2018
2//Author: John Frankland,,,
3
4#include "KVMFMDataFileReader.h"
5#include "TSystem.h"
6#include "TError.h"
7#include "MFMXmlFileHeaderFrame.h"
8
10
11
12
20
22 : KVRawDataReader(), MFMFileReader(filepath, 512 * 1024 * 1024)
23{
24 // Open the datafile with given path
25 // Read the first frame in the file (should be a MFMXmlFileHeaderFrame) and extract informations
26 //
27 // If the variable
28 // KVMFMDataFileReader.ActionsDirectory
29 // has been set, it will be used to search for EBYEDAT actions files in order to
30 // decode any EBYEDAT data in the file
31
32 std::string actions_dir = gEnv->GetValue("KVMFMDataFileReader.ActionsDirectory", "");
33 if (actions_dir != "") SetActionsDirectory(actions_dir);
34 std::string actions_expname = gEnv->GetValue("KVMFMDataFileReader.ActionsExpName", "");
35 if (actions_expname != "") SetActionsExpName(actions_expname);
36 if (!ReadNextFrame()) {
37 Error("KVMFMDataFileReader", "Cannot read file %s", filepath);
38 MakeZombie();
39 return;
40 }
41 if (GetFrameReadType() != MFM_XML_FILE_HEADER_FRAME_TYPE) {
42 Warning("KVMFMDataFileReader", "First frame in file is not MFM_XML_FILE_HEADER_FRAME_TYPE: type is %s",
43 GetFrameReadTypeSymbol().c_str());
44 }
45 else {
46 GetFrameRead().Print();
47 fRunInfos.SetValue("ExperimentName", GetFrameRead<MFMXmlFileHeaderFrame>().GetExperimentName());
48 fRunInfos.SetValue("FileName", GetFrameRead<MFMXmlFileHeaderFrame>().GetFileName());
49 fRunInfos.SetValue("FileCreationTime", GetFrameRead<MFMXmlFileHeaderFrame>().GetFileCreationTime());
50 fRunInfos.SetValue("RunNumber", GetFrameRead<MFMXmlFileHeaderFrame>().GetRunNumber());
51 fRunInfos.SetValue("RunIndex", GetFrameRead<MFMXmlFileHeaderFrame>().GetRunIndex());
52 fRunInfos.SetValue("RunStartTime", GetFrameRead<MFMXmlFileHeaderFrame>().GetRunStartTime());
53 }
54}
55
56
57
59
61{
62 TString fp(filepath);
63 if (fp.Contains('$')) gSystem->ExpandPathName(fp);
64 ::Info("KVMFMDataFileReader::Open", "Opening file %s...", fp.Data());
65 return new KVMFMDataFileReader(fp);
66}
67
68
69
73
75{
76 // Set directory in which to look for Ebyedat ACTIONS_* files
77 // Defaults to data directory
78 GetFrameLibrary().SetEbyedatActionsDirectory(d);
79}
80
81
82
88
90{
91 // Set experiment name for Ebyedat ACTIONS_* files.
92 //
93 // Setting this means that a single ACTIONS file will be looked for in the actions directory
94 // (set with SetActionsDirectory).
95 GetFrameLibrary().SetEbyedatExpName(e);
96}
97
98
99
103
105{
106 // Return run number of file currently being read.
107 // Only call once file has been successfully opened.
108
109 return fRunInfos.GetIntValue("RunNumber");
110}
111
112
113
116
118{
119 // Returns full path to last ACTIONS file used to decode Ebyedat parameters
120 return GetFrameLibrary().GetLastEbyedatActionsFile().c_str();
121}
122
123
124#ifdef WITH_MESYTEC
125
129
130void KVMFMDataFileReader::InitialiseMesytecConfig(const std::string& crate, const std::string& channels)
131{
132 // Read the two files whose full paths are given as argument in order to set up the
133 // Mesytec crate config and module-channel-detector correspondence
134
135#ifndef MESYTEC_DATA_BUFFER_READER_NO_DEFINE_SETUP
136 mesytec::experimental_setup exp;
137 exp.read_crate_map(crate);
138 exp.read_detector_correspondence(channels);
139 MTEC_bufrdr.define_setup(exp);
140#else
141 MTEC_bufrdr.read_crate_map(crate);
142 MTEC_bufrdr.read_detector_correspondence(channels);
143#endif
144}
145
146#endif
147
int Int_t
#define d(i)
#define e(i)
char Char_t
const char Option_t
R__EXTERN TEnv * gEnv
R__EXTERN TSystem * gSystem
Read MFM format acquisition data.
Int_t GetRunNumberReadFromFile() const
void SetActionsExpName(const string &)
void SetActionsDirectory(const string &)
TString GetPathToLastEbyedatActionsFile()
Returns full path to last ACTIONS file used to decode Ebyedat parameters.
static KVMFMDataFileReader * Open(const Char_t *filepath, Option_t *="")
Int_t GetIntValue(const Char_t *name) const
Abstract base class for reading raw (DAQ) data.
KVNameValueList fRunInfos
informations on run extracted from file
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual char * ExpandPathName(const char *path)
RVec< PromoteType< T > > exp(const RVec< T > &v)
void Error(const char *location, const char *fmt,...)
std::string GetFileName(const clang::Decl &decl, const cling::Interpreter &interp)
void Warning(const char *location, const char *fmt,...)
ClassImp(TPyArg)