1 #include <utl/config.h>
8 #include <fwk/CentralConfig.h>
9 #include <fwk/CoordinateSystemRegistry.h>
10 #include <fwk/RandomEngineRegistry.h>
12 #include <evt/Event.h>
13 #include <evt/ShowerSimData.h>
15 #include <mevt/MEvent.h>
16 #include <mevt/Counter.h>
17 #include <mevt/CounterSimData.h>
19 #include <det/Detector.h>
20 #include <mdet/MDetector.h>
21 #include <mdet/Counter.h>
23 #include <sevt/SEvent.h>
24 #include <sevt/Station.h>
25 #include <sevt/StationSimData.h>
27 #include <utl/ConfigUtils.h>
28 #include <utl/ErrorLogger.h>
29 #include <utl/GeometryUtilities.h>
30 #include <utl/MathConstants.h>
31 #include <utl/Particle.h>
32 #include <utl/ParticleCases.h>
33 #include <utl/PhysicalConstants.h>
34 #include <utl/Point.h>
35 #include <utl/RandomEngine.h>
36 #include <utl/TimeStamp.h>
38 #include <utl/Reader.h>
39 #include <utl/TabularStream.h>
40 #include <utl/TabulatedFunction.h>
44 #include <CLHEP/Random/RandFlat.h>
45 #include <CLHEP/Random/RandPoisson.h>
46 #include <CLHEP/Random/RandGauss.h>
50 using namespace MdShowerRegeneratorAG;
57 using CLHEP::RandFlat;
58 using CLHEP::RandPoisson;
61 #define MD_THETASIM_MAX 80*utl::degree
62 #define MD_SIM_AREA 30*utl::m2
63 #define MD_LARGE_SIDE 12*utl::m
65 namespace MdShowerRegeneratorAG {
82 const Point& position)
92 fOuterRadiusCut(1.e6*
km),
93 fElectronEnergyCut(0),
100 fHorizontalParticleCut(0),
116 CentralConfig::GetInstance()->
GetTopBranch(
"MdShowerRegenerator");
119 useAtt[
"use"] = string(
"yes");
143 if (topB.
GetChild(
"MuonWeightScale"))
146 fRandomEngine = &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector).GetEngine();
158 bool retrad =
IsRIn( r );
160 bool isin = retphi && retrad;
216 {
return fR1 <= r && r <=
fR2; }
220 const double pEnergy)
255 INFO(
"Performing Unthinning...");
258 ERROR(
"Current event does not have a simulated shower.");
264 ERROR(
"Current event does not have a simulated shower with particles.");
267 INFO(
"Retrieving ground particles from shower");
278 const mdet::MDetector& mDetector = det::Detector::GetInstance().GetMDetector();
283 MEvent& mEvent =
event.GetMEvent();
286 WARNING(
"SEvent found. InnerRadiusCut from MdShowerRegenerator.xml meaningless!");
308 const double showerZenith = (-simShower.
GetDirection()).GetTheta(localCS);
315 const int mId = cIt->GetId();
330 bool sd_exists =
false;
333 int partnerId = cIt->GetAssociatedTankId();
340 INFO(
"Associated Sd-Tank was flagged InsideMinRadiusCut. Forcing the same for Md-Counter.");
348 const Point& countPos = cIt->GetPosition();
349 double cR = countPos.
GetRho(showerCS);
376 const int mId = cIt->GetId();
386 const Point& countPos = cIt->GetPosition();
389 double cR = countPos.
GetRho(showerCS);
394 double r = partPos.
GetRho(showerCS);
395 double phi = partPos.
GetPhi(showerCS);
400 if( !
IsIn(phi, r, stat) )
404 const double pWeight =
425 const double cDepth = cIt->ModulesBegin()->GetDepth();
429 const double pCosine = -1.*pDirection.
GetZ(grParticleCS);
455 const double samplingArea = samplingAreaFactor *
Sqr(cR);
456 const double pWeightDensity = pWeight / samplingArea;
459 const double avgN = pWeightDensity * effArea;
475 for (
unsigned int i = 0; i < n; ++i) {
479 const double r = (RadiusCounter+ExtraRadius) *
sqrt( RandFlat::shoot(
fRandomEngine, 0, 1) );
483 const Point pNewPosition(r, phi, 0, localCS, Point::kCylindrical);
487 const Vector pNewDirection( pDirection.
GetR(grParticleCS), pDirection.
GetTheta(grParticleCS), pDirection.
GetPhi(grParticleCS), grParticleCS, Vector::kSpherical );
491 double pShiftedTime = pTime +
PlaneFrontTime(showerCS, partPos, pNewPosition);
492 newParticle.
SetTime(pShiftedTime);
507 std::cout <<
"Total number of muons in the shower " <<
fNMuons << std::endl;
508 std::cout <<
"Total number of muons injected for ground prop " <<
fNInjected << std::endl;
509 std::cout <<
"IsIn " << stat.
IsIn << std::endl;
510 std::cout <<
"InDeltaR " << stat.
InRad << std::endl;
511 std::cout <<
"InDeltaPhi " << stat.
InPhi << std::endl;
void SetTime(const TimeInterval &time)
Branch GetTopBranch() const
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
Iterator to retrieve particles from utl::VShowerParticlList.
Station Level Simulated Data
double fHorizontalParticleCut
VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
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
utl::ShowerParticleIterator GroundParticlesEnd() const
const TimeInterval & GetTime() const
Arrival time delay at the ground.
Report success to RunController.
double GetMinRadiusCut() const
Get the minimum radius from shower axis for which there are valid particles in the shower...
bool IsInsideMinRadius() const
Check whether the station is in the shower hole.
void SetPosition(const utl::Point &position)
Counter level event data.
CounterConstIterator CountersEnd() const
End iterator over the counters.
double GetR(const CoordinateSystemPtr &coordinateSystem) const
radius r in spherical coordinates coordinates (distance to origin)
Interface class to access to the SD part of an event.
Describes a particle for Simulation.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
void SetDirection(const utl::Vector &direction)
bool HasGroundParticles() const
bool HasSimShower() const
std::map< std::string, std::string > AttributeMap
bool IsParticleEnergyLow(const int, const double) const
#define INFO(message)
Macro for logging informational messages.
double PlaneFrontTime(const CoordinateSystemPtr showerCS, const Point &corePosition, const Point &position)
Calculate time of arrival of the plan front at point x.
bool HasCounter(const int cId) const
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Detector associated to muon detector hierarchy.
bool IsInsideMinRadius() const
Interface class to access Shower Simulated parameters.
double fElectronEnergyCut
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.
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
bool IsIn(double phi, double r, InStats &)
void SetWeight(const double weight)
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
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)
void SetIsInsideMinRadius(const bool isIn=true)
double GetRho(const CoordinateSystemPtr &coordinateSystem) const
radius r in cylindrical coordinates (distance to z axis)
CounterGroup::ConstIterator CounterConstIterator
Defines a more meaningful (and shorter) type for iterators.
Counter level simulation data.
double GetKineticEnergy() const
Get kinetic energy of the particle.
void AddGrdParticle(const utl::Particle &particle)
constexpr double kSpeedOfLight
ResultFlag
Flag returned by module methods to the RunController.
double GetWeight() const
Particle weight (assigned by shower generator thinning algorithms)
void SetRadRange(double r1, double r2)
void SetMinRadiusCut(const double minR)
Set the minimum radius cut.
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
const Point & GetPosition() const
Position of the particle.
Report failure to RunController, causing RunController to terminate execution.
#define OFFLINE_ELECTRONS
void MakeCounter(const int cId)
sevt::StationSimData & GetSimData()
Get simulated data at station level.
Counter & GetCounter(const int cId)
void SetParent(Particle &parent)
CounterConstIterator CountersBegin() const
Begin iterator over the counters.
void SetPhiRange(double phi, double dphi)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
CounterSimData & GetSimData()
#define ERROR(message)
Macro for logging error messages.
const Vector & GetDirection() const
Unit vector giving particle direction.
utl::ShowerParticleIterator GroundParticlesBegin() const
Root of the Muon event hierarchy.
VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
utl::RandomEngine::RandomEngineType * fRandomEngine
utl::CoordinateSystemPtr GetShowerCoordinateSystem() const