14 #include <fwk/CentralConfig.h>
15 #include <fwk/CoordinateSystemRegistry.h>
16 #include <fwk/LocalCoordinateSystem.h>
18 #include <utl/Reader.h>
19 #include <utl/ErrorLogger.h>
20 #include <utl/MathConstants.h>
21 #include <utl/PhysicalConstants.h>
22 #include <utl/Transformation.h>
23 #include <utl/TimeStamp.h>
24 #include <utl/TabulatedFunctionErrors.h>
25 #include <utl/Point.h>
26 #include <utl/UTMPoint.h>
27 #include <utl/ReferenceEllipsoid.h>
29 #include <evt/Event.h>
30 #include <evt/ShowerFRecData.h>
31 #include <evt/ShowerRecData.h>
32 #include <evt/ShowerSRecData.h>
36 #include <fevt/FEvent.h>
38 #include <fevt/Telescope.h>
39 #include <fevt/Pixel.h>
40 #include <fevt/PixelRecData.h>
41 #include <fevt/EyeRecData.h>
42 #include <fevt/TelescopeRecData.h>
43 #include <fevt/EyeHeader.h>
45 #include <det/Detector.h>
47 #include <fdet/FDetector.h>
49 #include <fdet/Telescope.h>
50 #include <fdet/Channel.h>
51 #include <fdet/Pixel.h>
54 #include <sevt/SEvent.h>
55 #include <sevt/Station.h>
56 #include <sevt/StationTriggerData.h>
57 #include <sevt/StationRecData.h>
58 #include <sevt/EventTrigger.h>
60 #include <sdet/SDetector.h>
61 #include <sdet/Station.h>
78 using namespace StereoGeometryFinderOG;
81 evt::Event* StereoGeometryFinder::fCurEvent = 0;
85 std::set<int> StereoGeometryFinder::fExcludeEye;
86 std::set<int> StereoGeometryFinder::fExcludeSDPEye;
88 int StereoGeometryFinder::fDebugging = 0;
90 double StereoGeometryFinder::fChi2SDP = 0;
91 int StereoGeometryFinder::fNDofSDP = 0;
93 double StereoGeometryFinder::fChi2TimeFit = 0;
94 int StereoGeometryFinder::fNDofTimeFit = 0;
96 int StereoGeometryFinder::fStereoHybrid = 0;
97 int StereoGeometryFinder::fHotStationId = 0;
98 double StereoGeometryFinder::fCelesteDelay = 0;
110 vector<int> exclEyes;
113 for (
unsigned int i = 0; i < exclEyes.size(); ++i)
114 fExcludeEye.insert(exclEyes[i]);
116 vector<int> exclSDPEyes;
118 fExcludeSDPEye.clear();
119 for (
unsigned int i = 0; i < exclSDPEyes.size(); ++i)
120 fExcludeSDPEye.insert(exclSDPEyes[i]);
134 return eContinueLoop;
142 unsigned int numEyes = 0;
144 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
145 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
156 if (fStereoHybrid == 1) {
158 fHotStationId = SdList[0];
167 INFO(
"It is not a stereo event. The stereo reconstruction will not do anything");
177 cout<<
"Calling FindAxisStereo"<<
"\n";
178 FindAxisStereo(event);
180 if ( fStereoHybrid == 1 ) {
184 cout<<
"Trying to include the Hybrid Fit in the stereo reconstruction \n";
185 FindAxisStereoHybrid(event);
188 cout<<
"There isn't any station involved with this event \n";
189 cout<<
"the reconstruction is purely stereo \n";
195 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
196 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
207 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
215 Vector EyeVertical(0,0,1,eyeCS);
221 Vector axis(rot * horizontalInSDP);
224 Vector coreEyeVec =
fRp / sin(
kPi - fChi0) * horizontalInSDP;
226 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
227 Point core = eyePosition + coreEyeVec;
247 telIt != eye.
TelescopesEnd(ComponentSelector::eHasData); ++telIt)
249 if (!telIt->HasRecData())
250 telIt->MakeRecData();
280 const fdet::FDetector& fdetector = det::Detector::GetInstance().GetFDetector();
284 det::Detector::GetInstance().GetSiteCoordinateSystem();
288 vector<Vector> sdp(nEyes);
289 vector<Vector> horizontal(nEyes);
290 vector<Vector> EyeToCore(nEyes);
291 vector<Point> eyePosition(nEyes);
292 vector<double> coreDistance(nEyes);
293 vector<double> EndFADCTrace(nEyes);
294 vector<Point> core(nEyes);
299 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
310 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
316 Vector EyeVertical(0,0,1,eyeCS);
320 Vector axis(rot * horizontalInSDP);
322 Vector coreEyeVec =
fRp / sin(
kPi - fChi0) * horizontalInSDP;
324 if (coreEyeVec.
GetMag() > 100000 )
325 coreEyeVec = 5000 * horizontalInSDP;
328 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
329 Point core = eyePosition + coreEyeVec;
331 det::Detector::GetInstance().GetSiteCoordinateSystem();
335 double deltaH = UTMCore.
GetHeight() - 1400;
336 Vector AxisPointingUp = axis;
337 if ( cos( axis.
GetTheta(eyeCS) ) < 0 )
338 AxisPointingUp *= -1;
340 double deltaLength = deltaH /cos(AxisPointingUp.
GetTheta(eyeCS));
342 Point PointCore1400 = core - deltaLength * AxisPointingUp;
343 UTMPoint UTMCore1400(PointCore1400,e);
349 fAxisTheta = axis.
GetTheta(core1CS);
350 fAxisPhi = axis.
GetPhi(core1CS);
359 TMinuit theMinuit(npar);
361 theMinuit.SetPrintLevel(-1);
363 theMinuit.SetFCN(StereoGeometryFinder::MinuitFitFuncStereo);
365 double arglist[
npar];
370 theMinuit.mnexcm(
"SET ERR", arglist,1,ierflag);
373 ERROR(
"Minuit SET ERR failed");
375 static double vstart[
npar];
376 static double step[
npar];
381 vstart[0] = fNorthing;
382 vstart[1] = fEasting;
383 vstart[2] = fAxisTheta;
384 vstart[3] = fAxisPhi;
393 theMinuit.mnparm(0,
"Northing ",vstart[0], step[0],0,0,ierflag);
394 theMinuit.mnparm(1,
"Easting ", vstart[1], step[1],0,0,ierflag);
395 theMinuit.mnparm(2,
"Theta ", vstart[2], step[2],0,0,ierflag);
396 theMinuit.mnparm(3,
"Phi ", vstart[3], step[3],0,0,ierflag);
397 theMinuit.mnparm(4,
"T01 ", vstart[4], step[4],0,0,ierflag);
401 theMinuit.mnexcm(
"MIGRAD", arglist ,2,ierflag);
417 ERROR(
"Minuit MIGRAD failed");
420 double Theta_err = 0;
424 double northing_err = 0;
426 double easting_err = 0;
431 theMinuit.GetParameter(0,northing,northing_err);
432 theMinuit.GetParameter(1,easting,easting_err);
433 theMinuit.GetParameter(2,Theta,Theta_err);
434 theMinuit.GetParameter(3,Phi,Phi_err);
435 theMinuit.GetParameter(4,To,To_err);
438 if (northing != northing) {
445 cout<<
"======= FAILED STEREO RECONSTRUCTION =====\n";
450 cout<<
"After Pure Stereo: \n";
451 printf(
"core UTM(E,N,H) : %9.1f , %10.1f , 1400 [m] \n",northing,easting);
452 printf(
"Axis(Theta,Phi)(coreCS) : %5.2f , %6.2f [deg] \n",Theta /
degree, Phi /
degree);
455 fNorthing = northing;
463 UTMPoint UTMcore(northing,easting,1400,19,
'H',e);
467 Vector stereoAxis(1,Theta,Phi,coreCS, Vector::kSpherical);
469 bool IsUpGoing =
false;
470 if ( cos( stereoAxis.
GetTheta(CS) ) < 0 )
478 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
479 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
490 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
493 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
496 double deltaH = core_1400.
GetZ(eyeCS);
497 Vector AxisPointingUp = stereoAxis;
499 AxisPointingUp *= -1;
501 double deltaLength = deltaH /cos(AxisPointingUp.
GetTheta(eyeCS));
503 core[count] = core_1400 - deltaLength * AxisPointingUp ;
504 EyeToCore[count] = core[count] - eyePosition[count];
505 coreDistance[count] = EyeToCore[count].
GetR(eyeCS);
506 EyeToCore[count] /= EyeToCore[count].GetR(eyeCS);
507 sdp[count] =
cross(stereoAxis,EyeToCore[count]);
508 sdp[count] /= sdp[count].GetR(eyeCS);
509 Vector EyeVertical(0,0,1,eyeCS);
510 horizontal[count] =
cross(sdp[count],EyeVertical);
511 horizontal[count] /= horizontal[count].GetR(eyeCS);
525 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
540 cout <<
"Eye: " << eye.
GetId()
541 <<
" core (x,y,z): (" << core[count].GetX(eye2CS)
542 <<
"," << core[count].GetY(eye2CS)
543 <<
"," << core[count].GetZ(eye2CS) <<
")\n";
545 double chi_0 =
Angle(horizontal[count],stereoAxis);
548 double r_p = coreDistance[count] * sin(
kPi - chi_0);
560 double chi_eye0 =
Angle(horizontal[0],stereoAxis);
563 double Rp_magnitude_eye0 = coreDistance[0] * sin(chi_eye0);
567 Rp_unit_eye0 /= Rp_unit_eye0.
GetR(CS);
568 PointRp_eye0 = eyePosition[0] + Rp_magnitude_eye0*Rp_unit_eye0;
569 double chi_00 =
Angle(horizontal[count],stereoAxis);
572 double Rp_magnitude = coreDistance[count] * sin(chi_00);
576 Rp_unit /= Rp_unit.
GetR(CS);
577 PointRp = eyePosition[count] + Rp_magnitude*Rp_unit;
578 Vector delta_distance = PointRp - PointRp_eye0;
581 if (PointRp.
GetZ(CS) > PointRp_eye0.GetZ(CS))
586 double T_zero = To + deltaT;
587 T_zero += (EndFADCTrace[0] - EndFADCTrace[count]);
590 eyerec.
SetSDP(sdp[count]);
611 Vector chi_i_vector = pixeldir - (sdp[count] * pixeldir) * sdp[count];
612 chi_i_vector /= chi_i_vector.
GetR(eyeCS);
614 double chi_i =
Angle(chi_i_vector,horizontal[count]);
627 StereoGeometryFinder::FindAxisStereoHybrid(
evt::Event& event)
632 const fdet::FDetector& fdetector = det::Detector::GetInstance().GetFDetector();
636 det::Detector::GetInstance().GetSiteCoordinateSystem();
640 vector<Vector> sdp(nEyes);
641 vector<Vector> horizontal(nEyes);
642 vector<Vector> EyeToCore(nEyes);
643 vector<Point> eyePosition(nEyes);
645 vector<double> coreDistance(nEyes);
646 vector<double> EndFADCTrace(nEyes);
647 vector<Point> core(nEyes);
654 TMinuit theMinuit(npar);
656 theMinuit.SetPrintLevel(-1);
658 theMinuit.SetFCN(StereoGeometryFinder::MinuitFitFuncStereoHybrid);
660 double arglist[
npar];
665 theMinuit.mnexcm(
"SET ERR", arglist,1,ierflag);
668 ERROR(
"Minuit SET ERR failed");
670 static double vstart[
npar];
671 static double step[
npar];
677 vstart[0] = fNorthing;
678 vstart[1] = fEasting;
679 vstart[2] = fAxisTheta;
680 vstart[3] = fAxisPhi;
690 theMinuit.mnparm(0,
"Northing ",vstart[0], step[0],0,0,ierflag);
691 theMinuit.mnparm(1,
"Easting ", vstart[1], step[1],0,0,ierflag);
692 theMinuit.mnparm(2,
"Theta ", vstart[2], step[2],0,0,ierflag);
693 theMinuit.mnparm(3,
"Phi ", vstart[3], step[3],0,0,ierflag);
694 theMinuit.mnparm(4,
"T01 ", vstart[4], step[4],0,0,ierflag);
698 theMinuit.mnexcm(
"MIGRAD", arglist ,2,ierflag);
714 ERROR(
"Minuit MIGRAD failed");
717 double Theta_err = 0;
721 double northing_err = 0;
723 double easting_err = 0;
728 theMinuit.GetParameter(0,northing,northing_err);
729 theMinuit.GetParameter(1,easting,easting_err);
730 theMinuit.GetParameter(2,Theta,Theta_err);
731 theMinuit.GetParameter(3,Phi,Phi_err);
732 theMinuit.GetParameter(4,To,To_err);
735 cout<<
"After Stereo-hybrid: \n";
736 printf(
"core UTM(E,N,H) : %9.1f , %10.1f , 1400 [m] \n",northing,easting);
737 printf(
"Axis(Theta,Phi)(coreCS) : %5.2f , %6.2f [deg] \n",Theta /
degree, Phi /
degree);
741 if (northing != northing) {
748 cout<<
"======= FAILED STEREO RECONSTRUCTION =====\n";
754 UTMPoint UTMcore(northing,easting,1400,19,
'H',e);
758 Vector stereoAxis(1,Theta,Phi,coreCS, Vector::kSpherical);
760 bool IsUpGoing =
false;
761 if ( cos( stereoAxis.
GetTheta(CS) ) < 0 )
769 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
770 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
781 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
784 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
787 double deltaH = core_1400.
GetZ(eyeCS);
788 Vector AxisPointingUp = stereoAxis;
790 AxisPointingUp *= -1;
792 double deltaLength = deltaH /cos( AxisPointingUp.
GetTheta(eyeCS));
794 core[count] = core_1400 - deltaLength * AxisPointingUp ;
795 EyeToCore[count] = core[count] - eyePosition[count];
796 coreDistance[count] = EyeToCore[count].
GetR(eyeCS);
797 EyeToCore[count] /= EyeToCore[count].GetR(eyeCS);
798 sdp[count] =
cross(stereoAxis,EyeToCore[count]);
799 sdp[count] /= sdp[count].GetR(eyeCS);
800 Vector EyeVertical(0,0,1,eyeCS);
801 horizontal[count] =
cross(sdp[count],EyeVertical);
802 horizontal[count] /= horizontal[count].GetR(eyeCS);
817 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
832 cout <<
"Eye: " << eye.
GetId()
833 <<
" core (x,y,z): (" << core[count].GetX(eye2CS)
834 <<
"," << core[count].GetY(eye2CS)
835 <<
"," << core[count].GetZ(eye2CS) <<
")\n";
837 double chi_0 =
Angle(horizontal[count],stereoAxis);
840 double r_p = coreDistance[count] * sin(
kPi - chi_0);
852 double chi_eye0 =
Angle(horizontal[0],stereoAxis);
855 double Rp_magnitude_eye0 = coreDistance[0] * sin(chi_eye0);
859 Rp_unit_eye0 /= Rp_unit_eye0.
GetR(CS);
860 PointRp_eye0 = eyePosition[0] + Rp_magnitude_eye0*Rp_unit_eye0;
861 double chi_00 =
Angle(horizontal[count],stereoAxis);
864 double Rp_magnitude = coreDistance[count] * sin(chi_00);
868 Rp_unit /= Rp_unit.
GetR(CS);
869 PointRp = eyePosition[count] + Rp_magnitude*Rp_unit;
870 Vector delta_distance = PointRp - PointRp_eye0;
873 if (PointRp.
GetZ(CS) > PointRp_eye0.GetZ(CS))
878 double T_zero = To + deltaT;
879 T_zero += (EndFADCTrace[0] - EndFADCTrace[count]);
883 eyerec.
SetSDP(sdp[count]);
904 Vector chi_i_vector = pixeldir - (sdp[count] * pixeldir) * sdp[count];
905 chi_i_vector /= chi_i_vector.
GetR(eyeCS);
907 double chi_i =
Angle(chi_i_vector,horizontal[count]);
918 StereoGeometryFinder::MinuitFitFuncStereoHybrid(
919 int& ,
double* ,
double& f,
double* par,
int )
924 const fdet::FDetector& fdetector = det::Detector::GetInstance().GetFDetector();
928 det::Detector::GetInstance().GetSiteCoordinateSystem();
934 double R =
sqrt((par[0]-6095767)*(par[0]-6095767) + (par[1]-469363)*(par[1]-469363));
940 UTMPoint UTMcore(par[0],par[1],1400,19,
'H',e);
943 Vector stereoAxis(1,par[2],par[3],coreCS, Vector::kSpherical);
945 bool IsUpGoing =
false;
946 if ( cos( stereoAxis.
GetTheta(CS) ) < 0 )
950 vector<Vector> sdp(nEyes);
951 vector<Vector> horizontal(nEyes);
952 vector<Point> eyePosition(nEyes);
953 vector<int> eyeId(nEyes);
954 vector<double> coreDistance(nEyes);
955 vector<double> EndFADCTrace(nEyes);
956 vector<Point> core(nEyes);
964 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
965 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
971 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
974 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
977 double deltaH = core_1400.
GetZ(eyeCS);
978 Vector AxisPointingUp = stereoAxis;
980 AxisPointingUp *= -1;
982 double deltaLength = deltaH / cos(AxisPointingUp.
GetTheta(eyeCS)) ;
984 core[count] = core_1400 - deltaLength * AxisPointingUp ;
985 horizontal[count] = core[count] - eyePosition[count];
987 coreDistance[count] = horizontal[count].
GetR(eyeCS);
988 horizontal[count] /= horizontal[count].GetR(eyeCS);
990 sdp[count] =
cross(stereoAxis,horizontal[count]);
991 sdp[count] /= sdp[count].GetR(eyeCS);
993 eyeId[count] = eye.
GetId();
1012 double chi_eye0 =
Angle(horizontal[0],stereoAxis);
1015 double Rp_magnitude_eye0 = coreDistance[0] * sin(chi_eye0);
1019 Rp_unit_eye0 /= Rp_unit_eye0.
GetR(CS);
1021 PointRp_eye0 = eyePosition[0] + Rp_magnitude_eye0*Rp_unit_eye0;
1023 UTMPoint UTM_Rp_Eye0(PointRp_eye0,e);
1024 double Rp0_height = UTM_Rp_Eye0.
GetHeight();
1025 double DeltaHeight = Rp0_height - 1400;
1026 double Delta_L = DeltaHeight / cos(stereoAxis.
GetTheta(coreCS));
1030 vector<double> chisq_time(nEyes, 0);
1031 vector<int> dof(nEyes, 0);
1032 double sum_charge = 0;
1036 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1037 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1052 double chi_0 =
Angle(horizontal[count],stereoAxis);
1055 double r_p = coreDistance[count] * sin(
kPi - chi_0);
1063 double Rp_magnitude = coreDistance[count] * sin(chi_0);
1067 Rp_unit /= Rp_unit.
GetR(CS);
1068 PointRp = eyePosition[count] + Rp_magnitude*Rp_unit;
1069 Vector delta_distance = PointRp - PointRp_eye0;
1073 if (PointRp.
GetZ(CS) > PointRp_eye0.GetZ(CS))
1078 double t_0 = par[4] + deltaT ;
1079 t_0 += (EndFADCTrace[0] - EndFADCTrace[count]);
1085 const Pixel& pixel = *iter;
1097 pixeldir.TransformTo(eyeCS);
1098 sdp[count].TransformTo(eyeCS);
1100 Vector chi_i_vector = pixeldir - (sdp[count] * pixeldir) * sdp[count];
1101 chi_i_vector.TransformTo(eyeCS);
1102 chi_i_vector /= chi_i_vector.
GetR(eyeCS);
1103 horizontal[count].TransformTo(eyeCS);
1104 chi_i =
Angle(chi_i_vector,horizontal[count]);
1110 double tmp = t_i - t_expected ;
1117 chisq_time[count] += tmp*tmp*charge/ (t_i_Err * t_i_Err) ;
1118 sum_charge += charge;
1120 if (fDebugging == 1)
1121 cout <<
"delta t: " << tmp
1122 <<
" chisq " << tmp*tmp / (t_i_Err * t_i_Err)
1123 <<
" Eye: " << eye.
GetId()
1124 <<
" Chi0 : " << chi_0/
degree
1127 <<
"chisq_time: " << chisq_time[count]
1133 chisq_time[count] /= sum_charge;
1140 vector<double> chisq_sdp(nEyes, 0);
1145 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1146 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1164 sdp[count].TransformTo(eyeCS);
1166 double sdpTheta = sdp[count].GetTheta(eyeCS);
1167 double sdpPhi = sdp[count].GetPhi(eyeCS);
1169 Vector sdp2 (1,sdpTheta ,sdpPhi ,eyeCS, Vector::kSpherical);
1180 dir.TransformTo(eyeCS);
1185 if (fDebugging == 1)
1186 cout <<
"deviation from SDP " << tmp /
degree
1187 <<
" [deg] , Eye: " << eye.
GetId()
1188 <<
" Pixel Id : " << detPixel.
GetId()
1194 chisq_sdp[count] += tmp*tmp * charge / ((0.35 *
degree * 0.35 *
degree));
1195 sum_charge += charge;
1198 chisq_sdp[count] /= sum_charge;
1199 chisq_sdp[count] *= dof[count];
1206 double chisq_hybrid = 0;
1213 if (!sditer->HasRecData()) {
1218 if (station.
GetId() != fHotStationId )
1227 det::Detector::GetInstance().GetSDetector().GetStation(station);
1231 const Vector VCoreToStation = pos - core_1400;
1233 const double Axis_VS_CoreToStation_angle =
Angle(VCoreToStation,stereoAxis);
1235 const double station_to_axis = VCoreToStation.
GetMag() * sin(Axis_VS_CoreToStation_angle);
1240 const double delta_d = VCoreToStation.
GetMag() * cos(Axis_VS_CoreToStation_angle);
1246 const double VerticalCurvature = 1 / 9000.;
1247 const double d2 = station_to_axis * station_to_axis;
1248 const double curvature = VerticalCurvature*stereoAxis.
GetCosTheta(coreCS);
1249 const double timeDelay = curvature * d2 / (2*
kSpeedOfLight);
1250 exp_t_st += timeDelay;
1256 if (IsUpGoing && station.
GetId() == 203) exp_t_st += fCelesteDelay;
1263 eye_trigger_time -= 1000 *100;
1265 exp_t_st += eye_trigger_time;
1267 double chi_hybrid = nanosecond - exp_t_st;
1268 double hybrid_error = 100;
1270 chisq_hybrid += chi_hybrid * chi_hybrid / (hybrid_error * hybrid_error);
1282 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1283 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1300 if (fDebugging == 1)
1301 cout <<
"chisq time: " << chisq_time[count]/dof[count]
1302 <<
" chisq SDP: " << chisq_sdp[count]/dof[count]
1303 <<
" dof " << dof[count]
1313 if (eyeId[count] < 6 ) {
1314 if (fExcludeEye.count(eyeId[count]) == 0)
1315 chisq += chisq_time[count];
1316 if (fExcludeSDPEye.count(eyeId[count]) == 0)
1317 chisq += chisq_sdp[count]*5;
1321 chisq += chisq_hybrid;
1326 StereoGeometryFinder::MinuitFitFuncStereo(
1327 int& ,
double* ,
double& f,
double* par,
int )
1332 const fdet::FDetector& fdetector = det::Detector::GetInstance().GetFDetector();
1336 det::Detector::GetInstance().GetSiteCoordinateSystem();
1341 UTMPoint UTMcore(par[0],par[1],1400,19,
'H',e);
1344 Vector stereoAxis(1,par[2],par[3],coreCS, Vector::kSpherical);
1346 bool IsUpGoing =
false;
1347 if ( cos( stereoAxis.
GetTheta(CS) ) < 0 )
1350 vector<Vector> sdp(nEyes);
1351 vector<Vector> horizontal(nEyes);
1352 vector<Point> eyePosition(nEyes);
1353 vector<int> eyeId(nEyes);
1354 vector<double> coreDistance(nEyes);
1355 vector<double> EndFADCTrace(nEyes);
1356 vector<Point> core(nEyes);
1364 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1365 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1371 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetEyeCoordinateSystem();
1373 eyePosition[count] =
1374 det::Detector::GetInstance().GetFDetector().GetEye(eye).GetPosition();
1377 double deltaH = core_1400.
GetZ(eyeCS);
1378 Vector AxisPointingUp = stereoAxis;
1380 AxisPointingUp *= -1;
1382 double deltaLength = deltaH / cos( AxisPointingUp.
GetTheta(eyeCS)) ;
1384 core[count] = core_1400 - deltaLength * AxisPointingUp ;
1385 horizontal[count] = core[count] - eyePosition[count];
1387 coreDistance[count] = horizontal[count].
GetR(eyeCS);
1388 horizontal[count] /= horizontal[count].GetR(eyeCS);
1390 sdp[count] =
cross(stereoAxis,horizontal[count]);
1391 sdp[count] /= sdp[count].GetR(eyeCS);
1393 eyeId[count] = eye.
GetId();
1410 double chi_eye0 =
Angle(horizontal[0],stereoAxis);
1413 double Rp_magnitude_eye0 = coreDistance[0] * sin(chi_eye0);
1417 Rp_unit_eye0 /= Rp_unit_eye0.
GetR(CS);
1419 PointRp_eye0 = eyePosition[0] + Rp_magnitude_eye0*Rp_unit_eye0;
1423 double chisq_time[nEyes];
1425 for (
unsigned int i = 0; i < nEyes; i++) {
1429 double sum_charge = 0;
1433 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1434 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1449 double chi_0 =
Angle(horizontal[count],stereoAxis);
1452 double r_p = coreDistance[count] * sin(
kPi - chi_0);
1460 double Rp_magnitude = coreDistance[count] * sin(chi_0);
1464 Rp_unit /= Rp_unit.
GetR(CS);
1465 PointRp = eyePosition[count] + Rp_magnitude*Rp_unit;
1466 Vector delta_distance = PointRp - PointRp_eye0;
1470 if (PointRp.
GetZ(CS) > PointRp_eye0.GetZ(CS))
1475 double t_0 = par[4] + deltaT ;
1476 t_0 += (EndFADCTrace[0] - EndFADCTrace[count]);
1482 const Pixel& pixel = *iter;
1494 pixeldir.TransformTo(eyeCS);
1495 sdp[count].TransformTo(eyeCS);
1497 Vector chi_i_vector = pixeldir - (sdp[count] * pixeldir) * sdp[count];
1498 chi_i_vector.TransformTo(eyeCS);
1499 chi_i_vector /= chi_i_vector.
GetR(eyeCS);
1500 horizontal[count].TransformTo(eyeCS);
1501 chi_i =
Angle(chi_i_vector,horizontal[count]);
1507 double tmp = t_i - t_expected ;
1514 chisq_time[count] += tmp*tmp*charge/ (t_i_Err * t_i_Err) ;
1515 sum_charge += charge;
1517 if (fDebugging == 1)
1518 cout <<
"delta t: " << tmp
1519 <<
" chisq " << tmp*tmp / (t_i_Err * t_i_Err)
1520 <<
" Eye: " << eye.
GetId()
1521 <<
" Chi0 : " << chi_0/
degree
1524 <<
"chisq_time: " << chisq_time[count]
1530 chisq_time[count] /= sum_charge;
1537 double chisq_sdp[nEyes];
1538 for (
unsigned int i = 0; i < nEyes; i++)
1544 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1545 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1563 sdp[count].TransformTo(CS);
1565 double sdpTheta = sdp[count].GetTheta(CS);
1566 double sdpPhi = sdp[count].GetPhi(CS);
1568 Vector sdp2 (1,sdpTheta ,sdpPhi ,CS, Vector::kSpherical);
1579 dir.TransformTo(CS);
1584 if (fDebugging == 1)
1585 cout <<
"deviation from SDP " << tmp /
degree
1586 <<
" [deg] , Eye: " << eye.
GetId()
1587 <<
" Pixel Id : " << detPixel.
GetId()
1593 chisq_sdp[count] += tmp*tmp * charge / ((0.35 *
degree * 0.35 *
degree));
1594 sum_charge += charge;
1597 chisq_sdp[count] /= sum_charge;
1598 chisq_sdp[count] *= dof[count];
1607 for (eyeIter = fevent.
EyesBegin(ComponentSelector::eHasData);
1608 eyeIter != fevent.
EyesEnd(ComponentSelector::eHasData);
1625 if (fDebugging == 1)
1626 cout <<
"chisq time: " << chisq_time[count]/dof[count]
1627 <<
" chisq SDP: " << chisq_sdp[count]/dof[count]
1628 <<
" dof " << dof[count]
1638 if (eyeId[count] < 6 ) {
1639 if (fExcludeEye.count(eyeId[count]) == 0)
1640 chisq += chisq_time[count];
1641 if (fExcludeSDPEye.count(eyeId[count]) == 0)
1642 chisq += chisq_sdp[count]*5;
1651 StereoGeometryFinder::Finish()
AxialVector cross(const Vector &l, const Vector &r)
vector cross product
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
The Auger coordinate system (x to east, z local verical) for this eye.
unsigned int GetId() const
unsigned int GetId() const
By default from 1..440.
const utl::Vector & GetDirection() const
pointing direction of this pixel
void SetChiZero(const double chiZero, const double error)
double GetChi0TZeroCorrelation() const
StationIterator StationsEnd()
End of all stations.
void SetSDPFitChiSquare(const double sdpChi2, const unsigned int ndof)
int GetId() const
Get the station Id.
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
double GetRpError() const
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Detector description interface for Station-related data.
void SetSDPFitChiSquare(const double sdpChi2, const unsigned int ndof)
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Fluorescence Detector Eye Event.
PixelIterator PulsedPixelsEnd()
Interface class to access Shower Reconstructed parameters.
bool HasRecShower() const
double GetR(const CoordinateSystemPtr &coordinateSystem) const
radius r in spherical coordinates coordinates (distance to origin)
const Pixel & GetPixel(const fevt::Pixel &eventPixel) const
Get fdet::Pixel from fevt::Channel.
Interface class to access to the SD part of an event.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
double GetChiZero() const
Class to hold and convert a point in geodetic coordinates.
double GetSDPFitChiSquare() const
void SetAxis(const utl::Vector &axis)
double GetCosTheta(const CoordinateSystemPtr &coordinateSystem) const
cos of zenith (theta) angle
std::vector< unsigned short int > & GetStationIds()
retrieve vector of station IDs used in hybrid fit
unsigned int GetSDPFitNDof() const
void SetCorePosition(const utl::Point &core)
EyeIterator EyesEnd(const ComponentSelector::Status status)
unsigned int GetTimeFitNDof() const
double GetRpTZeroCorrelation() const
sevt::StationRecData & GetRecData()
Get station level reconstructed data.
void SetTimeFitCorrelations(double rRpT0, double rRpChi0, double rChi0T0)
#define INFO(message)
Macro for logging informational messages.
unsigned int GetLastEyeId() const
Get Id of last eye.
void SetRp(const double rp, const double error)
void Init()
Initialise the registry.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Detector description interface for Eye-related data.
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
PixelIterator PulsedPixelsBegin()
double GetNorthing() const
Get the northing.
double GetSDPPhiError() const
double GetTZeroError() const
Detector description interface for FDetector-related data.
double GetChiZeroError() const
A TimeStamp holds GPS second and nanosecond for some event.
boost::indirect_iterator< ConstInternalPixelIterator, const Pixel & > ConstPixelIterator
Const iterator over pixels used in reconstruction.
utl::Point GetPosition() const
Tank position.
V To(const G4ThreeVector &v, const utl::CoordinateSystemPtr &cs, const double unitConversion)
void SetSDP(const utl::AxialVector &vec)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
class to hold data at Station level
void MakeFRecShower()
Allocate reconstructed shower info.
Reference ellipsoids for UTM transformations.
utl::TimeStamp GetSignalStartTime() const
Start time of the signal.
double GetHeight() const
Get the height.
Fluorescence Detector Pixel event.
void SetCoreTime(const utl::TimeStamp &coreTime, const utl::TimeInterval &coreTimeErr)
utl::CoordinateSystemPtr GetEyeCoordinateSystem() const
Returns the Eye Coordinate system.
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
utl::TimeInterval GetT_i() const
constexpr double nanosecond
void SetAxis(const utl::Vector &axis)
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)
void SetSDPPhiError(const double sdpPhiError)
void SetChiZero(const double chiZero, const double error)
void SetTimeFitChiSquare(const double tfitChi2, const unsigned int ndof)
double GetEasting() const
Get the easting.
constexpr double kPiOnTwo
double GetSDPCorrThetaPhi() const
Telescope-specific shower reconstruction data.
void SetSDPThetaError(const double sdpThetaError)
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
void GetData(bool &b) const
Overloads of the GetData member template function.
Top of Fluorescence Detector event hierarchy.
Eye-specific shower reconstruction data.
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
double GetInterval() const
Get the time interval as a double (in Auger base units)
const utl::AxialVector & GetSDP() const
double GetTimeFitChiSquare() const
unsigned int GetNTimeFitPixels() const
Get number of Time Fit pixels.
double GetRpChi0Correlation() const
boost::indirect_iterator< InternalPixelIterator, fevt::Pixel & > PixelIterator
Iterator over pixels used in reconstruction.
constexpr double kSpeedOfLight
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
double GetGPSNanoSecond() const
GPS nanosecond.
void SetTZero(const double tzero, const double error)
StationIterator StationsBegin()
Beginning of all stations.
double GetTotalCharge() const
integrated pulse charge
void SetTimeFitChiSquare(const double tfitChi2, const unsigned int ndof)
PixelIterator TimeFitPixelsEnd()
void SetRp(const double rp, const double error)
utl::TimeInterval GetT_iError() const
Main configuration utility.
void SetCorePosition(const utl::Point &core)
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
void SetSDP(const utl::AxialVector &vec)
void SetTZero(const double tzero, const double error)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
double GetNanoSecond() const
Get integer number of nanoseconds past seconds boundary.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
unsigned int GetNSDPPixels() const
Get number of SDP pixels.
PixelIterator TimeFitPixelsBegin()
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
#define ERROR(message)
Macro for logging error messages.
Fluorescence Detector Pixel Reconstructed Data.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
void SetChi_i(const double chi_i)
PixelRecData & GetRecData()
void SetSDPCorrThetaPhi(double sdpCorrThetaPhi)
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
double GetSDPThetaError() const