DAS  3.0
Das Analysis System
GenericObject.h
Go to the documentation of this file.
1 #pragma once
2 
3 // C
4 #include <cmath>
5 
6 // STD
7 #include <ostream>
8 #include <string_view>
9 #include <vector>
10 
11 // ROOT
12 #include <Math/Vector4D.h>
13 
14 // Darwin
15 #include <Variation.h>
16 #include <Weight.h>
17 
18 namespace Darwin::Physics {
19 
20 using FourVector = ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float>>;
21 
28 
29 public:
30  AbstractGenericObject () = default;
31  virtual ~AbstractGenericObject () = default;
32 
33  virtual FourVector CorrP4 (const Variation&) const = 0;
34  virtual float CorrPt (const Variation&) const = 0;
35  virtual double Weight (const Variation&) const = 0;
36 };
37 
45 protected:
46  virtual std::string_view scale_group () const = 0;
47  virtual std::string_view weight_group () const = 0;
48 
49  GenericObject () = default;
50  virtual ~GenericObject () = default;
51 
52 public:
54  std::vector<float> scales = {1.};
55  Weights weights = {{1.,0}};
56 
57  inline FourVector CorrP4 (size_t i = 0) const { return p4 * scales.at(i); }
58  inline float CorrPt (size_t i = 0) const { return p4.Pt() * scales.at(i); }
59  inline float Rapidity (const Variation& = nominal) const { return p4.Rapidity() ; }
60  inline float AbsRap (const Variation& = nominal) const { return std::abs(Rapidity()); }
61 
62  inline FourVector CorrP4 (const Variation& v) const final
63  { return GenericObject::CorrP4(v.Group() == scale_group() ? v.Index() : 0); }
64 
65  inline float CorrPt (const Variation& v) const final
66  { return GenericObject::CorrPt(v.Group() == scale_group() ? v.Index() : 0); }
67 
68  inline double Weight (const Variation& v) const final
69  {
70  if (v.Group() == weight_group()) {
71  const Darwin::Physics::Weight& w = weights.at(v.Index());
72  if (w.i == v.Bit()) return w;
73  }
74  return weights.front();
75  }
76 };
77 
78 inline bool operator== (const GenericObject& l, const GenericObject& r)
79 {
80  return l.p4 == r.p4 && l.scales == r.scales && l.weights == r.weights;
81 }
82 
83 inline bool operator< (const GenericObject& l, const GenericObject& r)
84 {
85  return l.CorrPt() < r.CorrPt();
86 }
87 
88 inline bool operator> (const GenericObject& l, const GenericObject& r)
89 {
90  return l.CorrPt() > r.CorrPt();
91 }
92 
93 } // end of Darwin::Physics namespace
94 
95 #if 0
96 inline std::ostream& operator<< (std::ostream& s, const Darwin::Physics::FourVector& p4)
97 {
98  return s << '(' << p4.Pt() << ',' << p4.Eta() << ',' << p4.Phi() << ',' << p4.M() << ')';
99 }
100 #endif
101 
102 inline std::ostream& operator<< (std::ostream& s, const Darwin::Physics::GenericObject& obj)
103 {
104  return s << obj.p4 << ' ' << obj.scales.size() << ' ' << obj.weights.size();
105 }
Darwin::Physics::Weight
Definition: Weight.h:17
Darwin::Physics::GenericObject::CorrPt
float CorrPt(size_t i=0) const
corrected transverse momentum
Definition: GenericObject.h:58
Darwin::Physics::GenericObject::CorrP4
FourVector CorrP4(const Variation &v) const final
< corrected 4-vector
Definition: GenericObject.h:62
Darwin::Physics::operator<
bool operator<(const GenericObject &l, const GenericObject &r)
Definition: GenericObject.h:83
Darwin::Physics::operator>
bool operator>(const GenericObject &l, const GenericObject &r)
Definition: GenericObject.h:88
Darwin::Physics::GenericObject::GenericObject
GenericObject()=default
Darwin::Physics::GenericObject::Weight
double Weight(const Variation &v) const final
< weight
Definition: GenericObject.h:68
DAS::JetEnergy::w
static const float w
Definition: common.h:51
operator<<
std::ostream & operator<<(std::ostream &s, const Darwin::Physics::GenericObject &obj)
Definition: GenericObject.h:102
Darwin::Physics::Weights
std::vector< Weight > Weights
Definition: Weight.h:42
Darwin::Physics::AbstractGenericObject::CorrP4
virtual FourVector CorrP4(const Variation &) const =0
Weight.h
Darwin::Physics::GenericObject::scale_group
virtual std::string_view scale_group() const =0
Darwin::Physics::Variation
Definition: Variation.h:20
Variation.h
Darwin::Physics::GenericObject::weights
Weights weights
object weights
Definition: GenericObject.h:55
Darwin::Physics::nominal
const Variation nominal("", "nominal")
Darwin::Physics::GenericObject::scales
std::vector< float > scales
energy scale corrections and variations
Definition: GenericObject.h:54
Darwin::Physics::AbstractGenericObject::~AbstractGenericObject
virtual ~AbstractGenericObject()=default
Darwin::Physics::GenericObject::~GenericObject
virtual ~GenericObject()=default
Darwin::Physics::GenericObject::Rapidity
float Rapidity(const Variation &=nominal) const
Definition: GenericObject.h:59
Darwin::Physics::AbstractGenericObject::CorrPt
virtual float CorrPt(const Variation &) const =0
Darwin::Physics::AbstractGenericObject
Definition: GenericObject.h:27
Darwin::Physics::GenericObject::AbsRap
float AbsRap(const Variation &=nominal) const
absolute rapidity
Definition: GenericObject.h:60
Darwin::Physics::GenericObject::CorrP4
FourVector CorrP4(size_t i=0) const
corrected 4-vector
Definition: GenericObject.h:57
Darwin::Physics::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: GenericObject.h:20
Darwin::Physics::GenericObject
Definition: GenericObject.h:44
Darwin::Physics::operator==
bool operator==(const GenericObject &l, const GenericObject &r)
Definition: GenericObject.h:78
Darwin::Physics::GenericObject::p4
FourVector p4
raw four-momentum directly after reconstruction
Definition: GenericObject.h:53
Darwin::Physics
Everything what concerns physics analysis directly.
Definition: darwin.h:24
Darwin::Physics::GenericObject::weight_group
virtual std::string_view weight_group() const =0
Darwin::Physics::GenericObject::CorrPt
float CorrPt(const Variation &v) const final
< corrected transverse momentum
Definition: GenericObject.h:65
Darwin::Physics::AbstractGenericObject::Weight
virtual double Weight(const Variation &) const =0
Darwin::Physics::AbstractGenericObject::AbstractGenericObject
AbstractGenericObject()=default