Version: SMASH-2.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:
47  RivetOutput(const bf::path& path, std::string name, const bool full_event,
48  const OutputParameters& out_par);
52  ~RivetOutput();
61  void at_eventend(const Particles& particles, const int32_t event_number,
62  const EventInfo& event) override;
68  void add_analysis(const std::string& name);
72  void add_path(const std::string& path);
76  void add_preload(const std::string& file);
80  void set_ignore_beams(bool ignore = true);
84  void set_log_level(const std::string& name, const std::string& level);
91  void set_cross_section(double xs, double xserr);
95  void setup();
96 
97  private:
102  struct Proxy {
104  using Handler = std::shared_ptr<Rivet::AnalysisHandler>;
106  explicit Proxy(Handler h) : h_(h), g_(0) {}
108  Proxy(Proxy&& p) : h_(p.h_), g_(std::move(p.g_)) {}
110  Handler operator->() { return h_; }
115  };
118 
120  std::shared_ptr<Rivet::AnalysisHandler> handler_;
122  bf::path filename_;
127 };
128 
129 } // namespace smash
130 
131 #endif // SRC_INCLUDE_SMASH_RIVETOUTPUT_H_
Interface to the SMASH configuration files.
Guard type that safely disables floating point traps for the scope in which it is placed.
Definition: fpenvironment.h:79
Base class for output handlers that need the HepMC3 structure.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
SMASH output to Rivet analyses.
Definition: rivetoutput.h:36
Proxy analysis_handler_proxy()
Return a proxy that temporarily disables FP exceptions.
Definition: rivetoutput.h:117
void add_path(const std::string &path)
Add a load path to the Rivet handler.
Definition: rivetoutput.cc:185
void add_analysis(const std::string &name)
Add an analysis or analyses to Rivet.
Definition: rivetoutput.cc:181
void setup()
Read configuration of Rivet from SMASH configuration.
Definition: rivetoutput.cc:224
std::shared_ptr< Rivet::AnalysisHandler > handler_
Rivet analysis handler.
Definition: rivetoutput.h:120
bool need_init_
Whether we need initialisation.
Definition: rivetoutput.h:124
~RivetOutput()
Destructor.
Definition: rivetoutput.cc:157
bf::path filename_
Output file.
Definition: rivetoutput.h:122
void set_cross_section(double xs, double xserr)
Set X-section.
Definition: rivetoutput.cc:220
void add_preload(const std::string &file)
Add preload to Rivet handler.
Definition: rivetoutput.cc:190
void set_log_level(const std::string &name, const std::string &level)
Set log level in Rivet.
Definition: rivetoutput.cc:200
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:164
Configuration rivet_confs_
Configutations for rivet.
Definition: rivetoutput.h:126
RivetOutput(const bf::path &path, std::string name, const bool full_event, const OutputParameters &out_par)
Create Rivet output.
Definition: rivetoutput.cc:146
void set_ignore_beams(bool ignore=true)
Do not insist on appropriate beams for analyses.
Definition: rivetoutput.cc:194
constexpr int p
Proton.
Definition: action.h:24
Structure to contain custom data for output.
Helper structure for Experiment to hold output options and parameters.
A proxy object that wraps all Rivet::AnalysisHandler calls in an environment where FP errors are disa...
Definition: rivetoutput.h:102
DisableFloatTraps g_
FP traps temporaryly disabled.
Definition: rivetoutput.h:114
Proxy(Proxy &&p)
Move construct.
Definition: rivetoutput.h:108
std::shared_ptr< Rivet::AnalysisHandler > Handler
Type of handler.
Definition: rivetoutput.h:104
Handler operator->()
Forward calls to handler.
Definition: rivetoutput.h:110
Proxy(Handler h)
Construct proxy.
Definition: rivetoutput.h:106