GamR  0.0.0
GammaROOT
Loading...
Searching...
No Matches
SolidAttenuation.cc
Go to the documentation of this file.
1
13
14#include <iostream>
15
16#include <utils/Utilities.hh>
17#include "SolidAttenuation.hh"
18
19
20#include <Math/SpecFunc.h> /* legendre polynomials */
21#include <TF1.h>
22
23namespace GamR {
24 namespace AngDist {
30 SolidAttenuation::SolidAttenuation(std::vector<double> Qk)
31 {
32 this->Qk = Qk;
33 }
34
47
48 SolidAttenuation::SolidAttenuation(double distance, double radius, int kmax /*=4*/, double absorbCoeff /*=-1*/)
49 {
50 double maxOpenAngle = atan(radius / distance);
51 TF1 *func;
52 if (absorbCoeff > 0) {
53 func = new TF1("SolidAttenuationFunc",
54 "((x==0)*1 + (x>0)*(1-exp(-[1]*(([2]-[3]*sin(x))/sin(x)))))*"
55 "ROOT::Math::legendre([0], cos(x)) * sin(x)",
56 0, maxOpenAngle);
57 func->SetParameter(2, radius);
58 func->SetParameter(3, distance);
59 func->SetParameter(1, absorbCoeff);
60 } else {
61 func = new TF1("SolidAttenuationFunc", "ROOT::Math::legendre([0], cos(x)) * sin(x)", 0, maxOpenAngle);
62 }
63 double J0 = 0;
64 func->SetParameter(0, 0);
65
66 J0 = func->Integral(0, maxOpenAngle);
67 this->Qk.clear();
68 this->Qk.push_back(1.);
69 for (int ik = 1; ik <= kmax; ++ik) {
70 func->SetParameter(0, ik);
71 this->Qk.push_back(func->Integral(0, maxOpenAngle) / J0);
72 }
73 delete func;
74 }
75
76 //Estimates the attenuation coefficient of a typical Ge(Li) detector from a fit to data in Krane (1972) NIM 98, 205. Qk is rather insensitive to this value so an estimate is OK.
77 double GetTauG(double E)
78 {
79 return 0.009425*std::pow(E,-2.5);
80 }
81
82 //Routine for calculating Qk coefficients for a coaxial Ge crystal detector with a 'dead' core. Translated from FORTRAN in Krane (1972) NIM 98, 205.
83 //XL = detector length, R = active outer radius, A = active inner radius (or dead radius), D = detector distance from source, tau = gamma-ray absorption coefficient. Units are all in cm.
84 //calculates for even k
85 //PROVIDE UNITS IN mm!! XL = detector length, R = active outer radius, A = active inner radius (or dead radius), D = detector distance from source, tau = gamma-ray absorption coefficient.
86 SolidAttenuation::SolidAttenuation(double distance, double length, double outer_radius, double inner_radius, double energy, int kmax/*=4*/)
87 {
88 this->Qk.clear();
89 this->Qk.push_back(1.);
90 distance /= 10.;
91 length /= 10.;
92 outer_radius /= 10.;
93 inner_radius /= 10.;
94
95 for (int k=1; k<=kmax; ++k) {
96 if(k%2) {
97 Qk.push_back(0.);
98 continue;
99 }
100 double TAU = GetTauG(energy);
101 double F[101];
102 double B[4];
103 double XJ[2] { 0 };
104 double Qk;
105 // Detector solid angles
106 B[0] = std::atan2(inner_radius, distance+length);
107 B[1] = std::atan2(inner_radius, distance);
108 B[2] = std::atan2(outer_radius, distance+length);
109 B[3] = std::atan2(outer_radius, distance);
110 for(int n=0; n<2; n++) {
111 double N = n + 1.;
112 if(k==0 && N==2) break;
113 int KA = int(k) * (2 - int(N)) + 1;
114 for(int j=0; j<3; j++) {
115 double J = j+1.;
116 double YL = B[j];
117 double YU = B[j + 1];
118 double DL = (YU - YL) / 100.;
119 for(int m=0; m<101; m++) {
120 // Trigonometry and attenuation
121 double M = m + 1.;
122 double XM = YL + DL * (M - 1);
123 double EX;
124 switch(j) {
125 case 0:
126 EX = TAU * ( inner_radius - (distance + length) * std::tan(XM) ) / std::sin(XM);
127 break;
128 case 1:
129 EX = -TAU * length / std::cos(XM);
130 break;
131 case 2:
132 EX = TAU * ( distance * std::tan(XM) - outer_radius) / std::sin(XM);
133 }
134 // Legendre polynomials
135 F[m] = std::sin(XM) * (1. - std::exp(EX));
136 if(J==1) F[m] *= std::exp(-TAU * ( inner_radius / std::sin(XM) - distance / std::cos(XM)));
137 F[m] *= ROOT::Math::legendre(KA-1, std::cos(XM));
138 }
139 // Simpson's rule integral
140 XJ[n] += GamR::Utils::Simps(F, 100, DL);
141 }
142 }
143 Qk = XJ[0] / XJ[1];
144 this->Qk.push_back(Qk);
145 }
146 }
147
148
149 } /* namespace AngDist */
150} /* namespace GamR */
SolidAttenuation(std::vector< double > Qk)
double GetTauG(double E)
double Simps(double *y, int n, double dx)
Definition Utilities.cc:301
Definition Gain.cc:19