5 #include <fwk/CentralConfig.h>
6 #include <fwk/RunController.h>
7 #include <fwk/RandomEngineRegistry.h>
8 #include <fwk/LocalCoordinateSystem.h>
10 #include <det/Detector.h>
12 #include <fdet/FDetector.h>
15 #include <sdet/SDetector.h>
16 #include <sdet/Station.h>
18 #include <rdet/RDetector.h>
19 #include <rdet/Station.h>
21 #include <evt/Event.h>
22 #include <evt/Header.h>
23 #include <evt/ShowerSimData.h>
24 #include <evt/RadioSimulation.h>
25 #include <evt/SimRadioPulse.h>
26 #include <evt/DefaultShowerGeometryProducer.h>
28 #include <revt/REvent.h>
29 #include <revt/Header.h>
31 #include <sevt/SEvent.h>
32 #include <sevt/Header.h>
33 #include <sevt/StationSimData.h>
34 #include <sevt/Station.h>
36 #include <fevt/FEvent.h>
37 #include <fevt/Header.h>
39 #include <mevt/MEvent.h>
40 #include <mevt/Header.h>
41 #include <mdet/MDetector.h>
42 #include <mdet/Counter.h>
43 #include <mevt/CounterSimData.h>
44 #include <mevt/Counter.h>
46 #include <utl/AugerCoordinateSystem.h>
47 #include <utl/AugerUnits.h>
48 #include <utl/CoordinateSystem.h>
49 #include <utl/Transformation.h>
50 #include <utl/ErrorLogger.h>
51 #include <utl/Reader.h>
52 #include <utl/UTMPoint.h>
53 #include <utl/ReferenceEllipsoid.h>
54 #include <utl/Vector.h>
55 #include <utl/AxialVector.h>
56 #include <utl/PhysicalConstants.h>
57 #include <utl/RandomEngine.h>
59 #include <utl/String.h>
60 #include <utl/Triple.h>
61 #include <utl/AugerException.h>
62 #include <utl/GeometryUtilities.h>
64 #include <boost/format.hpp>
66 #include <CLHEP/Random/RandFlat.h>
81 using namespace EventGeneratorOG;
83 using CLHEP::RandFlat;
86 namespace EventGeneratorOG {
99 for (
size_t t = 1; t <
a; ++t)
109 CentralConfig::GetInstance()->
GetTopBranch(
"EventGenerator");
116 if (topBranch.
GetChild(
"useRadioCorePosition")) {
117 topBranch.
GetChild(
"useRadioCorePosition").
GetData(fUseRadioCorePosition);
121 "\tUsage of radio core position is set to " << fUseRadioCorePosition <<
"\n"
122 "\tUsage of radio event time is set to " << fUseRadioEventTime;
130 else if (mode ==
"FD")
132 else if (mode ==
"Hy")
134 else if (mode ==
"MD")
136 else if (mode ==
"XD")
138 else if (mode ==
"XH")
141 INFO(
"Undefined event type...");
147 fSampleTimes =
false;
148 eventTimeB.
GetData(fStartDate);
155 fTimeOrdered =
false;
156 fTimeRandomized =
true;
163 timeRandomizedB.
GetData(fTimeRandomized);
172 Branch invalidateCompB = topBranch.
GetChild(
"invalidateComponents");
174 fInvalidateData =
true;
175 fInvalidateComponents =
true;
177 INFO(
"Configuring invalidation flags.");
178 if (invalidateDataB) {
179 INFO(
"Loading invalidate data flag from branch.");
180 invalidateDataB.
GetData(fInvalidateData);
182 if (invalidateCompB) {
183 INFO(
"Loading invalidate components flag from branch.");
184 invalidateCompB.
GetData(fInvalidateComponents);
187 INFO(
"Detector data will be invalidated on update.");
188 if (fInvalidateComponents)
189 INFO(
"Detector components will be invalidated on update.");
191 det::Detector::GetInstance().Update(fStartDate, fInvalidateData, fInvalidateComponents);
194 Branch coreRandomizationB = topBranch.
GetChild(
"coreRandomization");
197 Branch useCoresFromAirShowerMCB = coreRandomizationB.
GetChild(
"useCoresFromAirShowerMC");
200 Branch centerOfTileB = coreRandomizationB.
GetChild(
"centerOfTile");
201 Branch listOfCorePositionsB = coreRandomizationB.
GetChild(
"listOfCorePositions");
202 Branch useRandomStationB = coreRandomizationB.
GetChild(
"useRandomStation");
203 Branch useRandomInfillStationB = coreRandomizationB.
GetChild(
"useRandomInfillStation");
204 Branch sphereCenterB = coreRandomizationB.
GetChild(
"sphereCenter");
206 fUseRandomInfillStation =
false;
207 fUseRandomStation =
false;
209 if (useCoresFromAirShowerMCB) {
214 }
else if (useRandomStationB) {
216 useRandomStationB.
GetData(fUseRandomStation);
218 if (useRandomInfillStationB)
219 useRandomInfillStationB.
GetData(fUseRandomInfillStation);
221 }
else if (centerOfTileB) {
229 Branch stationAtCenterB = centerOfTileB.
GetChild(
"stationAtCenter");
230 if (stationAtCenterB) {
232 stationAtCenterB.
GetData(stationId);
235 det::Detector::GetInstance().GetSDetector().GetStation(stationId);
247 if (centerOfTileB.
GetChild(
"altitude"))
251 WARNING(
"keyword 'height' is deprecated in specification of core position. Please use 'altitude'.");
257 }
else if (listOfCorePositionsB) {
260 const double nor = coreB.GetChild(
"northing").Get<
double>();
261 const double eas = coreB.GetChild(
"easting").Get<
double>();
263 if (coreB.GetChild(
"altitude"))
264 coreB.GetChild(
"altitude").GetData(alt);
266 coreB.GetChild(
"height").GetData(alt);
267 WARNING(
"keyword 'height' is deprecated in specification of core position. Please use 'altitude'.");
269 const int zone = coreB.GetChild(
"zone").Get<
int>();
270 const char band = coreB.GetChild(
"band").Get<
char>();
271 fCorePositions.push_back(boost::tuple<double, double, double, int, char>(nor, eas, alt, zone, band));
274 fCorePositionsIt = fCorePositions.begin();
276 }
else if (sphereCenterB) {
284 Branch sphereCenterB = coreRandomizationB.
GetChild(
"sphereCenter");
285 const double nor = sphereCenterB.
GetChild(
"northing").
Get<
double>();
286 const double eas = sphereCenterB.
GetChild(
"easting").
Get<
double>();
288 if (sphereCenterB.
GetChild(
"altitude"))
292 WARNING(
"keyword 'height' is deprecated in specification of core position. Please use 'altitude'.");
294 const int zone = sphereCenterB.
GetChild(
"zone").
Get<
int>();
295 const char band = sphereCenterB.
GetChild(
"band").
Get<
char>();
296 fSphereCenter = boost::tuple<double, double, double, int, char>(nor, eas, alt, zone, band);
306 if (coreRandomizationB.
GetChild(
"mindist"))
308 if (coreRandomizationB.
GetChild(
"altitude"))
312 WARNING(
"keyword 'height' is deprecated in specification of core position. Please use 'altitude'.");
316 fRMaxEnergyDependent = (enDep ==
"yes");
318 coreRandomizationB.
GetChild(
"geometryCherenkovHECO").
GetData(fGeometryCheckCherenkovHECO);
319 if (fRMaxEnergyDependent && fGeometryCheckCherenkovHECO) {
320 WARNING(
"geometryCherenkovHECO is not compatible with rMaxEnergyDependent, geometryCherenkovHECO switched OFF");
321 fGeometryCheckCherenkovHECO =
false;
323 if (fGeometryCheckCherenkovHECO && coreRandomizationB.
GetChild(
"maxVAfileHECO")) {
326 TFile
file(f.c_str());
327 fMaxVA = (TH2D*)
file.Get(
"hMaxVA");
328 fMaxVA->SetDirectory(0);
334 fRandomEngine = &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector);
337 if (fSampleTimes && fTimeOrdered) {
339 INFO(
"generate new times and sort ascending .... ");
340 const double intervalLength = (fEndDate - fStartDate).GetInterval();
341 const auto re = &fRandomEngine->GetEngine();
342 for (
int i = 0; i < fNEvents; ++i) {
344 fTimeList.push_back(RandFlat::shoot(re, 0, 1) * intervalLength);
346 fTimeList.push_back(i * intervalLength / fNEvents);
356 info <<
"Parameters:\n"
357 " library identifier: " << fLibraryIdentifier <<
"\n"
358 " Id format: " << fFormat <<
"\n"
359 " SD Id format: " << fSdIdFormat[0] <<
" " << fSdIdFormat[1] <<
"\n"
360 " event init mode: ";
362 case eSD: info <<
"SD\n";
break;
363 case eFD: info <<
"FD\n";
break;
364 case eHy: info <<
"Hybrid\n";
break;
365 case eMD: info <<
"MD\n";
break;
366 case eXD: info <<
"eXtended SD (SD + MD)\n";
break;
367 case eXH: info <<
"eXtended Hybrid (SD + MD + FD)\n";
break;
368 default: info <<
"unknown\n";
break;
371 info <<
" -- sample event times from period -- \n"
372 " start period: " << fStartDate <<
"\n"
373 " end period: " << fEndDate <<
"\n"
374 " time pre-ordered: " << (fTimeOrdered ?
"yes" :
"no");
376 info <<
"; number of events: " << fNEvents;
377 info <<
"; time randomized: " << (fTimeRandomized ?
"yes" :
"no")
380 info <<
" event time: " << fStartDate <<
'\n';
383 info <<
" -- use cores from EAS simulation program -- \n";
384 }
else if (fInSphere) {
385 info <<
" -- shere volume centric option-- \n"
386 " sphere radius: " << fSphereRadius/
m <<
" m\n"
387 " skip upgoing: " << fSkipUpgoing <<
" m\n"
388 " maximum Rp limited: " << fLimitRp <<
" m\n"
389 " sphere center northing: " << fSphereCenter.get<0>() <<
" m\n"
390 " sphere center easting: " << fSphereCenter.get<1>() <<
" m\n"
391 " sphere center altitude: " << fSphereCenter.get<2>() <<
" m\n"
392 " sphere center zone: " << fSphereCenter.get<3>() <<
"\n"
393 " sphere center band: " << fSphereCenter.get<4>();
394 }
else if (fEyeCentric) {
395 info <<
" -- eye centric core randomization -- \n"
396 " eye Id: " << fEyeid <<
"\n"
397 " telescope Id: " << fTelid <<
"\n"
398 " delta phi: " << fDeltaPhi/
deg <<
"deg\n"
399 " min distance: " << fMinDist/
km <<
"km\n"
400 " max distance: " << fMaxDist/
km <<
"km"
401 << (fRMaxEnergyDependent ?
" (energy dependent)" :
"") <<
"\n"
402 << (fGeometryCheckCherenkovHECO ?
"Cherenkov HECO geometry cut\n" :
"") <<
403 " altitude: " << fAltitude/
m <<
'm';
405 if (fUseRandomStation) {
406 if (fUseRandomInfillStation)
407 info <<
" -- cores around random infill station --";
409 info <<
" -- cores around random station --";
410 }
else if (!fCorePositions.empty()) {
411 info <<
" -- cores from XML list --\n"
412 " number of cores: " << fCorePositions.size();
414 info <<
" -- array centric core randomization -- \n"
415 " northing: " << fNorthing <<
"\n"
416 " easting: " << fEasting <<
"\n"
417 " altitude: " << fAltitude;
435 const bool justSetDetectorTimeForMuonCalibrationLoop =
436 !
event.HasSimShower() && fMode != eMD && fMode != eXD && fMode != eXH;
440 const auto re = &fRandomEngine->GetEngine();
446 if (fTimeList.empty()) {
447 INFO(
"Maximum number of events generated in time interval. Stopping.");
451 eventTime = fStartDate +
TimeInterval(fTimeList.front());
454 if (!justSetDetectorTimeForMuonCalibrationLoop)
455 fTimeList.pop_front();
460 const double intervalLength = (fEndDate - fStartDate).GetInterval();
461 eventTime = fStartDate +
TimeInterval(RandFlat::shoot(re, 0, 1) * intervalLength);
466 if (fUseRadioEventTime) {
473 rdout <<
"Setting event time to radio event time " << eventTime;
476 throw utl::AugerException(
"UseRadioEventTime is set to true but no SimShower is available! Abort ...");
488 det::Detector::GetInstance().Update(eventTime, fInvalidateData, fInvalidateComponents);
491 if (justSetDetectorTimeForMuonCalibrationLoop) {
499 INFO(
"SimShower does not exist, only detector time will be set.");
501 if (event.
HasSEvent() ||
event.HasFEvent() ||
event.HasMEvent()) {
503 err <<
"Something in your ModuleSequence must be wrong! Your event data structure is corrupt (hasSd="
504 <<
event.HasSEvent() <<
", hasFD=" <<
event.HasFEvent()
505 <<
", hasMD=" <<
event.HasMEvent() <<
")!";
511 if (fMode ==
eSD || fMode == eHy || fMode == eXD || fMode == eXH) {
512 INFO(
"SD event is created for calibration loop.");
517 if (fMode ==
eFD || fMode == eHy || fMode == eXH) {
518 INFO(
"FD event is created for drum calibration loop.");
534 if (!event.
HasSEvent() && (fMode ==
eSD || fMode == eHy || fMode == eXD || fMode == eXH))
537 if (!event.
HasFEvent() && (fMode ==
eFD || fMode == eHy || fMode == eXH))
540 if (!event.
HasMEvent() && (fMode == eMD || fMode == eXD || fMode == eXH))
543 #warning RU: I think this should throw exception here. SimShower must already exists in EventGenerator. Check logic!!!!!
551 "You are using a shower with pre-defined core locations (e.g. AUGERHIT) but try to overwrite them. "
552 "This is not consistent. Very likely your simulation is garbage...";
560 if (fUseRandomStation) {
562 const sdet::SDetector& det = det::Detector::GetInstance().GetSDetector();
563 std::vector<int> stationList;
565 for (
const auto&
s : det.StationsRange()) {
566 if (fUseRandomInfillStation) {
568 stationList.push_back(
s.GetId());
569 }
else if (
s.IsInGrid() &&
s.GetCrown(1).size() == 6)
570 stationList.push_back(
s.GetId());
573 if (stationList.empty())
574 throw utl::AugerException(
"Asked to simulate around a random station but I get an empty list of stations.");
576 const int nrOfStations = stationList.size();
577 const int stationPos = int(RandFlat::shoot(re, 0, 1) * nrOfStations);
578 const int stationId = stationList[stationPos];
583 fEasting = utm.GetEasting();
584 fAltitude = utm.GetHeight();
585 fZone = utm.GetZone();
586 fBand = utm.GetBand();
587 fStationId = stationId;
590 bool csDefined =
false;
593 double newNorthingCore = 0;
594 double newEastingCore = 0;
595 double newAltitudeCore = 0;
602 coreCS = AugerCoordinateSystem::Create(core, e, e.
GetECEF());
610 }
else if (fInSphere) {
611 boost::tie(newEastingCore, newNorthingCore, newAltitudeCore) = GenerateSphereCentricCore(shower);
612 }
else if (fEyeCentric) {
613 boost::tie(newEastingCore, newNorthingCore) = GenerateEyeCentricCore(shower.
GetEnergy());
614 newAltitudeCore = fAltitude;
616 if (!fCorePositions.empty()) {
617 if (fCorePositionsIt == fCorePositions.end()) {
618 if (!fUseRadioCorePosition) {
619 INFO(
"Reached last requested core position in the list. Terminating the run.");
623 boost::tie(newEastingCore, newNorthingCore, newAltitudeCore) = GenerateArrayCentricListedCore();
625 if (fUseRandomStation) {
626 boost::tie(newEastingCore, newNorthingCore) = GenerateArrayCentricRandomizedCoreAroundRandomStation();
627 newAltitudeCore = fAltitude;
629 boost::tie(newEastingCore, newNorthingCore) = GenerateArrayCentricRandomizedCore();
630 newAltitudeCore = fAltitude;
635 const UTMPoint newPosition(newNorthingCore, newEastingCore, newAltitudeCore, fZone, fBand, e);
636 coreCS = AugerCoordinateSystem::Create(newPosition.
GetPoint(), e, e.
GetECEF());
641 if (fUseRadioCorePosition) {
664 rdout <<
"Set core position to radio core position ("
665 << core.
GetX(refCS)/
m <<
", " << core.GetY(refCS)/
m <<
", " << core.GetZ(refCS)/
m <<
") m "
666 "in reference CS (usually PampaAmarilla)";
679 static string showerRunId;
680 static int showerNumber = -1;
689 (boost::format(fFormat) % fLibraryIdentifier % showerRunId % showerNumber % fEventNumber).str();
699 const size_t showerNumberMax =
MyPow10(fSdIdFormat[0]);
700 const size_t useMax =
MyPow10(fSdIdFormat[1]);
701 stringstream runNumberStream;
702 for (
const auto&
c : showerRunId)
703 if (
'0' <=
c &&
c <=
'9')
704 runNumberStream << char(
c);
705 size_t runNumber = 0;
706 runNumberStream >> runNumber;
708 const int numericalId =
709 runNumber * showerNumberMax * useMax +
710 (showerNumber % showerNumberMax) * useMax +
711 (fEventNumber % useMax);
713 if (fMode ==
eSD || fMode == eHy || fMode == eXD || fMode == eXH) {
715 sHeader.
SetId(numericalId);
719 if (fMode ==
eFD || fMode == eHy || fMode == eXH) {
721 fHeader.
SetId(numericalId);
731 if (fMode == eMD || fMode == eXD || fMode == eXH) {
733 mHeader.
SetId(numericalId);
738 info <<
"generated event '" <<
id <<
"', "
739 "northing = " << setprecision(8) << newNorthingCore <<
", "
740 "easting = " << newEastingCore;
741 if (fUseRandomStation)
742 info <<
" (" <<
"around station " << fStationId <<
')';
745 if (fMode ==
eSD || fMode == eHy || fMode == eXD || fMode == eXH)
746 FlagHoleStations(event);
749 ++RunController::GetInstance().GetRunData().GetNamedCounters()[
"EventGenerator/GeneratedEvents"];
751 if ((fSkipUpgoing && fUpgoingShower) || (fLimitRp && fRpTooLarge)) {
752 return eContinueLoop;
760 EventGenerator::Finish()
763 if (fSampleTimes && fTimeOrdered && !fTimeList.empty()) {
765 const int nRemains = fTimeList.size();
769 " **********************************************************************************************\n"
771 " * sampling " << fNEvents <<
" time" <<
String::Plural(fNEvents) <<
" from time interval NOT successful!\n"
773 " * specified period from: " << fStartDate <<
"\n"
774 " * to: " << fEndDate <<
"\n"
776 " * stopped after " << (fNEvents-nRemains) <<
" event" <<
String::Plural(fNEvents-nRemains) <<
"!"
777 " Unprocessed " << nRemains <<
" event" <<
String::Plural(nRemains) <<
"!\n"
779 " * Since events are generated after beeing ordered in time no events have been issued\n"
780 " * from: " << (fStartDate +
TimeInterval(fTimeList.front())) <<
"\n"
781 " * to: " << fEndDate <<
"\n"
783 " * List of missing events:\n";
785 for (
const auto& t : fTimeList)
786 err <<
" * - Missing event No " << (++iMiss) <<
" at time " << (fStartDate +
TimeInterval(t)) <<
'\n';
789 " * Please read EventGenerator documentation to learn how to use <timeInterval> properly\n"
791 " **********************************************************************************************\n"
802 boost::tuple<double, double>
803 EventGenerator::GenerateArrayCentricRandomizedCore()
805 const auto re = &fRandomEngine->GetEngine();
806 const double newEastingCore = fEasting + RandFlat::shoot(re, -0.5, 0.5) * fDeltaEasting;
807 const double newNorthingCore = fNorthing + RandFlat::shoot(re, -0.5, 0.5) * fDeltaNorthing;
809 return boost::tuple<double, double>(newEastingCore, newNorthingCore);
817 const double gridSize = 750;
818 const sdet::SDetector& det = det::Detector::GetInstance().GetSDetector();
819 for (
const auto&
s : det.StationsRange()) {
821 s.GetId() != centralStation.
GetId() &&
822 (
s.GetPosition() - centralStation.
GetPosition()).GetMag() < 1.5*gridSize)
823 stations.push_back(
s.GetId());
830 boost::tuple<double, double>
831 EventGenerator::GenerateCoreAroundStation()
835 fDeltaNorthing = 2000*
meter;
836 fDeltaEasting = 2000*
meter;
838 const sdet::SDetector& detector = det::Detector::GetInstance().GetSDetector();
843 if (!fUseRandomInfillStation)
844 stations = centralStation.
GetCrown(1);
850 double eastingCore = 0;
851 double northingCore = 0;
854 const auto re = &fRandomEngine->GetEngine();
855 eastingCore = fEasting + RandFlat::shoot(re, -0.5, 0.5)*fDeltaEasting;
856 northingCore = fNorthing + RandFlat::shoot(re, -0.5, 0.5)*fDeltaNorthing;
858 const UTMPoint utmPosition(northingCore, eastingCore, fAltitude, fZone, fBand, e);
862 for (
const auto id : stations) {
864 in = in && (crownStationVector*randomVector < 0.5*(crownStationVector*crownStationVector));
868 return boost::tuple<double, double>(eastingCore, northingCore);
872 boost::tuple<double, double>
873 EventGenerator::GenerateArrayCentricRandomizedCoreAroundRandomStation()
877 fDeltaNorthing = 2000*
meter;
878 fDeltaEasting = 2000*
meter;
880 const double minAngle = 2*
utl::kPi - 0.1;
881 const double maxAngle = 2*
utl::kPi + 0.1;
883 const sdet::SDetector& detector = det::Detector::GetInstance().GetSDetector();
886 if (fUseRandomInfillStation)
889 double eastingCore = 0;
890 double northingCore = 0;
891 double totalAngle = 0;
894 const auto re = &fRandomEngine->GetEngine();
896 eastingCore = fEasting + RandFlat::shoot(re, -0.5, 0.5)*fDeltaEasting;
897 northingCore = fNorthing + RandFlat::shoot(re, -0.5, 0.5)*fDeltaNorthing;
899 const UTMPoint position(northingCore, eastingCore, fAltitude, fZone, fBand, e);
908 Vector stVector0 = center - hittingPosition;
917 for (
const auto id : stations) {
920 const double angle = acos(stVector * stVector0);
921 if (angle <= secondAngle) {
922 if (angle < firstAngle) {
923 secondAngle = firstAngle;
945 const double dist = 100;
946 const Point zero(0,0,0, localCS);
947 const Point p1 = zero + 0.5 * st2First;
948 const Point p11 = p1 + dist * v1;
949 const Point p2 = zero + 0.5 * st2Second;
950 const Point p22 = p2 + dist * v2;
952 const utl::Triple trip1 = p1.GetCoordinates(localCS);
953 const utl::Triple trip11 = p11.GetCoordinates(localCS);
954 const utl::Triple trip2 = p2.GetCoordinates(localCS);
955 const utl::Triple trip22 = p22.GetCoordinates(localCS);
957 const double x1 = trip1.get<0>();
958 const double y1 = trip1.get<1>();
959 const double x2 = trip11.get<0>();
960 const double y2 = trip11.get<1>();
962 const double x3 = trip2.get<0>();
963 const double y3 = trip2.get<1>();
964 const double x4 = trip22.get<0>();
965 const double y4 = trip22.get<1>();
967 const double denominator = (x1 - x2)*(y3 - y4) - (x3 - x4)*(y1 - y2);
968 const double nominatorX = (x1*y2 - x2*y1)*(x3 - x4) - (x3*y4 - x4*y3)*(x1 - x2);
969 const double finalPointX = nominatorX / denominator;
970 const double nominatorY = (x1*y2 - x2*y1)*(y3 - y4) - (x3*y4 - x4*y3)*(y1 - y2);
971 const double finalPointY = nominatorY / denominator;
973 const Point middlePoint(finalPointX, finalPointY, 0.5*(trip1.get<2>() + trip2.get<2>()), localCS);
980 totalAngle = acos(x0cm*x1cm) + acos(x1cm*x2cm) + acos(x2cm*x3cm) + acos(x3cm*x0cm);
982 }
while (totalAngle < minAngle || totalAngle > maxAngle);
984 return boost::tuple<double, double>(eastingCore, northingCore);
988 boost::tuple<double, double, double>
989 EventGenerator::GenerateArrayCentricListedCore()
991 const double newNorthingCore = fCorePositionsIt->get<0>();
992 const double newEastingCore = fCorePositionsIt->get<1>();
993 const double newAltCore = fCorePositionsIt->get<2>();
994 fZone = fCorePositionsIt->get<3>();
995 fBand = fCorePositionsIt->get<4>();
999 return boost::tuple<double, double, double>(newEastingCore, newNorthingCore, newAltCore);
1003 boost::tuple<double, double>
1004 EventGenerator::GenerateEyeCentricCore(
const double energy)
1007 det::Detector::GetInstance().GetFDetector();
1013 const double dPhiOneTel = 30*
deg;
1014 const double phiMean = 0.5*dPhiOneTel + (fTelid-1) * dPhiOneTel;
1015 const double phiMax = phiMean + 0.5*fDeltaPhi;
1016 const double phiMin = phiMean - 0.5*fDeltaPhi;
1018 const auto re = &fRandomEngine->GetEngine();
1019 const double phi = RandFlat::shoot(re, phiMin, phiMax);
1021 const double logEnergy = log10(energy /
eV);
1022 const double rmin = fMinDist;
1023 const double rmax = fGeometryCheckCherenkovHECO ?
1024 RcutoffCherenkovHECO(logEnergy) :
1025 (fRMaxEnergyDependent ? Rcutoff(logEnergy) : fMaxDist);
1029 rmin + (rmax - rmin) *
sqrt(RandFlat::shoot(re, 0, 1));
1031 const Point core(r*cos(phi), r*sin(phi), 0, eyeCS);
1037 const double newEastingCore = coreUTM.
GetEasting();
1038 const double newNorthingCore = coreUTM.
GetNorthing();
1043 return boost::tuple<double, double>(newEastingCore, newNorthingCore);
1047 boost::tuple<double, double, double>
1050 fUpgoingShower =
false;
1053 const UTMPoint centerUTM(fSphereCenter.get<0>(), fSphereCenter.get<1>(), fSphereCenter.get<2>(),
1054 fSphereCenter.get<3>(), fSphereCenter.get<4>(), e);
1061 const auto re = &fRandomEngine->GetEngine();
1062 const double phi = RandFlat::shoot(re, 0, 360*
deg);
1064 const double rmin = 0;
1065 const double rmax = fSphereRadius;
1069 rmin + (rmax - rmin) *
sqrt(RandFlat::shoot(re, 0, 1));
1071 const Vector up(0,0,1, centerCS);
1073 const Vector direction(sin(zenith)*cos(azimuth), sin(zenith)*sin(azimuth), cos(zenith), centerCS);
1075 const Transformation rot = Transformation::Rotation(phi, direction, centerCS);
1078 if (perpDir.
GetMag() > 1e-3) {
1081 const Vector right(1,0,0, centerCS);
1088 const Point groundPoint =
Point(0,0,0, referenceCS);
1091 Point core = impactPoint;
1093 const vector<Point> pEarth =
1096 if (pEarth.size() == 2) {
1099 if (zenith > 90*
deg) {
1101 fUpgoingShower =
true;
1109 const double newEastingCore = coreUTM.
GetEasting();
1110 const double newNorthingCore = coreUTM.
GetNorthing();
1111 const double newHeightCore = coreUTM.
GetHeight();
1125 const fdet::FDetector& fDetector = det::Detector::GetInstance().GetFDetector();
1128 const Point& eyePos = iEye->GetPosition();
1129 const Vector coreToEye = eyePos - core;
1130 const double rp = (coreToEye - (coreToEye*direction)*direction).GetMag();
1131 const double rpMax = MaximumRp(log10(shower.
GetEnergy() /
eV));
1133 fRpTooLarge =
false;
1139 return boost::tuple<double, double, double>(newEastingCore, newNorthingCore, newHeightCore);
1160 EventGenerator::Rcutoff(
const double lgE)
1162 const double x =
max(16.5, min(21., lgE));
1164 const double p1 = 4.86267e+05;
1165 const double p2 = -6.72442e+04;
1166 const double p3 = 2.31169e+03;
1168 return (p1 + x*(p2 + x*p3)) *
meter;
1173 EventGenerator::RcutoffCherenkovHECO(
const double lgE)
1177 info <<
"fMaxVA not specified, return Rcutoff" << endl;
1179 return Rcutoff(lgE);
1181 const int binLogE = fMaxVA->ProjectionX()->FindBin(lgE);
1182 const double hecoDistance = 169.46*
meter;
1183 double maxDist = fMaxVA->ProjectionY()->GetBinLowEdge(fMaxVA->GetNbinsY()+1)*
meter + hecoDistance;
1184 if (binLogE < 1 || binLogE > fMaxVA->GetNbinsX()) {
1185 info <<
"fMaxVA bin not found, maximum distance returned (" << maxDist/
meter <<
')' << endl;
1189 for (
int i = 1, n = fMaxVA->GetNbinsY()+1; i < n; ++i) {
1190 if (!fMaxVA->GetBinContent(binLogE, i)) {
1191 maxDist = fMaxVA->ProjectionY()->GetBinLowEdge(i)*
meter + hecoDistance;
1195 info <<
"maximum distance = " << maxDist/
meter << endl;
1202 EventGenerator::MaximumRp(
const double lgEeV)
1204 const double x =
max(lgEeV, 17.2);
1205 const double p[3] = { 4.68168e-3, 0.5, -19.1270 };
1206 const double q[2] = { 4.0, -26.8000 };
1207 double rpMax = p[0] * exp(p[1]*x) + p[2];
1209 rpMax = q[0]*x + q[1];
1232 const double cosZenith = (-shower.
GetDirection()).GetCosTheta(localCS);
1233 const double a2 =
Sqr(r / cosZenith);
1234 const double b2 =
Sqr(r);
1237 CoordinateSystem::RotationZ(
1242 const sdet::SDetector& sDet = det::Detector::GetInstance().GetSDetector();
1245 sIt != sDet.StationsEnd(); ++sIt) {
1247 const Point& tankPos = sIt->GetPosition();
1248 const int tankId = sIt->GetId();
1250 const double ellipseBound =
Sqr(tankPos.
GetX(ellipseCS)) / a2 +
1251 Sqr(tankPos.
GetY(ellipseCS)) / b2;
1255 if (ellipseBound <= 1) {
1262 sEvent.
GetStation(sIt->GetId()).GetSimData().SetIsInsideMinRadius();
1275 const rdet::RDetector& radioDet = det::Detector::GetInstance().GetRDetector();
1276 ostringstream odebug;
1280 long triedPulses = 0;
1290 odebug <<
"\n\tFor pulse: (" << loc.
GetX(coreSys) <<
", " << loc.
GetY(coreSys) <<
", " << loc.
GetZ(coreSys) <<
")";
1292 const int statID = FindClosestStationFromPoint(loc, radioDet, 5.);
1297 odebug <<
", no station could be associated.";
1300 odebug <<
", closest station id is " << statID;
1309 if (numpulses * 2 < triedPulses)
1315 info <<
"Could not successfully associate any stations out of the " << triedPulses
1316 <<
" stations in the event. Will now continue with the next event.";
1321 averageOffset *= 1. / numpulses;
1322 return averageOffset;
1329 double foundmindist = fMaximumDistance * maxDistanceFactor;
1332 const double dist = (rdIt->GetPosition() - pt).GetMag();
1333 if (dist < foundmindist) {
1334 stid = rdIt->GetId();
1335 foundmindist = dist;
Branch GetTopBranch() const
boost::transform_iterator< InternalStationFunctor, InternalStationIterator, const Station & > StationIterator
StationIterator returns a pointer to a station.
AxialVector Cross(const Vector &l, const Vector &r)
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
void SetCorePosition(const utl::Point &core)
Set the core position of the RadioSimulation using an utl::Point.
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...
constexpr T Sqr(const T &x)
bool HasStation(const int stationId) const
Check whether station exists.
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Detector description interface for Station-related data.
double GetMinRadiusCut() const
Get the minimum radius from shower axis for which there are valid particles in the shower...
void MakeSimData()
Make station simulated data object.
Base class for all exceptions used in the auger offline code.
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 and convert a point in geodetic coordinates.
StationIterator StationsEnd() const
End of the collection of pointers to commissioned stations.
CoordinateSystemPtr GetCoordinateSystem() const
Get the coordinate system of the current internal representation.
Data structure for simulated Radio pulses.
StationIterator StationsBegin() const
Beginning of the collection of pointers to commissioned stations.
bool HasSimShower() const
Data structure for a radio simulation (including several SimRadioPulses)
int GetZone() const
Get the zone.
void SetGroundParticleCoordinateSystemAzimuth(const double azimuth)
Set the azimuth angle of the shower. Angle in x-y plane wrt. to the x axis (0 is from east)...
#define INFO(message)
Macro for logging informational messages.
bool HasRadioSimulation() const
Check initialization of the RadioSimulation.
char GetBand() const
Get the band.
const utl::Point & GetSimCore(const int i) const
utl::Point GetLocation() const
void Init()
Initialise the registry.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
EyeIterator EyesBegin(const FDetComponentSelector::Type type=FDetComponentSelector::ePhysical) const
iterator pointing to first eye of given type (ePhysical, eVirtual, eAll)
Detector description interface for Eye-related data.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double GetNorthing() const
Get the northing.
void SetSimulatorSignature(const std::string &name)
Set name of the tank simulator module used to simulate this station.
Detector description interface for FDetector-related data.
A TimeStamp holds GPS second and nanosecond for some event.
Line Intersection(const Plane &p1, const Plane &p2)
Detector description interface for RDetector-related data.
utl::Point GetPosition() const
Tank position.
Interface class to access Shower Simulated parameters.
const char * Plural(const T n)
Branch GetNextSibling() const
Get next sibling of this branch.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
int GetShowerNumber() const
Get the number of the shower in the file.
Class representing a document branch.
boost::tuple< double, double, double > Triple
Coordinate triple for easy getting or setting of coordinates.
Reference ellipsoids for UTM transformations.
boost::filter_iterator< FDetComponentSelector, AllEyeIterator > EyeIterator
bool HasSimData() const
Check whether station simulated data exists.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
double GetHeight() const
Get the height.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
std::vector< int > StationIdCollection
utl::CoordinateSystemPtr GetEyeCoordinateSystem() const
Returns the Eye Coordinate system.
sdet::Station::StationIdCollection GetInfillCrown(const sdet::Station ¢ralStation)
RadioSimulation & GetRadioSimulation()
Get the radio simulation data.
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
get local coordinate system anchored at the core position
const utl::Point & GetPosition() const
Get the position of the shower core.
double GetEasting() const
Get the easting.
double GetEnergy() const
Get the energy of the shower primary particle.
void MakeStation(const int stationId)
make a station with specifying Id, throw if invalid stationId
const CoordinateSystemPtr GetECEF() const
Get the ECEF.
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
AxialVector Normalized(const AxialVector &v)
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
const SimRadioPulse & GetNextSimRadioPulse(bool &ok)
const utl::TimeStamp & GetEventTime() const
Get the event time of the RadioSimulation.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
size_t MyPow10(const size_t a)
void SetGroundParticleCoordinateSystemZenith(const double zenith)
Set the zenith angle of the shower. Room angle between z-axis and direction from where the shower is ...
std::string GetShowerRunId() const
Get the run id for the shower.
void MakeGeometry(const utl::Point &pointOnShowerAxis)
initialize the shower geometry. Pos is a point on the shower axis, but not necessarily the core ...
constexpr double kilometer
void SetMinRadiusCut(const double minR)
Set the minimum radius cut.
void MakeSimShower(const evt::VShowerGeometryProducer &p)
Detector description interface for SDetector-related data.
bool HasTimeStamp() const
Check initialization of the TimeStamp.
void MakeTimeStamp(const utl::TimeStamp &ts)
Make the TimeStamp of the shower.
sevt::StationSimData & GetSimData()
Get simulated data at station level.
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
Branch GetFirstChild() const
Get first child of this Branch.
double GetGroundParticleCoordinateSystemZenith() const
Get the zenith angle of the shower. Room angle between z-axis and direction from where the shower is ...
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
const Station & GetStation(const int stationId) const
Get station by Station Id.
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
int GetId() const
Station ID.
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.
double GetGroundParticleCoordinateSystemAzimuth() const
Get the azimuth angle of the shower. Angle in x-y plane wrt. to the x axis (0 is from east)...
EyeIterator EyesEnd(const FDetComponentSelector::Type type=FDetComponentSelector::ePhysical) const
iterator pointing to end of available eyes of given type (ePhysical, eVirtual, eAll) ...