value.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef root_value_hpp
  2. #define root_value_hpp
  3. #include "value.hpp"
  4. #include "TLorentzVector.h"
  5. namespace fv::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. void verify_integrity(){
  16. if (pt == nullptr)
  17. CRITICAL("LorentzVector " << this->get_name() << " created with invalid pt", -1);
  18. if (eta == nullptr)
  19. CRITICAL("LorentzVector " << this->get_name() << " created with invalid eta", -1);
  20. if (phi == nullptr)
  21. CRITICAL("LorentzVector " << this->get_name() << " created with invalid phi", -1);
  22. if (m == nullptr)
  23. CRITICAL("LorentzVector " << this->get_name() << " created with invalid mass", -1);
  24. }
  25. public:
  26. LorentzVector(const std::string& name,
  27. Value<double>* pt,
  28. Value<double>* eta,
  29. Value<double>* phi,
  30. Value<double>* m)
  31. :DerivedValue<TLorentzVector>(name),
  32. pt(pt), eta(eta),
  33. phi(phi), m(m) { }
  34. LorentzVector(const std::string& name,
  35. const std::string &pt_label,
  36. const std::string &eta_label,
  37. const std::string &phi_label,
  38. const std::string &m_label)
  39. :LorentzVector(name,
  40. dynamic_cast<Value<double>*>(GenValue::get_value(pt_label)),
  41. dynamic_cast<Value<double>*>(GenValue::get_value(eta_label)),
  42. dynamic_cast<Value<double>*>(GenValue::get_value(phi_label)),
  43. dynamic_cast<Value<double>*>(GenValue::get_value(m_label))){ }
  44. };
  45. class LorentzVectorEnergy : public DerivedValue<double>{
  46. protected:
  47. Value<TLorentzVector>* vector;
  48. void update_value(){
  49. value = vector->get_value().E();
  50. }
  51. void verify_integrity(){
  52. if (vector == nullptr)
  53. CRITICAL("LorentzVectorEnergy " << this->get_name() << " created with invalid vector", -1);
  54. }
  55. public:
  56. LorentzVectorEnergy(const std::string& name, Value<TLorentzVector>* vector)
  57. :DerivedValue<double>(name),
  58. vector(vector){ }
  59. LorentzVectorEnergy(const std::string& name, const std::string& vector_label)
  60. :LorentzVectorEnergy(name,
  61. dynamic_cast<Value<TLorentzVector>*>(GenValue::get_value(vector_label))){ }
  62. };
  63. }
  64. #endif // root_value_hpp