Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Detectors/TPC/base/include/TPCBase/ParameterDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct ParameterDetector : public o2::conf::ConfigurableParamHelper<ParameterDet
bool ExcludeFCGap = true; ///< exclude electrons created in the gap between the IFC vessel and OFC vessel and FC strips
bool UseGeant4Edep = false; ///< use Geant4 energy deposit directly for ionisation (for Kr-83m calibration runs)
float SpecialCutsGeV = 1e-6f; ///< CUTELE/CUTGAM/DCUTE/BCUTE applied to TPC drift-gas media by SetSpecialPhysicsCuts() when UseGeant4Edep is set (Kr-83m calibration isolation test); default 1e-6 GeV (1 keV) matches the prior hardcoded value
float TransferLogSlope = 0.f; ///< dE/dx transfer correction in simulation: the primary-collision rate is divided by R(x) = 1 + TransferLogSlope * ln(x), x = z^2 * BB(bg) / BB_min clamped to [1, TransferXMax] (ionisation in units of minimum ionisation; BB = BetheBlochParam, which must describe the truncated-mean dE/dx measured in data). Use the correction slope fitted against the reconstructed ionisation. 0 (default): off
float TransferXMax = 6.f; ///< upper limit of x in the dE/dx transfer correction (fit range: R is constant above it, no extrapolation); must be >= 1

O2ParamDef(ParameterDetector, "TPCDetParam");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class Detector : public o2::base::DetImpl<Detector>
int mElectronCounter = 0;
int mStepCounter = 0;
double mLastReferenceR = 0; ///<! track length at the last stored track reference (cm)
double mBetheBlochMin = 1.; ///<! minimum of BetheBlochAleph(bg) with the TPCGasParam parameters, normalisation of x in the dE/dx transfer correction
ElementalHit mHitLast{}; ///<! buffer last processed hit to be able to fill it to mHitsPerSectorCollection
HitGroup* mCurrentGroup = nullptr; ///<! hit group currently being filled
int mOldTrackId = -1; ///<! track of the current hit group
Expand Down
40 changes: 36 additions & 4 deletions Detectors/TPC/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

#include <iostream>
#include <cmath>
#include <algorithm>
#include "DetectorsBase/SimRandom.h"

using std::cout;
Expand Down Expand Up @@ -83,6 +84,7 @@ Detector::Detector(const Detector& rhs)
mHitCounter(0),
mElectronCounter(0),
mStepCounter(0),
mBetheBlochMin(rhs.mBetheBlochMin),
mGeoFileName(rhs.mGeoFileName)
{
for (int i = 0; i < Sector::MAXSECTOR; ++i) {
Expand All @@ -105,6 +107,26 @@ void Detector::InitializeO2Detector()
{
// Define the list of sensitive volumes
defineSensitiveVolumes();

// dE/dx transfer correction: R(x) = 1 + c ln(x), x = z^2 BB / BB_min in [1, xMax]
const auto& detParam = ParameterDetector::Instance();
if (detParam.TransferLogSlope != 0.f) {
// minimum of the Bethe-Bloch parametrisation used by the ionisation model: scan in log(bg), bg 0.1 - 1e4
const auto& bbPar = ParameterGas::Instance().BetheBlochParam;
mBetheBlochMin = 1.e30;
for (int i = 0; i <= 4000; ++i) {
const double bg = std::pow(10., -1. + 5. * i / 4000.);
mBetheBlochMin = std::min(mBetheBlochMin, BetheBlochAleph(bg, double(bbPar[0]), double(bbPar[1]), double(bbPar[2]), double(bbPar[3]), double(bbPar[4])));
}
const double ratioAtMax = 1. + detParam.TransferLogSlope * std::log(std::max(detParam.TransferXMax, 1.f));
if (!(mBetheBlochMin > 0.) || !(detParam.TransferXMax >= 1.f) || !(ratioAtMax > 0.)) {
LOG(fatal) << "TPC dE/dx transfer correction: invalid settings, BB_min = " << mBetheBlochMin << ", TransferXMax = " << detParam.TransferXMax
<< " (must be >= 1), R(xMax) = " << ratioAtMax << " (must be > 0)";
}
LOG(info) << "TPC dE/dx transfer correction ON: primary-collision rate divided by R(x) = 1 + " << detParam.TransferLogSlope
<< " * ln(x), x = z^2 BB / BB_min clamped to [1, " << detParam.TransferXMax << "], BB_min = " << mBetheBlochMin
<< ", R(xMax) = " << ratioAtMax;
}
}

Bool_t Detector::ProcessHits(FairVolume* vol)
Expand Down Expand Up @@ -240,10 +262,20 @@ Bool_t Detector::ProcessHits(FairVolume* vol)
numberOfElectrons = static_cast<int>(fMC->Edep() / static_cast<double>(gasParam.Wion));
} else {
// ---| number of primary ionisations per cm (zero-length steps give no collisions) |---
const double primaryElectronsPerCM =
gasParam.Nprim * BetheBlochAleph(static_cast<float>(TMath::Max(betaGamma, minBetaGamma)), gasParam.BetheBlochParam[0],
gasParam.BetheBlochParam[1], gasParam.BetheBlochParam[2],
gasParam.BetheBlochParam[3], gasParam.BetheBlochParam[4]);
// float, as before: with the transfer correction off the product is bit-identical to the previous code
const float betheBloch = BetheBlochAleph(static_cast<float>(TMath::Max(betaGamma, minBetaGamma)), gasParam.BetheBlochParam[0],
gasParam.BetheBlochParam[1], gasParam.BetheBlochParam[2],
gasParam.BetheBlochParam[3], gasParam.BetheBlochParam[4]);
double primaryElectronsPerCM = gasParam.Nprim * betheBloch;

// ---| optional dE/dx transfer correction: divide by R(x) = 1 + c ln(x), x = z^2 BB / BB_min in [1, xMax] (default c = 0: off) |---
// The reconstructed truncated-mean dE/dx / input rises with the ionisation (truncated-mean statistics);
// dividing the input by R makes the reconstructed dE/dx follow the input Bethe-Bloch.
if (detParam.TransferLogSlope != 0.f) {
const double xIon = trackCharge * trackCharge * betheBloch / mBetheBlochMin;
const double xClamped = std::min(std::max(xIon, 1.), static_cast<double>(detParam.TransferXMax));
primaryElectronsPerCM /= 1. + detParam.TransferLogSlope * std::log(xClamped);
}

// ---| mean number of collisions and random for this event |---
const double meanNcoll = stepSize * trackCharge * trackCharge * primaryElectronsPerCM;
Expand Down