OscProb
NuPath.cxx
Go to the documentation of this file.
1
2//
3// Implements functions to average neutrino paths
4//
5// jcoelho\@apc.in2p3.fr
7
8#include "NuPath.h"
9
10using namespace std;
11
12using OscProb::NuPath;
13
14//.............................................................................
28{
29 // Start with the first path
30 NuPath mergedPath = p1;
31
32 // Add the second length
33 mergedPath.length += p2.length;
34
35 // Compute weighted average of Z/A
36 mergedPath.zoa =
37 (p1.zoa * p1.length + p2.zoa * p2.length) / (p1.length + p2.length);
38
39 // Compute weighted average of density
40 mergedPath.density =
41 (p1.density * p1.zoa * p1.length + p2.density * p2.zoa * p2.length) /
42 (p1.zoa * p1.length + p2.zoa * p2.length);
43
44 // return merged path
45 return mergedPath;
46}
47
48//.............................................................................
60NuPath OscProb::AvgPath(std::vector<NuPath>& pv)
61{
62 // Get size of vector
63 int np = pv.size();
64
65 // Start with the first path
66 NuPath mergedPath;
67
68 // If vector is not empty, start on first path
69 if (np > 0)
70 mergedPath = pv[0];
71 else
72 return mergedPath;
73
74 // Merge each of the following paths
75 for (int i = 1; i < np; i++) { mergedPath = AvgPath(mergedPath, pv[i]); }
76
77 // return merged path
78 return mergedPath;
79}
80
81//.............................................................................
89vector<NuPath> OscProb::MergePaths(std::vector<NuPath>& inputPath, int j, int k)
90{
91 // Output vector
92 vector<NuPath> mergedPath;
93
94 // Loop over input paths
95 for (int i = 0; i < inputPath.size(); i++) {
96 // If first index, merge the paths j and k
97 if (i == j) mergedPath.push_back(AvgPath(inputPath[j], inputPath[k]));
98 // If not second index add the path as is
99 else if (i != k)
100 mergedPath.push_back(inputPath[i]);
101
102 } // End of loop
103
104 // return merged vector
105 return mergedPath;
106}
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 length
The length of the path segment in km.
Definition: NuPath.h:78
double zoa
The effective Z/A value of the path segment.
Definition: NuPath.h:80