Back to home page

sPhenix code displayed by LXR

 
 

    


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

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