657 if ((a1 != a2) || (a1 != a3) || (a2 != a3)) {
658 cout <<
" ( Digitize reco tacks ) Error ! " << endl;
662 int const stopper =
seg_stop / seg_size;
664 std::vector<float> segx, segnx;
665 std::vector<float> segy, segny;
666 std::vector<float> segz, segnz;
667 std::vector<float> segL;
677 double x00 = xxx.at(0);
678 double y00 = yyy.at(0);
679 double z00 = zzz.at(0);
683 std::vector<float> vx;
684 std::vector<float> vy;
685 std::vector<float> vz;
687 for (
int i = 0; i <
a1; i++) {
693 std::sqrt(cet::sum_of_squares(x00 - x0, y00 - y0, z00 - z0));
700 segL.push_back(stag);
720 for (
int i = indC; i < a1 - 1; i++) {
721 double const x1 = xxx.at(i);
722 double const y1 = yyy.at(i);
723 double const z1 = zzz.at(i);
725 double const dr1 = std::sqrt(cet::sum_of_squares(x1 - x0, y1 - y0, z1 - z0));
727 double const x2 = xxx.at(i + 1);
728 double const y2 = yyy.at(i + 1);
729 double const z2 = zzz.at(i + 1);
731 double const dr2 = std::sqrt(cet::sum_of_squares(x2 - x0, y2 - y0, z2 - z0));
733 if (dr1 < seg_size) {
741 if (dr1 <= seg_size && dr2 > seg_size) {
742 double const dx = x2 - x1;
743 double const dy = y2 - y1;
744 double const dz = z2 - z1;
745 double const dr = std::sqrt(dx * dx + dy * dy + dz * dz);
748 cout <<
" ( Zero ) Error ! " << endl;
753 2.0 * ((x1 - x0) * dx + (y1 - y0) * dy + (z1 - z0) * dz) / (dr * dr);
755 double const gamma = (dr1 * dr1 - seg_size * seg_size) / (dr * dr);
756 double const delta = beta * beta - 4.0 * gamma;
759 cout <<
" ( Discriminant ) Error ! " << endl;
763 double const lysi1 = (-beta + std::sqrt(delta)) / 2.0;
764 double const t = lysi1;
766 double const xp = x1 + t * dx;
767 double const yp = y1 + t * dy;
768 double const zp = z1 + t * dz;
774 segL.push_back(1.0 *
n_seg * 1.0 * seg_size + stag);
791 auto const na = vx.size();
796 for (std::size_t i = 0; i < na; ++i) {
806 std::vector<double> mx;
807 std::vector<double>
my;
808 std::vector<double> mz;
812 for (std::size_t i = 0; i < na; ++i) {
813 double const xxw1 = vx.at(i);
814 double const yyw1 = vy.at(i);
815 double const zzw1 = vz.at(i);
817 mx.push_back(xxw1 - sumx);
818 my.push_back(yyw1 - sumy);
819 mz.push_back(zzw1 - sumz);
821 double const xxw0 = mx.at(i);
822 double const yyw0 = my.at(i);
823 double const zzw0 = mz.at(i);
825 m(0, 0) += xxw0 * xxw0 / na;
826 m(0, 1) += xxw0 * yyw0 / na;
827 m(0, 2) += xxw0 * zzw0 / na;
829 m(1, 0) += yyw0 * xxw0 / na;
830 m(1, 1) += yyw0 * yyw0 / na;
831 m(1, 2) += yyw0 * zzw0 / na;
833 m(2, 0) += zzw0 * xxw0 / na;
834 m(2, 1) += zzw0 * yyw0 / na;
835 m(2, 2) += zzw0 * zzw0 / na;
838 TMatrixDSymEigen me(
m);
840 TVectorD eigenval = me.GetEigenValues();
841 TMatrixD eigenvec = me.GetEigenVectors();
843 double max1 = -666.0;
847 for (
int i = 0; i < 3; ++i) {
848 double const p1 = eigenval(i);
856 double ax = eigenvec(0, ind1);
857 double ay = eigenvec(1, ind1);
858 double az = eigenvec(2, ind1);
861 if (segx.at(
n_seg - 1) - segx.at(
n_seg - 2) > 0)
866 if (segy.at(
n_seg - 1) - segy.at(
n_seg - 2) > 0)
871 if (segz.at(
n_seg - 1) - segz.at(
n_seg - 2) > 0)
895 else if (dr1 > seg_size) {
896 double const dx = x1 - x0;
897 double const dy = y1 - y0;
898 double const dz = z1 - z0;
899 double const dr = std::sqrt(cet::sum_of_squares(dx, dy, dz));
902 cout <<
" ( Zero ) Error ! " << endl;
906 double const t = seg_size / dr;
907 double const xp = x0 + t * dx;
908 double const yp = y0 + t * dy;
909 double const zp = z0 + t * dz;
914 segL.push_back(1.0 *
n_seg * 1.0 * seg_size + stag);
933 double na = vx.size();
939 for (std::size_t i = 0; i < na; ++i) {
949 std::vector<double> mx;
950 std::vector<double>
my;
951 std::vector<double> mz;
955 for (
int i = 0; i < na; ++i) {
956 double const xxw1 = vx.at(i);
957 double const yyw1 = vy.at(i);
958 double const zzw1 = vz.at(i);
960 mx.push_back(xxw1 - sumx);
961 my.push_back(yyw1 - sumy);
962 mz.push_back(zzw1 - sumz);
964 double const xxw0 = mx.at(i);
965 double const yyw0 = my.at(i);
966 double const zzw0 = mz.at(i);
968 m(0, 0) += xxw0 * xxw0 / na;
969 m(0, 1) += xxw0 * yyw0 / na;
970 m(0, 2) += xxw0 * zzw0 / na;
972 m(1, 0) += yyw0 * xxw0 / na;
973 m(1, 1) += yyw0 * yyw0 / na;
974 m(1, 2) += yyw0 * zzw0 / na;
976 m(2, 0) += zzw0 * xxw0 / na;
977 m(2, 1) += zzw0 * yyw0 / na;
978 m(2, 2) += zzw0 * zzw0 / na;
981 TMatrixDSymEigen me(
m);
983 TVectorD eigenval = me.GetEigenValues();
984 TMatrixD eigenvec = me.GetEigenVectors();
986 double max1 = -666.0;
989 for (
int i = 0; i < 3; ++i) {
990 double const p1 = eigenval(i);
998 double ax = eigenvec(0, ind1);
999 double ay = eigenvec(1, ind1);
1000 double az = eigenvec(2, ind1);
1003 if (segx.at(
n_seg - 1) - segx.at(
n_seg - 2) > 0)
1008 if (segy.at(
n_seg - 1) - segy.at(
n_seg - 2) > 0)
1013 if (segz.at(
n_seg - 1) - segz.at(
n_seg - 2) > 0)
1018 segnx.push_back(ax);
1019 segny.push_back(ay);
1020 segnz.push_back(az);
1024 return std::nullopt;
1049 return std::make_optional<Segments>(Segments{segx, segnx, segy, segny, segz, segnz, segL});
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
my($xml, $fcl, $workdir, $check, $merge)
physics associatedGroupsWithLeft p1
BEGIN_PROLOG could also be cout