Project
Loading...
Searching...
No Matches
DigitTime.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_TPC_DigitTime_H_
17#define ALICEO2_TPC_DigitTime_H_
18
19#include "TPCBase/Mapper.h"
20#include "TPCBase/CalDet.h"
25
26namespace o2::tpc
27{
28
29class Digit;
30
36
38{
39 public:
42
44 DigitTime();
45
47 ~DigitTime() = default;
48
50 void reset();
51
55 float getCommonMode(const GEMstack& gemstack) const;
56
60 float getCommonMode(const CRU& cru) const { return getCommonMode(cru.gemStack()); }
61
68 void addDigit(const MCCompLabel& label, const CRU& cru, GlobalPadNumber globalPad, float signal);
69
78 template <DigitzationMode MODE>
80 std::vector<CommonMode>& commonModeOutput, const Sector& sector, TimeBin timeBin,
81 PrevDigitInfoArray* prevTime = nullptr, Streamer* debugStream = nullptr,
82 const CalPad* itParams[2] = nullptr, const CalDet<bool>* deadMap = nullptr);
83
84 private:
85 std::array<float, GEMSTACKSPERSECTOR> mCommonMode;
86 std::array<DigitGlobalPad, Mapper::getPadsInSector()> mGlobalPads;
87 int mDigitCounter = 0;
88
90 // std::deque<int> mOccupiedPads; // iterable container of occupied pads
91};
92
93inline DigitTime::DigitTime() : mCommonMode(), mGlobalPads()
94{
95 mCommonMode.fill(0.f);
96 mLabels.reserve(Mapper::getPadsInSector() / 3);
97}
98
99inline void DigitTime::addDigit(const MCCompLabel& label, const CRU& cru, GlobalPadNumber globalPad, float signal)
100{
101 auto& paddigit = mGlobalPads[globalPad];
102 if (paddigit.getID() == -1) {
103 // this means we have a new digit
104 paddigit.setID(mDigitCounter++);
105 // could also register this pad in a vector of digits
106 }
107
108 // previous digit for CM and ToT calculation
109 paddigit.addDigit(label, signal, mLabels);
110 // mCommonMode[cru.gemStack()] += signal * 0.5; // TODO: Replace 0.5 by k-factor, take into account ion tail
111}
112
113inline void DigitTime::reset()
114{
115 for (auto& pad : mGlobalPads) {
116 pad.reset();
117 }
118 mCommonMode.fill(0.f);
119}
120
121inline float DigitTime::getCommonMode(const GEMstack& gemstack) const
122{
124 const Mapper& mapper = Mapper::instance();
125 const auto nPads = mapper.getNumberOfPads(gemstack);
126 return mCommonMode[gemstack] / static_cast<float>(nPads);
127}
128
129template <DigitzationMode MODE>
131 std::vector<CommonMode>& commonModeOutput, const Sector& sector, TimeBin timeBin,
132 PrevDigitInfoArray* prevTime, Streamer* debugStream, const CalPad* padParams[3],
133 const CalDet<bool>* deadMap)
134{
135 const auto& mapper = Mapper::instance();
136 const auto& eleParam = ParameterElectronics::Instance();
137
138 // at this point we only have the pure signals from tracks
139 // loop over all pads to calculated ion tail, common mode and ToT for saturated signals
140 for (size_t iPad = 0; iPad < mGlobalPads.size(); ++iPad) {
141 auto& digit = mGlobalPads[iPad];
142 if (prevTime) {
143 auto& prevDigit = (*prevTime)[iPad];
144 if (prevDigit.hasSignal()) {
145 digit.foldSignal(prevDigit, sector.getSector(), iPad, timeBin, debugStream, padParams);
146 }
147 prevDigit.signal = digit.getChargePad(); // to make hasSignal() check work in next time bin
148 }
149 const CRU cru = mapper.getCRU(sector, iPad);
150 const float cmKValue = (padParams[2]) ? padParams[2]->getValue(sector.getSector(), iPad) : 1.f;
151 mCommonMode[cru.gemStack()] += digit.getChargePad() * eleParam.commonModeCoupling * cmKValue; // TODO: Add stack-by-stack variation?
152 }
153
154 // fill common mode output container
155 for (size_t i = 0; i < mCommonMode.size(); ++i) {
156 const float cm = getCommonMode(GEMstack(i));
157 if (cm > 0.) {
158 commonModeOutput.push_back({cm, timeBin, static_cast<unsigned char>(i)});
159 }
160 }
161
162 for (size_t iPad = 0; iPad < mGlobalPads.size(); ++iPad) {
163 auto& digit = mGlobalPads[iPad];
164 if (eleParam.doNoiseEmptyPads || (digit.getChargePad() > 0.f)) {
165 PrevDigitInfo prevDigit;
166 if (prevTime) {
167 prevDigit = (*prevTime)[iPad];
168 }
169 const CRU cru = mapper.getCRU(sector, iPad);
170 digit.fillOutputContainer<MODE>(output, mcTruth, cru, timeBin, iPad, mLabels, getCommonMode(cru), prevDigit, debugStream, deadMap);
171 }
172 }
173}
174} // namespace o2::tpc
175
176#endif // ALICEO2_TPC_DigitTime_H_
Definition of the common mode container class.
Definition of class for writing debug informations.
Definition of the GlobalPad container.
int32_t i
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
GEMstack gemStack() const
Definition CRU.h:82
void reset()
Resets the container.
Definition DigitTime.h:113
DigitTime()
Constructor.
Definition DigitTime.h:93
std::array< PrevDigitInfo, Mapper::getPadsInSector()> PrevDigitInfoArray
Definition DigitTime.h:41
float getCommonMode(const GEMstack &gemstack) const
Definition DigitTime.h:121
void fillOutputContainer(std::vector< Digit > &output, dataformats::MCTruthContainer< MCCompLabel > &mcTruth, std::vector< CommonMode > &commonModeOutput, const Sector &sector, TimeBin timeBin, PrevDigitInfoArray *prevTime=nullptr, Streamer *debugStream=nullptr, const CalPad *itParams[2]=nullptr, const CalDet< bool > *deadMap=nullptr)
float getCommonMode(const CRU &cru) const
Definition DigitTime.h:60
~DigitTime()=default
Destructor.
void addDigit(const MCCompLabel &label, const CRU &cru, GlobalPadNumber globalPad, float signal)
Definition DigitTime.h:99
static Mapper & instance(const std::string mappingDir="")
Definition Mapper.h:44
static constexpr unsigned short getPadsInSector()
Definition Mapper.h:414
static constexpr unsigned short getNumberOfPads(const GEMstack gemStack)
Definition Mapper.h:416
unsigned char getSector() const
Definition Sector.h:94
class to enable streaming debug information to root files
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
o2::cpv::Digit Digit
Global TPC definitions and constants.
Definition SimTraits.h:167
GEMstack
TPC GEM stack types.
Definition Defs.h:53
unsigned short GlobalPadNumber
global pad number
Definition Defs.h:129
unsigned int TimeBin
global time bin
Definition Defs.h:132