Skip to content

Commit 13fd76e

Browse files
added non-segmented version, with configurable choice
1 parent c58b43a commit 13fd76e

3 files changed

Lines changed: 50 additions & 27 deletions

File tree

Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper<DPLDigitizer
3232
int nSimSteps = 475; ///< number of steps in response simulation
3333
float energyToNElectrons = 1. / 3.6e-9; // conversion of eloss to Nelectrons
3434
int responseMatrixSize = 1; ///< size of the response matrix (odd number)
35+
bool performStepping = true; ///< flag to perform stepping simulation
3536

3637
std::string noiseFilePath{}; ///< optional noise masks file path. FIXME to be removed once switch to CCDBFetcher
3738

Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Digitizer : public TObject
9494
uint16_t row, uint16_t col, int nElectrons, o2::MCCompLabel& label);
9595

9696
void stepping(const o2::itsmft::Hit& hit, float**& respMatrix, int& rowStart, int& colStart, int& rowSpan, int& colSpan);
97+
void responseInTheMiddle(const o2::itsmft::Hit& hit, int& row, int& col);
9798

9899
/// Apply time smearing to simulate detector resolution
99100
double smearTime(double time) const;

Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -126,51 +126,55 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID)
126126
double absoluteTime = hitTime + eventTimeNS; // absolute time
127127
double smearedTime = smearTime(absoluteTime); // apply detector resolution
128128

129-
// For now, use simple row/col mapping from detector ID
130-
// TODO: Implement proper segmentation when geometry is finalized
131-
uint16_t chipIndex = static_cast<uint16_t>(chipID);
132-
133129
if (chipID < 0 || chipID >= mGeometry->getSize() || mGeometry->getSize() < 1) {
134130
LOG(debug) << "Invalid detector ID: " << chipID << ", geometry size: " << mGeometry->getSize();
135131
return; // invalid detector ID
136132
}
137-
138-
// stepping is called here
139-
float** respMatrix = nullptr;
140-
int rowStart = 0, colStart = 0, rowSpan = 0, colSpan = 0;
141-
stepping(hit, respMatrix, rowStart, colStart, rowSpan, colSpan);
142-
133+
143134
// Create the digit with time information
144135
o2::MCCompLabel label(hit.GetTrackID(), evID, srcID, false);
145136
const int roFrameAbs = 0; // For now, we can set this to 0 or calculate based on time if needed
146137
const int nROF = 1; // For now, we can assume the signal is contained in one ROF, this can be extended to multiple ROFs based on the time
147-
for (int irow = rowSpan; irow--;) {
148-
uint16_t rowIS = irow + rowStart;
149-
for (int icol = colSpan; icol--;) {
150-
uint16_t colIS = icol + colStart;
151-
float nEleResp = respMatrix[irow][icol];
152-
if (!nEleResp) {
153-
continue;
138+
139+
140+
if (digitizerParams.performStepping) {
141+
float** respMatrix = nullptr;
142+
int rowStart = 0, colStart = 0, rowSpan = 0, colSpan = 0;
143+
stepping(hit, respMatrix, rowStart, colStart, rowSpan, colSpan);
144+
145+
for (int irow = rowSpan; irow--;) {
146+
uint16_t rowIS = irow + rowStart;
147+
for (int icol = colSpan; icol--;) {
148+
uint16_t colIS = icol + colStart;
149+
float nEleResp = respMatrix[irow][icol];
150+
if (!nEleResp) {
151+
continue;
152+
}
153+
const int nElectronsSampled = gRandom->Poisson(electronsPerStep * nEleResp);
154+
// Noise can be added here if needed
155+
156+
registerDigits(chip, roFrameAbs, smearedTime, nROF,
157+
static_cast<uint16_t>(rowIS), static_cast<uint16_t>(colIS), nElectronsSampled, label);
154158
}
155-
int nElectronsSampled = gRandom->Poisson(electronsPerStep * nEleResp);
156-
// Noise can be added here if needed
157-
158-
registerDigits(chip, roFrameAbs, smearedTime, nROF,
159-
static_cast<uint16_t>(rowIS), static_cast<uint16_t>(colIS), nElectronsSampled, label);
160159
}
161-
}
162160

163-
for (int irow = 0; irow < rowSpan; ++irow) {
164-
delete[] respMatrix[irow];
161+
for (int irow = 0; irow < rowSpan; ++irow) {
162+
delete[] respMatrix[irow];
163+
}
164+
delete[] respMatrix;
165+
} else {
166+
int row = 0, col = 0;
167+
responseInTheMiddle(hit, row, col);
168+
const int nElectronsSampled = gRandom->Poisson(charge);
169+
registerDigits(chip, roFrameAbs, smearedTime, nROF, static_cast<uint16_t>(row), static_cast<uint16_t>(col), nElectronsSampled, label);
165170
}
166-
delete[] respMatrix;
167171
}
168172

169173
void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, int& rowStart, int& colStart, int& rowSpan, int& colSpan)
170174
{
171175
const auto& matrix = mGeometry->getMatrixL2G(hit.GetDetectorID());
172176
const int chipID = hit.GetDetectorID();
173-
const int subdetectorID = mGeometry->getIOTOFLayer();
177+
const int subdetectorID = mGeometry->getIOTOFLayer(chipID);
174178

175179
auto xyzPositionStart(matrix ^ (hit.GetPosStart())); // start position in sensor frame
176180
auto xyzPositionEnd(matrix ^ (hit.GetPos())); // end position in sensor frame
@@ -256,6 +260,23 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, int& r
256260
}
257261
}
258262

263+
void Digitizer::responseInTheMiddle(const o2::itsmft::Hit& hit, int& row, int& col)
264+
{
265+
const auto& matrix = mGeometry->getMatrixL2G(hit.GetDetectorID());
266+
const int chipID = hit.GetDetectorID();
267+
268+
math_utils::Vector3D<float> xyzPositionStart(matrix ^ (hit.GetPosStart())); // start position in sensor frame
269+
math_utils::Vector3D<float> xyzPositionEnd(matrix ^ (hit.GetPos())); // end position in sensor frame
270+
271+
// Calculate the middle position of the hit
272+
math_utils::Vector3D<float> xyzPositionMiddle = (xyzPositionStart + xyzPositionEnd) * 0.5f;
273+
274+
if (!sSegmentation->localToDetector(xyzPositionMiddle.X(), xyzPositionMiddle.Z(), row, col, mGeometry->getIOTOFLayer(chipID))) {
275+
LOG(debug) << "Hit position out of bounds for detector ID " << chipID;
276+
return; // hit is outside the active area
277+
}
278+
}
279+
259280
//_______________________________________________________________________
260281
double Digitizer::smearTime(double time) const
261282
{

0 commit comments

Comments
 (0)