Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Jet.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Jet.h
1 #ifndef JETBASE_JET_H
2 #define JETBASE_JET_H
3 
4 // The constituents between Jetv1 and Jetv2 are updated from
5 // typedef multimap<Jet::SRC, unsigned int> typ_comp_ids;
6 // to
7 // typedef vector<pair<Jet::SRC, unsigned int>> TYPE_comp_vec;
8 //
9 //
10 // Functions deprecated between v1 and above
11 // v1:
12 // virtual bool has_property(Jet::PROPERTY /*prop_id*/) const
13 // virtual float get_property(Jet::PROPERTY /*prop_id*/) const
14 // virtual void set_property(Jet::PROPERTY /*prop_id*/, float /*value*/)
15 // virtual void print_property(std::ostream & /*os*/) const
16 // virtual bool empty_comp() const
17 // virtual size_t size_comp() const
18 // virtual size_t count_comp(Jet::SRC /*source*/) const
19 // virtual size_t erase_comp(Jet::SRC)
20 // virtual void erase_comp(Iter /*iter*/)
21 // virtual void erase_comp(Iter /*first*/, Iter /*last*/)
22 // virtual ConstIter begin_comp() const;
23 // virtual ConstIter lower_bound_comp(Jet::SRC source) const;
24 // virtual ConstIter upper_bound_comp(Jet::SRC source) const;
25 // virtual ConstIter find(Jet::SRC source) const;
26 // virtual ConstIter end_comp() const;
27 // virtual Iter begin_comp();
28 // virtual Iter lower_bound_comp(Jet::SRC source);
29 // virtual Iter upper_bound_comp(Jet::SRC source);
30 // virtual Iter find(Jet::SRC source);
31 // virtual Iter end_comp();
32 //
33 //
34 // v2:
35 // virtual size_t size_properties()
36 // virtual inline float get_prop_by_index(unsigned int /*index*/) const
37 // virtual inline void set_prop_by_index(unsigned int /*index*/, float /*value*/)
38 // virtual size_t num_comp(SRC = Jet::SRC::VOID /**/)
39 // virtual std::map<Jet::SRC, size_t> comp_src_sizemap()
40 //
41 // typedef std::pair<Jet::SRC, unsigned int> TYPE_comp;
42 // typedef std::vector<TYPE_comp> TYPE_comp_vec;
43 // typedef TYPE_comp_vec::iterator ITER_comp_vec;
44 //
45 // virtual ITER_comp_vec comp_begin();
46 // virtual ITER_comp_vec comp_begin(Jet::SRC);
47 // virtual ITER_comp_vec comp_end();
48 // virtual ITER_comp_vec comp_end(Jet::SRC);
49 //
50 // virtual TYPE_comp_vec& get_comp_vec();
51 
52 #include <phool/PHObject.h>
53 
54 #include <cmath>
55 #include <cstddef> // for size_t
56 #include <iostream>
57 #include <map>
58 
59 class TClonesArray;
60 
61 class Jet : public PHObject
62 {
63  public:
64  // enums can be extended with new values, but values not altered
65 
66  enum ALGO
67  {
68  NONE = 0,
69  ANTIKT = 1,
70  KT = 2,
72  };
73 
74  enum SRC
75  {
76  VOID = 0,
77  PARTICLE = 1,
78  TRACK = 2,
89  CEMC_TOWER_RETOWER = 13, /* needed for HI jet reco */
92  HCALOUT_TOWER_SUB1 = 16, /* needed for HI jet reco */
95  HCALOUT_TOWER_SUB1CS = 19, /* needed for CS subtraction w/ HI jet reco */
96  HEPMC_IMPORT = 20, /*Direct import HEPMC containers, such as sHijing HIJFRG truth jets loaded by JetHepMCLoader*/
97  HCAL_TOPO_CLUSTER = 21, /* I+HOCal 3-D topoCluster input */
98  ECAL_TOPO_CLUSTER = 22, /* EMCal 3-D topoCluster input */
99  EEMC_TOWER = 23,
104  CEMC_TOWERINFO_RETOWER = 28, /* needed for HI jet reco */
107  HCALOUT_TOWERINFO_SUB1 = 31, /* needed for HI jet reco */
108  CEMC_TOWERINFO_EMBED = 32, /* needed for embedding */
114  JET_PROBE = 38,
115  };
116 
117  enum PROPERTY
118  {
119 
122 
125 
129 
133 
135  prop_zg = 5,
136  prop_Rg = 6,
137  prop_mu = 7,
142 
144  prop_area = 11,
146  };
147 
148  Jet() {}
149  ~Jet() override {}
150 
151  void identify(std::ostream& os = std::cout) const override;
152  int isValid() const override { return 0; }
153  PHObject* CloneMe() const override { return nullptr; }
154 
155  // jet info ------------------------------------------------------------------
156 
157  virtual unsigned int get_id() const { return 0xFFFFFFFF; }
158  virtual void set_id(unsigned int) { return; }
159 
160  virtual float get_px() const { return NAN; }
161  virtual void set_px(float) { return; }
162 
163  virtual float get_py() const { return NAN; }
164  virtual void set_py(float) { return; }
165 
166  virtual float get_pz() const { return NAN; }
167  virtual void set_pz(float) { return; }
168 
169  virtual float get_e() const { return NAN; }
170  virtual void set_e(float) { return; }
171 
172  virtual float get_p() const { return NAN; }
173  virtual float get_pt() const { return NAN; }
174  virtual float get_et() const { return NAN; }
175  virtual float get_eta() const { return NAN; }
176  virtual float get_phi() const { return NAN; }
177  virtual float get_mass() const { return NAN; }
178  virtual float get_mass2() const { return NAN; }
179 
180  // --------------------------------------------------------------------------
181  // Functions for jet properties (always float values)
182  // --------------------------------------------------------------------------
183  // In both Jetv1 and Jetv2
184  virtual float get_property(Jet::PROPERTY /*prop_id*/) const { return NAN; }; // in Jetv2 really uses the Jet::PROPERTY as an index for a vector
185  virtual void set_property(Jet::PROPERTY /*prop_id*/, float /*value*/) {}; // in Jetv2 really uses the Jet::PROPERTY as an index for a vector
186  virtual size_t size_properties() const { return 0; };
187 
188  // new with Jetv2
189  virtual void resize_properties(size_t ) { };
190  virtual std::vector<float>& get_property_vec();
191  //virtual inline float get_prop_by_index(unsigned int /*index*/) const { return NAN; }
192  //virtual inline void set_prop_by_index(unsigned int /*index*/, float /*value*/) { return; }
193 
194  // deprecated by Jetv2
195  virtual bool has_property(Jet::PROPERTY /*prop_id*/) const { return false; };
196  virtual void print_property(std::ostream& /*os*/) const {};
197  //----------------------------------------------------------------------------------
198 
199  // some types
200  typedef std::pair<Jet::SRC, unsigned int> TYPE_comp;
201  typedef std::vector<TYPE_comp> TYPE_comp_vec;
202  typedef TYPE_comp_vec::iterator ITER_comp_vec;
203 
204  // --------------------------------------------------------------------------
205  // Functions for jet components
206  // in all Jet versions
207  virtual void clear_comp() {}
208  virtual void insert_comp(Jet::SRC, unsigned int) {}
209  virtual void insert_comp(Jet::SRC, unsigned int, bool) {} //v2 only
210  virtual void insert_comp(TYPE_comp_vec&) {} //v2 only
211  virtual void insert_comp(TYPE_comp_vec&, bool) {} //v2 only
212 
213  virtual size_t size_comp() const { return 0; };
214  // new with Jetv2
215  virtual size_t num_comp(SRC = Jet::SRC::VOID ) { return 0; };
216  virtual void print_comp(std::ostream& , bool ) {};
217  virtual std::vector<Jet::SRC> comp_src_vec() { return {}; };
218  virtual std::map<Jet::SRC, size_t> comp_src_sizemap() { return {}; };
219  virtual void set_comp_sort_flag(bool=false) {};
220 //
221 //
222  virtual ITER_comp_vec comp_begin();
224  virtual ITER_comp_vec comp_end();
226 //
227  virtual TYPE_comp_vec& get_comp_vec();
228  //-- deprecated with Jetv2 ---------------------------------------------------------
229  virtual bool empty_comp() const { return true; }
230  virtual size_t count_comp(Jet::SRC /*source*/) const { return 0; };
231 //
232  typedef std::multimap<Jet::SRC, unsigned int> typ_comp_ids;
233  typedef typ_comp_ids::const_iterator ConstIter;
234  typedef typ_comp_ids::iterator Iter;
235 //
236  virtual ConstIter begin_comp() const;
237  virtual ConstIter lower_bound_comp(Jet::SRC source) const;
238  virtual ConstIter upper_bound_comp(Jet::SRC source) const;
239  virtual ConstIter find(Jet::SRC source) const;
240  virtual ConstIter end_comp() const;
241 //
242  virtual Iter begin_comp();
245  virtual Iter find(Jet::SRC source);
246  virtual Iter end_comp();
247 
248  virtual size_t erase_comp(Jet::SRC) { return 0; }
249  virtual void erase_comp(Iter /*iter*/) { return; }
250  virtual void erase_comp(Iter /*first*/, Iter /*last*/) { return; }
251  //----------------------------------------------------------------------------------
252  // structure to iterate over the jets in a TClonesArray in the JetContainer
253  struct IterJetTCA
254  {
255  TClonesArray* tca{nullptr};
256  int index{0};
257  int size;
258 
259  IterJetTCA(TClonesArray* _tca);
260  void operator++() { ++index; };
261  Jet* operator*();
262  bool operator!=(const IterJetTCA& /*rhs*/) { return index != size; };
263  };
264 
265  ClassDefOverride(Jet, 1);
266 };
267 
268 #endif