Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:37

0001 #ifndef JETBASE_JETCONTAINER_H
0002 #define JETBASE_JETCONTAINER_H
0003 
0004 #include "Jet.h"
0005 
0006 #include <phool/PHObject.h>
0007 
0008 #include <cfloat>
0009 #include <cmath>
0010 #include <cstddef>  // for size_t
0011 #include <functional>
0012 #include <iostream>
0013 #include <limits>
0014 #include <map>
0015 #include <set>
0016 #include <vector>
0017 
0018 class Jet;
0019 class TClonesArray;
0020 // ---------------------------------------------------------------------------------------
0021 // JetContainer class -- used to fill, update, and access TClonesArray of jets
0022 // ---------------------------------------------------------------------------------------
0023 class JetContainer : public PHObject
0024 {
0025  public:
0026   JetContainer() = default;
0027   ~JetContainer() override = default;
0028   virtual void identify(std::ostream& /*-*/) const override;
0029   int isValid() const override { return 0; }
0030   PHObject* CloneMe() const override { return nullptr; }
0031   virtual TClonesArray* clone_data() const;
0032 
0033   // status of jet contents
0034   virtual bool empty() const { return true; }
0035   virtual size_t size() const { return 0; }
0036 
0037   // adding/access jets
0038   /* virtual Jet* current_jet() ; // points to most recently accessed jet */
0039   virtual Jet* add_jet() { return nullptr; };                                // Add a new jet to the TClonesArray and return the pointer
0040   virtual Jet* get_jet(unsigned int /*index*/) { return nullptr; };          // Get jet at loc. return nullptr is out of range
0041   virtual Jet* get_UncheckedAt(unsigned int /*index*/) { return nullptr; };  // Get get at location; no range checking
0042 
0043   // convenience shortcuts of get_{jet,UncheckedAt}
0044   virtual Jet* operator()(int /*index*/) { return nullptr; };  // synonym for get_get()
0045   virtual Jet* operator[](int /*index*/) { return nullptr; };  // get jet, don't check for length
0046 
0047   // ---------------------------------------------------------------------------
0048   // Legacy functions (copied from JetMap) used to record which functions are used.
0049   // These options are not actually consulted when the clustering is done in the
0050   // FastJetAlgo class; these are just informational.
0051   // ---------------------------------------------------------------------------
0052   virtual void set_algo(Jet::ALGO /*algo*/) { return; }
0053   virtual Jet::ALGO get_algo() const { return Jet::ALGO::NONE; }
0054 
0055   virtual void set_par(float) { return; }
0056   virtual float get_par() const { return std::numeric_limits<float>::quiet_NaN(); }
0057 
0058   virtual void set_jetpar_R(float) { return; }
0059   virtual float get_jetpar_R() const { return std::numeric_limits<float>::quiet_NaN(); }
0060 
0061   // ---------------------------------------------------------------------------
0062   //  Sources "src":
0063   // Keep a std::set of data listing the input sources
0064   // present in the jest
0065   // ---------------------------------------------------------------------------
0066   typedef std::set<Jet::SRC>::const_iterator ConstSrcIter;
0067   typedef std::set<Jet::SRC>::iterator SrcIter;
0068 
0069   virtual bool empty_src() const { return true; }
0070   virtual void insert_src(Jet::SRC /*src*/) { return; }
0071 
0072   virtual ConstSrcIter begin_src() const;
0073   virtual ConstSrcIter find_src(Jet::SRC src) const;
0074   virtual ConstSrcIter end_src() const;
0075 
0076   virtual SrcIter begin_src();
0077   virtual SrcIter find_src(Jet::SRC src);
0078   virtual SrcIter end_src();
0079 
0080   // ----------------------------------------------------------------------------------------
0081   //  Interface for adding, setting, and getting jet properties
0082   // ----------------------------------------------------------------------------------------
0083   // The optional properties in each Jet are stored in a vector of floats,
0084   // e.g. { Rg_value, mg_value, area, .... }
0085   // The JetContainer generates the jet and keeps a map of which properties in which location.
0086   // Default values in the Jet Properties are set to NAN
0087   // ----------------------------------------------------------------------------------------
0088 
0089   // Get and queary the map of indices of the vector<properties> in the jets
0090   virtual std::map<Jet::PROPERTY, Jet::PROPERTY /*really this is an index*/> property_indices() const { return {}; };
0091   virtual bool has_property(Jet::PROPERTY /*-*/) const { return false; };
0092   virtual size_t size_properties() const { return std::numeric_limits<unsigned int>::max(); };
0093   virtual size_t add_property(Jet::PROPERTY /**/) { return 0; };
0094   virtual size_t add_property(std::set<Jet::PROPERTY> /**/) { return 0; };
0095   virtual Jet::PROPERTY property_index(Jet::PROPERTY) { return static_cast<Jet::PROPERTY>(1000); };  // get the propery index
0096   virtual void print_property_types(std::ostream& /*os*/) const {};                                  // print the order of properties in jet
0097 
0098   virtual void print_jets(std::ostream& os = std::cout)
0099   {
0100     os << "";
0101     return;
0102   };  // print the order of properties in jet
0103 
0104   // ---------------------------------------------------------------------------------------
0105   //  Add ability for: ```for (auto jet : jet_container->iter_jets()) { ... }```
0106   // ---------------------------------------------------------------------------------------
0107   // Use:
0108   // ```
0109   //     for (jet : jet_containter->iter_jets()) {
0110   //     // jet will increment as Jet* through all jets
0111   //     ... }
0112   // ```
0113   // In the loop, current_jet in JetContainer will be updated, too. So, you can reference
0114   // members using the JetContainer, just as {get,set}_selected_property
0115   /* virtual IterJetTCA iter_jets() ; */
0116   virtual Jet::IterJetTCA begin();
0117   virtual Jet::IterJetTCA end();
0118   // ---------------------------------------------------------------------------------------
0119 
0120   virtual unsigned int get_index_single() const { return std::numeric_limits<unsigned int>::max(); };
0121   virtual std::vector<unsigned int> get_index_vec() const { return {}; };
0122 
0123   virtual void set_rho_median(float /**/){};
0124   virtual float get_rho_median() const { return std::numeric_limits<float>::quiet_NaN(); };
0125 
0126  private:
0127   ClassDefOverride(JetContainer, 1);
0128 };
0129 
0130 #endif /* JETBASE_JETCONTAINER_H */