hej is hosted by Hepforge, IPPP Durham
HEJ 2.2.2
High energy resummation for hadron colliders
Loading...
Searching...
No Matches
LesHouchesReader.hh
Go to the documentation of this file.
1
8#pragma once
9
10#include <string>
11#include <numeric>
12
13#include "LHEF/LHEF.h"
14
15#include "HEJ/EventReader.hh"
16#include "HEJ/stream.hh"
17
18namespace HEJ {
19
22 public:
24 explicit LesHouchesReader(std::string const & filename);
25
27 bool read_event() override;
28
30 std::string const & header() const override {
31 return reader_.headerBlock;
32 }
33
35 LHEF::HEPRUP const & heprup() const override {
36 return reader_.heprup;
37 }
38
40 LHEF::HEPEUP const & hepeup() const override {
41 return reader_.hepeup;
42 }
43
44 std::optional<size_t> number_events() const override {
45 std::size_t start = header().rfind("Number of Events");
46 start = header().find_first_of("123456789", start);
47 if(start == std::string::npos) {
48 return {};
49 }
50 const std::size_t end = header().find_first_not_of("0123456789", start);
51 return std::stoi(header().substr(start, end - start));
52 }
53
54 double scalefactor() const override {
55 if (generator_==Generator::Sherpa) {
56 const std::size_t num_trials = std::accumulate(
57 num_trials_.begin(), num_trials_.end(), 0
58 );
59 return 1./static_cast<double>(num_trials);
60 }
61 else
62 return 1.;
63 }
64
65 private:
66 enum class Generator{
67 HEJ,
68 HEJFOG,
69 Sherpa,
70 MG,
71 unknown
72 };
73
74 bool calculate_XSECUP() {
75 return calculate_XSECUP_;
76 }
77 Generator get_generator(
78 LHEF::HEPRUP const & heprup, std::string const & header
79 );
80
81 istream stream_;
82 LHEF::Reader reader_;
83 std::vector<size_t> num_trials_;
84 Generator generator_;
85 bool calculate_XSECUP_;
86 };
87
88} // namespace HEJ
Header file for event reader interface.
Class for reading events from a file in the Les Houches Event File format.
Definition: LesHouchesReader.hh:21
LHEF::HEPEUP const & hepeup() const override
Access last read event.
Definition: LesHouchesReader.hh:40
bool read_event() override
Read an event.
double scalefactor() const override
Definition: LesHouchesReader.hh:54
LHEF::HEPRUP const & heprup() const override
Access run information.
Definition: LesHouchesReader.hh:35
LesHouchesReader(std::string const &filename)
Contruct object reading from the given file.
std::string const & header() const override
Access header text.
Definition: LesHouchesReader.hh:30
std::optional< size_t > number_events() const override
Guess number of events from header.
Definition: LesHouchesReader.hh:44
Main HEJ 2 Namespace.
Definition: mainpage.dox:1
Declares input streams.
Abstract base class for reading events from files.
Definition: EventReader.hh:25