12 #include <utl/config.h>
17 #include <utl/Reader.h>
18 #include <utl/ErrorLogger.h>
19 #include <utl/AugerUnits.h>
20 #include <utl/MathConstants.h>
22 #include <utl/PhysicalConstants.h>
23 #include <utl/PhysicalFunctions.h>
24 #include <utl/Point.h>
25 #include <utl/Vector.h>
26 #include <utl/TabulatedFunction.h>
27 #include <utl/TabulatedFunctionErrors.h>
28 #include <utl/Trace.h>
29 #include <utl/MultiTabulatedFunction.h>
30 #include <utl/Photon.h>
31 #include <utl/RandomEngine.h>
32 #include <utl/RandomSamplerFromPDF.h>
33 #include <utl/UTMPoint.h>
35 #include <fwk/CentralConfig.h>
36 #include <fwk/CoordinateSystemRegistry.h>
37 #include <fwk/LocalCoordinateSystem.h>
38 #include <fwk/RandomEngineRegistry.h>
40 #include <det/Detector.h>
42 #include <fdet/FDetector.h>
44 #include <fdet/Telescope.h>
45 #include <fdet/Mirror.h>
46 #include <fdet/Filter.h>
47 #include <fdet/Corrector.h>
48 #include <fdet/Camera.h>
50 #include <evt/Event.h>
51 #include <evt/ShowerSimData.h>
52 #include <evt/LaserData.h>
54 #include <fevt/FEvent.h>
56 #include <fevt/TelescopeSimData.h>
57 #include <fevt/Telescope.h>
59 #include <atm/ProfileResult.h>
60 #include <atm/InclinedAtmosphericProfile.h>
62 #include <CLHEP/Random/Randomize.h>
64 #include <boost/tuple/tuple.hpp>
80 using namespace ShowerPhotonGeneratorOG;
89 using CLHEP::RandFlat;
94 fUseOnlyReferenceWavelength(false),
95 fFluorescenceLDF(eOff),
96 fScatteredCherenkovLDF(eOff),
97 fDirectCherenkovLDF(eOff),
98 fLightSourceSelector(-2),
99 fMultipleScatterer(NULL)
110 fRandomEngine = &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector);
116 string fluorescence3D;
118 if (fluorescence3D ==
"off")
120 else if (fluorescence3D ==
"NKG")
122 else if (fluorescence3D ==
"Gora")
126 err <<
" Unknown fluorescence LDF mode: \"" << fluorescence3D;
133 if (cherenkov3D ==
"off")
135 else if (cherenkov3D ==
"NKG")
137 else if (cherenkov3D ==
"Gora")
139 else if (cherenkov3D ==
"Cherenkov")
141 else if (cherenkov3D ==
"CherenkovAtAxis")
143 else if (cherenkov3D ==
"CORSIKA")
147 err <<
" Unknown direct cherenkov LDF option: " << cherenkov3D;
152 if (cherenkov3D ==
"off")
154 else if (cherenkov3D ==
"NKG")
156 else if (cherenkov3D ==
"Gora")
158 else if (cherenkov3D ==
"Cherenkov")
160 else if (cherenkov3D ==
"CherenkovAtAxis")
164 err <<
" Unknown scattered cherenkov LDF option: " << cherenkov3D;
175 " max raytraced photons per time bin: " <<
fMaxNRayTrace<<
"\n"
176 " min raytraced photons per time bin: " <<
fMinNRayTrace<<
"\n"
178 " fluorescence LDF: ";
180 case eOff: info <<
"off\n";
break;
181 case eNKG: info <<
"NKG\n";
break;
182 case eGora: info <<
"Gora et al.\n";
break;
183 default: info <<
"UNKNOWN\n";
break;
185 info <<
" direct Cherenkov LDF: ";
187 case eOff: info <<
"off\n";
break;
188 case eNKG: info <<
"NKG\n";
break;
189 case eGora: info <<
"Gora\n";
break;
190 case eCherenkov: info <<
"full sim. Cherenkov emission\n";
break;
191 case eCherenkovAtAxis: info <<
"Cherenkov sim. for electrons at axis\n";
break;
194 info <<
" scattered Cherenkov LDF: ";
196 case eOff: info <<
"off\n";
break;
197 case eNKG: info <<
"NKG\n";
break;
198 case eGora: info <<
"Gora\n";
break;
199 case eCherenkov: info <<
"full sim. Cherenkov emission\n";
break;
200 case eCherenkovAtAxis: info <<
"Cherenkov sim. for electrons at axis\n";
break;
211 ERROR(
"Sim. Cherenkov LDF for direct Cherenkov emission not implemeted yet.");
224 ERROR (
"Event has no FEvent.");
230 !
event.GetSimShower().HasDirection() ||
231 (!
event.GetSimShower().HasGHParameters() && !
event.GetSimShower().HasLaserData())) {
232 ERROR (
"Event has no sim-data.");
242 const Point showerCore(0, 0, 0, showerCS);
243 const Vector showerAxis(0, 0, -1, showerCS);
246 const double cosZenith = (-simShower.
GetDirection()).GetCosTheta(localCS);
247 const double absCosZenith = std::fabs(cosZenith);
250 Detector& detector = Detector::GetInstance();
255 const vector<double>& WLengthFluo = atmo.
GetWavelengths(Atmosphere::eFluorescence);
256 const vector<double>& WLengthCkov = atmo.
GetWavelengths(Atmosphere::eCerenkov);
257 const int nWLengthCkov = WLengthCkov.size();
263 const double tempHeightMin = temperatureProfile.
MinX();
264 const double tempHeightMax = temperatureProfile.
MaxX();
265 const double pressHeightMin = pressureProfile.
MinX();
266 const double pressHeightMax = pressureProfile.
MaxX();
268 bool flatEarth =
false;
270 double atmDistanceMin = 0;
271 double atmDistanceMax = 0;
280 atmDistanceMin = flatEarth ? (coreZ - depthProfile.
MinX()) / absCosZenith : slantDepthVsDistance->
MinX();
281 atmDistanceMax = flatEarth ? (coreZ - depthProfile.
MaxX()) / absCosZenith : slantDepthVsDistance->
MaxX();
285 double showerXmax = 0;
286 double laserWavelength = 0;
303 for (
unsigned int i = 0; i < ages.size(); ++i) {
304 const double agePlot = ages[i];
311 iEye != end; ++iEye) {
316 unsigned int eyeId = iEye->GetId();
321 iTel != end; ++iTel) {
323 const unsigned int telId = iTel->
GetId();
340 info <<
"Photons for eye=" << eyeId
341 <<
", telescope=" << telId
343 unsigned int countRTPhotons = 0;
344 double totalWeightPhotons = 0;
348 const Point telescopePos(0.0, 0.0, 0.0, telCS);
350 const Point p1(telescopePos);
351 const Vector telescopeToShowerCore(showerCore-p1);
356 const unsigned int nBins = distanceTrace.
GetSize();
357 const double tracebin = distanceTrace.
GetBinning();
365 const double totalTraceDuration = tracebin * nBins;
366 const unsigned int telTraceNBins = int(0.5 + totalTraceDuration / telTraceBinWidth);
370 info <<
" photonTraceSize=" << nBins
371 <<
" tracebin=" << tracebin
372 <<
" telTraceBinWidth=" << telTraceBinWidth
373 <<
" telTraceNBins=" << telTraceNBins << endl;
382 double previousDistance = 0;
383 for (
unsigned int iTrace = 0; iTrace < nBins; ++iTrace) {
385 unsigned int totalNRayTracedPhotonsPerBin = 0;
388 const bool firstBin = iTrace <= 0;
389 const bool lastBin = iTrace >= nBins-1;
391 const double currentDistance = distanceTrace[iTrace];
392 const double deltaNext = (lastBin ? 0. : distanceTrace[iTrace+1]-currentDistance);
393 const double deltaPrev = (firstBin ? 0. : currentDistance-previousDistance);
395 const double delta = (binFraction<0 ? deltaPrev : deltaNext);
396 double distancePhoton = currentDistance + delta * binFraction;
397 previousDistance = currentDistance;
399 const double traceTime = tracebin * (0.5 + binFraction + iTrace);
404 const Point pointOnShower = showerCore + showerAxis * distancePhoton;
406 const double temperature = temperatureProfile.
Y(
std::max(std::min(height, tempHeightMax),
408 const double pressure = pressureProfile.
Y(
std::max(std::min(height, pressHeightMax),
410 const double cosLocalZenith =
411 (-showerAxis).GetCosTheta(LocalCoordinateSystem::Create(
UTMPoint(pointOnShower, wgs84)));
413 flatEarth ? cosZenith : cosLocalZenith);
416 map<double, double> sourcePDF;
417 map<int, RandomSamplerFromPDF*> randomWavelengthSource;
420 double totalSumPhotons = 0;
423 iSource != end; ++iSource) {
433 map<double, double> sourceWavelengthPDF;
435 double totalSumPhotonsSource = 0;
438 iBin != end; ++iBin) {
439 const TraceD& photonTrace = iBin->GetTrace();
440 const double nPhotonsWL = photonTrace[iTrace];
441 if (nPhotonsWL > 0) {
442 sourceWavelengthPDF[iBin->GetLabel()] = nPhotonsWL;
443 totalSumPhotonsSource += nPhotonsWL;
447 if (totalSumPhotonsSource <= 0)
450 if (!laserWavelength) {
453 sourcePDF[int(iSource->first)] = totalSumPhotonsSource;
454 totalSumPhotons += totalSumPhotonsSource;
457 if (totalSumPhotons <= 0)
464 const unsigned int tmpRayTrace = (
unsigned int)(
fExtraRayTraceFactor*((
unsigned int)totalSumPhotons + 1));
467 totalNRayTracedPhotonsPerBin += nRayTrace;
468 countRTPhotons += nRayTrace;
469 const double nBunchPhotons = totalSumPhotons / nRayTrace;
471 map<int, RandomSamplerFromPDF*> cherenkovProductionDistance;
472 ScopeGuard cherProdDistGuard(cherenkovProductionDistance);
474 for (
unsigned int iSample = 0; iSample < nRayTrace; ++iSample) {
479 const int iwl = isLaser ? 0 : int(randomWavelengthSource[lightSource]->shoot(
fRandomEngine->
GetEngine()));
482 double wavelength = 0;
483 switch (lightSource) {
485 ERROR(
"DONT KNOW WHAT TO DO");
508 if (!cherenkovProductionDistance.count(iwl)) {
511 double totalBeamLDF = 0;
512 for (
unsigned int iTraceBeam = 0; iTraceBeam < cherenkovBeamProduction.
GetNPoints(); ++iTraceBeam) {
513 const double distanceBeam = cherenkovBeamProduction[iTraceBeam].X();
514 if (distanceBeam > distancePhoton)
516 const double nProd = cherenkovBeamProduction[iTraceBeam].
Y();
517 cherenkovProductionBeamLDF.
PushBack(distanceBeam, nProd);
518 totalBeamLDF += nProd;
520 cherenkovProductionDistance[iwl] = 0;
521 if (totalBeamLDF>0) {
522 cherenkovProductionDistance[iwl] =
531 wavelength = laserWavelength;
534 ERROR(
"Background light photons are not implemented");
541 if (wavelength == 0) {
542 ERROR(
"No wavelength selected");
550 const double xDia = diaR * cos(diaPh);
551 const double yDia = diaR * sin(diaPh);
552 const Point pIn(xDia, yDia, 0.0, telCS);
554 Point pointOnShower = showerCore + showerAxis * distancePhoton;
555 Vector photonDir = pointOnShower - telescopePos;
556 double timeShift = 0;
562 const double distToShower = (pointOnShower-telescopePos).GetMag();
564 const double Xvert = depthProfile.
Y(
std::max(depthProfile.
MinX(), std::min(height, depthProfile.
MaxX())));
565 const double Xslant = flatEarth ? Xvert/absCosZenith : slantDepthVsDistance->
Y(
std::max(atmDistanceMin, std::min(distancePhoton, atmDistanceMax)));
569 const double age =
ShowerAge(Xslant, showerXmax);
572 switch(photonSource) {
602 if (cherenkovProductionDistance[iwl]) {
603 double emissionDistance = 0;
604 Point pointOfCkovEmission;
605 Vector directionOfCkovEmission;
612 pointOfCkovEmission, directionOfCkovEmission,
613 *cherenkovProductionDistance[iwl],
615 slantDepthVsDistance,
641 photonDir = pointOnShower - telescopePos;
643 const double dist3D = photonDir.
GetMag();
647 info <<
" p " << Pressure/
bar
648 <<
" rm: " << moliereR/
m
650 <<
" T: " << Temperature
651 <<
" Height: " << height/
m
652 <<
" X: " << Xvert/
g*
cm*
cm
654 <<
" dist: " << distToShower/
m
655 <<
" anlge: " << angleToCore/
deg
656 <<
" shift: " << timeShift/
ns
667 const double projectedDiaphragmArea = diaphragmArea * photonDir.
GetCosTheta(telCS);
668 const double weight = nBunchPhotons * projectedDiaphragmArea;
686 totalWeightPhotons += weight;
687 utl::Photon photonIn(pIn, -photonDir, wavelength, weight, lightSource);
692 vector<Photon> photonVector;
694 telescopePos, photonVector);
695 for (
unsigned int iPh = 0; iPh < photonVector.size(); ++iPh)
701 rayTracedPhotonTrace[iTrace] += totalNRayTracedPhotonsPerBin;
704 info <<
", generated " << setw(6) << countRTPhotons <<
" photons"
705 <<
", total weight=" << totalWeightPhotons;
725 #include <TPolyMarker3D.h>
726 #include <TPolyLine3D.h>
732 ostringstream newname;
733 newname << h->GetName() <<
"_cumulative";
734 TH1D*
const o =
new TH1D(newname.str().c_str(), newname.str().c_str(),
735 h->GetNbinsX(), h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
736 o->SetLineColor(h->GetLineColor());
737 o->SetLineStyle(h->GetLineStyle());
738 o->SetLineWidth(h->GetLineWidth());
742 for (
int i = 1; i <= h->GetNbinsX(); ++i) {
743 sum += h->GetBinContent(i);
744 o->SetBinContent(i, sum/total);
756 const bool flatEarth =
false;
758 Detector& detector = Detector::GetInstance();
765 const double tempHeightMin = temperatureProfile.
MinX();
766 const double tempHeightMax = temperatureProfile.
MaxX();
769 const double atmDistanceMin = slantDepthVsDistance->
MinX();
770 const double atmDistanceMax = slantDepthVsDistance->
MaxX();
774 const Point showerCore(0,0,0,showerCS);
775 const Vector showerAxis(0,0,-1,showerCS);
778 const double cosZenith = (-simShower.
GetDirection()).GetCosTheta(localCS);
779 const double absCosZenith = std::fabs(cosZenith);
784 const Point& pointX1 = showerCore + showerAxis*distanceX1;
786 const double Xslant = 2. * age * showerXmax / (3 - age);
787 const double distance = distanceVsSlantDepth.
Y(Xslant);
788 const double height = heightVsDistance.
Y(distance);
789 const double Xvert = depthProfile.
Y(height);
790 const Point& pointOnShower = showerCore + showerAxis*distance;
792 const double Temperature = temperatureProfile.
Y(
std::max(std::min(height, tempHeightMax), tempHeightMin));
793 const double Pressure = Xvert *
kgEarth;
795 (-showerAxis).GetCosTheta(LocalCoordinateSystem::Create(
UTMPoint(pointOnShower, wgs84))) );
798 for (
unsigned int iTrace = 0; iTrace < cherenkovProductionBeam.
GetNPoints(); ++iTrace) {
799 const double distanceBin = cherenkovProductionBeam[iTrace].X();
800 if (distanceBin > distance)
802 cherenkovProductionBeamLDF.
PushBack(cherenkovProductionBeam[iTrace].X(), cherenkovProductionBeam[iTrace].Y());
808 cout <<
" PlotLDF: age=" << age
809 <<
" Xslant=" << Xslant/
g*
cm2
810 <<
" Xvert=" << Xvert/
g*
cm2
811 <<
" distance=" << distance
812 <<
" height=" << height
814 <<
" bins=" << cherenkovProductionBeamLDF.
GetNPoints()
817 ostringstream hFluoLDFName, hCkovLDFName;
818 hFluoLDFName <<
"hFluoLDF_" << fixed << setprecision(2) << age;
819 hCkovLDFName <<
"hCkovLDF_" << fixed << setprecision(2) << age;
820 const int nBins = 100;
821 const double minR = 0;
822 const double maxR = 1600;
823 TH1D*
const hFluoLDF =
new TH1D(hFluoLDFName.str().c_str(), hFluoLDFName.str().c_str(), nBins, minR, maxR);
824 TH1D*
const hCkovLDF =
new TH1D(hCkovLDFName.str().c_str(), hCkovLDFName.str().c_str(), nBins, minR, maxR);
825 TCanvas*
const c3D =
new TCanvas(
"c3D",
"c3D", 500, 1500);
826 c3D->SetFillColor(kWhite);
834 TPolyMarker3D*
const p1 =
new TPolyMarker3D(2);
835 p1->SetPoint(0, pointOnShower.
GetX(showerCS), pointOnShower.
GetY(showerCS), pointOnShower.
GetZ(showerCS));
836 p1->SetPoint(1, pointX1.
GetX(showerCS), pointX1.
GetY(showerCS), pointX1.
GetZ(showerCS));
837 p1->SetMarkerStyle(20);
838 p1->SetMarkerColor(kRed);
840 const int n_samples = 100000;
841 for (
int i = 0; i < n_samples; ++i) {
845 double emissionDistance = 0;
846 Point pointOfCkovEmission;
847 Vector directionOfCkovEmission;
854 directionOfCkovEmission,
855 *cherenkovProductionDistance,
857 slantDepthVsDistance,
863 TPolyLine3D*
const l3D =
new TPolyLine3D(2);
864 l3D->SetPoint(0, pointOfCkovEmission.
GetX(showerCS), pointOfCkovEmission.
GetY(showerCS), pointOfCkovEmission.
GetZ(showerCS));
865 l3D->SetPoint(1, (pointOnShower+ckovR).GetX(showerCS), (pointOnShower+ckovR).GetY(showerCS), (pointOnShower+ckovR).GetZ(showerCS));
866 l3D->SetLineStyle(1);
867 l3D->SetLineWidth(1);
868 l3D->SetLineColor(kBlue);
870 const double ckovLDF = ckovR.
GetMag();
871 hFluoLDF->Fill(fluoLDF/
m);
872 hCkovLDF->Fill(ckovLDF/
m);
875 TH1D*
const hFluoLDFc =
ToCumu(hFluoLDF, n_samples);
876 TH1D*
const hCkovLDFc =
ToCumu(hCkovLDF, n_samples);
878 ostringstream hLDFPrint, hLDFcumu;
879 hLDFPrint <<
"LDF_" << fixed << setfill(
'0') << setw(3) << setprecision(3) << age <<
".eps";
880 hLDFcumu <<
"LDF_" << fixed << setfill(
'0') << setw(3) << setprecision(3) << age <<
".cumulative.eps";
881 gROOT->SetStyle(
"Plain");
882 gStyle->SetOptTitle(0);
883 gStyle->SetOptStat(0);
884 TCanvas*
const c =
new TCanvas(
"ldf",
"ldf");
885 TLegend*
const l =
new TLegend(0.5, 0.6, 0.85, 0.85);
889 l->SetTextSize(0.045);
890 l->AddEntry(hFluoLDF,
"Fluorescence",
"l");
891 l->AddEntry(hCkovLDF,
"Cherenkov",
"l");
893 double integral = hFluoLDF->Integral();
895 hFluoLDF->Scale(1. / integral);
896 integral = hCkovLDF->Integral();
898 hCkovLDF->Scale(1. / integral);
900 hFluoLDF->SetLineColor(2);
901 hCkovLDF->SetLineColor(4);
902 hFluoLDF->SetXTitle(
"Distance [m]");
903 hFluoLDF->SetYTitle(
"R dP/dR");
904 hFluoLDF->GetYaxis()->SetTitleOffset(1.15);
906 hCkovLDF->Draw(
"lsame");
908 c->Print(hLDFPrint.str().c_str());
910 TCanvas*
const c2 =
new TCanvas(
"ldfcumu",
"ldfcumu");
911 TLegend*
const l2 =
new TLegend(0.5, 0.2, 0.85, 0.6);
913 l2->SetBorderSize(0);
915 l2->SetTextSize(0.045);
916 l2->AddEntry(hFluoLDF,
"Fluorescence",
"l");
917 l2->AddEntry(hCkovLDF,
"Cherenkov",
"l");
919 hFluoLDFc->SetLineColor(2);
920 hCkovLDFc->SetLineColor(4);
921 hFluoLDFc->SetXTitle(
"Distance [m]");
922 hFluoLDFc->SetYTitle(
"R dP/dR");
923 hFluoLDFc->GetYaxis()->SetTitleOffset(1.15);
924 hFluoLDFc->Draw(
"l");
925 hCkovLDFc->Draw(
"lsame");
927 c2->Print(hLDFcumu.str().c_str());
929 ostringstream h3DPrint;
930 h3DPrint <<
"LDF_" << fixed << setfill(
'0') << setw(3) << setprecision(3) << age <<
".3d.root";
932 c3D->Print(h3DPrint.str().c_str());
934 delete cherenkovProductionDistance;
946 const double r_moliere)
948 const double fMax = 0.95;
949 const double r = r_moliere *
NKGFunction(s_age, fMax);
952 return Vector(r, phi, 0., shwCS, Vector::kCylindrical);
964 const double r_moliere)
969 return Vector(r, phi, 0., shwCS, Vector::kCylindrical);
982 double distanceCoreToPointOnShower,
985 double& emissionDistance,
991 const double absCosZenith,
993 const bool flatEarth,
994 const double atmDistanceMin,
995 const double atmDistanceMax)
1000 const bool emissionIn = emissionDistance > atmDistanceMin && emissionDistance < atmDistanceMax;
1001 const double emissionDepthVert =
1002 emissionIn ? depthProfile.
Y(
std::max(depthProfile.
MinX(), std::min(depthProfile.
MaxX(), coreZ-emissionDistance*absCosZenith))) : 0;
1003 const double emissionDepth =
1004 flatEarth ? emissionDepthVert / absCosZenith :
1005 (emissionIn ? slantDepthVsDistance->
Y(emissionDistance) : 0);
1006 const double emissionAge =
ShowerAge(emissionDepth, Xmax);
1011 const double maxIntegrationAngle = 90.*
utl::degree;
1014 const Atmosphere& atmo = Detector::GetInstance().GetAtmosphere();
1017 const double cdfMax =
1021 double leftAngle = 0.;
1022 double rightAngle = maxIntegrationAngle;
1026 while (fabs(leftAngle - rightAngle) > 2*deltaAngle) {
1028 const double midAngle = 0.5 * (leftAngle + rightAngle);
1029 const double cdfMiddle =
1032 if (cdfLeft*cdfMiddle < 0)
1033 rightAngle = midAngle;
1037 leftAngle = midAngle;
1041 const double cdfRight =
1043 const double electronAngleTheta = leftAngle - (rightAngle-leftAngle)/(cdfRight-cdfLeft) * (cdfLeft);
1048 CoordinateSystem::RotationX(electronAngleTheta, CoordinateSystem::RotationZ(electronAnglePhi, showerCS));
1054 const double cosCherenkovTheta = 1. / nRefrac;
1055 const double sinCherenkovTheta =
sqrt(1.-cosCherenkovTheta*cosCherenkovTheta);
1063 directionOfEmission =
Vector(-sinCherenkovTheta*sin(cherenkovAnglePhi),
1064 -sinCherenkovTheta*cos(cherenkovAnglePhi),
1070 const double photonTravelDistance = (distanceCoreToPointOnShower-emissionDistance) / (directionOfEmission*axis);
1072 return Vector(pointOfEmission.
GetX(showerCS) + directionOfEmission.
GetX(showerCS) * photonTravelDistance,
1073 pointOfEmission.
GetY(showerCS) + directionOfEmission.
GetY(showerCS) * photonTravelDistance,
1099 const double closeToZero = 1.e-20;
1100 const double sMax = 1.999;
1102 static double lastFmax = -1;
1103 static double xMaxArr[200];
1106 if (fMax != lastFmax) {
1109 for (
int j = 0; j < 200; ++j) {
1110 const double a = (0.5+j)/100;
1111 const double b = 4.5 - 2*
a;
1113 double xxMax = closeToZero;
1114 while (frac < fMax) {
1116 const double arg = 1/(1+1/xxMax);
1130 const double xMin = closeToZero;
1131 const int ageBin = int(s*100);
1132 const double xMax = xMaxArr[ageBin];
1143 const double g = s - 4.5;
1144 const double g1 = g + 1;
1148 const double Fa =
pow(xMin+1, g1);
1149 const double Fb =
pow(xMax+1, g1);
1150 const double y = Fa + (Fb-Fa)*rdm;
1157 const double Ymax =
pow(xMax, s-1);
1164 const double g = s - 1;
1165 const double g1 = g + 1;
1169 if (fabs(g1) > closeToZero) {
1170 const double Fa =
pow(xMin, g1);
1171 const double Fb =
pow(xMax, g1);
1172 const double y = Fa + (Fb - Fa)*rdm;
1175 const double lMin = log10(xMin);
1176 const double lMax = log10(xMax);
1177 x =
pow(10, lMin + rdm*(lMax - lMin));
1182 Y =
pow(1+x, s - 4.5);
1209 if (rdm < std::numeric_limits<double>::min())
1210 rdm = std::numeric_limits<double>::min();
1227 for (map<int, RandomSamplerFromPDF*>::iterator iMap =
fMap.begin(),
1229 iMap != end; ++iMap) {
1230 delete iMap->second;
unsigned int GetId() const
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
PhotonTraceSourceIterator PhotonTracesSourceEnd()
LaserData & GetLaserData()
Get the laser data.
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
int GetLightSourceSelection()
ELDFMode fScatteredCherenkovLDF
double GetFADCBinSize() const
unsigned int fMinNRayTrace
max no. of photons per bin
double InverseGoraCDF(const double fraction, const double age)
bool HasLaserData() const
Check initialization of the LaserData.
double GetLaserWavelength() const
utl::Vector LateralDistributionNKG(const utl::CoordinateSystemPtr &shwCS, const double s_age, const double r_moliere)
Distribute points according to a NKG function.
void AddPhotons(const utl::Point &PointOfOrigin, const utl::Photon &PhotonDirect, const utl::Point &PointOfDetection, std::vector< utl::Photon > &photonVector)
Report success to RunController.
const std::vector< double > & GetWavelengths(const EmissionMode mode=eFluorescence) const
Fluorescence Detector Eye Event.
const utl::TabulatedFunction & GetCherenkovBeamProductionPhotons(const int wavelength) const
Get the cherenkov beam production along the shower axis.
RandomEngineType & GetEngine()
const evt::VGaisserHillasParameter & GetGHParameters() const
Get the Gaisser-Hillas parameters of the shower.
utl::Vector LateralDistributionGora(const utl::CoordinateSystemPtr &shwCS, const double s_age, const double r_moliere)
Distribute points according to a Gora function.
PhotonTraceSourceIterator PhotonTracesSourceBegin()
unsigned int fMaxNRayTrace
Returns int as implementation of an eNone equivalent.
Class to hold and convert a point in geodetic coordinates.
Skip remaining modules in the current loop and continue with next iteration of the loop...
Class to hold collection (x,y) points and provide interpolation between them.
const atm::ProfileResult & EvaluatePressureVsHeight() const
Tabulated function giving Y=air pressure as a function of X=height.
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
bool HasSimShower() const
EyeIterator EyesEnd(const ComponentSelector::Status status)
double GetBinning() const
size of one slot
double GetDiaphragmRadius() const
const atm::ProfileResult & EvaluateDistanceVsSlantDepth() const
Table of distance as a function of slant depth.
void PlotLDF(const evt::ShowerSimData &simShower, const utl::TabulatedFunction &cherenkovProductionBeam, const double age)
utl::TraceI & GetRayTracedPhotonTrace()
Number of photons that were actually ray-traced (per time bin)
#define INFO(message)
Macro for logging informational messages.
void AddPhoton(const utl::Photon &p)
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
void PushBack(const double x, const double y)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
utl::Vector LateralDistributionScatteredCherenkov(const utl::CoordinateSystemPtr &showerCX, const utl::Point &core, const utl::Vector &axis, double distanceCoreToPointOnShower, double Xmax, double rMoliere, double &emissionDistance, utl::Point &pointOfEnission, utl::Vector &directionOfEmission, const utl::VRandomSampler &cherenkovProduction, const atm::ProfileResult &depthProfile, const atm::ProfileResult *slantDepthVsDistance, const double absCosZenith, const double coreZ, const bool flatEarth, const double atmDistanceMin, const double atmDistanceMax)
Distribute points according to scattered Cherenkov emission.
double pow(const double x, const unsigned int i)
EPhotonSource
The source that generated this photon.
double shoot(HepEngine &engine) const
Method to shoot random values using a given engine by-passing the static generator.
std::string GetVersionInfo(const VersionInfoType v) const
Retrieve different sorts of module version info.
utl::MultiTraceD::Iterator PhotonTraceIterator
An iterator over the components of the photon trace.
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
utl::RandomEngine * fRandomEngine
This can be set in order to simulate photons for a single source ONLY (for FdLightCollectionEfficienc...
Detector description interface for FDetector-related data.
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
double fExtraRayTraceFactor
min no. of photons per bin
Interface class to access Shower Simulated parameters.
const atm::Atmosphere & GetAtmosphere() const
double IncompleteBeta(const double a, const double b, const double x)
Incomplete Beta function.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
double AngularCherenkovCDF(const double theta, const double verticalDepth, const double showerAge) const
cumulative of angular Cherenkov distribution from 0 to theta
double GetXFirst() const
Get depth of first interaction.
fevt::TelescopeSimData & GetSimData()
Description of simulated data for one Telescope.
Class representing a document branch.
utl::CoordinateSystemPtr GetTelescopeCoordinateSystem() const
PhotonTraceSourceContainer::iterator PhotonTraceSourceIterator
Reference ellipsoids for UTM transformations.
double GoraFunction(const double s)
returns random numbers drawn from Gora et al. LDF
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
LightSource
Possible light sources.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
double MoliereRadius(double temperature, double pressure, const double cosTheta)
The Moliere Radius (2 radiation length above obs-level, GAP-1998-002)
Class describing the Atmospheric profile.
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Top of the hierarchy of the detector description interface.
EyeIterator EyesBegin(const ComponentSelector::Status status)
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
const fdet::FDetector & GetFDetector() const
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
TH1D * ToCumu(TH1D *h, double total)
PhotonTraceIterator PhotonTracesEnd(const fevt::FdConstants::LightSource source)
void GetData(bool &b) const
Overloads of the GetData member template function.
Top of Fluorescence Detector event hierarchy.
ScopeGuard(std::map< int, utl::RandomSamplerFromPDF * > &theMap)
bool HasDistanceTrace() const
Check that trace for the distance along the shower axis is present.
bool HasRayTracedPhotonTrace() const
Check that "ray-traced photon trace" is present.
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
ELDFMode fFluorescenceLDF
Photons are generated at the reference wavelength only if this is set.
double GetReferenceLambda() const
double LorentzLorentz(const double verticalDepth)
Calculate the refraction index for a given depth.
bool fUseOnlyReferenceWavelength
for doing more tracing to reduce fluctuations
double GetY(const CoordinateSystemPtr &coordinateSystem) const
constexpr double kSpeedOfLight
Detector description interface for Telescope-related data.
A TimeInterval is used to represent time elapsed between two events.
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
ResultFlag
Flag returned by module methods to the RunController.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
PhotonTraceIterator PhotonTracesBegin(const fevt::FdConstants::LightSource source)
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
ELDFMode fDirectCherenkovLDF
double GetDiaphragmArea() const
double ShowerAge(const double slantDepth, const double showerMax)
General definition of shower age.
execption handling for calculation/access for inclined atmosphere model
Report failure to RunController, causing RunController to terminate execution.
Main configuration utility.
Fluorescence Detector Telescope Event.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
std::map< int, utl::RandomSamplerFromPDF * > & fMap
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
void MakeRayTracedPhotonTrace(const unsigned int size=0, const double binSize=0)
Add a trace for the number of photons that were ray-traced.
void SetTime(const utl::TimeInterval &t)
void SetNumberOfPhotonBins(const int n)
MultipleScatterer * fMultipleScatterer
const atm::ProfileResult & EvaluateSlantDepthVsDistance() const
Automatically frees memory on scope exit.
#define ERROR(message)
Macro for logging error messages.
double NKGFunction(const double s, const double fMax)
returns random numbers drawn from
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Class to shoot random numbers given by a user-defined distribution function.
utl::CoordinateSystemPtr GetShowerCoordinateSystem() const
const atm::ProfileResult & EvaluateTemperatureVsHeight() const
Tabulated function giving Y=temperature as a function of X=height.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
utl::TraceD & GetDistanceTrace()
Trace for the distance along the shower axis of the light at the diaphragm.
const atm::ProfileResult & EvaluateHeightVsDistance() const
Table of height as a function of distance.