13#include "prem_default.hpp"
24const double PremModel::DET_TOL = 0.2;
35PremModel::PremModel(
string filename) : fDetLayer(0)
80 cerr <<
"WARNING: Detector must be inside Earth model." << endl
81 <<
"WARNING: Adjusting detector radius from " <<
fDetRadius
82 <<
" km to " <<
fPremLayers.back().radius <<
" km." << endl;
105 cerr <<
"WARNING: Adjusting detector radius from " <<
fDetRadius
106 <<
" km to " << radius <<
" km." << endl;
187 if (filename ==
"") { filename = PREM_DEFAULT; }
191 fin.open(filename.c_str());
194 cerr <<
"ERROR: File " << filename <<
" not found!" << endl;
199 float radius, density, zoa, layer;
205 while (fin >> radius >> density >> zoa >> layer) {
207 if (radius <= rprev) {
209 <<
"ERROR: Radii are not sorted in increasing order in the model file"
216 AddLayer(radius, density, zoa, layer);
241 for (
int i = 0; i < nlayers; i++) {
262 cerr <<
"ERROR: Not that many layer types. Returning 0" << endl;
266 for (
int i = 0; i < nlayers; i++) {
275 cerr <<
"ERROR: layer type not found. Returning 0" << endl;
291 cerr <<
"WARNING: Layer thickness should be positive. Do nothing." << endl;
298 cerr <<
"WARNING: PremModel has no layers. Do nothing." << endl;
308 double topRadius = bottomRadius + thick;
353 if (fabs(cosT) > 1)
return 0;
356 double minR =
fDetRadius * sqrt(1 - cosT * cosT);
357 double minRsq = minR * minR;
364 while (
fPremLayers[minlayer].radius < minR) minlayer++;
368 if (cosT < 0) nsteps += 2 * (
fDetLayer - minlayer) + 1;
371 int layer = toplayer;
375 for (
int i = 0; i < nsteps; i++) {
378 double L1 = pow(
fPremLayers[layer].radius, 2) - minRsq;
383 if (L1 < 0)
return true;
388 if (layer > 0) L2 += pow(
fPremLayers[layer - 1].radius, 2);
392 bool ismin = (L2 <= 0 && cosT < 0);
403 dL = sqrt(L1) - sqrt(L2);
double fRadiusMax
Maximum radius in Earth model (in km)
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)
virtual void SetDetectorCoordinates(double rad, double lat, double lon)
virtual void AddLayer(double radius, double density, double zoa, double layer)
Add a layer to the model.
virtual void SetTopLayerSize(double thick)
Set the outermost layer thickness in km.
virtual void CleanIdentical()
Clear identical consecutive layers.
int fDetLayer
The layer index of the detector.
virtual void AddDetLayer()
Add the detector layer.
virtual void LoadModel(std::string filename)
Load an earth model from a file.
void SetDetPos(double rad, double lat=0, double lon=0)
int FillPath(double cosT, double phi=0)
Fill the path sequence in a vector.
static const double DET_TOL
The detector position tolerance near boundaries.
std::vector< PremLayer > fPremLayers
The layers in the earth model.
virtual ~PremModel()
Destructor.
virtual void ClearModel()
Clear the earth model information.
virtual void SetLayerZoA(int layer, double zoa)
Set Z/A of all layers of a given type.
virtual void AddPath(double length, PremLayer pl)
Add a path segment to the sequence.
virtual std::vector< PremLayer > GetPremLayers()
virtual double GetLayerZoA(int layer)
Get Z/A of all layers of a given type.
Some useful general definitions.
A struct representing a spherical shell of matter for earth models.
double radius
The outer radius of the layer in km.
double zoa
The effective Z/A value of the layer.
double density
The density of the layer in g/cm^3.
int layer
An index to identify the matter type.