Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Jetv2.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Jetv2.h
1 
9 #ifndef G4JET_JETV2_H
10 #define G4JET_JETV2_H
11 
12 #include "Jet.h"
13 
14 #include <cmath>
15 #include <cstddef> // for size_t
16 #include <iostream>
17 #include <map>
18 #include <array>
19 #include <utility> // for pair, make_pair
20 
21 class PHObject;
22 
26 class Jetv2 : public Jet
27 {
28  public:
29  Jetv2() = default;
30  Jetv2(unsigned int);
31  /* ~Jetv2() override = default; //{} */
32  /* Jetv2(const Jetv2&) = default; */
33  /* Jetv2(Jetv2&) = default; */
34  /* Jetv2& operator=(const Jetv2&) = default; */
35 
36  // method used to sort the consistuents of the jet -- to be used when generating the jets only
37  struct CompareSRC
38  {
39  bool operator()(const std::pair<Jet::SRC, int>& lhs, const unsigned int rhs)
40  {
41  return static_cast<unsigned int>(lhs.first) < rhs;
42  }
43  bool operator()(const unsigned int lhs, const std::pair<Jet::SRC, int>& rhs)
44  {
45  return lhs < static_cast<unsigned int>(rhs.first);
46  }
47  bool operator()(const std::pair<Jet::SRC, int>& lhs, const std::pair<Jet::SRC, int>& rhs)
48  {
49  return static_cast<unsigned int>(lhs.first) < static_cast<unsigned int>(rhs.first);
50  }
51  /* static void sort_comp_ids(Jetv2* jet); */
52  };
53 
54  // PHObject virtual overloads
55 
56  void identify(std::ostream& os = std::cout) const override;
57  void Reset() override;
58  int isValid() const override;
59  PHObject* CloneMe() const override;
60 
61  // jet info
62 
63  unsigned int get_id() const override { return _id; }
64  void set_id(unsigned int id) override { _id = id; }
65 
66  float get_px() const override { return _mom[0]; }
67  void set_px(float px) override { _mom[0] = px; }
68 
69  float get_py() const override { return _mom[1]; }
70  void set_py(float py) override { _mom[1] = py; }
71 
72  float get_pz() const override { return _mom[2]; }
73  void set_pz(float pz) override { _mom[2] = pz; }
74 
75  float get_e() const override { return _e; }
76  void set_e(float e) override { _e = e; }
77 
78  float get_p() const override;
79  float get_pt() const override;
80  float get_et() const override;
81  float get_eta() const override;
82  float get_phi() const override;
83  float get_mass() const override;
84  float get_mass2() const override;
85 
86  // Jet properties
87  void resize_properties(size_t size) override { _properties.resize(size, NAN); };
88  std::vector<float>& get_property_vec() override { return _properties; } // new in v2
89  size_t size_properties() const override { return _properties.size(); } // implemented in v1 and v2
90 
91  float get_property(Jet::PROPERTY index) const override { return _properties[static_cast<int>(index)]; };
92  inline void set_property(Jet::PROPERTY index, float value) override
93  { _properties[static_cast<int>(index)] = value; };
94 
95  // Jet components
96  size_t size_comp() const override { return _comp_ids.size(); }
97  void clear_comp() override { _comp_ids.clear(); }
98  void insert_comp(SRC iSRC, unsigned int compid) override;
99  void insert_comp(Jet::SRC, unsigned int compid, bool) override; //skips setting _is_sorted flag
100  void insert_comp(TYPE_comp_vec&) override;
101  void insert_comp(TYPE_comp_vec&, bool) override;
102  void set_comp_sort_flag(bool f=false) override {_is_sorted=f;};
103 
104  void print_comp(std::ostream& os = std::cout, bool single_line = false) override;
105  size_t num_comp(SRC iSRC = Jet::SRC::VOID) override;
106  std::vector<Jet::SRC> comp_src_vec() override;
107  std::map<Jet::SRC, size_t> comp_src_sizemap() override; // map of Jet::SRC to number of entries
108 
109  // FYI: ITER_comp_vec = vector<pair<Jet::SRC, unsigned int>>::iterator
110  ITER_comp_vec comp_begin() override { return _comp_ids.begin(); } // new in v2
111  ITER_comp_vec comp_begin(Jet::SRC) override; // new in v2
112  ITER_comp_vec comp_end() override { return _comp_ids.end(); } // new in v2
113  ITER_comp_vec comp_end(Jet::SRC) override; // new in v2
114  TYPE_comp_vec& get_comp_vec() override { return _comp_ids; }; // new in v2
115 
116  inline void Clear(Option_t* = nullptr) override { Reset(); }
117 
118  private:
120  unsigned int _id = ~0x0;
121  void ensure_sorted();
122  bool _is_sorted { false };
123 
125  std::array<float,3> _mom {{ NAN, NAN, NAN}} ;
126 
128  float _e = NAN;
129 
131  /* typ_comp_ids _comp_ids; */
132  std::vector<std::pair<Jet::SRC, unsigned int>> _comp_ids;
133 
134  std::vector<float> _properties{};
135 
136  bool empty_comp() const override;
137  size_t count_comp(SRC source ) const override;
138 
139  // only in v1 msg
140  void msg_dep_fn(const std::string& method_name) const;
141 
142  // functions deprecated in this Jet Version
143  bool has_property(Jet::PROPERTY /*prop_id*/) const override;
144  void print_property(std::ostream& ) const override;
145  ConstIter begin_comp() const override;
146  ConstIter lower_bound_comp(SRC source) const override;
147  ConstIter upper_bound_comp(SRC source) const override;
148  ConstIter find(Jet::SRC source) const override;
149  ConstIter end_comp() const override;
150 
151  Iter begin_comp() override;
152  Iter lower_bound_comp(SRC source) override;
153  Iter upper_bound_comp(SRC source) override;
154  Iter find(SRC source) override;
155  Iter end_comp() override;
156 
157  size_t erase_comp(Jet::SRC ) override;
158  void erase_comp(Iter /*iter*/) override;
159  void erase_comp(Iter /*first*/, Iter /*last*/) override;
160 
161 
162 
164 };
165 
166 #endif // G4JET_JETV2_H