Back to home page

sPhenix code displayed by LXR

 
 

    


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

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