2 #include <fwk/LocalCoordinateSystem.h>
3 #include <fwk/CoordinateSystemRegistry.h>
4 #include <fwk/CentralConfig.h>
5 #include <fwk/RunController.h>
8 #include <evt/ShowerRecData.h>
9 #include <evt/ShowerSRecData.h>
10 #include <evt/ShowerSimData.h>
11 #include <evt/AtmosphereParameters.h>
13 #include <sevt/SEvent.h>
14 #include <sevt/Station.h>
15 #include <sevt/PMTCalibData.h>
16 #include <sevt/PMTRecData.h>
17 #include <sevt/StationRecData.h>
18 #include <sevt/Header.h>
20 #include <det/Detector.h>
22 #include <sdet/SDetector.h>
23 #include <sdet/STimeVariance.h>
25 #include <atm/Atmosphere.h>
26 #include <atm/InclinedAtmosphericProfile.h>
28 #include <utl/MathConstants.h>
29 #include <utl/CoordinateSystemPtr.h>
30 #include <utl/AxialVector.h>
31 #include <utl/Vector.h>
32 #include <utl/Point.h>
33 #include <utl/AugerUnits.h>
34 #include <utl/ReferenceEllipsoid.h>
35 #include <utl/PhysicalConstants.h>
36 #include <utl/UTMPoint.h>
37 #include <utl/TimeStamp.h>
38 #include <utl/Trace.h>
39 #include <utl/ErrorLogger.h>
40 #include <utl/TraceAlgorithm.h>
41 #include <utl/AugerException.h>
42 #include <utl/UTCDateTime.h>
57 using namespace MuonProductionDepthFinderGL;
62 const vector<double>& hl,
63 const vector<double>& al,
const vector<double>& bl,
const vector<double>& cl)
65 for (
unsigned int i = 0; i < 4; ++i)
66 if (hl[i] <= h && h < hl[i+1])
67 return al[i] + bl[i] * exp(-h / cl[i]);
69 const double hTopAtmosphere = al[4] * cl[4] / bl[4];
70 if (hl[4] <= h && h < hTopAtmosphere)
71 return al[4] - bl[4] * (h / cl[4]);
79 const vector<double>& hl,
80 const vector<double>& al,
const vector<double>& bl,
const vector<double>& cl)
83 for (
unsigned int i = 0; i < 5; ++i)
84 xl[i] =
ZToDepth(hl[i], hl, al, bl, cl);
86 for (
unsigned int i = 0; i < 4; ++i)
87 if (xl[i] >= x && x > xl[i+1])
88 return -cl[i] * log((x - al[i]) / bl[i]);
90 if (xl[4] >= x && x > 0)
91 return cl[4] * (al[4] - x) / bl[4];
99 ZToSlantDepth(
const double zcground,
const double theta,
const double z,
100 const vector<double>& hl,
101 const vector<double>& al,
const vector<double>& bl,
const vector<double>& cl,
102 const bool curvature)
104 double zinjection = (al[4] * cl[4]) / bl[4];
106 const double x0 =
ZToDepth(zinjection, hl, al, bl, cl);
108 const double cosTheta = cos(theta);
110 const double rEarth = 6371315.*
meter;
111 const double rEarth2 = 2 * rEarth;
117 const double coplanemin = 0.996;
118 const double deltax0 = 0.4;
119 const double xquantum = 0.000000000002;
123 cout <<
"ERROR: you are using an wrong zenith angle (> 90 deg)" << endl;
125 if (cosTheta < coplanemin && curvature) {
128 sqrt(z*z + 2 * z * (rEarth + zcground) * cosTheta + (rEarth + zcground) * (rEarth + zcground)) - rEarth;
129 const double xvertical =
ZToDepth(zv, hl, al, bl, cl);
130 const bool xsign = (x0 > xvertical);
142 const double cozen2 = cosTheta * cosTheta;
143 const double xvrfact0 = deltax0 * cozen2;
144 const double xvrfact = 1 + xvrfact0;
145 const double xvqx =
max(0.0001 * xvmax, xquantum);
146 const double xvl0 = xvqx / xvrfact0;
147 const double zgrsz2 = 4 * (1 - cozen2) * (zcground + rEarth) * (zcground + rEarth);
151 const double xvp = xv;
161 const double zvp = zv;
164 const double sizprim2 = zgrsz2 /((zv + zvp + rEarth2) * (zv + zvp + rEarth2));
165 xpath += (xv - xvp) /
sqrt(1 - sizprim2);
168 return xsign ? -xpath : xpath;
173 const double zv = z * cosTheta + zcground;
174 const double xvertical =
ZToDepth(zv, hl, al, bl, cl);
175 return (xvertical - x0) / cosTheta;
191 return -0.6085 + logz * (1.955 + logz * (-0.3299 + logz * 0.0186));
198 const double lgz = log10(z);
200 return p0 /
pow(r, 1.1758);
207 INFO(
"MuonProductionDepthFinder::Init()");
210 const Branch& topBranch = theCentralConfig->
GetTopBranch(
"MuonProductionDepthFinder");
219 topBranch.
GetChild(
"usePionPathCorrection").
GetData(fUsePionPathCorrection);
223 topBranch.
GetChild(
"tblEnergy").
Get<vector<double> >(),
224 topBranch.
GetChild(
"tblRadiusCut").
Get<vector<double> >()
232 MuonProductionDepthFinder::Run(
Event& event)
234 INFO(
"MuonProductionDepthFinder::Run()");
236 if (!(event.
HasSEvent() &&
event.HasRecShower() &&
237 event.GetRecShower().HasSRecShower()))
238 return eContinueLoop;
240 InitCoordinateSys(event, 0, 0, 0, 0);
241 SetMuonProductionDepthHist(event);
248 MuonProductionDepthFinder::Finish()
250 INFO(
"MuonProductionDepthFinder::Finish()");
257 MuonProductionDepthFinder::InitCoordinateSys(
const Event& event,
258 const double dX,
const double dY,
259 const double dTheta,
const double dPhi)
261 INFO(
"MuonProductionDepthFinder::InitCoordSys()");
272 const Vector shiftcore(dX, dY, 0, originallocalCS);
273 fCore = originalcore + shiftcore;
278 fTheta = axis.
GetTheta(originallocalCS) + dTheta;
279 fPhi = axis.
GetPhi(originallocalCS) + dPhi;
283 CoordinateSystem::RotationZ(fPhi, fLocalCS);
284 fShowerCS = CoordinateSystem::RotationY(fTheta, alignedCS);
286 if (!fUseConstRadiusCut) {
287 if (showersrec.
GetEnergy() < fTblFuncRadiusCut.GetX(0))
288 fRadiusCut = fTblFuncRadiusCut.GetY(0);
289 else if (showersrec.
GetEnergy() > fTblFuncRadiusCut.GetX(fTblFuncRadiusCut.GetNPoints() - 1))
290 fRadiusCut = fTblFuncRadiusCut.GetY(fTblFuncRadiusCut.GetNPoints() - 1);
292 fRadiusCut = fTblFuncRadiusCut.Y(showersrec.
GetEnergy());
298 MuonProductionDepthFinder::SetMuonProductionDepthHist(
Event& event)
300 INFO(
"MuonProductionDepthFinder::SetMuonProductionDepthHist()");
306 const det::Detector& detector = det::Detector::GetInstance();
314 const bool hasSimEvent =
event.HasSimShower();
318 fAATM = atmospherePars.
GetA();
319 fBATM = atmospherePars.
GetB();
320 fCATM = atmospherePars.
GetC();
323 const Atmosphere& atmo = Detector::GetInstance().GetAtmosphere();
333 const double cosZenith = cos(fTheta);
334 const double sinZenith = sin(fTheta);
344 const double tankHeight = dStation.
GetHeight();
345 const double tankRadius = dStation.
GetRadius();
346 const double vemCorrection =
347 cosZenith + 2 * tankHeight * sinZenith/(
kPi * tankRadius);
352 bool useItInTheMPD =
true;
354 useItInTheMPD =
false;
357 const Vector sRelPos = sPosition - fCore;
359 const double delta = sRelPos.
GetZ(fShowerCS);
360 const double r = sRelPos.
GetRho(fShowerCS);
361 const double r2 = r * r;
363 const TimeStamp fArrivalTimeOfShowerPlane =
365 const double fStartTimeReferredToArrivalOfShowerPlane =
375 useItInTheMPD =
false;
379 useItInTheMPD =
false;
381 const int numberOfPMTs = distance(sIt->PMTsBegin(), sIt->PMTsEnd());
383 vector<pair<double, double> > depthSignalVector;
386 pIt != sIt->PMTsEnd(); ++pIt) {
387 depthSignalVector.clear();
389 if (!pIt->HasRecData())
406 for (
unsigned int i = startBin; i < endBin; ++i)
407 peak =
max(peak, vemtraceTot[i]);
411 fSignalThreshold = peak * 0.15;
413 for (
unsigned int i = startBin; i < endBin; ++i) {
416 (fStartTimeReferredToArrivalOfShowerPlane + (i+0.5 - startBin) * fadcBinSize - fTimeShift) *
422 double zmdelta = 0.5 * (r2 / ct - ct);
423 double z = zmdelta + delta;
428 for (
unsigned int j = 0; j < 2; ++j) {
429 const double epsilon =
EpsilonRz(r, zmdelta);
430 const double dcte = ct - epsilon * 0.5 * r2 / (
sqrt(r2 + zmdelta * zmdelta));
431 zmdelta = 0.5 * (r2 / dcte - dcte);
442 if (fUsePionPathCorrection) {
443 const double energyPion = 1500.*
GeV *
pow(r, -0.84);
444 const double massPion = 139.57*
MeV;
445 const double ctauPion = 7.8045*
meter;
446 const double zPion = z /
sqrt(r2 + z*z) * ctauPion * energyPion / massPion;
450 if (vemtraceTot[i] > fSignalThreshold && z > 0) {
455 const bool curvature =
false;
456 fSlantDepth =
ZToSlantDepth(zground, fTheta, z, fHLAY, fAATM, fBATM, fCATM, curvature);
461 const double atmMinDistance = fSlantDepthProfile.MinX() + 1*
mm;
462 const double atmMaxDistance = fSlantDepthProfile.MaxX() - 1*
mm;
463 const double distance = -z;
464 if (distance < atmMinDistance || distance > atmMaxDistance)
466 fSlantDepth = fSlantDepthProfile.Y(distance);
470 const double signal = vemCorrection * vemtraceTot[i] / numberOfPMTs;
473 depthSignalVector.push_back(make_pair(fSlantDepth, signal));
478 if (!depthSignalVector.empty()) {
482 for (
unsigned int i = 0, n = depthSignalVector.size(); i < n; ++i) {
491 const double deltaX = 0;
492 mpdProfile.
PushBack(depthSignalVector[i].first, deltaX, depthSignalVector[i].
second, 0);
503 MuonProductionDepthFinder::IsContained(
const SEvent& sevent)
506 const SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
513 const unsigned int neighbours = dStation.
GetCrown(1).size();
void MakeMPDHistogram(const int nBins, const double min, const double max)
Top of the interface to Atmosphere information.
StationIterator StationsEnd()
End of all stations.
const StationIdCollection & GetCrown(const int level) const
Returns a list of station id's in the crown. If the argument is 0, it returns the station id...
bool HasMPDHistogram() const
utl::TraceD & GetVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
Traces calibrated in VEM Peak.
const evt::AtmosphereParameters & GetAtmosphereParameters() const
Get the Atmosphere profile used to simulate the shower.
double FLogP0(double logz)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
void InitSlantProfileModel(const utl::Point &core, const utl::Vector &dir, const double deltaX) const
Detector description interface for Station-related data.
utl::Histogram< double > & GetMPDHistogram()
Interface class to access to the SD Reconstruction of a Shower.
double DepthToZ(const double x, const vector< double > &hl, const vector< double > &al, const vector< double > &bl, const vector< double > &cl)
Interface class to access to the SD part of an event.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Class to hold collection (x,y) points and provide interpolation between them.
const std::vector< double > & GetA() const
sevt::StationRecData & GetRecData()
Get station level reconstructed data.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
const std::vector< double > & GetB() const
boost::filter_iterator< PMTFilter, InternalPMTIterator > PMTIterator
Iterator over station for read/write.
double pow(const double x, const unsigned int i)
utl::TabulatedFunctionErrors & GetMuonProductionDepth()
void Fill(const double x)
bool IsCandidate() const
Check if the station is a candidate.
A TimeStamp holds GPS second and nanosecond for some event.
utl::Point GetPosition() const
Tank position.
Interface class to access Shower Simulated parameters.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
class to hold data at Station level
Reference ellipsoids for UTM transformations.
class to hold reconstructed data at PMT level
utl::TimeStamp GetSignalStartTime() const
Start time of the signal.
double ZToDepth(const double h, const vector< double > &hl, const vector< double > &al, const vector< double > &bl, const vector< double > &cl)
double ZToSlantDepth(const double zcground, const double theta, const double z, const vector< double > &hl, const vector< double > &al, const vector< double > &bl, const vector< double > &cl, const bool curvature)
const utl::TimeStamp & GetCoreTime() const
time when shower front passes through the core point
double GetTotalSignal() const
Total integrated signal in VEM unit, averaged over pmts.
Top of the hierarchy of the detector description interface.
const sdet::SDetector & GetSDetector() const
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
unsigned int GetSignalStartSlot() const
Start time of the signal in time slots from beginning of trace.
double GetRadius() const
Radius of the tank (water only)
double GetHeight() const
Height of the tank (water only)
signal after subtracting direct light (includes all particle sources).
const utl::Vector & GetAxis() 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.
unsigned int GetSignalEndSlot() const
End time of the signal in time slots from beginning of trace.
double EpsilonRz(const double r, const double z)
double GetRho(const CoordinateSystemPtr &coordinateSystem) const
radius r in cylindrical coordinates (distance to z axis)
void MakeMuonProductionDepth()
bool IsLowGainSaturation() const
Check which gains are saturated.
constexpr double kSpeedOfLight
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
double GetFADCBinSize() const
void SetIsUsedInGlobalMPD(const bool is)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
StationIterator StationsBegin()
Beginning of all stations.
const std::vector< double > & GetLayerAltitudes() const
total (shower and background)
execption handling for calculation/access for inclined atmosphere model
Detector description interface for SDetector-related data.
const utl::Point & GetCorePosition() const
Main configuration utility.
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
const Station & GetStation(const int stationId) const
Get station by Station Id.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
const std::vector< double > & GetC() const
bool HasVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal) const
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
const atm::ProfileResult & EvaluateSlantDepthVsDistance() const
#define ERROR(message)
Macro for logging error messages.
bool HasMuonProductionDepth() const
const std::string & GetMessage() const
Retrieve the message from the exception.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Class to hold the standard parameters used to specify an atmospheric profile.