672 if (
fDebugIsOn) std::cerr <<
" LBNFMagneticFieldPolyconeHorn::getFieldFrom3DMapCurrentEqualizer xyz " 674 for (
int k=0;
k !=3;
k++) Bfield[
k] = 0.;
677 const unsigned int iZ1 =
680 const unsigned int iZ2 = (iZ1 == (
fNumZPtsForCE-1)) ? iZ1 : (iZ1 + 1);
683 if (phi < 0.) phi += 2.0*M_PI;
684 const unsigned int iQuadrant = (
unsigned int) std::floor(2.0*phi/M_PI);
685 const double phiFirst = phi - iQuadrant*M_PI/2.;
686 const unsigned int iPhi1 =
688 const unsigned int iPhi2 = (iPhi1 == (
fNumPhiPtsForCE-1)) ? 0 : (iPhi1 + 1);
690 if (
fDebugIsOn) std::cerr <<
" ..... phi " << phi <<
" phiFirst " << phiFirst
691 <<
" indices " << iPhi1 <<
" / " << iPhi2 <<
std::endl;
694 const double rSqZ2 = rSqRequested - fField3DMapCurrentEqualizerRadSqAtZ[iZ2];
695 if ((rSqZ1 < 0.) && (rSqZ2 < 0.))
return;
696 double radOCAtZ = 0.;
697 double radICAtZ = 0.;
698 if ((rSqZ1 < 0.) || (rSqZ2 < 0.)) {
700 if (rSqRequested < (radOCAtZ*radOCAtZ))
return;
703 const unsigned int iR2Z1 = (rSqZ1 < 0.) ? 0 : ((iR1Z1 == (
fNumRPtsForCE-1)) ? iR1Z1 : (iR1Z1 + 1));
705 const unsigned int iR2Z2 = (rSqZ2 < 0.) ? 0 : ((iR1Z2 == (
fNumRPtsForCE-1)) ? iR1Z2 : (iR1Z2 + 1));
708 if (
fDebugIsOn) std::cerr <<
" ..... RsQ, Z1 " << rSqZ1 <<
" at Z2 " << rSqZ2 <<
" indices " 709 << iR1Z1 <<
" / " << iR2Z1 <<
" / " << iR1Z2 <<
" / " << iR2Z2 <<
std::endl;
719 if (
fDebugIsOn) std::cerr <<
" ..... ii indices " << ii1 <<
" / " << ii2 <<
" / " << ii3 <<
" / " << ii4
721 double bxIz1 = 0.;
double byIz1 = 0.;
728 double bxIz2 = 0.;
double byIz2 = 0.;
729 if (((iR2Z1 == iR1Z1) || (iR2Z2 == iR1Z2)) && (iR1Z1 != 0) &&
730 (iR1Z2 != 0) && (iR2Z1 != 0) && (iR2Z2 != 0) ) {
736 const double bix1 =
static_cast<double>(itm1->second.first);
737 const double biy1 =
static_cast<double>(itm1->second.second);
738 const double bix4 =
static_cast<double>(itm4->second.first);
739 const double biy4 =
static_cast<double>(itm4->second.second);
740 bxIz1 = (1. - ui)*bix1 + ui*bix4;
741 byIz1 = (1. - ui)*biy1 + ui*biy4;
750 const double bjx1 =
static_cast<double>(jtm1->second.first);
751 const double bjy1 =
static_cast<double>(jtm1->second.second);
752 const double bjx4 =
static_cast<double>(jtm4->second.first);
753 const double bjy4 =
static_cast<double>(jtm4->second.second);
754 bxIz2 = (1. - ui)*bjx1 + ui*bjx4;
755 byIz2 = (1. - ui)*bjy1 + ui*bjy4;
759 Bfield[0] = (1.0 - v)*bxIz1 + v*bxIz2;
760 Bfield[1] = (1.0 - v)*byIz1 + v*byIz2;
762 if (
fDebugIsOn) std::cerr <<
" ....Phi/Z interpolation only. " 763 <<
" Bfield " << Bfield[0] <<
" / " << Bfield[1] <<
std::endl;
774 const double bjx1 =
static_cast<double>(jtm1->second.first);
775 const double bjy1 =
static_cast<double>(jtm1->second.second);
776 const double bjx2 =
static_cast<double>(jtm2->second.first);
777 const double bjy2 =
static_cast<double>(jtm2->second.second);
778 const double bjx3 =
static_cast<double>(jtm3->second.first);
779 const double bjy3 =
static_cast<double>(jtm3->second.second);
780 const double bjx4 =
static_cast<double>(jtm4->second.first);
781 const double bjy4 =
static_cast<double>(jtm4->second.second);
784 bxIz2 = (1. - ui)*(1.0 - tj)*bjx1 + (1.0 - ui)*tj*bjx2 + ui*tj*bjx3 + (1.0 - tj)*ui*bjx4 ;
785 byIz2 = (1. - ui)*(1.0 - tj)*bjy1 + (1.0 - ui)*tj*bjy2 + ui*tj*bjy3 + (1.0 - tj)*ui*bjy4 ;
787 std::cerr <<
" tj " << tj <<
" bjxs " << bjx1 <<
" / " << bjx2 <<
" / " << bjx3 <<
" / " << bjx4 <<
std::endl;
788 std::cerr <<
" bjys " << bjy1 <<
" / " << bjy2 <<
" / " << bjy3 <<
" / " << bjy4 <<
std::endl;
789 std::cerr <<
" bxIz2 " << bxIz2 <<
" byIz2 " << byIz2 <<
std::endl;
796 if (
fDebugIsOn) std::cerr <<
" .... v " << v <<
" Bfield " << Bfield[0] <<
" / " << Bfield[1] <<
std::endl;
797 }
else if (rSqZ2 < 0.) {
806 const double bix1 =
static_cast<double>(itm1->second.first);
807 const double biy1 =
static_cast<double>(itm1->second.second);
808 const double bix2 =
static_cast<double>(itm2->second.first);
809 const double biy2 =
static_cast<double>(itm2->second.second);
810 const double bix3 =
static_cast<double>(itm3->second.first);
811 const double biy3 =
static_cast<double>(itm3->second.second);
812 const double bix4 =
static_cast<double>(itm4->second.first);
813 const double biy4 =
static_cast<double>(itm4->second.second);
816 bxIz1 = (1. - ui)*(1.0 - ti)*bix1 + (1.0 - ui)*ti*bix2 + ui*ti*bix3 + (1.0 - ti)*ui*bix4 ;
817 byIz1 = (1. - ui)*(1.0 - ti)*biy1 + (1.0 - ui)*ti*biy2 + ui*ti*biy3 + (1.0 - ti)*ui*biy4 ;
819 std::cerr <<
" ui " << ui <<
" ti " << ti <<
std::endl;
820 std::cerr <<
" bixs " << bix1 <<
" / " << bix2 <<
" / " << bix3 <<
" / " << bix4 <<
std::endl;
821 std::cerr <<
" biys " << biy1 <<
" / " << biy2 <<
" / " << biy3 <<
" / " << biy4 <<
std::endl;
822 std::cerr <<
" bxIz1 " << bxIz1 <<
" byIz1 " << byIz1 <<
std::endl;
827 Bfield[0] = (1.0 - v)*bxIz1;
828 Bfield[1] = (1.0 - v)*byIz1;
829 if (
fDebugIsOn) std::cerr <<
" .... v " << v <<
" Bfield " << Bfield[0] <<
" / " << Bfield[1] <<
std::endl;
840 const double bix1 =
static_cast<double>(itm1->second.first);
841 const double biy1 =
static_cast<double>(itm1->second.second);
842 const double bix2 =
static_cast<double>(itm2->second.first);
843 const double biy2 =
static_cast<double>(itm2->second.second);
844 const double bix3 =
static_cast<double>(itm3->second.first);
845 const double biy3 =
static_cast<double>(itm3->second.second);
846 const double bix4 =
static_cast<double>(itm4->second.first);
847 const double biy4 =
static_cast<double>(itm4->second.second);
850 bxIz1 = (1. - ui)*(1.0 - ti)*bix1 + (1.0 - ui)*ti*bix2 + ui*ti*bix3 + (1.0 - ti)*ui*bix4 ;
851 byIz1 = (1. - ui)*(1.0 - ti)*biy1 + (1.0 - ui)*ti*biy2 + ui*ti*biy3 + (1.0 - ti)*ui*biy4 ;
853 std::cerr <<
" ui " << ui <<
" ti " << ti <<
std::endl;
854 std::cerr <<
" bixs " << bix1 <<
" / " << bix2 <<
" / " << bix3 <<
" / " << bix4 <<
std::endl;
855 std::cerr <<
" biys " << biy1 <<
" / " << biy2 <<
" / " << biy3 <<
" / " << biy4 <<
std::endl;
856 std::cerr <<
" bxIz1 " << bxIz1 <<
" byIz1 " << byIz1 <<
std::endl;
870 const double bjx1 =
static_cast<double>(jtm1->second.first);
871 const double bjy1 =
static_cast<double>(jtm1->second.second);
872 const double bjx2 =
static_cast<double>(jtm2->second.first);
873 const double bjy2 =
static_cast<double>(jtm2->second.second);
874 const double bjx3 =
static_cast<double>(jtm3->second.first);
875 const double bjy3 =
static_cast<double>(jtm3->second.second);
876 const double bjx4 =
static_cast<double>(jtm4->second.first);
877 const double bjy4 =
static_cast<double>(jtm4->second.second);
880 bxIz2 = (1. - ui)*(1.0 - tj)*bjx1 + (1.0 - ui)*tj*bjx2 + ui*tj*bjx3 + (1.0 - tj)*ui*bjx4 ;
881 byIz2 = (1. - ui)*(1.0 - tj)*bjy1 + (1.0 - ui)*tj*bjy2 + ui*tj*bjy3 + (1.0 - tj)*ui*bjy4 ;
883 std::cerr <<
" tj " << tj <<
" bjxs " << bjx1 <<
" / " << bjx2 <<
" / " << bjx3 <<
" / " << bjx4 <<
std::endl;
884 std::cerr <<
" bjys " << bjy1 <<
" / " << bjy2 <<
" / " << bjy3 <<
" / " << bjy4 <<
std::endl;
885 std::cerr <<
" bxIz2 " << bxIz2 <<
" byIz2 " << byIz2 <<
std::endl;
890 Bfield[0] = (1.0 - v)*bxIz1 + v*bxIz2;
891 Bfield[1] = (1.0 - v)*byIz1 + v*byIz2;
892 if (
fDebugIsOn) std::cerr <<
" .... v " << v <<
" Bfield " << Bfield[0] <<
" / " << Bfield[1] <<
std::endl;
896 if (iQuadrant == 0)
return;
897 double bfQ[2]; bfQ[0] = Bfield[0]; bfQ[1] = Bfield[1];
898 switch (iQuadrant ) {
900 Bfield[0] = -bfQ[1]; Bfield[1] = bfQ[0];
break;
902 Bfield[0] = -bfQ[0]; Bfield[1] = -bfQ[1];
break;
904 Bfield[0] = bfQ[1]; Bfield[1] = -bfQ[0];
break;
std::vector< double > fField3DMapCurrentEqualizerRadSqRStepAtZ
double fField3DMapCurrentEqualizerZStep
unsigned int fNumRPtsForCE
unsigned int fNumPhiPtsForCE
static int max(int a, int b)
void fillHornPolygonRadii(double z, double *rIn, double *rOut) const
std::vector< double > fField3DMapCurrentEqualizerRadSqAtZ
unsigned int fNumZPtsForCE
std::map< unsigned int, std::pair< float, float > > fField3DMapCurrentEqualizer
double fField3DMapCurrentEqualizerZMin
double fField3DMapCurrentEqualizerPhiStep
QTextStream & endl(QTextStream &s)