Shower unthinning. More...
#include <CachedShowerRegenerator.h>
Public Types | |
enum | ResultFlag { eSuccess, eFailure, eBreakLoop, eContinueLoop } |
Flag returned by module methods to the RunController. More... | |
enum | VersionInfoType { eFilename = 1, eRevisionNumber = 2, eDate = 3, eTime = 4, eLastEditor = 5 } |
Different types of version info that can be retrieved from GetVersionInfo. More... | |
Public Member Functions | |
CachedShowerRegenerator () | |
VModule::ResultFlag | Finish () |
Finish: invoked at end of the run (NOT end of the event) More... | |
utl::Stopwatch & | GetStopwatch () |
const utl::Stopwatch & | GetStopwatch () const |
std::string | GetVersionInfo (const VersionInfoType v) const |
Retrieve different sorts of module version info. More... | |
VModule::ResultFlag | Init () |
Initialize: invoked at beginning of run (NOT beginning of event) More... | |
void | InitTiming () |
VModule::ResultFlag | Run (evt::Event &event) |
Run: invoked once per event. More... | |
ResultFlag | RunWithTiming (evt::Event &event) |
Static Public Member Functions | |
static std::string | GetResultFlagByName (const ResultFlag flag) |
Protected Types | |
enum | InfoLevel { eInfoNone = 0, eInfoFinal = 1, eInfoIntermediate = 2, eInfoDebug = 3 } |
Protected Attributes | |
int | fInfoLevel = 0 |
Private Member Functions | |
void | InitNewShower (evt::Event &event) |
bool | IsParticleEnergyLow (const int type, const double energy) const |
void | OutputStats (evt::Event &event) |
REGISTER_MODULE ("CachedShowerRegeneratorOG", CachedShowerRegenerator) | |
Private Attributes | |
double | fDeltaPhi = 0 |
double | fDeltaROverR = 0 |
double | fElectronEnergyCut = 0 |
double | fHadronEnergyCut = 0 |
double | fHorizontalParticleCut = 0 |
double | fInnerRadiusCut = 0 |
bool | fLimitParticlesPerCycle = false |
double | fLogGaussSmearingWidth = 0 |
double | fMARTARadius = 0 |
double | fMesonEnergyCut = 0 |
double | fMuonEnergyCut = 0 |
double | fMuonWeightScale = 1 |
double | fOuterRadiusCut = 1e6*utl::km |
unsigned int | fParticlesPerCycle = 0 |
double | fPhiGranularity = 0 |
double | fPhotonEnergyCut = 0 |
utl::RandomEngine::RandomEngineType * | fRandomEngine = nullptr |
double | fRGranularity = 0 |
utl::ShadowPtr< ShowerData > | fShowerData |
bool | fSimulateMARTA = false |
bool | fSimulateUMD = false |
double | fUMDMaxRadius = 0 |
double | fUMDTightRadius = 0 |
bool | fUseStationPositionMatrix = true |
bool | fUseWeightDependentResamplingArea = true |
bool | fUseWeightedStationSimulation = false |
unsigned int | fWeightedStationSimulationParticleLimit = 0 |
double | fWeightedStationSimulationThinningFactor = 0.5 |
Shower unthinning.
This modules takes weighted particles from a shower simulation programs, regenerates particles with unity weight, and injects particles them in to stations for simulation. The algorithm is based on the technique described in GAP-2000-025.
In order to avoide excessive memory consumption in cases where the shower core is very close to a tank, this module supports a limit on the maximum number of particles which can be simulated in one pass (described in more detail below).
There are a number of things you can control from the configuration file:
Analysis applications using the offline framework are usually set up as a sequence of modules, in which each physics module does some job, then passes control to the next module in the sequence. The most simple-minded way to simulate the detector response to a simulated shower using this approach would be to use a sequence fragment something like this:
<module> EventFileReader </module> <!-- read sim shower --> <module> EventGenerator </module> <!-- situate shower somewhere on array --> <module> ShowerRegenerator </module> <!-- unthin shower and inject particles in tanks --> <module> TankSimulator </module> <!-- simulate each tank in event--> <!-- other simulation modules -->
In the third step in this sequence, the ShowerRegenerator has to loop through all particles in the shower and all the candidate stations, and must fill the sevt::StationSimData object of each sevt::Station with a list of all the particles that need to be simulated for that sevt::Station. A problem can sometimes occur for cases in which the shower core lands near a station, since the huge numbers of particles injected into this station may consume a lot of memory, and in some cases may cause the program to crash.
This problem can usually be solved in by stepping through the shower regenerator and tank simulator modules several times and limiting the number of particles simulated in each pass. This works since the tank response is "linear": injecting 2 particles into a tank and simulating them yields the same result as injecting and simulating the first particle, then injecting and simulating the second. In this approach, the modules sequence fragment looks like:
<module> EventFileReader </module> <module> EventGenerator </module> <loop numTimes="unbounded" save="no"> <module> CachedShowerRegenerator </module> <module> TankSimulator </module> </loop> <!-- other simulation modules -->
The CachedShowerRegenerator (renamed to distinguish it from the ShowerRegenerator in the previous sequence example) then unthins and injects a limited number of particles before passing control to the TankSimulator. When the TankSimulator is done, it returns control to the CachedShowerRegenerator, which picks up where it left off in the list of shower particles. When CachedShowerRegenerator reaches the end of the shower particles, it throws a fwk::VModule::eBreakLoop instruction to the fwk::RunController, which ends the regeneration/tank simulation step. Note that the save="no"
attribute in the <loop>
tag ensures that the CachedShowerRegenerator receives the event in the state in which it was left by the previous pass through the TankSimulator.
The limit on the number of particles processed in one pass through the loop is set using the <LimitParticlesPerCycle>
element. For example:
<LimitParticlesPerCycle use="yes"> 100000 </LimitParticlesPerCycle>
will limit the memory footprint to about 300 Mb. Note that this limit is enabled by setting the use
attribute to "yes"
and disabled by setting it to "no"
. If use="no"
, there will be no limit on the number of particles simulated in one cycle, and consequently there will be just one pass through the loop.
This method has some shortcomings. It is important to note that the limits on particles per cycle is a limit on weithted particles, not on particles which have been assigned unity-weight by the regeneration algorithm. In fact, it can sometimes happen that particles with extremely high weights can defeat the protections normally afforded by this method. It can also sometimes happen that showers contain particles with trajectories nearly parallel to the ground plane, in which case the resampling algorithm will project an essentially infinite shadow of the side wall of the tank, and thereby generate a vast number of particles. Since the method of limiting particles per cycle only applies a limit before resampling, such cases may cause the program to run for a long time, or to crash.
The CachedShowerRegenerator config file contains an element :
<NumberOfRegenerationsLimit> 100000000 </NumberOfRegenerationsLimit>
(or similar) which you can set to cause the CachedShowerRegenerator to issues a warning if a particle is regenerated to produce more than the number of particles specified in the element.
If necessary, you can tell the CachedShowerRegenerator to disregard particles that fall inside a minimum radial distance to the shower axis, or outside a maximum radial distance to the shower axis. For example,
<DistanceCuts> <InnerRadiusCut unit="m" use="yes"> 250.0 </InnerRadiusCut> <OuterRadiusCut unit="km" use="yes"> 100.0 </OuterRadiusCut> </DistanceCuts>
will cause the CachedShowerRegenerator to only consider particles between 250 m and 100 km from the shower axis. You can switch off the cuts entirely by setting the use="no"
attribute in the appropriate tag.
Note that even if you switch off these cuts, there may still be some minimum and maximum radii cuts imposed by the generator-level shower simulation program (eg. Aires, Corsika). Information on generator-level radii cuts can be extracted from evt::ShowerSimData::GetMinRadiusCut() and evt::ShowerSimData::GetMaxRadiusCut(). Furthermore, the EventGeneratorOG::EventGenerator module identifies any sevt::Station which falls inside the minimum radius cut (projected onto the ground) by setting sevt::StationSimData::IsInsideMinRadius() to true.
Particles with energies below a minimum value can be removed from the shower by setting cuts the EnergyCuts
element. For example:
<EnergyCuts> <ElectronEnergyCut unit="MeV"> 1.0 </ElectronEnergyCut> <MuonEnergyCut unit="MeV"> 10.0 </MuonEnergyCut> <PhotonEnergyCut unit="MeV"> 1.0 </PhotonEnergyCut> <HadronEnergyCut unit="MeV"> 10.0 </HadronEnergyCut> <MesonEnergyCut unit="MeV"> 10.0 </MesonEnergyCut> </EnergyCuts>
The size of the sampling region is set in the AlgorithmParameters
element. Here is an example:
<AlgorithmParameters> <DeltaROverR> 0.1 </DeltaOverR> <!-- dimensionless (dR/R) --> <DeltaPhi unit="radian"> 0.15 </DeltaPhi> </AlgorithmParameters>
See Figure 1 of GAP-2000-025 for a definition of the sampling region in terms of these AlgorithmParameters
.
Definition at line 81 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
protectedinherited |
|
inherited |
Flag returned by module methods to the RunController.
Enumerator | |
---|---|
eSuccess |
Report success to RunController. |
eFailure |
Report failure to RunController, causing RunController to terminate execution. |
eBreakLoop |
Break current loop. It works for nested loops too! |
eContinueLoop |
Skip remaining modules in the current loop and continue with next iteration of the loop. |
|
inherited |
|
inline |
Definition at line 83 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
inlinevirtual |
Finish: invoked at end of the run (NOT end of the event)
This method is for things that should be done at the end of the run (for example, closing files or writing out histograms) {You must override this method in your concrete module}
Implements fwk::VModule.
Definition at line 87 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
References fwk::VModule::eSuccess.
|
staticinherited |
Definition at line 8 of file VModule.cc.
References fwk::VModule::eBreakLoop, fwk::VModule::eContinueLoop, fwk::VModule::eFailure, and fwk::VModule::eSuccess.
Referenced by fwk::RunController::DoNextInSequence(), fwk::RunController::FinishBranch(), and fwk::RunController::InitBranch().
|
inlineinherited |
Definition at line 106 of file VModule.h.
References fwk::VModule::fStopwatch.
|
inlineinherited |
Definition at line 107 of file VModule.h.
References fwk::VModule::fStopwatch.
|
inherited |
Retrieve different sorts of module version info.
Definition at line 26 of file VModule.cc.
Referenced by fwk::CentralConfig::GetConfig(), ThresholdCalculatorKG::ThresholdCalculator::Init(), fdDoubleBumpFinder::FdDoubleBumpFinder::Init(), LaserGeneratorNA::LaserGenerator::Init(), LaserLightSimulatorNA::LaserLightSimulator::Init(), FdElectronicsSimulatorOG::FdElectronicsSimulator::Init(), TelescopeSimulatorKG::TelescopeSimulator::Init(), TelescopeSimulatorKG2::TelescopeSimulator::Init(), SdSimpleSimKG::SdSimpleSim::Init(), ShowerPhotonGeneratorOG::ShowerPhotonGenerator::Init(), and testRunController::testModuleVersionInfo().
|
virtual |
Initialize: invoked at beginning of run (NOT beginning of event)
This method is for things that should be done once at the beginning of a run (for example, booking histograms, performing calculations that need to be done only once, initializing parameters) {You must override this method in your concrete module}
Implements fwk::VModule.
Definition at line 171 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.cc.
References utl::abs(), ERROR, io::eSuccess, utl::Branch::GetChild(), utl::Branch::GetData(), utl::Branch::GetTopBranch(), INFO, km, max, and WARNING.
|
private |
Definition at line 295 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.cc.
References evt::Event::HasSEvent(), INFO, evt::Event::MakeSEvent(), max, galactic::meter, galactic::meter2, CachedShowerRegeneratorOG::PlaneFrontTime(), and utl::Sqr().
|
inlineinherited |
Definition at line 95 of file VModule.h.
References fwk::VModule::fStopwatch, and utl::Stopwatch::Reset().
|
inlineprivate |
Definition at line 273 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.cc.
References OFFLINE_BARYONS, OFFLINE_ELECTRONS, OFFLINE_MESONS, OFFLINE_MUONS, and OFFLINE_PHOTON.
|
private |
Definition at line 678 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.cc.
References utl::delr, utl::endc, utl::endr, utl::hline(), INFO, km, utl::mm, ns, CachedShowerRegeneratorOG::Round(), utl::s, and tab.
|
private |
|
virtual |
Run: invoked once per event.
This method is for things that should be done once per event {You must override this method in your concrete module}
Implements fwk::VModule.
Definition at line 412 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.cc.
References DUMP, DUMP_REJECT, ERROR, io::eSuccess, utl::Particle::GetDirection(), utl::Particle::GetPosition(), utl::BasicVector< HepVector >::GetZ(), evt::Event::HasSimShower(), INFO, CachedShowerRegeneratorOG::InsertValue(), CachedShowerRegeneratorOG::IsMuonic(), utl::kPi, utl::kPiOnTwo, utl::kTwoPi, max, mod(), ns, particle, CachedShowerRegeneratorOG::PlaneFrontTime(), utl::Particle::SetPosition(), utl::Particle::SetTime(), utl::Particle::SetWeight(), utl::Sqr(), and sqrt().
|
inlineinherited |
Definition at line 98 of file VModule.h.
References fwk::VModule::fStopwatch, fwk::VModule::Run(), utl::Stopwatch::Start(), and utl::Stopwatch::Stop().
Referenced by fwk::RunController::DoNextInSequence().
|
private |
Definition at line 115 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 114 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 108 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 111 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 116 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
protectedinherited |
Definition at line 123 of file VModule.h.
Referenced by RdChannelASCIINoiseImporterRD::RdChannelASCIINoiseImporterRD::Init(), Rd2dLDFFitter::Rd2dLDFFitter::Init(), RdChannelNoiseImporter_AERA::RdChannelNoiseImporter_AERA::Init(), and Rd2dLDFFitter::Rd2dLDFFitter::Run().
|
private |
Definition at line 105 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 98 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 120 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 134 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 112 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 109 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 123 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 106 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 99 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 118 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 110 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 125 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 119 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 136 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 133 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 128 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 130 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 129 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 117 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 121 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 101 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 102 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.
|
private |
Definition at line 103 of file CachedShowerRegeneratorOG/CachedShowerRegenerator.h.