DAS  3.0
Das Analysis System
Di.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cmath>
4 
5 #include <algorithm>
6 #include <iostream>
7 #include <type_traits>
8 
12 
13 #include "Math/VectorUtil.h"
14 
15 namespace DAS {
16 
32 template<typename Obj1, typename Obj2> struct Di : public std::pair<Obj1*, Obj2*>,
33  public AbstractPhysicsObject {
34 
35  using base = std::pair<Obj1*, Obj2*>;
36 
37  using std::pair<Obj1*, Obj2*>::pair;
38  using std::pair<Obj1*, Obj2*>::first,
39  std::pair<Obj1*, Obj2*>::second;
40 
41 public:
42  explicit operator bool () const { return first && second; }
43 
44  inline void clear () { first = nullptr; second = nullptr; }
45 
47  { return first->CorrP4(v) + second->CorrP4(v); }
48  inline float CorrPt (const Uncertainties::Variation& v = Uncertainties::nominal) const override
49  { return CorrP4(v).Pt(); }
50 
52  { return CorrP4(v).Rapidity(); }
53  inline float AbsRap (const Uncertainties::Variation& v = Uncertainties::nominal) const
54  { return std::abs(Rapidity(v)); }
55 
57  { return second->CorrP4(v).Eta() - first->CorrP4(v).Eta(); }
59  { return ROOT::Math::VectorUtil::DeltaPhi(first->CorrP4(v), second->CorrP4(v)); }
60  inline float DeltaR (const Uncertainties::Variation& v = Uncertainties::nominal) const
61  { return ROOT::Math::VectorUtil::DeltaR (first->CorrP4(v), second->CorrP4(v)); }
62 
63  inline float Yboost (const Uncertainties::Variation& v = Uncertainties::nominal) const
64  { return (first->Rapidity(v) + second->Rapidity(v))/2; }
65  inline float Ystar (const Uncertainties::Variation& v = Uncertainties::nominal) const
66  { return (first->Rapidity(v) - second->Rapidity(v))/2; }
67 
68  inline float Ymax (const Uncertainties::Variation& v = Uncertainties::nominal) const
69  { return std::max(first->AbsRap(), second->AbsRap()); }
70  inline float HT (const Uncertainties::Variation& v = Uncertainties::nominal) const
71  { return (first->CorrPt(v) + second->CorrPt(v))/2; }
72 
73  inline double Weight (const Uncertainties::Variation& v = Uncertainties::nominal) const override
74  { return first->Weight(v) * second->Weight(v); }
75 };
76 
83 
84 } // end of DAS namespace
85 
92 template<typename Obj1, typename Obj2,
93  class = typename std::enable_if_t<std::is_base_of_v<DAS::AbstractPhysicsObject, Obj1>>,
94  class = typename std::enable_if_t<std::is_base_of_v<DAS::AbstractPhysicsObject, Obj2>>>
95 auto operator+ (Obj1& o1, Obj2& o2)
96 {
97  return DAS::Di<Obj1,Obj2>{&o1,&o2};
98 }
99 
100 template<typename Obj1, typename Obj2>
101 std::ostream& operator<< (std::ostream& s, const DAS::Di<Obj1,Obj2>& di)
102 {
103  if (di)
104  return s << '[' << *di.first << ", " << *di.second << "] = " << di.CorrP4();
105  else
106  return s << "\x1B[33minvalid system\x1B[0m";
107 }
108 
109 #if defined(__ROOTCLING__)
110 #pragma link C++ class DAS::GenDijet::base +;
111 #pragma link C++ class DAS::GenDimuon::base +;
112 #pragma link C++ class DAS::GenZJet::base +;
113 #pragma link C++ class DAS::RecDijet::base +;
114 #pragma link C++ class DAS::RecDimuon::base +;
115 #pragma link C++ class DAS::RecZJet::base +;
116 
117 #pragma link C++ class DAS::GenDijet +;
118 #pragma link C++ class DAS::GenDimuon +;
119 #pragma link C++ class DAS::GenZJet +;
120 #pragma link C++ class DAS::RecDijet +;
121 #pragma link C++ class DAS::RecDimuon +;
122 #pragma link C++ class DAS::RecZJet +;
123 #endif
DAS
Definition: applyBTagSF.cc:31
DAS::Di::AbsRap
float AbsRap(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:53
DAS::Di::Ystar
float Ystar(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:65
DAS::Di::Weight
double Weight(const Uncertainties::Variation &v=Uncertainties::nominal) const override
Definition: Di.h:73
DAS::Di< const DAS::GenJet, const DAS::GenJet >::base
std::pair< const DAS::GenJet *, const DAS::GenJet * > base
Definition: Di.h:35
Lepton.h
operator<<
std::ostream & operator<<(std::ostream &s, const DAS::Di< Obj1, Obj2 > &di)
Definition: Di.h:101
DAS::Di::HT
float HT(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:70
DAS::Di::DeltaR
float DeltaR(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:60
DAS::Di::CorrPt
float CorrPt(const Uncertainties::Variation &v=Uncertainties::nominal) const override
Definition: Di.h:48
DAS::Di
Definition: Di.h:33
DAS::Uncertainties::nominal
const Variation nominal
Definition: Variation.h:109
DAS::AbstractPhysicsObject
Definition: PhysicsObject.h:22
DAS::Di::Rapidity
float Rapidity(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:51
DAS::Di::Yboost
float Yboost(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:63
DAS::Di::DeltaEta
float DeltaEta(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:56
DAS::Di::Ymax
float Ymax(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:68
Variation.h
Jet.h
DAS::Di::CorrP4
FourVector CorrP4(const Uncertainties::Variation &v=Uncertainties::nominal) const override
Definition: Di.h:46
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
DAS::Di::clear
void clear()
Definition: Di.h:44
DAS::Di::DeltaPhi
float DeltaPhi(const Uncertainties::Variation &v=Uncertainties::nominal) const
Definition: Di.h:58
DAS::Uncertainties::Variation
Definition: Variation.h:22