Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // $Id: $
0002 
0003 /*!
0004  * \file RawClusterUtility.h
0005  * \brief
0006  * \author Jin Huang <jhuang@bnl.gov>
0007  * \version $Revision:   $
0008  * \date $Date: $
0009  */
0010 
0011 #ifndef CALOBASE_RAWCLUSTERUTILITY_H
0012 #define CALOBASE_RAWCLUSTERUTILITY_H
0013 
0014 #include "RawCluster.h"
0015 
0016 #include <CLHEP/Vector/ThreeVector.h>
0017 
0018 /*!
0019  * \brief RawClusterUtility
0020  */
0021 class RawClusterUtility
0022 {
0023  public:
0024   virtual ~RawClusterUtility() {}
0025 
0026   //
0027   //! polar angle of cluster with respect to given vertex position
0028   static inline float
0029   GetPolarAngle(const RawCluster& cluster, const CLHEP::Hep3Vector vertex) { return (cluster.get_position() - vertex).getTheta(); }
0030   //
0031   //! azimuth angle of cluster with respect to given vertex position
0032   static inline float
0033   GetAzimuthAngle(const RawCluster& cluster, const CLHEP::Hep3Vector vertex) { return (cluster.get_position() - vertex).getPhi(); }
0034   //
0035   //! Pseudorapidity of cluster with respect to given vertex position
0036   static inline float
0037   GetPseudorapidity(const RawCluster& cluster, const CLHEP::Hep3Vector vertex) { return (cluster.get_position() - vertex).pseudoRapidity(); }
0038   //
0039   //! Transverse energy of cluster with respect to given vertex position
0040   static inline float
0041   GetET(const RawCluster& cluster, const CLHEP::Hep3Vector vertex)
0042   {
0043     const CLHEP::Hep3Vector cluster_vec(cluster.get_position() - vertex);
0044     const double mag = cluster_vec.mag();
0045 
0046     return mag > 0 ? cluster_vec.perp() / cluster_vec.mag() * cluster.get_energy() : 0;
0047   }
0048   //
0049   //! Transverse core energy of cluster with respect to given vertex position
0050   static inline float
0051   GetETCore(const RawCluster& cluster, const CLHEP::Hep3Vector vertex)
0052   {
0053     const CLHEP::Hep3Vector cluster_vec(cluster.get_position() - vertex);
0054 
0055     return cluster_vec.perp() / cluster_vec.mag() * cluster.get_ecore();
0056   }
0057   //
0058   //! Get energy vector of cluster based on cluster energy
0059   static inline CLHEP::Hep3Vector GetEVec(const RawCluster& cluster, const CLHEP::Hep3Vector vertex) { return (cluster.get_position() - vertex).unit() * cluster.get_energy(); }
0060   //! Get energy vector of cluster based on E_core
0061   static inline CLHEP::Hep3Vector GetECoreVec(const RawCluster& cluster, const CLHEP::Hep3Vector vertex) { return (cluster.get_position() - vertex).unit() * cluster.get_ecore(); }
0062 
0063  private:
0064   //! not intended to make an instance
0065   RawClusterUtility() {}
0066 };
0067 
0068 #endif