656 if ((a1 != a2) || (a1 != a3) || (a2 != a3)) {
657 cout <<
" ( Digitize reco tacks ) Error ! " <<
endl;
661 int const stopper =
seg_stop / seg_size;
663 std::vector<float> segx, segnx;
664 std::vector<float> segy, segny;
665 std::vector<float> segz, segnz;
666 std::vector<float> segL;
676 double x00 = xxx.at(0);
677 double y00 = yyy.at(0);
678 double z00 = zzz.at(0);
682 std::vector<float> vx;
683 std::vector<float> vy;
684 std::vector<float> vz;
686 for (
int i = 0; i <
a1; i++) {
699 segL.push_back(stag);
719 for (
int i = indC; i < a1 - 1; i++) {
720 double const x1 = xxx.at(i);
721 double const y1 = yyy.at(i);
722 double const z1 = zzz.at(i);
726 double const x2 = xxx.at(i + 1);
727 double const y2 = yyy.at(i + 1);
728 double const z2 = zzz.at(i + 1);
732 if (dr1 < seg_size) {
740 if (dr1 <= seg_size && dr2 > seg_size) {
741 double const dx = x2 -
x1;
742 double const dy = y2 - y1;
743 double const dz = z2 - z1;
744 double const dr = std::sqrt(dx * dx + dy * dy + dz * dz);
747 cout <<
" ( Zero ) Error ! " <<
endl;
752 2.0 * ((x1 - x0) * dx + (y1 - y0) * dy + (z1 - z0) * dz) / (dr * dr);
754 double const gamma = (dr1 * dr1 - seg_size * seg_size) / (dr * dr);
755 double const delta = beta * beta - 4.0 *
gamma;
758 cout <<
" ( Discriminant ) Error ! " <<
endl;
762 double const lysi1 = (-beta + std::sqrt(delta)) / 2.0;
763 double const t = lysi1;
765 double const xp = x1 + t * dx;
766 double const yp = y1 + t * dy;
767 double const zp = z1 + t * dz;
773 segL.push_back(1.0 *
n_seg * 1.0 * seg_size + stag);
790 auto const na = vx.size();
795 for (std::size_t i = 0; i < na; ++i) {
805 std::vector<double> mx;
806 std::vector<double>
my;
807 std::vector<double> mz;
811 for (std::size_t i = 0; i < na; ++i) {
812 double const xxw1 = vx.at(i);
813 double const yyw1 = vy.at(i);
814 double const zzw1 = vz.at(i);
816 mx.push_back(xxw1 - sumx);
817 my.push_back(yyw1 - sumy);
818 mz.push_back(zzw1 - sumz);
820 double const xxw0 = mx.at(i);
821 double const yyw0 = my.at(i);
822 double const zzw0 = mz.at(i);
824 m(0, 0) += xxw0 * xxw0 / na;
825 m(0, 1) += xxw0 * yyw0 / na;
826 m(0, 2) += xxw0 * zzw0 / na;
828 m(1, 0) += yyw0 * xxw0 / na;
829 m(1, 1) += yyw0 * yyw0 / na;
830 m(1, 2) += yyw0 * zzw0 / na;
832 m(2, 0) += zzw0 * xxw0 / na;
833 m(2, 1) += zzw0 * yyw0 / na;
834 m(2, 2) += zzw0 * zzw0 / na;
837 TMatrixDSymEigen
me(
m);
839 TVectorD eigenval =
me.GetEigenValues();
840 TMatrixD eigenvec =
me.GetEigenVectors();
842 double max1 = -666.0;
846 for (
int i = 0; i < 3; ++i) {
847 double const p1 = eigenval(i);
855 double ax = eigenvec(0, ind1);
856 double ay = eigenvec(1, ind1);
857 double az = eigenvec(2, ind1);
860 if (segx.at(
n_seg - 1) - segx.at(
n_seg - 2) > 0)
865 if (segy.at(
n_seg - 1) - segy.at(
n_seg - 2) > 0)
870 if (segz.at(
n_seg - 1) - segz.at(
n_seg - 2) > 0)
894 else if (dr1 > seg_size) {
895 double const dx = x1 - x0;
896 double const dy = y1 - y0;
897 double const dz = z1 - z0;
901 cout <<
" ( Zero ) Error ! " <<
endl;
905 double const t = seg_size / dr;
906 double const xp = x0 + t * dx;
907 double const yp = y0 + t * dy;
908 double const zp = z0 + t * dz;
913 segL.push_back(1.0 *
n_seg * 1.0 * seg_size + stag);
932 double na = vx.size();
938 for (std::size_t i = 0; i < na; ++i) {
948 std::vector<double> mx;
949 std::vector<double> my;
950 std::vector<double> mz;
954 for (
int i = 0; i < na; ++i) {
955 double const xxw1 = vx.at(i);
956 double const yyw1 = vy.at(i);
957 double const zzw1 = vz.at(i);
959 mx.push_back(xxw1 - sumx);
960 my.push_back(yyw1 - sumy);
961 mz.push_back(zzw1 - sumz);
963 double const xxw0 = mx.at(i);
964 double const yyw0 = my.at(i);
965 double const zzw0 = mz.at(i);
967 m(0, 0) += xxw0 * xxw0 / na;
968 m(0, 1) += xxw0 * yyw0 / na;
969 m(0, 2) += xxw0 * zzw0 / na;
971 m(1, 0) += yyw0 * xxw0 / na;
972 m(1, 1) += yyw0 * yyw0 / na;
973 m(1, 2) += yyw0 * zzw0 / na;
975 m(2, 0) += zzw0 * xxw0 / na;
976 m(2, 1) += zzw0 * yyw0 / na;
977 m(2, 2) += zzw0 * zzw0 / na;
980 TMatrixDSymEigen
me(
m);
982 TVectorD eigenval =
me.GetEigenValues();
983 TMatrixD eigenvec =
me.GetEigenVectors();
985 double max1 = -666.0;
988 for (
int i = 0; i < 3; ++i) {
989 double const p1 = eigenval(i);
997 double ax = eigenvec(0, ind1);
998 double ay = eigenvec(1, ind1);
999 double az = eigenvec(2, ind1);
1002 if (segx.at(
n_seg - 1) - segx.at(
n_seg - 2) > 0)
1007 if (segy.at(
n_seg - 1) - segy.at(
n_seg - 2) > 0)
1012 if (segz.at(
n_seg - 1) - segz.at(
n_seg - 2) > 0)
1017 segnx.push_back(ax);
1018 segny.push_back(ay);
1019 segnz.push_back(az);
1023 return std::nullopt;
1048 return std::make_optional<Segments>(Segments{segx, segnx, segy, segny, segz, segnz, segL});
double beta(double KE, const simb::MCParticle *part)
constexpr T sum_of_squares(T x, T y)
double gamma(double KE, const simb::MCParticle *part)
QTextStream & endl(QTextStream &s)