11 #include <evt/Event.h>
12 #include <evt/ShowerFRecData.h>
14 #include <fdet/FDetector.h>
16 #include <fevt/FEvent.h>
18 #include <fevt/EyeHeader.h>
19 #include <fevt/EyeRecData.h>
21 #include <utl/ErrorLogger.h>
22 #include <utl/PhysicalConstants.h>
23 #include <utl/TimeStamp.h>
24 #include <utl/Transformation.h>
25 #include <utl/GeometryUtilities.h>
26 #include <utl/FileName.h>
28 #include <fwk/LocalCoordinateSystem.h>
29 #include <fwk/CoordinateSystemRegistry.h>
31 #include <sdet/SDetector.h>
32 #include <sdet/Station.h>
33 #include <sevt/SEvent.h>
34 #include <sevt/Station.h>
54 auto& sEvent =
event.GetSEvent();
56 bool isCeleste =
false;
57 bool isRamiro =
false;
59 for (
const auto& station : sEvent.StationsRange()) {
60 if (!station.HasRecData() || !station.IsCandidate())
62 if (station.GetId() == 203)
64 else if (station.GetId() == 805)
69 INFO(
"This is a CLF event.");
71 INFO(
"This is an XLF event.");
72 if (isCeleste && isRamiro) {
73 INFO(
"Cannot have both Celeste and Ramiro; skipping.");
76 if (!isCeleste && !isRamiro) {
77 INFO(
"No Celeste or Ramiro found: NOT a hybrid laser event; skipping.");
88 FindTimeOffset::ExamineFEvent(
const evt::Event& event,
const bool isCeleste)
90 const auto& sEvent =
event.GetSEvent();
91 const auto& fEvent =
event.GetFEvent();
102 std::ostringstream os;
104 << v.GetX(cs)/unit <<
", "
105 << v.GetY(cs)/unit <<
", "
106 << v.GetZ(cs)/unit <<
')';
113 const bool isCeleste)
120 const auto& det = det::Detector::GetInstance();
121 const auto& dEye = det.GetFDetector().GetEye(eye);
122 const auto& eyePos = dEye.GetPosition();
123 const auto& eyeCs = dEye.GetLocalCoordinateSystem();
125 const auto eye2Laser = laserPos - eyePos;
130 const double rp = eyeRec.GetRp();
131 const double t0 = eyeRec.GetTZero();
132 const auto& sdp = eyeRec.GetSDP();
139 const auto fdEyeTriggerTime = fdEventTime - fdTraceLength;
145 const auto laserPointing =
148 std::ostringstream info;
149 info <<
"GPS = " << fdEventTime.GetGPSSecond() <<
" s "
150 << int(fdEventTime.GetGPSNanoSecond()) <<
" ns, "
151 "eye = " << eye.
GetId() <<
", "
152 "chi0 = " << chi0/
utl::deg <<
" deg, "
154 "t0 = " << t0/
utl::ns <<
" ns";
158 info <<
"laser pointing (eye CS): "
159 "theta = " << laserPointing.GetTheta(eyeCs)/
utl::deg <<
" deg, "
160 "phi = " << laserPointing.GetPhi(eyeCs)/
utl::deg <<
" deg";
164 info <<
"laser pointing (laser CS): "
165 "theta = " << laserPointing.GetTheta(laserCs)/
utl::deg <<
", "
166 "phi = " << laserPointing.GetPhi(laserCs)/
utl::deg <<
" deg";
169 const double beta =
utl::Angle(-eye2Laser, laserPointing);
177 info <<
"beta = " << beta/
utl::deg <<
" deg, "
178 "dt = " << geometricDelay/
utl::ns <<
" ns";
181 const auto& shFRec = eyeRec.GetFRecShower();
182 const auto& fdCore = shFRec.GetCorePosition();
183 const auto& fdCoreTime = shFRec.GetCoreTime();
184 const auto& fdAxis = shFRec.GetAxis();
186 for (
const auto& station : sEvent.StationsRange()) {
188 if (!station.HasRecData() ||
189 !station.IsCandidate() ||
190 !(station.GetId() == 203 || station.GetId() == 805))
194 const auto& stationStart = station.GetRecData().GetSignalStartTime();
195 const auto laserStart = stationStart - fiberDelay;
197 const auto sdT0 = laserStart - geometricDelay;
200 info <<
"sdT0 = " << sdT0;
204 const auto fdT0 = fdEyeTriggerTime + t0;
207 info <<
"fdT0 = " << fdT0;
210 const auto offset = sdT0 - fdT0;
213 info <<
"SD/FD time offset = " << offset/
utl::ns <<
" ns";
220 const double coreLaserParallelDistance = fdAxis * (fdCore - laserPos);
222 const auto fdTimeAtLaser = fdCoreTime + coreLaserParallelDt;
224 const auto offset2 = laserStart - fdTimeAtLaser;
226 const auto& stationPos = det.GetSDetector().GetStation(station).GetPosition();
227 const auto projectedFdCore =
230 info <<
"(in CS of the laser)\n"
232 " fdCore_proj = " <<
ToString(projectedFdCore, laserCs,
utl::m) <<
" m\n"
233 " stationPos = " <<
ToString(stationPos, laserCs,
utl::m) <<
" m\n"
235 " distance(core, laser) = " << (fdCore - laserPos).GetMag()/
utl::meter <<
" m\n"
236 " distance(core, station) = " << (fdCore - stationPos).GetMag()/
utl::meter <<
" m\n"
237 " laserStart - fdCoreTime = " << (laserStart - fdCoreTime)/
utl::ns <<
" ns\n"
238 " projection delay = " << coreLaserParallelDt/
utl::ns <<
" ns";
242 info <<
"SD/FD time offset from core = " << offset2/
utl::ns <<
" ns";
245 const double laserPointingElevation =
utl::kHalfPi - laserPointing.GetTheta(laserCs);
247 const auto outputFile =
"offset.dat";
249 std::ofstream fout(outputFile);
250 fout <<
"# fd_id offset gps_sec gps_ns laser_elevation laser_azimuth signal celeste offset2 fd_core_x y z\n";
252 std::ofstream fout(outputFile, std::ios::app);
253 fout << eye.
GetId() <<
' '
255 << fdEventTime.GetGPSSecond() <<
' '
256 << int(fdEventTime.GetGPSNanoSecond()) <<
' '
257 << laserPointingElevation/
utl::deg <<
' '
258 << laserPointing.GetPhi(laserCs)/
utl::deg <<
' '
259 << station.GetRecData().GetTotalSignal() <<
' '
262 << projectedFdCore.GetX(laserCs)/
utl::m <<
' '
263 << projectedFdCore.GetY(laserCs)/
utl::m <<
' '
264 << projectedFdCore.GetZ(laserCs)/
utl::m
AxialVector Cross(const Vector &l, const Vector &r)
unsigned int GetId() const
Report success to RunController.
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Fluorescence Detector Eye Event.
bool Exists(const string &filename)
Interface class to access to the SD part of an event.
double GetChiZero() const
Skip remaining modules in the current loop and continue with next iteration of the loop...
std::string ToString(const V &v, const utl::CoordinateSystemPtr &cs, const double unit)
#define INFO(message)
Macro for logging informational messages.
Line Intersection(const Plane &p1, const Plane &p2)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class describing a Plane object.
AxialVector Normalized(const AxialVector &v)
constexpr double kSpeedOfLight
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
void ExamineFEvent(const evt::Event &event, const bool isCeleste)
double Angle(const Vector &left, const Vector &right)
void FindOffset(const sevt::SEvent &sEvent, const fevt::Eye &eye, const bool isCeleste)
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.