Project
Loading...
Searching...
No Matches
CalibLHCphaseTOF.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
14
15#include <algorithm>
16#include <cstdio>
18
19using namespace o2::dataformats;
20
21//ClassImp(o2::dataformats::CalibLHCphaseTOF);
22
23float CalibLHCphaseTOF::getLHCphase(int timestamp) const
24{
25 int n = 0;
26 while (n < mLHCphase.size() && mLHCphase[n].first <= timestamp) {
27 n++;
28 }
29 n--;
30
31 if (n < 0) { // timestamp is before of the first available value
32 return 0;
33 }
34 return mLHCphase[n].second;
35}
36//______________________________________________
37
38void CalibLHCphaseTOF::addLHCphase(int timestamp, float phaseLHC)
39{
40 // optimized if timestamp are given in increasing order
41 int n = mLHCphase.size();
42 mLHCphase.emplace_back(timestamp, phaseLHC);
43
44 if (n && mLHCphase[n].first < mLHCphase[n - 1].first) { // in the wrong order sort!
45 std::sort(mLHCphase.begin(), mLHCphase.end(), [](const auto& lhs, const auto& rhs) {
46 return lhs.first < rhs.first;
47 });
48 }
49}
50//______________________________________________
51
53{
54 if (other.mLHCphase.size() > mLHCphase.size()) {
55 mLHCphase.clear();
56 for (auto obj = other.mLHCphase.begin(); obj != other.mLHCphase.end(); obj++) {
57 mLHCphase.push_back(*obj);
58 }
59 }
60 return *this;
61}
62//______________________________________________
Class to store the output of the matching to TOF for calibration.
CalibLHCphaseTOF & operator+=(const CalibLHCphaseTOF &other)
float getLHCphase(int timestamp) const
void addLHCphase(int timestamp, float phaseLHC)
GLdouble n
Definition glcorearb.h:1982
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
VectorOfTObjectPtrs other