Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:16:56

0001 #ifndef CALOBASE_RAWCLUSTER_H
0002 #define CALOBASE_RAWCLUSTER_H
0003 
0004 #include "RawClusterDefs.h"
0005 #include "RawTowerDefs.h"
0006 
0007 #include <phool/PHObject.h>
0008 #include <phool/phool.h>
0009 
0010 #include <CLHEP/Vector/ThreeVector.h>
0011 
0012 #include <cstddef>
0013 #include <iostream>
0014 #include <limits>
0015 #include <map>
0016 #include <string>  // for string
0017 #include <type_traits>
0018 #include <utility>
0019 
0020 class RawCluster : public PHObject
0021 {
0022  public:
0023   typedef std::map<RawTowerDefs::keytype, float> TowerMap;
0024   typedef TowerMap::iterator TowerIterator;
0025   typedef TowerMap::const_iterator TowerConstIterator;
0026   typedef std::pair<TowerIterator, TowerIterator> TowerRange;
0027   typedef std::pair<TowerConstIterator, TowerConstIterator> TowerConstRange;
0028 
0029   ~RawCluster() override {}
0030   void Reset() override { PHOOL_VIRTUAL_WARNING; }
0031 
0032   PHObject* CloneMe() const override { return nullptr; }
0033 
0034   int isValid() const override
0035   {
0036     PHOOL_VIRTUAL_WARNING;
0037     return 0;
0038   }
0039   void identify(std::ostream& /*os*/ = std::cout) const override { PHOOL_VIRTUAL_WARNING; }
0040   /** @defgroup getters
0041    *  @{
0042    */
0043   //! cluster ID
0044   virtual RawClusterDefs::keytype get_id() const
0045   {
0046     PHOOL_VIRTUAL_WARN("get_id()");
0047     return 0;
0048   }
0049   //! total energy
0050   virtual float get_energy() const
0051   {
0052     PHOOL_VIRTUAL_WARN("get_energy()");
0053     return std::numeric_limits<float>::signaling_NaN();
0054   }
0055   //! Tower operations
0056   virtual size_t getNTowers() const
0057   {
0058     PHOOL_VIRTUAL_WARNING;
0059     return 0;
0060   }
0061   virtual TowerConstRange get_towers() const
0062   {
0063     PHOOL_VIRTUAL_WARN("get_towers()");
0064     static TowerMap dummy;
0065     return make_pair(dummy.begin(), dummy.end());
0066   }
0067   //! return tower map for c++11 range-based for-loop
0068   virtual const TowerMap& get_towermap() const
0069   {
0070     PHOOL_VIRTUAL_WARN("get_towers()");
0071     static TowerMap dummy;
0072     return dummy;
0073   }
0074 
0075   virtual CLHEP::Hep3Vector get_position() const
0076   {
0077     PHOOL_VIRTUAL_WARN("get_position()");
0078     return CLHEP::Hep3Vector(std::numeric_limits<float>::signaling_NaN(), std::numeric_limits<float>::signaling_NaN(), std::numeric_limits<float>::signaling_NaN());
0079   }
0080   //
0081   //!  access to intrinsic cylindrical coordinate system
0082   virtual float get_phi() const
0083   {
0084     PHOOL_VIRTUAL_WARN("get_phi()");
0085     return std::numeric_limits<float>::signaling_NaN();
0086   }
0087   virtual float get_r() const
0088   {
0089     PHOOL_VIRTUAL_WARN("get_r()");
0090     return std::numeric_limits<float>::signaling_NaN();
0091   }
0092   virtual float get_z() const
0093   {
0094     PHOOL_VIRTUAL_WARN("get_z()");
0095     return std::numeric_limits<float>::signaling_NaN();
0096   }
0097   //
0098 
0099   /*! \page where is RawCluster::get_eta() ?
0100    *
0101    * get_eta() is retired!
0102    * eta does not have meaning for cluster unless user choose a vertex, which is totally up to user in case of multiple collision,
0103    * and therefore not an intrinsic property of clusterizer.
0104    * The goal is to force people to calculate it based on r/z and the vertex of choice.
0105    *
0106    * There is a utility to help you calculate, a concise example is here to get energy 3-vector:
0107    * https://www.phenix.bnl.gov/WWW/sPHENIX/doxygen/html/dc/d23/ClusterJetInput_8C_source.html#l00045
0108    * Or this one if you only interest in eta:
0109    * https://www.phenix.bnl.gov/WWW/sPHENIX/doxygen/html/d7/daf/CaloEvaluator_8C_source.html#l00487
0110    *
0111    * Older code is commented out here:
0112    *
0113    *  //! convert cluster location to psuedo-rapidity given a user chosen z-location
0114    *  virtual float get_eta() const
0115    *  {
0116    *    PHOOL_VIRTUAL_WARN("get_eta()");
0117    *    return std::numeric_limits<float>::signaling_NaN();
0118    *  }
0119    *  //! convert cluster E_T given a user chosen z-location
0120    *  virtual float get_et() const
0121    *  {
0122    *    PHOOL_VIRTUAL_WARN("get_et()");
0123    *    return std::numeric_limits<float>::signaling_NaN();
0124    *  }
0125    */
0126 
0127   //! access Cartesian coordinate system
0128   virtual float get_x() const
0129   {
0130     PHOOL_VIRTUAL_WARN("get_x()");
0131     return std::numeric_limits<float>::signaling_NaN();
0132   }
0133   virtual float get_y() const
0134   {
0135     PHOOL_VIRTUAL_WARN("get_y()");
0136     return std::numeric_limits<float>::signaling_NaN();
0137   }
0138   //
0139   //! access additional optional properties
0140   //! cluster core energy for EM shower
0141   virtual float get_ecore() const
0142   {
0143     PHOOL_VIRTUAL_WARN("get_ecore()");
0144     return std::numeric_limits<float>::signaling_NaN();
0145   }
0146   //! reduced chi2 for EM shower
0147   virtual float get_chi2() const
0148   {
0149     PHOOL_VIRTUAL_WARN("get_chi2()");
0150     return std::numeric_limits<float>::signaling_NaN();
0151   }
0152   //! cluster template probability for EM shower
0153   virtual float get_prob() const
0154   {
0155     PHOOL_VIRTUAL_WARN("get_prob()");
0156     return std::numeric_limits<float>::signaling_NaN();
0157   }
0158   //! cluster template probability for merged pi0 EM shower
0159   virtual float get_merged_cluster_prob() const
0160   {
0161     PHOOL_VIRTUAL_WARN("get_merged_cluster_prob()");
0162     return std::numeric_limits<float>::signaling_NaN();
0163   }
0164   //! isolation ET default
0165   virtual float get_et_iso() const
0166   {
0167     PHOOL_VIRTUAL_WARN("get_et_iso()");
0168     return std::numeric_limits<float>::signaling_NaN();
0169   }
0170   //! isolation ET the radius and hueristic can be specified
0171   virtual float get_et_iso(const int /*radiusx10*/, bool /*subtracted*/, bool /*clusterTower*/) const
0172   {
0173     PHOOL_VIRTUAL_WARN("get_et_iso(const int radiusx10, bool subtracted, bool clusterTower)");
0174     return std::numeric_limits<float>::signaling_NaN();
0175   }
0176 
0177   virtual std::vector<float> get_shower_shapes(float /*tower_thresh*/) const
0178   {
0179     PHOOL_VIRTUAL_WARN("get_shower_shapes(float tower_thresh)");
0180     return std::vector<float>();
0181   }
0182 
0183   virtual std::pair<int,int> get_lead_tower() const
0184   {
0185     PHOOL_VIRTUAL_WARN("get_lead_tower()");
0186     return {std::numeric_limits<int>::signaling_NaN(),std::numeric_limits<int>::signaling_NaN()};
0187   }
0188 
0189   //  //! truth cluster's PHG4Particle ID
0190   //  virtual int get_truth_track_ID() const
0191   //  {
0192   //    PHOOL_VIRTUAL_WARN("get_truth_track_ID()");
0193   //    return 0;
0194   //  }
0195   //  //! truth cluster's PHG4Particle flavor
0196   //  virtual int get_truth_flavor() const
0197   //  {
0198   //    PHOOL_VIRTUAL_WARN("get_truth_flavor()");
0199   //    return 0;
0200   //  }
0201   //
0202   /** @} */  // end of getters
0203 
0204   /** @defgroup setters
0205    *  @{
0206    */
0207   //! cluster ID
0208   virtual void set_id(const RawClusterDefs::keytype) { PHOOL_VIRTUAL_WARNING; }
0209   //! Tower operations
0210   virtual void addTower(const RawClusterDefs::keytype /*twrid*/, const float /*etower*/) { PHOOL_VIRTUAL_WARNING; }
0211   //! total energy
0212   virtual void set_energy(const float) { PHOOL_VIRTUAL_WARNING; }
0213   //
0214   //!  access to intrinsic cylindrical coordinate system
0215   virtual void set_phi(const float) { PHOOL_VIRTUAL_WARNING; }
0216   virtual void set_z(const float) { PHOOL_VIRTUAL_WARNING; }
0217   virtual void set_r(const float) { PHOOL_VIRTUAL_WARNING; }
0218   //
0219   //! access additional optional properties
0220   //! cluster core energy for EM shower
0221   virtual void set_ecore(const float) { PHOOL_VIRTUAL_WARNING; }
0222   //! reduced chi2 for EM shower
0223   virtual void set_chi2(const float) { PHOOL_VIRTUAL_WARNING; }
0224   //! cluster template probability for EM shower
0225   virtual void set_prob(const float) { PHOOL_VIRTUAL_WARNING; }
0226   //! cluster template merged pi0 cluster probability for EM shower
0227   virtual void set_merged_cluster_prob(const float) { PHOOL_VIRTUAL_WARNING; }
0228   //! isolation ET
0229   virtual void set_et_iso(const float) { PHOOL_VIRTUAL_WARNING; }
0230   virtual void set_et_iso(const float /*e*/, const int /*radiusx10*/, bool /*subtracted*/, bool /*clusterTower*/) { PHOOL_VIRTUAL_WARNING; }
0231   //  //! truth cluster's PHG4Particle ID
0232   //  virtual void set_truth_track_ID(const int) { PHOOL_VIRTUAL_WARNING; }
0233   //  //! truth cluster's PHG4Particle flavor
0234   //  virtual void set_truth_flavor(const int) { PHOOL_VIRTUAL_WARNING; }
0235   //
0236   /*
0237    *
0238    * @} */
0239   // end of setters
0240 
0241   /** @defgroup property_map property map definitions
0242    *  @{
0243    */
0244 
0245  public:
0246   //! Procedure to add a new PROPERTY tag:
0247   //! 1.add new tag below with unique value,
0248   //! 2.add a short name to RawCluster::get_property_info()
0249   enum PROPERTY
0250   {  //
0251      // ----- additional cluster properties -----
0252      //! cluster core energy for EM shower
0253     prop_ecore = 0,
0254     //! cluster template probability for EM shower
0255     prop_prob = 1,
0256     //! reduced chi2 for EM shower
0257     prop_chi2 = 2,
0258     //! cluster template merged pi0 cluster probability for EM shower
0259     prop_merged_cluster_prob = 3,
0260 
0261     // ----- analysis specific quantities -----
0262     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.1
0263     prop_et_iso_calotower_sub_R01 = 20,
0264     //! isolation ET by the calorimeter tower heuristic no subtracted background R=.1
0265     prop_et_iso_calotower_R01 = 21,
0266     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0267     prop_et_iso_calotower_sub_R02 = 22,
0268     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0269     prop_et_iso_calotower_R02 = 23,
0270     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0271     prop_et_iso_calotower_sub_R03 = 24,
0272     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0273     prop_et_iso_calotower_R03 = 25,
0274     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0275     prop_et_iso_calotower_sub_R04 = 26,
0276     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0277     prop_et_iso_calotower_R04 = 27,
0278     //    // ----- truth cluster quantities -----
0279     //    //! truth cluster's PHG4Particle ID
0280     //    prop_truth_track_ID = 100,
0281     //    //! truth cluster's PHG4Particle flavor
0282     //    prop_truth_flavor = 101,
0283 
0284     //! max limit in order to fit into 8 bit unsigned number
0285     prop_MAX_NUMBER = std::numeric_limits<unsigned char>::max()
0286   };
0287 
0288   enum PROPERTY_TYPE
0289   {  //
0290     type_int = 1,
0291     type_uint = 2,
0292     type_float = 3,
0293     type_unknown = -1
0294   };
0295 
0296   //! getters
0297   virtual bool has_property(const PROPERTY /*prop_id*/) const { return false; }
0298   virtual float get_property_float(const PROPERTY /*prop_id*/) const { return std::numeric_limits<float>::signaling_NaN(); }
0299   virtual int get_property_int(const PROPERTY /*prop_id*/) const { return std::numeric_limits<int>::min(); }
0300   virtual unsigned int get_property_uint(const PROPERTY /*prop_id*/) const { return std::numeric_limits<unsigned int>::max(); }
0301   //! setters
0302   virtual void set_property(const PROPERTY /*prop_id*/, const float /*value*/) { return; }
0303   virtual void set_property(const PROPERTY /*prop_id*/, const int /*value*/) { return; }
0304   virtual void set_property(const PROPERTY /*prop_id*/, const unsigned int /*value*/) { return; }
0305   //! type management
0306   static std::pair<const std::string, PROPERTY_TYPE> get_property_info(PROPERTY prop_id);
0307   static bool check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type);
0308   static std::string get_property_type(const PROPERTY_TYPE prop_type);
0309 
0310   /** @} */  // end of property map definitions
0311 
0312  protected:
0313   RawCluster() {}  // make sure nobody calls ctor of base class
0314   ClassDefOverride(RawCluster, 1)
0315 };
0316 
0317 #endif