ATLAS Offline Software
Loading...
Searching...
No Matches
Polarization.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4/* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
5
6#ifndef ATLASHEPMC_POLARIZATION_H
7#define ATLASHEPMC_POLARIZATION_H
8#ifdef HEPMC3
9#include "HepMC3/GenParticle.h"
10#include "HepMC3/Attribute.h"
11namespace HepMC {
12class Polarization {
13public:
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) {};
17 ~Polarization() {};
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);}
22private:
23 double m_theta;
24 double m_phi;
25 bool m_is_defined;
26};
27template <class T, std::enable_if_t<std::is_same<T, HepMC3::GenParticlePtr>::value || std::is_same<T, HepMC3::ConstGenParticlePtr>::value, bool > = true>
28inline Polarization polarization(const T& a) {
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);
35}
36template<class T> inline void set_polarization( T& a, const Polarization& b) {
37 a->add_attribute("phi",std::make_shared<HepMC3::DoubleAttribute>(b.phi()));
38 a->add_attribute("theta",std::make_shared<HepMC3::DoubleAttribute>(b.theta()));
39}
40}
41#else
42#include "HepMC/Polarization.h"
43namespace HepMC {
44template <class T> inline void set_polarization( T& a, const Polarization& b) {
45 a->set_polarization(b);
46}
47template <class T> inline Polarization polarization(const T& a) {
48 return a->polarization();
49}
50}
51#endif
52#endif
Scalar phi() const
phi method
Scalar theta() const
theta method
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
static Double_t a
void set_polarization(T &a, const Polarization &b)
Polarization polarization(const T &a)