62 default:
return "unknown-gtouchable";
86 GIdentifier(
const std::string& n,
int v) : idName{n}, idValue{v} {
103 [[nodiscard]]
inline std::string
getName()
const {
return idName; }
109 [[nodiscard]]
inline int getValue()
const {
return idValue; }
158 GTouchable(
const std::shared_ptr<GOptions>& gopt,
159 const std::string& digitization,
160 const std::string& gidentityString,
161 const std::vector<double>& dimensions);
174 GTouchable(
const std::shared_ptr<GLogger>& logger,
175 const std::string& digitization,
176 const std::string& gidentityString,
177 const std::vector<double>& dimensions);
191 GTouchable(
const std::shared_ptr<GTouchable>& base,
int newTimeIndex)
194 gidentity(base->gidentity),
195 trackId(base->trackId),
196 eMultiplier(base->eMultiplier),
197 stepTimeAtElectronicsIndex(newTimeIndex) {
255 [[nodiscard]]
inline std::vector<GIdentifier>
getIdentity()
const {
return gidentity; }
266 std::string idString;
267 for (
const auto&
id : gidentity) { idString +=
id.getName() +
": " + std::to_string(
id.getValue()) +
" "; }
290 for (
const auto& gt : v) {
292 log->
info(2,
"GTouchable",
this,
" exists in vector.");
296 log->
info(2,
"GTouchable",
this,
" does not exist in vector.");
311 static std::shared_ptr<GTouchable>
create(
const std::shared_ptr<GOptions>& gopt) {
312 int touchableNumber = globalGTouchableCounter.fetch_add(1, std::memory_order_relaxed);
313 int sector = (touchableNumber % 6) + 1;
314 int paddle = (touchableNumber % 20) + 1;
315 std::string identity =
"sector: " + std::to_string(sector) +
", paddle: " + std::to_string(paddle);
316 const auto& dimensions = {10.0, 20.0, 30.0};
318 return std::make_shared<GTouchable>(gopt,
"readout", identity, dimensions);
331 static std::shared_ptr<GTouchable>
create(
const std::shared_ptr<GLogger>& logger) {
332 int touchableNumber = globalGTouchableCounter.fetch_add(1, std::memory_order_relaxed);
333 int sector = (touchableNumber % 6) + 1;
334 int paddle = (touchableNumber % 20) + 1;
335 std::string identity =
"sector: " + std::to_string(sector) +
", paddle: " + std::to_string(paddle);
336 const auto& dimensions = {10.0, 20.0, 30.0};
338 return std::make_shared<GTouchable>(logger,
"readout", identity, dimensions);
343 std::vector<GIdentifier> gidentity;
346 int stepTimeAtElectronicsIndex;
347 std::vector<double> detectorDimensions;
353 static std::atomic<int> globalGTouchableCounter;
std::shared_ptr< GLogger > log
void debug(debug_type type, Args &&... args) const
void info(int level, Args &&... args) const
Represents a touchable sensitive detector element used as a hit-collection discriminator.
GTouchable(const GTouchable &)=default
static std::shared_ptr< GTouchable > create(const std::shared_ptr< GOptions > &gopt)
Creates a synthetic readout touchable for testing (options-based).
std::vector< GIdentifier > getIdentity() const
Returns a copy of the identity vector.
~GTouchable()
Destructor with debug trace.
bool operator==(const GTouchable >ouchable) const
Compares two GTouchable instances using the module comparison semantics.
void assignTrackId(int tid)
Assigns the track id used by flux and dosimeter discrimination.
void assignStepTimeAtElectronicsIndex(int timeIndex)
Assigns the electronics time-cell index used by readout discrimination.
friend std::ostream & operator<<(std::ostream &stream, const GTouchable >ouchable)
Stream output helper used in logs and diagnostics.
double getEnergyMultiplier() const
Returns the energy multiplier used for energy sharing.
static std::shared_ptr< GTouchable > create(const std::shared_ptr< GLogger > &logger)
Creates a synthetic readout touchable for testing (logger-based).
GTouchable & operator=(const GTouchable &)=default
int getStepTimeAtElectronicsIndex() const
Returns the electronics time-cell index.
bool exists_in_vector(const std::vector< GTouchable > &v) const
Checks whether this touchable exists in a vector using operator== semantics.
std::string getIdentityString() const
Builds a human-readable identity string from the stored identifiers.
std::vector< double > getDetectorDimensions() const
Returns the detector dimensions stored at construction time.
GTouchable(const std::shared_ptr< GTouchable > &base, int newTimeIndex)
Copy constructor that preserves identity but updates the electronics time-cell index.
Conventions and constants used by the gtouchable module.
#define FLUXNAME
Digitization type name for flux-like detectors.
#define DOSIMETERNAME
Digitization type name for dosimeters.
#define COUNTERNAME
Digitization type name for simple particle counters.
GTouchableType
Enumeration representing the type of a touchable sensitive element.
@ flux
Flux-like discrimination using track id.
@ particleCounter
Identity vector only; no additional discriminating factor.
@ readout
Electronic readout with time-window discrimination (time-cell index).
@ dosimeter
Radiation digitization; discrimination using track id.
Options definition entry point for the gtouchable module.
const char * to_string(GTouchableType t)
Converts a GTouchableType value to a stable string for logging.
A single (name,value) identifier element used to build a touchable identity vector.
GIdentifier(const std::string &n, int v)
Constructs a GIdentifier.
friend std::ostream & operator<<(std::ostream &stream, const GIdentifier &gidentifier)
Stream output helper used in logs and diagnostics.
std::string getName() const
Returns the identifier name.
bool operator==(const GIdentifier &gid) const
Compares identifiers by value only.
int getValue() const
Returns the identifier value.