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#include "HepMC3/GenParticle.h"
9#include "HepMC3/Attribute.h"
11namespace HepMC {
13public:
14 Polarization(const double a = 0.0, const double b = 0.0,
15 bool is_defined = false)
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;
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>(HepMCStr::phi);
30 std::shared_ptr<HepMC3::DoubleAttribute> theta_A = a->template attribute<HepMC3::DoubleAttribute>(HepMCStr::theta);
31 const double phi = (phi_A ? phi_A->value() : 0.0);
32 const double theta = (theta_A ? theta_A->value() : 0.0);
33 const 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(HepMCStr::phi, std::make_shared<HepMC3::DoubleAttribute>(b.phi()));
38 a->add_attribute(HepMCStr::theta, std::make_shared<HepMC3::DoubleAttribute>(b.theta()));
39}
40}
41#endif
Scalar phi() const
phi method
Scalar theta() const
theta method
static Double_t a
double theta() const
Polarization(const double a=0.0, const double b=0.0, bool is_defined=false)
bool is_defined() const
double phi() const
bool operator==(const Polarization &a) const
const std::string phi
const std::string theta
void set_polarization(T &a, const Polarization &b)
Polarization polarization(const T &a)