11 #include <utl/ErrorLogger.h>
12 #include <utl/Vector.h>
13 #include <utl/MathConstants.h>
14 #include <utl/PhysicalConstants.h>
15 #include <utl/PhysicalFunctions.h>
16 #include <utl/TabulatedFunction.h>
17 #include <utl/TabulatedFunctionErrors.h>
18 #include <utl/MultiTabulatedFunction.h>
19 #include <utl/ReferenceEllipsoid.h>
20 #include <utl/Reader.h>
22 #include <evt/Event.h>
23 #include <evt/ShowerRecData.h>
24 #include <evt/ShowerFRecData.h>
26 #include <fevt/FEvent.h>
28 #include <fevt/Telescope.h>
29 #include <fevt/EyeRecData.h>
31 #include <det/Detector.h>
32 #include <atm/Atmosphere.h>
33 #include <atm/ScatteringResult.h>
34 #include <atm/AttenuationResult.h>
35 #include <atm/ProfileResult.h>
37 #include <fdet/FDetector.h>
39 #include <fdet/Telescope.h>
40 #include <fdet/Pixel.h>
41 #include <fdet/Channel.h>
43 #include <utl/Vector.h>
44 #include <utl/Point.h>
46 #include <fwk/CentralConfig.h>
47 #include <fwk/CoordinateSystemRegistry.h>
48 #include <fwk/LocalCoordinateSystem.h>
52 using namespace FdCherenkovFinderOG;
96 eyeIter !=
event.GetFEvent().EyesEnd();
107 GetNPoints()<1 )
continue;
121 fCore = fRecShower->GetCorePosition();
125 .GetEye(eye).GetEyeCoordinateSystem();
127 fEyePos = det::Detector::GetInstance().GetFDetector().GetEye(eye)
135 Vector vertical(0,0,1,eyeCS);
139 fCoreDistance =
fRp/sin(
kPi - fChi0);
141 fCoreEyeVec = fCoreDistance*horizontalInSDP;
142 fCore = fEyePos + fCoreEyeVec;
147 fEfficiencyCalibration =
148 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetTelescope(1).GetMeasuredRelativeEfficiency();
150 fWavelength.resize(fEfficiencyCalibration.GetNPoints());
152 std::copy( fEfficiencyCalibration.XBegin(),
153 fEfficiencyCalibration.XEnd(),
154 fWavelength.begin()) ;
156 CherenkovFinderAtAperture(eye);
180 directCherenkovFlux.
Clear();
188 rayScattCherenkovFlux.
Clear();
196 mieScattCherenkovFlux.
Clear();
200 fRecShower->GetLongitudinalProfile() ;
202 double ghXMax = fRecShower->GetGHParameters().GetXMax();
206 const Atmosphere& atm = det::Detector::GetInstance().GetAtmosphere();
208 double atmHeightMin = dvh.
MinX();
209 double atmHeightMax = dvh.
MaxX();
211 vector<double> cherenkovAtTrack = InitialCherenkov(eye);
217 det::Detector::GetInstance().GetSiteCoordinateSystem();
222 double rayScattCkv = 0.0;
223 double mieScattCkv = 0.0;
225 vector<double> vecDirCkv(fWavelength.size());
226 vector<double> vecRayScattCkv(fWavelength.size());
227 vector<double> vecMieScattCkv(fWavelength.size());
229 const double lambdaRef =
230 det::Detector::GetInstance().GetFDetector().GetReferenceLambda();
231 const double epsilonRef = fEfficiencyCalibration.
Y(lambdaRef);
236 for(iter = lightFlux.
Begin(); iter != lightFlux.
End(); ++iter) {
238 double time = iter->
X();
242 double l = fCoreEyeVec.GetMag()*sin(chiAv)/sin(fChi0 - chiAv);
244 double time1 = time/
ns - dtime/
ns;
246 double l1 = fCoreEyeVec.GetMag()*sin(chi1)/sin(fChi0 - chi1);
248 double time2 = time/
ns + dtime/
ns;
250 double l2 = fCoreEyeVec.GetMag()*sin(chi2)/sin(fChi0 - chi2);
253 Vector chiAvVec = fCoreEyeVec + l*fAxis;
255 Point pos1 = fCore + l1*fAxis;
256 Point pos2 = fCore + l2*fAxis;
260 if ((pos1_z>atmHeightMax || pos1_z<atmHeightMin) ||
261 (pos2_z>atmHeightMax || pos2_z<atmHeightMin)) {
262 directCherenkovFlux.
PushBack(time,0,0,0);
263 rayScattCherenkovFlux.
PushBack(time,0,0,0);
264 mieScattCherenkovFlux.
PushBack(time,0,0,0);
269 double xpos = (pos1.
GetX(siteCS) + pos2.
GetX(siteCS))/2.0;
270 double ypos = (pos1.
GetY(siteCS) + pos2.
GetY(siteCS))/2.0;
271 double zpos = (pos1.
GetZ(siteCS) + pos2.
GetZ(siteCS))/2.0;
273 Point avepos(xpos,ypos,zpos,siteCS);
280 const double slantDepth = longitudinalProfile.
GetX(n);
281 const double showerAge =
ShowerAge(slantDepth, xMax);
301 for(
unsigned int w = 0; w < fWavelength.size(); w++) {
303 cherenkovAtTrack[w] *= mieAtt.
GetY(w)*rayleighAtt.
GetY(w);
304 if (longitudinalProfile.
GetY(n)>0.0)
305 cherenkovAtTrack[w] += CherenkovProd.
GetY(w)*longitudinalProfile.
GetY(n);
310 double disteye = (avepos - fEyePos).GetMag();
313 double angle = fChi0 - chiAv;
335 for(
unsigned int i=0; i<fWavelength.size(); i++) {
338 if(longitudinalProfile.
GetY(n)>0.0) {
340 vecDirCkv[i] = directCherenkov.
GetY(i)*longitudinalProfile.
GetY(n);
341 vecDirCkv[i] *= mieAttTrackEye.
GetY(i)*rayleighAttTrackEye.
GetY(i);
343 dirCkv += vecDirCkv[i]*fEfficiencyCalibration[i].Y()/epsilonRef;
366 for(
unsigned int i=0; i<fWavelength.size(); i++) {
368 vecRayScattCkv[i] = 0.0;
369 vecMieScattCkv[i] = 0.0;
371 vecRayScattCkv[i] = cherenkovAtTrack[i]
372 *rayleighScattTrackEye.
GetY(i);
373 vecMieScattCkv[i] = cherenkovAtTrack[i]
374 *mieScattTrackEye.
GetY(i);
376 vecRayScattCkv[i] *= mieAttTrackEye.
GetY(i)
377 *rayleighAttTrackEye.
GetY(i);
378 vecMieScattCkv[i] *= mieAttTrackEye.
GetY(i)
379 *rayleighAttTrackEye.
GetY(i);
381 rayScattCkv += vecRayScattCkv[i]
382 *fEfficiencyCalibration[i].Y()/epsilonRef;
383 mieScattCkv += vecMieScattCkv[i]
384 *fEfficiencyCalibration[i].Y()/epsilonRef;
388 directCherenkovFlux.
PushBack(time,0,dirCkv,0);
389 rayScattCherenkovFlux.
PushBack(time,0,rayScattCkv,0);
390 mieScattCherenkovFlux.
PushBack(time,0,mieScattCkv,0);
406 fRecShower->GetLongitudinalProfile() ;
408 const Atmosphere& atm = det::Detector::GetInstance().GetAtmosphere();
410 cout <<
"- " << longitudinalProfile.
GetNPoints() << endl;
412 double xInit = longitudinalProfile.
GetX(0);
413 double sizeInit = longitudinalProfile.
GetY(0);
415 cout <<
"-- " << xInit <<
" " << sizeInit << endl;
417 double ghXMax = fRecShower->GetGHParameters().GetXMax();
419 int xBin = int((xInit - fX0)/fStep);
427 double normSize = 0.0;
429 vector<double> cherenkov;
430 for(
unsigned int w=0; w<fWavelength.size(); w++)
431 cherenkov.push_back(0.);
439 double cosZenithAngle = fAxis.GetCosTheta(coreCS);
442 double atmDepthMin = hvd.
MinX();
443 double atmDepthMax = hvd.
MaxX();
445 for(
int i=0; i<xBin; i++) {
448 x1 = fX0 + (double(i) - 1.0)*fStep;
449 x2 = fX0 + double(i)*fStep;
451 xMed = (x1 + x2)*0.5;
455 size *= sizeInit/normSize;
462 double depth1=x1*cosZenithAngle;
463 double depth2=x2*cosZenithAngle;
464 if( depth1<atmDepthMin || depth1>atmDepthMax ||
465 depth2<atmDepthMin || depth2>atmDepthMax ) {
470 double h1 = hvd.
Y(depth1);
471 double h2 = hvd.
Y(depth2);
474 if (h1 !=0. && h2 !=0.) {
481 double l1 = h1/cosZenithAngle;
482 double l2 = h2/cosZenithAngle;
485 Point pos1 = fCore + l1*fAxis;
486 Point pos2 = fCore + l2*fAxis;
488 const double showerAge =
ShowerAge(xMed, xMax);
508 for(
unsigned int w=0; w<fWavelength.size(); w++) {
510 cherenkov.at(w) *= mieAtt.
GetY(w)*rayleighAtt.
GetY(w);
511 cherenkov.at(w) += cherenkovProd.
GetY(w)*size;
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
unsigned int GetNPoints() const
Top of the interface to Atmosphere information.
bool HasLightFlux(const FdConstants::LightSource source=FdConstants::eTotal) const
Check that light profile for source /par source is present.
atm::AttenuationResult EvaluateMieAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Fluorescence Detector Eye Event.
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
double GetChiZero() const
Class to hold collection (x,y) points and provide interpolation between them.
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
Class holding the output of the ScatteringResult function.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Reference ellipsoids for UTM transformations.
bool HasLongitudinalProfile() const
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Class describing the Atmospheric profile.
const utl::TabulatedFunction & EvaluateCherenkovDirect(const utl::Point &xA, const utl::Point &xB, const utl::Point &xEye, const double showerAge) const
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
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)
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
atm::ScatteringResult EvaluateRayleighScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const
std::vector< double > InitialCherenkov(fevt::Eye &eye) const
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.
Eye-specific shower reconstruction data.
const double & GetY(const unsigned int idx) const
const utl::AxialVector & GetSDP() const
double GaisserHillas(const double x, const double x0, const double xMax, const double nMax, const double lambda)
Calculate the Gaisser-Hillas function.
fevt::FEvent & GetFEvent()
fwk::VModule::ResultFlag CherenkovFinderAtAperture(fevt::Eye &eye)
bool HasGHParameters() const
const utl::TabulatedFunctionErrors & GetScatteringFactor() const
Scattering factor.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
constexpr double kSpeedOfLight
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
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)
constexpr double kLambdaGH
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.
const utl::TabulatedFunction & EvaluateCherenkovPhotons(const utl::Point &xA, const utl::Point &xB, const double showerAge) const
const double & GetX(const unsigned int idx) const
Main configuration utility.
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
const atm::ProfileResult & EvaluateHeightVsDepth() const
Tabulated function giving Y=height as a function of X=depth.
utl::TabulatedFunctionErrors & GetLightFlux(const FdConstants::LightSource source=fevt::FdConstants::eTotal)
Light flux at diaphragm, photons/m^2 versus time in ns.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
void MakeLightFlux(const FdConstants::LightSource source=FdConstants::eTotal)
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Class describing the Atmospheric attenuation.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.
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