18 double timeWindow = 10;
19 double gridStartTime = 0;
20 double maxStep = 1 * CLHEP::mm;
23 readoutSpecs = std::make_shared<GReadoutSpecs>(timeWindow, gridStartTime, maxStep,
log);
31 auto gdata = std::make_unique<GDigitizedData>(
gopts, ghit);
35 auto dose = etot / mass;
38 gdata->includeVariable(
"etot", etot / MeV);
70 [[maybe_unused]] std::string
const& variation) {
72 std::map<int, std::string> nielDataFiles;
73 nielDataFiles[11] =
"niel_electron.txt";
74 nielDataFiles[211] =
"niel_pion.txt";
75 nielDataFiles[2112] =
"niel_neutron.txt";
76 nielDataFiles[2212] =
"niel_proton.txt";
81 for (
const auto& [pid, filename] : nielDataFiles) {
82 std::string dataFileWithPath = gemcRoot.string() +
"/dosimeterData" +
"/Niel/" + filename;
84 std::ifstream inputfile(dataFileWithPath);
88 dataFileWithPath = gemcRoot.string() +
"/gemc/gdynamicDigitization/dosimeterData" +
"/Niel/" + filename;
89 inputfile.open(dataFileWithPath);
96 log->
info(1,
" Loading dosimeter data for pid <", pid,
"> from file ", dataFileWithPath);
100 while (inputfile >> p0 >> p1) {
101 nielfactorMap[pid].push_back(p0);
102 E_nielfactorMap[pid].push_back(p1);
108 pMassMeV[11] = 0.510;
109 pMassMeV[211] = 139.570;
110 pMassMeV[2112] = 939.565;
111 pMassMeV[2212] = 938.272;
117double GDosimeterDigitization::getNielFactorForParticleAtEnergy(
int pid,
double energyMeV) {
118 const auto niel_N = nielfactorMap[pid].size();
123 log->
error(EC__FILENOTFOUND,
"NIEL tables are empty for pid <", pid,
">. Did loadConstantsImpl fail?");
130 for (
size_t i = 0; i < niel_N; i++) {
131 if (energyMeV < E_nielfactorMap[pid][i]) {
139 if (j > 0 && j < niel_N) {
141 const auto nielfactor_low = nielfactorMap[pid][j - 1];
142 const auto nielfactor_high = nielfactorMap[pid][j];
143 const auto energy_low = E_nielfactorMap[pid][j - 1];
144 const auto energy_high = E_nielfactorMap[pid][j];
146 value = nielfactor_low +
147 ( nielfactor_high - nielfactor_low ) / ( energy_high - energy_low ) * ( energyMeV - energy_low );
151 value = nielfactorMap[pid].front();
155 value = nielfactorMap[pid].back();
158 log->
debug(NORMAL,
" pid: ", pid,
", j: ", j,
", value: ", value,
", energy: ", energyMeV);
std::shared_ptr< GLogger > log
bool defineReadoutSpecsImpl() override
Defines readout specifications for dosimeter digitization.
std::unique_ptr< GDigitizedData > digitizeHitImpl(GHit *ghit, size_t hitn) override
Digitizes a hit for dosimeter detectors.
bool loadConstantsImpl(int runno, std::string const &variation) override
Loads digitization constants for dosimeter digitization.
std::shared_ptr< GOptions > gopts
Options used by the digitization plugin instance.
std::shared_ptr< const GReadoutSpecs > readoutSpecs
Readout specs are created during initialization and treated as immutable.
double getTotalEnergyDeposited()
void debug(debug_type type, Args &&... args) const
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
constexpr G4double picogray
std::filesystem::path gemc_root()