DAS  3.0
Das Analysis System
Di.h
Go to the documentation of this file.
1 #pragma once
2 
3 // C
4 #include <cmath>
5 
6 // STD
7 #include <algorithm>
8 #include <iostream>
9 #include <type_traits>
10 
11 // ROOT
12 #include <Math/VectorUtil.h>
13 
14 // Darwin
15 #include <colours.h>
16 #include <Variation.h>
17 #include <GenericObject.h>
18 
19 namespace Darwin::Physics {
20 
36 template<typename Obj1, typename Obj2> class Di : public std::pair<Obj1*, Obj2*>,
37  public AbstractGenericObject {
38 
39 public:
40  using std::pair<Obj1*, Obj2*>::pair;
41  using std::pair<Obj1*, Obj2*>::first,
42  std::pair<Obj1*, Obj2*>::second;
43 
44  explicit operator bool () const { return first && second; }
45 
46  inline void clear () { first = nullptr; second = nullptr; }
47 
48  inline FourVector CorrP4 (const Variation& v = nominal) const override { return first->CorrP4(v) + second->CorrP4(v); }
49  inline float CorrPt (const Variation& v = nominal) const override { return CorrP4(v).Pt(); }
50 
51  inline float Rapidity (const Variation& v = nominal) const { return CorrP4(v).Rapidity(); }
52  inline float AbsRap (const Variation& v = nominal) const { return std::abs(Rapidity(v)); }
53 
54  inline float DeltaEta (const Variation& v = nominal) const { return second->CorrP4(v).Eta() - first->CorrP4(v).Eta(); }
55  inline float DeltaPhi (const Variation& v = nominal) const { return ROOT::Math::VectorUtil::DeltaPhi(first->CorrP4(v),
56  second->CorrP4(v)); }
57  inline float DeltaR (const Variation& v = nominal) const { return ROOT::Math::VectorUtil::DeltaR (first->CorrP4(v),
58  second->CorrP4(v)); }
59 
60  inline float Yboost (const Variation& v = nominal) const { return (first->Rapidity(v) + second->Rapidity(v))/2; }
61  inline float Ystar (const Variation& v = nominal) const { return (first->Rapidity(v) - second->Rapidity(v))/2; }
62 
63  inline float Ymax (const Variation& v = nominal) const { return std::max(first->AbsRap(v), second->AbsRap(v)); }
64  inline float HT (const Variation& v = nominal) const { return (first->CorrPt(v) + second->CorrPt(v))/2; }
65 
66  inline double Weight (const Variation& v = nominal) const override { return first->Weight(v) * second->Weight(v); }
67 };
68 
69 } // end of Darwin::Physics namespace
70 
71 #if 0
72 
85 template<typename Obj1, typename Obj2,
86  class = typename std::enable_if_t<std::is_base_of_v<Darwin::Physics::AbstractGenericObject, Obj1>>,
87  class = typename std::enable_if_t<std::is_base_of_v<Darwin::Physics::AbstractGenericObject, Obj2>>>
88 inline auto operator+ (Obj1& o1, Obj2& o2)
89 {
90  return Darwin::Physics::Di<Obj1,Obj2>{&o1,&o2};
91 }
92 
93 template<typename Obj1, typename Obj2>
94 std::ostream& operator<< (std::ostream& s, const Darwin::Physics::Di<Obj1,Obj2>& di)
95 {
96  if (di)
97  return s << '[' << *di.first << ", " << *di.second << "] = " << di.CorrP4();
98  else
99  return s << red << "invalid system" << normal;
100 }
101 
102 #endif
Darwin::Physics::Di::Ystar
float Ystar(const Variation &v=nominal) const
Definition: Di.h:61
Darwin::Physics::Di::Ymax
float Ymax(const Variation &v=nominal) const
Definition: Di.h:63
Darwin::Physics::Di::CorrP4
FourVector CorrP4(const Variation &v=nominal) const override
Definition: Di.h:48
Darwin::Physics::Di::CorrPt
float CorrPt(const Variation &v=nominal) const override
Definition: Di.h:49
Darwin::Physics::Di::clear
void clear()
Definition: Di.h:46
colours.h
Darwin::Physics::Variation
Definition: Variation.h:20
Variation.h
Step::red
static const char * red
Definition: Step.h:34
Darwin::Physics::Di::Weight
double Weight(const Variation &v=nominal) const override
Definition: Di.h:66
Darwin::Physics::nominal
const Variation nominal("", "nominal")
Darwin::Physics::Di
Definition: Di.h:37
normal
static const char * normal
Definition: colours.h:8
Darwin::Physics::Di::HT
float HT(const Variation &v=nominal) const
Definition: Di.h:64
Darwin::Physics::Di::Yboost
float Yboost(const Variation &v=nominal) const
Definition: Di.h:60
Darwin::Physics::Di::Rapidity
float Rapidity(const Variation &v=nominal) const
Definition: Di.h:51
operator<<
std::ostream & operator<<(std::ostream &s, const DAS::Di< Obj1, Obj2 > &di)
Definition: Di.h:101
Darwin::Physics::Di::DeltaEta
float DeltaEta(const Variation &v=nominal) const
Definition: Di.h:54
Darwin::Physics::Di::DeltaPhi
float DeltaPhi(const Variation &v=nominal) const
Definition: Di.h:55
Darwin::Physics::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: GenericObject.h:20
GenericObject.h
Darwin::Physics::Di::AbsRap
float AbsRap(const Variation &v=nominal) const
Definition: Di.h:52
Darwin::Physics::Di::DeltaR
float DeltaR(const Variation &v=nominal) const
Definition: Di.h:57
Darwin::Physics
Everything what concerns physics analysis directly.
Definition: darwin.h:24