LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
LArSoft interface to CORSIKA event generator. More...
Public Types | |
using | ModuleType = EDProducer |
template<typename UserConfig , typename KeysToIgnore = void> | |
using | Table = Modifier::Table< UserConfig, KeysToIgnore > |
Public Member Functions | |
CORSIKAGen (fhicl::ParameterSet const &pset) | |
virtual | ~CORSIKAGen () |
void | produce (art::Event &evt) |
void | beginRun (art::Run &run) |
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 | openDBs (std::string const &module_label) |
void | populateNShowers () |
void | populateTOffset () |
void | GetSample (simb::MCTruth &) |
double | wrapvar (const double var, const double low, const double high) |
double | wrapvarBoxNo (const double var, const double low, const double high, int &boxno) |
void | ProjectToBoxEdge (const double xyz[], const double dxyz[], const double xlo, const double xhi, const double ylo, const double yhi, const double zlo, const double zhi, double xyzout[]) |
Propagates a point back to the surface of a box. More... | |
Private Attributes | |
int | fShowerInputs = 0 |
Number of shower inputs to process from. More... | |
std::vector< double > | fNShowersPerEvent |
Number of showers to put in each event of duration fSampleTime; one per showerinput. More... | |
std::vector< int > | fMaxShowers |
double | fShowerBounds [6] |
Boundaries of area over which showers are to be distributed (x(min), x(max), unused, y, z(min), z(max) ) More... | |
double | fToffset_corsika |
Timing offset to account for propagation time through atmosphere, populated from db. More... | |
ifdh_ns::ifdh * | fIFDH = 0 |
(optional) flux file handling More... | |
double | fProjectToHeight = 0. |
Height to which particles will be projected [cm]. More... | |
std::vector< std::string > | fShowerInputFiles |
Set of CORSIKA shower data files to use. More... | |
std::string | fShowerCopyType |
std::vector< double > | fShowerFluxConstants |
Set of flux constants to be associated with each shower data file. More... | |
double | fSampleTime = 0. |
Duration of sample [s]. More... | |
double | fToffset = 0. |
Time offset of sample, defaults to zero (no offset) [s]. More... | |
std::vector< double > | fBuffBox |
Buffer box extensions to cryostat in each direction (6 of them: x_lo,x_hi,y_lo,y_hi,z_lo,z_hi) [cm]. More... | |
double | fShowerAreaExtension |
Extend distribution of corsika particles in x,z by this much (e.g. 1000 will extend 10 m in -x, +x, -z, and +z) [cm]. More... | |
sqlite3 * | fdb [5] |
Pointers to sqlite3 database object, max of 5. More... | |
double | fRandomXZShift |
Each shower will be shifted by a random amount in xz so that showers won't repeatedly sample the same space [cm]. More... | |
CLHEP::HepRandomEngine & | fGenEngine |
CLHEP::HepRandomEngine & | fPoisEngine |
LArSoft interface to CORSIKA event generator.
In CORSIKA jargon, a "shower" is the cascade of particles resulting from a primary cosmic ray interaction. This module creates a single simb::MCTruth
object (stored as data product into a std::vector<simb::MCTruth>
with a single entry) containing all the particles from cosmic ray showers crossing a surface above the detector.
The generation procedure consists of selecting showers from a database of pregenerated events, and then to adapt them to the parameters requested in the module configuration. Pregenerated showers are "observed" at a altitude set in CORSIKA configuration.
Databases need to be stored as files in SQLite3 format. Multiple file sources can be specified (ShowerInputFiles
configuration parameter). From each source, one database file is selected and copied locally via IFDH. From each source, showers are extracted proportionally to the relative flux specified in the configuration (specified in ShowerFluxConstants
, see normalization below). The actual number of showers per event and per source is extracted according to a Poisson distribution around the predicted average number of primary cosmic rays for that source.
CORSIKA generates showers from each specific cosmic ray type (e.g. iron, proton, etc.) according to a power law distribution of the primary particle energy [GeV]. When sampling pregenerated events, we bypass the normalization imposed by CORSIKA and gain complete control on it.
Within CORSIKAGen, for each source (usually each on a different primary cosmic ray type, e.g. iron, proton, etc.), the average number of generated showers is with the area of the surface the flux passes across, the exposure time, the integral defined over the full energy range of the pregenerated showers in the source, and a factor specified in the configuration (ShowerFluxConstants
parameters). This is the flux of primary cosmic rays, not of the observed particles from their showers. Note that it depends on an area and a time interval, but it is uniform with respect to translations and constant in time.
As explained below, we consider only the secondary particles that cross an "observation" surface. After cosmic ray primary particles cross the flux surface ( above), they develop into showers of particles that spread across large areas. Limiting ourself to the observation of particles on a small surface has two effects. We lose the part of the showers that misses that surface . Also, considering a span of time with multiple showers, we miss particles from other hypothetical showers whose primaries crossed outside the generation surface whose shower development would leak into : we did not simulate those showers at all! In terms of total flux of observed particles, under the assumption that the flux is uniform in space, choosing the same size as makes the two effects get the same size: just as many particles from primaries from leak out of , as many particles from primaries from outside sneak in . In that case, counting all the particles from the primaries crossing a surface of area S regardless of where they land yields the right amount of cosmic ray secondary particles across an observation surface also of area S. Practically, the particles landing outside need to be recovered to preserve the correct normalization, which is described in the next section.
The surface we detect the particles through (let's call it ) is defined by the smallest rectangle including all cryostats in the detector, and located at the height of the ceiling of the tallest cryostat. This surface can be increased by specifying a positive value for ShowerAreaExtension
configuration parameter, in which case each side of the rectangle will be extended by that amount.
Showers are extracted one by one from the pregenerated samples and treated independently. Ideally, the detection surface would be at the same exact altitude as the observation surface set in CORSIKA (called above). In practice, we go the other way around, with the assumption that the shower observed at would be very close to the one we actually generated at , and teleport the generated particles on . Since the cryostats may be just meters from the earth surface lies on, this is an acceptable approximation.
All the particles of one shower are compelled within surface as a first step. As explained when describing the "normalization", we need to keep all the shower particles, one way or the other. So, particles of the shower that fell out of are repackaged into other showers and translated back in. This is equivalent to assume the primary cosmic rays originating such shower would happen outside our generation volume ( ), and their shower would then spill into . Since these repackaged showers are in principle independent and uncorrelated, they are assigned a random time different than the main shower, leveraging the assumption of constantness of the flux.
As for the azimuth, this module uses an approximation by setting north direction to match the z axis of LArSoft geometry (typically assumed to be the direction of the beam particle).
The particles so manipulated are then back-propagated from the observation surface to an absolute height defined by ProjectToHeight
(although for particular combination of position and direction, the particles might be propagated back to the edge of the world, or even outside it).
As a final filter, only the particles whose straight projections cross any of the cryostats (with some buffer volume around, defined by BufferBox
) are stored, while the other ones are discarded. Note that the actual interactions that particles from the generation surface undergo may deviate them enough to miss the cryostats anyway, and conversely particles that have been filtered out because shooting off the cryostats might have been subsequently deviated to actually cross them. This effect is not corrected for at this time.
The time of the showers is uniformly distributed within the configured time interval, defined by SampleTime
starting from TimeOffset
.
ShowerInputFiles
(list of paths; mandatory): a list of file paths to pregenerated CORSIKA shower files. Each entry can be a single file or use wildcards (*
) to specify a set of files to choose among. Paths and wildcards are processed by IFDH.ShowerFluxConstants
(list of real numbers; mandatory): for each entry in ShowerInputFiles
, specify the normalization factor of their distribution [ ]ProjectToHeight
(real, default: 0
): the generated particles will appear to come from this height [cm]TimeOffset
(real; default: 0
): start time of the exposure window [s], relative to the simulation time startSampleTime
(real; mandatory): duration of the simulated exposure to cosmic rays [s]ShowerAreaExtension
(real; default: 0
): extend the size of the observation surface of shower particles (S) by this much [cm]; e.g. 1000 will extend 10 m on each sideRandomXZShift
(real; default: 0
): the original position of each shower is randomly shifted within a square with this length as side [cm]BufferBox
(list of six lengths, all 0
by default): extension to the volume of each cryostat for the purpose of filtering out the particles which do not cross the detector; each cryostat volume is independently extended by the same amount, specified here as shifts to lower x, higher x, lower y, higher y, lower z and higher z, in that order cmSeedGenerator
(integer): force random number generator for event generation to the specified valueSeedPoisson
(integer): force random number generator for number of showers to the specified valueSeed
: alias for SeedGenerator
Currently two random engines are used:
SeedGenerator
), of general useSeedPoisson
), only used to determine the number of showers to be selected on each event Definition at line 221 of file CORSIKAGen_module.cc.
|
inherited |
Definition at line 17 of file EDProducer.h.
|
inherited |
Definition at line 26 of file Producer.h.
|
explicit |
Definition at line 302 of file CORSIKAGen_module.cc.
References art::detail::EngineCreator::createEngine(), fBuffBox, fGenEngine, fPoisEngine, fProjectToHeight, fRandomXZShift, fSampleTime, fShowerAreaExtension, fShowerCopyType, fShowerFluxConstants, fShowerInputFiles, fShowerInputs, fToffset, openDBs(), populateNShowers(), and populateTOffset().
|
virtual |
Definition at line 347 of file CORSIKAGen_module.cc.
References fdb, fIFDH, and fShowerInputs.
|
virtual |
Reimplemented from art::EDProducer.
Definition at line 801 of file CORSIKAGen_module.cc.
References geo::GeometryCore::DetectorName(), art::fullRun(), and art::Run::put().
|
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().
|
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().
|
private |
Definition at line 625 of file CORSIKAGen_module.cc.
References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), fdb, fGenEngine, fMaxShowers, fNShowersPerEvent, fPoisEngine, fProjectToHeight, fRandomXZShift, fSampleTime, fShowerBounds, fShowerInputs, fToffset, fToffset_corsika, MF_LOG_DEBUG, ProjectToBoxEdge(), geo::GeometryCore::WorldBox(), wrapvar(), wrapvarBoxNo(), x, x1, x2, y1, y2, and z.
Referenced by produce().
|
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().
|
private |
Definition at line 402 of file CORSIKAGen_module.cc.
References fdb, fGenEngine, fIFDH, fShowerCopyType, fShowerInputFiles, fShowerInputs, and MF_LOG_DEBUG.
Referenced by CORSIKAGen().
|
private |
Definition at line 537 of file CORSIKAGen_module.cc.
References fBuffBox, fdb, fMaxShowers, fNShowersPerEvent, fRandomXZShift, fSampleTime, fShowerAreaExtension, fShowerBounds, fShowerFluxConstants, fShowerInputs, fToffset, and geo::GeometryCore::Iterate().
Referenced by CORSIKAGen().
|
private |
Definition at line 503 of file CORSIKAGen_module.cc.
References fdb, fShowerInputs, and fToffset_corsika.
Referenced by CORSIKAGen().
|
virtual |
Implements art::EDProducer.
Definition at line 807 of file CORSIKAGen_module.cc.
References simb::MCTruth::Add(), DEFINE_ART_MODULE, fBuffBox, simb::MCTruth::GetParticle(), GetSample(), geo::GeometryCore::Iterate(), simb::kCosmicRay, simb::MCParticle::Momentum(), simb::MCTruth::NParticles(), simb::MCParticle::Position(), art::Event::put(), and simb::MCTruth::SetOrigin().
|
private |
Propagates a point back to the surface of a box.
xyz | coordinates of the point to be propagated ({ x, y, z } ) |
dxyz | direction of the point ({ dx, dy, dz } ) |
xlo | lower x coordinate of the target box |
xhi | upper x coordinate of the target box |
ylo | lower y coordinate of the target box |
yhi | upper y coordinate of the target box |
zlo | lower z coordinate of the target box |
zhi | upper z coordinate of the target box |
xyzout | _(output, room for at least 3 numbers)_ propagated point |
The point xyz
, assumed to be inside the box, is propagated at the level of the closest among the sides of the box. Note that this means the propagated point might still be not on the surface of the box, even if it would later reach it. It is anyway guaranteed that xyzout
is not inside the target box, and that at least one of its three coordinates is on the box surface.
Definition at line 356 of file CORSIKAGen_module.cc.
References d.
Referenced by GetSample().
|
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 490 of file CORSIKAGen_module.cc.
Referenced by GetSample().
|
private |
Definition at line 496 of file CORSIKAGen_module.cc.
Referenced by GetSample().
|
private |
Buffer box extensions to cryostat in each direction (6 of them: x_lo,x_hi,y_lo,y_hi,z_lo,z_hi) [cm].
Definition at line 289 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), populateNShowers(), and produce().
|
private |
Pointers to sqlite3 database object, max of 5.
Definition at line 292 of file CORSIKAGen_module.cc.
Referenced by GetSample(), openDBs(), populateNShowers(), populateTOffset(), and ~CORSIKAGen().
|
private |
Definition at line 295 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), GetSample(), and openDBs().
|
private |
(optional) flux file handling
Definition at line 278 of file CORSIKAGen_module.cc.
Referenced by openDBs(), and ~CORSIKAGen().
|
private |
Definition at line 268 of file CORSIKAGen_module.cc.
Referenced by GetSample(), and populateNShowers().
|
private |
Number of showers to put in each event of duration fSampleTime; one per showerinput.
Definition at line 267 of file CORSIKAGen_module.cc.
Referenced by GetSample(), and populateNShowers().
|
private |
Definition at line 296 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), and GetSample().
|
private |
Height to which particles will be projected [cm].
Definition at line 281 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), and GetSample().
|
private |
Each shower will be shifted by a random amount in xz so that showers won't repeatedly sample the same space [cm].
Definition at line 293 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), GetSample(), and populateNShowers().
|
private |
Duration of sample [s].
Definition at line 286 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), GetSample(), and populateNShowers().
|
private |
Extend distribution of corsika particles in x,z by this much (e.g. 1000 will extend 10 m in -x, +x, -z, and +z) [cm].
Definition at line 290 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), and populateNShowers().
|
private |
Boundaries of area over which showers are to be distributed (x(min), x(max), unused, y, z(min), z(max) )
Definition at line 269 of file CORSIKAGen_module.cc.
Referenced by GetSample(), and populateNShowers().
|
private |
Definition at line 283 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), and openDBs().
|
private |
Set of flux constants to be associated with each shower data file.
Definition at line 285 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), and populateNShowers().
|
private |
Set of CORSIKA shower data files to use.
Definition at line 282 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), and openDBs().
|
private |
Number of shower inputs to process from.
Definition at line 265 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), GetSample(), openDBs(), populateNShowers(), populateTOffset(), and ~CORSIKAGen().
|
private |
Time offset of sample, defaults to zero (no offset) [s].
Definition at line 287 of file CORSIKAGen_module.cc.
Referenced by CORSIKAGen(), GetSample(), and populateNShowers().
|
private |
Timing offset to account for propagation time through atmosphere, populated from db.
Definition at line 276 of file CORSIKAGen_module.cc.
Referenced by GetSample(), and populateTOffset().