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);
32 auto gdata = std::make_unique<GDigitizedData>(
gopts, ghit);
36 auto dose = etot / mass;
39 gdata->includeVariable(
"etot", etot / MeV);
72 [[maybe_unused]] std::string
const& variation) {
74 std::map<int, std::string> nielDataFiles;
75 nielDataFiles[11] =
"niel_electron.txt";
76 nielDataFiles[211] =
"niel_pion.txt";
77 nielDataFiles[2112] =
"niel_neutron.txt";
78 nielDataFiles[2212] =
"niel_proton.txt";
83 for (
const auto& [pid, filename] : nielDataFiles) {
84 std::string dataFileWithPath = gemcRoot.string() +
"/dosimeterData" +
"/Niel/" + filename;
86 std::ifstream inputfile(dataFileWithPath);
90 dataFileWithPath = gemcRoot.string() +
"/gdynamicDigitization/dosimeterData" +
"/Niel/" + filename;
91 inputfile.open(dataFileWithPath);
98 log->
info(1,
" Loading dosimeter data for pid <", pid,
"> from file ", dataFileWithPath);
102 while (inputfile >> p0 >> p1) {
103 nielfactorMap[pid].push_back(p0);
104 E_nielfactorMap[pid].push_back(p1);
110 pMassMeV[11] = 0.510;
111 pMassMeV[211] = 139.570;
112 pMassMeV[2112] = 939.565;
113 pMassMeV[2212] = 938.272;
119double GDosimeterDigitization::getNielFactorForParticleAtEnergy(
int pid,
double energyMeV) {
120 const auto niel_N = nielfactorMap[pid].size();
125 log->
error(EC__FILENOTFOUND,
"NIEL tables are empty for pid <", pid,
">. Did loadConstantsImpl fail?");
132 for (
size_t i = 0; i < niel_N; i++) {
133 if (energyMeV < E_nielfactorMap[pid][i]) {
141 if (j > 0 && j < niel_N) {
143 const auto nielfactor_low = nielfactorMap[pid][j - 1];
144 const auto nielfactor_high = nielfactorMap[pid][j];
145 const auto energy_low = E_nielfactorMap[pid][j - 1];
146 const auto energy_high = E_nielfactorMap[pid][j];
148 value = nielfactor_low +
149 ( nielfactor_high - nielfactor_low ) / ( energy_high - energy_low ) * ( energyMeV - energy_low );
153 value = nielfactorMap[pid].front();
157 value = nielfactorMap[pid].back();
160 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()