Skip to content

Commit 0db3f11

Browse files
author
Brandon Gomes
authored
Merge pull request #62 from bhgomes/master
Add Initial Corsika Generator
2 parents c0b71e2 + dc6de2c commit 0db3f11

31 files changed

+1750
-750
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ add_executable(simulation
5353
src/geometry/prototype/RPC.cc
5454
src/geometry/prototype/Scintillator.cc
5555

56+
src/physics/Particle.cc
5657
src/physics/Generator.cc
5758
src/physics/HepMCGenerator.cc
5859
src/physics/PythiaGenerator.cc
5960
src/physics/RangeGenerator.cc
61+
src/physics/CORSIKAReaderGenerator.cc
6062

6163
src/tracking.cc
6264

@@ -66,7 +68,6 @@ add_executable(simulation
6668
target_compile_features(simulation PUBLIC cxx_std_14)
6769
target_compile_options(simulation PUBLIC -Wno-missing-braces
6870
-pthread
69-
-ftls-model=global-dynamic
7071
-fPIC)
7172

7273
target_link_libraries(simulation PUBLIC

include/geometry/Construction.hh

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ extern G4Material* Iron;
5353
//__Geometry Builder Class______________________________________________________________________
5454
class Builder : public G4VUserDetectorConstruction, public G4UImessenger {
5555
public:
56-
Builder(const std::string& detector);
56+
Builder(const std::string& detector,
57+
const std::string& export_dir);
5758
G4VPhysicalVolume* Construct();
5859
void ConstructSDandField();
5960

@@ -258,12 +259,14 @@ G4RotationMatrix Matrix(const double mxx,
258259

259260
//__GDML File Export____________________________________________________________________________
260261
void Export(const G4LogicalVolume* volume,
262+
const std::string& dir,
261263
const std::string& file,
262264
const std::string& schema="");
263265
//----------------------------------------------------------------------------------------------
264266

265267
//__GDML File Export____________________________________________________________________________
266268
void Export(const G4VPhysicalVolume* volume,
269+
const std::string& dir,
267270
const std::string& file,
268271
const std::string& schema="");
269272
//----------------------------------------------------------------------------------------------
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* include/physics/CORSIKAReaderGenerator.hh
3+
*
4+
* Copyright 2018 Brandon Gomes
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef MU__PHYSICS_CORSIKA_READER_GENERATOR_HH
20+
#define MU__PHYSICS_CORSIKA_READER_GENERATOR_HH
21+
#pragma once
22+
23+
#include "Generator.hh"
24+
25+
namespace MATHUSLA { namespace MU {
26+
27+
namespace Physics { ////////////////////////////////////////////////////////////////////////////
28+
29+
//__CORSIKA Simulation Config Structure_________________________________________________________
30+
struct CORSIKAConfig {
31+
int primary_id;
32+
double energy_slope,
33+
energy_min,
34+
energy_max,
35+
azimuth_min,
36+
azimuth_max,
37+
zenith_min,
38+
zenith_max;
39+
};
40+
//----------------------------------------------------------------------------------------------
41+
42+
//__CORSIKA Simulation Event Structure__________________________________________________________
43+
struct CORSIKAEvent {
44+
std::vector<int> id;
45+
std::vector<double> t, x, y, z, px, py, pz;
46+
bool empty() const;
47+
std::size_t size() const;
48+
void clear();
49+
void reserve(std::size_t capacity);
50+
void push_back(int new_id,
51+
double new_t,
52+
double new_x,
53+
double new_y,
54+
double new_z,
55+
double new_px,
56+
double new_py,
57+
double new_pz);
58+
const Particle operator[](const std::size_t index) const;
59+
};
60+
//----------------------------------------------------------------------------------------------
61+
62+
//__CORSIKA Simulation Event Vector_____________________________________________________________
63+
using CORSIKAEventVector = std::vector<CORSIKAEvent>;
64+
//----------------------------------------------------------------------------------------------
65+
66+
//__CORSIKA Simulation Generator________________________________________________________________
67+
class CORSIKAReaderGenerator : public Generator {
68+
public:
69+
CORSIKAReaderGenerator();
70+
71+
void GeneratePrimaryVertex(G4Event* event);
72+
void SetNewValue(G4UIcommand* command,
73+
G4String value);
74+
void SetFile(const std::string& path);
75+
76+
virtual const Analysis::SimSettingList GetSpecification() const;
77+
78+
private:
79+
static G4ThreadLocal CORSIKAEventVector* _data;
80+
static G4ThreadLocal std::size_t _data_index;
81+
CORSIKAConfig _config;
82+
std::string _path;
83+
Command::StringArg* _read_file;
84+
// TODO: Command::StringArg* _read_directory;
85+
};
86+
//----------------------------------------------------------------------------------------------
87+
88+
} /* namespace Physics */ //////////////////////////////////////////////////////////////////////
89+
90+
} } /* namespace MATHUSLA::MU */
91+
92+
#endif /* MU__PHYSICS_CORSIKA_READER_GENERATOR_HH */

0 commit comments

Comments
 (0)