7 #include <fevt/EyeRecData.h>
8 #include <fevt/EyeHeader.h>
9 #include <fevt/Telescope.h>
10 #include <fevt/TelescopeRecData.h>
11 #include <fevt/Pixel.h>
13 #include <evt/ShowerFRecData.h>
15 #include <det/Detector.h>
16 #include <fdet/FDetector.h>
18 #include <fdet/Pixel.h>
19 #include <fdet/Telescope.h>
21 #include <atm/Atmosphere.h>
22 #include <atm/ProfileResult.h>
23 #include <atm/AttenuationResult.h>
24 #include <atm/ScatteringResult.h>
25 #include <atm/InclinedAtmosphericProfile.h>
27 #include <fwk/CentralConfig.h>
28 #include <utl/Reader.h>
29 #include <utl/ErrorLogger.h>
30 #include <utl/UTMPoint.h>
31 #include <utl/AugerException.h>
32 #include <utl/TabulatedFunctionErrors.h>
33 #include <utl/PhysicalConstants.h>
34 #include <utl/PhysicalFunctions.h>
36 #include <fwk/LocalCoordinateSystem.h>
48 using namespace FdEnergyDepositFinderKG;
60 delete fLateralLightCalculator;
64 auto lldBranch = topBranch.
GetChild(
"lateralLight");
66 lldBranch.
GetChild(
"multipleScattering").
GetData(fDoMultipleScattering);
68 info <<
"\n\t multiple scattering is "
69 << (fDoMultipleScattering ?
"on" :
"off");
74 CFMatrixCalculator::~CFMatrixCalculator()
76 delete fLateralLightCalculator;
81 CFMatrixCalculator::BuildMatrix(
const fevt::Eye& eye,
const bool leavingAtmoIsError,
const unsigned int addDense)
85 if (InitCalculation(eye) && CalculateTelescopeData(eye, leavingAtmoIsError, addDense)) {
89 << fNumberOfDepthBins <<
"..." << endl;
91 CalculateDiagonalParameters();
92 CalculateFluorescenceMatrix();
93 CalculateDirectCherenkovMatrix();
96 fDirectCFMatrix = fDirectCherenkovMatrix + fDirectFluorescenceMatrix;
100 CalculateMieAndRayScattCherenkovMatrix();
102 fCFMatrix = fMieScatteredCherenkovMatrix +
103 fRayScatteredCherenkovMatrix +
104 fDirectCherenkovMatrix +
105 fDirectFluorescenceMatrix;
115 CFMatrixCalculator::InitCalculation(
const fevt::Eye& eye)
117 fEyeId = eye.
GetId();
128 if (shower.HasGHParameters() && shower.GetGHParameters().GetXMax() > 0)
134 fElectronEnergyThreshold = shower.GetEnergyCutoff();
135 const auto& atmo = det::Detector::GetInstance().GetAtmosphere();
136 atmo.SetCherenkovEnergyCutoff(fElectronEnergyThreshold);
139 fCherWaveLength = atmo.GetWavelengths(Atmosphere::eCerenkov);
140 fFluoWaveLength = atmo.GetWavelengths(Atmosphere::eFluorescence);
143 const auto& fdDetector = Detector::GetInstance().GetFDetector();
145 const auto& relEff = fdDetector.GetEye(fEyeId).TelescopesBegin()->GetMeasuredRelativeEfficiency();
146 const double effMinLam = relEff.GetX(0);
147 const double effMaxLam = relEff.GetX(relEff.GetNPoints() - 1);
149 for (
auto lIt = fFluoWaveLength.begin(); lIt != fFluoWaveLength.end(); ) {
150 if (effMinLam <= *lIt && *lIt <= effMaxLam && relEff.Y(*lIt) > 0)
153 lIt = fFluoWaveLength.erase(lIt);
156 for (
auto lIt = fCherWaveLength.begin(); lIt != fCherWaveLength.end(); ) {
158 if (effMinLam <= *lIt && *lIt <= effMaxLam)
161 lIt = fCherWaveLength.erase(lIt);
169 CFMatrixCalculator::CalculateTelescopeData(
const fevt::Eye& eye,
const bool leavingAtmoIsError,
const unsigned int addDense)
172 const auto& axis = shower.
GetAxis();
173 fShowerAxis = -shower.GetAxis();
174 const auto& core = shower.GetCorePosition();
179 const auto& coreTime = shower.GetCoreTime();
184 const auto& atmo = Detector::GetInstance().GetAtmosphere();
186 atmo.InitSlantProfileModel(core, axis, fMethod == ePrecise ? 10*
g/
cm2 : 100*
g/
cm2);
192 const auto& slantDepthProfile = atmo.EvaluateSlantDepthVsDistance();
193 const auto& slantDistProfile = atmo.EvaluateDistanceVsSlantDepth();
194 const double atmMinDistance = slantDepthProfile.MinX() + 1*
mm;
195 const double atmMaxDistance = slantDepthProfile.MaxX() - 1*
mm;
196 const auto& verticalDepthProfile = atmo.EvaluateDepthVsHeight();
197 const double atmMinHeight = verticalDepthProfile.MinX();
198 const double atmMaxHeight = verticalDepthProfile.MaxX();
203 if (!telIter->HasRecData())
207 const auto& telRecData = telIter->GetRecData();
215 if (photonTrace.GetNPoints() != bgTrace.GetNPoints()) {
216 ERROR(
"incompatible light fluxes --> skip tel!!");
222 typedef unique_ptr<TabulatedFunctionErrors> TabFuncErrAutoPtr;
228 const auto& zetaPixelIds = telRecData.GetPixelsInZetaOverTime();
229 if (fMethod == ePrecise && zetaPixelIds.size() != photonTrace.GetNPoints()) {
230 ostringstream errMsg;
231 errMsg <<
"inconsistent trace/zetaPixels: N(trace) = "
232 << photonTrace.GetNPoints() <<
" N(zetaPixels)="
233 << zetaPixelIds.size();
243 bool firstTime =
true;
247 double maxSignal = 0;
248 const auto& timeRangeList = telRecData.GetSpotFarFromBorderTimeRanges();
249 for (
auto timeRangeIter = timeRangeList.begin(), end = timeRangeList.end(); timeRangeIter != end; ++timeRangeIter) {
251 const double thisRange = fabs(timeRangeIter->first - timeRangeIter->second);
252 const double thisRangeMin = fmin(timeRangeIter->first, timeRangeIter->second);
253 const double thisRangeMax = fmax(timeRangeIter->first, timeRangeIter->second);
255 const auto& flux = telRecData.GetLightFlux();
256 double thisSignal = 0;
257 for (
auto it = flux.Begin(), end = flux.End(); it != end; ++it) {
258 if (thisRangeMin <= it->X() && it->X() <= thisRangeMax)
259 thisSignal += it->Y() / it->YErr();
263 if (firstTime || thisSignal > maxSignal) {
265 maxSignal = thisSignal;
266 maxRange = thisRange;
267 minTime = thisRangeMin;
268 maxTime = thisRangeMax;
273 ostringstream errMsg;
274 errMsg <<
" zero time range for telId=" << telIter->GetId() <<
"??";
279 const auto& fdDetector = Detector::GetInstance().GetFDetector();
280 const auto& detTel = fdDetector.GetEye(eye.
GetId()).GetTelescope(telIter->GetId());
281 const unsigned int physicalEyeId = detTel.GetParentPhysicalEyeId();
282 const auto& telEyeCS = fdDetector.GetEye(physicalEyeId).GetEyeCoordinateSystem();
288 const auto coreTelescopeVec = detTel.GetPosition() - core;
289 const double cDist = coreTelescopeVec.GetMag();
290 const double cosBeta =
CosAngle(axis, coreTelescopeVec);
296 for (
unsigned int i = 0; i < photonTrace.GetNPoints(); ++i) {
299 for (
unsigned int j = 0; j < addDense; ++j) {
308 const double halfBinWidth = photonTrace.GetXErr(i);
309 const double tMean = photonTrace.GetX(i) - halfBinWidth + (2*j + 1) * halfBinWidth / addDense;
310 const double tFirst = tMean-halfBinWidth / addDense;
311 const double tLast = tMean+halfBinWidth / addDense;
319 if (photonTrace.GetX(i) - halfBinWidth < minTime)
321 if (photonTrace.GetX(i) + halfBinWidth > maxTime)
326 const auto& wgs84 = ReferenceEllipsoid::GetWGS84();
328 const auto firstTimeAtTelescope = eyeTriggerTime + tFirst;
329 const double deltaFirst = (firstTimeAtTelescope - coreTime).GetInterval()*
kSpeedOfLight;
330 const double firstDistance =
331 -(cDist*cDist - deltaFirst*deltaFirst) / (2*(deltaFirst + cDist*cosBeta));
332 const auto firstPointOnShower = core - firstDistance*axis;
333 const double firstHeight = wgs84.PointToLatitudeLongitudeHeight(firstPointOnShower).get<2>();
335 if (firstDistance < atmMinDistance || firstDistance > atmMaxDistance ||
336 firstHeight < atmMinHeight || firstHeight > atmMaxHeight) {
337 if (leavingAtmoIsError)
340 map<FdConstants::LightSource, double> lightEfficiencies;
343 halfBinWidth / addDense,
345 photonTrace.GetYErr(i),
346 pow(bgTrace.GetYErr(i), 2),
347 lightEfficiencies, i);
348 noiseTelData.AddTelescopeDataBin(telDataBin);
353 const double firstDepth = slantDepthProfile.Y(firstDistance);
355 TimeStamp lastTimeAtTelescope = eyeTriggerTime + tLast;
356 const double deltaLast =
358 const double lastDistance =
359 -(cDist*cDist-deltaLast*deltaLast)/(2*(deltaLast+cDist*cosBeta));
360 const Point lastPointOnShower = core-lastDistance*axis;
361 const double lastHeight =
362 wgs84.PointToLatitudeLongitudeHeight(lastPointOnShower).get<2>();
364 if (lastDistance < atmMinDistance || lastDistance > atmMaxDistance ||
365 lastHeight < atmMinHeight || lastHeight > atmMaxHeight) {
366 if (leavingAtmoIsError)
369 map<FdConstants::LightSource, double> lightEfficiencies;
372 halfBinWidth/addDense,
374 photonTrace.GetYErr(i),
375 pow(bgTrace.GetYErr(i),2),
376 lightEfficiencies, i);
377 noiseTelData.AddTelescopeDataBin(telDataBin);
382 const double lastDepth = slantDepthProfile.Y(lastDistance);
383 const double meanDepth = (firstDepth + lastDepth) / 2.;
384 const double meanDistance = slantDistProfile.Y(meanDepth);
385 const Point meanPointOnShower = core - meanDistance * axis;
386 const double meanHeight =
387 wgs84.PointToLatitudeLongitudeHeight(meanPointOnShower).get<2>();
388 if (meanHeight < atmMinHeight || meanHeight > atmMaxHeight) {
389 if (leavingAtmoIsError)
392 map<FdConstants::LightSource, double> lightEfficiencies;
395 halfBinWidth/addDense,
397 photonTrace.GetYErr(i),
398 pow(bgTrace.GetYErr(i),2),
399 lightEfficiencies, i);
400 noiseTelData.AddTelescopeDataBin(telDataBin);
405 if (!isfinite(firstDepth) || !isfinite(lastDepth))
408 map<FdConstants::LightSource, double> lightEfficiencies;
409 if (fluorLCEff.get())
412 if (directCherLCEff.get())
414 directCherLCEff->GetY(i);
415 if (rayCherLCEff.get())
417 rayCherLCEff->GetY(i);
418 if (mieCherLCEff.get())
420 mieCherLCEff->GetY(i);
423 fmax(firstDepth,lastDepth),
429 halfBinWidth/addDense,
431 photonTrace.GetYErr(i),
432 pow(bgTrace.GetYErr(i),2),
433 lightEfficiencies, i);
438 if (fMethod == ePrecise) {
439 Vector vecToShower = meanPointOnShower-detTel.GetPosition();
440 const double vecToShowerPhi = vecToShower.
GetPhi(telEyeCS);
441 const double vecToShowerElevation =
444 CoordinateSystem::RotationZ(vecToShowerPhi, telEyeCS);
446 CoordinateSystem::RotationY(-vecToShowerElevation, auxCS);
448 const vector<unsigned int> pixelIdVec = zetaPixelIds[i];
449 for (
unsigned int iPix=0; iPix < pixelIdVec.size(); ++iPix) {
451 const unsigned int pixId = pixelIdVec[iPix];
452 const fdet::Pixel& thisPixel = detTel.GetPixel(pixId);
454 const double x = pixelDir.
GetPhi(toShowerCS);
458 const double sideLength =
sqrt(2./3.*omega/
kSqrt3);
460 double tiltAngle = 0;
464 if (detTel.GetFirstColumn() != detTel.GetLastColumn()) {
465 const unsigned int thisRow = thisPixel.
GetRow();
466 const unsigned int thisColumn = thisPixel.
GetColumn();
467 const unsigned int nextColumn =
468 (thisColumn == 1 ? thisColumn + 1: thisColumn - 1);
469 const fdet::Pixel& nextPixel = detTel.GetPixel(thisRow, nextColumn);
473 tiltAngle = atan2(nextY - y, nextX -x );
483 telData.AddTelescopeDataBin(telDataBin);
484 noiseTelData.AddTelescopeDataBin(telDataBin);
495 if (!telData.GetTelescopeDataBins().empty()) {
497 noiseTelData.SortBins();
498 SetTelescopeParameters(eye, telData);
499 SetTelescopeParameters(eye, noiseTelData);
500 telData.SetZeta(telRecData.GetZeta());
501 noiseTelData.SetZeta(telRecData.GetZeta());
502 fTelescopeData.push_back(telData);
503 fNoiseTelescopeData.push_back(noiseTelData);
508 if (!fTelescopeData.empty()) {
511 for (std::vector<TelescopeData>::const_iterator
512 telIter = fTelescopeData.begin();
513 telIter != fTelescopeData.end(); ++telIter)
514 fFOVsize += telIter->GetTelescopeDataBins().size();
516 AddBinsOutsideFOV(eye);
518 fNumberOfDepthBins = 0;
519 sort(fTelescopeData.begin(), fTelescopeData.end());
520 for (std::vector<TelescopeData>::const_iterator
521 telIter = fTelescopeData.begin();
522 telIter != fTelescopeData.end(); ++telIter)
523 fNumberOfDepthBins += telIter->GetTelescopeDataBins().size();
525 sort(fNoiseTelescopeData.begin(), fNoiseTelescopeData.end());
535 CFMatrixCalculator::AddBinsOutsideFOV(
const fevt::Eye& eye)
540 for (std::vector<TelescopeData>::const_iterator telIter = fTelescopeData.begin();
541 telIter != fTelescopeData.end(); ++telIter) {
543 const double minTelDepth = telIter->GetMinDepth();
544 if (first || minTelDepth < minDepth) {
545 minDepth = minTelDepth;
551 const Atmosphere& atmo = det::Detector::GetInstance().GetAtmosphere();
553 const double atmoMinDepth = distProfile.
MinX();
555 const double atmMinHeight = verticalDepthProfile.
MinX();
556 const double atmMaxHeight = verticalDepthProfile.
MaxX();
557 const double dX = 25.*(
g/
cm2);
564 const Point& detEyePos =
565 Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetPosition();
566 const double minHeight =
574 double thisDepth = minDepth;
575 while (thisDepth > atmoMinDepth+dX) {
576 const double nextDepth = thisDepth - dX;
577 const Point firstPointOnShower = core-distProfile.
Y(nextDepth)*axis;
578 const Point lastPointOnShower = core-distProfile.
Y(thisDepth)*axis;
579 const double meanDepth = (thisDepth+nextDepth)/2.;
580 const double meanDistance = distProfile.
Y(meanDepth);
581 const Point meanPointOnShower = core-meanDistance*axis;
582 const map<FdConstants::LightSource, double> dummyEff;
583 const double meanHeight =
585 if (meanHeight > minHeight && meanHeight > atmMinHeight &&
586 meanHeight < atmMaxHeight && fmin(thisDepth, nextDepth) > atmoMinDepth) {
588 fmax(thisDepth,nextDepth),
597 thisDepth = nextDepth;
603 <<
" bins outside FOV (X<" << minDepth/
g*
cm2 <<
")"
608 fTelescopeData.push_back(telData);
609 fNoiseTelescopeData.push_back(telData);
615 CFMatrixCalculator::CalculateDiagonalParameters()
617 fCherTransmissionToTel.clear();
618 fFluoTransmissionToTel.clear();
620 const Atmosphere& atmo = Detector::GetInstance().GetAtmosphere();
622 Detector::GetInstance().GetFDetector().GetEye(fEyeId);
625 const std::vector<double>& lambdaCVec = fCherWaveLength;
626 const unsigned int nCLambda = lambdaCVec.size();
627 vector<double> cherenkovTelTransmission(nCLambda);
628 vector<double> cherenkovTrackTransmission(nCLambda);
629 vector<double> cherenkovRayleighScattering(nCLambda);
630 vector<double> cherenkovMieScattering(nCLambda);
631 vector<double> cherenkovProduction(nCLambda);
633 const std::vector<double>& lambdaFVec = fFluoWaveLength;
634 const unsigned int nFLambda = lambdaFVec.size();
635 std::vector<double> fluorescenceTransmission(nFLambda);
637 const double fourPi = 4.0*
kPi;
640 for (vector<TelescopeData>::const_iterator telIter = fTelescopeData.begin();
641 telIter != fTelescopeData.end(); ++telIter) {
643 const Point& telPos = telIter->GetType() == TelescopeData::eInsideFOV?
647 for (vector<TelescopeDataBin>::const_iterator binIter =
648 telIter->TelDataBinsBegin();
649 binIter != telIter->TelDataBinsEnd(); ++binIter) {
651 const Point& meanPos = binIter->fMeanDepthPoint;
655 const Vector showerTelVec = telPos-meanPos;
656 const double distToTelSquared = showerTelVec.
GetMag2();
657 const double distToTel =
sqrt(distToTelSquared);
658 fGeometricalFactor.push_back(1./fourPi/distToTelSquared);
659 fZetaDistance.push_back(tan(telIter->GetZeta())*distToTel);
664 fElectronEnergyThreshold);
665 fMeandEdXPerElectron.push_back(alpha);
668 const double cosLocalZenith =
670 fCosTheta.push_back(cosLocalZenith);
700 const double emissionAngle =
Angle(fShowerAxis, showerTelVec);
704 emissionAngle, distToTel, lambdaCVec);
708 emissionAngle, distToTel, lambdaCVec);
717 binIter->fLastPoint, lambdaCVec);
722 binIter->fLastPoint, lambdaCVec);
727 const double showerAge =
utl::ShowerAge(binIter->GetMeanDepth(), fXmax);
730 binIter->fLastPoint, showerAge);
733 for (
unsigned int j=0; j<nCLambda; ++j) {
734 cherenkovRayleighScattering[j] = rayleighScattTrackTel.
GetY(j);
735 cherenkovMieScattering[j] = mieScattTrackTel.
GetY(j);
736 cherenkovTelTransmission[j] = mieCAtt.
GetY(j)*rayCAtt.
GetY(j);
737 cherenkovTrackTransmission[j] = rayTrackAtt.
GetY(j)*mieTrackAtt.
GetY(j);
738 cherenkovProduction[j] = cherenkovProd.GetY(j);
741 for (
unsigned int j=0; j<nFLambda; ++j)
742 fluorescenceTransmission[j] = mieFAtt.
GetY(j) * rayFAtt.
GetY(j);
744 fFluoTransmissionToTel.push_back(fluorescenceTransmission);
745 fRayScatToTel.push_back(cherenkovRayleighScattering);
746 fMieScatToTel.push_back(cherenkovMieScattering);
747 fCherTransmissionToTel.push_back(cherenkovTelTransmission);
748 fCherenkovAtTrack.push_back(cherenkovProduction);
749 fCherTransmissionShower.push_back(cherenkovTrackTransmission);
757 CFMatrixCalculator::CalculateFluorescenceMatrix()
759 const Atmosphere& atmo = det::Detector::GetInstance().GetAtmosphere();
760 const double dEdX0 = atmo.
GetdEdX0();
762 const std::vector<double>& lambdaVec = fFluoWaveLength;
763 const fdet::FDetector& fdDetector = Detector::GetInstance().GetFDetector();
765 fDirectFluorescenceMatrix.SetSize(fNumberOfDepthBins);
768 for (vector<TelescopeData>::const_iterator telIter = fTelescopeData.begin();
769 telIter != fTelescopeData.end(); ++telIter) {
771 const bool realTelescope =
772 (telIter->GetType() == TelescopeData::eInsideFOV);
773 const unsigned int telId = realTelescope? telIter->
GetId() :
781 for (vector<TelescopeDataBin>::const_iterator binIter =
782 telIter->TelDataBinsBegin();
783 binIter != telIter->TelDataBinsEnd(); ++binIter) {
785 const double height = binIter->fHeight;
790 double epsYTsum = 0.;
791 for (
unsigned int j = 0; j < lambdaVec.size(); j++) {
792 const double Y_j = fluoyield_tab.
Y(lambdaVec[j]);
793 epsYTsum += Y_j * relEff.
Y(lambdaVec[j]) * fFluoTransmissionToTel[i][j];
796 const double deltaL =
797 (binIter->fFirstPoint - binIter->fLastPoint).GetMag();
798 const double lldFraction =
806 const double msFactor =
807 1. / (1 - MultipleScatteringFraction(*binIter,
813 fFluorescenceMultipleScattering.push_back(msFactor);
815 fDirectFluorescenceMatrix(i,i) = lldFraction * msFactor *
816 epsYTsum * fGeometricalFactor[i] / dEdX0 * deltaL;
825 CFMatrixCalculator::CalculateDirectCherenkovMatrix()
827 const Atmosphere& atmo = det::Detector::GetInstance().GetAtmosphere();
828 const std::vector<double>& lambdaVec = fCherWaveLength;
829 const fdet::FDetector& fdDetector = Detector::GetInstance().GetFDetector();
832 fDirectCherenkovMatrix.SetSize(fNumberOfDepthBins);
835 for (vector<TelescopeData>::const_iterator telIter = fTelescopeData.begin();
836 telIter != fTelescopeData.end(); ++telIter) {
838 const bool realTelescope =
839 (telIter->GetType() == TelescopeData::eInsideFOV);
840 const unsigned int telId = realTelescope? telIter->
GetId() :
848 for (vector<TelescopeDataBin>::const_iterator binIter =
849 telIter->TelDataBinsBegin();
850 binIter != telIter->TelDataBinsEnd(); ++binIter) {
852 const double showerAge =
utl::ShowerAge(binIter->GetMeanDepth(),fXmax);
855 binIter->fLastPoint, telPos, showerAge);
857 for (
unsigned int j = 0; j < lambdaVec.size(); j++) {
858 const double Y_j = directCherenkov.
GetY(j);
859 epsYTsum += Y_j * relEff.
Y(lambdaVec[j]) * fCherTransmissionToTel[i][j];
862 const double lldFraction =
870 const double msFactor =
871 1. / (1 - MultipleScatteringFraction(*binIter,
877 fCherenkovMultipleScattering.push_back(msFactor);
879 fDirectCherenkovMatrix(i) =
880 epsYTsum / fMeandEdXPerElectron[i] * msFactor * lldFraction;
889 CFMatrixCalculator::CalculateMieAndRayScattCherenkovMatrix()
891 fMieScatteredCherenkovMatrix.SetSize(fNumberOfDepthBins);
892 fRayScatteredCherenkovMatrix.SetSize(fNumberOfDepthBins);
894 const fdet::FDetector& fdDetector = Detector::GetInstance().GetFDetector();
897 const unsigned int nLambda = fCherWaveLength.size();
898 vector<double> transmission(nLambda);
901 for (vector<TelescopeData>::const_iterator telIter_i = fTelescopeData.begin();
902 telIter_i != fTelescopeData.end(); ++telIter_i) {
903 const bool realTelescope = telIter_i->GetType() == TelescopeData::eInsideFOV;
904 const unsigned int telId =
910 for (vector<TelescopeDataBin>::const_iterator binIter_i = telIter_i->TelDataBinsBegin();
911 binIter_i != telIter_i->TelDataBinsEnd(); ++binIter_i) {
913 const double msFactor = fCherenkovMultipleScattering[i];
915 for (
unsigned int k = 0; k < nLambda; ++k)
918 const bool realTelescope =
919 (telIter_i->GetType() == TelescopeData::eInsideFOV);
920 const unsigned int telId = realTelescope? telIter_i->GetId():
923 for (
int j = i; j >= 0; --j) {
927 if (IsOverlapBin(i,j)) {
928 fMieScatteredCherenkovMatrix(i, j) = 0;
929 fRayScatteredCherenkovMatrix(i, j) = 0;
933 double epsYTsumMie = 0;
934 double epsYTsumRay = 0;
935 for (
unsigned int k = 0; k < nLambda; ++k) {
938 transmission[k]*=fCherTransmissionShower[j][k];
940 const double detEff = relEff.
Y(fCherWaveLength[k]);
941 const double factor =
942 transmission[k]*detEff*fCherenkovAtTrack[j][k]*
943 fCherTransmissionToTel[i][k];
945 epsYTsumMie += factor*fMieScatToTel[i][k];
946 epsYTsumRay += factor*fRayScatToTel[i][k];
950 const double oneOverAlpha = 1 / fMeandEdXPerElectron[j];
952 fMieScatteredCherenkovMatrix(i, j) = epsYTsumMie * oneOverAlpha;
953 fRayScatteredCherenkovMatrix(i, j) = epsYTsumRay * oneOverAlpha;
961 const double lldFraction =
962 fLateralLightCalculator->GetLightFraction(lightType,
963 emissionBin, detectionBin,
967 telIter_i->GetZeta());
968 fRayScatteredCherenkovMatrix(i,j) *= (lldFraction*msFactor);
969 fMieScatteredCherenkovMatrix(i,j) *= (lldFraction*msFactor);
1002 CFMatrixCalculator::Clear()
1005 fMieScatteredCherenkovMatrix.Clear();
1006 fRayScatteredCherenkovMatrix.Clear();
1007 fDirectCherenkovMatrix.Clear();
1008 fDirectFluorescenceMatrix.Clear();
1009 fTelescopeData.clear();
1010 fNoiseTelescopeData.clear();
1011 fCherWaveLength.clear();
1012 fFluoWaveLength.clear();
1013 fCherTransmissionToTel.clear();
1014 fFluoTransmissionToTel.clear();
1015 fCherTransmissionShower.clear();
1016 fRayScatToTel.clear();
1017 fMieScatToTel.clear();
1018 fFluorescenceMultipleScattering.clear();
1019 fCherenkovMultipleScattering.clear();
1020 fCherenkovAtTrack.clear();
1021 fGeometricalFactor.clear();
1022 fZetaDistance.clear();
1023 fMeandEdXPerElectron.clear();
1027 pair<const TelescopeData*, const TelescopeDataBin*>
1028 CFMatrixCalculator::GetTelescopeDataBin(
const unsigned int i)
1032 for (std::vector<TelescopeData>::const_iterator
1033 telIter = fTelescopeData.begin();
1034 telIter != fTelescopeData.end(); ++telIter) {
1035 const unsigned int thisSize =
1036 telIter->TelDataBinsEnd()-telIter->TelDataBinsBegin();
1037 if (j + thisSize > i) {
1040 return pair<const TelescopeData*, const TelescopeDataBin*>(tel,
data);
1046 ostringstream errMsg;
1047 errMsg <<
" request bin " << i <<
" in ";
1048 for (std::vector<TelescopeData>::const_iterator telIter = fTelescopeData.begin();
1049 telIter != fTelescopeData.end(); ++telIter)
1050 errMsg <<
"(tel " << telIter->GetId() <<
" n="
1051 << telIter->TelDataBinsEnd()-telIter->TelDataBinsBegin()
1054 ERROR(errMsg.str());
1058 return pair<const TelescopeData*, const TelescopeDataBin*>
1059 (&fTelescopeData[0], &(*fTelescopeData[0].TelDataBinsBegin()));
1064 CFMatrixCalculator::IsOverlapBin(
const int i,
const int j)
1071 typedef std::pair<const TelescopeData*, const TelescopeDataBin*> TelDataPair;
1072 TelDataPair data_j = GetTelescopeDataBin(j);
1073 TelDataPair data_i = GetTelescopeDataBin(i);
1076 if (data_i.first->GetId() == data_j.first->GetId())
1080 if (data_i.first->DepthInRange(data_j.second->fMinDepth) ||
1081 data_i.first->DepthInRange(data_j.second->fMaxDepth)) {
1083 cout <<
" overlap type1, i=" << i <<
" j=" << j <<
" depth(j)="
1084 << data_j.second->GetMeanDepth()/
g*
cm2 <<
" tel_j="
1085 << data_j.first->GetId()
1086 <<
" tel_i " << data_i.first->GetId() <<
" X=["
1087 << data_i.first->GetMinDepth()/
g*
cm2 <<
","
1088 << data_i.first->GetMaxDepth()/
g*
cm2 <<
"]" << endl;
1094 for (vector<TelescopeData>::const_iterator telIter = fTelescopeData.begin();
1095 telIter != fTelescopeData.end(); ++telIter) {
1096 if (telIter->DepthInRange(data_j.second->fMinDepth) ||
1097 telIter->DepthInRange(data_j.second->fMaxDepth)) {
1098 if (telIter->GetId() != data_j.first->GetId()) {
1100 cout <<
" overlap type2, i=" << i <<
" j=" << j <<
" depth(j)="
1101 << data_j.second->GetMeanDepth()/
g*
cm2 <<
" tel_j="
1102 << data_j.first->GetId()
1103 <<
" tel_k " << telIter->GetId() <<
" X=["
1104 << telIter->GetMinDepth()/
g*
cm2 <<
","
1105 << telIter->GetMaxDepth()/
g*
cm2 <<
"]" << endl;
1115 ostringstream errMsg;
1116 errMsg <<
" logical error for i=" << i <<
" j=" << j;
1117 ERROR(errMsg.str());
1125 CFMatrixCalculator::SetTelescopeParameters(
const fevt::Eye& eye,
1129 const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
1133 double avgPEfactor = 0;
1145 avgPEfactor /= countPix;
1167 const std::vector<double>& waveLengths,
1170 const Point& telescopePosition,
1174 if (!fDoMultipleScattering)
1177 const Atmosphere& atmo = det::Detector::GetInstance().GetAtmosphere();
1212 double yieldEffSum = 0;
1213 double yieldEffAttEyeSum = 0;
1214 double yieldEffAttBinSum = 0;
1216 for (
unsigned int j = 0; j < waveLengths.size(); ++j) {
1217 const double Y_j = yield.
Y(waveLengths[j]);
1218 const double eff = efficiency.
Y(waveLengths[j]);
1219 const double attEye = rayAttShowerToEye.
GetY(j)*mieAttShowerToEye.
GetY(j);
1220 const double attBin = rayAttInBin.
GetY(j)*mieAttInBin.
GetY(j);
1222 const double yEff = Y_j*eff;
1223 yieldEffSum += yEff;
1224 yieldEffAttEyeSum += yEff*attEye;
1225 yieldEffAttBinSum += yEff*attBin;
1228 const double distanceToEye = (meanPos-telescopePosition).GetMag();
1232 const double attenuationToEye = yieldEffAttEyeSum/yieldEffSum;
1233 const double attenuationInBin = yieldEffAttBinSum/yieldEffSum;
1235 const double opticalDepth = attenuationToEye > 0 ?
1236 -log(attenuationToEye):
1238 const double alphaTot = attenuationInBin > 0 ?
1239 -log(attenuationInBin)/binLength:
1243 const double argument = opticalDepth * alphaTot/
utl::m *
1246 const double fraction = 0.774 *
pow(argument , 0.68);
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
unsigned int GetId() const
const utl::Vector & GetDirection() const
pointing direction of this pixel
Top of the interface to Atmosphere information.
const utl::TabulatedFunction & EvaluateFluorescenceYield(const double heightAboveSeaLevel) const
Evaluated Fluorescence Yield for a specific model.
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
atm::AttenuationResult EvaluateMieAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Fluorescence Detector Eye Event.
unsigned int GetId() const
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
unsigned int GetColumn(const unsigned int pixelid) const
const Pixel & GetPixel(const fevt::Pixel &eventPixel) const
Get fdet::Pixel from fevt::Channel.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Class to hold and convert a point in geodetic coordinates.
Class to hold collection (x,y) points and provide interpolation between them.
const std::string gPrintPrefix
double GetMeasuredRelativeEfficiency(const double wl) const
const atm::ProfileResult & EvaluateDistanceVsSlantDepth() const
Table of distance as a function of slant depth.
double GetGainVariance() const
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Base class for exceptions trying to access non-existing components.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Detector description interface for Eye-related data.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
unsigned int GetFirstTelescopeId() const
First telescope id in the eye.
double pow(const double x, const unsigned int i)
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
Report attempts to use invalid UTM zone.
PixelIterator PixelsEnd()
iterator pointing to end of available pixels of status eHasData (DEPRECATED)
Detector description interface for FDetector-related data.
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
A TimeStamp holds GPS second and nanosecond for some event.
Exception for reporting variable out of valid range.
Class holding the output of the ScatteringResult function.
double GetSolidAngle() const
The solid angle viewed by this pixel.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Reference ellipsoids for UTM transformations.
LightSource
Possible light sources.
Class describing the Atmospheric profile.
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
const utl::TabulatedFunction & EvaluateCherenkovDirect(const utl::Point &xA, const utl::Point &xB, const utl::Point &xEye, const double showerAge) const
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
constexpr double fraction
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
unsigned int GetId() const
Eye numerical Id.
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
boost::filter_iterator< ComponentSelector, ConstAllPixelIterator > ConstPixelIterator
constexpr double kPiOnTwo
atm::ScatteringResult EvaluateRayleighScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const
Telescope-specific shower reconstruction data.
utl::MultiTabulatedFunctionErrors & GetLightCollectionEfficiency()
Get the light-collection-efficiency multi tabulated function (for various LightSources) ...
A collection of TabulatedFunctionErrors, which provides methods to access different sources...
void GetData(bool &b) const
Overloads of the GetData member template function.
TabulatedFunctionErrors & GetTabulatedFunctionErrors(const int label=0)
Returns the TabulatedFunctionErrors for /par source.
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
const double & GetY(const unsigned int idx) const
bool HasLightCollectionEfficiency() const
Check that a light-collection-efficiency multi tabulated function exists (for various LightSources) ...
double GetReferenceLambda() const
const utl::TabulatedFunctionErrors & GetScatteringFactor() const
Scattering factor.
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.
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
double GetDiaphragmArea() const
double ShowerAge(const double slantDepth, const double showerMax)
General definition of shower age.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
void SetTelescopeParameters(double peFactor, double gainVariance, double diaArea)
utl::Point GetPosition() const
const utl::TabulatedFunction & EvaluateCherenkovPhotons(const utl::Point &xA, const utl::Point &xB, const double showerAge) const
double EnergyDeposit(const double age, const double enCut)
Parametrization for the average energy deposit per particle.
execption handling for calculation/access for inclined atmosphere model
Interface class to access to Fluorescence reconstruction of a Shower.
double GetdEdX0() const
get reference energy deposit for fluorescence yield model
const std::vector< TelescopeDataBin > & GetTelescopeDataBins() const
double CosAngle(const Vector &l, const Vector &r)
Fluorescence Detector Telescope Event.
PixelIterator PixelsBegin()
iterator pointing to first available pixel of status eHasData (DEPRECATED)
void AddZetaPixel(const ZetaPixel &pixel)
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
unsigned int GetRow(const unsigned int pixelid) const
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
double GetDiaPhoton2PEFactor(const double wavelength, const std::string &configSignature="") const
#define ERROR(message)
Macro for logging error messages.
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
const std::string & GetMessage() const
Retrieve the message from the exception.
utl::Point GetPosition() const
Eye position.
bool HasLabel(const int label) const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Class describing the Atmospheric attenuation.
void AddTelescopeDataBin(const TelescopeDataBin &telDataBin)
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
utl::Point fMeanDepthPoint
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.
atm::ScatteringResult EvaluateMieScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const