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 { return ((t - mTriggerTime) < mLiveTime || (t - mTriggerTime) >= (mLiveTime + mBusyTime - mPreTriggerTime)); }
64 bool isLive() const { return ((mLastEventTime - mTriggerTime) < mLiveTime || (mLastEventTime - mTriggerTime) >= (mLiveTime + mBusyTime - mPreTriggerTime)); }
65
66 // function returns true if the collision occurs 600ns before the readout window is open
67 // Look here for more details https://alice.its.cern.ch/jira/browse/EMCAL-681
68 bool preTriggerCollision() const { return ((mLastEventTime - mTriggerTime) >= (mLiveTime + mBusyTime - mPreTriggerTime)); }
69
74 void addDigits(unsigned int towerID, std::vector<LabeledDigit>& digList);
75
78
80 void setBufferSize(unsigned int nsamples) { mBufferSize = nsamples; }
81 unsigned int getBufferSize() const { return mBufferSize; }
82
84 void forwardMarker(o2::InteractionTimeRecord record, bool trigger);
85
87 void setLiveTime(unsigned int liveTime) { mLiveTime = liveTime; }
88 void setBusyTime(unsigned int busyTime) { mBusyTime = busyTime; }
89 void setPreTriggerTime(unsigned int pretriggerTime) { mPreTriggerTime = pretriggerTime; }
90
91 unsigned int getPhase() const { return mPhase; }
92
93 const std::vector<o2::emcal::Digit>& getDigits() const { return mDigitStream.getDigits(); }
94 const std::vector<o2::emcal::TriggerRecord>& getTriggerRecords() const { return mDigitStream.getTriggerRecords(); }
96
97 private:
98 unsigned int mBufferSize = 15;
99 unsigned int mLiveTime = 1500;
100 unsigned int mBusyTime = 35000;
101 unsigned int mPreTriggerTime = 600;
102 unsigned long mTriggerTime = 0;
103 unsigned long mLastEventTime = 0;
104 unsigned int mPhase = 0;
105 unsigned int mSwapPhase = 0;
106 bool mFirstEvent = true;
107 std::deque<o2::emcal::DigitTimebin> mTimedDigitsFuture;
108 std::deque<o2::emcal::DigitTimebin> mTimedDigitsPast;
109
110 o2::emcal::DigitsVectorStream mDigitStream;
111
112 ClassDefNV(DigitsWriteoutBuffer, 1);
113};
114
115} // namespace emcal
116
117} // namespace o2
118
119#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 ...