Project
Loading...
Searching...
No Matches
IRFrameSelector.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 O2_UTILS_IRFRAMESELECTOR_H
17#define O2_UTILS_IRFRAMESELECTOR_H
18
20#include <gsl/span>
21
22namespace o2::utils
23{
25{
26 public:
27 long check(o2::dataformats::IRFrame fr, size_t bwd = 0, size_t fwd = 0);
28 long check(const o2::InteractionRecord& ir, size_t bwd = 0, size_t fwd = 0) { return check(o2::dataformats::IRFrame{ir, ir}, bwd, fwd); }
29 gsl::span<const o2::dataformats::IRFrame> getMatchingFrames(const o2::dataformats::IRFrame& fr);
30
31 template <typename SPAN>
32 void setSelectedIRFrames(const SPAN& sp, size_t bwd = 0, size_t fwd = 0, long shift = 0, bool removeOverlaps = true)
33 {
34 mFrames = gsl::span<const o2::dataformats::IRFrame>(sp.data(), sp.size());
35 mIsSet = true;
36 applyMargins(bwd, fwd, shift, removeOverlaps);
37 mLastIRFrameChecked.getMin().clear(); // invalidate
38 mLastBoundID = -1;
39 }
40
41 void clear();
42 size_t loadIRFrames(const std::string& fname);
43 void applyMargins(size_t bwd, size_t fwd, long shift, bool removeOverlaps = true);
44 void print(bool lst = false) const;
45
46 auto getIRFrames() const { return mFrames; }
47 bool isSet() const { return mIsSet; }
48
49 void setOwnList(const std::vector<o2::dataformats::IRFrame>& lst, bool toBeSorted);
50
51 private:
52 gsl::span<const o2::dataformats::IRFrame> mFrames{}; // externally provided span of IRFrames, must be sorted in IRFrame.getMin()
53 o2::dataformats::IRFrame mLastIRFrameChecked{}; // last frame which was checked
54 long mLastBoundID = -1; // id of the last checked entry >= mLastIRFrameChecked
55 bool mIsSet = false; // flag that something was set (even if empty)
56 std::vector<o2::dataformats::IRFrame> mOwnList; // list loaded from the file
57 ClassDefNV(IRFrameSelector, 1);
58};
59
60} // namespace o2::utils
61
62#endif
void print() const
Class to delimit start and end IR of certain time period.
void setOwnList(const std::vector< o2::dataformats::IRFrame > &lst, bool toBeSorted)
size_t loadIRFrames(const std::string &fname)
void applyMargins(size_t bwd, size_t fwd, long shift, bool removeOverlaps=true)
long check(const o2::InteractionRecord &ir, size_t bwd=0, size_t fwd=0)
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
gsl::span< const o2::dataformats::IRFrame > getMatchingFrames(const o2::dataformats::IRFrame &fr)
void setSelectedIRFrames(const SPAN &sp, size_t bwd=0, size_t fwd=0, long shift=0, bool removeOverlaps=true)
o2::InteractionRecord ir(0, 0)