Project
Loading...
Searching...
No Matches
ROFRecord.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
16
17#ifndef ALICEO2_MID_ROFRECORD_H
18#define ALICEO2_MID_ROFRECORD_H
19
20#include <utility>
21
25#include "Framework/Logger.h"
26
27namespace o2
28{
29namespace mid
30{
31
32enum class EventType {
33 Standard = 0,
34 Calib = 1,
35 FET = 2
36};
37constexpr uint32_t NEvTypes = 3;
38
41struct ROFRecord {
43
44 o2::InteractionRecord interactionRecord{}; //< Interaction record
46 size_t firstEntry{0}; //< First associated entry
47 size_t nEntries{0}; //< Number of associated entries
48
49 ROFRecord() = default;
50 ROFRecord(const o2::InteractionRecord& intRecord, const EventType& evtType, size_t first, size_t nElements) : interactionRecord(intRecord), eventType(evtType), firstEntry(first), nEntries(nElements) {}
52 size_t getEndIndex() const { return firstEntry + nEntries; }
53
54 //__________________________________________________________________________
58 std::pair<Time, bool> getTimeMUS(const InteractionRecord& startIR, uint32_t nOrbits = 128,
59 bool printError = false) const
60 {
61 auto bcDiff = interactionRecord.differenceInBC(startIR);
62 float tMean = (bcDiff + 0.5) * o2::constants::lhc::LHCBunchSpacingMUS;
64 bool isInTF = bcDiff >= 0 && bcDiff < nOrbits * o2::constants::lhc::LHCMaxBunches;
65 if (printError && !isInTF) {
66 LOGP(alarm, "ATTENTION: wrong bunches diff. {} for current IR {} wrt 1st TF orbit {}, source:MID",
67 bcDiff, interactionRecord.asString(), startIR.asString());
68 }
69 return std::make_pair(Time(tMean, tErr), isInTF);
70 }
71
73};
74
75} // namespace mid
76} // namespace o2
77
78#endif
Header to collect LHC related constants.
constexpr double LHCBunchSpacingMUS
constexpr int LHCMaxBunches
constexpr uint32_t NEvTypes
Definition ROFRecord.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string asString() const
int64_t differenceInBC(const InteractionRecord &other) const
size_t getEndIndex() const
Definition ROFRecord.h:52
ROFRecord(const ROFRecord &other, size_t first, size_t nElements)
Definition ROFRecord.h:51
o2::InteractionRecord interactionRecord
Definition ROFRecord.h:44
std::pair< Time, bool > getTimeMUS(const InteractionRecord &startIR, uint32_t nOrbits=128, bool printError=false) const
Definition ROFRecord.h:58
EventType eventType
Definition ROFRecord.h:45
ClassDefNV(ROFRecord, 1)
o2::dataformats::TimeStampWithError< float, float > Time
Definition ROFRecord.h:42
ROFRecord(const o2::InteractionRecord &intRecord, const EventType &evtType, size_t first, size_t nElements)
Definition ROFRecord.h:50
VectorOfTObjectPtrs other