11 #include <boost/filesystem.hpp>
12 #include <boost/format.hpp>
14 #include <fwk/CentralConfig.h>
15 #include <fwk/RunController.h>
17 #include <evt/Event.h>
18 #include <evt/ShowerFRecData.h>
19 #include <evt/ShowerRecData.h>
20 #include <evt/ShowerSRecData.h>
21 #include <evt/ShowerSimData.h>
22 #include <evt/ShowerUnivRecData.h>
24 #include <fevt/EyeRecData.h>
25 #include <fevt/FEvent.h>
26 #include <sdet/SDetector.h>
27 #include <sdet/Station.h>
28 #include <sevt/SEvent.h>
30 #include <utl/AugerUnits.h>
31 #include <utl/PhysicalConstants.h>
32 #include <utl/PhysicalFunctions.h>
33 #include <utl/UTCDateTime.h>
57 det::Detector::GetInstance().GetReferenceCoordinateSystem();
58 const auto &sDet = det::Detector::GetInstance().GetSDetector();
71 INFO(boost::format(
"Fix Xmax to FD: %b") % (fixXmaxToFd));
72 INFO(boost::format(
"Fix energy to FD: %b") % (fixEnergyToFd));
80 ERROR(
"No RecShower found!");
120 const bool realEvent = !
event.HasSimShower();
121 const auto &recShower =
event.GetRecShower().GetSRecShower();
123 !realEvent ?
event.GetSimShower().GetEnergy() : recShower.GetEnergy();
124 double avgXmax =
avgXmax0(log10(recEnergy), realEvent) - 45.;
125 const Vector &recAxis = recShower.GetAxis();
126 const Point &recCore = recShower.GetCorePosition();
127 const double recTheta = recAxis.
GetTheta(augerCS);
128 const bool realAtmosphere = !
event.HasSimShower();
129 double realXmax =
event.HasSimShower()
130 ?
event.GetSimShower().GetGHParameters().GetXMax() / gcm
132 const unsigned int pId =
133 event.HasSimShower() ?
event.GetSimShower().GetPrimaryParticle() : 666;
136 const double recPhi = recAxis.
GetPhi(augerCS);
137 const double recAzimuth = (recPhi < 0) ? recPhi + 2 * M_PI : recPhi;
139 vector<vector<double>> FdXmax = {};
140 double FdMeanXmax = 0;
141 double FdMeanEnergy = 0;
142 double FdMeanLgEnergy = 0;
143 double wEnergySum = 0;
157 if (!eye->GetRecData().HasFRecShower())
160 const auto &eyeRec = eye->GetRecData();
161 if (!eyeRec.GetFRecShower().HasGHParameters())
164 double eyeEnergy = eyeRec.GetFRecShower().GetTotalEnergy();
165 const double eyeXmax = eyeRec.GetFRecShower().GetGHParameters().GetXMax();
166 const double eyeXmaxErr =
167 eyeRec.GetFRecShower().GetGHParameters().GetXMaxError();
168 const double eyeEnergyErr = eyeRec.GetFRecShower().GetTotalEnergyError();
171 const double energyRatioSdFd = recEnergy / eyeEnergy;
173 eyeEnergy = eyeEnergy * energyRatioSdFd/corrFactor;
174 INFO(boost::format(
"eye (%i) correction factor %.2f") % eye->GetId() % energyRatioSdFd);
177 FdXmax.push_back({eyeXmax / gcm, eyeXmaxErr / gcm});
179 FdMeanXmax += eyeXmax / gcm /
pow(eyeXmaxErr / gcm, 2);
180 FdMeanEnergy += eyeEnergy /
pow(eyeEnergyErr, 2);
181 wXmaxSum += 1 /
pow(eyeXmaxErr / gcm, 2);
182 wEnergySum += 1 /
pow(eyeEnergyErr, 2);
185 FdMeanXmax /= wXmaxSum;
186 FdMeanEnergy /= wEnergySum;
187 FdMeanLgEnergy = log10(FdMeanEnergy);
188 INFO(boost::format(
"FD mean Xmax %.2f g/cm^2") % FdMeanXmax);
189 INFO(boost::format(
"FD mean lgE/eV %.2f") % FdMeanLgEnergy);
192 if (fixXmaxToFd && FdMeanXmax > 0)
193 avgXmax = FdMeanXmax;
195 if (fixXmaxToFd && FdMeanXmax > 0 && realEvent)
196 realXmax = FdMeanXmax;
198 if (fixEnergyToFd && FdMeanEnergy > 0)
199 recEnergy = FdMeanEnergy;
201 INFO(boost::format(
"lg(E/eV) = %.2f θ = %.2f°") % (log10(recEnergy)) %
204 if (log10(recEnergy) < 18.5) {
205 WARNING(
"Energy too low for universality reconstruction!");
206 WARNING(
"Energy too low for universality reconstruction!");
207 WARNING(
"Energy too low for universality reconstruction!");
211 auto &univRecShower =
event.GetRecShower().GetUnivRecShower();
213 univRecShower.SetCorePosition(recCore);
214 univRecShower.SetAxis(recAxis);
216 const auto &sEvent =
event.GetSEvent();
231 double useCorrelationPenalty;
236 powerFit.AddMetaData(avgXmax, log10(recEnergy), recTheta,
239 useCorrelationPenalty);
240 LdfFit.AddMetaData(avgXmax, log10(recEnergy), recTheta, event.
HasSimShower(),
242 EnergyFit.AddMetaData(avgXmax, log10(recEnergy), recTheta,
245 RatioFit.AddMetaData(avgXmax, log10(recEnergy), recTheta,
248 unsigned short int numDet = 0;
249 unsigned short int numEnDet = 0;
250 unsigned short int numTimeDet = 0;
251 unsigned short int numDenseDet = 0;
252 unsigned short int numSatDet = 0;
253 const int numDenseDetTot =
254 sDet.GetDenseStationList().size() * 2;
256 const string basepath =
".";
257 const string dumpfileId =
258 event.GetHeader().GetId();
260 const string pythonDumpFilepath =
261 boost::str(boost::format(
"%s/event_dump_universalityv2_%s.txt") %
262 basepath % dumpfileId);
264 INFO(boost::format(
"Dumpfile will be at %s") % pythonDumpFilepath);
266 ofstream pythonDump(
"dumpfile.txt");
269 pythonDump << boost::format(
"\"ID\": \"%s\",\n") % (dumpfileId);
270 pythonDump << boost::format(
"\"GPSSecond\": %i,\n") %
271 event.GetHeader().GetTime().GetGPSSecond();
272 pythonDump << boost::format(
"\"reclgE\": %.5f,\n") % (log10(recEnergy));
273 pythonDump << boost::format(
"\"recTheta\": %.5f,\n") % recTheta;
274 pythonDump << boost::format(
"\"recPhi\": %.5f,\n") % recPhi;
275 pythonDump << boost::format(
"\"recAzimuth\": %.5f,\n") % recAzimuth;
276 pythonDump << boost::format(
"\"realXmax\": %.5f,\n") % realXmax;
277 pythonDump << boost::format(
"\"particleId\": %i,\n") % pId;
278 pythonDump << boost::format(
"\"detectors\":\n[\n");
280 vector<un2Detector> un2Detectors;
283 for (
const auto &station : boost::make_iterator_range(sEvent.StationsBegin(),
284 sEvent.StationsEnd())) {
287 if (!station.HasRecData())
290 const unsigned int stationId = station.GetId();
291 const bool isDense = sDet.GetStation(stationId).IsDense();
292 const auto &statRecData = station.GetRecData();
293 const double rsp = statRecData.GetSPDistance();
300 const double az = statRecData.GetAzimuthShowerPlane();
301 const double height =
302 sDet.GetStation(stationId).GetPosition().GetZ(augerCS) + 1400.;
304 const size_t sigStartSlot = statRecData.GetSignalStartSlot();
305 const size_t sigStopSlot = statRecData.GetSignalEndSlot();
307 const double coreTime = recShower.GetCoreTime().GetGPSNanoSecond();
308 const double stationTime =
309 statRecData.GetSignalStartTime().GetGPSNanoSecond();
310 const double stationPFTime =
311 coreTime - 1. / 0.2998 * (cos(az) * rsp * tan(recTheta));
315 const double planeFrontTimeResidual = stationPFTime - stationTime;
317 un2Detector un2WCD(station.GetId(), station,
"WCD", rsp, az, height,
318 planeFrontTimeResidual, isDense);
320 un2WCD.signalStopSlot = sigStopSlot;
321 un2WCD.referenceDt40 =
323 month, realAtmosphere)[0];
324 un2WCD.referenceDt0 =
325 GetTimeQuantile(recTheta, rsp, az, height, realXmax,
"WCD",
"t0", month,
328 un2Detectors.push_back(un2WCD);
331 if (station.HasScintillator() && station.GetScintillator().HasRecData()) {
332 un2Detector un2SSD(station.GetId(), station,
"SSD", rsp, az, height,
333 planeFrontTimeResidual, isDense);
335 un2SSD.signalStopSlot = sigStopSlot;
337 un2SSD.referenceDt40 =
339 month, realAtmosphere)[0];
340 un2SSD.referenceDt0 =
342 month, realAtmosphere)[0];
344 un2Detectors.push_back(un2SSD);
349 for (
auto &un2det : un2Detectors) {
351 INFO(boost::format(
"Detector %s %i") %un2det.type %un2det.Id);
354 if (0==un2det.signalUnit) {
355 WARNING(boost::format(
"Could not recover signal unit! Skipping Detector!"));
359 const auto &trace = un2det.GetTrace();
361 if (
"WCD" == un2det.type)
362 un2det.totalSignal = un2det.station.GetRecData().GetTotalSignal();
364 if (
"SSD" == un2det.type)
366 un2det.station.GetScintillator().GetRecData().GetTotalSignal();
368 un2det.stationNSTime =
369 un2det.station.GetRecData().GetSignalStartTime().GetGPSNanoSecond();
371 un2det.referenceSignal =
372 GetSignal(hadrIntModel, log10(recEnergy), recTheta, un2det.spRadius,
373 un2det.spAzimuth, un2det.heightAboveSL, realXmax, 1.,
374 un2det.type, month, realAtmosphere,
true)[0];
375 un2det.uncertaintySignal =
376 (
"WCD" == un2det.type)
386 if (
"SSD" == un2det.type && un2det.uncertaintySignal < 1)
387 un2det.uncertaintySignal = 1;
390 CalcDX(realAtmosphere,
false , un2det.spRadius,
391 un2det.spAzimuth, un2det.heightAboveSL, realXmax ,
392 recTheta, month,
false );
394 un2det.nsBin = trace.GetBinning();
396 if (un2det.isVirtual) {
398 un2det.mcSpRadius = sDet.GetStation(un2det.Id).GetPosition().GetRho(
401 const auto &muonTrace =
405 const double muonSignal =
406 accumulate(muonTrace.Begin(), muonTrace.End(), 0.);
410 const double muonPrediction =
413 un2det.mcSpRadius, un2det.spAzimuth,
414 un2det.heightAboveSL, realXmax, 1., un2det.type,
415 month, realAtmosphere,
true)[2]
417 un2det.mcSpRadius, un2det.spAzimuth,
418 un2det.heightAboveSL, realXmax, 1., un2det.type,
419 month, realAtmosphere,
true)[0];
421 const double stationRmu = muonSignal * un2det.signalUnit / muonPrediction;
423 RmuSum += stationRmu /
pow(un2det.uncertaintySignal, 2);
424 wRmuSum += 1 /
pow(un2det.uncertaintySignal, 2);
427 "Station level Rmu for %i - %s: %.2f +/- %.2f at %.2f m") %
428 un2det.Id % un2det.type % stationRmu %
429 (un2det.uncertaintySignal / un2det.referenceSignal) %
435 if (un2det.station.IsLowGainSaturation() && !un2det.isVirtual)
438 vector<double> predIntegratedSignal;
439 vector<double> fitIntegratedSignal;
440 vector<double> stdIntegratedSignal;
443 if (!un2det.isVirtual && !un2det.station.IsLowGainSaturation() &&
444 un2det.referenceSignal > 3 &&
445 un2det.totalSignal > 1) {
447 if (un2det.type ==
"SSD")
450 vector<double> timeVec = {0};
455 for (
unsigned int i = un2det.signalStartSlot;
456 i < (un2det.signalStartSlot + 4500 / un2det.nsBin); ++i) {
458 timeVec.push_back(timeVec.back() + un2det.nsBin);
461 if (i < trace.GetSize()-1 && i < un2det.signalStopSlot) {
463 un2det.integratedSignal.push_back(un2det.integratedSignal.back() +
464 trace[i] * un2det.signalUnit);
465 un2det.integratedNormalizedSignal.push_back(
466 un2det.integratedNormalizedSignal.back() +
467 trace[i] * un2det.signalUnit / un2det.totalSignal);
471 un2det.integratedSignal.push_back(un2det.integratedSignal.back());
472 un2det.integratedNormalizedSignal.push_back(
473 un2det.integratedNormalizedSignal.back());
476 if (un2det.integratedSignal.back() < 0.4 * un2det.totalSignal)
477 un2det.t40RelToStart =
481 un2det.Dt40 = un2det.t40RelToStart - un2det.pfTimeResidual;
484 const string detT0ParName =
485 "t0_" + un2det.type +
"_" + to_string(un2det.Id);
490 INFO(boost::format(
"Detector %s %i added to LDFFit") %un2det.type %un2det.Id);
491 LdfFit.AddDetectorData(un2det);
496 INFO(boost::format(
"Detector %s %i added to EnergyFit") %un2det.type %un2det.Id);
497 EnergyFit.AddDetectorData(un2det);
501 if (un2det.referenceSignal > 5) {
504 INFO(boost::format(
"Detector %s %i added to RatioFit") %un2det.type %un2det.Id);
505 RatioFit.AddDetector(un2det);
508 if (un2det.spRadius < 1800. *
utl::m && un2det.referenceSignal > 5) {
514 {
"Rmu", 1.10, 0.1, 0., 4.,
true},
515 {
"lgE", log10(recEnergy), .1, 18, 21.,
true}});
517 detFit.AddMetaData(avgXmax, log10(recEnergy), recTheta,
519 detFit.AddDetectorData(un2det);
521 const double t0start = un2det.referenceDt0[0] + un2det.pfTimeResidual;
522 const double t0sig = un2det.referenceDt0[1];
524 parDefs.push_back({detT0ParName, t0start, 25., t0start - t0sig,
525 t0start + 0.5 * t0sig,
false});
531 const auto detRes = detMin.GetParametersAndErrors();
533 vector<double> timeVecDet = {};
534 const double t0 = detRes.at(3).first;
536 for (
unsigned int t = 0; t < un2det.integratedSignal.size(); ++t) {
537 timeVecDet.
push_back(t * un2det.nsBin - t0);
542 timeVec, hadrIntModel, log10(recEnergy), recTheta, un2det.spRadius,
543 un2det.spAzimuth, un2det.heightAboveSL, realXmax, 1.0, un2det.type,
544 month, realAtmosphere,
true, un2det.pfTimeResidual, un2det.nsBin,
545 un2det.integratedSignal.back());
548 timeVecDet, hadrIntModel, log10(recEnergy), recTheta,
549 un2det.spRadius, un2det.spAzimuth, un2det.heightAboveSL,
550 detRes.at(0).first, detRes.at(1).first, un2det.type, month,
551 realAtmosphere,
true, un2det.pfTimeResidual, un2det.nsBin,
552 un2det.integratedSignal.back());
555 timeVec, hadrIntModel, log10(recEnergy), recTheta, un2det.spRadius,
556 un2det.spAzimuth, un2det.heightAboveSL, realXmax, 1.0, un2det.type,
557 month, realAtmosphere,
true, un2det.pfTimeResidual, un2det.nsBin,
558 "unc", 0, un2det.integratedSignal.back());
560 for (
unsigned int i = 0; i < timeVecDet.size(); ++i) {
563 utl::Sqr((fitIntegratedSignal[i] - un2det.integratedSignal[i]) /
564 stdIntegratedSignal[i]);
568 (un2det.detChiSq == un2det.detChiSq) ? un2det.detChiSq : FLT_MAX;
573 msg << boost::format(
"%s %i\nr = %.1f m ψ = %.0f°\n") % un2det.type %
574 un2det.Id % un2det.spRadius %
Rad2Deg(un2det.spAzimuth);
575 msg << boost::format(
"reconstructed Signal / pred. reference Signal: "
576 "%.2f / %.2f ± %.2f\n") %
577 un2det.totalSignal % un2det.referenceSignal %
578 un2det.uncertaintySignal;
579 msg << boost::format(
"reference ΔX = %.2f g/cm²\n") % un2det.DX;
582 msg << boost::format(
"Δt0 = %.2f ns (ref.: %.2f ± %.2f ns)\n") %
583 (-1. * un2det.pfTimeResidual) % un2det.referenceDt0[0] %
584 un2det.referenceDt40[1];
585 msg << boost::format(
"Δt40 = %.2f ns (ref.: %.2f ± %.2f ns)\n") %
586 (un2det.Dt40) % un2det.referenceDt40[0] %
587 un2det.referenceDt40[1];
588 msg << boost::format(
"Detector level Xmax: %.2f ± %.4f g/cm²\n") %
589 detRes.at(0).first % detRes.at(0).second;
590 msg << boost::format(
"Detector level Rmu: %.2f ± %.4f g/cm²\n") %
591 detRes.at(1).first % detRes.at(1).second;
592 msg << boost::format(
"Shift t0 = %.2f ns\n") % detRes.at(3).first;
593 msg << boost::format(
"CDF chi squared = %.2f ") % un2det.detChiSq;
596 if (detRes.at(0).first == 780. || un2det.detChiSq > 5.e2 * un2det.referenceSignal/20.) {
598 INFO(
"CDF fit did not converge, not adding detector to PowerFit!");
603 INFO(boost::format(
"Detector %s %i added to PowerFit") %un2det.type %un2det.Id);
607 un2det.detBestFitXmax = detRes.at(0).first;
608 un2det.detBestFitRmu = detRes.at(1).first;
610 un2det.detBestFitT0 = detRes.at(3).first;
612 powerFit.AddDetectorData(un2det);
617 parDefsPow.push_back({detT0ParName, t0, 0.1, t0 - 10, t0 + 10,
true});
626 pythonDump << boost::format(
" {\n");
627 pythonDump << boost::format(
" \"type\": \"%s\", \n") % un2det.type;
628 pythonDump << boost::format(
" \"isVirtual\": \"%s\", \n") %
630 pythonDump << boost::format(
" \"isSat\": \"%s\", \n") %
631 un2det.station.IsLowGainSaturation();
632 pythonDump << boost::format(
" \"id\": %i, \n") % un2det.Id;
633 pythonDump << boost::format(
" \"totalSignal\": %.3f, \n") %
635 pythonDump << boost::format(
" \"uncertaintySignal\": %.3f, \n") %
636 un2det.uncertaintySignal;
637 pythonDump << boost::format(
" \"referenceSignal\": %.3f, \n") %
638 un2det.referenceSignal;
639 pythonDump << boost::format(
" \"referencet40\": %.3f, \n") %
640 un2det.referenceDt40[0];
641 pythonDump << boost::format(
" \"referencet0\": %.3f, \n") %
642 un2det.referenceDt0[0];
643 pythonDump << boost::format(
" \"r\": %.2f, \n") % un2det.spRadius;
644 pythonDump << boost::format(
" \"psi\": %.2f, \n") % un2det.spAzimuth;
645 pythonDump << boost::format(
" \"h\": %.2f, \n") % un2det.heightAboveSL;
646 pythonDump << boost::format(
" \"nsBin\": %.5f, \n") % un2det.nsBin;
647 pythonDump << boost::format(
" \"sigStartSlot\": %.5f, \n") %
648 un2det.signalStartSlot;
649 pythonDump << boost::format(
" \"sigStopSlot\": %.5f, \n") %
650 un2det.signalStopSlot;
651 pythonDump << boost::format(
" \"stationNSTime\": %.5f, \n") %
652 un2det.stationNSTime;
653 pythonDump << boost::format(
" \"stationPFTimeResidual\": %.5f, \n") %
654 un2det.pfTimeResidual;
655 pythonDump << boost::format(
" \"AoP\": %.5f, \n") % un2det.avgAoP;
656 pythonDump << boost::format(
" \"nPMTs\": %.5f, \n") %
657 un2det.station.GetNPMTs();
659 << boost::format(
" \"commissionTimeGPSSecond\": %.2f, \n") %
660 sDet.GetStation(un2det.Id).GetCommissionTime().GetGPSSecond();
664 pythonDump << boost::format(
" }\n,");
671 pythonDump << boost::format(
" \"trace\": [");
672 for (
unsigned int i = 0; i < thisTrace.
GetSize()-1; ++i)
673 pythonDump << boost::format(
"%.4f, ") % thisTrace[i];
674 pythonDump << boost::format(
" ] ,\n");
676 pythonDump << boost::format(
" \"integratedSignal\": [");
677 for (
unsigned int i = 0; i < un2det.integratedSignal.size(); ++i)
678 pythonDump << boost::format(
"%.4f, ") % un2det.integratedSignal[i];
679 pythonDump << boost::format(
" ] ,\n");
681 pythonDump << boost::format(
" \"bestFitIntegratedSignal\": [");
682 for (
unsigned int i = 0; i < fitIntegratedSignal.size(); ++i)
683 pythonDump << boost::format(
"%.4f, ") % fitIntegratedSignal[i];
684 pythonDump << boost::format(
" ] ,\n");
686 pythonDump << boost::format(
" \"predIntegratedSignal\": [");
687 for (
unsigned int i = 0; i < predIntegratedSignal.size(); ++i)
688 pythonDump << boost::format(
"%.4f, ") % predIntegratedSignal[i];
689 pythonDump << boost::format(
" ] ,\n");
691 pythonDump << boost::format(
" \"stdIntegratedSignal\": [");
692 for (
unsigned int i = 0; i < stdIntegratedSignal.size(); ++i)
693 pythonDump << boost::format(
"%.4f, ") % stdIntegratedSignal[i];
694 pythonDump << boost::format(
" ] ,\n");
696 pythonDump << boost::format(
" \"t0\": %.5f, \n") % un2det.detBestFitT0;
697 pythonDump << boost::format(
" \"n\": %.5f, \n") % un2det.detBestFitN;
698 pythonDump << boost::format(
" \"signalUnit\": %.5f, \n") %
700 pythonDump << boost::format(
" \"bestFitXmax\": %.5f, \n") %
701 un2det.detBestFitXmax;
702 pythonDump << boost::format(
" \"bestFitRmu\": %.5f \n") %
703 un2det.detBestFitRmu;
704 pythonDump << boost::format(
" }\n,");
708 pythonDump << boost::format(
"], \n");
710 const double realRmu = isnan(RmuSum / wRmuSum) ? 666 : (RmuSum / wRmuSum);
712 INFO(boost::format(
"dense ring Rmu: %.2f") % realRmu);
713 INFO(boost::format(
"Found %i regular and %i/%i virtual dense detectors.") %
714 numDet % numDenseDet % numDenseDetTot);
715 INFO(boost::format(
"Found %i detectors for time fit.") % numTimeDet);
717 double XmaxResult = 0.;
718 double XmaxResultErr = 10000.;
719 double RmuResult = 0.;
720 double RmuResultErr = 10000.;
721 double lgEResult = 0;
722 double lgEResultErr = 10000.;
732 newEnergyDefs[0] = {
"Xmax", avgXmax, .1, avgXmax - 50, avgXmax + 50,
true};
733 newEnergyDefs[1] = {
"Rmu", 1.1, .01, .9, 1.3,
true};
736 double deltaLgEnergy;
739 if (0.05 > deltaLgEnergy && !(fixEnergyToFd)) {
740 INFO(
"You are running in BENCHMARK MODE! Energy is tightly constrained to MC or S38 value!");
743 const double startLgRecEnergy = (fixEnergyToFd && FdMeanLgEnergy > 0) ? FdMeanLgEnergy : log10(recShower.GetEnergy());
744 newEnergyDefs[2] = {
"lgE", startLgRecEnergy, .015,
745 log10(recEnergy) - deltaLgEnergy, log10(recEnergy) + deltaLgEnergy, fixEnergyToFd};
750 WARNING(
"ENERGY CANNOT BE ESTIMATED!");
759 const auto energyResult = EnergyMin.GetParametersAndErrors();
760 lgEResult = energyResult.at(2).first;
761 lgEResultErr = energyResult.at(2).second;
762 INFO(boost::format(
"LDF lgE fit result: %.2f ± %.2f") % lgEResult %
771 newLDFDefs[0] = {
"Xmax", avgXmax, 3.,
772 avgXmax - 70, avgXmax + 40,
true};
773 newLDFDefs[1] = {
"Rmu", 1.15, .05, 0., 3.,
false};
774 newLDFDefs[2] = {
"lgE", lgEResult, .005, lgEResult - 0.041, lgEResult + 0.041,
778 double XmaxResultLDFOnly, RmuResultLDFOnly;
786 const auto LdfResult = LdfMin.GetParametersAndErrors();
788 INFO(boost::format(
"LDF Xmax fit result: %.2f g/cm² ± %.2f g/cm²") %
789 LdfResult.at(0).first % LdfResult.at(0).second);
790 INFO(boost::format(
"LDF Rmu fit result: %.2f ± %.2f") %
791 LdfResult.at(1).first % LdfResult.at(1).second);
793 XmaxResult = LdfResult.at(0).first;
795 RmuResult = LdfResult.at(1).first;
796 RmuResultErr = LdfResult.at(1).second;
798 lgEResult = LdfResult.at(2).first;
802 XmaxResultLDFOnly = LdfResult.at(0).first;
803 RmuResultLDFOnly = LdfResult.at(1).first;
809 RatioFit.GeneratePairs();
811 newRatioDefs[0] = {
"Xmax", XmaxResult, 2., 600, 1200,
true};
812 newRatioDefs[1] = {
"Rmu", RmuResult, .05, 0, 3,
false};
814 newRatioDefs[2] = {
"lgE", lgEResult, .001, lgEResult - 0.02, lgEResult + 0.02,
818 if (2 < RatioFit.NumPairs()) {
823 const auto RatioResult = RatioMin.GetParametersAndErrors();
825 INFO(boost::format(
"Ratio Rmu fit result: %.2f ± %.2f") %
826 RatioResult.at(1).first % RatioResult.at(1).second);
828 RmuResult = RatioResult.at(1).first;
829 RmuResultErr = RatioResult.at(1).second;
833 if (biasCorrection) {
841 newPowerDefs[0] = {
"Xmax", avgXmax, 5., 600, 1200, fixXmaxToFd};
843 newPowerDefs[1] = {
"Rmu", RmuResult, .01, RmuResult - 0.05, RmuResult + 0.05,
846 newPowerDefs[2] = {
"lgE", lgEResult, .001, lgEResult - 0.02, lgEResult + 0.02,
856 const auto powerResult = powerMin.GetParametersAndErrors();
858 XmaxResult = powerResult.at(0).first;
859 XmaxResultErr = powerResult.at(0).second;
864 lgEResult = powerResult.at(2).first;
869 if (biasCorrection) {
874 const double recLnA =
lnA(RmuResult, XmaxResult, log10(recEnergy), realEvent);
876 pythonDump << boost::format(
"\"numDet\": %i,\n") % numDet;
877 pythonDump << boost::format(
"\"numEnDet\": %i,\n") % numEnDet;
878 pythonDump << boost::format(
"\"numTimeDet\": %i,\n") % numTimeDet;
879 pythonDump << boost::format(
"\"numSatDet\": %i,\n") % numSatDet;
880 pythonDump << boost::format(
"\"T5Status\": %i,\n") %
881 event.GetRecShower().GetSRecShower().GetT5Trigger();
882 pythonDump << boost::format(
"\"realRmu\": %.5f,\n") % realRmu;
883 pythonDump << boost::format(
"\"resultRmu\": %.5f,\n") % RmuResult;
884 pythonDump << boost::format(
"\"resultXmax\": %.5f,\n") % XmaxResult;
885 pythonDump << boost::format(
"\"resultlgE\": %.5f,\n") % lgEResult;
886 pythonDump << boost::format(
"\"uncRmu\": %.5f,\n") % RmuResultErr;
887 pythonDump << boost::format(
"\"uncXmax\": %.5f,\n") % XmaxResultErr;
888 pythonDump << boost::format(
"\"LdfRmu\": %.5f,\n") % RmuResultLDFOnly;
889 pythonDump << boost::format(
"\"LdfXmax\": %.5f,\n") % XmaxResultLDFOnly;
890 pythonDump << boost::format(
"\"recLnA\": %.5f,\n") % recLnA;
891 pythonDump << boost::format(
"\"FdMeanXmax\": %.5f,\n") % FdMeanXmax;
892 pythonDump << boost::format(
"\"FdXmax\": [");
893 for (
unsigned int i = 0; i < FdXmax.size(); ++i)
894 pythonDump << boost::format(
"(%.4f, %.4f), ") % FdXmax[i].at(0) %
896 pythonDump << boost::format(
"] ,\n");
897 pythonDump << boost::format(
"}\n");
900 INFO(boost::format(
"MC/average Xmax = %.2f g/cm²") % (realXmax));
901 INFO(boost::format(
"Combined Xmax fit result: %.2f g/cm² ± %.2f g/cm²") %
902 XmaxResult % XmaxResultErr);
903 INFO(boost::format(
"Combined Rmu fit result: %.2f ± %.2f") % RmuResult %
905 INFO(boost::format(
"Xmax/Rmu correlation lnA: %.2f ") % recLnA);
913 event.GetRecShower().GetUnivRecShower().SetGoodRec(XmaxResultErr < 300. && RmuResultErr < 1.);
914 event.GetRecShower().GetUnivRecShower().SetNmu(RmuResult, RmuResultErr);
915 event.GetRecShower().GetUnivRecShower().SetXmax(XmaxResult * gcm,
916 XmaxResultErr * gcm);
917 event.GetRecShower().GetUnivRecShower().SetEnergy(
pow(10., lgEResult),
918 pow(10, lgEResultErr));
919 event.GetRecShower().GetUnivRecShower().SetLnA(
922 INFO(boost::format(
"Ending un2 reconstruction."));
void SetVerbose(const bool verbose)
double CalcDX(const bool realAtmosphere, const bool useDL, const double spRadius, const double spPsi, const double groundHeight, const double xMax, const double theta, const int month, const bool silent)
double BiasCorrectionXmax(const double sst, const double lgE, const bool realEvent)
double BiasCorrectionRmu(const double sst, const double lgE, const bool realEvent)
bool HasUnivRecShower() const
constexpr double Rad2Deg(const double rad)
constexpr T Sqr(const T &x)
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
total (shower and background)
evt::Header & GetHeader()
void GetTimeQuantile(const float *const trace, const float sum, const int nT, const float timeUnit, const float f, float &tQ, float &tQ_err)
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
bool HasRecShower() const
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
ShowerRecData & GetRecShower()
bool HasSimShower() const
#define INFO(message)
Macro for logging informational messages.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
EyeIterator EyesBegin(const ComponentSelector::Status status)
ShowerSimData & GetSimShower()
vector< double > GetSignal(string model, double lgE, double zenith, double r, double psi, double height, double Xmax, double Rmu, string detector, int month, bool realAtmosphere, bool useThreshold)
double GetEnergy() const
Get the energy of the shower primary particle.
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
std::vector< ParameterDef > & GetParameterDefs()
unsigned int signalStartSlot
fevt::FEvent & GetFEvent()
bool HasEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
void SetNmu(const double Nmu)
double lnA(const double Rmu, const double Xmax, const double lgE, const bool realEvent)
int Minimize(const int n=500)
double SignalUncertainty(const ESignalVarianceModel model, const double cosTheta, const double signal)
unsigned long GetGPSSecond() const
GPS second.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
double avgXmax0(const double lgE, const bool realEvent)
vector< double > GetIntegratedTotalSignalSum(vector< double > t, string model, double lgE, double zenith, double r, double psi, double height, double Xmax, double Rmu, string detector, int month, bool realAtmosphere, bool useThreshold, double planeFrontTimeResidual, double nsBin, double normalized)
vector< double > GetIntegratedTotalSignal(vector< double > t, string model, double lgE, double zenith, double r, double psi, double height, double Xmax, double Rmu, string detector, int month, bool realAtmosphere, bool useThreshold, double planeFrontTimeResidual, double nsBin, string returnValue, int component, double normalized)
double SignalUncertainty(const ESignalVarianceModel model, const double cosTheta, const double signal)
void SimpleReco(evt::Event &event)
#define ERROR(message)
Macro for logging error messages.
void SetParameterDefs(const std::vector< ParameterDef > &defs)
mu+ and mu- (including signal from mu decay electrons) from shower
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
utl::CoordinateSystemPtr GetShowerCoordinateSystem() const
r push_back(GetParameter(i))