Skip to content

Commit 7c79e17

Browse files
matthias-kleinerwiechula
authored andcommitted
TPC: time gain calibration optimizations
- bug fix: using bin centre of the dE/dx instead of lower bin edge - add option to not perform per sector scaling (needed for MC)
1 parent 6d11591 commit 7c79e17

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

DataFormats/Detectors/TPC/include/DataFormatsTPC/CalibdEdxCorrection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class CalibdEdxCorrection
115115
/// Single fit parameters averaged over all sectors for a stack type
116116
float getMeanEntries(const GEMstack stack, ChargeType charge) const;
117117

118+
/// set all corrections to 1, used for default initialization and to reset corrections
119+
void setUnity();
120+
118121
#endif
119122

120123
private:

DataFormats/Detectors/TPC/src/CalibdEdxCorrection.cxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,16 @@ float CalibdEdxCorrection::getMeanEntries(const GEMstack stack, ChargeType charg
168168

169169
return mean / (SECTORSPERSIDE * SIDES);
170170
}
171+
172+
void CalibdEdxCorrection::setUnity()
173+
{
174+
for (int i = 0; i < FitSize; ++i) {
175+
for (int j = 0; j < ParamSize; ++j) {
176+
mParams[i][j] = 0.f;
177+
}
178+
mParams[i][0] = 1.f; // constant term = 1
179+
mChi2[i] = 0.f;
180+
mEntries[i] = 0;
181+
}
182+
mDims = 0;
183+
}

Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ class CalibdEdx
129129
/// Compute MIP position from dEdx histograms and save result in the correction container.
130130
/// To retrieve the correction call `CalibdEdx::getCalib()`
131131
/// \param useGausFits make gaussian fits of dEdx vs tgl instead of fitting the mean dEdx
132-
void finalize(const bool useGausFits = true);
132+
/// \param averageSectors If true, the correction is averaged over all sectors.
133+
/// In this case, no mean-sector scaling is applied when statistics are low.
134+
void finalize(const bool useGausFits = true, const bool averageSectors = false);
133135

134136
/// Return calib data histogram
135137
const Hist& getHist() const { return mHist; }

Detectors/TPC/calibration/src/CalibdEdx.cxx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ auto ProjectBoostHistoXFastAllSectors(const Hist& hist, std::vector<int>& bin_in
351351

352352
// access the bin content specified by bin_indices
353353
const float counts = hist.at(bin_indices);
354-
float dEdx = hist.axis(ax::dEdx).value(i);
354+
float dEdx = hist.axis(ax::dEdx).bin(i).center();
355355

356356
// scale the dedx to the mean
357357
if (stackMean != nullptr) {
@@ -532,7 +532,7 @@ void CalibdEdx::fitHistGaus(TLinearFitter& fitter, CalibdEdxCorrection& corr, co
532532
LOGP(info, "Calibration fits took: {}", time.count());
533533
}
534534

535-
void CalibdEdx::finalize(const bool useGausFits)
535+
void CalibdEdx::finalize(const bool useGausFits, const bool averageSectors)
536536
{
537537
const float entries = minStackEntries();
538538
mCalib.clear();
@@ -565,10 +565,15 @@ void CalibdEdx::finalize(const bool useGausFits)
565565
// get mean of each GEM stack
566566
CalibdEdxCorrection meanCorr{};
567567
meanCorr.setDims(0);
568-
TLinearFitter meanFitter(0);
569-
meanFitter.SetFormula("1");
570-
// get the mean dEdx for each stack
571-
fitHist(mHist, meanCorr, meanFitter, mFitCut, mFitLowCutFactor, mFitPasses);
568+
if (averageSectors) {
569+
// set mean dEdx per stack to unity
570+
meanCorr.setUnity();
571+
} else {
572+
// get the mean dEdx for each stack
573+
TLinearFitter meanFitter(0);
574+
meanFitter.SetFormula("1");
575+
fitHist(mHist, meanCorr, meanFitter, mFitCut, mFitLowCutFactor, mFitPasses, nullptr, mDebugOutputStreamer.get());
576+
}
572577
if (!useGausFits) {
573578
// get higher dimension corrections with projected sectors
574579
fitHist(mHist, mCalib, fitter, mFitCut, mFitLowCutFactor, mFitPasses, &meanCorr, mDebugOutputStreamer.get());

0 commit comments

Comments
 (0)