Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetContainer.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetContainer.h
1 #ifndef JETBASE_JETCONTAINER_H
2 #define JETBASE_JETCONTAINER_H
3 
4 #include "Jet.h"
5 
6 #include <phool/PHObject.h>
7 
8 #include <TClonesArray.h>
9 
10 #include <cmath>
11 #include <cfloat>
12 #include <cstddef> // for size_t
13 #include <iostream>
14 #include <map>
15 #include <vector>
16 #include <functional>
17 #include <set>
18 #include <climits>
19 
20 class Jet;
21 
22 // ---------------------------------------------------------------------------------------
23 // JetContainer class -- used to fill, update, and access TClonesArray of jets
24 // ---------------------------------------------------------------------------------------
25 class JetContainer : public PHObject
26 {
27 public:
28  JetContainer() = default;
29  ~JetContainer() override = default;
30  virtual void identify(std::ostream&/*-*/) const override;
31  int isValid() const override { return 0; }
32  PHObject* CloneMe() const override { return nullptr; }
33  virtual TClonesArray* clone_data() const;
34 
35  // status of jet contents
36  virtual bool empty() const { return true; }
37  virtual size_t size() const { return 0; }
38 
39  // adding/access jets
40  /* virtual Jet* current_jet() ; // points to most recently accessed jet */
41  virtual Jet* add_jet() { return nullptr; }; // Add a new jet to the TClonesArray and return the pointer
42  virtual Jet* get_jet(unsigned int /*index*/) { return nullptr; }; // Get jet at loc. return nullptr is out of range
43  virtual Jet* get_UncheckedAt(unsigned int /*index*/) { return nullptr; }; // Get get at location; no range checking
44 
45  // convenience shortcuts of get_{jet,UncheckedAt}
46  virtual Jet* operator()(int /*index*/) { return nullptr; }; // synonym for get_get()
47  virtual Jet* operator[](int /*index*/) { return nullptr; }; // get jet, don't check for length
48 
49  // ---------------------------------------------------------------------------
50  // Legacy functions (copied from JetMap) used to record which functions are used.
51  // These options are not actually consulted when the clustering is done in the
52  // FastJetAlgo class; these are just informational.
53  // ---------------------------------------------------------------------------
54  virtual void set_algo(Jet::ALGO /*algo*/) { return; }
55  virtual Jet::ALGO get_algo() const { return Jet::ALGO::NONE; }
56 
57  virtual void set_par(float) { return; }
58  virtual float get_par() const { return NAN; }
59 
60  virtual void set_jetpar_R(float) { return; }
61  virtual float get_jetpar_R() const { return NAN; }
62 
63  // ---------------------------------------------------------------------------
64  // Sources "src":
65  // Keep a std::set of data listing the input sources
66  // present in the jest
67  // ---------------------------------------------------------------------------
68  typedef std::set<Jet::SRC>::const_iterator ConstSrcIter;
69  typedef std::set<Jet::SRC>::iterator SrcIter;
70 
71  virtual bool empty_src() const { return true; }
72  virtual void insert_src(Jet::SRC /*src*/) { return; }
73 
74  virtual ConstSrcIter begin_src() const;
75  virtual ConstSrcIter find_src(Jet::SRC src) const;
76  virtual ConstSrcIter end_src() const;
77 
78  virtual SrcIter begin_src();
79  virtual SrcIter find_src(Jet::SRC src);
80  virtual SrcIter end_src();
81 
82  // ----------------------------------------------------------------------------------------
83  // Interface for adding, setting, and getting jet properties
84  // ----------------------------------------------------------------------------------------
85  // The optional properties in each Jet are stored in a vector of floats,
86  // e.g. { Rg_value, mg_value, area, .... }
87  // The JetContainer generates the jet and keeps a map of which properties in which location.
88  // Default values in the Jet Properties are set to NAN
89  // ----------------------------------------------------------------------------------------
90 
91  // Get and queary the map of indices of the vector<properties> in the jets
92  virtual std::map<Jet::PROPERTY, Jet::PROPERTY /*really this is an index*/> property_indices() const { return {}; };
93  virtual bool has_property(Jet::PROPERTY /*-*/) const { return false; };
94  virtual size_t size_properties() const { return UINT_MAX; };
95  virtual size_t add_property(Jet::PROPERTY) { return 0; } ;
96  virtual size_t add_property(std::set<Jet::PROPERTY> ) { return 0; };
97  virtual Jet::PROPERTY property_index(Jet::PROPERTY) { return static_cast<Jet::PROPERTY>(1000); }; // get the propery index
98  virtual void print_property_types(std::ostream& /*os*/) const {}; // print the order of properties in jet
99 
100  virtual void print_jets(std::ostream& os=std::cout) { os<<""; return; }; // print the order of properties in jet
101 
102  // ---------------------------------------------------------------------------------------
103  // Add ability for: ```for (auto jet : jet_container->iter_jets()) { ... }```
104  // ---------------------------------------------------------------------------------------
105  // Use:
106  // ```
107  // for (jet : jet_containter->iter_jets()) {
108  // // jet will increment as Jet* through all jets
109  // ... }
110  // ```
111  // In the loop, current_jet in JetContainer will be updated, too. So, you can reference
112  // members using the JetContainer, just as {get,set}_selected_property
113  /* virtual IterJetTCA iter_jets() ; */
114  virtual Jet::IterJetTCA begin() ;
115  virtual Jet::IterJetTCA end() ;
116  // ---------------------------------------------------------------------------------------
117 
118  virtual unsigned int get_index_single() const { return UINT_MAX; };
119  virtual std::vector<unsigned int> get_index_vec() const { return {}; };
120 
121  virtual void set_rho_median(float ) {};
122  virtual float get_rho_median() const { return NAN; };
123 
124  private:
126 };
127 
128 
129 #endif /* JETBASE_JETCONTAINER_H */