forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRFrameSelector.h
More file actions
62 lines (51 loc) · 2.52 KB
/
Copy pathIRFrameSelector.h
File metadata and controls
62 lines (51 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file IRFrameSelector.h
/// \brief Class to check if give InteractionRecord or IRFrame is selected by the external IRFrame vector
/// \author ruben.shahoyan@cern.ch
#ifndef O2_UTILS_IRFRAMESELECTOR_H
#define O2_UTILS_IRFRAMESELECTOR_H
#include "CommonDataFormat/IRFrame.h"
#include <gsl/span>
namespace o2::utils
{
class IRFrameSelector
{
public:
long check(o2::dataformats::IRFrame fr, size_t bwd = 0, size_t fwd = 0);
long check(const o2::InteractionRecord& ir, size_t bwd = 0, size_t fwd = 0) { return check(o2::dataformats::IRFrame{ir, ir}, bwd, fwd); }
gsl::span<const o2::dataformats::IRFrame> getMatchingFrames(const o2::dataformats::IRFrame& fr);
template <typename SPAN>
void setSelectedIRFrames(const SPAN& sp, size_t bwd = 0, size_t fwd = 0, long shift = 0, bool removeOverlaps = true)
{
mFrames = gsl::span<const o2::dataformats::IRFrame>(sp.data(), sp.size());
mIsSet = true;
applyMargins(bwd, fwd, shift, removeOverlaps);
mLastIRFrameChecked.getMin().clear(); // invalidate
mLastBoundID = -1;
}
void clear();
size_t loadIRFrames(const std::string& fname, size_t margin = 0);
void applyMargins(size_t bwd, size_t fwd, long shift, bool removeOverlaps = true);
void print(bool lst = false) const;
auto getIRFrames() const { return mFrames; }
bool isSet() const { return mIsSet; }
void setOwnList(const std::vector<o2::dataformats::IRFrame>& lst, bool toBeSorted);
private:
gsl::span<const o2::dataformats::IRFrame> mFrames{}; // externally provided span of IRFrames, must be sorted in IRFrame.getMin()
o2::dataformats::IRFrame mLastIRFrameChecked{}; // last frame which was checked
long mLastBoundID = -1; // id of the last checked entry >= mLastIRFrameChecked
bool mIsSet = false; // flag that something was set (even if empty)
std::vector<o2::dataformats::IRFrame> mOwnList; // list loaded from the file
ClassDefNV(IRFrameSelector, 1);
};
} // namespace o2::utils
#endif