LArSoft interface to CORSIKA event generator. More...
Public Member Functions | |
CORSIKAGen (fhicl::ParameterSet const &pset) | |
virtual | ~CORSIKAGen () |
void | produce (art::Event &evt) |
void | beginRun (art::Run &run) |
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] ={0.,0.,0.,0.,0.,0.} |
Boundaries of area over which showers are to be distributed (x(min), x(max), unused, y, z(min), z(max) ) More... | |
double | fToffset_corsika =0. |
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 =0. |
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 =0. |
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.
|
explicit |
Definition at line 291 of file CORSIKAGen_module.cc.
|
virtual |
Definition at line 325 of file CORSIKAGen_module.cc.
void evgen::CORSIKAGen::beginRun | ( | art::Run & | run | ) |
Definition at line 714 of file CORSIKAGen_module.cc.
|
private |
Definition at line 562 of file CORSIKAGen_module.cc.
|
private |
Definition at line 372 of file CORSIKAGen_module.cc.
|
private |
Definition at line 487 of file CORSIKAGen_module.cc.
|
private |
Definition at line 460 of file CORSIKAGen_module.cc.
void evgen::CORSIKAGen::produce | ( | art::Event & | evt | ) |
Definition at line 720 of file CORSIKAGen_module.cc.
|
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 333 of file CORSIKAGen_module.cc.
|
private |
Definition at line 449 of file CORSIKAGen_module.cc.
|
private |
Definition at line 454 of file CORSIKAGen_module.cc.
|
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 280 of file CORSIKAGen_module.cc.
|
private |
Pointers to sqlite3 database object, max of 5.
Definition at line 282 of file CORSIKAGen_module.cc.
|
private |
Definition at line 284 of file CORSIKAGen_module.cc.
|
private |
(optional) flux file handling
Definition at line 271 of file CORSIKAGen_module.cc.
|
private |
Definition at line 268 of file CORSIKAGen_module.cc.
|
private |
Number of showers to put in each event of duration fSampleTime; one per showerinput.
Definition at line 267 of file CORSIKAGen_module.cc.
|
private |
Definition at line 285 of file CORSIKAGen_module.cc.
|
private |
Height to which particles will be projected [cm].
Definition at line 274 of file CORSIKAGen_module.cc.
|
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 283 of file CORSIKAGen_module.cc.
|
private |
Duration of sample [s].
Definition at line 278 of file CORSIKAGen_module.cc.
|
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 281 of file CORSIKAGen_module.cc.
|
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.
|
private |
Definition at line 276 of file CORSIKAGen_module.cc.
|
private |
Set of flux constants to be associated with each shower data file.
Definition at line 277 of file CORSIKAGen_module.cc.
|
private |
Set of CORSIKA shower data files to use.
Definition at line 275 of file CORSIKAGen_module.cc.
|
private |
Number of shower inputs to process from.
Definition at line 266 of file CORSIKAGen_module.cc.
|
private |
Time offset of sample, defaults to zero (no offset) [s].
Definition at line 279 of file CORSIKAGen_module.cc.
|
private |
Timing offset to account for propagation time through atmosphere, populated from db.
Definition at line 270 of file CORSIKAGen_module.cc.