Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309562
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/t/test_hdf5_write.cc b/t/test_hdf5_write.cc
index f068bef..4eb04be 100644
--- a/t/test_hdf5_write.cc
+++ b/t/test_hdf5_write.cc
@@ -1,82 +1,92 @@
/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
#include "HEJ/Event.hh"
#include "HEJ/HDF5Reader.hh"
#include "HEJ/make_writer.hh"
#include "HEJ/utility.hh"
#include <cstdio>
#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;
+ size_t max_nevent = 15299;
// this scope is needed to trigger the HEJ::HDF5Writer destructor
// don't remove it
{
auto reader = HEJ::make_reader(argv[1]);
auto writer = HEJ::make_format_writer(
HEJ::FileFormat::HDF5, file.name(), reader->heprup()
);
+ size_t nevent = 0;
while(reader->read_event()) {
+ ++nevent;
const auto event = HEJ::Event::EventData{reader->hepeup()}.cluster(
fastjet::JetDefinition{fastjet::antikt_algorithm, 0.4}, 20.
);
events.emplace_back(event);
writer->write(event);
+ if(nevent>=max_nevent)
+ break;
}
+ max_nevent = std::min(nevent,max_nevent);
}
HEJ::HDF5Reader reader{file.name()};
+ size_t nevent = 0;
for(auto const & event: events) {
+ ++nevent;
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;
}
+ if(nevent!=max_nevent)
+ return EXIT_FAILURE;
return EXIT_SUCCESS;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Dec 21, 3:46 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4015048
Default Alt Text
(2 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment