Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:17

0001 #ifndef TRACKBASEHISTORIC_TRACKSTATEINFOV1_H
0002 #define TRACKBASEHISTORIC_TRACKSTATEINFOV1_H
0003 
0004 #include "TrackStateInfo.h"
0005 #include <trackbase/TrkrDefs.h>
0006 
0007 #include <cmath>
0008 #include <cstddef>  // for size_t
0009 #include <cstdint>
0010 #include <iostream>
0011 #include <map>
0012 #include <utility>  // for pair
0013 
0014 class PHObject;
0015 
0016 class TrackStateInfo_v1 : public TrackStateInfo
0017 {
0018  public:
0019   TrackStateInfo_v1() = default;
0020 
0021   ~TrackStateInfo_v1() override = default;
0022 
0023   // The "standard PHObject response" functions...
0024   void identify(std::ostream& os = std::cout) const override
0025   {
0026     os << "TrackStateInfo_v1 class" << std::endl;
0027   }
0028   void Reset() override { *this = TrackStateInfo_v1(); }
0029 
0030   PHObject* CloneMe() const override { return new TrackStateInfo_v1(*this); }
0031 
0032   //! import PHObject CopyFrom, in order to avoid clang warning
0033   using PHObject::CopyFrom;
0034   // copy content from base class
0035   void CopyFrom(const TrackStateInfo&) override {}
0036   void CopyFrom(TrackStateInfo* source) override
0037   {
0038     CopyFrom(*source);
0039   }
0040 
0041   //
0042   // basic track information ---------------------------------------------------
0043   //
0044 
0045   float get_x() const override { return m_Position[0]; }
0046   void set_x(float x) override { m_Position[0] = x; }
0047 
0048   float get_y() const override { return m_Position[1]; }
0049   void set_y(float y) override { m_Position[1] = y; }
0050 
0051   float get_z() const override { return m_Position[2]; }
0052   void set_z(float z) override { m_Position[2] = z; }
0053 
0054   float get_pos(unsigned int i) const override { return m_Position[i]; }
0055 
0056   float get_px() const override;
0057   float get_py() const override;
0058   float get_pz() const override;
0059 
0060   float get_phi() const override { return m_Momentum[0]; }
0061   void set_phi(const float phi) override { m_Momentum[0] = phi; }
0062 
0063   int get_charge() const override { return get_qOp() > 0 ? 1 : -1; }
0064   float get_theta() const override { return m_Momentum[1]; }
0065   void set_theta(const float theta) override { m_Momentum[1] = theta; }
0066 
0067   float get_qOp() const override { return m_Momentum[2]; }
0068   void set_qOp(const float qop) override { m_Momentum[2] = qop; }
0069 
0070   float get_mom(unsigned int i) const override
0071   {
0072     if (i == 0)
0073     {
0074       return get_px();
0075     }
0076     if (i == 1)
0077     {
0078       return get_py();
0079     }
0080     if (i == 2)
0081     {
0082       return get_pz();
0083     }
0084     return std::numeric_limits<float>::quiet_NaN();
0085   }
0086 
0087   float get_p() const override { return sqrt(std::pow(get_px(), 2) + std::pow(get_py(), 2) + std::pow(get_pz(), 2)); }
0088   float get_pt() const override { return sqrt(std::pow(get_px(), 2) + std::pow(get_py(), 2)); }
0089   float get_eta() const override { return -std::log(std::tan(get_theta() / 2.)); }
0090 
0091   float get_covariance(int i, int j) const override;
0092   void set_covariance(int i, int j, float value) override;
0093 
0094  private:
0095   float m_Momentum[3] = {std::numeric_limits<float>::quiet_NaN()};  // global phi, theta, q/p
0096   float m_Position[3] = {std::numeric_limits<float>::quiet_NaN()};  // global [x,y,z]
0097   float m_Covariance[15] = {std::numeric_limits<float>::quiet_NaN()};
0098 
0099   ClassDefOverride(TrackStateInfo_v1, 1)
0100 };
0101 
0102 #endif