11 #include <fwk/CentralConfig.h>
12 #include <fwk/RandomEngineRegistry.h>
14 #include <det/Detector.h>
16 #include <evt/Event.h>
18 #include <sdet/SDetector.h>
19 #include <sdet/Station.h>
22 #include <sevt/PMTSimData.h>
23 #include <sevt/SEvent.h>
24 #include <sevt/Station.h>
25 #include <sevt/StationSimData.h>
27 #include <utl/AugerUnits.h>
28 #include <utl/ErrorLogger.h>
29 #include <utl/Particle.h>
30 #include <utl/PhysicalConstants.h>
31 #include <utl/Point.h>
32 #include <utl/RandomEngine.h>
33 #include <utl/TimeDistribution.h>
35 #include <utl/Reader.h>
37 #include <CLHEP/Random/RandFlat.h>
38 #include <CLHEP/Random/RandPoisson.h>
40 using namespace FastTankSimulatorOG;
50 using CLHEP::RandFlat;
51 using CLHEP::RandPoisson;
70 CentralConfig::GetInstance()->
GetTopBranch(
"FastTankSimulator");
81 vector<double> photonInteractionLength;
82 topBranch.
GetChild(
"PhotonInteractionLength").
GetData(photonInteractionLength);
83 vector<double> pairProductionProbability;
84 topBranch.
GetChild(
"PairProductionProbability").
GetData(pairProductionProbability);
85 vector<double> energyTable;
93 fRandomEngine = &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector);
103 ERROR(
"Non-existent SEvent.");
110 det::Detector::GetInstance().GetSDetector();
115 if (sIt->HasSimData()) {
129 const unsigned long numParticles =
139 if (!nParticlesAlreadySimulated)
145 pIt != sIt->GetSimData().ParticlesEnd(); ++pIt) {
185 boost::tie(x, y, z) = particle.
GetPosition().GetCoordinates(cs);
187 boost::tie(pX, pY, pZ) = particle.
GetDirection().GetCoordinates(cs);
190 const double b = x*pX + y*pY;
191 const double b2 =
Sqr(b);
193 const double ac = a*
c;
196 const double vertDistance = (pZ < 0) ? -z/pZ : (
fTankHeight - z)/pZ;
200 const double horizDistance = (b2 >= ac) ? (-b +
sqrt(b2 - ac))/a : 0;
201 return min(vertDistance, horizDistance);
210 const double energyLoss)
235 const double energyDifference = energy - energyLoss;
237 if (energyDifference > 0)
238 return ratio*energyDifference *
240 log((energy/energyLoss) *
241 (energyLoss + 2*mass)/(energy + 2*mass)));
249 const double cerenkovRate)
254 if (!pmtIt->HasSimData())
255 pmtIt->MakeSimData();
259 const unsigned int numberPhotoElectrons =
262 for (
unsigned int countPE = 0; countPE < numberPhotoElectrons; ++countPE) {
267 const double randNum =
280 pmtIt->GetSimData().GetPETimeDistribution().AddTime(time);
321 const double energyLoss =
339 const double energyLoss =
382 const double interactionLength =
386 const double pathLength =
392 if (pathLength < distanceInTank) {
412 const double productionProbability =
416 if (randNum < productionProbability)
449 const double kineticEnergy =
452 newElectron.SetKineticEnergy(kineticEnergy);
453 newPositron.SetKineticEnergy(maxKineticEnergy - kineticEnergy);
469 const double b = energyMin/energy + energy/energyMin;
478 a = energyFinal/energy + energy/energyFinal;
483 const double cosTheta = 1 +
kElectronMass * (1/energy - 1/energyFinal);
484 const double sinTheta =
sqrt(1 -
Sqr(cosTheta));
488 const double cosPhi = cos(phi);
489 const double sinPhi = sin(phi);
498 boost::tie(pX, pY, pZ) = dir.GetCoordinates(cs);
500 const double uR = dir.
GetRho(cs);
523 const Vector u = cosTheta * dir +
524 sinTheta *
Vector(cosPhi*vX+sinPhi*wX, cosPhi*vY+sinPhi*wY, sinPhi*wZ, cs);
526 Vector v = energy * dir - energyFinal * u;
542 const double electronEnergy = energy - energyFinal;
Branch GetTopBranch() const
unsigned int GetNPoints() const
Station Level Simulated Data
StationIterator StationsEnd()
End of all stations.
constexpr T Sqr(const T &x)
const TimeInterval & GetTime() const
Arrival time delay at the ground.
Report success to RunController.
total (shower and background)
constexpr double kElectronMass
RandomEngineType & GetEngine()
void CalculatePhotoElectrons(const utl::Particle &p, const double)
Interface class to access to the SD part of an event.
utl::RandomEngine * fRandomEngine
Describes a particle for Simulation.
PMTIterator PMTsBegin(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
begin PMT iterator for read/write
Class to hold collection (x,y) points and provide interpolation between them.
void SimulatePhotons(const utl::Particle &p)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
boost::filter_iterator< PMTFilter, InternalPMTIterator > PMTIterator
Iterator over station for read/write.
void SetSimulatorSignature(const std::string &name)
Set name of the tank simulator module used to simulate this station.
bool HasPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a PE release time distribution exists (optionally for a given source)
void SimulateComptonScattering(const utl::Particle &p)
ParticleVector::iterator ParticleIterator
VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
electrons and positrons from shower
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
void SimulatePairProduction(const utl::Particle &p)
Class representing a document branch.
double fPhotoElectronRate
void SimulateElectrons(const utl::Particle &p)
VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the tank.
double GetRadius() const
Radius of the tank (water only)
double GetHeight() const
Height of the tank (water only)
PMTIterator PMTsEnd(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
end PMT iterator for read/write
sevt::Station * fCurrentEventStation
void GetData(bool &b) const
Overloads of the GetData member template function.
const double & GetY(const unsigned int idx) const
double GetInterval() const
Get the time interval as a double (in Auger base units)
double GetRho(const CoordinateSystemPtr &coordinateSystem) const
radius r in cylindrical coordinates (distance to z axis)
ParticleIterator ParticlesBegin()
Beginning of simulated particles entering the station.
double CalculateDistanceInTank(const utl::Particle &p)
double GetKineticEnergy() const
Get kinetic energy of the particle.
VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
void SimulateMuons(const utl::Particle &p)
constexpr double kMuonMass
constexpr double kSpeedOfLight
const sdet::Station * fCurrentDetectorStation
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
double GetWeight() const
Particle weight (assigned by shower generator thinning algorithms)
unsigned int GetTotalSimParticleCount() const
Get the total number of particles that were actually simulated (after thinning)
utl::Particle fInitialParticle
void SetTotalSimParticleCount(const unsigned int n)
StationIterator StationsBegin()
Beginning of all stations.
Source GetSource() const
Source of the particle (eg. shower or background)
Class to hold simulated data at PMT level.
struct particle_info particle[80]
const double & GetX(const unsigned int idx) const
double GetRho2(const CoordinateSystemPtr &coordinateSystem) const
radius r^2 in cylindrical coordinates (distance to z axis)^2
Detector description interface for SDetector-related data.
const Point & GetPosition() const
Position of the particle.
Report failure to RunController, causing RunController to terminate execution.
double fTankRadiusSquared
double CalculateIntegratedCerenkovRate(const utl::Particle &p, const double)
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
utl::TabulatedFunction fPairProductionProbability
utl::TimeDistributionI & GetPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Simulated photoelectron time distribution.
const Station & GetStation(const int stationId) const
Get station by Station Id.
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
double fCerenkovMinElectron
utl::TabulatedFunction fPhotonInteractionLength
#define ERROR(message)
Macro for logging error messages.
ParticleIterator ParticlesEnd()
End of simulated particles entering the station.
const Vector & GetDirection() const
Unit vector giving particle direction.
void AddTime(const double time, const T weight=T(1))
Add an entry (optionally weighted) for the given time. Slot will be computed.
std::vector< double > fPECumulativeProbability
sevt::SEvent & GetSEvent()
mu+ and mu- (including signal from mu decay electrons) from shower
void MakePETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a PE release time distribution (optionally for given source)