6 #include "earthmodel.hh" 10 #include "position.hh" 14 #include "icemc_random.h" 27 void Ray::PrintAnglesofIncidence() {
29 cout <<
"angle of incidence (firn-air) is " << nrf_iceside[3].Angle(nsurf_rfexit)*DEGRAD <<
"\n";
30 cout <<
"angle of incidence (ice-firn) is " << nrf_iceside[4].Angle(nsurf_rfexit)*DEGRAD <<
"\n";
32 void Ray::Initialize() {
34 for (
int i=0;i<3;i++) {
35 n_exit2bn[i]=
Vector(0.,0.,0.);
36 nrf_iceside[i]=
Vector(0.,0.,0.);
37 rfexit_db[i]=
Vector(0.,0.,0.);
38 rfexit[i]=
Vector(0.,0.,0.);
42 n_exit2bn_eachboresight[i][k][j]=
Vector(0.,0.,0.);
43 nrf_iceside_eachboresight[i][k][j]=
Vector(0.,0.,0.);
45 rfexit_eachboresight[i][k][j]=
Vector(0.,0.,0.);
50 nsurf_rfexit=
Vector(0.,0.,0.);
51 nsurf_rfexit_db=
Vector(0.,0.,0.);
59 WhereDoesItLeave(posnu,nrf_iceside[2*whichtry],antarctica,
65 WhereDoesItLeave(posnu_down,nrf_iceside[2*whichtry],antarctica,rfexit[whichtry]);
68 n_exit2bn[whichtry] = (r_bn - rfexit[whichtry]).Unit();
70 if (settings1->BORESIGHTS) {
72 for(
int ilayer=0;ilayer<settings1->NLAYERS;ilayer++) {
73 for(
int ifold=0;ifold<anita1->
NRX_PHI[ilayer];ifold++) {
74 WhereDoesItLeave(posnu,nrf_iceside_eachboresight[2*whichtry][ilayer][ifold],antarctica,
75 rfexit_eachboresight[whichtry][ilayer][ifold]);
76 n_exit2bn_eachboresight[whichtry][ilayer][ifold] = (r_boresights[ilayer][ifold] - rfexit_eachboresight[whichtry][ilayer][ifold]).Unit();
81 if (settings1->SLAC) {
85 double x=sin(settings1->SLACSLOPE*RADDEG)*(settings1->SLACICELENGTH/2.+rfexit[0].
Distance(rfexit[whichtry]))/sin(PI/2.+acos(nrf_iceside[2*whichtry].Dot(nsurf_rfexit)));
87 rfexit[whichtry]-=x*nrf_iceside[2*whichtry];
89 if (settings1->BORESIGHTS) {
90 for(
int ilayer=0;ilayer<settings1->NLAYERS;ilayer++) {
91 for(
int ifold=0;ifold<anita1->
NRX_PHI[ilayer];ifold++) {
93 x=sin(settings1->SLACSLOPE*RADDEG)*(settings1->SLACICELENGTH/2.+rfexit_eachboresight[0][ilayer][ifold].
Distance(rfexit_eachboresight[whichtry][ilayer][ifold]))/sin(PI/2.+acos(nrf_iceside_eachboresight[2*whichtry][ilayer][ifold].Dot(nsurf_rfexit)));
95 rfexit_eachboresight[whichtry][ilayer][ifold]-=x*nrf_iceside_eachboresight[2*whichtry][ilayer][ifold];
97 n_exit2bn_eachboresight[whichtry][ilayer][ifold] = (r_boresights[ilayer][ifold] - rfexit_eachboresight[whichtry][ilayer][ifold]).Unit();
110 double howmuch=settings1->SLOPEYSIZE;
114 if (!settings1->SLAC)
115 nsurf_rfexit_temp = antarctica->GetSurfaceNormal(rfexit_temp);
116 else if (settings1->SLAC) {
118 nsurf_rfexit_temp=(rfexit_temp.Unit()).Rotate(-settings1->SLACSLOPE*RADDEG,posnu.Cross(zaxis));
121 Position nsurf_rfexit_temp_copy=nsurf_rfexit_temp;
123 if (settings1->SLOPEY) {
125 TRandom * rng = getRNG(RNG_SLOPEY);
134 slopeyx=howmuch*rng->Gaus();
135 slopeyy=howmuch*rng->Gaus();
136 slopeyz=howmuch*rng->Gaus();
138 Vector ntemp2 = nsurf_rfexit_temp + slopeyx * xaxis
143 ntemp2 = ntemp2 / ntemp2.Mag();
145 double rtemp= ntemp2*nsurf_rfexit_temp;
148 slopeyness=acos(rtemp);
149 sum_slopeyness+=slopeyness;
150 nsurf_rfexit_temp = ntemp2;
155 if (settings1->DEBUG) {
156 rtemp=nsurf_rfexit_temp.Mag();
157 if (fabs(rtemp-1.0)>=0.01) {
158 cout <<
"error: nx,ny,nz_surf="<<nsurf_rfexit_temp<<endl;
165 if (fabs(nsurf_rfexit_temp[2])>=0.99999) {
166 nsurf_rfexit_temp =
Vector(sqrt(1.-0.99999*0.99999-nsurf_rfexit_temp[1]*nsurf_rfexit_temp[1]), nsurf_rfexit_temp[1], 0.99999);
169 slopeyangle=DEGRAD*acos(nsurf_rfexit_temp*nsurf_rfexit_temp_copy);
170 nsurf_rfexit=nsurf_rfexit_temp;
176 int Ray::GetSurfaceNormal(
Settings *settings1,
IceModel *antarctica,
Vector posnu,
double &slopeyangle,
int whichtry) {
180 rfexit_temp=rfexit[whichtry];
183 if (!RandomizeSurface(settings1,rfexit_temp,posnu,antarctica,slopeyangle,whichtry)) {
197 int Ray::TraceRay(
Settings *settings1,
Anita *anita1,
int iter,
double n_depth) {
205 if (settings1->FIRN) {
208 if (!GetRayIceSide(n_exit2bn[iter-1],nsurf_rfexit,Signal::N_AIR,NFIRN,
209 nrf_iceside[2*iter-1])) {
220 if (!GetRayIceSide(nrf_iceside[2*iter-1],nsurf_rfexit,NFIRN,n_depth,
221 nrf_iceside[2*iter])) {
233 if (settings1->BORESIGHTS) {
235 for(
int ilayer=0;ilayer<settings1->NLAYERS;ilayer++) {
236 for(
int ifold=0;ifold<anita1->
NRX_PHI[ilayer];ifold++) {
238 if (!GetRayIceSide(n_exit2bn_eachboresight[iter-1][ilayer][ifold],nsurf_rfexit,Signal::N_AIR,NFIRN,
239 nrf_iceside_eachboresight[2*iter-1][ilayer][ifold]))
253 if (!GetRayIceSide(nrf_iceside_eachboresight[2*iter-1][ilayer][ifold],nsurf_rfexit,NFIRN,n_depth,
254 nrf_iceside_eachboresight[2*iter][ilayer][ifold]))
269 if (!GetRayIceSide(n_exit2bn[iter-1],nsurf_rfexit,Signal::N_AIR,Signal::NICE,
270 nrf_iceside[2*iter-1]))
272 nrf_iceside[2*iter]=nrf_iceside[2*iter-1];
274 if (settings1->BORESIGHTS) {
276 for(
int ilayer=0;ilayer<settings1->NLAYERS;ilayer++) {
277 for(
int ifold=0;ifold<anita1->
NRX_PHI[ilayer];ifold++) {
279 if (!GetRayIceSide(n_exit2bn_eachboresight[iter-1][ilayer][ifold],nsurf_rfexit,Signal::N_AIR,Signal::NICE,
280 nrf_iceside_eachboresight[2*iter-1][ilayer][ifold]))
282 nrf_iceside_eachboresight[2*iter][ilayer][ifold]=nrf_iceside_eachboresight[2*iter-1][ilayer][ifold];
297 int Ray::GetRayIceSide(
const Vector &n_exit2bn,
298 const Vector &nsurf_rfexit,
307 double NRATIO=nexit/nenter;
311 costh=(n_exit2bn*nsurf_rfexit)/(n_exit2bn.Mag() * nsurf_rfexit.Mag());
318 double sinth=sqrt(1 - costh*costh);
332 double factor=NRATIO*costh-sqrt(1-(NRATIO*sinth*NRATIO*sinth));
335 nrf2_iceside = -factor*nsurf_rfexit + NRATIO*n_exit2bn;
336 nrf2_iceside = nrf2_iceside.Unit();
double Distance(const Position &second) const
Returns chord distance (direct distance between two vectors)
Reads in and stores input settings for the run.
This class is a 3-vector that represents a position on the Earth's surface.
Contains everything about positions within payload and signals it sees for each event, in both the trigger and signal paths.
static const int NLAYERS_MAX
max number of layers (in smex design, it's 4)
This class represents a three-vector. Operators are overloaded to provide for the familiar operations...
static const int NPHI_MAX
max number of antennas around in phi (in smex, 16)
int NRX_PHI[NLAYERS_MAX]
number of antennas around in each layer. (radians)
Ice thicknesses and water depth.