Skip to content
Snippets Groups Projects
Commit eacbaaf5 authored by mingf2's avatar mingf2
Browse files

save in h5 format

parent b32a63e4
No related branches found
No related tags found
No related merge requests found
...@@ -38,23 +38,24 @@ int main(int argc, char** argv) ...@@ -38,23 +38,24 @@ int main(int argc, char** argv)
} }
print_execution_time(); print_execution_time();
// save data to txt files // // save data to txt files
std::ofstream outfile_LG("timestamps.txt"); // std::ofstream outfile_LG("timestamps.txt");
if(!outfile_LG){// file couldn't be opened // if(!outfile_LG){// file couldn't be opened
std::cerr << "Error: timestamps.txt could not be opened" << std::endl; // std::cerr << "Error: timestamps.txt could not be opened" << std::endl;
exit(1); // exit(1);
} // }
for (int i=0; i<newEvents.size();i++) // for (int i=0; i<newEvents.size();i++)
{ // {
for (int j=0; j<32; j++) // for (int j=0; j<32; j++)
{ // {
outfile_LG << newEvents[i].chargeLG[j] << ' '; // separated by space // outfile_LG << newEvents[i].chargeLG[j] << ' '; // separated by space
} // }
outfile_LG << '\n'; // outfile_LG << '\n';
} // }
outfile_LG.close(); // outfile_LG.close();
print_execution_time(); // 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<std::vector<uint16_t>> LG_charges(newEvents.size(), std::vector<uint16_t>(32, 0));
std::vector<uint64_t> timestamps(newEvents.size(), 0); std::vector<uint64_t> timestamps(newEvents.size(), 0);
for (int i=0; i<newEvents.size();i++) for (int i=0; i<newEvents.size();i++)
...@@ -65,7 +66,6 @@ int main(int argc, char** argv) ...@@ -65,7 +66,6 @@ int main(int argc, char** argv)
{ {
timestamps[i] = newEvents[i].RunEventTimecode; timestamps[i] = newEvents[i].RunEventTimecode;
} }
const std::string FILE_NAME("newEvents.h5");
try { try {
// Create a new file using the default property lists. // Create a new file using the default property lists.
HighFive::File file("newEvents.h5", HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Overwrite); HighFive::File file("newEvents.h5", HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Overwrite);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment