30bool system_in_rejection_list(
const std::shared_ptr<GOptions>& gopts,
const std::string& option,
31 const std::string& systemName) {
32 auto list_option = gopts->getOptionalScalarString(option);
33 if (!list_option || list_option->empty()) {
return false; }
34 std::string list = std::move(*list_option);
35 std::replace(list.begin(), list.end(),
',',
' ');
37 if (name ==
"all" || name == systemName) {
return true; }
47 auto trueInfoData = std::make_unique<GTrueInfoData>(
gopts, ghit);
49 std::vector<GIdentifier> identities = ghit->
getGID();
56 const auto missingMotherVertex = G4ThreeVector(
60 const G4ThreeVector motherTrackVertex = motherInfo.vertex.value_or(missingMotherVertex);
62 trueInfoData->includeVariable(
"pid", ghit->
getPid());
64 trueInfoData->includeVariable(
"tid", ghit->
getTid());
65 trueInfoData->includeVariable(
"otid", 0);
66 trueInfoData->includeVariable(
"opid", 0);
67 trueInfoData->includeVariable(
"opx", 0.0);
68 trueInfoData->includeVariable(
"opy", 0.0);
69 trueInfoData->includeVariable(
"opz", 0.0);
70 trueInfoData->includeVariable(
"mtid", motherInfo.trackId);
72 trueInfoData->includeVariable(
"trackE", ghit->
getTrackE());
74 trueInfoData->includeVariable(
"avgx", avgGlobalPos.getX());
75 trueInfoData->includeVariable(
"avgy", avgGlobalPos.getY());
76 trueInfoData->includeVariable(
"avgz", avgGlobalPos.getZ());
77 trueInfoData->includeVariable(
"avglx", avgLocalPos.getX());
78 trueInfoData->includeVariable(
"avgly", avgLocalPos.getY());
79 trueInfoData->includeVariable(
"avglz", avgLocalPos.getZ());
80 trueInfoData->includeVariable(
"vx", trackVertex.getX());
81 trueInfoData->includeVariable(
"vy", trackVertex.getY());
82 trueInfoData->includeVariable(
"vz", trackVertex.getZ());
83 trueInfoData->includeVariable(
"mvx", motherTrackVertex.getX());
84 trueInfoData->includeVariable(
"mvy", motherTrackVertex.getY());
85 trueInfoData->includeVariable(
"mvz", motherTrackVertex.getZ());
88 trueInfoData->includeVariable(
"px", momentum.getX());
89 trueInfoData->includeVariable(
"py", momentum.getY());
90 trueInfoData->includeVariable(
"pz", momentum.getZ());
92 trueInfoData->includeVariable(
"nsteps",
static_cast<int>(ghit->
getStepCount()));
94 trueInfoData->includeVariable(
"hitn",
static_cast<int>(hitn));
97 trueInfoData->includeVariable(
"processName", processName);
98 trueInfoData->includeVariable(
"procID", processName);
113 std::vector<int> haddress = electronics.
getHAddress();
125 for (
const auto& tname : touchableNames) {
126 modifierWeightsMap[tname] = {};
133 modifierWeightsMap[touchableName].push_back(idValue);
134 modifierWeightsMap[touchableName].push_back(weight);
141 modifierWeightsAndTimesMap[touchableName].push_back(idValue);
142 modifierWeightsAndTimesMap[touchableName].push_back(weight);
143 modifierWeightsAndTimesMap[touchableName].push_back(time);
149 size_t countWeights = modifierWeightsMap[tname].size() / 2;
150 for (
size_t h = 0; h < countWeights; h++) {
151 modifierWeightsMap[tname][h * 2 + 1] = modifierWeightsMap[tname][h * 2 + 1] / totalWeight;
155 size_t countWeightsAndTimes = modifierWeightsAndTimesMap[tname].size() / 3;
156 for (
size_t h = 0; h < countWeightsAndTimes; h++) {
157 modifierWeightsAndTimesMap[tname][h * 3 + 1] = modifierWeightsAndTimesMap[tname][h * 3 + 1] / totalWeight;
163 [[maybe_unused]] G4Step* thisStep) {
165 return thisStep->GetPostStepPoint()->GetGlobalTime();
170 std::shared_ptr<GTouchable>
gtouchable, G4Step* thisStep) {
172 int stepTimeAtElectronicsIndex =
readoutSpecs->timeCellIndex(stepTimeAtElectronics);
174 std::vector<std::shared_ptr<GTouchable>> result;
178 const auto& assignedTimeIndex =
gtouchable->getStepTimeAtElectronicsIndex();
179 if (!assignedTimeIndex || stepTimeAtElectronicsIndex == *assignedTimeIndex) {
180 gtouchable->assignStepTimeAtElectronicsIndex(stepTimeAtElectronicsIndex);
185 auto cloned = std::make_shared<GTouchable>(
gtouchable, stepTimeAtElectronicsIndex);
189 result.emplace_back(cloned);
197 [[maybe_unused]]
const std::shared_ptr<GTouchable>& gTouchID,
200 std::vector<std::shared_ptr<GTouchable>> touchables;
206 applyThresholds_ = system_in_rejection_list(
gopts,
"applyThresholds", systemName);
207 applyInefficiencies_ = system_in_rejection_list(
gopts,
"applyInefficiencies", systemName);
std::shared_ptr< GLogger > log
void includeVariable(const std::string &vname, int value)
std::shared_ptr< GOptions > gopts
Options used by the digitization plugin instance.
virtual std::unique_ptr< GTrueInfoData > collectTrueInformationImpl(GHit *ghit, size_t hitn)
Implementation hook for true-information collection.
double processStepTime(const std::shared_ptr< GTouchable > &gTouchID, G4Step *thisStep)
Computes the time associated with a simulation step for electronics binning.
virtual std::vector< std::shared_ptr< GTouchable > > processGTouchableModifiersImpl(const std::shared_ptr< GTouchable > &gTouchID, const GTouchableModifiers &gmods)
Implementation hook for touchable modifier application.
void check_if_log_defined() const
Ensures options/logging are configured before plugin methods run.
virtual double processStepTimeImpl(const std::shared_ptr< GTouchable > &gTouchID, G4Step *thisStep)
Implementation hook for step time computation.
std::shared_ptr< const GTranslationTable > translationTable
Translation table is typically loaded during initialization and treated as immutable.
virtual std::vector< std::shared_ptr< GTouchable > > processTouchableImpl(std::shared_ptr< GTouchable > gtouchable, G4Step *thisStep)
Implementation hook for touchable processing.
std::shared_ptr< const GReadoutSpecs > readoutSpecs
Readout specs are created during initialization and treated as immutable.
void setHitRejectionPolicies(const std::string &systemName)
Resolves this routine's hit-rejection policies from the global options.
void chargeAndTimeAtHardware(int time, int q, const GHit *ghit, GDigitizedData &gdata)
Adds hardware-level time/charge and address fields to a digitized record.
const std::optional< std::string > & getProcessName() const
size_t getStepCount() const
G4ThreeVector getMomentum() const
double getTotalEnergyDeposited() const
const MotherInfo & getMotherInfo() const
std::vector< GIdentifier > getGID() const
std::vector< int > getTTID() const
double getAverageTime() const
size_t getNumberOfOpticalPhotons() const
G4ThreeVector getTrackVertexPosition() const
G4ThreeVector getAvgLocalPosition() const
G4ThreeVector getAvgGlobalPosition() const
Helper container for representing touchable “modifier” information.
void insertIdAndWeight(const std::string &touchableName, int idValue, double weight)
Inserts a new (id, weight) pair for the specified touchable.
void insertIdWeightAndTime(const std::string &touchableName, int idValue, double weight, double time)
Inserts a new (id, weight, time) triplet for the specified touchable.
void assignOverallWeight(const std::string &touchableName, double totalWeight)
Normalizes modifier weights by dividing by a provided total.
GTouchableModifiers(const std::vector< std::string > &touchableNames)
Constructs the container and declares supported touchable names.
constexpr const char * TIMEATELECTRONICS
constexpr const char * CRATESTRINGID
constexpr const char * CHANNELSTRINGID
constexpr const char * SLOTSTRINGID
constexpr const char * CHARGEATELECTRONICS
Exit/error codes used by gdynamic digitization.
constexpr int MISSING_TRUE_INFORMATION_NUMBER
constexpr int EC__TTNOTFOUNDINTT
vector< std::string > getStringVectorFromString(const std::string &input)
constexpr char SERIALIZED_NULL_TOKEN[]
std::vector< int > getHAddress() const