From eacbaaf5a4222cc5d0868344b7f856cde49571a0 Mon Sep 17 00:00:00 2001 From: Ming Fang <mingf2@illinois.edu> Date: Tue, 15 Aug 2023 16:06:02 -0500 Subject: [PATCH] save in h5 format --- example_h5.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/example_h5.cpp b/example_h5.cpp index 8614ceb..7c33720 100644 --- a/example_h5.cpp +++ b/example_h5.cpp @@ -38,23 +38,24 @@ int main(int argc, char** argv) } print_execution_time(); - // save data to txt files - std::ofstream outfile_LG("timestamps.txt"); - if(!outfile_LG){// file couldn't be opened - std::cerr << "Error: timestamps.txt could not be opened" << std::endl; - exit(1); - } - for (int i=0; i<newEvents.size();i++) - { - for (int j=0; j<32; j++) - { - outfile_LG << newEvents[i].chargeLG[j] << ' '; // separated by space - } - outfile_LG << '\n'; - } - outfile_LG.close(); - print_execution_time(); + // // save data to txt files + // std::ofstream outfile_LG("timestamps.txt"); + // if(!outfile_LG){// file couldn't be opened + // std::cerr << "Error: timestamps.txt could not be opened" << std::endl; + // exit(1); + // } + // for (int i=0; i<newEvents.size();i++) + // { + // for (int j=0; j<32; j++) + // { + // outfile_LG << newEvents[i].chargeLG[j] << ' '; // separated by space + // } + // outfile_LG << '\n'; + // } + // outfile_LG.close(); + // print_execution_time(); + // save data to HDF5 std::vector<std::vector<uint16_t>> LG_charges(newEvents.size(), std::vector<uint16_t>(32, 0)); std::vector<uint64_t> timestamps(newEvents.size(), 0); for (int i=0; i<newEvents.size();i++) @@ -65,7 +66,6 @@ int main(int argc, char** argv) { timestamps[i] = newEvents[i].RunEventTimecode; } - const std::string FILE_NAME("newEvents.h5"); try { // Create a new file using the default property lists. HighFive::File file("newEvents.h5", HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Overwrite); -- GitLab