32 mKTime = settings.kTime;
33 mITMultFactor = settings.ITMultFactor;
34 LOGP(info,
"IT settings: kTime = {}, ITMultFactor = {}, padITCorrFile = {}",
35 settings.kTime, settings.ITMultFactor, settings.padITCorrFile);
37 if (!settings.padITCorrFile.empty()) {
60 float kAmp = std::abs(mITMultFactor) * 0.1276;
61 if (mITMultFactor < 0) {
62 kAmp = kAmp / (1 + kAmp);
66 float tailSlopeUnit = std::exp(-kTime);
68 for (
auto& digit :
digits) {
69 const auto sector =
CRU(digit.getCRU()).
sector();
70 const auto row = digit.getRow();
71 const auto pad = digit.getPad();
72 const auto time = digit.getTimeStamp();
75 kAmp = mFraction->getValue(sector,
row, pad) * std::abs(mITMultFactor);
76 if (mITMultFactor < 0) {
77 kAmp = kAmp / (1 + kAmp);
81 tailSlopeUnit = mExpLambda->getValue(sector,
row, pad);
82 kTime = -std::log(tailSlopeUnit);
93 auto origCuml = cumul;
94 cumul *= tailSlopeUnit;
97 streamData(digit.getCRU(),
row, pad,
time,
lastTime, kAmp, kTime, tailSlopeUnit, origCuml, cumul, 0, 0);
108 const auto origCharge = digit.getChargeFloat();
109 const auto charge = origCharge + mSign * kAmp * (1 - tailSlopeUnit) * cumul;
112 const auto origCuml = cumul;
114 cumul *= tailSlopeUnit;
117 streamData(digit.getCRU(),
row, pad,
time,
lastTime, kAmp, kTime, tailSlopeUnit, origCuml, cumul, origCharge,
charge);
132 std::sort(
digits.begin(),
digits.end(), [](
const auto&
a,
const auto&
b) {
133 if (a.getRow() < b.getRow()) {
136 if (
a.getRow() ==
b.getRow()) {
137 if (a.getPad() < b.getPad()) {
139 }
else if (
a.getPad() ==
b.getPad()) {
140 return a.getTimeStamp() < b.getTimeStamp();
150 std::sort(
digits.begin(),
digits.end(), [](
const auto&
a,
const auto&
b) {
151 if (a.getTimeStamp() < b.getTimeStamp()) {
154 if (
a.getTimeStamp() ==
b.getTimeStamp()) {
155 if (a.getRow() < b.getRow()) {
157 }
else if (
a.getRow() ==
b.getRow()) {
158 return a.getPad() < b.getPad();
167 if (!std::filesystem::exists(itParamFile)) {
168 LOGP(fatal,
"Could not find IF param file {}", itParamFile);
173 LOGP(fatal,
"Could not read IT fraction object from file {}", itParamFile);
176 LOGP(fatal,
"Could not read IT expLambda object from file {}", itParamFile);
179 mFraction.reset(calDets[0]);
180 mExpLambda.reset(calDets[1]);
182 LOGP(info,
"Loaded ion tail correction values from file {}", itParamFile);
185void IonTailCorrection::streamData(
int cru,
int row,
int pad,
int time,
int lastTime,
float kAmp,
float kTime,
float tailSlopeUnit,
float origCumul,
float cumul,
float origCharge,
float charge)
187 mStreamer.setStreamer(
"debug_ITCorr",
"UPDATE");
189 mStreamer.getStreamer()
198 <<
"tailSlopeUnit=" << tailSlopeUnit
199 <<
"itMultFactor=" << mITMultFactor
201 <<
"origCharge=" << origCharge
Implementation of the ion tail correction from TPC digits.
static const IonTailSettings & Instance()
const Sector sector() const
static void sortDigitsOneSectorPerTimeBin(std::vector< Digit > &digits)
void streamData(int cru, int row, int pad, int time, int lastTime, float kAmp, float kTime, float tailSlopeUnit, float origCumul, float cumul, float origCharge, float charge)
void filterDigitsDirect(std::vector< Digit > &digits)
static void sortDigitsOneSectorPerPad(std::vector< Digit > &digits)
Sort digits of a single sector per pad in increasing time bin order.
void loadITPadValuesFromFile(std::string_view itParamFile)
class to enable streaming debug information to root files
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
std::vector< CalPad * > readCalPads(const std::string_view fileName, const std::vector< std::string > &calPadNames)
Global TPC definitions and constants.
@ streamITCorr
stream ion tail correction information
std::vector< Digit > digits