Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:19:44

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 <utility>
0018 #include <vector>
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 = default;
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>::quiet_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>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_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>::quiet_NaN();
0086   }
0087   virtual float get_r() const
0088   {
0089     PHOOL_VIRTUAL_WARN("get_r()");
0090     return std::numeric_limits<float>::quiet_NaN();
0091   }
0092   virtual float get_z() const
0093   {
0094     PHOOL_VIRTUAL_WARN("get_z()");
0095     return std::numeric_limits<float>::quiet_NaN();
0096   }
0097 
0098 
0099   virtual void set_tower_cog(float /*xr*/, float /*yr*/, float /*xc*/, float /*yc*/){return;}
0100   virtual float x_tower_raw() const { return std::numeric_limits<float>::quiet_NaN(); }
0101   virtual float y_tower_raw() const { return std::numeric_limits<float>::quiet_NaN(); }
0102   virtual float x_tower_corr()const  { return std::numeric_limits<float>::quiet_NaN(); }
0103   virtual float y_tower_corr()const  { return std::numeric_limits<float>::quiet_NaN(); }
0104     
0105   virtual void  set_mean_time(float /*t*/) { return; }
0106   virtual float mean_time() const          { return std::numeric_limits<float>::quiet_NaN(); }
0107 
0108 
0109   //
0110 
0111   /*! \page where is RawCluster::get_eta() ?
0112    *
0113    * get_eta() is retired!
0114    * eta does not have meaning for cluster unless user choose a vertex, which is totally up to user in case of multiple collision,
0115    * and therefore not an intrinsic property of clusterizer.
0116    * The goal is to force people to calculate it based on r/z and the vertex of choice.
0117    *
0118    * There is a utility to help you calculate, a concise example is here to get energy 3-vector:
0119    * https://www.phenix.bnl.gov/WWW/sPHENIX/doxygen/html/dc/d23/ClusterJetInput_8C_source.html#l00045
0120    * Or this one if you only interest in eta:
0121    * https://www.phenix.bnl.gov/WWW/sPHENIX/doxygen/html/d7/daf/CaloEvaluator_8C_source.html#l00487
0122    *
0123    * Older code is commented out here:
0124    *
0125    *  //! convert cluster location to psuedo-rapidity given a user chosen z-location
0126    *  virtual float get_eta() const
0127    *  {
0128    *    PHOOL_VIRTUAL_WARN("get_eta()");
0129    *    return std::numeric_limits<float>::quiet_NaN();
0130    *  }
0131    *  //! convert cluster E_T given a user chosen z-location
0132    *  virtual float get_et() const
0133    *  {
0134    *    PHOOL_VIRTUAL_WARN("get_et()");
0135    *    return std::numeric_limits<float>::quiet_NaN();
0136    *  }
0137    */
0138 
0139   //! access Cartesian coordinate system
0140   virtual float get_x() const
0141   {
0142     PHOOL_VIRTUAL_WARN("get_x()");
0143     return std::numeric_limits<float>::quiet_NaN();
0144   }
0145   virtual float get_y() const
0146   {
0147     PHOOL_VIRTUAL_WARN("get_y()");
0148     return std::numeric_limits<float>::quiet_NaN();
0149   }
0150   //
0151   //! access additional optional properties
0152   //! cluster core energy for EM shower
0153   virtual float get_ecore() const
0154   {
0155     PHOOL_VIRTUAL_WARN("get_ecore()");
0156     return std::numeric_limits<float>::quiet_NaN();
0157   }
0158   //! reduced chi2 for EM shower
0159   virtual float get_chi2() const
0160   {
0161     PHOOL_VIRTUAL_WARN("get_chi2()");
0162     return std::numeric_limits<float>::quiet_NaN();
0163   }
0164   //! cluster template probability for EM shower
0165   virtual float get_prob() const
0166   {
0167     PHOOL_VIRTUAL_WARN("get_prob()");
0168     return std::numeric_limits<float>::quiet_NaN();
0169   }
0170   //! cluster template probability for merged pi0 EM shower
0171   virtual float get_merged_cluster_prob() const
0172   {
0173     PHOOL_VIRTUAL_WARN("get_merged_cluster_prob()");
0174     return std::numeric_limits<float>::quiet_NaN();
0175   }
0176   //! isolation ET default
0177   virtual float get_et_iso() const
0178   {
0179     PHOOL_VIRTUAL_WARN("get_et_iso()");
0180     return std::numeric_limits<float>::quiet_NaN();
0181   }
0182   //! isolation ET the radius and hueristic can be specified
0183   virtual float get_et_iso(const int /*radiusx10*/, bool /*subtracted*/, bool /*clusterTower*/) const
0184   {
0185     PHOOL_VIRTUAL_WARN("get_et_iso(const int radiusx10, bool subtracted, bool clusterTower)");
0186     return std::numeric_limits<float>::quiet_NaN();
0187   }
0188 
0189   virtual std::vector<float> get_shower_shapes(float /*tower_thresh*/) const
0190   {
0191     PHOOL_VIRTUAL_WARN("get_shower_shapes(float tower_thresh)");
0192     return std::vector<float>();
0193   }
0194 
0195   virtual std::pair<int, int> get_lead_tower() const
0196   {
0197     PHOOL_VIRTUAL_WARN("get_lead_tower()");
0198     return {std::numeric_limits<int>::quiet_NaN(), std::numeric_limits<int>::quiet_NaN()};
0199   }
0200 
0201 
0202   virtual float get_shower_shape_parameter(const std::string& /*name*/) const
0203   {
0204     PHOOL_VIRTUAL_WARN("get_shower_shape_parameter()");
0205     return std::numeric_limits<float>::quiet_NaN();
0206   }
0207 
0208   virtual const std::map<std::string, float>& get_all_shower_shapes() const
0209   {
0210     PHOOL_VIRTUAL_WARN("get_all_shower_shapes()");
0211     static const std::map<std::string, float> dummy;
0212     return dummy;
0213   }
0214 
0215   virtual bool pass_photon_cuts() const
0216   {
0217     PHOOL_VIRTUAL_WARN("pass_photon_cuts()");
0218     return false;
0219   }
0220 
0221   virtual void identify_photon(std::ostream& /*os*/ = std::cout) const
0222   {
0223     PHOOL_VIRTUAL_WARN("identify_photon()");
0224   }
0225 
0226 
0227   virtual void reset_photon_properties()
0228   {
0229     PHOOL_VIRTUAL_WARN("reset_photon_properties()");
0230   }
0231 
0232   //  //! truth cluster's PHG4Particle ID
0233   //  virtual int get_truth_track_ID() const
0234   //  {
0235   //    PHOOL_VIRTUAL_WARN("get_truth_track_ID()");
0236   //    return 0;
0237   //  }
0238   //  //! truth cluster's PHG4Particle flavor
0239   //  virtual int get_truth_flavor() const
0240   //  {
0241   //    PHOOL_VIRTUAL_WARN("get_truth_flavor()");
0242   //    return 0;
0243   //  }
0244   //
0245   /** @} */  // end of getters
0246 
0247   /** @defgroup setters
0248    *  @{
0249    */
0250   //! cluster ID
0251   virtual void set_id(const RawClusterDefs::keytype) { PHOOL_VIRTUAL_WARNING; }
0252   //! Tower operations
0253   virtual void addTower(const RawClusterDefs::keytype /*twrid*/, const float /*etower*/) { PHOOL_VIRTUAL_WARNING; }
0254   //! total energy
0255   virtual void set_energy(const float) { PHOOL_VIRTUAL_WARNING; }
0256   //
0257   //!  access to intrinsic cylindrical coordinate system
0258   virtual void set_phi(const float) { PHOOL_VIRTUAL_WARNING; }
0259   virtual void set_z(const float) { PHOOL_VIRTUAL_WARNING; }
0260   virtual void set_r(const float) { PHOOL_VIRTUAL_WARNING; }
0261   //
0262   //! access additional optional properties
0263   //! cluster core energy for EM shower
0264   virtual void set_ecore(const float) { PHOOL_VIRTUAL_WARNING; }
0265   //! reduced chi2 for EM shower
0266   virtual void set_chi2(const float) { PHOOL_VIRTUAL_WARNING; }
0267   //! cluster template probability for EM shower
0268   virtual void set_prob(const float) { PHOOL_VIRTUAL_WARNING; }
0269   //! cluster template merged pi0 cluster probability for EM shower
0270   virtual void set_merged_cluster_prob(const float) { PHOOL_VIRTUAL_WARNING; }
0271   //! isolation ET
0272   virtual void set_et_iso(const float) { PHOOL_VIRTUAL_WARNING; }
0273   virtual void set_et_iso(const float /*e*/, const int /*radiusx10*/, bool /*subtracted*/, bool /*clusterTower*/) { PHOOL_VIRTUAL_WARNING; }
0274 
0275 
0276   virtual void set_shower_shape_parameter(const std::string& /*name*/, const float /*shape*/)
0277   {
0278     PHOOL_VIRTUAL_WARN("set_shower_shape_parameter()");
0279   }
0280   //  //! truth cluster's PHG4Particle ID
0281   //  virtual void set_truth_track_ID(const int) { PHOOL_VIRTUAL_WARNING; }
0282   //  //! truth cluster's PHG4Particle flavor
0283   //  virtual void set_truth_flavor(const int) { PHOOL_VIRTUAL_WARNING; }
0284   //
0285   /*
0286    *
0287    * @} */
0288   // end of setters
0289 
0290   /** @defgroup property_map property map definitions
0291    *  @{
0292    */
0293 
0294  public:
0295   //! Procedure to add a new PROPERTY tag:
0296   //! 1.add new tag below with unique value,
0297   //! 2.add a short name to RawCluster::get_property_info()
0298   enum PROPERTY
0299   {  //
0300      // ----- additional cluster properties -----
0301      //! cluster core energy for EM shower
0302     prop_ecore = 0,
0303     //! cluster template probability for EM shower
0304     prop_prob = 1,
0305     //! reduced chi2 for EM shower
0306     prop_chi2 = 2,
0307     //! cluster template merged pi0 cluster probability for EM shower
0308     prop_merged_cluster_prob = 3,
0309 
0310     // ----- analysis specific quantities -----
0311     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.1
0312     prop_et_iso_calotower_sub_R01 = 20,
0313     //! isolation ET by the calorimeter tower heuristic no subtracted background R=.1
0314     prop_et_iso_calotower_R01 = 21,
0315     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0316     prop_et_iso_calotower_sub_R02 = 22,
0317     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0318     prop_et_iso_calotower_R02 = 23,
0319     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0320     prop_et_iso_calotower_sub_R03 = 24,
0321     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0322     prop_et_iso_calotower_R03 = 25,
0323     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0324     prop_et_iso_calotower_sub_R04 = 26,
0325     //! isolation ET by the calorimeter tower heuristic with subtracted background R=.2
0326     prop_et_iso_calotower_R04 = 27,
0327     //! tower-space CoG x (raw, tower units)
0328     prop_tower_x_raw  = 40,
0329     //! tower-space CoG y (raw, tower units)
0330     prop_tower_y_raw  = 41,
0331     //! tower-space CoG x (corrected, tower units)
0332     prop_tower_x_corr = 42,
0333     //! tower-space CoG y (corrected, tower units)
0334     prop_tower_y_corr = 43,
0335     //! energy-weighted mean time
0336     prop_tower_t_mean = 44,
0337     // ----- mechanical incidence angles (CEMC) -----
0338     //! signed mechanical incidence alpha_phi (radians)
0339     prop_incidence_alpha_phi = 45,
0340     //! signed mechanical incidence alpha_eta (radians)
0341     prop_incidence_alpha_eta = 46,
0342     //    // ----- truth cluster quantities -----
0343     //    //! truth cluster's PHG4Particle ID
0344     //    prop_truth_track_ID = 100,
0345     //    //! truth cluster's PHG4Particle flavor
0346     //    prop_truth_flavor = 101,
0347       
0348     //! max limit in order to fit into 8 bit unsigned number
0349     prop_MAX_NUMBER = std::numeric_limits<unsigned char>::max()
0350   };
0351 
0352   enum PROPERTY_TYPE
0353   {  //
0354     type_int = 1,
0355     type_uint = 2,
0356     type_float = 3,
0357     type_unknown = -1
0358   };
0359 
0360   //! getters
0361   virtual bool has_property(const PROPERTY /*prop_id*/) const { return false; }
0362   virtual float get_property_float(const PROPERTY /*prop_id*/) const { return std::numeric_limits<float>::quiet_NaN(); }
0363   virtual int get_property_int(const PROPERTY /*prop_id*/) const { return std::numeric_limits<int>::min(); }
0364   virtual unsigned int get_property_uint(const PROPERTY /*prop_id*/) const { return std::numeric_limits<unsigned int>::max(); }
0365   //! setters
0366   virtual void set_property(const PROPERTY /*prop_id*/, const float /*value*/) { return; }
0367   virtual void set_property(const PROPERTY /*prop_id*/, const int /*value*/) { return; }
0368   virtual void set_property(const PROPERTY /*prop_id*/, const unsigned int /*value*/) { return; }
0369   //! type management
0370   static std::pair<const std::string, PROPERTY_TYPE> get_property_info(PROPERTY prop_id);
0371   static bool check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type);
0372   static std::string get_property_type(const PROPERTY_TYPE prop_type);
0373 
0374   /** @} */  // end of property map definitions
0375 
0376  protected:
0377   RawCluster() = default;  // make sure nobody calls ctor of base class
0378   ClassDefOverride(RawCluster, 1)
0379 };
0380 
0381 #endif