TTTT Analysis  0.1
value.hpp
1 #ifndef root_value_hpp
2 #define root_value_hpp
3 #include "value.hpp"
4 #include "TLorentzVector.h"
5 
6 namespace fv::root{
7 
8 class LorentzVector : public DerivedValue<TLorentzVector>{
9  protected:
10  Value<double> *pt;
11  Value<double> *eta;
12  Value<double> *phi;
13  Value<double> *m;
14 
15  void update_value(){
16  value.SetPtEtaPhiM(pt->get_value(), eta->get_value(), phi->get_value(), m->get_value());
17  }
18 
20  if (pt == nullptr)
21  CRITICAL("LorentzVector " << this->get_name() << " created with invalid pt", -1);
22  if (eta == nullptr)
23  CRITICAL("LorentzVector " << this->get_name() << " created with invalid eta", -1);
24  if (phi == nullptr)
25  CRITICAL("LorentzVector " << this->get_name() << " created with invalid phi", -1);
26  if (m == nullptr)
27  CRITICAL("LorentzVector " << this->get_name() << " created with invalid mass", -1);
28  }
29 
30  public:
31  LorentzVector(const std::string& name,
32  Value<double>* pt,
33  Value<double>* eta,
34  Value<double>* phi,
35  Value<double>* m)
37  pt(pt), eta(eta),
38  phi(phi), m(m) { }
39 
40  LorentzVector(const std::string& name,
41  const std::string &pt_label,
42  const std::string &eta_label,
43  const std::string &phi_label,
44  const std::string &m_label)
45  :LorentzVector(name,
46  dynamic_cast<Value<double>*>(GenValue::get_value(pt_label)),
47  dynamic_cast<Value<double>*>(GenValue::get_value(eta_label)),
48  dynamic_cast<Value<double>*>(GenValue::get_value(phi_label)),
49  dynamic_cast<Value<double>*>(GenValue::get_value(m_label))){ }
50 };
51 
52 class LorentzVectorEnergy : public DerivedValue<double>{
53  protected:
54  Value<TLorentzVector>* vector;
55  void update_value(){
56  value = vector->get_value().E();
57  }
58 
60  if (vector == nullptr)
61  CRITICAL("LorentzVectorEnergy " << this->get_name() << " created with invalid vector", -1);
62  }
63 
64  public:
65  LorentzVectorEnergy(const std::string& name, Value<TLorentzVector>* vector)
67  vector(vector){ }
68 
69  LorentzVectorEnergy(const std::string& name, const std::string& vector_label)
70  :LorentzVectorEnergy(name,
71  dynamic_cast<Value<TLorentzVector>*>(GenValue::get_value(vector_label))){ }
72 };
73 }
74 #endif // root_value_hpp
std::string name
The name of the value.
Definition: value.hpp:190
void update_value()
Updates the internal value.
Definition: value.hpp:15
void verify_integrity()
This function serves to check that this Value has been created with real, i.e.
Definition: value.hpp:59
void verify_integrity()
This function serves to check that this Value has been created with real, i.e.
Definition: value.hpp:19
Definition: value.hpp:8
Definition: value.hpp:52
A generic, derived, value.
Definition: value.hpp:366
virtual T & get_value()=0
Calculate, if necessary, and return the value held by this object.
void update_value()
Updates the internal value.
Definition: value.hpp:55