value.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef root_value_hpp
  2. #define root_value_hpp
  3. #include "value.hpp"
  4. #include "TLorentzVector.h"
  5. namespace filval::root{
  6. class LorentzVector : public DerivedValue<TLorentzVector>{
  7. protected:
  8. Value<double> *pt;
  9. Value<double> *eta;
  10. Value<double> *phi;
  11. Value<double> *m;
  12. void update_value(){
  13. value.SetPtEtaPhiM(pt->get_value(), eta->get_value(), phi->get_value(), m->get_value());
  14. }
  15. public:
  16. LorentzVector(Value<double>* pt,
  17. Value<double>* eta,
  18. Value<double>* phi,
  19. Value<double>* m)
  20. :pt(pt), eta(eta),
  21. phi(phi), m(m) { }
  22. LorentzVector(ValueSet *values,
  23. const std::string &pt_label,
  24. const std::string &eta_label,
  25. const std::string &phi_label,
  26. const std::string &m_label)
  27. :LorentzVector(dynamic_cast<Value<double>*>(values->at(pt_label)),
  28. dynamic_cast<Value<double>*>(values->at(eta_label)),
  29. dynamic_cast<Value<double>*>(values->at(phi_label)),
  30. dynamic_cast<Value<double>*>(values->at(m_label))){ }
  31. };
  32. class LorentzVectorEnergy : public DerivedValue<double>{
  33. protected:
  34. Value<TLorentzVector>* vector;
  35. void update_value(){
  36. value = vector->get_value().E();
  37. }
  38. public:
  39. LorentzVectorEnergy(Value<TLorentzVector>* vector)
  40. :vector(vector){ }
  41. LorentzVectorEnergy(ValueSet *values, const std::string& vector_label)
  42. :LorentzVectorEnergy(dynamic_cast<Value<TLorentzVector>*>(values->at(vector_label))){ }
  43. };
  44. }
  45. #endif // root_value_hpp