Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "SvtxVertex_v1.h"
0002 
0003 #include <cmath>
0004 #include <utility>  // for swap
0005 
0006 SvtxVertex_v1::SvtxVertex_v1()
0007 {
0008   std::fill(std::begin(_pos), std::end(_pos), std::numeric_limits<float>::quiet_NaN());
0009   std::fill(std::begin(_err), std::end(_err), std::numeric_limits<float>::quiet_NaN());
0010 }
0011 
0012 void SvtxVertex_v1::identify(std::ostream &os) const
0013 {
0014   os << "---SvtxVertex_v1--------------------" << std::endl;
0015   os << "vertexid: " << get_id() << std::endl;
0016 
0017   os << " t0 = " << get_t() << std::endl;
0018 
0019   os << " (x,y,z) =  (" << get_position(0);
0020   os << ", " << get_position(1) << ", ";
0021   os << get_position(2) << ") cm" << std::endl;
0022 
0023   os << " chisq = " << get_chisq() << ", ";
0024   os << " ndof = " << get_ndof() << std::endl;
0025 
0026   os << "         ( ";
0027   os << get_error(0, 0) << " , ";
0028   os << get_error(0, 1) << " , ";
0029   os << get_error(0, 2) << " )" << std::endl;
0030   os << "  err  = ( ";
0031   os << get_error(1, 0) << " , ";
0032   os << get_error(1, 1) << " , ";
0033   os << get_error(1, 2) << " )" << std::endl;
0034   os << "         ( ";
0035   os << get_error(2, 0) << " , ";
0036   os << get_error(2, 1) << " , ";
0037   os << get_error(2, 2) << " )" << std::endl;
0038 
0039   os << " list of tracks ids: ";
0040   for (ConstTrackIter iter = begin_tracks(); iter != end_tracks(); ++iter)
0041   {
0042     os << *iter << " ";
0043   }
0044   os << std::endl;
0045   os << "-----------------------------------------------" << std::endl;
0046 
0047   return;
0048 }
0049 
0050 int SvtxVertex_v1::isValid() const
0051 {
0052   if (_id == std::numeric_limits<unsigned int>::max())
0053   {
0054     return 0;
0055   }
0056   if (std::isnan(_t0))
0057   {
0058     return 0;
0059   }
0060   if (std::isnan(_chisq))
0061   {
0062     return 0;
0063   }
0064   if (_ndof == std::numeric_limits<unsigned int>::max())
0065   {
0066     return 0;
0067   }
0068 
0069   for (const float &_po : _pos)
0070   {
0071     if (std::isnan(_po))
0072     {
0073       return 0;
0074     }
0075   }
0076   for (int j = 0; j < 3; ++j)
0077   {
0078     for (int i = j; i < 3; ++i)
0079     {
0080       if (std::isnan(get_error(i, j)))
0081       {
0082         return 0;
0083       }
0084     }
0085   }
0086   if (_track_ids.empty())
0087   {
0088     return 0;
0089   }
0090   return 1;
0091 }
0092 
0093 void SvtxVertex_v1::set_error(unsigned int i, unsigned int j, float value)
0094 {
0095   _err[covar_index(i, j)] = value;
0096   return;
0097 }
0098 
0099 float SvtxVertex_v1::get_error(unsigned int i, unsigned int j) const
0100 {
0101   return _err[covar_index(i, j)];
0102 }
0103 
0104 unsigned int SvtxVertex_v1::covar_index(unsigned int i, unsigned int j) const
0105 {
0106   if (i > j)
0107   {
0108     std::swap(i, j);
0109   }
0110   return i + 1 + (j + 1) * (j) / 2 - 1;
0111 }