//////////////////////////////////////////////////////////////////////// // // Implements functions to average neutrino paths // // jcoelho\@apc.in2p3.fr //////////////////////////////////////////////////////////////////////// #include "NuPath.h" using namespace std; using namespace OscProb; //...................................................................... /// /// Get the merged average of two paths /// /// This method will merge two paths and take their average density /// weighted by Z/A and path length. /// /// The Z/A will be the average weighted by path length /// /// @param p1 - The first path to merge /// @param p2 - The second path to merge /// @return The merged path /// NuPath OscProb::AvgPath(NuPath& p1, NuPath& p2){ // Start with the first path NuPath mergedPath = p1; // Add the second length mergedPath.length += p2.length; // Compute weighted average of Z/A mergedPath.zoa = (p1.zoa*p1.length + p2.zoa*p2.length) / (p1.length + p2.length); // Compute weighted average of density mergedPath.density = (p1.density*p1.zoa*p1.length + p2.density*p2.zoa*p2.length) / (p1.zoa*p1.length + p2.zoa*p2.length); // return merged path return mergedPath; } //...................................................................... /// /// Get the merged average of a vector of paths /// /// This method will merge a set of paths and take their average density /// weighted by Z/A and path length. /// /// The Z/A will be the average weighted by path length /// /// @param pv - vector of paths to merge /// @return The merged path /// NuPath OscProb::AvgPath(std::vector& pv){ // Get size of vector int np = pv.size(); // Start with the first path NuPath mergedPath; // If vector is not empty, start on first path if(np>0) mergedPath = pv[0]; else return mergedPath; // Merge each of the following paths for(int i=1; i OscProb::MergePaths(std::vector& inputPath, int j, int k){ // Output vector vector mergedPath; // Loop over input paths for(int i=0; i