7 #include <utl/ErrorLogger.h>
8 #include <utl/AugerUnits.h>
9 #include <utl/PhysicalFunctions.h>
11 #include <fevt/EyeRecData.h>
12 #include <fevt/Telescope.h>
13 #include <fevt/TelescopeRecData.h>
14 #include <evt/ShowerFRecData.h>
20 using namespace FdEnergyDepositFinderKG;
26 ProfileCalculator::CalculateProfile(
Eye& eye,
32 const unsigned int matrixSize =
35 vector<double> lightFluxVariance(matrixSize);
36 vector<double> fluxFitVariance(matrixSize);
37 vector<double> lightFluxTime(matrixSize);
38 vector<double> lightFluxTimeBin(matrixSize);
39 vector<double> gainVarVec(matrixSize);
40 vector<double> bgVarVec(matrixSize);
41 vector<double> fluxToPhotonVec(matrixSize);
42 vector<double> depthVec(matrixSize);
44 using namespace FdConstants;
65 eyeRecData.GetLightFlux(
eTotal);
68 set<unsigned int> inFOVbins;
73 for (vector<TelescopeDataBin>::const_iterator binIter =
74 telIter->TelDataBinsBegin();
75 binIter != telIter->TelDataBinsEnd(); ++binIter) {
77 if (telIter->GetType() == TelescopeData::eInsideFOV)
80 lightFlux(i) = binIter->fSignal;
81 lightFluxVariance[i] =
pow(binIter->fSignalErr,2);
82 lightFluxTime[i] = binIter->fTime;
83 lightFluxTimeBin[i] = binIter->fTimeBinHalfWidth;
84 depthVec[i] = binIter->GetMeanDepth();
86 bgVarVec[i] = binIter->fBackgroundVariance;
87 gainVarVec[i] = telIter->GetGainVariance();
88 fluxToPhotonVec[i] = telIter->GetDiaphragmArea() *
89 telIter->GetPhotonToPhotoElectron();
104 double xMax = shower.HasGHParameters() ?
105 shower.GetGHParameters().GetXMax() :
108 const double electronEnergyThreshold = shower.GetEnergyCutoff();
112 if (shower.HasGHParameters()) {
114 for (
unsigned int i = 0; i < matrixSize; ++i)
115 ghdEdXVec(i) = shower.GetGHParameters().Eval(depthVec[i]);
131 if (shower.HasGHParameters()) {
132 for (
unsigned int i = 0; i < matrixSize; ++i) {
133 if (inFOVbins.find(i) == inFOVbins.end()) {
134 const double lightSum = cherenkovFlux(i) +
135 fluorescenceFlux(i) +
136 rayScatteredCherenkovFlux(i) +
137 mieScatteredCherenkovFlux(i);
138 lightFlux(i) = lightSum;
141 dEdXVec = inverseCFM*lightFlux;
145 for (
unsigned int i = 0; i < matrixSize; ++i) {
146 if (inFOVbins.find(i) != inFOVbins.end()) {
147 const double kFluxToPe = fluxToPhotonVec[i];
148 const double kFluxToPe2 = kFluxToPe * kFluxToPe;
149 const double gainVariance = gainVarVec[i];
150 const double totalFitLight = cherenkovFlux(i) +
151 fluorescenceFlux(i) +
152 rayScatteredCherenkovFlux(i) +
153 mieScatteredCherenkovFlux(i);
154 const double bgVariance = bgVarVec[i];
155 const double nPeBackground =
156 bgVariance*kFluxToPe2 / (1 + gainVariance);
159 const double nPeSignal = fmax(0, totalFitLight*kFluxToPe);
160 const double nPeExp = nPeSignal + nPeBackground;
161 const double fluxVariance = nPeExp*(1 + gainVariance) / kFluxToPe2;
162 fluxFitVariance[i] = fluxVariance;
164 fluxFitVariance[i] = 0;
168 for (
unsigned int i = 0; i < matrixSize; ++i) {
170 if (inFOVbins.find(i) != inFOVbins.end()) {
172 double varianceSum = 0.;
173 for (
unsigned int k = 0; k <= i; ++k)
174 varianceSum += inverseCFM(i,k)*inverseCFM(i,k)*fluxFitVariance[k];
176 dedxProfile.PushBack(depthVec[i], 0., dEdXVec(i),
sqrt(varianceSum));
179 dirCher.PushBack(lightFluxTime[i], lightFluxTimeBin[i],
180 cherenkovFlux(i), 0.);
181 scatMCher.PushBack(lightFluxTime[i], lightFluxTimeBin[i],
182 mieScatteredCherenkovFlux(i), 0.);
183 scatRCher.PushBack(lightFluxTime[i], lightFluxTimeBin[i],
184 rayScatteredCherenkovFlux(i), 0.);
185 fluorTot.PushBack(lightFluxTime[i], lightFluxTimeBin[i],
186 fluorescenceFlux(i), 0);
187 fluorDir.PushBack(lightFluxTime[i], lightFluxTimeBin[i],
188 fluorescenceFlux(i), 0);
189 totalLight.PushBack(lightFluxTime[i], lightFluxTimeBin[i],
190 lightFlux(i),
sqrt(lightFluxVariance[i]));
194 electronEnergyThreshold);
195 sizeProfile.PushBack(depthVec[i],0.,dEdXVec(i)/alpha,
196 sqrt(varianceSum)/alpha);
199 cherMS.PushBack(0,0,0,0);
200 fluorMS.PushBack(0,0,0,0);
210 if (telIter->GetType() == TelescopeData::eInsideFOV) {
234 for (vector<TelescopeDataBin>::const_iterator binIter = telIter->TelDataBinsBegin();
235 binIter != telIter->TelDataBinsEnd(); ++binIter) {
236 if (inFOVbins.find(iMatrixBin) != inFOVbins.end()) {
237 telDirCher.
PushBack(lightFluxTime[iMatrixBin],
238 lightFluxTimeBin[iMatrixBin],
239 cherenkovFlux(iMatrixBin), 0.);
240 telScatMCher.
PushBack(lightFluxTime[iMatrixBin],
241 lightFluxTimeBin[iMatrixBin],
242 mieScatteredCherenkovFlux(iMatrixBin), 0.);
243 telScatRCher.
PushBack(lightFluxTime[iMatrixBin],
244 lightFluxTimeBin[iMatrixBin],
245 rayScatteredCherenkovFlux(iMatrixBin), 0.);
246 telFluorTot.
PushBack(lightFluxTime[iMatrixBin],
247 lightFluxTimeBin[iMatrixBin],
248 fluorescenceFlux(iMatrixBin), 0);
249 telFluorDir.
PushBack(lightFluxTime[iMatrixBin],
250 lightFluxTimeBin[iMatrixBin],
251 fluorescenceFlux(iMatrixBin), 0);
261 iMatrixBin += telIter->GetTelescopeDataBins().size();
274 ProfileCalculator::InitProfiles(
Eye& eye)
295 using namespace FdConstants;
338 if (!telIt->HasRecData())
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
bool HasLightFlux(const FdConstants::LightSource source=FdConstants::eTotal) const
Check that light profile for source /par source is present.
Fluorescence Detector Eye Event.
bool HasFluorescencePhotons() const
void MakeLongitudinalProfile()
void SetSize(const int n)
Set the size of the vector. Does NOT initialize elements to 0.
unsigned int GetSize() const
void MakeFluorescencePhotons()
fevt::TelescopeRecData & GetRecData()
Reconstructed data for this telescope.
double pow(const double x, const unsigned int i)
ConstTelDataIterator AllTelDataBegin() const
std::vector< TelescopeData >::const_iterator ConstTelDataIterator
const LowerTriangularMatrix & GetMieScatteredCherenkovMatrix() const
utl::TabulatedFunctionErrors & GetLightFlux(const FdConstants::LightSource source=fevt::FdConstants::eTotal)
Light flux at diaphragm, photons/m^2 versus time in ns.
bool HasLongitudinalProfile() const
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
bool HasLightFlux(const FdConstants::LightSource source=FdConstants::eTotal) const
Check that light profile for source /par source is present.
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
Telescope-specific shower reconstruction data.
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
void PushBack(const double x, const double xErr, const double y, const double yErr)
Eye-specific shower reconstruction data.
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
const DiagonalMatrix & GetDirectFluorescenceMatrix() const
utl::TabulatedFunctionErrors & GetLongitudinalProfile()
retrieve longitudinal profile information (size vs depth)
utl::TabulatedFunctionErrors & GetFluorescencePhotons()
retrieve number of fluorescence photons versus depth
total (shower and background)
unsigned int GetSize() const
double EnergyDeposit(const double age, const double enCut)
Parametrization for the average energy deposit per particle.
Interface class to access to Fluorescence reconstruction of a Shower.
void MakeLightFlux(const FdConstants::LightSource source=FdConstants::eTotal)
const LowerTriangularMatrix & GetRayScatteredCherenkovMatrix() const
Fluorescence Detector Telescope Event.
utl::TabulatedFunctionErrors & GetLightFlux(const FdConstants::LightSource source=fevt::FdConstants::eTotal)
Light flux at diaphragm, photons/m^2 versus time in ns.
#define ERROR(message)
Macro for logging error messages.
ConstTelDataIterator AllTelDataEnd() const
const DiagonalMatrix & GetDirectCherenkovMatrix() const
const std::string & GetMessage() const
Retrieve the message from the exception.
bool HasEnergyDeposit() const
void MakeLightFlux(const FdConstants::LightSource source=FdConstants::eTotal)
utl::TabulatedFunctionErrors & GetEnergyDeposit()
retrieve dE/dX
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.