2 #include <tls/TankResponseUtilities.h>
9 #include <utl/AugerUnits.h>
10 #include <utl/MathConstants.h>
11 #include <utl/Branch.h>
12 #include <utl/AugerException.h>
17 using namespace USCMuonProfileNS;
26 double x1(0),x2(0),y1(0),y2(0);
28 int ix = h.GetXaxis()->FindBin(x);
29 int iy = h.GetYaxis()->FindBin(y);
31 if (ix == h.GetNbinsX()+1) ix -= 1;
33 x1 = h.GetXaxis()->GetBinCenter(ix);
36 x1 = h.GetXaxis()->GetBinCenter(ix);
38 x2 = h.GetXaxis()->GetBinCenter(ix+1);
40 y1 = h.GetYaxis()->GetBinCenter(iy);
43 y1 = h.GetYaxis()->GetBinCenter(iy);
45 y2 = h.GetYaxis()->GetBinCenter(iy+1);
47 const double v00 = h.GetBinContent(ix,iy);
48 const double v01 = h.GetBinContent(ix,iy+1);
49 const double v10 = h.GetBinContent(ix+1,iy);
50 const double v11 = h.GetBinContent(ix+1,iy+1);
51 const double zx = (x-x1)/(x2-x1);
52 const double zy = (y-y1)/(y2-y1);
53 return (1.0-zx)*(1.0-zy)*v00 + (1.0-zx)*zy*v01 + zx*(1.0-zy)*v10 + zx*zy*v11;
59 Extrapolate(
const TH2D& h,
double rmax,
double r,
double zeta)
63 return exp(a + b*(
sqrt(r)-
sqrt(rmax)));
74 const double c[64] = { 1.323609e+05, 1.187303e+05, 9.395542e+04, 6.895397e+04,
75 4.840035e+04, 3.251341e+04, 2.091493e+04, 1.282508e+04,
76 7.433439e+03, 4.007066e+03, 1.945498e+03, 7.860169e+02,
77 1.895583e+02, -7.845296e+01, -1.691854e+02, -1.726411e+02,
78 -1.390602e+02, -9.562383e+01, -5.631717e+01, -2.703336e+01,
79 -8.487988e+00, 1.335395e+00, 5.137142e+00, 5.495047e+00,
80 4.413872e+00, 3.072145e+00, 1.835842e+00, 6.221296e-01,
81 -6.599210e-01, -1.829552e+00, -2.470651e+00, -2.467011e+00,
82 -1.996112e+00, -1.483970e+00, -1.217739e+00, -1.242982e+00,
83 -1.399658e+00, -1.550564e+00, -1.492873e+00, -1.091996e+00,
84 -4.217213e-01, 3.443991e-01, 1.022913e+00, 1.490880e+00,
85 1.786550e+00, 2.054111e+00, 2.299077e+00, 2.372312e+00,
86 2.122376e+00, 1.491762e+00, 5.303430e-01, -4.858504e-01,
87 -1.286566e+00, -1.638024e+00, -1.536687e+00, -1.157604e+00,
88 -8.427614e-01, -9.519352e-01, -1.534490e+00, -2.439957e+00,
89 -3.454757e+00, -4.376512e+00, -4.991014e+00, -5.234057e+00 };
91 const unsigned int n = 64;
92 const double z = 2*theta/(0.5*
utl::kPi)-1.0;
95 for (
unsigned int i=n-1;i!=0;--i)
98 d = 2*z*d - dd + c[i];
103 const double cosThetaMu = cos(theta)/
sqrt(
pow(cos(theta),2) +
pow(d*cos(phi)*sin(theta)-x,2) +
pow(d*sin(phi)*sin(theta)-y,2) );
104 return acos(cosThetaMu);
109 fDensity(0), fThetaRange(),
110 fTheta(0.), fPhi(0.), fEnergy(10.*
EeV),
111 fExponent(1.0), fNMuonScale(1.0), fNMuonScaleEnergy(1.0),
112 fIndexThetaLow(0), fIndexThetaUp(0), fIndexPhiLow(0), fIndexPhiUp(0),
113 fHistDen1(NULL),fHistDen2(NULL),fHistDen3(NULL),fHistDen4(NULL)
122 string pathToDataFile;
125 fDensity = TFile::Open(pathToDataFile.c_str(),
"READ");
128 msg <<
"Could not read histogram file " << pathToDataFile <<
"\n";
138 const double thetaDeg = theta/
degree;
139 const double phiDeg = phi /
degree;
144 const double phiMapDeg =
PhiMap(phiDeg);
153 ostringstream histoID1;
154 histoID1 <<
"h" << id1 ;
156 ostringstream histoID2;
157 histoID2 <<
"h" << id2 ;
159 ostringstream histoID3;
160 histoID3 <<
"h" << id3 ;
162 ostringstream histoID4;
163 histoID4 <<
"h" << id4 ;
172 msg <<
"the following histograms are missing in file "
174 if(!
fHistDen1) msg << histoID1.str().c_str() <<
" ";
175 if(!
fHistDen2) msg << histoID2.str().c_str() <<
" ";
176 if(!
fHistDen3) msg << histoID3.str().c_str() <<
" ";
177 if(!
fHistDen4) msg << histoID4.str().c_str() <<
" ";
178 msg << endl <<
"\tTheta: " << thetaDeg
179 <<
" Phi: " << phiDeg << endl;
193 const double zeta = psi-
fBPsi+0.5*
kPi;
194 const double xperp = rperp*cos(zeta);
195 const double yperp = rperp*sin(zeta);
197 double dum1,dum2,dum3,dum4;
198 if (fabs(xperp) < 3950. and fabs(yperp) < 3950.)
209 if (fabs(xperp)>3950.) rmax1 = fabs(3950./cos(zeta));
210 if (fabs(yperp)>3950.) rmax2 = fabs(3950./sin(zeta));
211 const double rmax = rmax1 < rmax2 ? rmax1 : rmax2;
235 double u = (phiMap-u1)/(u2 -u1);
236 dummy = (1-u)*dum1+u*dum2;
247 double t = (thetaMap-t1)/(t2-t1);
249 dummy = (1-t)*dum1 +t*dum3;
257 double t = (thetaMap-t1)/(t2-t1);
262 double u = (phiMap-u1)/(u2 -u1);
263 dummy = (1-t)*(1-u)*dum1 + u*(1-t)*dum2 + t*u*dum4 + t*(1-u)*dum3;
267 const double localTheta =
ThetaMuon(xpos,ypos,theta,phi,energy);
287 if (r>4000.*
m) r = 4000*
m;
291 double Ap0 = -1.92124e+01;
292 double Ap1 = 8.75452e-01;
293 double Ap2 = -1.19709e-02;
294 double Ap3 = 5.74630e-05;
295 double A = Ap0 + Ap1*th + Ap2*th*th + Ap3*th*th*th;
298 double Bp0 = 3.65857e+00;
299 double Bp1 = -1.61666e-01;
300 double Bp2 = 1.97280e-03;
301 double Bp3 = -8.13659e-06;
302 double B = Bp0 + Bp1*th + Bp2*th*th + Bp3*th*th*th;
304 double LogEMu = A + B*log10(r);
305 double E =
pow(10,LogEMu);
308 if (std::isnan(E) || E<1.0) E = 1.0;
309 else if (E>1000.) E=1000.;
319 return static_cast<unsigned int>(floor((theta - 60.0)/2.0));
327 return static_cast<unsigned int>(ceil((theta - 60.0)/2.0));
335 return static_cast<unsigned int>(floor(phi/5.0))*5;
343 return static_cast<unsigned int>(ceil(phi/5.0))*5;
350 return 60.0+
static_cast<double>(2*(itheta));
357 return 5.0*
static_cast<double>(iphi/5);
367 if (phiAires<0) phiAires = 360+phiAires;
369 if (phiAires>180) phiAires = 360 - phiAires;
double Extrapolate(const TH2D &h, double rmax, double r, double zeta)
unsigned int fIndexThetaLow
double rPerpendicular(const double xpos, const double ypos, const double theta, const double phi)
radial distance in shower front plane coordinate system
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
void SetProfile(double theta, double phi, double energy)
double pow(const double x, const unsigned int i)
unsigned int Theta2IndexLower(double theta)
void LoadHistograms(double theta, double phi)
Class representing a document branch.
double NMuon(double xpos, double ypos, double theta, double phi, double energy)
Expected average number of muons per tank, at the given coordinates on the ground, for a certain combination of theta, phi, and energy of the primary particle.
double Index2Theta(unsigned int itheta)
double approx(double num, double prec=1e-3)
void GetData(bool &b) const
Overloads of the GetData member template function.
double TankGroundArea(const double theta)
Projected ground area of Auger tank seen by muon with zenith angle theta.
unsigned int Phi2IndexUpper(double theta)
static const double kDeclination
kDeclination of geomagnetic field in Malargüe, 2007
double PsiPerpendicular(const double xpos, const double ypos, const double theta, const double phi)
polar angle in shower front plane coordinate system
double GetThetaMax()
Maximum zenith angle, at which the tank response function is defined.
unsigned int Theta2IndexUpper(double theta)
double EnergyMuon(double xpos, double ypos, double theta, double phi, double energy)
Expected average muon energy on the ground, at the given coordinates on the ground, for a certain combination of theta, phi, and energy of the primary particle.
USCMuonProfile(utl::Branch branch)
double GetThetaMin()
Minimum zenith angle, at which the tank response function is defined.
double LocalMuonAngle(double x, double y, double theta, double phi)
unsigned int fIndexThetaUp
unsigned int Phi2IndexLower(double theta)
double PhiMap(double phi)
double ThetaMuon(double xpos, double ypos, double theta, double phi, double energy)
Expected average muon inclination angle on the ground, at the given coordinates on the ground...
unsigned int fIndexPhiLow
double Index2Phi(unsigned int iphi)
double InterpolateHistrogram(const TH2D &h, double x, double y)
std::vector< double > fThetaRange