Page MenuHomeHEPForge

No OneTemporary

diff --git a/t/test_hdf5_write.cc b/t/test_hdf5_write.cc
index c4c9240..f068bef 100644
--- a/t/test_hdf5_write.cc
+++ b/t/test_hdf5_write.cc
@@ -1,80 +1,82 @@
/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
-#include "HEJ/HDF5Reader.hh"
-#include "HEJ/HDF5Writer.hh"
#include "HEJ/Event.hh"
+#include "HEJ/HDF5Reader.hh"
+#include "HEJ/make_writer.hh"
#include "HEJ/utility.hh"
#include <cstdio>
-#include <unistd.h>
#include <iostream>
+#include <unistd.h>
// apparently hdf5 can't deal with the (safer) files in /proc/self/fd
// so we use tmpnam instead and RAII to ensure it gets deleted
class Tempfile {
public:
Tempfile():
file_{std::tmpnam(nullptr)}
{}
std::string const & name() const {
return file_;
}
~Tempfile(){
unlink(file_.c_str());
}
private:
std::string file_;
};
int main(int argc, char** argv) {
if(argc != 2) {
std::cerr << "Usage: " << argv[0] << " file.hdf5\n";
return EXIT_FAILURE;
}
Tempfile file;
std::vector<HEJ::Event> events;
// this scope is needed to trigger the HEJ::HDF5Writer destructor
// don't remove it
{
- HEJ::HDF5Reader reader{argv[1]};
+ auto reader = HEJ::make_reader(argv[1]);
- HEJ::HDF5Writer writer{file.name(), reader.heprup()};
+ auto writer = HEJ::make_format_writer(
+ HEJ::FileFormat::HDF5, file.name(), reader->heprup()
+ );
- while(reader.read_event()) {
- const auto event = HEJ::Event::EventData{reader.hepeup()}.cluster(
+ while(reader->read_event()) {
+ const auto event = HEJ::Event::EventData{reader->hepeup()}.cluster(
fastjet::JetDefinition{fastjet::antikt_algorithm, 0.4}, 20.
);
events.emplace_back(event);
- writer.write(event);
+ writer->write(event);
}
}
HEJ::HDF5Reader reader{file.name()};
for(auto const & event: events) {
reader.read_event();
const auto ev = HEJ::Event::EventData{reader.hepeup()}.cluster(
fastjet::JetDefinition{fastjet::antikt_algorithm, 0.4}, 20.
);
for(size_t i = 0; i < ev.incoming().size(); ++i) {
if(!HEJ::nearby(ev.incoming()[i].p, event.incoming()[i].p)) return EXIT_FAILURE;
}
if(ev.outgoing().size() != event.outgoing().size()) return EXIT_FAILURE;
for(size_t i = 0; i < ev.outgoing().size(); ++i) {
if(!HEJ::nearby(ev.outgoing()[i].p, event.outgoing()[i].p)) return EXIT_FAILURE;
}
if(ev.decays().size() != event.decays().size()) return EXIT_FAILURE;
if(ev.type() != event.type()) return EXIT_FAILURE;
if(ev.central().weight != ev.central().weight) return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Dec 21, 12:54 PM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4022840
Default Alt Text
(2 KB)

Event Timeline