5 #include <utl/TabulatedFunction.h>
6 #include <utl/UTMPoint.h>
7 #include <utl/MathConstants.h>
8 #include <utl/PhysicalConstants.h>
9 #include <utl/AugerUnits.h>
12 #include <det/Detector.h>
14 #include <evt/ShowerSimData.h>
17 #include <atm/Atmosphere.h>
18 #include <atm/ProfileResult.h>
54 fMuonProductionHeightDistribution (0) {
83 sprintf(nome,
"e_logt_%.1f",
angle);
86 sprintf(nome,
"tMe_logt_%.1f",
angle);
89 sprintf(nome,
"g_logt_%.1f",
angle);
92 sprintf(nome,
"tMg_logt_%.1f",
angle);
95 sprintf(nome,
"TotaldNdlogt_%.1f",
angle);
106 fMuonProductionHeightDistribution (0) {
150 sprintf(nome,
"e_logt_%.1f",
angle);
153 sprintf(nome,
"tMe_logt_%.1f",
angle);
156 sprintf(nome,
"g_logt_%.1f",
angle);
159 sprintf(nome,
"tMg_logt_%.1f",
angle);
162 sprintf(nome,
"TotaldNdlogt_%.1f",
angle);
191 printf(
"*******************************\n");
192 printf(
"* MODEL CONSTANTS *\n");
193 printf(
"*******************************\n");
194 printf(
"* pk %5.2f GeV/km *\n",
pk*1000);
195 printf(
"* kappa %5.1f *\n",
kappa);
196 printf(
"* lambda %5.1f *\n",
lambda);
197 printf(
"* gamma %5.1f *\n",
gam);
198 printf(
"* ptc or Q %5.2f GeV *\n",
ptc);
199 printf(
"*******************************\n");
200 printf(
"*******************************\n");
201 printf(
"* SHOWER CONSTANTS *\n");
202 printf(
"*******************************\n");
203 printf(
"* angle %5.1f deg *\n",
angle);
204 printf(
"* logMean /m %5.3f *\n",
logMean);
205 printf(
"* logSigma /m %5.3f *\n",
logSigma);
206 printf(
"* logLambda /m %5.3f *\n",
logLambda);
207 printf(
"*******************************\n");
209 printf(
"* D(a)=1 *\n");
else
210 printf(
"* D(a)=cos(a)+Delta/L *\n");
211 printf(
"*******************************\n");
247 double c = cos (thetadeg*TMath::DegToRad());
365 double cosTheta = cos (thetadeg*
deg);
376 double HeightXobs = heightProfile.
Y (Xobs);
378 vector <double> ValueZ;
379 vector <double> ValuedNdZ;
381 double AtmDepthMin = depthProfile.
Y (depthProfile.
MaxX());
382 double AtmDepthMax = depthProfile.
Y (depthProfile.
MinX());
388 double z_old = 0, HeightX_old = 0, Nmu_old = 0;
390 iProfile != MuonProfile.
End();
393 double Nmu = iProfile->Y();
394 double Xslant = iProfile->X();
395 double Xvert = Xslant*cosTheta;
397 if (Xvert<AtmDepthMin || Xvert>AtmDepthMax)
400 double HeightX = heightProfile.
Y (Xvert);
401 double z = (HeightX-HeightXobs)/cosTheta/
meter;
421 HeightX_old = HeightX;
429 double dz = z - z_old;
430 double dN = Nmu_old - Nmu;
431 double zMean = (z_old + z) / 2.;
434 logMean += log10 (zMean) * (Nmu+Nmu_old)/2.;
435 Norm += (Nmu+Nmu_old)/2.;
438 ValueZ.insert (ValueZ.begin(),
zMean);
439 ValuedNdZ.insert (ValuedNdZ.begin(), dN/dz);
445 HeightX_old = HeightX;
479 double cosTheta = cos (thetadeg*
deg);
490 double HeightXobs = heightProfile.
Y (Xobs);
492 vector <double> ValueZ;
493 vector <double> ValuedNdZ;
495 double AtmDepthMin = depthProfile.
Y (depthProfile.
MaxX());
496 double AtmDepthMax = depthProfile.
Y (depthProfile.
MinX());
501 double dXslant =
abs (MuonProdProfile[1].X() - MuonProdProfile[0].X());
502 double dXvert = dXslant * cosTheta;
505 iProfile != MuonProdProfile.
End();
508 double nDmu = iProfile->Y();
509 double Xslant = iProfile->X();
510 double Xvert = Xslant*cosTheta;
513 if (Xvert-dXvert/2<AtmDepthMin || Xvert+dXvert/2>AtmDepthMax)
516 double Height = heightProfile.
Y (Xvert);
517 double z = (Height-HeightXobs)/cosTheta/
meter;
519 double Height1 = heightProfile.
Y (Xvert-dXvert/2);
520 double z1 = (Height1-HeightXobs)/cosTheta/
meter;
522 double Height2 = heightProfile.
Y (Xvert+dXvert/2);
523 double z2 = (Height2-HeightXobs)/cosTheta/
meter;
525 double dz =
abs (z1-z2);
537 ValueZ.insert (ValueZ.begin(), z);
538 ValuedNdZ.insert (ValuedNdZ.begin(), nDmu*dXslant/dz);
569 return sqrt(z*z+r*r);
578 double cosa2=1-(r*r)/(L*L);
582 double ret=cosa2+Delta/L*
sqrt(cosa2);
590 return 0.5*(r*r/(
c*t)-
c*t);
595 return 0.5*(r*r/(
c*t*t)+
c);
620 TProfile *hist =
new TProfile (
"lorenzo_dNdz",
621 "lorenzo model mu prod. height",
624 double dz = (zMax-zMin)/nBin;
625 for (
double z = zMin; z<zMax; z+=dz) {
627 hist->Fill (z+dz/2,
dNdz (z));
635 double cosTheta,
double HeightObs) {
642 double HeightX, Xvert;
643 HeightX = zMin*
meter*cosTheta + HeightObs;
644 Xvert = depthProfile.
Y (HeightX);
645 double xMax = Xvert/cosTheta;
646 HeightX = zMax*
meter*cosTheta + HeightObs;
647 Xvert = depthProfile.
Y (HeightX);
648 double xMin = Xvert/cosTheta;
650 TProfile *hist =
new TProfile (
"lorenzo_dNdX",
651 "lorenzo model mu prod. height",
652 nBin, xMin/
g*
cm*
cm, xMax/
g*cm*cm);
653 double dz = (zMax-zMin)/nBin;
654 for (
double z = zMin; z<zMax; z+=dz) {
656 HeightX = z*
meter*cosTheta + HeightObs;
657 Xvert = depthProfile.
Y (HeightX);
658 double X = Xvert/cosTheta;
660 hist->Fill (X/
g*cm*cm,
dNdz (z));
669 double zMin = (*fMuonProductionHeightDistribution) [0].X();
670 double zMax = (*fMuonProductionHeightDistribution) [nBin-1].X();
671 TProfile *hist =
new TProfile (
"dNdz_prof",
"muon production height",
679 hist->Fill (x->X()/
meter, x->Y());
692 double zMin = (*fMuonProductionHeightDistribution) [0].X();
693 double zMax = (*fMuonProductionHeightDistribution) [nBin-1].X();
695 double HeightX, Xvert;
696 HeightX = zMin*
meter*cosTheta + HeightObs;
697 Xvert = depthProfile.
Y (HeightX);
698 double xMax = Xvert/cosTheta;
699 HeightX = zMax*
meter*cosTheta + HeightObs;
700 Xvert = depthProfile.
Y (HeightX);
701 double xMin = Xvert/cosTheta;
703 TProfile *hist =
new TProfile (
"dNdX_prof",
"charged profile",
704 nBin, xMin/
g*
cm*
cm, xMax/
g*cm*cm);
711 HeightX = x->X()*
meter*cosTheta + HeightObs;
712 Xvert = depthProfile.
Y (HeightX);
713 double X = Xvert/cosTheta;
715 hist->Fill (X/
g*cm*cm, x->Y());
728 return (exp(-0.5*e*e))/(
logSigma*2.50662827463100024);
741 return norm*exp(f1+f2)*TMath::Erfc(f3+f4)/(2*
logLambda);
753 if (z<fZmin || z>
fZmax)
769 double logz = log(z)/log(10.);
770 return 1/(z*log (10.))*
dNdlogz (logz);
787 return g_t(t[0],r[0],r[1],1);
792 double t=
pow(10,logt[0]);
793 return t*log(10.)*
g_t(t,r[0],r[1],1);
798 double t=
pow(10,logt[0]);
814 if (E<
pk*x || x<=0 || r>=x)
return 0;
820 double E=
pow(10.,logE);
821 return E*log(10.)*
dNdE(E,x,r);
826 return dNdlogE(logE[0],p[0],p[1]);
835 double x=
sqrt(z*z+r*r);
843 return e_t(t[0],r[0],r[1],r[2]);
849 double t=
pow(10.,logt[0]);
850 return t*log(10.)*
e_t(t,r[0],r[1],1);
854 double t=
pow(10,logt[0]);
867 Delta=r*cos(psi)*tan(TMath::DegToRad()*
angle);
936 if(t_i<t_first) t_first=t_i;
951 if(t_i<t_first) t_first=t_i;
979 if(t_i<t_first) t_first=t_i;
994 if(t_i>t_last) t_last=t_i;
1002 double t1sum=0,t1sum2=0,t1;
1004 for(
int i=0;i<
stats;i++)
1011 mean_t1= t1sum/
stats;
1012 RMS_t1=
sqrt(t1sum2/stats-mean_t1*mean_t1);
1046 double auxz=
Fe_logt->GetParameter(1);
1049 Fe_logt->SetParameter(1,auxz);
1062 double h=(tmax-tmin)/steps;
1064 double sum=0,t_i=tmin+h/2;
1066 for(
int i=0;i<N;i++)
1068 sum+=
g_t(t-t_i,r,Delta,1)*
e_t(t_i,r,
zMean-Delta,1);
1080 double t=
pow(10.,logt[0]);
1081 return t*log(10.)*
TotaldNdt(t,r[0],r[1],1);
1104 double f1=
function(xmin,level);
1105 double f2=
function(xmax,level);
1110 double x0=(x1+x2)/2;
1111 double f0=
function(x0,level);
1112 double epsilon= (x0-x1)/2;
1113 while (epsilon>=precision) {
1125 f0=
function(x0,level);
1130 printf(
"No hay zeros en el rango \n");
1131 return pow(10,xmin);
unsigned int GetNPoints() const
TProfile * Get_dNdX(float zMin, float zMax, int nBin, double cosTheta, double HeightObs)
double LinkTofTotaldNdlogt(double *x, double *p)
double fg_t(double *t, double *r)
double get_function_zero(double level)
double fe_t(double *t, double *r)
double fTotaldNdlogt(double *logt, double *r)
ArrayIterator XEnd()
end of array of X
Class to hold collection (x,y) points and provide interpolation between them.
double GetMomentumNumber()
double GetTimes(int N, double *at)
double E(double t, double x)
double fdNdlogE(double *logE, double *p)
double pow(const double x, const unsigned int i)
void MakeProductionHeightDistribution(double thetadeg, const utl::TabulatedFunction &MuonProfile, double XobsVertical)
void MakeProductionHeightParameters(double thetadeg, int primary)
dN/dlnz parametrisation
double GetLastTime(int N=1)
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
double ftMg_logt(double *logt, double *r)
TProfile * Get_dNdz(float zMin, float zMax, int nBin)
const atm::Atmosphere & GetAtmosphere() const
void GetFirstAndMeanTime(double &t_first, double &t_mean, int N=1)
double fg_logt(double *logt, double *r)
static const double precision
double TotaldNdt(double t, double r, double Delta, double n)
Class describing the Atmospheric profile.
double dEdt(double t, double x)
double abs(const SVector< n, T > &v)
TimeModel * gThisTimeModel
Top of the hierarchy of the detector description interface.
double GetMeanTime(int N=1)
double function(double logt, double level)
double LinkToftMe_logt(double *x, double *p)
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
double e_t(double t, double r, double z, double n)
double Get_tM_e_t(double MomentumNumber_in)
void ConvertProductionHeightDistribution(double thetadeg, const utl::TabulatedFunction &MuonProdProfile, double Xobs)
double GetFirstTime(int N=1)
double GetRiseTime(double down=0.1, double up=0.5)
double z_t(double t, double r)
TProfile * Get_dNdX_FromProfile(double cosTheta, double HeightObs)
bool fProductionHeightFromProfile
utl::TabulatedFunction * fMuonProductionHeightDistribution
double dNdlogE(double logE, double x, double r)
double LinkToftMg_logt(double *x, double *p)
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
double ftMe_logt(double *logt, double *r)
double cosaDa(double z, double r, double Delta)
void SetMomentumNumber(double MomentumNumber_in)
ArrayIterator XBegin()
begin of array of X
double LinkTofe_logt(double *x, double *p)
void GetMeanAndRMSOfFirstTime(double &mean_t1, double &RMS_t1, int N=1, int stats=1000)
double dzdt(double t, double r)
double dNdlogz(double logz)
double Get_tM_g_t(double MomentumNumber_in)
const atm::ProfileResult & EvaluateHeightVsDepth() const
Tabulated function giving Y=height as a function of X=depth.
double g_t(double t, double r, double Delta, double n)
TProfile * Get_dNdz_FromProfile()
double Eval_e_t(double t)
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
double fe_logt(double *logt, double *r)
double L_t(double z, double r)
double dNdE(double E, double x, double r)
double LinkTofg_logt(double *x, double *p)
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
double SetCoordinates(double r, double psi)
TimeModel(double angle_in, int primary, int Da_flag_in=1)