OscProb
EarthModelBase.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * EarthModelBase.cxx
3 * Base class for all Earth model clases in OscProb
4 * (created by Rebekah Pestes based on PremModel.cxx)
5 *************************************************************************/
6
7#include <cmath>
8#include <iostream>
9
10#include "EarthModelBase.h"
11
12using namespace std;
13
14using namespace OscProb;
15
16//.............................................................................
25void EarthModelBase::SetDetectorCoordinates(double rad, double lat, double lon)
26{
27 // Force radius to be non-negative
28 if (rad < 0) {
29 cerr << "WARNING: Negative radius detected. Setting to absolute value."
30 << endl;
31 rad = -rad;
32 }
33 fDetRadius = rad;
34
35 // Force latitude to be between -90 and 90 deg
36 lat -= floor((lat + 90.0) / 360.0) * 360.0;
37 if (lat > 90) { lat = 180.0 - lat; }
38 fDetLat = lat / 180.0 * M_PI; // convert to radians
39
40 // Force longitude to be between 0 and 360 deg
41 lon -= floor(lon / 360.0) * 360.0;
42 fDetLon = lon / 180.0 * M_PI; // convert to radians
43}
44
45//.............................................................................
52vector<NuPath> EarthModelBase::GetNuPath() { return fNuPath; }
53
54//.............................................................................
65void EarthModelBase::AddPathSegment(double length, double density, double zoa,
66 int index)
67{
68 fNuPath.push_back(NuPath(length, density, zoa, index));
69}
70
71//.............................................................................
77double EarthModelBase::GetTotalL(double cosT)
78{
79 if (fabs(cosT) > 1) return 0;
80
81 double sinsqrT = 1 - cosT * cosT;
82
83 return -fDetRadius * cosT +
84 sqrt(fRadiusMax * fRadiusMax - fDetRadius * fDetRadius * sinsqrT);
85}
86
87//.............................................................................
100{
101 if (L < fRadiusMax - fDetRadius) return 1;
102 if (L > fRadiusMax + fDetRadius) return -1;
103
104 return (fRadiusMax * fRadiusMax - fDetRadius * fDetRadius - L * L) /
105 (2 * fDetRadius * L);
106}
107
108//.............................................................................
121vector<NuPath> EarthModelBase::GetMergedPaths(double prec)
122{
123 // The output vector
124 vector<NuPath> mergedPath;
125
126 // Start with the first path
127 NuPath path = fNuPath[0];
128
129 // Track the total length
130 double totL = 0;
131
132 // Loop over all paths starting from second
133 for (int i = 1; i < fNuPath.size(); i++) {
134 // If this path electron density is beyond the tolerance
135 if (fabs(path.density * path.zoa - fNuPath[i].density * fNuPath[i].zoa) >
136 prec * path.zoa) {
137 // Add merged path to vector
138 mergedPath.push_back(path);
139
140 // Set this path as new merged path
141 path = fNuPath[i];
142 }
143 else { // If path is within tolerance
144
145 // Merge the path with current merged path
146 path = AvgPath(path, fNuPath[i]);
147 }
148
149 // Increment total length
150 totL += fNuPath[i].length;
151
152 } // End of loop over paths
153
154 // Add the final merged path to vector
155 mergedPath.push_back(path);
156
157 // If tag is true, remove small paths
158 if (fRemoveSmallPaths) {
159 // Start at first path
160 int k = 0;
161
162 // While not at the end of vector
163 while (k + 1 < mergedPath.size()) {
164 // If length is less than 1% of total
165 if (mergedPath[k].length < 0.01 * totL) {
166 // Merge path with following path
167 mergedPath = MergePaths(mergedPath, k, k + 1);
168 }
169 // If path is long enough skip it
170 else
171 k++;
172
173 } // End of while loop
174
175 } // End of if statement
176
177 // return the merged vector
178 return mergedPath;
179}
180
181//.............................................................................
virtual double GetTotalL(double cosT)
Get the total baseline for a given cosTheta.
double fRadiusMax
Maximum radius in Earth model (in km)
bool fRemoveSmallPaths
Tag whether to merge small paths.
double fDetLat
The latitude (in rad) where the detector sits.
virtual std::vector< NuPath > GetMergedPaths(double prec=0.25)
Get merged path sequence in a vector.
virtual double GetCosT(double L)
Get the cosTheta for a given total baseline.
double fDetLon
The longitude (in rad) where the detector sits.
virtual std::vector< NuPath > GetNuPath()
virtual void SetRemoveSmallPaths(bool rp=true)
Set tag to remove small paths.
virtual void AddPathSegment(double length, double density, double zoa, int index)
Add a path segment to the sequence.
std::vector< NuPath > fNuPath
The current neutrino path sequence.
double fDetRadius
The radius where the detector sits (in km)
Some useful general definitions.
Definition: Absorption.h:6
std::vector< NuPath > MergePaths(std::vector< NuPath > &inputPath, int j, int k)
Merge paths j and k in vector.
Definition: NuPath.cxx:89
NuPath AvgPath(NuPath &p1, NuPath &p2)
Get the average of two paths.
Definition: NuPath.cxx:27
Definition: EigenPoint.h:44
A struct representing a neutrino path segment.
Definition: NuPath.h:34
double density
The density of the path segment in g/cm^3.
Definition: NuPath.h:79
double zoa
The effective Z/A value of the path segment.
Definition: NuPath.h:80