6#ifndef ATLASHEPMC_POLARIZATION_H
7#define ATLASHEPMC_POLARIZATION_H
9#include "HepMC3/GenParticle.h"
10#include "HepMC3/Attribute.h"
14 Polarization(
const double a=0.0,
const double b=0.0,
15 bool is_defined =
false)
16 : m_theta(
a), m_phi(
b), m_is_defined(is_defined) {};
18 double theta()
const {
return m_theta;}
19 double phi()
const {
return m_phi;}
20 bool is_defined()
const {
return m_is_defined; }
21 inline bool operator ==(
const Polarization &
a)
const {
return (std::abs(
a.phi() -
phi()) <= 0.00001) && (std::abs(
a.theta() -
theta()) <= 0.00001);}
27template <class T, std::enable_if_t<std::is_same<T, HepMC3::GenParticlePtr>::value || std::is_same<T, HepMC3::ConstGenParticlePtr>::value,
bool > =
true>
29 std::shared_ptr<HepMC3::DoubleAttribute> phi_A =
a->template attribute<HepMC3::DoubleAttribute>(
"phi");
30 std::shared_ptr<HepMC3::DoubleAttribute> theta_A =
a->template attribute<HepMC3::DoubleAttribute>(
"theta");
31 double phi = (phi_A ? phi_A->value() : 0.0);
32 double theta = (theta_A ? theta_A->value() : 0.0);
33 bool is_defined = phi_A && theta_A;
34 return Polarization(
theta,
phi, is_defined);
37 a->add_attribute(
"phi",std::make_shared<HepMC3::DoubleAttribute>(
b.phi()));
38 a->add_attribute(
"theta",std::make_shared<HepMC3::DoubleAttribute>(
b.theta()));
45 a->set_polarization(b);
48 return a->polarization();
Scalar phi() const
phi method
Scalar theta() const
theta method
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
void set_polarization(T &a, const Polarization &b)
Polarization polarization(const T &a)