62 std::set<std::string>,
63 const std::map<
int, std::pair<int, std::string>>&,
65 bool part_of_batch =
false,
87 std::map<std::string, std::map<std::string, std::string>>&
90 inline static bool fIsStandalone =
false;
96 std::string ntuple_group,
97 std::set<std::string> aux_ntuples,
98 const std::map<
int, std::pair<int, std::string>>& ntuple_meta,
103 : fHdf5FileName(filename), fNtupleGroupName(ntuple_group), fAuxNtuples(aux_ntuples),
104 fNtupleMeta(ntuple_meta), fDryRun(dry_run), fIsPartOfBatch(part_of_batch),
105 fEventCount(n_ev) {};
109 static int iter_children(hid_t,
const char*,
const H5L_info_t*,
void*);
110 static std::vector<std::string> GetChildren(H5::Group&);
112 bool ExistsByType(H5::H5Location&, std::string, H5O_type_t);
114 void SetStringAttribute(H5::H5Object&, std::string, std::string);
115 std::optional<std::string> GetStringAttribute(H5::H5Object&, std::string);
117 void CreateUIntDataset(H5::Group&, std::string, uint64_t);
118 void CreateStringDataset(H5::Group&, std::string, std::string);
123 bool ConvertToLH5Internal();
125 std::pair<std::string, std::vector<std::string>> ReadNullSepDataset(
131 static inline const std::regex names_it_re = std::regex(
"(_in_.+?)?\\0|(_in_.+?)$");
133 std::unique_ptr<H5::DataType> FormToHDFDataType(std::string);
134 std::string DataTypeToLGDO(H5::DataType);
135 bool ConvertNTupleToTable(H5::Group&);
137 bool CheckGeantHeader(H5::Group&);
142 bool ConvertFromLH5Internal(std::map<std::string, std::map<std::string, std::string>>&);
144 static inline const std::regex table_dtype_re = std::regex(
"^table\\{.*\\}$");
146 std::string HDFDataTypeToForm(H5::DataType);
147 bool ConvertTableToNTuple(H5::Group&, std::map<std::string, std::string>&);
151 template<
typename... Args>
void LH5Log(
RMGLog::LogLevel loglevel,
const Args&... args) {
153 std::string fn_prefix = fIsPartOfBatch ?
" (" + fHdf5FileName +
")" :
"";
157 fIsStandalone ?
"" :
"ConvertLH5",
158 fDryRun ?
"[dry-run]" :
"",
165 std::string fHdf5FileName;
166 std::string fNtupleGroupName;
167 std::set<std::string> fAuxNtuples;
168 std::map<int, std::pair<int, std::string>> fNtupleMeta;
169 std::string fUIDKeyFormatString =
"det{:03}";
172 int fEventCount = -1;
static bool ConvertFromLH5(std::string, std::string, bool, bool part_of_batch, std::map< std::string, std::map< std::string, std::string > > &)
Convert an LH5 input file to HDF5 format.
Definition RMGConvertLH5.cc:601
static bool ConvertToLH5(std::string, std::string, std::set< std::string >, const std::map< int, std::pair< int, std::string > > &, bool, bool part_of_batch=false, int n_ev=-1)
Convert a Geant4 HDF5 output file to LH5 format.
Definition RMGConvertLH5.cc:423