TimeModel.cc
Go to the documentation of this file.
1 #include "TimeModel.h"
2 #include "TMath.h"
3 #include <TProfile.h>
4 
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>
10 using namespace utl;
11 
12 #include <det/Detector.h>
13 
14 #include <evt/ShowerSimData.h>
15 using namespace evt;
16 
17 #include <atm/Atmosphere.h>
18 #include <atm/ProfileResult.h>
19 using namespace atm;
20 
21 #include <vector>
22 using namespace std;
23 
24 
25 
27 
28 
29 double LinkTofe_logt(double *x,double *p) {
30  return gThisTimeModel->fe_logt(x,p);
31 }
32 
33 double LinkToftMe_logt(double *x,double *p) {
34  return gThisTimeModel->ftMe_logt(x,p);
35 }
36 
37 double LinkTofg_logt(double *x,double *p) {
38  return gThisTimeModel->fg_logt(x,p);
39 }
40 
41 double LinkToftMg_logt(double *x,double *p) {
42  return gThisTimeModel->ftMg_logt(x,p);
43 }
44 
45 double LinkTofTotaldNdlogt(double *x,double *p) {
46  return gThisTimeModel->fTotaldNdlogt(x,p);
47 }
48 
49 
50 
51 TimeModel::TimeModel (double angle_in, // in deg
52  int primary, // 0:photon, 1:proton, 2: iron
53  int Da_flag_in) : // volume detector: 1 flat: 0
54  fMuonProductionHeightDistribution (0) {
55 
56  gThisTimeModel=this;
57 
58  Da_flag=Da_flag_in;
59 
60  /* Model Constants */
61  m=0.105;
62  m2=0.011;
63  pk=0.0002;
64  kappa=0.8;
65  lambda=1;
66  ptc=0.17;
67  gam=2.6;
68  c=0.2997924580;
69 
70  logt_e_up=3.23;
71  /*********************/
73 
74 
75  angle = angle_in; // in degrees
76  fProductionHeightFromProfile = false; // use parameters
77  MakeProductionHeightParameters (angle, primary /*,logE*/);
78 
79  zMean = pow (10,logMean);
80 
81 
82  char nome[100];
83  sprintf(nome,"e_logt_%.1f",angle);
84  Fe_logt=new TF1(nome,LinkTofe_logt,-6.,5.,2);
85 
86  sprintf(nome,"tMe_logt_%.1f",angle);
87  FtMe_logt=new TF1(nome,LinkToftMe_logt,-6.,5.,2);
88 
89  sprintf(nome,"g_logt_%.1f",angle);
90  Fg_logt=new TF1(nome,LinkTofg_logt,-4.,6.,2);
91 
92  sprintf(nome,"tMg_logt_%.1f",angle);
93  FtMg_logt=new TF1(nome,LinkToftMg_logt,-4.,6.,2);
94 
95  sprintf(nome,"TotaldNdlogt_%.1f",angle);
96  FTotaldNdlogt=new TF1(nome,LinkTofTotaldNdlogt,-4.,6.,3);
97 
98 }
99 
100 
101 TimeModel::TimeModel (double angle_in, // in deg
102  const utl::TabulatedFunction& MuonProfile,
103  double XobsVertical,
105  int Da_flag_in) :
106  fMuonProductionHeightDistribution (0) {
107 
108 
109  gThisTimeModel=this;
110 
112  if (profType == evt::ShowerSimData::eMuon) {
113 
115  MuonProfile,
116  XobsVertical);
117 
118  } else {
119 
121  MuonProfile,
122  XobsVertical);
123 
124  }
125 
126  Da_flag=Da_flag_in;
127 
128  /* Model Constants */
129  m=0.105;
130  m2=0.011;
131  pk=0.0002;
132  kappa=0.8;
133  lambda=1;
134  ptc=0.17;
135  gam=2.6;
136  c=0.2997924580;
137 
138  logt_e_up=3.23;
139  /*********************/
140  MomentumNumber=1;
141 
142 
143  angle = angle_in; // in degrees
144 
145  zMean = pow(10,logMean);
146 
147 
148 
149  char nome[100];
150  sprintf(nome,"e_logt_%.1f",angle);
151  Fe_logt=new TF1(nome,LinkTofe_logt,-6.,5.,2);
152 
153  sprintf(nome,"tMe_logt_%.1f",angle);
154  FtMe_logt=new TF1(nome,LinkToftMe_logt,-6.,5.,2);
155 
156  sprintf(nome,"g_logt_%.1f",angle);
157  Fg_logt=new TF1(nome,LinkTofg_logt,-4.,6.,2);
158 
159  sprintf(nome,"tMg_logt_%.1f",angle);
160  FtMg_logt=new TF1(nome,LinkToftMg_logt,-4.,6.,2);
161 
162  sprintf(nome,"TotaldNdlogt_%.1f",angle);
163  FTotaldNdlogt=new TF1(nome,LinkTofTotaldNdlogt,-4.,6.,3);
164 
165 }
166 
167 
168 
170 
171  gThisTimeModel=this;
172 
173  delete Fe_logt;
174  delete FtMe_logt;
175  delete Fg_logt;
176  delete FtMg_logt;
177 
178  delete FTotaldNdlogt;
179 
181 }
182 
183 
184 
185 
186 void TimeModel::Info(void) {
187 
188  gThisTimeModel=this;
189 
190  printf("\n");
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");
208  if(Da_flag==1)
209  printf("* D(a)=1 *\n"); else
210  printf("* D(a)=cos(a)+Delta/L *\n");
211  printf("*******************************\n");
212  /*
213  printf("*******************************\n");
214  printf("* COORDINATES *\n");
215  printf("*******************************\n");
216  printf("* r %10.1f m *\n",r);
217  printf("* psi %5.1f deg *\n",psi);
218  printf("*******************************\n");
219  */
220 
221 }
222 
223 
224 
225 
226 
227 
228 
244  int primary /*,
245  double logE*/) {
246 
247  double c = cos (thetadeg*TMath::DegToRad());
248 
249  switch (primary) {
250 
251  case 0:
252 
253  logMean=
254  +5.712
255  -6.815 *c
256  +13.82 *c*c
257  -15.28 *c*c*c
258  +6.124 *c*c*c*c;
259 
260  logSigma=
261  +0.01546
262  +0.594 *c
263  -1.499 *c*c
264  +1.000 *c*c*c
265  -1.571 *c*c*c*c
266  -1.496 *c*c*c*c*c;
267  /*
268  Norm=
269  -6.79e5
270  +1.81e7 *c
271  -9.30e7 *c*c
272  +2.18e8 *c*c*c
273  -1.33e8 *c*c*c*c;
274  */
275  logLambda=
276  -0.198
277  +2.82 *c
278  -19.25 *c*c
279  +54.26 *c*c*c
280  -57.43 *c*c*c*c
281  -20.61 *c*c*c*c*c;
282  break;
283 
284 
285 
286  case 1:
287 
288  logMean=
289  +5.682
290  -5.524 *c
291  +9.180 *c*c
292  -8.277 *c*c*c
293  +2.797 *c*c*c*c;
294 
295  logSigma=
296  +0.03266
297  +0.456 *c
298  -1.084 *c*c
299  +1.199 *c*c*c
300  -0.4366 *c*c*c*c;
301  /*
302  Norm=
303  -3.673E5
304  +4.467E7 *c
305  -9.47E7 *c*c
306  +2.917E8 *c*c*c
307  -1.781E8 *c*c*c*c;
308  */
309  logLambda=
310  -0.01111
311  +0.2581 *c
312  -0.7385 *c*c
313  +3.362 *c*c*c
314  -2.261 *c*c*c*c;
315  break;
316 
317 
318  case 2:
319 
320  logMean=
321  +5.692
322  -5.490 *c
323  +9.147 *c*c
324  -8.228 *c*c*c
325  +2.782 *c*c*c*c;
326 
327  logSigma=
328  +0.03432
329  +0.457 *c
330  -1.028 *c*c
331  +1.047 *c*c*c
332  -0.3476 *c*c*c*c;
333  /*
334  Norm=
335  -6.72e4
336  +5.23e7 *c
337  -8.03e7 *c*c
338  +2.82e8 *c*c*c
339  -1.71e8 *c*c*c*c;
340  */
341  logLambda=
342  -0.00579
343  +0.154 *c
344  -0.239 *c*c
345  +2.292 *c*c*c
346  -1.626 *c*c*c*c;
347  break;
348  }
349 
350 
351  if (logLambda<0.03)
352  logLambda = 0.03;
353 
354 }
355 
356 
357 
358 
359 
361  const utl::TabulatedFunction& MuonProfile,
362  double Xobs) { // vert. depth
363 
364 
365  double cosTheta = cos (thetadeg*deg);
366 
367  // convert X (slant depth) to z / m
368  // taking care of earth curvature
369  det::Detector& Det = det::Detector::GetInstance();
370 
371  const ProfileResult heightProfile
373  const ProfileResult depthProfile
375 
376  double HeightXobs = heightProfile.Y (Xobs);
377 
378  vector <double> ValueZ;
379  vector <double> ValuedNdZ;
380 
381  double AtmDepthMin = depthProfile.Y (depthProfile.MaxX());
382  double AtmDepthMax = depthProfile.Y (depthProfile.MinX());
383 
384  logMean = 0;
385  double Norm = 0;
386 
387  bool First = true;
388  double z_old = 0, HeightX_old = 0, Nmu_old = 0;
389  for (TabulatedFunction::ConstIterator iProfile = MuonProfile.Begin();
390  iProfile != MuonProfile.End();
391  ++iProfile) {
392 
393  double Nmu = iProfile->Y();
394  double Xslant = iProfile->X();
395  double Xvert = Xslant*cosTheta;
396 
397  if (Xvert<AtmDepthMin || Xvert>AtmDepthMax)
398  continue;
399 
400  double HeightX = heightProfile.Y (Xvert);
401  double z = (HeightX-HeightXobs)/cosTheta/meter;
402 
403  // only look at shower not before
404  if (Nmu==0) {
405  continue;
406  }
407 
408  /*
409  // only look above the ground
410  if (z<-1000) {
411  continue;
412  }
413  */
414 
415  // first bin is for init only
416  if (First) {
417 
418  First = false;
419 
420  z_old = z;
421  HeightX_old = HeightX;
422  Nmu_old = Nmu;
423 
424  fZmax = 0;
425  fZmin = z;
426  continue;
427  }
428 
429  double dz = z - z_old;
430  double dN = Nmu_old - Nmu;
431  double zMean = (z_old + z) / 2.;
432 
433  if (zMean>0) {
434  logMean += log10 (zMean) * (Nmu+Nmu_old)/2.;
435  Norm += (Nmu+Nmu_old)/2.;
436  }
437 
438  ValueZ.insert (ValueZ.begin(), zMean);
439  ValuedNdZ.insert (ValuedNdZ.begin(), dN/dz);
440 
441  if (zMean<fZmin) fZmin = zMean;
442  if (zMean>fZmax) fZmax = zMean;
443 
444  z_old = z;
445  HeightX_old = HeightX;
446  Nmu_old = Nmu;
447  }
448 
450  = new TabulatedFunction (ValueZ, ValuedNdZ);
451 
452 
455 
456 
457  /*
458  int n=ValueZ.size();
459  for (int i=0; i<n; i++) {
460  cout << " B> " << ValueZ [i] << " " << ValuedNdZ[i] << endl;
461  }
462  */
463 
464  ValueZ.clear();
465  ValuedNdZ.clear();
466 
467  logMean /= Norm;
468 }
469 
470 
471 
472 
473 
475  const utl::TabulatedFunction& MuonProdProfile,
476  double Xobs) { // vert. depth
477 
478 
479  double cosTheta = cos (thetadeg*deg);
480 
481  // convert X (slant depth) to z / m
482  // taking care of earth curvature
483  det::Detector& Det = det::Detector::GetInstance();
484 
485  const ProfileResult heightProfile
487  const ProfileResult depthProfile
489 
490  double HeightXobs = heightProfile.Y (Xobs);
491 
492  vector <double> ValueZ;
493  vector <double> ValuedNdZ;
494 
495  double AtmDepthMin = depthProfile.Y (depthProfile.MaxX());
496  double AtmDepthMax = depthProfile.Y (depthProfile.MinX());
497 
498  logMean = 0;
499  double Norm = 0;
500 
501  double dXslant = abs (MuonProdProfile[1].X() - MuonProdProfile[0].X());
502  double dXvert = dXslant * cosTheta;
503 
504  for (TabulatedFunction::ConstIterator iProfile = MuonProdProfile.Begin();
505  iProfile != MuonProdProfile.End();
506  ++iProfile) {
507 
508  double nDmu = iProfile->Y();
509  double Xslant = iProfile->X();
510  double Xvert = Xslant*cosTheta;
511 
512 
513  if (Xvert-dXvert/2<AtmDepthMin || Xvert+dXvert/2>AtmDepthMax)
514  continue;
515 
516  double Height = heightProfile.Y (Xvert);
517  double z = (Height-HeightXobs)/cosTheta/meter;
518 
519  double Height1 = heightProfile.Y (Xvert-dXvert/2);
520  double z1 = (Height1-HeightXobs)/cosTheta/meter;
521 
522  double Height2 = heightProfile.Y (Xvert+dXvert/2);
523  double z2 = (Height2-HeightXobs)/cosTheta/meter;
524 
525  double dz = abs (z1-z2);
526 
527  // only look at shower not before
528  if (nDmu==0) {
529  continue;
530  }
531 
532  if (z>0) {
533  logMean += log10 (z) * (nDmu);
534  Norm += (nDmu);
535  }
536 
537  ValueZ.insert (ValueZ.begin(), z);
538  ValuedNdZ.insert (ValuedNdZ.begin(), nDmu*dXslant/dz);
539 
540  if (z<fZmin) fZmin = z;
541  if (z>fZmax) fZmax = z;
542 
543  }
544 
546  = new TabulatedFunction (ValueZ, ValuedNdZ);
547 
550 
551  /*
552  int n=ValueZ.size();
553  for (int i=0; i<n; i++) {
554  cout << " B> " << ValueZ [i] << " " << ValuedNdZ[i] << endl;
555  }
556  */
557 
558  ValueZ.clear();
559  ValuedNdZ.clear();
560 
561  logMean /= Norm;
562 }
563 
564 
565 
566 
567  double TimeModel::L_t(double z,double r)
568 {
569  return sqrt(z*z+r*r);
570 }
571 
572 
573  double TimeModel::cosaDa(double Z,double r,double Delta)
574 {
575  if (Z<0) return 0;
576  // isto permite muons back!?
577  double L=L_t(Z,r);
578  double cosa2=1-(r*r)/(L*L);
579 
580  if (Da_flag==1) return sqrt(cosa2);
581 
582  double ret=cosa2+Delta/L*sqrt(cosa2);
583 
584  return ret;
585 
586 }
587 
588 double TimeModel::z_t(double t,double r)
589 {
590  return 0.5*(r*r/(c*t)-c*t);
591 }
592 
593 double TimeModel::dzdt(double t,double r)
594 {
595  return 0.5*(r*r/(c*t*t)+c);
596 }
597 
598 
599 // RU Wed May 18 12:15:06 CEST 2005
600 // to get some plots
601 TProfile *TimeModel::Get_dNdz (float zMin, float zMax, int nBin) {
602  /*
603  LOG scale
604 
605  if (zMin<=0) zMin = 1e0;
606  double logZmin = log10 (zMin);
607  double logZmax = log10 (zMax);
608 
609  TProfile *hist = new TProfile ("lorenzo_dNdz",
610  "lorenzo model mu prod. height",
611  nBin, logZmin, logZmax);
612 
613  double dz = (logZmax-logZmin)/nBin;
614  for (double z = logZmin; z<logZmax; z+=dz) {
615 
616  hist->Fill (z+dz/2, dNdlogz (z));
617  }
618  */
619 
620  TProfile *hist = new TProfile ("lorenzo_dNdz",
621  "lorenzo model mu prod. height",
622  nBin, zMin, zMax);
623 
624  double dz = (zMax-zMin)/nBin;
625  for (double z = zMin; z<zMax; z+=dz) {
626 
627  hist->Fill (z+dz/2, dNdz (z));
628  }
629 
630  return hist;
631 }
632 
633 
634 TProfile *TimeModel::Get_dNdX (float zMin, float zMax, int nBin,
635  double cosTheta, double HeightObs) {
636 
637  det::Detector& Det = det::Detector::GetInstance();
638 
639  const ProfileResult depthProfile =
641 
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;
649 
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) {
655 
656  HeightX = z*meter*cosTheta + HeightObs;
657  Xvert = depthProfile.Y (HeightX);
658  double X = Xvert/cosTheta;
659 
660  hist->Fill (X/g*cm*cm, dNdz (z));
661  }
662 
663  return hist;
664 }
665 
667 
669  double zMin = (*fMuonProductionHeightDistribution) [0].X();
670  double zMax = (*fMuonProductionHeightDistribution) [nBin-1].X();
671  TProfile *hist = new TProfile ("dNdz_prof", "muon production height",
672  nBin, zMin, zMax);
673 
677  ++x) {
678 
679  hist->Fill (x->X()/meter, x->Y());
680  }
681 
682  return hist;
683 }
684 
685 TProfile *TimeModel::Get_dNdX_FromProfile (double cosTheta, double HeightObs) {
686 
687  det::Detector& Det = det::Detector::GetInstance();
688  const ProfileResult depthProfile =
690 
692  double zMin = (*fMuonProductionHeightDistribution) [0].X();
693  double zMax = (*fMuonProductionHeightDistribution) [nBin-1].X();
694 
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;
702 
703  TProfile *hist = new TProfile ("dNdX_prof", "charged profile",
704  nBin, xMin/g*cm*cm, xMax/g*cm*cm);
705 
709  ++x) {
710 
711  HeightX = x->X()*meter*cosTheta + HeightObs;
712  Xvert = depthProfile.Y (HeightX);
713  double X = Xvert/cosTheta;
714 
715  hist->Fill (X/g*cm*cm, x->Y());
716  }
717 
718  return hist;
719 }
720 // RU --------------------
721 
722 
723 double TimeModel::dNdlogz(double logz)
724 {
725  if(logLambda<=0)
726  {
727  double e=(logz-logMean)/logSigma;
728  return (exp(-0.5*e*e))/(logSigma*2.50662827463100024);
729  }
730  else
731  { // a nova parametrizacion incluida na tese
732  // estan definidos desde fora
733  double norm=1;
734  double s2=sqrt(2.);
735 
736  double f1=(logz-logMean)/logLambda;
737  double f2=.5*(logSigma*logSigma)/(logLambda*logLambda);
738  double f3=(logz-logMean)/(s2*logSigma);
739  double f4=logSigma/(s2*logLambda);
740 
741  return norm*exp(f1+f2)*TMath::Erfc(f3+f4)/(2*logLambda);
742 
743  }
744 }
745 
746 double TimeModel::dNdz (double z) {
747 
748  if(z<0)
749  return 0;
750 
751  if (fProductionHeightFromProfile) { // from dN/dLog10z profile
752 
753  if (z<fZmin || z>fZmax)
754  return 0.;
755 
756  //cout << " z " << z << " " << fZmin << " " << fZmax << endl;
757 
758  double value = fMuonProductionHeightDistribution->Y (z);
759 
760  // don't look at decaying muon (at least if they are outnumbering
761  // the muon-production (!) and dN/dz<0
762  if (value<0)
763  value = 0;
764 
765  return value;
766 
767  } else { // from dN/dlog10z parametrisation
768 
769  double logz = log(z)/log(10.);
770  return 1/(z*log (10.))*dNdlogz (logz);
771  }
772 }
773 
774 
775 double TimeModel::g_t(double t,double r,double Delta,double n)
776 {
777  double Z=z_t(t,r);
778  if(t<=0)
779  return 0; /* || z<=0) antiguo*/
780  else
781  return n*cosaDa(Z,r,Delta)*dNdz(Z+Delta)*dzdt(t,r);
782  //dzdt=dZdt
783 }
784 
785 double TimeModel::fg_t(double *t,double *r)
786 {
787  return g_t(t[0],r[0],r[1],1);
788 }
789 
790 double TimeModel::fg_logt(double *logt,double *r)
791 {
792  double t=pow(10,logt[0]);
793  return t*log(10.)*g_t(t,r[0],r[1],1);
794 
795 }
796 double TimeModel::ftMg_logt(double *logt,double *r)
797 {
798  double t=pow(10,logt[0]);
799  return pow(t,MomentumNumber)*t*log(10.)*g_t(t,r[0],r[1],1);
800 }
801 
802 
803 double TimeModel::E(double t,double x)
804 {
805  return 0.5*pk*x*(1+sqrt(1+2*m2/(pk*pk*x*c*t)));
806 }
807 double TimeModel::dEdt(double t,double x)
808 {
809  return 0.5*pk*x*1/sqrt(1+2*m2/(pk*pk*x*c*t))*m2/(pk*pk*x*c*t*t);
810 }
811 
812 double TimeModel::dNdE(double E,double x,double r)
813 {
814  if (E<pk*x || x<=0 || r>=x) return 0; // os dous ultimos xa non poden ser por construccion
815  return (1-r*r/(x*x))*pow(r/x,lambda)*pow(E,-gam-kappa+lambda+1)*pow(E-pk*x,kappa)*exp(-E*r/(x*ptc));
816 }
817 
818 double TimeModel::dNdlogE(double logE,double x,double r)
819 {
820  double E=pow(10.,logE);
821  return E*log(10.)*dNdE(E,x,r);
822 }
823 
824 double TimeModel::fdNdlogE(double *logE,double *p)
825 {
826  return dNdlogE(logE[0],p[0],p[1]);
827 }
828 
829 double TimeModel::e_t(double t,double r,double z,double n)
830 {
831 
832  if(t<=0) return 0;
833  else
834  {
835  double x=sqrt(z*z+r*r);
836  return n*dNdE(E(t,x),x,r)*dEdt(t,x);
837  }
838 
839 }
840 
841 double TimeModel::fe_t(double *t,double *r)
842 {
843  return e_t(t[0],r[0],r[1],r[2]);
844 }
845 
846 
847  double TimeModel::fe_logt(double *logt,double *r)
848 {
849  double t=pow(10.,logt[0]);
850  return t*log(10.)*e_t(t,r[0],r[1],1);
851 }
852  double TimeModel::ftMe_logt(double *logt,double *r)
853 {
854  double t=pow(10,logt[0]);
855  return pow(t,MomentumNumber)*t*log(10.)*e_t(t,r[0],r[1],1);
856 
857 }
858 
859 
860 
861 
862 
863 double TimeModel::SetCoordinates(double r,double psi)//psi rad
864 {
865  gThisTimeModel=this;
866 
867  Delta=r*cos(psi)*tan(TMath::DegToRad()*angle);
868 
869  Fe_logt->SetParameter(0,r);
870  Fe_logt->SetParameter(1,zMean-Delta);
871  FtMe_logt->SetParameter(0,r);
872  FtMe_logt->SetParameter(1,zMean-Delta);
873 
874  Fg_logt->SetParameter(0,r);
875  Fg_logt->SetParameter(1,Delta);
876  FtMg_logt->SetParameter(0,r);
877  FtMg_logt->SetParameter(1,Delta);
878 
879  FTotaldNdlogt->SetParameter(0,r);
880  FTotaldNdlogt->SetParameter(1,Delta);
881  FTotaldNdlogt->SetParameter(2,1);
882 
883 
884  double Integral;
885 
886  double LZ=(pow(10,logMean)-Delta);
887 
888 
889  logt_g_up=log10(8000*(sqrt(r*r+LZ*LZ)-LZ)); /* limite superior, para estar seguro*/
890  logt_g_low=log10(0.2*(sqrt(r*r+LZ*LZ)-LZ)); /* limite superior, para estar seguro*/
891 
892  {
893 
894  Integral=Fg_logt->Integral(logt_g_low,logt_g_up);
895 
896  // if (Integral>.9) break;
897 
898 
899  }
900 
901 
902  Fg_logt->SetRange(logt_g_low,logt_g_up);
904 
905  // printf("Draw()!!\n");
906  // Fg_logt->Draw();
907 
908 
909 
910  int_e=Fe_logt->Integral(-6,logt_e_up,(double *)NULL,0.0000001);
911  int_g=Fg_logt->Integral(logt_g_low,logt_g_up,(double *)NULL,0.0000001);
912 
913 
914  return Integral;
915 
916  }
917 
918 void TimeModel::SetMomentumNumber(double MomentumNumber_in)
919 {
920  MomentumNumber=MomentumNumber_in;
921 }
922 
924 {
925  return MomentumNumber;
926 }
927 
928 double TimeModel::GetFirstTime(int N/*=1*/)
929  {
930  gThisTimeModel=this;
931  double t_first=1e25;
932  double t_i;
933  for(int i=0;i<N;i++)
934  {
935  t_i=pow(10,Fg_logt->GetRandom())+pow(10,Fe_logt->GetRandom());
936  if(t_i<t_first) t_first=t_i;
937  }
938 
939  return t_first-Delta/c;
940  }
941 
942  double TimeModel::GetTimes(int N,double *at)
943  {
944  gThisTimeModel=this;
945  double t_first=1e25;
946  double t_i;
947  for(int i=0;i<N;i++)
948  {
949  t_i=pow(10,Fg_logt->GetRandom())+pow(10,Fe_logt->GetRandom());
950  at[i]=t_i-Delta/c;
951  if(t_i<t_first) t_first=t_i;
952  }
953 
954  return t_first-Delta/c;
955  }
956 
957 
958 double TimeModel::GetMeanTime(int N/*=1*/)
959  {
960  gThisTimeModel=this;
961  double t_mean=0;
962  for(int i=0;i<N;i++)
963  {
964  t_mean+=pow(10,Fg_logt->GetRandom())+pow(10,Fe_logt->GetRandom());
965 
966  }
967  return t_mean/N-Delta/c;
968  }
969 
970 void TimeModel::GetFirstAndMeanTime(double& t_first,double& t_mean,int N/*=1*/)
971  {
972  gThisTimeModel=this;
973  double t_i;
974  t_mean=0;
975  t_first=1e25;
976  for(int i=0;i<N;i++)
977  {
978  t_i=pow(10,Fg_logt->GetRandom())+pow(10,Fe_logt->GetRandom());
979  if(t_i<t_first) t_first=t_i;
980  t_mean+=t_i;
981  }
982  t_first-=Delta/c;
983  t_mean=t_mean/N-Delta/c;
984 
985  }
986 double TimeModel::GetLastTime(int N/*=1*/)
987  {
988  gThisTimeModel=this;
989  double t_last=0;
990  double t_i;
991  for(int i=0;i<N;i++)
992  {
993  t_i=pow(10,Fg_logt->GetRandom())+pow(10,Fe_logt->GetRandom());
994  if(t_i>t_last) t_last=t_i;
995  }
996  return t_last-Delta/c;
997  }
998 
999 void TimeModel::GetMeanAndRMSOfFirstTime(double& mean_t1,double& RMS_t1,int N/*=1*/,int stats/*=1000*/)
1000  {
1001  gThisTimeModel=this;
1002  double t1sum=0,t1sum2=0,t1;
1003 
1004  for(int i=0;i<stats;i++)
1005  {
1006  t1=GetFirstTime(N);
1007  t1sum+=t1;
1008  t1sum2+=t1*t1;
1009  }
1010 
1011  mean_t1= t1sum/stats;
1012  RMS_t1=sqrt(t1sum2/stats-mean_t1*mean_t1);
1013 
1014  }
1016 {
1017  gThisTimeModel=this;
1018  return Delta/c;
1019 }
1020 double TimeModel::Eval_e_t(double t)
1021 {
1022  gThisTimeModel=this;
1023  return e_t(t,Fe_logt->GetParameter(0),zMean-Delta,1);
1024 }
1025 
1026 double TimeModel::Get_tM_g_t(double MomentumNumber_in)
1027 {
1028  gThisTimeModel=this;
1029  MomentumNumber=MomentumNumber_in;
1030  return FtMg_logt->Integral(logt_g_low,logt_g_up,(double *)NULL,0.0000001)/int_g;
1031 
1032 }
1033 
1034 double TimeModel::Get_tM_e_t(double MomentumNumber_in)
1035 {
1036  gThisTimeModel=this;
1037  MomentumNumber=MomentumNumber_in;
1038  return FtMe_logt->Integral(-6,logt_e_up,(double *)NULL,0.0000001)/int_e;
1039 }
1040 
1041 
1042 double TimeModel::Get_tM_e_t(double MomentumNumber_in,double z)
1043 {
1044  gThisTimeModel=this;
1045  MomentumNumber=MomentumNumber_in;
1046  double auxz=Fe_logt->GetParameter(1);
1047  Fe_logt->SetParameter(1,z-Delta);
1048  double ret=FtMe_logt->Integral(-6,logt_e_up,(double *)NULL,0.0000001)/int_e;
1049  Fe_logt->SetParameter(1,auxz);
1050  return ret;
1051 }
1052 
1053 double TimeModel::TotaldNdt(double t,double r,double Delta, double n)
1054 {
1055 double steps=850;
1056 double tmin=0;
1057  double tmax=1700;
1058 
1059 
1060  if (t<tmax) tmax=t;
1061 
1062  double h=(tmax-tmin)/steps;
1063  int N=int(steps);
1064  double sum=0,t_i=tmin+h/2;
1065 
1066  for(int i=0;i<N;i++)
1067  {
1068  sum+=g_t(t-t_i,r,Delta,1)*e_t(t_i,r,zMean-Delta,1);
1069  t_i+=h;
1070  }
1071 
1072  return n*sum*h;
1073 
1074 
1075 }
1076 
1077 double TimeModel::fTotaldNdlogt(double *logt,double *r)
1078 {
1079 
1080  double t=pow(10.,logt[0]);
1081  return t*log(10.)*TotaldNdt(t,r[0],r[1],1);
1082 }
1083 
1084 double TimeModel::function(double logt,double level)
1085 {
1086 
1087 
1088 
1089 /*
1090  double integral=Fg_logt->Integral(logtd,logt);
1091  return integral/(int_g) - level;
1092 */
1093 
1094  double integral=FTotaldNdlogt->Integral(logt_g_low,logt);
1095  return integral/(int_g*int_e) - level;
1096 
1097 }
1098 
1099 double TimeModel::get_function_zero(double level)
1100 {
1101  double xmin=logt_g_low;
1102  double xmax=logt_g_up;
1103  double precision=1.e-4;
1104  double f1=function(xmin,level);
1105  double f2=function(xmax,level);
1106  double x1=xmin;
1107  double x2=xmax;
1108 
1109  if (f1*f2<0) {
1110  double x0=(x1+x2)/2;
1111  double f0=function(x0,level);
1112  double epsilon= (x0-x1)/2;
1113  while (epsilon>=precision) {
1114  if (f1*f0<0) {
1115  x2=x0;
1116  f2=f0;
1117  }
1118  else
1119  {
1120  x1=x0;
1121  f1=f0;
1122  }
1123  epsilon= (x2-x1)/2;
1124  x0=(x1+x2)/2;
1125  f0=function(x0,level);
1126  }
1127 
1128  }
1129  else {
1130  printf("No hay zeros en el rango \n");
1131  return pow(10,xmin);
1132  }
1133 // printf("level %.1f time=%.1f\n",level,pow(10,x1));
1134  return pow(10,x1);
1135 }
1136 
1137 
1138 double TimeModel::GetRiseTime(double down,double up)
1139 {
1140  return (get_function_zero(up)-get_function_zero(down));
1141 }
void Info(void)
Definition: TimeModel.cc:186
double pk
Definition: TimeModel.h:56
double angle
Definition: TimeModel.h:67
unsigned int GetNPoints() const
TProfile * Get_dNdX(float zMin, float zMax, int nBin, double cosTheta, double HeightObs)
Definition: TimeModel.cc:634
double fZmin
Definition: TimeModel.h:51
double int_g
Definition: TimeModel.h:77
double LinkTofTotaldNdlogt(double *x, double *p)
Definition: TimeModel.cc:45
double MomentumNumber
Definition: TimeModel.h:75
double fg_t(double *t, double *r)
Definition: TimeModel.cc:785
double get_function_zero(double level)
Definition: TimeModel.cc:1099
double Delta
Definition: TimeModel.h:73
double fe_t(double *t, double *r)
Definition: TimeModel.cc:841
double fZmax
Definition: TimeModel.h:52
int Da_flag
Definition: TimeModel.h:79
double ptc
Definition: TimeModel.h:59
double dNdz(double z)
Definition: TimeModel.cc:746
double fTotaldNdlogt(double *logt, double *r)
Definition: TimeModel.cc:1077
ArrayIterator XEnd()
end of array of X
double c
Definition: TimeModel.h:61
Class to hold collection (x,y) points and provide interpolation between them.
TF1 * FtMg_logt
Definition: TimeModel.h:118
double GetMomentumNumber()
Definition: TimeModel.cc:923
double GetTimes(int N, double *at)
Definition: TimeModel.cc:942
TF1 * FtMe_logt
Definition: TimeModel.h:116
const double meter
Definition: GalacticUnits.h:29
double E(double t, double x)
Definition: TimeModel.cc:803
double m
Definition: TimeModel.h:54
double fdNdlogE(double *logE, double *p)
Definition: TimeModel.cc:824
double pow(const double x, const unsigned int i)
void MakeProductionHeightDistribution(double thetadeg, const utl::TabulatedFunction &MuonProfile, double XobsVertical)
Definition: TimeModel.cc:360
double logt_g_up
Definition: TimeModel.h:70
void MakeProductionHeightParameters(double thetadeg, int primary)
dN/dlnz parametrisation
Definition: TimeModel.cc:243
double GetLastTime(int N=1)
Definition: TimeModel.cc:986
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
double ftMg_logt(double *logt, double *r)
Definition: TimeModel.cc:796
constexpr double deg
Definition: AugerUnits.h:140
TF1 * Fe_logt
Definition: TimeModel.h:115
TProfile * Get_dNdz(float zMin, float zMax, int nBin)
Definition: TimeModel.cc:601
const atm::Atmosphere & GetAtmosphere() const
Definition: Detector.h:113
void GetFirstAndMeanTime(double &t_first, double &t_mean, int N=1)
Definition: TimeModel.cc:970
double fg_logt(double *logt, double *r)
Definition: TimeModel.cc:790
static const double precision
double TotaldNdt(double t, double r, double Delta, double n)
Definition: TimeModel.cc:1053
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
double dEdt(double t, double x)
Definition: TimeModel.cc:807
double kappa
Definition: TimeModel.h:57
TF1 * Fg_logt
Definition: TimeModel.h:117
double abs(const SVector< n, T > &v)
TimeModel * gThisTimeModel
Definition: TimeModel.cc:26
double logt_g_low
Definition: TimeModel.h:71
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
double GetMeanTime(int N=1)
Definition: TimeModel.cc:958
double function(double logt, double level)
Definition: TimeModel.cc:1084
double LinkToftMe_logt(double *x, double *p)
Definition: TimeModel.cc:33
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)
Definition: TimeModel.cc:829
double Get_tM_e_t(double MomentumNumber_in)
Definition: TimeModel.cc:1034
double logMean
Definition: TimeModel.h:64
constexpr double g
Definition: AugerUnits.h:200
double lambda
Definition: TimeModel.h:58
void ConvertProductionHeightDistribution(double thetadeg, const utl::TabulatedFunction &MuonProdProfile, double Xobs)
Definition: TimeModel.cc:474
double GetFirstTime(int N=1)
Definition: TimeModel.cc:928
double GetRiseTime(double down=0.1, double up=0.5)
Definition: TimeModel.cc:1138
double logSigma
Definition: TimeModel.h:65
double gam
Definition: TimeModel.h:60
double z_t(double t, double r)
Definition: TimeModel.cc:588
TProfile * Get_dNdX_FromProfile(double cosTheta, double HeightObs)
Definition: TimeModel.cc:685
double logt_e_up
Definition: TimeModel.h:62
bool fProductionHeightFromProfile
Definition: TimeModel.h:49
TF1 * FTotaldNdlogt
Definition: TimeModel.h:119
utl::TabulatedFunction * fMuonProductionHeightDistribution
Definition: TimeModel.h:50
double dNdlogE(double logE, double x, double r)
Definition: TimeModel.cc:818
double LinkToftMg_logt(double *x, double *p)
Definition: TimeModel.cc:41
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
double ftMe_logt(double *logt, double *r)
Definition: TimeModel.cc:852
double cosaDa(double z, double r, double Delta)
Definition: TimeModel.cc:573
double norm(utl::Vector x)
void SetMomentumNumber(double MomentumNumber_in)
Definition: TimeModel.cc:918
ArrayIterator XBegin()
begin of array of X
constexpr double cm
Definition: AugerUnits.h:117
double LinkTofe_logt(double *x, double *p)
Definition: TimeModel.cc:29
void GetMeanAndRMSOfFirstTime(double &mean_t1, double &RMS_t1, int N=1, int stats=1000)
Definition: TimeModel.cc:999
double int_e
Definition: TimeModel.h:76
double dzdt(double t, double r)
Definition: TimeModel.cc:593
double dNdlogz(double logz)
Definition: TimeModel.cc:723
double Get_tM_g_t(double MomentumNumber_in)
Definition: TimeModel.cc:1026
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)
Definition: TimeModel.cc:775
double GetDeltaTime()
Definition: TimeModel.cc:1015
TProfile * Get_dNdz_FromProfile()
Definition: TimeModel.cc:666
double Eval_e_t(double t)
Definition: TimeModel.cc:1020
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
double fe_logt(double *logt, double *r)
Definition: TimeModel.cc:847
double L_t(double z, double r)
Definition: TimeModel.cc:567
double dNdE(double E, double x, double r)
Definition: TimeModel.cc:812
int stats
Definition: dump1090.h:293
double zMean
Definition: TimeModel.h:68
double LinkTofg_logt(double *x, double *p)
Definition: TimeModel.cc:37
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
double logLambda
Definition: TimeModel.h:66
double SetCoordinates(double r, double psi)
Definition: TimeModel.cc:863
TimeModel(double angle_in, int primary, int Da_flag_in=1)
Definition: TimeModel.cc:51
double m2
Definition: TimeModel.h:55

, generated on Tue Sep 26 2023.