Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef JETBASE_JET_H
0002 #define JETBASE_JET_H
0003 
0004 // The constituents between Jetv1 and Jetv2 are updated from
0005 //    typedef multimap<Jet::SRC, unsigned int> typ_comp_ids;
0006 //  to
0007 //    typedef vector<pair<Jet::SRC, unsigned int>> TYPE_comp_vec;
0008 //
0009 //
0010 // Functions deprecated between v1 and above
0011 //   v1:
0012 //  virtual bool   has_property(Jet::PROPERTY  /*prop_id*/) const
0013 //  virtual float  get_property(Jet::PROPERTY  /*prop_id*/) const
0014 //  virtual void   set_property(Jet::PROPERTY  /*prop_id*/, float   /*value*/)
0015 //  virtual void   print_property(std::ostream & /*os*/) const
0016 //  virtual bool   empty_comp() const
0017 //  virtual size_t size_comp()  const
0018 //  virtual size_t count_comp(Jet::SRC /*source*/) const
0019 //  virtual size_t erase_comp(Jet::SRC)
0020 //  virtual void   erase_comp(Iter /*iter*/)
0021 //  virtual void   erase_comp(Iter /*first*/, Iter /*last*/)
0022 //  virtual ConstIter begin_comp() const;
0023 //  virtual ConstIter lower_bound_comp(Jet::SRC source) const;
0024 //  virtual ConstIter upper_bound_comp(Jet::SRC source) const;
0025 //  virtual ConstIter find(Jet::SRC source) const;
0026 //  virtual ConstIter end_comp() const;
0027 //   virtual Iter begin_comp();
0028 //   virtual Iter lower_bound_comp(Jet::SRC source);
0029 //   virtual Iter upper_bound_comp(Jet::SRC source);
0030 //   virtual Iter find(Jet::SRC source);
0031 //   virtual Iter end_comp();
0032 //
0033 //
0034 //  v2:
0035 //  virtual size_t        size_properties()
0036 //  virtual inline float  get_prop_by_index(unsigned int /*index*/) const
0037 //  virtual inline void   set_prop_by_index(unsigned int /*index*/, float /*value*/)
0038 //  virtual size_t        num_comp(SRC = Jet::SRC::VOID /**/)
0039 //  virtual std::map<Jet::SRC, size_t> comp_src_sizemap()
0040 //
0041 //  typedef std::pair<Jet::SRC, unsigned int> TYPE_comp;
0042 //  typedef std::vector<TYPE_comp> TYPE_comp_vec;
0043 //  typedef TYPE_comp_vec::iterator ITER_comp_vec;
0044 //
0045 //  virtual ITER_comp_vec comp_begin();
0046 //  virtual ITER_comp_vec comp_begin(Jet::SRC);
0047 //  virtual ITER_comp_vec comp_end();
0048 //  virtual ITER_comp_vec comp_end(Jet::SRC);
0049 //
0050 //  virtual TYPE_comp_vec& get_comp_vec();
0051 
0052 #include <phool/PHObject.h>
0053 
0054 #include <cstddef>  // for size_t
0055 #include <iostream>
0056 #include <limits>
0057 #include <map>
0058 
0059 class TClonesArray;
0060 
0061 class Jet : public PHObject
0062 {
0063  public:
0064   // enums can be extended with new values, but values not altered
0065 
0066   enum ALGO
0067   {
0068     NONE = 0,
0069     ANTIKT = 1,
0070     KT = 2,
0071     CAMBRIDGE = 3
0072   };
0073 
0074   enum SRC
0075   {
0076     VOID = 0,
0077     PARTICLE = 1,
0078     TRACK = 2,
0079     CEMC_TOWER = 3,
0080     CEMC_CLUSTER = 4,
0081     HCALIN_TOWER = 5,
0082     HCALIN_CLUSTER = 6,
0083     HCALOUT_TOWER = 7,
0084     HCALOUT_CLUSTER = 8,
0085     FEMC_TOWER = 9,
0086     FEMC_CLUSTER = 10,
0087     FHCAL_TOWER = 11,
0088     FHCAL_CLUSTER = 12,
0089     CEMC_TOWER_RETOWER = 13, /* needed for HI jet reco */
0090     CEMC_TOWER_SUB1 = 14,
0091     HCALIN_TOWER_SUB1 = 15,
0092     HCALOUT_TOWER_SUB1 = 16, /* needed for HI jet reco */
0093     CEMC_TOWER_SUB1CS = 17,
0094     HCALIN_TOWER_SUB1CS = 18,
0095     HCALOUT_TOWER_SUB1CS = 19, /* needed for CS subtraction w/ HI jet reco */
0096     HEPMC_IMPORT = 20,         /*Direct import HEPMC containers, such as sHijing HIJFRG truth jets loaded by JetHepMCLoader*/
0097     HCAL_TOPO_CLUSTER = 21,    /* I+HOCal 3-D topoCluster input */
0098     ECAL_TOPO_CLUSTER = 22,    /* EMCal 3-D topoCluster input */
0099     EEMC_TOWER = 23,
0100     EEMC_CLUSTER = 24,
0101     CEMC_TOWERINFO = 25,
0102     HCALIN_TOWERINFO = 26,
0103     HCALOUT_TOWERINFO = 27,
0104     CEMC_TOWERINFO_RETOWER = 28, /* needed for HI jet reco */
0105     CEMC_TOWERINFO_SUB1 = 29,
0106     HCALIN_TOWERINFO_SUB1 = 30,
0107     HCALOUT_TOWERINFO_SUB1 = 31, /* needed for HI jet reco */
0108     CEMC_TOWERINFO_EMBED = 32,   /* needed for embedding */
0109     CEMC_TOWERINFO_SIM = 33,
0110     HCALIN_TOWERINFO_EMBED = 34,
0111     HCALIN_TOWERINFO_SIM = 35,
0112     HCALOUT_TOWERINFO_EMBED = 36,
0113     HCALOUT_TOWERINFO_SIM = 37,
0114     JET_PROBE = 38,
0115     ECAL_HCAL_TOPO_CLUSTER = 39,    /* EMCal+IHCal+OHCal 3-D topoCluster input */
0116     CHARGED_PARTICLE = 40  /* for truth-level track jets */
0117   };
0118 
0119   enum PROPERTY
0120   {
0121 
0122     //! jet charge
0123     prop_JetCharge = 1,
0124 
0125     //! b-jet fraction
0126     prop_BFrac = 2,
0127 
0128     //! discriminator D = max tower E / average E , used to identify
0129     //! seeds in 1st iteration of UE determination
0130     prop_SeedD = 3,
0131 
0132     //! used to tag as seed jet in 1st or 2nd iteration of UE
0133     //! determination
0134     prop_SeedItr = 4,
0135 
0136     //! SoftDrop quantities
0137     prop_zg = 5,
0138     prop_Rg = 6,
0139     prop_mu = 7,
0140     //! photon tag property
0141     prop_gamma = 8,
0142     prop_JetHadronFlavor = 9,
0143     prop_JetHadronZT = 10,
0144 
0145     //! jet area
0146     prop_area = 11,
0147     no_property = 12,
0148   };
0149 
0150   Jet() {}
0151   ~Jet() override {}
0152 
0153   void identify(std::ostream& os = std::cout) const override;
0154   int isValid() const override { return 0; }
0155   PHObject* CloneMe() const override { return nullptr; }
0156 
0157   // jet info ------------------------------------------------------------------
0158 
0159   virtual unsigned int get_id() const { return 0xFFFFFFFF; }
0160   virtual void set_id(unsigned int) { return; }
0161 
0162   virtual float get_px() const { return std::numeric_limits<float>::quiet_NaN(); }
0163   virtual void set_px(float) { return; }
0164 
0165   virtual float get_py() const { return std::numeric_limits<float>::quiet_NaN(); }
0166   virtual void set_py(float) { return; }
0167 
0168   virtual float get_pz() const { return std::numeric_limits<float>::quiet_NaN(); }
0169   virtual void set_pz(float) { return; }
0170 
0171   virtual float get_e() const { return std::numeric_limits<float>::quiet_NaN(); }
0172   virtual void set_e(float) { return; }
0173 
0174   virtual float get_p() const { return std::numeric_limits<float>::quiet_NaN(); }
0175   virtual float get_pt() const { return std::numeric_limits<float>::quiet_NaN(); }
0176   virtual float get_et() const { return std::numeric_limits<float>::quiet_NaN(); }
0177   virtual float get_eta() const { return std::numeric_limits<float>::quiet_NaN(); }
0178   virtual float get_phi() const { return std::numeric_limits<float>::quiet_NaN(); }
0179   virtual float get_mass() const { return std::numeric_limits<float>::quiet_NaN(); }
0180   virtual float get_mass2() const { return std::numeric_limits<float>::quiet_NaN(); }
0181 
0182   // --------------------------------------------------------------------------
0183   // Functions for jet properties (always float values)
0184   // --------------------------------------------------------------------------
0185   // In both Jetv1 and Jetv2
0186   virtual float get_property(Jet::PROPERTY /*prop_id*/) const { return std::numeric_limits<float>::quiet_NaN(); };  // in Jetv2 really uses the Jet::PROPERTY as an index for a vector
0187   virtual void set_property(Jet::PROPERTY /*prop_id*/, float /*value*/){};      // in Jetv2 really uses the Jet::PROPERTY as an index for a vector
0188   virtual size_t size_properties() const { return 0; };
0189 
0190   //    new with Jetv2
0191   virtual void resize_properties(size_t /**/){};
0192   virtual std::vector<float>& get_property_vec();
0193   // virtual inline float get_prop_by_index(unsigned int /*index*/) const { return std::numeric_limits<float>::quiet_NaN(); }
0194   // virtual inline void set_prop_by_index(unsigned int /*index*/, float /*value*/) { return; }
0195 
0196   //   deprecated by Jetv2
0197   virtual bool has_property(Jet::PROPERTY /*prop_id*/) const { return false; };
0198   virtual void print_property(std::ostream& /*os*/) const {};
0199   virtual int get_isCalib() {return 0;};
0200   virtual void set_isCalib(int) {};
0201   //----------------------------------------------------------------------------------
0202 
0203   // some types
0204   typedef std::pair<Jet::SRC, unsigned int> TYPE_comp;
0205   typedef std::vector<TYPE_comp> TYPE_comp_vec;
0206   typedef TYPE_comp_vec::iterator ITER_comp_vec;
0207 
0208   // --------------------------------------------------------------------------
0209   // Functions for jet components
0210   //    in all Jet versions
0211   virtual void clear_comp() {}
0212   virtual void insert_comp(Jet::SRC, unsigned int) {}
0213   virtual void insert_comp(Jet::SRC, unsigned int, bool) {}    // v2 only
0214   virtual void insert_comp(TYPE_comp_vec& /**/) {}             // v2 only
0215   virtual void insert_comp(TYPE_comp_vec& /**/, bool /**/) {}  // v2 only
0216 
0217   virtual size_t size_comp() const { return 0; };
0218   //    new with Jetv2
0219   virtual size_t num_comp(SRC = Jet::SRC::VOID /**/) { return 0; };
0220   virtual void print_comp(std::ostream& /**/, bool /**/){};
0221   virtual std::vector<Jet::SRC> comp_src_vec() { return {}; };
0222   virtual std::map<Jet::SRC, size_t> comp_src_sizemap() { return {}; };
0223   virtual void set_comp_sort_flag(bool = false){};
0224   //
0225   //
0226   virtual ITER_comp_vec comp_begin();
0227   virtual ITER_comp_vec comp_begin(Jet::SRC);
0228   virtual ITER_comp_vec comp_end();
0229   virtual ITER_comp_vec comp_end(Jet::SRC);
0230   //
0231   virtual TYPE_comp_vec& get_comp_vec();
0232   //-- deprecated with Jetv2 ---------------------------------------------------------
0233   virtual bool empty_comp() const { return true; }
0234   virtual size_t count_comp(Jet::SRC /*source*/) const { return 0; };
0235   //
0236   typedef std::multimap<Jet::SRC, unsigned int> typ_comp_ids;
0237   typedef typ_comp_ids::const_iterator ConstIter;
0238   typedef typ_comp_ids::iterator Iter;
0239   //
0240   virtual ConstIter begin_comp() const;
0241   virtual ConstIter lower_bound_comp(Jet::SRC source) const;
0242   virtual ConstIter upper_bound_comp(Jet::SRC source) const;
0243   virtual ConstIter find(Jet::SRC source) const;
0244   virtual ConstIter end_comp() const;
0245   //
0246   virtual Iter begin_comp();
0247   virtual Iter lower_bound_comp(Jet::SRC source);
0248   virtual Iter upper_bound_comp(Jet::SRC source);
0249   virtual Iter find(Jet::SRC source);
0250   virtual Iter end_comp();
0251 
0252   virtual size_t erase_comp(Jet::SRC) { return 0; }
0253   virtual void erase_comp(Iter /*iter*/) { return; }
0254   virtual void erase_comp(Iter /*first*/, Iter /*last*/) { return; }
0255   //----------------------------------------------------------------------------------
0256   // structure to iterate over the jets in a TClonesArray in the JetContainer
0257   struct IterJetTCA
0258   {
0259     TClonesArray* tca{nullptr};
0260     int index{0};
0261     int size;
0262 
0263     IterJetTCA(TClonesArray* _tca);
0264     void operator++() { ++index; };
0265     Jet* operator*() const;
0266     bool operator!=(const IterJetTCA& /*rhs*/) { return index != size; };
0267   };
0268 
0269   ClassDefOverride(Jet, 1);
0270 };
0271 
0272 #endif