hej is hosted by Hepforge, IPPP Durham
HEJ 2.1.4
High energy resummation for hadron colliders
Loading...
Searching...
No Matches
EventReader.hh
Go to the documentation of this file.
1
10#pragma once
11
12#include <cstddef>
13#include <memory>
14#include <string>
15
16#include "HEJ/optional.hh"
17
18namespace LHEF {
19 class HEPEUP;
20 class HEPRUP;
21}
22
23namespace HEJ {
24
26 struct EventReader {
28 virtual bool read_event() = 0;
29
31 virtual std::string const & header() const = 0;
32
34 virtual LHEF::HEPRUP const & heprup() const = 0;
35
37 virtual LHEF::HEPEUP const & hepeup() const = 0;
38
41 std::size_t start = header().rfind("Number of Events");
42 start = header().find_first_of("123456789", start);
43 if(start == std::string::npos) {
44 return {};
45 }
46 const std::size_t end = header().find_first_not_of("0123456789", start);
47 return std::stoi(header().substr(start, end - start));
48 }
49
50 virtual ~EventReader() = default;
51 };
52
54
59 std::unique_ptr<EventReader> make_reader(std::string const & filename);
60} // namespace HEJ
Main HEJ 2 Namespace.
Definition: mainpage.dox:1
std::unique_ptr< EventReader > make_reader(std::string const &filename)
Factory function for event readers.
boost::optional< T > optional
Definition: optional.hh:23
Definition: Analysis.hh:14
Defines the optional type.
Abstract base class for reading events from files.
Definition: EventReader.hh:26
virtual LHEF::HEPEUP const & hepeup() const =0
Access last read event.
virtual std::string const & header() const =0
Access header text.
virtual ~EventReader()=default
virtual bool read_event()=0
Read an event.
virtual LHEF::HEPRUP const & heprup() const =0
Access run information.
virtual optional< std::size_t > number_events() const
Guess number of events from header.
Definition: EventReader.hh:40