Project
Loading...
Searching...
No Matches
DigitsWriteoutBuffer.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
12#ifndef ALICEO2_EMCAL_DIGITSWRITEOUTBUFFER_H_
13#define ALICEO2_EMCAL_DIGITSWRITEOUTBUFFER_H_
14
15#include <memory>
16#include <unordered_map>
17#include <vector>
18#include <deque>
19#include <list>
20#include <gsl/span>
25
26namespace o2
27{
28namespace emcal
29{
30
37
39{
40 public:
42 DigitsWriteoutBuffer(unsigned int nTimeBins = 15);
43
46
48 void clear();
49
51 void flush() { mDigitStream.clear(); }
52
53 void init();
54
56 void reserve();
57
59 void finish();
60
61 double getTriggerTime() const { return mTriggerTime; }
62 double getEventTime() const { return mLastEventTime; }
63 bool isLive(double t) const
64 {
65 return ((t - mTriggerTime) < mLiveTime || (t - mTriggerTime) >= (mLiveTime + mBusyTime - mPreTriggerTime));
66 }
67 bool isLive() const
68 {
69 return ((mLastEventTime - mTriggerTime) < (mLiveTime - mPreTriggerTime) || (mLastEventTime - mTriggerTime) >= (mLiveTime + mBusyTime - mPreTriggerTime));
70 }
71
75 {
76 return mLastEventTime == mTriggerTime;
77 }
78
79 // function returns true if the collision occurs 600ns before the readout window is open
80 // Look here for more details https://alice.its.cern.ch/jira/browse/EMCAL-681
81 bool preTriggerCollision() const { return ((mLastEventTime - mTriggerTime) >= (mLiveTime + mBusyTime - mPreTriggerTime)); }
82
87 void addDigits(unsigned int towerID, std::vector<LabeledDigit>& digList);
88
91
93 void setBufferSize(unsigned int nsamples) { mBufferSize = nsamples; }
94 unsigned int getBufferSize() const { return mBufferSize; }
95
97 void forwardMarker(o2::InteractionTimeRecord record, bool trigger);
98
100 void setLiveTime(unsigned int liveTime) { mLiveTime = liveTime; }
101 void setBusyTime(unsigned int busyTime) { mBusyTime = busyTime; }
102 void setPreTriggerTime(unsigned int pretriggerTime) { mPreTriggerTime = pretriggerTime; }
103
104 unsigned int getPhase() const { return mPhase; }
105
106 const std::vector<o2::emcal::Digit>& getDigits() const { return mDigitStream.getDigits(); }
107 const std::vector<o2::emcal::TriggerRecord>& getTriggerRecords() const { return mDigitStream.getTriggerRecords(); }
109
110 private:
111 unsigned int mBufferSize = 15;
112 unsigned int mLiveTime = 1500;
113 unsigned int mBusyTime = 35000;
114 unsigned int mPreTriggerTime = 600;
115 unsigned long mTriggerTime = 0;
116 unsigned long mLastEventTime = 0;
117 unsigned int mPhase = 0;
118 unsigned int mSwapPhase = 0;
119 bool mFirstEvent = true;
120 std::deque<o2::emcal::DigitTimebin> mTimedDigitsFuture;
121 std::deque<o2::emcal::DigitTimebin> mTimedDigitsPast;
122
123 o2::emcal::DigitsVectorStream mDigitStream;
124
125 ClassDefNV(DigitsWriteoutBuffer, 1);
126};
127
128} // namespace emcal
129
130} // namespace o2
131
132#endif /* ALICEO2_EMCAL_DIGITSWRITEOUTBUFFER_H_ */
std::vector< uint16_t > nsamples
Definition testDigit.cxx:38
A container to hold and manage MC truth information/labels.
Container class for Digits, MC lebels, and trigger records.
void clear()
clear the container
const std::vector< o2::emcal::Digit > & getDigits() const
Getters for the finals data vectors, digits vector, labels vector, and trigger records vector.
const o2::dataformats::MCTruthContainer< o2::emcal::MCLabel > & getMCLabels() const
const std::vector< o2::emcal::TriggerRecord > & getTriggerRecords() const
Container class for time sampled digits.
void setLiveTime(unsigned int liveTime)
Setters for the live time, busy time, pre-trigger time.
const std::vector< o2::emcal::Digit > & getDigits() const
void setSampledDigitsTime()
This function sets the right time for all digits in the buffer.
void setBufferSize(unsigned int nsamples)
Setting the buffer size.
void finish()
This is for the readout window that was interrupted by the end of the run.
void flush()
clear DigitsVectorStream
void reserve()
Reserve space for the future container.
void forwardMarker(o2::InteractionTimeRecord record, bool trigger)
forward the marker for every 100 ns
const std::vector< o2::emcal::TriggerRecord > & getTriggerRecords() const
const o2::dataformats::MCTruthContainer< o2::emcal::MCLabel > & getMCLabels() const
void addDigits(unsigned int towerID, std::vector< LabeledDigit > &digList)
void setPreTriggerTime(unsigned int pretriggerTime)
void setBusyTime(unsigned int busyTime)
~DigitsWriteoutBuffer()=default
Destructor.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...