DAS  3.0
Das Analysis System
PhysicsObject.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cmath>
4 #include <vector>
5 #include <iostream>
6 #include <string_view>
7 
8 #include "Math/Vector4D.h"
9 
12 
13 namespace DAS {
14 
15 typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float>> FourVector;
16 
23 
24  AbstractPhysicsObject () = default;
25  virtual ~AbstractPhysicsObject () = default;
26 
27  virtual FourVector CorrP4 (const Uncertainties::Variation&) const = 0;
28  virtual float CorrPt (const Uncertainties::Variation&) const = 0;
29  virtual double Weight (const Uncertainties::Variation&) const = 0;
30 };
31 
39 protected:
40  virtual std::string_view scale_group () const = 0;
41  virtual std::string_view weight_group () const = 0;
42 
43  PhysicsObject () = default;
44  virtual ~PhysicsObject () = default;
45 
46 public:
48  std::vector<float> scales = {1.};
49  Weights weights = {{1.,0}};
50 
51  inline FourVector CorrP4 (size_t i = 0) const { return p4 * scales.at(i); }
52  inline float CorrPt (size_t i = 0) const { return p4.Pt() * scales.at(i); }
53  inline float Rapidity (const Uncertainties::Variation& = Uncertainties::nominal) const { return p4.Rapidity() ; }
54  inline float AbsRap (const Uncertainties::Variation& = Uncertainties::nominal) const { return std::abs(Rapidity()); }
55 
56  inline FourVector CorrP4 (const Uncertainties::Variation& v) const final
57  { return PhysicsObject::CorrP4(v.group == scale_group() ? v.index : 0); }
58 
59  inline float CorrPt (const Uncertainties::Variation& v) const final
60  { return PhysicsObject::CorrPt(v.group == scale_group() ? v.index : 0); }
61 
62  inline double Weight (const Uncertainties::Variation& v) const final
63  {
64  if (v.group == weight_group()) {
65  const DAS::Weight& w = weights.at(v.index);
66  if (w.i == v.bit) return w;
67  }
68  return weights.front();
69  }
70 };
71 
72 inline bool operator== (const PhysicsObject& l, const PhysicsObject& r)
73 {
74  return l.p4 == r.p4 && l.scales == r.scales && l.weights == r.weights;
75 }
76 
77 inline bool operator< (const PhysicsObject& l, const PhysicsObject& r)
78 {
79  return l.CorrPt() < r.CorrPt();
80 }
81 
82 inline bool operator> (const PhysicsObject& l, const PhysicsObject& r)
83 {
84  return l.CorrPt() > r.CorrPt();
85 }
86 
87 } // end of DAS namespace
88 
89 inline std::ostream& operator<< (std::ostream& s, const DAS::FourVector& p4)
90 {
91  return s << '(' << p4.Pt() << ',' << p4.Eta() << ',' << p4.Phi() << ',' << p4.M() << ')';
92 }
93 
94 inline std::ostream& operator<< (std::ostream& s, const DAS::PhysicsObject& obj)
95 {
96  return s << obj.p4 << ' ' << obj.scales.size() << ' ' << obj.weights.size();
97 }
98 
99 #if defined(__ROOTCLING__)
100 #pragma link C++ class DAS::AbstractPhysicsObject +;
101 #pragma link C++ class DAS::PhysicsObject +;
102 #pragma link C++ class std::vector<DAS::FourVector> +;
103 #endif
DAS::operator==
bool operator==(const PhysicsObject &l, const PhysicsObject &r)
Definition: PhysicsObject.h:72
DAS::Weights
std::vector< Weight > Weights
Definition: Weight.h:41
DAS
Definition: applyBTagSF.cc:31
DAS::AbstractPhysicsObject::CorrPt
virtual float CorrPt(const Uncertainties::Variation &) const =0
DAS::PhysicsObject::Weight
double Weight(const Uncertainties::Variation &v) const final
< weight
Definition: PhysicsObject.h:62
DAS::PhysicsObject::p4
FourVector p4
raw four-momentum directly after reconstruction
Definition: PhysicsObject.h:47
DAS::PhysicsObject::scale_group
virtual std::string_view scale_group() const =0
DAS::PhysicsObject::Rapidity
float Rapidity(const Uncertainties::Variation &=Uncertainties::nominal) const
Definition: PhysicsObject.h:53
DAS::AbstractPhysicsObject::Weight
virtual double Weight(const Uncertainties::Variation &) const =0
DAS::PhysicsObject::CorrP4
FourVector CorrP4(size_t i=0) const
corrected 4-vector
Definition: PhysicsObject.h:51
DAS::PhysicsObject::PhysicsObject
PhysicsObject()=default
DAS::PhysicsObject
Definition: PhysicsObject.h:38
DAS::PhysicsObject::scales
std::vector< float > scales
energy scale corrections and variations
Definition: PhysicsObject.h:48
DAS::JetEnergy::w
static const float w
Definition: common.h:51
DAS::PhysicsObject::AbsRap
float AbsRap(const Uncertainties::Variation &=Uncertainties::nominal) const
absolute rapidity
Definition: PhysicsObject.h:54
DAS::operator>
bool operator>(const PhysicsObject &l, const PhysicsObject &r)
Definition: PhysicsObject.h:82
DAS::AbstractPhysicsObject::AbstractPhysicsObject
AbstractPhysicsObject()=default
DAS::AbstractPhysicsObject::~AbstractPhysicsObject
virtual ~AbstractPhysicsObject()=default
DAS::Uncertainties::nominal
const Variation nominal
Definition: Variation.h:109
DAS::AbstractPhysicsObject
Definition: PhysicsObject.h:22
DAS::PhysicsObject::weight_group
virtual std::string_view weight_group() const =0
DAS::AbstractPhysicsObject::CorrP4
virtual FourVector CorrP4(const Uncertainties::Variation &) const =0
DAS::Weight
Definition: Weight.h:16
DAS::PhysicsObject::CorrPt
float CorrPt(size_t i=0) const
corrected transverse momentum
Definition: PhysicsObject.h:52
DAS::PhysicsObject::~PhysicsObject
virtual ~PhysicsObject()=default
DAS::operator<
bool operator<(const PhysicsObject &l, const PhysicsObject &r)
Definition: PhysicsObject.h:77
Weight.h
DAS::PhysicsObject::weights
Weights weights
object weights
Definition: PhysicsObject.h:49
operator<<
std::ostream & operator<<(std::ostream &s, const DAS::FourVector &p4)
Definition: PhysicsObject.h:89
DAS::PhysicsObject::CorrPt
float CorrPt(const Uncertainties::Variation &v) const final
< corrected transverse momentum
Definition: PhysicsObject.h:59
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
DAS::Uncertainties::Variation
Definition: Variation.h:22
Variation.h
DAS::PhysicsObject::CorrP4
FourVector CorrP4(const Uncertainties::Variation &v) const final
< corrected 4-vector
Definition: PhysicsObject.h:56