10 #include <utl/ErrorLogger.h>
11 #include <utl/Reader.h>
12 #include <utl/Vector.h>
13 #include <utl/Point.h>
14 #include <utl/PhysicalConstants.h>
15 #include <utl/TabulatedFunctionErrors.h>
16 #include <utl/MathConstants.h>
17 #include <utl/PairErr.h>
19 #include <evt/Event.h>
20 #include <evt/ShowerFRecData.h>
21 #include <evt/GaisserHillas4Parameter.h>
24 #include <fevt/FEvent.h>
26 #include <fevt/Telescope.h>
27 #include <fevt/EyeHeader.h>
28 #include <fevt/EyeRecData.h>
29 #include <fevt/TelescopeRecData.h>
30 #include <fevt/FdConstants.h>
31 #include <fevt/Pixel.h>
33 #include <fwk/CentralConfig.h>
34 #include <fwk/RunController.h>
35 #include <fwk/CoordinateSystemRegistry.h>
36 #include <fwk/LocalCoordinateSystem.h>
38 #include <det/Detector.h>
40 #include <fdet/FDetector.h>
42 #include <fdet/Telescope.h>
43 #include <fdet/Camera.h>
45 #include <atm/Atmosphere.h>
46 #include <atm/InclinedAtmosphericProfile.h>
47 #include <atm/ProfileResult.h>
52 using namespace FdLaserEnergyReconstructorKG;
69 ERROR(
"Could not find branch FdLaserEnergyReconstructorKG");
98 eyeiter !=
event.GetFEvent().EyesEnd(ComponentSelector::eHasData); ++eyeiter) {
103 cout <<
" no recData for eye " << eye.
GetId() <<
" --> skip! " << endl;
107 GetGeometryData(eye);
138 teliter != eye.
TelescopesEnd(ComponentSelector::eHasData); ++teliter) {
144 GetTelescopeData(tel, detTel);
149 pixiter != tel.
PixelsEnd(ComponentSelector::eHasData); ++pixiter) {
151 const Pixel& pix = *pixiter;
156 if (pixels < fPixelsWithPeak) {
157 string msg =
"Telescope with to few pixels";
165 cout <<
"No LightFlux for this Eye ---> skip" << endl;
173 for (
int i = 1; i <= int(fTraceLength); ++i) {
175 const int midTimeBin = int(i * fBinSize - 0.5 * fBinSize);
179 if (
int(bin.
X()) == midTimeBin) {
186 const utl::Point pointAtLaserBeam = CalculateLaserBeamPosition(
double(i));
188 const double Coefficient = CalculateAtmosphereCoefficient(atmos, pointAtLaserBeam, eff, i);
194 const double distanceToCore = (pointAtLaserBeam - fCore).GetMag();
195 if (distanceToCore < atmMinDistance || distanceToCore > atmMaxDistance) {
196 cerr <<
"Error - point outside atmosphere, d=" << distanceToCore << endl;
200 const double X = slantDepthProfile.
Y(distanceToCore);
202 const double w = 1 /
pow(recEnergyErr, 2);
203 sum += w * recEnergy;
207 dedxProfile.
PushBack(X, 0, recEnergy/
g*
cm2, recEnergyErr/
g*cm2);
208 longProfile.
PushBack(X, 0, recEnergy, recEnergyErr);
216 const double avEnergy = sum / wsum;
217 const double avEnergyErr =
sqrt(1 / wsum);
219 if (std::isnan(avEnergy) || std::isnan(avEnergyErr) || avEnergy < 1 || avEnergyErr < 1) {
220 cout <<
"Energy Reconstruction failed! --> skip" << endl;
228 unsigned int ndf = 0;
229 double chisquared = 0;
230 bool setchisquared =
false;
235 chisquared +=
pow(((bin.
Y() - avEnergy) / bin.
YErr()), 2);
239 setchisquared =
true;
270 fGPSTime -
TimeInterval(((fTraceLength - bin) * fBinSize - (fBinSize / 2) + static_cast<double>(fTelTimeOffset)));
273 const double deltaT = (binTime - fCoreTime).GetInterval();
280 return fCore - factor * fAxis;
288 const double efficiency,
292 const utl::Point pointAtLaserBeamA = CalculateLaserBeamPosition(i - 0.5);
293 const utl::Point pointAtLaserBeamB = CalculateLaserBeamPosition(i + 0.5);
294 const utl::Vector eyeToPointLaser = pointAtLaserBeam - fTelPos;
295 const double angle =
Angle(-eyeToPointLaser, fAxis);
305 const double SMie = atmos.
EvaluateMieScattering(pointAtLaserBeamA, pointAtLaserBeamB, angle, eyeToPointLaser.
GetMag(), fLaserWaveLength);
306 const double STot = SMie + SRay;
308 const double Coefficient = TRay1 * TRay2 * TMie1 * TMie2 * STot * efficiency;
unsigned int GetId() const
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
double GetFADCBinSize() const
bool HasLightFlux(const FdConstants::LightSource source=FdConstants::eTotal) const
Check that light profile for source /par source is present.
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
void InitSlantProfileModel(const utl::Point &core, const utl::Vector &dir, const double deltaX) const
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.
unsigned int GetTimeOffset() const
Time offset of this Telescope compared to fevt::Header::GetTime [ns].
Fluorescence Detector Eye Event.
void MakeLongitudinalProfile()
A pair of graph points (x,y) with errors.
double GetMeasuredRelativeEfficiency(const double wl) const
#define INFO(message)
Macro for logging informational messages.
utl::Point CalculateLaserBeamPosition(const double bin)
void SetShapeParameter(const gh::EShapeParameter par, const double value, const double error)
Setters.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
fevt::TelescopeRecData & GetRecData()
Reconstructed data for this telescope.
double pow(const double x, const unsigned int i)
bool PulseIsFound() const
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
PixelIterator PixelsEnd()
iterator pointing to end of available pixels of status eHasData (DEPRECATED)
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.
const atm::Atmosphere & GetAtmosphere() const
utl::TabulatedFunctionErrors & GetLightFlux(const FdConstants::LightSource source=fevt::FdConstants::eTotal)
Light flux at diaphragm, photons/m^2 versus time in ns.
Class representing a document branch.
bool IsSpotFarFromBorder(const double timeRelToEyeTriggerTime) const
bool HasLongitudinalProfile() const
Fluorescence Detector Pixel event.
Class describing the Atmospheric profile.
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
void GetTelescopeData(const fevt::Telescope &tel, const fdet::Telescope &detTel)
constexpr double millimeter
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
Top of the hierarchy of the detector description interface.
bool HasFRecShower() const
Check if reconstructed shower info has been allocated.
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
EyeIterator EyesBegin(const ComponentSelector::Status status)
boost::filter_iterator< ComponentSelector, ConstAllPixelIterator > ConstPixelIterator
const fdet::FDetector & GetFDetector() const
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
atm::ScatteringResult EvaluateRayleighScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
void PushBack(const double x, const double xErr, const double y, const double yErr)
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetChiSquare(const double chi, const unsigned int ndof)
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
fevt::FEvent & GetFEvent()
bool HasGHParameters() const
constexpr double kSpeedOfLight
Detector description interface for Telescope-related data.
void GetGeometryData(const fevt::Eye &eye)
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.
utl::TabulatedFunctionErrors & GetLongitudinalProfile()
retrieve longitudinal profile information (size vs depth)
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
unsigned int GetId() const
utl::Point GetPosition() const
execption handling for calculation/access for inclined atmosphere model
Interface class to access to Fluorescence reconstruction of a Shower.
Main configuration utility.
constexpr double kSpeedOfLight2
Fluorescence Detector Telescope Event.
PixelIterator PixelsBegin()
iterator pointing to first available pixel of status eHasData (DEPRECATED)
Gaisser Hillas with 4 parameters.
void SetTotalEnergy(const double energy, const double energyError, const EUncertaintyType type=eTotal)
void MakeGHParameters(const VGaisserHillasParameter &gh)
const atm::ProfileResult & EvaluateSlantDepthVsDistance() const
#define ERROR(message)
Macro for logging error messages.
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
int GetFADCTraceLength() const
const std::string & GetMessage() const
Retrieve the message from the exception.
bool HasEnergyDeposit() const
double CalculateAtmosphereCoefficient(const atm::Atmosphere &atmos, const utl::Point pointAtLaserBeam, const double eps, const double i)
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
PixelRecData & GetRecData()
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
const utl::TimeStamp & GetCoreTime() const
time when shower front passes through the core point
utl::TabulatedFunctionErrors & GetEnergyDeposit()
retrieve dE/dX
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