PremModel.cxx
//......................................................................
///
/// Load an earth model from a file.
///
/// By default it loads the model stored in PremTables/prem_default.txt
///
/// The decision of whether to create a layer for the detector position
/// is made in this function, so the detector position must be set before
/// calling this function.
///
/// @param filename - The txt file containing a table of earth layers
///
Load an earth model from a file.

By default it loads the model stored in PremTables/prem_default.txt

The decision of whether to create a layer for the detector position
is made in this function, so the detector position must be set before
calling this function.
Load an earth model from a file . By default it loads the model stored in PremTables / prem_default . txt The decision of whether to create a layer for the detector position is made in this function so the detector position must be set before calling this function .
void PremModel::LoadModel(string filename)
{
  ClearModel();
  if(filename == ""){
    filename = PREM_DEFAULT;
  }
  ifstream fin;
  fin.open(filename.c_str());
  if(!fin){
    cout << "ERROR: File " << filename << " not found!" << endl;
    return;
  }
  float radius, density, zoa, layer;
  bool crossed_det = false;
  double rprev = 0;
  while(fin >> radius >> density >> zoa >> layer){
    if(radius <= rprev){
      cout << "ERROR: Radii are not sorted in increasing order in the model file" << endl;
      ClearModel();
      return;
    }
    if(radius > fDetPos - DET_TOL && !crossed_det){
      crossed_det = true;
      fDetLayer = fPremLayers.size();
      if(radius > fDetPos + DET_TOL){
        AddLayer(fDetPos, density, zoa, layer);
      }
    }
    AddLayer(radius, density, zoa, layer);
  }
}
void PremModel :: LoadModel ( string filename ) { ClearModel ( ) ; if ( filename == " " ) { filename = PREM_DEFAULT ; } ifstream fin ; fin . open ( filename . c_str ( ) ) ; if ( ! fin ) { cout << " " << filename << " " << endl ; return ; } float radius , density , zoa , layer ; bool crossed_det = false ; double rprev = 0 ; while ( fin >> radius >> density >> zoa >> layer ) { if ( radius <= rprev ) { cout << " " << endl ; ClearModel ( ) ; return ; } if ( radius > fDetPos - DET_TOL && ! crossed_det ) { crossed_det = true ; fDetLayer = fPremLayers . size ( ) ; if ( radius > fDetPos + DET_TOL ) { AddLayer ( fDetPos , density , zoa , layer ) ; } } AddLayer ( radius , density , zoa , layer ) ; } }
......................................................................
Load an earth model from a file.
...................................................................... Load an earth model from a file .
// Clear the current model // Use default if no file provided // Open the file // Variables for storing table rows // Flag to mark we've passed the detector // Keep track of previous radius // Loop over table rows // Radii must be ordered in model file // See if we passed the detector and decide whether // to create a special layer for it // If detector is not near boundary, add a special layer // Add this layer to the model