3 #include <det/Detector.h>
5 #include <sdet/SDetector.h>
6 #include <sdet/Station.h>
9 #include <evt/ShowerSimData.h>
11 #include <fwk/CentralConfig.h>
12 #include <fwk/RunController.h>
14 #include <sevt/SEvent.h>
15 #include <sevt/Station.h>
16 #include <sevt/StationSimData.h>
17 #include <sevt/Header.h>
20 #include <utl/AugerCoordinateSystem.h>
21 #include <utl/AugerUnits.h>
22 #include <utl/MathConstants.h>
23 #include <utl/Particle.h>
24 #include <utl/PhysicalConstants.h>
25 #include <utl/Point.h>
26 #include <utl/TimeStamp.h>
27 #include <utl/TimeInterval.h>
28 #include <utl/ErrorLogger.h>
29 #include <utl/Vector.h>
30 #include <utl/Cache.h>
31 #include <utl/CoordinateSystemPtr.h>
40 using namespace SdAccidentalInjectorKG;
49 const Branch topBranch = CentralConfig::GetInstance()->
GetTopBranch(
"SdAccidentalInjector");
52 const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
63 fMaxDistance2 *= fMaxDistance2;
66 const auto nCosThetaColumns = bFlux.
GetChild(
"nCosThetaColumns").
Get<
unsigned int>();
67 const auto nLog10EGeVRows = bFlux.
GetChild(
"nLog10EGeVRows").
Get<
unsigned int>();
68 const auto rangeCosTheta = bFlux.
GetChild(
"rangeCosTheta").
Get<vector<double>>();
69 const auto rangeLog10EGeV = bFlux.
GetChild(
"rangeLog10EGeV").
Get<vector<double>>();
70 const auto table = bFlux.
GetChild(
"table").
Get<vector<double>>();
72 const double minimumEnergy = topBranch.
GetChild(
"minimumEnergy").
Get<
double>();
73 const double lgEmin = log10(minimumEnergy /
GeV);
74 const int iemin =
max(0., floor((lgEmin - rangeLog10EGeV.at(0)) / (rangeLog10EGeV.at(1) - rangeLog10EGeV.at(0)) * nLog10EGeVRows));
75 if (iemin >=
int(nLog10EGeVRows)) {
76 ERROR(
"minimumEnergy cuts the whole histogram away!");
79 const double lgEminEdge = rangeLog10EGeV[0] + iemin * (rangeLog10EGeV[1] - rangeLog10EGeV[0]) / nLog10EGeVRows;
82 TH2D h(
"SdAccidentalInjector::fHist",
"",
83 nLog10EGeVRows - iemin, lgEminEdge, rangeLog10EGeV[1],
84 nCosThetaColumns, rangeCosTheta.at(0), rangeCosTheta.at(1));
91 for (
unsigned int ie = 1; ie <= nLog10EGeVRows; ++ie) {
93 for (
unsigned int ic = 1; ic <= nCosThetaColumns; ++ic) {
94 const double cosTh = h.GetYaxis()->GetBinCenter(ic);
95 const double area =
StationArea(radius, height, cosTh);
96 const double flux = table.at(i++);
98 h.SetBinContent(ie - iemin, ic, flux * area);
105 msg <<
"Configuration:\n"
106 "Muon rate per station [Hz] : " << fMuonRatePerStation/(1./
s) <<
"\n"
107 "Minimum energy [GeV] : " << minimumEnergy/
GeV <<
"\n"
108 "Start injection [ns, rel. to core time]: " << -fTimeBefore/
ns <<
"\n"
109 "Stop injection [ns, rel. to core time]: " << fTimeAfter/
ns;
120 ERROR(
"Current event does not have a simulated shower.");
124 const Point& core =
event.GetSimShower().GetPosition();
127 const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
130 msg <<
"Injecting accidental muons:";
137 if ((dStation.
GetPosition() - core).GetMag2() > fMaxDistance2)
140 const int nMuons = fPoisson(fMuonRatePerStation * (fTimeAfter + fTimeBefore));
155 "station " << dStation.
GetId() <<
" gets " << nMuons <<
" muon" << (nMuons == 1 ?
"" :
"s") <<
':';
157 for (
int iMu = 0; iMu < nMuons; ++iMu) {
159 const auto ec = fHist();
160 const double energy =
pow(10, ec.first) *
GeV;
161 const double theta = acos(ec.second);
162 const double phi = fFlat(2 *
kPi);
165 const Vector pMomentum(-totalMomentum, theta, phi, dStationCS, Vector::kSpherical);
166 const TimeInterval pTime = fFlat(-fTimeBefore, fTimeAfter);
168 const tuple<double, double, double> xyz = fCyl(theta, phi);
169 const Point pPosition(get<0>(xyz), get<1>(xyz), get<2>(xyz), dStationCS);
176 " energy = " << (energy/
GeV) <<
" GeV, "
177 "theta = " << theta/
degree <<
" deg, "
187 "Total number of accidental muons: " << nTotal;
Branch GetTopBranch() const
double StationArea(const double radius, const double height, const double cosTheta)
bool HasStation(const int stationId) const
Check whether station exists.
Detector description interface for Station-related data.
void MakeSimData()
Make station simulated data object.
Interface class to access to the SD part of an event.
Describes a particle for Simulation.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
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)
utl::Point GetPosition() const
Tank position.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
class to hold data at Station level
bool HasSimData() const
Check whether station simulated data exists.
constexpr double nanosecond
StationIterator StationsEnd() const
End of the collection of pointers to commissioned stations.
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the tank.
double GetRadius() const
Radius of the tank (water only)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
double GetHeight() const
Height of the tank (water only)
StationIterator StationsBegin() const
Beginning of the collection of pointers to commissioned stations.
void MakeStation(const int stationId)
make a station with specifying Id, throw if invalid stationId
void AddParticle(const utl::Particle &particle)
void GetData(bool &b) const
Overloads of the GetData member template function.
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
double GetInterval() const
Get the time interval as a double (in Auger base units)
constexpr double kMuonMass
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
double GetThickness() const
Thickness of the tank walls.
struct particle_info particle[80]
Detector description interface for SDetector-related data.
int GetId() const
Station ID.
#define ERROR(message)
Macro for logging error messages.