18 double timeWindow = 10;
19 double gridStartTime = 0;
21 double maxStep = 1 * CLHEP::mm;
24 readoutSpecs = std::make_shared<GReadoutSpecs>(timeWindow, gridStartTime, hitBitSet, maxStep,
log);
33 auto dose = etot / mass;
35 auto gdata = std::make_unique<GDigitizedData>(
gopts, ghit);
38 gdata->includeVariable(
"etot", etot / MeV);
71 [[maybe_unused]] std::string
const& variation) {
73 std::map<int, std::string> nielDataFiles;
74 nielDataFiles[11] =
"niel_electron.txt";
75 nielDataFiles[211] =
"niel_pion.txt";
76 nielDataFiles[2112] =
"niel_neutron.txt";
77 nielDataFiles[2212] =
"niel_proton.txt";
82 for (
const auto& [pid, filename] : nielDataFiles) {
83 std::string dataFileWithPath = gemcRoot.string() +
"/dosimeterData" +
"/Niel/" + filename;
85 std::ifstream inputfile(dataFileWithPath);
89 dataFileWithPath = gemcRoot.string() +
"/gdynamicDigitization/dosimeterData" +
"/Niel/" + filename;
90 inputfile.open(dataFileWithPath);
97 log->
info(1,
" Loading dosimeter data for pid <", pid,
"> from file ", dataFileWithPath);
101 while (inputfile >> p0 >> p1) {
102 nielfactorMap[pid].push_back(p0);
103 E_nielfactorMap[pid].push_back(p1);
109 pMassMeV[11] = 0.510;
110 pMassMeV[211] = 139.570;
111 pMassMeV[2112] = 939.565;
112 pMassMeV[2212] = 938.272;
118double GDosimeterDigitization::getNielFactorForParticleAtEnergy(
int pid,
double energyMeV) {
119 const auto niel_N = nielfactorMap[pid].size();
124 log->
error(EC__FILENOTFOUND,
"NIEL tables are empty for pid <", pid,
">. Did loadConstantsImpl fail?");
131 for (
size_t i = 0; i < niel_N; i++) {
132 if (energyMeV < E_nielfactorMap[pid][i]) {
140 if (j > 0 && j < niel_N) {
142 const auto nielfactor_low = nielfactorMap[pid][j - 1];
143 const auto nielfactor_high = nielfactorMap[pid][j];
144 const auto energy_low = E_nielfactorMap[pid][j - 1];
145 const auto energy_high = E_nielfactorMap[pid][j];
147 value = nielfactor_low +
148 ( nielfactor_high - nielfactor_low ) / ( energy_high - energy_low ) * ( energyMeV - energy_low );
152 value = nielfactorMap[pid].front();
156 value = nielfactorMap[pid].back();
159 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
std::bitset< NHITBITS > HitBitSet
constexpr G4double picogray
std::filesystem::path gemc_root()