DAS  3.0
Das Analysis System
Variation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <memory>
5 
6 #include <TString.h>
7 
8 #include "Math/Vector4D.h"
9 
11 
12 namespace DAS {
13 
14 typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<float>> FourVector;
15 
16 namespace Uncertainties {
17 
22 struct Variation {
23 
24  const TString group;
25  const TString name;
26 
27  const std::size_t index;
28  const int bit;
29 
32  ~Variation () = default;
33 
36  Variation (const TString& group, const TString& name, size_t index = 0, int bit = 0) :
38  { }
39 
42  Variation (const Variation& v) :
43  group(v.group), name(v.name), index(v.index), bit(v.bit)
44  { }
45 
49  group(std::move(v.group)), name(std::move(v.name)),
50  index(std::move(v.index)), bit(std::move(v.bit))
51  { }
52 
61  template<class T>
62  const T& getCorrection (const std::string_view& group,
63  const std::vector<T>& corrections) const;
64 
72  template<class PhysicsObject>
73  const Weight& getWeight (const PhysicsObject& object) const;
74 
82  template<class PhysicsObject>
83  FourVector getCorrP4 (const PhysicsObject& object) const;
84 };
85 
86 template<class T
87 > inline const T& Variation::getCorrection (const std::string_view& group,
88  const std::vector<T>& corrections) const
89 {
90  if (index >= corrections.size() || group != this->group)
91  return corrections.front();
92  return corrections.at(index);
93 }
94 
95 template<class PhysicsObject>
96 [[ deprecated ]]
97 inline const DAS::Weight& Variation::getWeight (const PhysicsObject& object) const
98 {
99  return getCorrection(PhysicsObject::WeightVar, object.weights);
100 }
101 
102 template<class PhysicsObject>
103 [[ deprecated ]]
104 inline FourVector Variation::getCorrP4 (const PhysicsObject& object) const
105 {
106  return group == PhysicsObject::ScaleVar ? object.CorrP4(index) : object.CorrP4(0);
107 }
108 
109 const Variation nominal {"", "nominal"};
110 
111 inline std::ostream& operator<< (std::ostream& s, const DAS::Uncertainties::Variation& v)
112 {
113  return s << v.group << ' ' << v.name << ' ' << v.index << ' ' << v.bit;
114 }
115 
116 } // end of namespace Uncertainties
117 
118 } // end of namespace DAS
DAS
Definition: applyBTagSF.cc:31
DAS::Uncertainties::Variation::Variation
Variation(const TString &group, const TString &name, size_t index=0, int bit=0)
Normal constructor.
Definition: Variation.h:36
DAS::Uncertainties::Variation::name
const TString name
variation name (including "Up" or "Down")
Definition: Variation.h:25
DAS::Uncertainties::Variation::getWeight
const Weight & getWeight(const PhysicsObject &object) const
DAS::PhysicsObject
Definition: PhysicsObject.h:38
DAS::Uncertainties::operator<<
std::ostream & operator<<(std::ostream &s, const DAS::Uncertainties::Variation &v)
Definition: Variation.h:111
DAS::Uncertainties::Variation::Variation
Variation(const Variation &v)
Copy constructor.
Definition: Variation.h:42
DAS::Uncertainties::nominal
const Variation nominal
Definition: Variation.h:109
DAS::Uncertainties::Variation::~Variation
~Variation()=default
Destructor.
DAS::Uncertainties::Variation::bit
const int bit
correlation bit
Definition: Variation.h:28
DAS::Weight
Definition: Weight.h:16
DAS::Uncertainties::Variation::getCorrection
const T & getCorrection(const std::string_view &group, const std::vector< T > &corrections) const
Definition: Variation.h:87
Weight.h
DAS::Uncertainties::Variation::Variation
Variation(Variation &&v)
Move constructor.
Definition: Variation.h:48
DAS::Uncertainties::Variation::group
const TString group
e.g. event, recjet
Definition: Variation.h:24
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
weights
DAS::Weights weights
Definition: classes.h:12
DAS::Uncertainties::Variation
Definition: Variation.h:22
DAS::Uncertainties::Variation::getCorrP4
FourVector getCorrP4(const PhysicsObject &object) const
Definition: Variation.h:104
DAS::Uncertainties::Variation::index
const std::size_t index
index in the vector where the variation factor is stored
Definition: Variation.h:27