KaliVeda
Toolkit for HIC analysis
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 
25  : KVRawDataReader(), MFMFileReader(filepath, bufsize * 1024 * 1024)
26 {
27  // Open the datafile with given path
28  //
29  // bufsize = buffer size [MB] - default = 512
30  //
31  // Read the first frame in the file (should be a MFMXmlFileHeaderFrame) and extract informations
32  //
33  // If the variable
34  // KVMFMDataFileReader.ActionsDirectory
35  // has been set, it will be used to search for EBYEDAT actions files in order to
36  // decode any EBYEDAT data in the file
37 
38  std::string actions_dir = gEnv->GetValue("KVMFMDataFileReader.ActionsDirectory", "");
39  if (actions_dir != "") SetActionsDirectory(actions_dir);
40  std::string actions_expname = gEnv->GetValue("KVMFMDataFileReader.ActionsExpName", "");
41  if (actions_expname != "") SetActionsExpName(actions_expname);
42  if (!ReadNextFrame()) {
43  Error("KVMFMDataFileReader", "Cannot read file %s", filepath);
44  MakeZombie();
45  return;
46  }
47  if (GetFrameReadType() != MFM_XML_FILE_HEADER_FRAME_TYPE) {
48  Warning("KVMFMDataFileReader", "First frame in file is not MFM_XML_FILE_HEADER_FRAME_TYPE: type is %s",
49  GetFrameReadTypeSymbol().c_str());
50  }
51  else {
52  GetFrameRead().Print();
53  fRunInfos.SetValue("ExperimentName", GetFrameRead<MFMXmlFileHeaderFrame>().GetExperimentName());
54  fRunInfos.SetValue("FileName", GetFrameRead<MFMXmlFileHeaderFrame>().GetFileName());
55  fRunInfos.SetValue("FileCreationTime", GetFrameRead<MFMXmlFileHeaderFrame>().GetFileCreationTime());
56  fRunInfos.SetValue("RunNumber", GetFrameRead<MFMXmlFileHeaderFrame>().GetRunNumber());
57  fRunInfos.SetValue("RunIndex", GetFrameRead<MFMXmlFileHeaderFrame>().GetRunIndex());
58  fRunInfos.SetValue("RunStartTime", GetFrameRead<MFMXmlFileHeaderFrame>().GetRunStartTime());
59  }
60 }
61 
62 
63 
65 
67 {
68  TString fp(filepath);
69  if (fp.Contains('$')) gSystem->ExpandPathName(fp);
70  ::Info("KVMFMDataFileReader::Open", "Opening file %s...", fp.Data());
71  return new KVMFMDataFileReader(fp);
72 }
73 
74 
75 
79 
81 {
82  // Set directory in which to look for Ebyedat ACTIONS_* files
83  // Defaults to data directory
84  GetFrameLibrary().SetEbyedatActionsDirectory(d);
85 }
86 
87 
88 
94 
96 {
97  // Set experiment name for Ebyedat ACTIONS_* files.
98  //
99  // Setting this means that a single ACTIONS file will be looked for in the actions directory
100  // (set with SetActionsDirectory).
101  GetFrameLibrary().SetEbyedatExpName(e);
102 }
103 
104 
105 
109 
111 {
112  // Return run number of file currently being read.
113  // Only call once file has been successfully opened.
114 
115  return fRunInfos.GetIntValue("RunNumber");
116 }
117 
118 
119 
122 
124 {
125  // Returns full path to last ACTIONS file used to decode Ebyedat parameters
126  return GetFrameLibrary().GetLastEbyedatActionsFile().c_str();
127 }
128 
129 
130 #ifdef WITH_MESYTEC
131 
135 
136 void KVMFMDataFileReader::InitialiseMesytecConfig(const std::string& crate, const std::string& channels)
137 {
138  // Read the two files whose full paths are given as argument in order to set up the
139  // Mesytec crate config and module-channel-detector correspondence
140 
141 #ifndef MESYTEC_DATA_BUFFER_READER_NO_DEFINE_SETUP
142  mesytec::experimental_setup exp;
143  exp.read_crate_map(crate);
144  exp.read_detector_correspondence(channels);
145  MTEC_bufrdr.define_setup(exp);
146 #else
147  MTEC_bufrdr.read_crate_map(crate);
148  MTEC_bufrdr.read_detector_correspondence(channels);
149 #endif
150 }
151 
152 #endif
153 
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.
KVMFMDataFileReader(const Char_t *filepath, ULong64_t bufsize=512)
void SetActionsExpName(const string &)
void SetActionsDirectory(const string &)
TString GetPathToLastEbyedatActionsFile()
Returns full path to last ACTIONS file used to decode Ebyedat parameters.
Int_t GetRunNumberReadFromFile() const override
void InitialiseMesytecConfig(const std::string &crate, const std::string &channels)
static KVMFMDataFileReader * Open(const Char_t *filepath, Option_t *="")
mesytec::buffer_reader MTEC_bufrdr
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)
unsigned long long ULong64_t
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)