18 using namespace HepMC3;
22 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();;
27 assert(
std::abs(evt.
weights()[0] - 2.0) < std::numeric_limits<double>::epsilon() );
28 assert(
std::abs(evt.
weights()[1] - 4.56) < std::numeric_limits<double>::epsilon() );
29 assert( evt.
weights().size() == 2 );
30 assert( !evt.
weights().empty() );
32 std::vector<double> vec;
33 for(
int i = 0; i < 15; ++i )
35 double x = (double)i + 0.14*(
double)i;
39 assert( evt.
weights().size() == 15 );
41 assert( evt.
weights().size() == 14 );
44 std::vector<std::string> names;
45 for(
size_t i = 0; i < evt.
weights().size() - 1; ++i ) names.push_back(std::to_string((
unsigned long long)i));
46 std::string nm =
"tau";
48 run->set_weight_names(names);
56 double x = evt.
weight(
"bad");
57 std::cout <<
"lookup of nonexistent name returns " << x << std::endl;
59 catch (std::exception& e)
61 std::cout << e.what() << std::endl;
62 std::cout <<
"HepMC testWeights: the above error is intentional" << std::endl;
Definition of class GenRunInfo.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
Stores event-related information.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
Definition of static class Print.
int main(int argc, char **argv)
const std::vector< double > & weights() const
Get event weight values as a vector.
Definition of class GenEvent.
double weight(const unsigned long &index=0) const
Feature< Feature_type > abs(const Feature< Feature_type > &input)
Obtain the absolute value of a Feature. This works as you'd expect. If foo is a valid Feature...