16#ifndef ALICEO2_TPC_DigitGlobalPad_H_
17#define ALICEO2_TPC_DigitGlobalPad_H_
21#include <fmt/format.h>
86 int getID()
const {
return mID; }
95 template <DigitzationMode MODE>
109 float mChargePad = 0.;
116 bool isKnown =
false;
117 auto view = labels.getLabels(mID);
118 for (
auto& mcLabel : view) {
119 if (compareMClabels(
label, mcLabel.first)) {
128 std::pair<MCCompLabel, int> newlabel(
label, 1);
129 labels.addLabel(mID, newlabel);
131 mChargePad += signal;
138 const float kAmp = (padParams[0]) ? padParams[0]->getValue(sector, pad) * itSettings.ITMultFactor : itSettings.ITMultFactor * 0.1276;
139 const float expLambda = (padParams[1]) ? padParams[1]->getValue(sector, pad) : std::exp(-itSettings.kTime);
143 if (eleParam.doSaturationTail) {
144 if (prevDigit.
signal > 1023.f) {
145 prevDigit.
tot +=
int(std::round(mChargePad * eleParam.adcToT));
147 if (prevDigit.
tot > 0) {
154 float modCharge = mChargePad;
155 if ((prevDigit.
tot == 0) && (eleParam.doIonTail || eleParam.doIonTailPerPad)) {
156 modCharge = mChargePad + kAmp * (1 - expLambda) * prevDigit.
cumul;
158 prevDigit.
cumul *= expLambda;
159 if (prevDigit.
cumul < 0.1) {
163 prevDigit.
signal = modCharge;
167 float kAmpTmp = kAmp;
168 float tailSlopeUnitTmp = expLambda;
169 float cmKValue = (padParams[2]) ? padParams[2]->getValue(sector, pad) : 1.f;
172 unsigned int timeBin =
time;
176 debugStream->getStreamer() <<
"foldSignal"
179 <<
"timeBin=" << timeBin
180 <<
"kAmp=" << kAmpTmp
181 <<
"tailSlopeUnit=" << tailSlopeUnitTmp
182 <<
"cmKValue=" << cmKValue
183 <<
"charge=" << mChargePad
184 <<
"prevDig=" << prevDigInfTmp
185 <<
"dig=" << prevDigit
189 mChargePad = modCharge;
207template <DigitzationMode MODE>
218 static std::vector<std::pair<MCCompLabel, int>> labelCollector;
223 float noise, pedestal;
224 const float mADC = sampaProcessing.
makeSignal<MODE>(mChargePad, cru.
sector(), globalPad, commonMode, pedestal, noise, prevDigit.
tot);
225 const bool isDead = (deadMap ==
nullptr) ?
false : deadMap->
getValue(cru.
sector(), globalPad);
228 int sector = cru.
sector();
232 debugStream->getStreamer() <<
"digit"
233 <<
"sector=" << sector
234 <<
"pad=" << globalPad
235 <<
"timeBin=" << timeBin
236 <<
"charge=" << mChargePad
238 <<
"prevDig=" << prevDigitTmp
239 <<
"cm=" << commonMode
240 <<
"isDead=" << isDead
245 if (!isDead && (mADC > 0)) {
248 const auto digiPos =
output.size();
249 output.emplace_back(cru, mADC, pad.getRow(), pad.getPad(), timeBin);
253 mcTruth.addNoLabelIndex(digiPos);
255 auto labelview = labels.getLabels(mID);
256 labelCollector.clear();
257 for (
auto& mcLabel : labelview) {
258 labelCollector.push_back(mcLabel);
260 if (labelview.size() > 1) {
262 using P = std::pair<MCCompLabel, int>;
263 std::sort(labelCollector.begin(), labelCollector.end(), [](
const P&
a,
const P&
b) { return a.second > b.second; });
265 for (
auto& mcLabel : labelCollector) {
266 mcTruth.addElement(digiPos, mcLabel.first);
Definition of class for writing debug informations.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the SAMPA response.
uint64_t getRawValue() const
static const ParameterElectronics & Instance()
const Sector sector() const
const T getValue(const int sec, const int globalPadInSector) const
void foldSignal(PrevDigitInfo &prevDigit, const int sector, const int pad, const TimeBin time, Streamer *debugStream=nullptr, const CalPad *padParams[3]=nullptr)
Fold signal with previous pad signal add ion tail and ToT for sigmal saturation.
void reset()
Resets the container.
void addDigit(const MCCompLabel &label, float signal, o2::dataformats::LabelContainer< std::pair< MCCompLabel, int >, false > &)
void fillOutputContainer(std::vector< Digit > &output, dataformats::MCTruthContainer< MCCompLabel > &mcTruth, const CRU &cru, TimeBin timeBin, GlobalPadNumber globalPad, o2::dataformats::LabelContainer< std::pair< MCCompLabel, int >, false > &labelContainer, float commonMode=0.f, const PrevDigitInfo &prevDigit=PrevDigitInfo(), Streamer *debugStream=nullptr, const CalDet< bool > *deadMap=nullptr)
o2::utils::DebugStreamer Streamer
DigitGlobalPad()=default
Constructor.
float getChargePad() const
~DigitGlobalPad()=default
Destructor.
const PadPos & padPos(GlobalPadNumber padNumber) const
static Mapper & instance(const std::string mappingDir="")
static SAMPAProcessing & instance()
float makeSignal(float ADCcounts, const int sector, const int globalPadInSector, const float commonMode, float &pedestal, float &noise, float tot=0)
class to enable streaming debug information to root files
GLboolean GLboolean GLboolean b
GLuint GLsizei const GLchar * label
GLboolean GLboolean GLboolean GLboolean a
Global TPC definitions and constants.
unsigned short GlobalPadNumber
global pad number
unsigned int TimeBin
global time bin
@ streamDigits
stream digit information
@ streamDigitFolding
stream ion tail and saturatio information
float cumul
cumulative signal of prev time bins
ClassDefNV(PrevDigitInfo, 1)
int tot
remaining time over threshold