8 #include <det/Detector.h>
9 #include <sdet/SDetector.h>
10 #include <sdet/Station.h>
11 #include <cdet/CDetector.h>
13 #include <evt/Event.h>
14 #include <evt/ShowerSimData.h>
16 #include <fwk/CentralConfig.h>
17 #include <fwk/RunController.h>
18 #include <fwk/LocalCoordinateSystem.h>
19 #include <fwk/CoordinateSystemRegistry.h>
20 #include <fwk/RandomEngineRegistry.h>
22 #include <cevt/CEvent.h>
24 #include <utl/config.h>
25 #include <utl/Trace.h>
26 #include <utl/AugerUnits.h>
28 #include <utl/MathConstants.h>
29 #include <utl/PhysicalConstants.h>
30 #include <utl/TimeStamp.h>
31 #include <utl/TabulatedFunction.h>
32 #include <utl/ErrorLogger.h>
33 #include <utl/Particle.h>
34 #include <utl/AugerCoordinateSystem.h>
35 #include <utl/UTMPoint.h>
36 #include <utl/MultiTimeDistribution.h>
37 #include <utl/GeometryUtilities.h>
39 #include <CLHEP/Random/RandGauss.h>
49 using namespace RPCSimulatorLX;
56 using CLHEP::RandGauss;
62 delete fChargeProfileHisto;
63 delete fChargeGenerator;
69 INFO(
"RPCSimulator::Init()");
76 fUseRootHistos =
true;
77 rootB.
GetData(fRootHistoFilename);
78 fChargeHisto =
new TH1D(
"chargeDist",
"charge distribution", 200, 0, 100);
79 fChargeProfileHisto =
new TProfile(
"AverageChargeVsAngle",
"Average charge vs angle of incidence at RPC", 90, 0, 90);
84 fUseChargeDistribution =
true;
85 const double k0 = chargeB.
GetChild(
"k_param").
Get<
double>();
86 const double th0 = chargeB.
GetChild(
"th_param").
Get<
double>();
87 const double referenceAngle = chargeB.
GetChild(
"ref_angle").
Get<
double>();
90 WARNING(
"PDF for charge generation in the RPC switched off! "
91 "A fixed charge of 3.1415 pC will be set for each particle crossing the gas!");
94 fRandomEngine = &RandomEngineRegistry::GetInstance().Get(RandomEngineRegistry::eDetector);
103 INFO(
"RPCSimulator::Finish()");
105 if (fUseRootHistos) {
106 TFile outFile(fRootHistoFilename.c_str(),
"RECREATE");
108 fChargeHisto->Write();
109 fChargeProfileHisto->Write();
114 delete fChargeProfileHisto;
116 fChargeHisto =
nullptr;
117 fChargeProfileHisto =
nullptr;
120 delete fChargeGenerator;
121 fChargeGenerator =
nullptr;
130 INFO(
"RPCSimulator::Run()");
133 ERROR(
"RPCSimulator::No CEvent!");
137 const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
138 const cdet::CDetector& cDetector = det::Detector::GetInstance().GetCDetector();
140 CEvent &cEvent =
event.GetCEvent();
147 cout <<
"No sim data for station " << station.
GetId() <<
" !!!!";
178 const unsigned padId = dStation.
GetPadId(partPosition);
185 if (!station.
HasPad(padId))
200 particleDist1.
AddTime(particleTime);
228 particleDist2.
AddTime(particleTime);
231 const double theta = partMomentum.
GetTheta(cs);
236 const double charge = fUseChargeDistribution ? fChargeGenerator->GetCharge(theta) :
kPi*pC;
238 if (fUseRootHistos) {
239 fChargeHisto->Fill(charge / pC);
240 fChargeProfileHisto->Fill(theta /
deg, charge / pC);
243 const double time = particleTime;
251 chargeDist1.
AddTime(time, charge);
277 chargeDist2.
AddTime(time, charge);
Branch GetTopBranch() const
bool HasChargeTimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if Pad signal already exists (optionally for a given source)
boost::indirect_iterator< InternalParticleIterator, utl::Particle & > ParticleIterator
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
const TimeInterval & GetTime() const
Arrival time delay at the ground.
Station Level Simulated Data
Detector description interface for CDetector-related data.
bool HasSimData() const
Check whether station simulated data exists.
Pad & GetPad(const unsigned int padId)
Retrive a Pad by Id.
unsigned int GetPadId(const utl::Point &position) const
StationIterator StationsEnd()
End of all stations.
Describes a particle for Simulation.
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
utl::TimeDistributionD & GetChargeTimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Get simulated signal at the Pad base, optionally for a given source.
std::map< std::string, std::string > AttributeMap
Histogram class for time distributions with suppressed empty bins.
#define INFO(message)
Macro for logging informational messages.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Class to hold simulated data at Pad level.
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Detector description interface for MARTA Station-related data.
class to hold data at Pad level
utl::TimeDistributionI & GetParticleTimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Simulated particle time distribution.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
bool HasPad(const unsigned int padId) const
Check if a particular Pad object exists.
int GetId() const
Get the station Id.
bool HasParticleTimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a Particle release time distribution exists (optionally for a given source) ...
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
const Station & GetStation(const int stationId) const
Get station by Station Id.
double GetInterval() const
Get the time interval as a double (in Auger base units)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
void MakeSimData()
Make Pad simulated data object.
class to hold data at Station level
ResultFlag
Flag returned by module methods to the RunController.
double GetWeight() const
Particle weight (assigned by shower generator thinning algorithms)
ParticleIterator ParticlesBegin()
Beginning of simulated particles entering the station.
StationIterator StationsBegin()
Beginning of all stations.
Detector description interface for SDetector-related data.
const Point & GetPosition() const
Position of the particle.
PadSimData & GetSimData()
Get object containing Pad simulated data.
void MakeParticleTimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a Particle release time distribution (optionally for given source)
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
void MakePad(const unsigned int padId)
Make a Pad by Id.
const Station & GetStation(const int stationId) const
Get station by Station Id.
#define ERROR(message)
Macro for logging error messages.
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.
ParticleIterator ParticlesEnd()
End of simulated particles entering the station.
StationSimData & GetSimData()
Get simulated data at station level.
void MakeChargeTimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a TimeDistributionD representing signal at Pad (optionally for a give source) ...
Interface class to access to the SD part of an event.
bool HasSimData() const
Check for existence of Pad simulated data object.