HepMC event record
include/HepMC/GenCrossSection.h
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2015 The HepMC collaboration (see AUTHORS for details)
5 //
6 #ifndef HEPMC_CROSS_SECTION_H
7 #define HEPMC_CROSS_SECTION_H
8 /**
9  * @file GenCrossSection.h
10  * @brief Definition of attribute \b class GenCrossSection
11  *
12  * @class HepMC::GenCrossSection
13  * @brief Stores additional information about cross-section
14  *
15  * This is an example of event attribute used to store cross-section information
16  *
17  * This class is meant to be used to pass, on an event by event basis,
18  * the current best guess of the total cross section.
19  * It is expected that the final cross section will be stored elsewhere.
20  *
21  * - double cross_section; // cross section in pb
22  * - double cross_section_error; // error associated with this cross section
23  *
24  * The units of cross_section and cross_section_error are expected to be pb.
25  *
26  * @ingroup attributes
27  *
28  */
29 #include <iostream>
30 #include "HepMC/Attribute.h"
31 
32 namespace HepMC {
33 
34 
35 class GenCrossSection : public Attribute {
36 
37 //
38 // Fields
39 //
40 public:
41 
42  double cross_section; ///< Generated cross-section
43  double cross_section_error; ///< Generated cross-section error
44  long accepted_events; ///< The number of events generated so far.
45  long attempted_events; ///< The number of events attempted so far.
46 
47 //
48 // Functions
49 //
50 public:
51  /** @brief Implementation of Attribute::from_string */
52  bool from_string(const string &att);
53 
54  /** @brief Implementation of Attribute::to_string */
55  bool to_string(string &att) const;
56 
57  /** @brief Set all fields */
58  void set_cross_section( double xs, double xs_err, long n_acc = -1, long n_att = -1) {
59  cross_section = xs;
60  cross_section_error = xs_err;
61  accepted_events = n_acc;
62  attempted_events = n_att;
63  }
64 
65  bool operator==( const GenCrossSection& ) const; ///< Operator ==
66  bool operator!=( const GenCrossSection& ) const; ///< Operator !=
67  bool is_valid() const; ///< Verify that the instance contains non-zero information
68 };
69 
70 
71 } // namespace HepMC
72 
73 #endif
double cross_section_error
Generated cross-section error.
bool to_string(string &att) const
Implementation of Attribute::to_string.
Stores additional information about cross-section.
long accepted_events
The number of events generated so far.
bool from_string(const string &att)
Implementation of Attribute::from_string.
long attempted_events
The number of events attempted so far.
double cross_section
Generated cross-section.
bool operator!=(const GenCrossSection &) const
Operator !=.
bool operator==(const GenCrossSection &) const
Operator ==.
Definition of template class SmartPointer.
bool is_valid() const
Verify that the instance contains non-zero information.
void set_cross_section(double xs, double xs_err, long n_acc=-1, long n_att=-1)
Set all fields.