Project
Loading...
Searching...
No Matches
TimeSlot.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
12#ifndef DETECTOR_CALIB_TIMESLOT_H_
13#define DETECTOR_CALIB_TIMESLOT_H_
14
15#include <memory>
16#include <Rtypes.h>
17#include "Framework/Logger.h"
21
23
24namespace o2
25{
26namespace calibration
27{
28
29using TFType = uint32_t;
30inline constexpr TFType INFINITE_TF = std::numeric_limits<TFType>::max();
31
32template <typename Container>
34{
35 public:
36 TimeSlot() = default;
37 TimeSlot(TFType tfS, TFType tfE) : mTFStart(tfS), mTFEnd(tfE) {}
38 TimeSlot(const TimeSlot& src) : mTFStart(src.mTFStart), mTFEnd(src.mTFEnd), mEntries(src.mEntries), mRunStartOrbit(src.mRunStartOrbit), mTFStartMS(src.mTFStartMS)
39 {
40 mContainer = src.mContainer ? std::make_unique<Container>(*src.mContainer) : nullptr;
41 }
43
44 ~TimeSlot() = default;
45
46 TFType getTFStart() const { return mTFStart; }
47 TFType getTFEnd() const { return mTFEnd; }
48
49 long getStaticStartTimeMS() const { return mTFStartMS; }
52
53 const Container* getContainer() const { return mContainer.get(); }
54 Container* getContainer() { return mContainer.get(); }
55 void setContainer(std::unique_ptr<Container> ptr) { mContainer = std::move(ptr); }
56
57 void setTFStart(TFType v) { mTFStart = v; }
58 void setTFEnd(TFType v) { mTFEnd = v; }
59 void setStaticStartTimeMS(long t) { mTFStartMS = t; }
60 void setRunStartOrbit(long t) { mRunStartOrbit = t; }
61 auto getRunStartOrbit() const { return mRunStartOrbit; }
62
63 // compare the TF with this slot boundaties
64 int relateToTF(TFType tf) { return tf < mTFStart ? -1 : (tf > mTFEnd ? 1 : 0); }
65
66 // merge data of previous slot to this one and extend the mTFStart to cover prev
68 {
69 mContainer->merge(prev.mContainer.get());
70 mTFStart = prev.mTFStart;
71 mTFStartMS = prev.mTFStartMS;
72 }
73
74 void print() const
75 {
76 LOGF(info, "Calibration slot %5d <=TF<= %5d (start in ms = %ld)", mTFStart, mTFEnd, mTFStartMS);
77 mContainer->print();
78 }
79
80 private:
81 TFType mTFStart = 0;
82 TFType mTFEnd = 0;
83 size_t mEntries = 0;
84 long mRunStartOrbit = 0;
85 std::unique_ptr<Container> mContainer; // user object to accumulate the calibration data for this slot
86 long mTFStartMS = 0; // start time of the slot in ms that avoids to calculate it on the fly; needed when a slot covers more runs, otherwise the OrbitReset that is read is the one of the latest run, and the validity will be wrong
87
88 ClassDefNV(TimeSlot, 2);
89};
90
91} // namespace calibration
92} // namespace o2
93
94#endif
Helper for geometry and GRP related CCDB requests.
Header to collect LHC related constants.
TBranch * ptr
auto getOrbitResetTimeMS() const
static GRPGeomHelper & instance()
Container * getContainer()
Definition TimeSlot.h:54
void setContainer(std::unique_ptr< Container > ptr)
Definition TimeSlot.h:55
int relateToTF(TFType tf)
Definition TimeSlot.h:64
long getStaticStartTimeMS() const
Definition TimeSlot.h:49
TFType getTFEnd() const
Definition TimeSlot.h:47
void setStaticStartTimeMS(long t)
Definition TimeSlot.h:59
void setTFEnd(TFType v)
Definition TimeSlot.h:58
void setTFStart(TFType v)
Definition TimeSlot.h:57
long getStartTimeMS() const
Definition TimeSlot.h:50
void setRunStartOrbit(long t)
Definition TimeSlot.h:60
auto getRunStartOrbit() const
Definition TimeSlot.h:61
TimeSlot(const TimeSlot &src)
Definition TimeSlot.h:38
TimeSlot & operator=(TimeSlot &&src)=default
long getEndTimeMS() const
Definition TimeSlot.h:51
TimeSlot(TFType tfS, TFType tfE)
Definition TimeSlot.h:37
const Container * getContainer() const
Definition TimeSlot.h:53
void mergeToPrevious(TimeSlot &prev)
Definition TimeSlot.h:67
TFType getTFStart() const
Definition TimeSlot.h:46
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
uint32_t TFType
Definition TimeSlot.h:29
constexpr TFType INFINITE_TF
Definition TimeSlot.h:30
constexpr double LHCOrbitMUS
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< GPUReconstructionTimeframe > tf