LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
Runs Geant4 simulation and propagation of electrons and photons to readout. More...
Public Types | |
using | ModuleType = EDProducer |
template<typename UserConfig , typename KeysToIgnore = void> | |
using | Table = Modifier::Table< UserConfig, KeysToIgnore > |
Public Member Functions | |
LArG4 (fhicl::ParameterSet const &pset) | |
void | doBeginJob (SharedResources const &resources) |
void | doEndJob () |
void | doRespondToOpenInputFile (FileBlock const &fb) |
void | doRespondToCloseInputFile (FileBlock const &fb) |
void | doRespondToOpenOutputFiles (FileBlock const &fb) |
void | doRespondToCloseOutputFiles (FileBlock const &fb) |
bool | doBeginRun (RunPrincipal &rp, ModuleContext const &mc) |
bool | doEndRun (RunPrincipal &rp, ModuleContext const &mc) |
bool | doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc) |
bool | doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc) |
bool | doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed) |
void | fillProductDescriptions () |
void | registerProducts (ProductDescriptions &productsToRegister) |
ModuleDescription const & | moduleDescription () const |
void | setModuleDescription (ModuleDescription const &) |
std::array< std::vector< ProductInfo >, NumBranchTypes > const & | getConsumables () const |
void | sortConsumables (std::string const ¤t_process_name) |
std::unique_ptr< Worker > | makeWorker (WorkerParams const &wp) |
template<typename T , BranchType BT> | |
ViewToken< T > | consumesView (InputTag const &tag) |
template<typename T , BranchType BT> | |
ViewToken< T > | mayConsumeView (InputTag const &tag) |
Protected Member Functions | |
ConsumesCollector & | consumesCollector () |
template<typename T , BranchType = InEvent> | |
ProductToken< T > | consumes (InputTag const &) |
template<typename Element , BranchType = InEvent> | |
ViewToken< Element > | consumesView (InputTag const &) |
template<typename T , BranchType = InEvent> | |
void | consumesMany () |
template<typename T , BranchType = InEvent> | |
ProductToken< T > | mayConsume (InputTag const &) |
template<typename Element , BranchType = InEvent> | |
ViewToken< Element > | mayConsumeView (InputTag const &) |
template<typename T , BranchType = InEvent> | |
void | mayConsumeMany () |
Private Member Functions | |
void | produce (art::Event &evt) override |
void | beginJob () override |
void | beginRun (art::Run &run) override |
std::unique_ptr< util::PositionInVolumeFilter > | CreateParticleVolumeFilter (std::set< std::string > const &vol_names) const |
Pointer used for correctly updating the clock data state. More... | |
Private Attributes | |
std::unique_ptr< g4b::G4Helper > | fG4Help {nullptr} |
G4 interface object. More... | |
larg4::ParticleListAction * | fparticleListAction |
Geant4 user action to particle information. More... | |
std::string | fG4PhysListName |
predefined physics list to use if not making a custom one More... | |
std::string | fG4MacroPath |
bool | fCheckOverlaps |
Whether to use the G4 overlap checker. More... | |
bool | fMakeMCParticles |
Whether to keep a sim::MCParticle list. More... | |
bool | fStoreDroppedMCParticles |
Whether to keep a sim::MCParticleLite list of dropped particles. More... | |
bool | fdumpParticleList |
Whether each event's sim::ParticleList will be displayed. More... | |
bool | fdumpSimChannels |
Whether each event's sim::Channel will be displayed. More... | |
bool | fUseLitePhotons |
bool | fStoreReflected {false} |
int | fSmartStacking |
Whether to instantiate and use class to. More... | |
double | fOffPlaneMargin = 0. |
std::vector< std::string > | fInputLabels |
std::vector< std::string > | fKeepParticlesInVolumes |
Only write particles that have trajectories through these volumes. More... | |
bool | fSparsifyTrajectories |
Sparsify MCParticle Trajectories. More... | |
CLHEP::HepRandomEngine & | fEngine |
detinfo::DetectorPropertiesData | fDetProp |
Must outlive fAllPhysicsLists! More... | |
AllPhysicsLists | fAllPhysicsLists |
LArVoxelReadoutGeometry * | fVoxelReadoutGeometry |
Runs Geant4 simulation and propagation of electrons and photons to readout.
This module collects generated particles from one or more generators and processes them through Geant4.
The module reads the particles to process from simb::MCTruth
records. Each particle generator is required to produce a vector of such records: std::vector<simb::MCTruth>
.
The module allows two operation modes:
LArG4
configurationLArG4
module configuration, and the module will process all data products of type std::vector<simb::MCTruth>
, in a non-specified orderFor each simb::MCTruth
, a Geant4 run is started. The interface with Geant4 is via a helper class provided by nug4. Only the particles in the truth record which have status code (simb::MCParticle::StatusCode()
) equal to 1
are processed. These particles are called, in LArG4
jargon, primaries.
The LArG4
module produces:
sim::SimChannel
: each sim::SimChannel
represents the set of energy depositions in liquid argon which drifted and were observed on a certain channel; it includes physics effects like attenuation, diffusion, electric field distortion, etc. Information of the generating Geant4 "track" is retained;sim::SimPhotons
or sim::SimPhotonsLite
: each sim::SimPhotons
represents the set of individual photons reaching a channel of the optical detector; it includes physics effects as well as quantum efficiency of the detector (to reduce data size early in the process); sim::SimPhotonsLite
drops the information of the single photons and stores only collective information (e.g. their number).sim::OpDetBacktrackerRecord
(to be documented)sim::AuxDetSimChannel
(to be documented)simb::MCParticle
: the particles generated in the interaction of the primary particles with the material in the world are stored, but minor filtering by geometry and by physics is possible. An association of them with the originating simb::MCTruth
object is also produced.simb::MCTruth
) which have status code (simb::MCParticle::StatusCode()
) equal to 1
are passed to Geant4. These particles are called, in LArG4
jargon, primaries. The interface with Geant4 is via a helper class provided by nug4.simb::MCParticle
object into the output particle list. Each simb::MCParticle
includes a Geant4-like track ID which is also recorded into each sim::IDE
deposited by that particle. This information can be used to track all the deposition from a particle, or to backtrack the particle responsible of a deposition (but see below...). Note that the stored track ID may be different than the one Geant4 used (and, in particular, it's guaranteed to be unique within a sim::LArG4
instance output).sim::LArG4Parameters
service) which allow for Geant4 tracks not to be saved as simb::MCParticle
(e.g. ParticleKineticEnergyCut
, KeepEMShowerDaughters
). When these particles have deposited energy, their sim::IDE
will report the ID of the first parent Geant4 track which is saved in the simb::MCParticle
list, but with its sign flipped. Therefore, when tracking or backtracking (see above), comparisons should be performed using the absolute value of the sim::IDE
(e.g. std::abs(ide.trackID)
).The LArG4
module produces sim::SimChannel
objects from generated simb::MCParticle
. Each particle ("primary") is assigned the time taken from its vertex (a 4-vector), which is expected to be represented in nanoseconds. The sim::SimChannel
object is a collection of sim::IDE
in time. The position in the sim::IDE
is the location where some ionization occurred. The time associated to a sim::IDE
is stored in tick units. The time it represents is the time when the ionization happened, which is the time of the primary particle plus the propagation time to the ionization location, plus the drift time, which the ionized electrons take to reach the anode wire. This time is then shifted to the frame of the electronics time via detinfo::DetectorClocks::G4ToElecTime()
, which adds a configurable time offset. The time is converted into ticks via detinfo::DetectorClocks::TPCClock()
, and this is the final value associated to the sim::IDE
. For a more complete overview, see https://cdcvs.fnal.gov/redmine/projects/larsoft/wiki/Simulation#Simulation-Timing
The random number generators used by this process are:
"larg4::PhysicsList"
): whether to use the G4 overlap checker, which catches different issues than ROOTfalse
): whether to use the G4 overlap checkerfalse
): whether to print all MCParticles tracked; requires MakeMCParticles
being true
false
): whether to print all depositions on each SimChannel0
): whether to use class to dictate how tracks are put on stack (nonzero is on)true
): keep a list of the particles seen in the detector, and eventually save it; you almost always want this onsimb::MCParticle
objects (empty keeps all); requires MakeMCParticles
being true
G4Helper
for setting G4 commandNuRandomService
by default)NuRandomService
by default)simb::MCTruth
will be simulated; if not specified, all simb::MCTruth
vector data products are simulated0
): sets the maximum distance from a plane for the wire charge recovery to occur, in centimeters; for details on how it works, see larg4::LArVoxelReadout::SetOffPlaneChargeRecoveryMargin()
. A value of 0
effectively disables this feature. All TPCs will have the same margin applied. Some of the physical properties have their values set in FHiCL configuration (e.g. detinfo::LArParameters
). Then, GEANT4 is informed of them via larg4::MaterialPropertyLoader
. The material property table in GEANT4 is then used by other LArSoft components to discover the parameter values.
Among the parameters registered to GEANT4, the scintillation yields, i.e. how many scintillation photons are produced on average by 1 MeV of deposited energy, are also stored by type of ioniziong particle. These scintillation yields do include a prescale factor (that may include, for example, the photomultiplier quantum efficiency), from the ScintPreScale
parameter of detinfo::LArPropertiesStandard
or equivalent.
Two models are supported for the simulation of (scintillation) light crossing detector surfaces:
G4OpBoundaryProcess
larg4::OpBoundaryProcessSimple
The model is chosen according to the value of detinfo::DetectorProperties::SimpleBoundary()
, and the choice is currently exerted by larg4::OpticalPhysics
.
The simplified model is faster and simpler: it only deals with absorption and reflection (both specular and diffues). This is the "default" model used in most contexts.
GEANT4 model is more complete and slower. It may take some art to fully configure all the properties of the materials at the sides of the surfaces. The price is a detailed simulation that includes among others refraction and wavelength shifting.
When using the fast optical simulation, which is the "standard" running mode, energy depositions from GEANT4 are "converted" into a number of scintillation photons by the global larg4::IonizationAndScintillation
object instance, which internally utilizes the algorithm set up via configuration parameter IonAndScintCalculator
in LArG4Parameters
service (at the time of writing, "Separate"
is supported and "NEST"
is accepted too). The number of scintillation photons per energy unit is read from GEANT4 material properties table. It includes already quantum efficiency ("prescale") and it may depend on the type of ionizing particle, depending on the configuration (LArPropertiesStandard
parameter ScintByParticleType
). This value ("yield") is used as the average of a Poisson distribution from which the actual number of scintillation photons is extracted case by case. The implementation larg4::ISCalculationSeparate
may also include medium saturation effects as well, if configured, but only if the scintillation yield is set not to depend on the type of ionizing particle. The number of scintillation photons is then distributed between the fast and slow component by a yield ratio also set in the material parameters, and the single photons are distributed in time accordingly to their component.
Definition at line 315 of file LArG4_module.cc.
|
inherited |
Definition at line 17 of file EDProducer.h.
|
inherited |
Definition at line 26 of file Producer.h.
|
explicit |
Definition at line 406 of file LArG4_module.cc.
References art::errors::Configuration, art::detail::EngineCreator::createEngine(), e, fAllPhysicsLists, fCheckOverlaps, fDetProp, fdumpParticleList, fdumpSimChannels, fEngine, fG4MacroPath, fG4PhysListName, sim::LArG4Parameters::FillSimEnergyDeposits(), fInputLabels, fKeepParticlesInVolumes, fMakeMCParticles, fOffPlaneMargin, fSmartStacking, fSparsifyTrajectories, fStoreDroppedMCParticles, fStoreReflected, fUseLitePhotons, MF_LOG_DEBUG, sim::LArG4Parameters::NoElectronPropagation(), sim::LArG4Parameters::NoPhotonPropagation(), art::ProductRegistryHelper::produces(), art::errors::ServiceNotFound, phot::PhotonVisibilityService::StoreReflected(), and sim::LArG4Parameters::UseLitePhotons().
|
overrideprivatevirtual |
Reimplemented from art::EDProducer.
Definition at line 512 of file LArG4_module.cc.
References g4b::UserActionManager::AddAndAdoptAction(), larg4::IonizationAndScintillation::CreateInstance(), fCheckOverlaps, fEngine, fG4Help, fG4MacroPath, fG4PhysListName, fMakeMCParticles, fOffPlaneMargin, fparticleListAction, fSmartStacking, fStoreDroppedMCParticles, fUseLitePhotons, fVoxelReadoutGeometry, geo::GeometryCore::GDMLFile(), larg4::MaterialPropertyLoader::GetPropertiesFromServices(), g4b::UserActionManager::Instance(), sim::LArG4Parameters::KeepEMShowerDaughters(), larg4::LArVoxelReadout::Setup_t::offPlaneMargin, geo::GeometryCore::OpDetGeoName(), sim::LArG4Parameters::ParticleKineticEnergyCut(), larg4::LArVoxelReadout::Setup_t::propGen, larg4::LArVoxelReadoutGeometry::Setup_t::readoutSetup, sim::LArG4Parameters::StoreTrajectories(), and larg4::MaterialPropertyLoader::UpdateGeometry().
|
overrideprivatevirtual |
Reimplemented from art::EDProducer.
Definition at line 583 of file LArG4_module.cc.
References CreateParticleVolumeFilter(), fKeepParticlesInVolumes, fparticleListAction, and larg4::ParticleListAction::ParticleFilter().
|
protectedinherited |
Definition at line 61 of file ModuleBase.h.
References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().
|
protectedinherited |
|
protectedinherited |
Definition at line 75 of file ModuleBase.h.
References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().
|
protectedinherited |
|
inherited |
Definition at line 68 of file ModuleBase.h.
References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().
|
private |
Pointer used for correctly updating the clock data state.
Configures and returns a particle filter
Definition at line 591 of file LArG4_module.cc.
References util::empty().
Referenced by beginRun().
|
inherited |
Definition at line 22 of file Producer.cc.
References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().
|
inherited |
Definition at line 65 of file Producer.cc.
References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().
|
inherited |
Definition at line 85 of file Producer.cc.
References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().
|
inherited |
Definition at line 30 of file Producer.cc.
References art::detail::Producer::endJobWithFrame().
|
inherited |
Definition at line 75 of file Producer.cc.
References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().
|
inherited |
Definition at line 95 of file Producer.cc.
References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().
|
inherited |
Definition at line 105 of file Producer.cc.
References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().
|
inherited |
Definition at line 44 of file Producer.cc.
References art::detail::Producer::respondToCloseInputFileWithFrame().
|
inherited |
Definition at line 58 of file Producer.cc.
References art::detail::Producer::respondToCloseOutputFilesWithFrame().
|
inherited |
Definition at line 37 of file Producer.cc.
References art::detail::Producer::respondToOpenInputFileWithFrame().
|
inherited |
Definition at line 51 of file Producer.cc.
References art::detail::Producer::respondToOpenOutputFilesWithFrame().
|
inherited |
Definition at line 10 of file Modifier.cc.
References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().
|
inherited |
Definition at line 43 of file ModuleBase.cc.
References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().
|
inherited |
Definition at line 37 of file ModuleBase.cc.
References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.
|
protectedinherited |
Definition at line 82 of file ModuleBase.h.
References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().
|
protectedinherited |
Definition at line 96 of file ModuleBase.h.
References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().
|
protectedinherited |
|
inherited |
Definition at line 89 of file ModuleBase.h.
References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().
|
inherited |
Definition at line 13 of file ModuleBase.cc.
References art::errors::LogicError.
Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().
|
overrideprivatevirtual |
The main routine of this module: Fetch the primary particles from the event, simulate their evolution in the detector, and produce the detector response.
Implements art::EDProducer.
Definition at line 635 of file LArG4_module.cc.
References geo::GeometryCore::AuxDet(), sim::SimChannel::Channel(), larg4::AuxDetReadout::clear(), larg4::OpDetPhotonTable::ClearEnergyDeposits(), larg4::OpDetPhotonTable::ClearTable(), geo::GeometryCore::Cryostat(), DEFINE_ART_MODULE, sim::SimPhotonsLite::DetectedPhotons, sim::dump::DumpMCParticle(), sim::dump::DumpMCTruth(), util::empty(), fdumpParticleList, fdumpSimChannels, fG4Help, fInputLabels, fMakeMCParticles, fparticleListAction, fSparsifyTrajectories, fStoreDroppedMCParticles, fStoreReflected, fUseLitePhotons, fVoxelReadoutGeometry, art::Ptr< T >::get(), larg4::AuxDetReadout::GetAuxDetSimChannel(), art::ProductRetriever::getByLabel(), larg4::OpDetPhotonTable::GetLitePhotons(), art::ProductRetriever::getMany(), larg4::OpDetPhotonTable::GetPhotons(), larg4::ParticleListAction::GetPrimaryTruthIndex(), art::Event::id(), larg4::OpDetPhotonTable::Instance(), larg4::ParticleListAction::isDropped(), art::errors::LogicError, MF_LOG_DEBUG, simb::MCParticle::Mother(), geo::GeometryCore::NAuxDets(), geo::GeometryCore::Ncryostats(), geo::GeometryCore::NOpDets(), geo::AuxDetGeo::NSensitiveVolume(), geo::CryostatGeo::NTPC(), sim::SimPhotonsLite::OpChannel, simb::MCTruth::Origin(), sim::MCParticleLite::Origin(), art::Handle< T >::provenance(), art::Event::put(), larg4::ParticleListAction::ResetTrackIDOffset(), sc, util::size(), sim::ParticleList::size(), simb::MCParticle::SparsifyTrajectory(), simb::MCParticle::StatusCode(), sim::SimChannel::TDCIDEMap(), simb::MCParticle::TrackId(), larg4::ParticleListAction::YieldDroppedList(), larg4::ParticleListAction::YieldList(), larg4::OpDetPhotonTable::YieldOpDetBacktrackerRecords(), larg4::OpDetPhotonTable::YieldReflectedOpDetBacktrackerRecords(), and larg4::OpDetPhotonTable::YieldSimEnergyDeposits().
|
inherited |
Definition at line 16 of file Modifier.cc.
References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().
|
inherited |
|
inherited |
Definition at line 49 of file ModuleBase.cc.
References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().
|
private |
Definition at line 355 of file LArG4_module.cc.
Referenced by LArG4().
|
private |
Whether to use the G4 overlap checker.
Definition at line 334 of file LArG4_module.cc.
Referenced by beginJob(), and LArG4().
|
private |
Must outlive fAllPhysicsLists!
Definition at line 354 of file LArG4_module.cc.
Referenced by LArG4().
|
private |
Whether each event's sim::ParticleList will be displayed.
Definition at line 338 of file LArG4_module.cc.
|
private |
Whether each event's sim::Channel will be displayed.
Definition at line 339 of file LArG4_module.cc.
|
private |
Random-number engine for IonizationAndScintillation initialization
Definition at line 351 of file LArG4_module.cc.
Referenced by beginJob(), and LArG4().
|
private |
G4 interface object.
Definition at line 327 of file LArG4_module.cc.
Referenced by beginJob(), and produce().
|
private |
directory path for Geant4 macro file to be executed before main MC processing.
Definition at line 332 of file LArG4_module.cc.
Referenced by beginJob(), and LArG4().
|
private |
predefined physics list to use if not making a custom one
Definition at line 331 of file LArG4_module.cc.
Referenced by beginJob(), and LArG4().
|
private |
Definition at line 345 of file LArG4_module.cc.
|
private |
Only write particles that have trajectories through these volumes.
Definition at line 347 of file LArG4_module.cc.
Referenced by beginRun(), and LArG4().
|
private |
Whether to keep a sim::MCParticle
list.
Definition at line 335 of file LArG4_module.cc.
Referenced by beginJob(), LArG4(), and produce().
|
private |
Off-plane charge recovery margin dictate how tracks are put on stack.
Definition at line 343 of file LArG4_module.cc.
Referenced by beginJob(), and LArG4().
|
private |
Geant4 user action to particle information.
Definition at line 328 of file LArG4_module.cc.
Referenced by beginJob(), beginRun(), and produce().
|
private |
Whether to instantiate and use class to.
Definition at line 342 of file LArG4_module.cc.
Referenced by beginJob(), and LArG4().
|
private |
Sparsify MCParticle Trajectories.
Definition at line 349 of file LArG4_module.cc.
|
private |
Whether to keep a sim::MCParticleLite
list of dropped particles.
Definition at line 337 of file LArG4_module.cc.
Referenced by beginJob(), LArG4(), and produce().
|
private |
Definition at line 341 of file LArG4_module.cc.
|
private |
Definition at line 340 of file LArG4_module.cc.
Referenced by beginJob(), LArG4(), and produce().
|
private |
Definition at line 356 of file LArG4_module.cc.
Referenced by beginJob(), and produce().