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"
28
29namespace o2::tpc
30{
31
32class Digit;
33
39
41{
42 public:
45
47 ~DigitContainer() = default;
48
50 void reset();
51
53 void reserve(TimeBin eventTimeBin);
54
57 void setStartTime(TimeBin time) { mFirstTimeBin = time; }
58
66 void addDigit(const MCCompLabel& label, const CRU& cru, TimeBin timeBin, GlobalPadNumber globalPad, float signal);
67
76 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);
77
79 size_t size() const { return mTimeBins.size(); }
80
81 private:
82 TimeBin mFirstTimeBin = 0;
83 TimeBin mEffectiveTimeBin = 0;
84 TimeBin mTmaxTriggered = 0;
85 TimeBin mOffset;
86 std::deque<DigitTime*> mTimeBins;
87 std::unique_ptr<DigitTime::PrevDigitInfoArray> mPrevDigArr;
88 o2::utils::DebugStreamer mStreamer;
89
90 void reportSettings();
91};
92
94{
95 auto& detParam = ParameterDetector::Instance();
96 auto& gasParam = ParameterGas::Instance();
97 auto& eleParam = ParameterElectronics::Instance();
98 mTmaxTriggered = detParam.TmaxTriggered;
99
100 // always have 50 % contingency for the size of the container depending on the input
101 mOffset = static_cast<TimeBin>(detParam.TPCRecoWindowSim * detParam.TPClength / gasParam.DriftV / eleParam.ZbinWidth);
102 mTimeBins.resize(mOffset, nullptr);
103}
104
106{
107 mFirstTimeBin = 0;
108 mEffectiveTimeBin = 0;
109 for (auto& time : mTimeBins) {
110 if (time) {
111 time->reset();
112 }
113 }
114 if (mPrevDigArr) {
115 std::fill(mPrevDigArr->begin(), mPrevDigArr->end(), PrevDigitInfo{});
116 }
117}
118
119inline void DigitContainer::reserve(TimeBin eventTimeBin)
120{
121 const auto space = mOffset + eventTimeBin - mFirstTimeBin;
122 if (mTimeBins.size() < space) {
123 mTimeBins.resize(space);
124 }
125}
126
127inline void DigitContainer::addDigit(const MCCompLabel& label, const CRU& cru, TimeBin timeBin, GlobalPadNumber globalPad,
128 float signal)
129{
130 mEffectiveTimeBin = timeBin - mFirstTimeBin;
131 if (mEffectiveTimeBin >= mTimeBins.size()) {
132 // LOG(warning) << "Out of bound access to digit container .. dropping digit";
133 return;
134 }
135
136 if (mTimeBins[mEffectiveTimeBin] == nullptr) {
137 mTimeBins[mEffectiveTimeBin] = new DigitTime();
138 }
139
140 mTimeBins[mEffectiveTimeBin]->addDigit(label, cru, globalPad, signal);
141}
142
143} // namespace o2::tpc
144
145#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
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.
void setStartTime(TimeBin time)
size_t size() const
Get the size of the container for one event.
DigitContainer()
Default constructor.
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()=default
Destructor.
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.
Definition SimTraits.h:167
unsigned short GlobalPadNumber
global pad number
Definition Defs.h:129
unsigned int TimeBin
global time bin
Definition Defs.h:132