Project
Loading...
Searching...
No Matches
DigitContainer.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_DigitContainer_H_
17#define ALICEO2_TPC_DigitContainer_H_
18
19#include <deque>
20#include <algorithm>
21#include "TPCBase/CRU.h"
22#include "DataFormatsTPC/Defs.h"
25#include "TPCBase/CalDet.h"
30
31namespace o2::tpc
32{
33
34class Digit;
35
41
43{
44 public:
47
50 {
51 for (auto time : mTimeBins) {
52 delete time;
53 }
54 }
55
58
60 void reset();
61
63 void reserve(TimeBin eventTimeBin);
64
67 void setStartTime(TimeBin time) { mFirstTimeBin = time; }
68
76 void addDigit(const MCCompLabel& label, const CRU& cru, TimeBin timeBin, GlobalPadNumber globalPad, float signal);
77
86 void fillOutputContainer(std::vector<Digit>& output, dataformats::MCTruthContainer<MCCompLabel>& mcTruth, std::vector<CommonMode>& commonModeOutput, const Sector& sector, TimeBin eventTimeBin = 0, bool isContinuous = true, bool finalFlush = false);
87
89 size_t size() const { return mTimeBins.size(); }
90
92 void setSAMPAProcessing(SAMPAProcessing* sampaProcessing) { mSAMPAProcessing = sampaProcessing; }
93
96 void updateCalibrations();
97
98 private:
99 TimeBin mFirstTimeBin = 0;
100 TimeBin mEffectiveTimeBin = 0;
101 TimeBin mTmaxTriggered = 0;
102 TimeBin mOffset;
103 std::deque<DigitTime*> mTimeBins;
104 std::unique_ptr<DigitTime::PrevDigitInfoArray> mPrevDigArr;
105 o2::utils::DebugStreamer mStreamer;
106 const CalPad* mPadParams[3] = {nullptr, nullptr, nullptr};
107 const CalDet<bool>* mDeadMap = nullptr;
108 std::unique_ptr<CalDet<bool>> mDeadMapCopy;
109 bool mCMCEnabled = false;
110 bool mCalibrationsUpdated = false;
111 SAMPAProcessing* mSAMPAProcessing = nullptr;
112 std::vector<std::pair<MCCompLabel, int>> mLabelCollector;
113
114 void reportSettings();
115};
116
118{
119 auto& detParam = ParameterDetector::Instance();
120 auto& gasParam = ParameterGas::Instance();
121 auto& eleParam = ParameterElectronics::Instance();
122 mTmaxTriggered = detParam.TmaxTriggered;
123
124 // always have 50 % contingency for the size of the container depending on the input
125 mOffset = static_cast<TimeBin>(detParam.TPCRecoWindowSim * detParam.TPClength / gasParam.DriftV / eleParam.ZbinWidth);
126 mTimeBins.resize(mOffset, nullptr);
127}
128
130{
131 mFirstTimeBin = 0;
132 mEffectiveTimeBin = 0;
133 // drop all time bins, including those beyond the timeframe limit, so that no MC labels survive
134 for (auto time : mTimeBins) {
135 delete time;
136 }
137 mTimeBins.assign(mOffset, nullptr);
138 if (mPrevDigArr) {
139 std::fill(mPrevDigArr->begin(), mPrevDigArr->end(), PrevDigitInfo{});
140 }
141}
142
143inline void DigitContainer::reserve(TimeBin eventTimeBin)
144{
145 const auto space = mOffset + eventTimeBin - mFirstTimeBin;
146 if (mTimeBins.size() < space) {
147 mTimeBins.resize(space);
148 }
149}
150
151inline void DigitContainer::addDigit(const MCCompLabel& label, const CRU& cru, TimeBin timeBin, GlobalPadNumber globalPad,
152 float signal)
153{
154 mEffectiveTimeBin = timeBin - mFirstTimeBin;
155 if (mEffectiveTimeBin >= mTimeBins.size()) {
156 // LOG(warning) << "Out of bound access to digit container .. dropping digit";
157 return;
158 }
159
160 if (mTimeBins[mEffectiveTimeBin] == nullptr) {
161 mTimeBins[mEffectiveTimeBin] = new DigitTime();
162 }
163
164 mTimeBins[mEffectiveTimeBin]->addDigit(label, cru, globalPad, signal);
165}
166
167} // namespace o2::tpc
168
169#endif // ALICEO2_TPC_DigitContainer_H_
Definition of class for writing debug informations.
Definition of the Time Bin container.
int16_t time
Definition RawEventData.h:4
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the parameter class for the detector.
Definition of the parameter class for the detector electronics.
Definition of the parameter class for the detector gas.
Definition of the SAMPA response.
void setStartTime(TimeBin time)
void setSAMPAProcessing(SAMPAProcessing *sampaProcessing)
Use this SAMPAProcessing instead of the singleton when filling the output.
size_t size() const
Get the size of the container for one event.
DigitContainer()
Default constructor.
DigitContainer & operator=(const DigitContainer &)=delete
void fillOutputContainer(std::vector< Digit > &output, dataformats::MCTruthContainer< MCCompLabel > &mcTruth, std::vector< CommonMode > &commonModeOutput, const Sector &sector, TimeBin eventTimeBin=0, bool isContinuous=true, bool finalFlush=false)
void reset()
Reset the container.
DigitContainer(const DigitContainer &)=delete
void addDigit(const MCCompLabel &label, const CRU &cru, TimeBin timeBin, GlobalPadNumber globalPad, float signal)
void reserve(TimeBin eventTimeBin)
Reserve space in the container for a given event.
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.
unsigned short GlobalPadNumber
global pad number
Definition Defs.h:114