Project
Loading...
Searching...
No Matches
ROFRecord.cxx
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
13
14#include <fmt/format.h>
15#include <iostream>
16#include <stdexcept>
17
19#include "Framework/Logger.h"
20
21namespace o2::mch
22{
23std::ostream& operator<<(std::ostream& os, const ROFRecord& rof)
24{
25 os << fmt::format("{} FirstIdx: {:5d} LastIdx: {:5d} Width: {:2d} BCs",
26 rof.getBCData().asString(), rof.getFirstIdx(), rof.getLastIdx(),
27 rof.getBCWidth());
28 return os;
29}
30
31//__________________________________________________________________________
35std::pair<ROFRecord::Time, bool> ROFRecord::getTimeMUS(const BCData& startIR, uint32_t nOrbits, bool printError) const
36{
37 auto bcDiff = mBCData.differenceInBC(startIR);
38 float tMean = (bcDiff + 0.5 * mBCWidth) * o2::constants::lhc::LHCBunchSpacingMUS;
39 float tErr = 0.5 * mBCWidth * o2::constants::lhc::LHCBunchSpacingMUS;
40 bool isInTF = bcDiff >= 0 && bcDiff < nOrbits * o2::constants::lhc::LHCMaxBunches;
41 if (printError && !isInTF) {
42 LOGP(alarm, "ATTENTION: wrong bunches diff. {} for current IR {} wrt 1st TF orbit {}, source:MCH",
43 bcDiff, mBCData.asString(), startIR.asString());
44 }
45 return std::make_pair(Time(tMean, tErr), isInTF);
46}
47
48} // namespace o2::mch
Header to collect LHC related constants.
Definition of the MCH ROFrame record.
int getLastIdx() const
get the index of the last associated object
Definition ROFRecord.h:59
const BCData & getBCData() const
get the interaction record
Definition ROFRecord.h:46
std::pair< Time, bool > getTimeMUS(const BCData &startIR, uint32_t nOrbits=128, bool printError=false) const
Definition ROFRecord.cxx:35
int getFirstIdx() const
get the index of the first associated object
Definition ROFRecord.h:57
int getBCWidth() const
get the time span by this ROF, in BC unit
Definition ROFRecord.h:64
constexpr double LHCBunchSpacingMUS
constexpr int LHCMaxBunches
std::ostream & operator<<(std::ostream &os, const o2::dataformats::MeanVertexObject &o)
std::string asString() const
int64_t differenceInBC(const InteractionRecord &other) const