Version: SMASH-2.0.2
rivetoutput.h
Go to the documentation of this file.
1 
2 /*
3  *
4  * Copyright (c) 2021 Christian Holm Christensen
5  * GNU General Public License (GPLv3 or later)
6  *
7  */
8 
9 #ifndef SRC_INCLUDE_SMASH_RIVETOUTPUT_H_
10 #define SRC_INCLUDE_SMASH_RIVETOUTPUT_H_
11 
12 #include <Rivet/AnalysisHandler.hh>
13 
14 #include <memory>
15 #include <string>
16 #include <utility>
17 
18 #include <boost/filesystem.hpp>
19 
20 #include "smash/fpenvironment.h"
21 #include "smash/hepmcinterface.h"
22 
23 namespace smash {
24 
36 class RivetOutput : public HepMcInterface {
37  public:
49  RivetOutput(const bf::path& path, std::string name, const bool full_event,
50  const int total_N, const int proj_N,
51  const OutputParameters& out_par);
55  ~RivetOutput();
64  void at_eventend(const Particles& particles, const int32_t event_number,
65  const EventInfo& event) override;
71  void add_analysis(const std::string& name);
75  void add_path(const std::string& path);
79  void add_preload(const std::string& file);
83  void set_ignore_beams(bool ignore = true);
87  void set_log_level(const std::string& name, const std::string& level);
94  void set_cross_section(double xs, double xserr);
98  void setup();
99 
100  private:
105  struct Proxy {
107  using Handler = std::shared_ptr<Rivet::AnalysisHandler>;
109  explicit Proxy(Handler h) : h_(h), g_(0) {}
111  Proxy(Proxy&& p) : h_(p.h_), g_(std::move(p.g_)) {}
113  Handler operator->() { return h_; }
118  };
121 
123  std::shared_ptr<Rivet::AnalysisHandler> handler_;
125  bf::path filename_;
130 };
131 
132 } // namespace smash
133 
134 #endif // SRC_INCLUDE_SMASH_RIVETOUTPUT_H_
smash
Definition: action.h:24
smash::RivetOutput::analysis_handler_proxy
Proxy analysis_handler_proxy()
Return a proxy that temporarily disables FP exceptions.
Definition: rivetoutput.h:120
smash::RivetOutput::~RivetOutput
~RivetOutput()
Destructor.
Definition: rivetoutput.cc:158
hepmcinterface.h
smash::RivetOutput::setup
void setup()
Read configuration of Rivet from SMASH configuration.
Definition: rivetoutput.cc:225
smash::RivetOutput::Proxy::h_
Handler h_
Handler.
Definition: rivetoutput.h:115
smash::RivetOutput::Proxy::operator->
Handler operator->()
Forward calls to handler.
Definition: rivetoutput.h:113
smash::RivetOutput::at_eventend
void at_eventend(const Particles &particles, const int32_t event_number, const EventInfo &event) override
Add the final particles information of an event to the central vertex.
Definition: rivetoutput.cc:165
smash::RivetOutput::Proxy::g_
DisableFloatTraps g_
FP traps temporaryly disabled.
Definition: rivetoutput.h:117
smash::RivetOutput::Proxy::Handler
std::shared_ptr< Rivet::AnalysisHandler > Handler
Type of handler.
Definition: rivetoutput.h:107
smash::DisableFloatTraps
Guard type that safely disables floating point traps for the scope in which it is placed.
Definition: fpenvironment.h:79
smash::RivetOutput::add_path
void add_path(const std::string &path)
Add a load path to the Rivet handler.
Definition: rivetoutput.cc:186
smash::EventInfo
Structure to contain custom data for output.
Definition: outputinterface.h:36
smash::Configuration
Interface to the SMASH configuration files.
Definition: configuration.h:464
smash::OutputParameters
Helper structure for Experiment to hold output options and parameters.
Definition: outputparameters.h:25
smash::RivetOutput::need_init_
bool need_init_
Whether we need initialisation.
Definition: rivetoutput.h:127
smash::RivetOutput::set_log_level
void set_log_level(const std::string &name, const std::string &level)
Set log level in Rivet.
Definition: rivetoutput.cc:201
smash::RivetOutput::add_analysis
void add_analysis(const std::string &name)
Add an analysis or analyses to Rivet.
Definition: rivetoutput.cc:182
smash::RivetOutput::filename_
bf::path filename_
Output file.
Definition: rivetoutput.h:125
smash::RivetOutput
SMASH output to Rivet analyses.
Definition: rivetoutput.h:36
fpenvironment.h
smash::RivetOutput::Proxy
A proxy object that wraps all Rivet::AnalysisHandler calls in an environment where FP errors are disa...
Definition: rivetoutput.h:105
smash::RivetOutput::RivetOutput
RivetOutput(const bf::path &path, std::string name, const bool full_event, const int total_N, const int proj_N, const OutputParameters &out_par)
Create Rivet output.
Definition: rivetoutput.cc:146
smash::HepMcInterface
Base class for output handlers that need the HepMC3 structure.
Definition: hepmcinterface.h:81
smash::Particles
Definition: particles.h:33
smash::RivetOutput::rivet_confs_
Configuration rivet_confs_
Configutations for rivet.
Definition: rivetoutput.h:129
smash::RivetOutput::Proxy::Proxy
Proxy(Proxy &&p)
Move construct.
Definition: rivetoutput.h:111
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::RivetOutput::add_preload
void add_preload(const std::string &file)
Add preload to Rivet handler.
Definition: rivetoutput.cc:191
smash::RivetOutput::set_cross_section
void set_cross_section(double xs, double xserr)
Set X-section.
Definition: rivetoutput.cc:221
smash::RivetOutput::Proxy::Proxy
Proxy(Handler h)
Construct proxy.
Definition: rivetoutput.h:109
smash::RivetOutput::handler_
std::shared_ptr< Rivet::AnalysisHandler > handler_
Rivet analysis handler.
Definition: rivetoutput.h:123
smash::RivetOutput::set_ignore_beams
void set_ignore_beams(bool ignore=true)
Do not insist on appropriate beams for analyses.
Definition: rivetoutput.cc:195