Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:20

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   ClustInfo.cc
0003  *  \author Derek Anderson
0004  *  \date   03.01.2024
0005  *
0006  *  Utility class to hold information from
0007  *  calorimeter clusters.
0008  */
0009 /// ---------------------------------------------------------------------------
0010 
0011 #define SCORRELATORUTILITIES_CLUSTINFO_CC
0012 
0013 // class definition
0014 #include "ClustInfo.h"
0015 
0016 // make comon namespaces implicit
0017 using namespace std;
0018 
0019 
0020 
0021 namespace SColdQcdCorrelatorAnalysis {
0022 
0023   // private methods ==========================================================
0024 
0025   // --------------------------------------------------------------------------
0026   //! Set data members to absolute minima
0027   // --------------------------------------------------------------------------
0028   void Types::ClustInfo::Minimize() {
0029 
0030     system  = -1 * numeric_limits<int>::max();
0031     id      = -1 * numeric_limits<int>::max();
0032     nTwr    = -1 * numeric_limits<int>::max();
0033     ene     = -1. * numeric_limits<double>::max();
0034     rho     = -1. * numeric_limits<double>::max();
0035     eta     = -1. * numeric_limits<double>::max();
0036     phi     = -1. * numeric_limits<double>::max();
0037     px      = -1. * numeric_limits<double>::max();
0038     py      = -1. * numeric_limits<double>::max();
0039     pz      = -1. * numeric_limits<double>::max();
0040     rx      = -1. * numeric_limits<double>::max();
0041     ry      = -1. * numeric_limits<double>::max();
0042     rz      = -1. * numeric_limits<double>::max();
0043     return;
0044 
0045   }  // end 'Minimize()'
0046 
0047 
0048 
0049   // --------------------------------------------------------------------------
0050   //! Set data members to absolute maxima
0051   // --------------------------------------------------------------------------
0052   void Types::ClustInfo::Maximize() {
0053 
0054     system  = numeric_limits<int>::max();
0055     id      = numeric_limits<int>::max();
0056     nTwr    = numeric_limits<int>::max();
0057     ene     = numeric_limits<double>::max();
0058     rho     = numeric_limits<double>::max();
0059     eta     = numeric_limits<double>::max();
0060     phi     = numeric_limits<double>::max();
0061     px      = numeric_limits<double>::max();
0062     py      = numeric_limits<double>::max();
0063     pz      = numeric_limits<double>::max();
0064     rx      = numeric_limits<double>::max();
0065     ry      = numeric_limits<double>::max();
0066     rz      = numeric_limits<double>::max();
0067     return;
0068 
0069   }  // end 'Maximize()'
0070 
0071 
0072 
0073   // public methods ===========================================================
0074 
0075   // --------------------------------------------------------------------------
0076   //! Reset object by maximizing data members
0077   // --------------------------------------------------------------------------
0078   void Types::ClustInfo::Reset() {
0079 
0080     Maximize();
0081     return;
0082 
0083   }  // end 'Reset()'
0084 
0085 
0086 
0087   // --------------------------------------------------------------------------
0088   //! Pull relevant information from a F4A RawCluster
0089   // --------------------------------------------------------------------------
0090   void Types::ClustInfo::SetInfo(const RawCluster* clust, optional<ROOT::Math::XYZVector> vtx, optional<int> sys) {
0091 
0092     // if no vertex provided, use origin
0093     ROOT::Math::XYZVector vtxToUse(0., 0., 0.);
0094     if (vtx.has_value()) {
0095       vtxToUse = vtx.value();
0096     }
0097 
0098     // if subsystem ID provided, set data member
0099     if (sys.has_value()) {
0100       system = sys.value();
0101     }
0102 
0103     // grab position
0104     ROOT::Math::XYZVector position(
0105       clust -> get_position().x(),
0106       clust -> get_position().y(),
0107       clust -> get_position().z()
0108     );
0109 
0110     // grab momentum
0111     ROOT::Math::PxPyPzEVector momentum = Tools::GetClustMomentum(clust -> get_energy(), position, vtxToUse);
0112 
0113     // set remaining members
0114     id   = clust -> get_id();
0115     nTwr = clust -> getNTowers();
0116     ene  = clust -> get_energy();
0117     rho  = clust -> get_r();
0118     eta  = momentum.Eta();
0119     phi  = momentum.Phi();
0120     px   = momentum.Px();
0121     py   = momentum.Py();
0122     pz   = momentum.Pz();
0123     rx   = position.X();
0124     ry   = position.Y();
0125     rz   = position.Z();
0126     return;
0127 
0128   }  // end 'SetInfo(RawCluster*, optional<ROOT::Math::XYZVector>, optional<int>)'
0129 
0130 
0131 
0132   // --------------------------------------------------------------------------
0133   //! Check if object is within provided bounds (explicit minimum, maximum)
0134   // --------------------------------------------------------------------------
0135   bool Types::ClustInfo::IsInAcceptance(const ClustInfo& minimum, const ClustInfo& maximum) const {
0136 
0137     return ((*this >= minimum) && (*this <= maximum));
0138 
0139   }  // end 'IsInAcceptance(ClustInfo&, ClustInfo&)'
0140 
0141 
0142 
0143   // --------------------------------------------------------------------------
0144   //! Check if object is within provided bounds (set by pair)
0145   // --------------------------------------------------------------------------
0146   bool Types::ClustInfo::IsInAcceptance(const pair<ClustInfo, ClustInfo>& range) const {
0147 
0148     return ((*this >= range.first) && (*this <= range.second));
0149 
0150   }  // end 'IsInAcceptance(pair<ClustInfo, ClustInfo>&)'
0151 
0152 
0153 
0154   // static methods ===========================================================
0155 
0156   // --------------------------------------------------------------------------
0157   //! Get list of data fields
0158   // --------------------------------------------------------------------------
0159   vector<string> Types::ClustInfo::GetListOfMembers() {
0160 
0161     vector<string> members = {
0162       "system",
0163       "id",
0164       "nTwr",
0165       "ene",
0166       "rho",
0167       "eta",
0168       "phi",
0169       "px",
0170       "py",
0171       "pz",
0172       "rx",
0173       "ry",
0174       "rz"
0175     };
0176     return members;
0177 
0178   }  // end 'GetListOfMembers()'
0179 
0180 
0181 
0182   // overloaded operators =====================================================
0183 
0184   // --------------------------------------------------------------------------
0185   //! Overloaded less-than comparison
0186   // --------------------------------------------------------------------------
0187   bool Types::operator <(const ClustInfo& lhs, const ClustInfo& rhs) {
0188 
0189     // note that some quantities aren't relevant for this comparison
0190     const bool isLessThan = (
0191       (lhs.nTwr < rhs.nTwr) &&
0192       (lhs.ene  < rhs.ene)  &&
0193       (lhs.rho  < rhs.rho)  &&
0194       (lhs.eta  < rhs.eta)  &&
0195       (lhs.phi  < rhs.phi)  &&
0196       (lhs.px   < rhs.px)   &&
0197       (lhs.py   < rhs.py)   &&
0198       (lhs.pz   < rhs.pz)   &&
0199       (lhs.rx   < rhs.rx)   &&
0200       (lhs.ry   < rhs.ry)   &&
0201       (lhs.rz   < rhs.rz)
0202     );
0203     return isLessThan;
0204 
0205   }  // end 'operator <(ClustInfo&, ClustInfo&) const'
0206 
0207 
0208 
0209   // --------------------------------------------------------------------------
0210   //! Overloaded greater-than comparison
0211   // --------------------------------------------------------------------------
0212   bool Types::operator >(const ClustInfo& lhs, const ClustInfo& rhs) {
0213 
0214     // note that some quantities aren't relevant for this comparison
0215     const bool isGreaterThan = (
0216       (lhs.nTwr > rhs.nTwr) &&
0217       (lhs.ene  > rhs.ene)  &&
0218       (lhs.rho  > rhs.rho)  &&
0219       (lhs.eta  > rhs.eta)  &&
0220       (lhs.phi  > rhs.phi)  &&
0221       (lhs.px   > rhs.px)   &&
0222       (lhs.py   > rhs.py)   &&
0223       (lhs.pz   > rhs.pz)   &&
0224       (lhs.rx   > rhs.rx)   &&
0225       (lhs.ry   > rhs.ry)   &&
0226       (lhs.rz   > rhs.rz)
0227     );
0228     return isGreaterThan;
0229 
0230   }  // end 'operator >(ClustInfo&, ClustInfo&)'
0231 
0232 
0233 
0234   // --------------------------------------------------------------------------
0235   //! Overloaded less-than-or-equal-to comparison
0236   // --------------------------------------------------------------------------
0237   bool Types::operator <=(const ClustInfo& lhs, const ClustInfo& rhs) {
0238 
0239     // note that some quantities aren't relevant for this comparison
0240     const bool isLessThanOrEqualTo = (
0241       (lhs.nTwr <= rhs.nTwr) &&
0242       (lhs.ene  <= rhs.ene)  &&
0243       (lhs.rho  <= rhs.rho)  &&
0244       (lhs.eta  <= rhs.eta)  &&
0245       (lhs.phi  <= rhs.phi)  &&
0246       (lhs.px   <= rhs.px)   &&
0247       (lhs.py   <= rhs.py)   &&
0248       (lhs.pz   <= rhs.pz)   &&
0249       (lhs.rx   <= rhs.rx)   &&
0250       (lhs.ry   <= rhs.ry)   &&
0251       (lhs.rz   <= rhs.rz)
0252     );
0253     return isLessThanOrEqualTo;
0254 
0255   }  // end 'operator <=(ClustInfo&, ClustInfo&) const'
0256 
0257 
0258 
0259   // --------------------------------------------------------------------------
0260   //! Overloaded greater-than-or-equal-to comparison
0261   // --------------------------------------------------------------------------
0262   bool Types::operator >=(const ClustInfo& lhs, const ClustInfo& rhs) {
0263 
0264     // note that some quantities aren't relevant for this comparison
0265     const bool isGreaterThanOrEqualTo = (
0266       (lhs.nTwr >= rhs.nTwr) &&
0267       (lhs.ene  >= rhs.ene)  &&
0268       (lhs.rho  >= rhs.rho)  &&
0269       (lhs.eta  >= rhs.eta)  &&
0270       (lhs.phi  >= rhs.phi)  &&
0271       (lhs.px   >= rhs.px)   &&
0272       (lhs.py   >= rhs.py)   &&
0273       (lhs.pz   >= rhs.pz)   &&
0274       (lhs.rx   >= rhs.rx)   &&
0275       (lhs.ry   >= rhs.ry)   &&
0276       (lhs.rz   >= rhs.rz)
0277     );
0278     return isGreaterThanOrEqualTo;
0279 
0280   }  // end 'operator >=(ClustInfo&, ClustInfo&)'
0281 
0282 
0283 
0284   // ctor/dtor ================================================================
0285 
0286   // --------------------------------------------------------------------------
0287   //! Default class constructor
0288   // --------------------------------------------------------------------------
0289   Types::ClustInfo::ClustInfo() {
0290 
0291      /* nothing to do */
0292 
0293   }  // end ctor()
0294 
0295 
0296 
0297   // --------------------------------------------------------------------------
0298   //! Default class destructor
0299   // --------------------------------------------------------------------------
0300   Types::ClustInfo::~ClustInfo() {
0301 
0302     /* nothing to do */
0303 
0304   }  // end dtor()
0305 
0306 
0307 
0308   // --------------------------------------------------------------------------
0309   //! Constructor accepting initialization option (minimize or maximize)
0310   // --------------------------------------------------------------------------
0311   Types::ClustInfo::ClustInfo(const Const::Init init) {
0312 
0313     switch (init) {
0314       case Const::Init::Minimize:
0315         Minimize();
0316         break;
0317       case Const::Init::Maximize:
0318         Maximize();
0319         break;
0320       default:
0321         Maximize();
0322         break;
0323     }
0324 
0325   }  // end ctor(Const::Init)
0326 
0327 
0328 
0329   // --------------------------------------------------------------------------
0330   //! Constructor accepting a F4A RawCluster and possibly a vertex
0331   // --------------------------------------------------------------------------
0332   Types::ClustInfo::ClustInfo(const RawCluster* clust, optional<ROOT::Math::XYZVector> vtx, optional<int> sys) {
0333 
0334     SetInfo(clust, vtx, sys);
0335 
0336   }  // end ctor(RawCluster*, optional<ROOT::Math::XYZVector>, optional<int>)'
0337 
0338 }  // end SColdQcdCorrelatorAnalysis namespace
0339 
0340 // end ------------------------------------------------------------------------