Skip to content

Commit 999225e

Browse files
committed
Improve digit efficiency in stepping
1 parent e96811d commit 999225e

2 files changed

Lines changed: 33 additions & 31 deletions

File tree

‎Detectors/Upgrades/ALICE3/IOTOF/macros/CheckDigitsIOTOF.C‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ void addTLines(float pitch)
7575
gPad->Update();
7676
}
7777

78-
void CheckDigitsIOTOF(std::string digifile = "tf3digits.root", std::string hitfile = "o2sim_HitsTF3.root", std::string inputGeom = "o2sim_geometry.root")
78+
void CheckDigitsIOTOF(std::string digifile = "tf3digits.root", std::string hitfile = "o2sim_HitsTF3.root", std::string inputGeom = "o2sim_geometry.root",
79+
std::string cfgStr = "IOTOFBase.segmentedInnerTOF=true;IOTOFBase.segmentedOuterTOF=true;IOTOFBase.enableForwardTOF=false;IOTOFBase.enableBackwardTOF=false;")
7980
{
8081
gStyle->SetPalette(55);
8182

@@ -85,7 +86,7 @@ void CheckDigitsIOTOF(std::string digifile = "tf3digits.root", std::string hitfi
8586
using o2::iotof::Digit;
8687
using o2::itsmft::Hit;
8788

88-
o2::conf::ConfigurableParam::updateFromString("IOTOFBase.segmentedInnerTOF=true;IOTOFBase.segmentedOuterTOF=true;IOTOFBase.enableForwardTOF=false;IOTOFBase.enableBackwardTOF=false");
89+
o2::conf::ConfigurableParam::updateFromString(cfgStr);
8990

9091
auto seg = o2::iotof::Segmentation::Instance();
9192

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

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -110,38 +110,12 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID)
110110
return;
111111
}
112112

113-
// middle position of the hit in the sensor frame
114-
const auto& matrix = mGeometry->getMatrixL2G(chipID);
115-
auto xyzPositionStart = matrix ^ hit.GetPosStart();
116-
auto xyzPositionEnd = matrix ^ hit.GetPos();
117-
const auto xMid = 0.5f * (xyzPositionStart.X() + xyzPositionEnd.X());
118-
const auto zMid = 0.5f * (xyzPositionStart.Z() + xyzPositionEnd.Z());
119-
// move this to the local pixel coordinates for the efficiency map
120-
int row, col;
121-
float xPixelCenter, zPixelCenter;
122-
if (!sSegmentation->localToDetector(xMid, zMid, row, col, mGeometry->getIOTOFLayer(chipID))) {
123-
LOG(debug) << "Hit rejected because position (" << xMid << ", " << zMid << ") is outside the active area of chip " << chipID;
124-
return; // hit is outside the active area
125-
}
126-
sSegmentation->detectorToLocalUnchecked(row, col, xPixelCenter, zPixelCenter, mGeometry->getIOTOFLayer(chipID));
127-
128-
if (!isEfficient(xMid - xPixelCenter, zMid - zPixelCenter)) {
129-
LOG(debug) << "Hit rejected by efficiency cut";
130-
return;
131-
}
132-
133113
// Convert energy loss to charge (number of electrons)
134114
float energyLoss = hit.GetEnergyLoss(); // in GeV
135115
int charge = energyToCharge(energyLoss);
136116
const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance();
137117
int electronsPerStep = static_cast<int>(charge / digitizerParams.nSimSteps);
138118

139-
// Apply charge threshold
140-
if (charge < digitizerParams.chargeThreshold) {
141-
LOG(debug) << "Hit rejected by charge threshold: " << charge << " < " << digitizerParams.chargeThreshold;
142-
return;
143-
}
144-
145119
// Get hit time and apply smearing
146120
// Hit time is in seconds, convert to ns and add event time
147121
double hitTime = hit.GetTime() * sec2ns; // convert to ns
@@ -172,6 +146,11 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID)
172146
continue;
173147
}
174148
const int nElectronsSampled = gRandom->Poisson(electronsPerStep * nEleResp);
149+
// Apply charge threshold cut taking into account fraction of charge in the pixel
150+
if (nElectronsSampled < digitizerParams.chargeThreshold) {
151+
LOG(debug) << "Hit rejected by charge threshold: " << nElectronsSampled << " < " << digitizerParams.chargeThreshold;
152+
continue;
153+
}
175154
// Noise can be added here if needed
176155

177156
registerDigits(chip, roFrameAbs, smearedTime, nROF,
@@ -242,22 +221,44 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, int& r
242221
respMatrix[i] = new float[colSpan]();
243222
}
244223

245-
int rowPrev = -1, colPrev = -1, row = 0, col = 0;
246224
if (!respMatrix || rowSpan <= 0 || colSpan <= 0) {
247225
return;
248226
}
249227
if (nSkip) {
250228
nSteps -= nSkip;
251229
}
252230

231+
int rowPrev = -1, colPrev = -1, row = 0, col = 0;
253232
auto& currentPosLocal = xyzPositionStart;
233+
float xPixelCenter, zPixelCenter;
254234
for (int iStep = nSteps; iStep--;) {
255-
sSegmentation->localToDetector(currentPosLocal.X(), currentPosLocal.Z(), row, col, subdetectorID);
235+
236+
// Check whether the mid-position of the step is within the active area of the chip
237+
if (!sSegmentation->localToDetector(currentPosLocal.X(), currentPosLocal.Z(), row, col, subdetectorID)) {
238+
LOG(debug) << "Step is in passive area: (" << currentPosLocal.X() << ", " << currentPosLocal.Z() << ") is outside the active area of chip " << subdetectorID;
239+
currentPosLocal += stepVector;
240+
continue;
241+
}
242+
243+
// Update the pixel center coordinates if the row or column has changed
256244
if (row != rowPrev || col != colPrev) {
245+
if (!sSegmentation->detectorToLocal(row, col, xPixelCenter, zPixelCenter, subdetectorID)) {
246+
LOG(debug) << "Failed to get pixel center for row " << row << ", col " << col << ", chip " << chipID;
247+
currentPosLocal += stepVector;
248+
continue;
249+
}
257250
rowPrev = row;
258251
colPrev = col;
259252
}
260253

254+
// Apply efficiency cut based on the step position relative to the pixel center
255+
if (!isEfficient(currentPosLocal.X() - xPixelCenter, currentPosLocal.Z() - zPixelCenter)) {
256+
LOG(debug) << "Step rejected by efficiency cut";
257+
currentPosLocal += stepVector;
258+
continue;
259+
}
260+
261+
LOG(debug) << "Step accepted: (" << currentPosLocal.X() << ", " << currentPosLocal.Z() << ") in chip " << subdetectorID;
261262
currentPosLocal += stepVector; // Move to the next step position
262263

263264
for (int irow = digitizerParams.responseMatrixSize; irow--;) {
@@ -407,7 +408,7 @@ void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nR
407408
int tdc = int((time - nbc * o2::constants::lhc::LHCBunchSpacingNS) / digitizerParams.tdcBin);
408409
nbc += mEventTime.toLong();
409410

410-
LOG(debug) << nbc << "\t" << tdc;
411+
LOG(debug) << "nbc: " << nbc << "\ttdc: " << tdc;
411412
double absoluteTime = tdc * digitizerParams.tdcBin * 1.e-9 + nbc * o2::constants::lhc::LHCBunchSpacingNS;
412413

413414
auto key = o2::iotof::Digit::getOrderingKey(nbc, row, col);

0 commit comments

Comments
 (0)