PremModel.cxx
//......................................................................
///
/// Merge similar paths to reduce number of steps
///
/// This method will merge consecutive paths and take their averages
/// until it finds a large enough gap to start a new merged path.
///
/// The merged paths will be returned, and the original detailed path
/// will not be changed and will stay stored as an attribute.
///
/// @param prec - The precision to merge paths in g/cm^3
/// @return The vector of merged path segments
///
Merge similar paths to reduce number of steps

This method will merge consecutive paths and take their averages
until it finds a large enough gap to start a new merged path.

The merged paths will be returned, and the original detailed path
will not be changed and will stay stored as an attribute.
Merge similar paths to reduce number of steps This method will merge consecutive paths and take their averages until it finds a large enough gap to start a new merged path . The merged paths will be returned and the original detailed path will not be changed and will stay stored as an attribute .
vector<NuPath> PremModel::GetMergedPaths(double prec){
  vector<NuPath> mergedPath;
  OscProb::NuPath path = fNuPath[0];
  double totL = 0;
  for(int i=1; i<fNuPath.size(); i++){
    if( fabs(path.density*path.zoa - fNuPath[i].density*fNuPath[i].zoa) > prec*path.zoa ){
      mergedPath.push_back(path);
      path = fNuPath[i];
    }
    else{
      path = OscProb::AvgPath(path, fNuPath[i]);
    }
    totL += fNuPath[i].length;
  }
  mergedPath.push_back(path);
  if(fRemoveSmallPaths){
    int k = 0;
    while(k + 1 < mergedPath.size()){
      if(mergedPath[k].length < 0.01*totL){
        mergedPath = MergePaths(mergedPath, k, k+1);
      }
      else k++;
    }
  }
  return mergedPath;
}
vector < NuPath > PremModel :: GetMergedPaths ( double prec ) { vector < NuPath > mergedPath ; OscProb :: NuPath path = fNuPath [ 0 ] ; double totL = 0 ; for ( int i = 1 ; i < fNuPath . size ( ) ; i ++ ) { if ( fabs ( path . density * path . zoa - fNuPath [ i ] . density * fNuPath [ i ] . zoa ) > prec * path . zoa ) { mergedPath . push_back ( path ) ; path = fNuPath [ i ] ; } else { path = OscProb :: AvgPath ( path , fNuPath [ i ] ) ; } totL += fNuPath [ i ] . length ; } mergedPath . push_back ( path ) ; if ( fRemoveSmallPaths ) { int k = 0 ; while ( k + 1 < mergedPath . size ( ) ) { if ( mergedPath [ k ] . length < 0.01 * totL ) { mergedPath = MergePaths ( mergedPath , k , k + 1 ) ; } else k ++ ; } } return mergedPath ; }
......................................................................
......................................................................
// The output vector // Start with the first path // Track the total length // Loop over all paths starting from second // If this path electron density is beyond the tolerance // Add merged path to vector // Set this path as new merged path // If path is within tolerance // Merge the path with current merged path // Increment total length // End of loop over paths // Add the final merged path to vector // If tag is true, remove small paths // Start at first path // While not at the end of vector // If length is less than 1% of total // Merge path with following path // If path is long enough skip it // End of while loop // End of if statement // return the merged vector