Project
Loading...
Searching...
No Matches
LHCClockCalibrator.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 TOF_LHCPHASE_CALIBRATION_H_
13#define TOF_LHCPHASE_CALIBRATION_H_
14
18#include "TOFBase/CalibTOFapi.h"
21#include "TOFBase/Geo.h"
22#include "CCDB/CcdbObjectInfo.h"
23#include <array>
24
25//#define DEBUGGING
26
27#ifdef DEBUGGING
28#include "TH2F.h"
29#endif
30
31namespace o2
32{
33namespace tof
34{
35
38 int nbins = 1000;
39 float v2Bin = nbins / (2 * range);
40 int entries = 0;
42 std::vector<float> histo{0};
43
45
46#ifndef DEBUGGING
47 LHCClockDataHisto(int nb, float r, o2::tof::CalibTOFapi* api) : nbins(nb), range(r), v2Bin(0), calibApi(api)
48#else
49 LHCClockDataHisto(int nb, float r, o2::tof::CalibTOFapi* api, int slot, TH2F* h = nullptr) : nbins(nb), range(r), v2Bin(0), calibApi(api), mSlot(slot), mTimeHist(h)
50#endif
51 {
52 if (r <= 0. || nb < 1) {
53 throw std::runtime_error("Wrong initialization of the histogram");
54 }
55 v2Bin = nbins / (2 * range);
56 histo.resize(nbins, 0.);
57 }
58
59 size_t getEntries() const { return entries; }
60 void print() const;
61 void fill(const gsl::span<const o2::dataformats::CalibInfoTOF> data);
62 void merge(const LHCClockDataHisto* prev);
63
64#ifdef DEBUGGING
65 TH2F* mTimeHist;
66 int mSlot;
67#endif
68
70};
71
72class LHCClockCalibrator final : public o2::calibration::TimeSlotCalibration<o2::tof::LHCClockDataHisto>
73{
74 using TFType = o2::calibration::TFType;
79 using CcdbObjectInfoVector = std::vector<CcdbObjectInfo>;
80 using LHCphaseVector = std::vector<LHCphase>;
81
82 public:
83 LHCClockCalibrator(int minEnt = 500, int nb = 10000, float r = 244000, const std::string path = o2::base::NameConf::getCCDBServer()) : mMinEntries(minEnt), mNBins(nb), mRange(r)
84 {
85 mCalibTOFapi->setURL(path);
86#ifdef DEBUGGING
87 mTimeHist = new TH2F("phaseTrend", ";slot #; t - t_{exp}^{#pi} (ps)", 200, 0, 200, mNBins, -mRange, mRange);
88#endif
89 }
90 ~LHCClockCalibrator() final = default;
91 bool hasEnoughData(const Slot& slot) const final { return slot.getContainer()->entries >= mMinEntries; }
92 void initOutput() final;
93 void finalizeSlot(Slot& slot) final;
94 Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
95
96 const LHCphaseVector& getLHCphaseVector() const { return mLHCphaseVector; }
97 const CcdbObjectInfoVector& getLHCphaseInfoVector() const { return mInfoVector; }
98 CcdbObjectInfoVector& getLHCphaseInfoVector() { return mInfoVector; }
99
100 void setCalibTOFapi(CalibTOFapi* api) { mCalibTOFapi = api; }
101 CalibTOFapi* getCalibTOFapi() const { return mCalibTOFapi; }
102
103 private:
104 int mMinEntries = 0;
105 int mNBins = 0;
106 float mRange = 0.;
107 CalibTOFapi* mCalibTOFapi = nullptr;
108 CcdbObjectInfoVector mInfoVector; // vector of CCDB Infos , each element is filled with the CCDB description of the accompanying LHCPhase
109 LHCphaseVector mLHCphaseVector; // vector of LhcPhase, each element is filled in "process" when we finalize one slot (multiple can be finalized during the same "process", which is why we have a vector. Each element is to be considered the output of the device, and will go to the CCDB
110
111#ifdef DEBUGGING
112 int mNslot = 0;
113 TH2F* mTimeHist; //("channelDist",";channel; t - t_{exp}^{#pi} (ps)",13104,0,157248,1000,-100000,100000);
114#endif
115
116 ClassDefOverride(LHCClockCalibrator, 1);
117};
118
119} // end namespace tof
120} // end namespace o2
121
122#endif /* TOF_LHCPHASE_CALIBRATION_H_ */
Class to store the output of the matching to TOF for calibration.
Class to store the output of the matching to TOF for calibration.
Class to use TOF calibration (decalibration, calibration)
uint64_t TFType
Definition of the Names Generator class.
Class for time synchronization of RawReader instances.
static std::string getCCDBServer()
Definition NameConf.cxx:110
void setURL(const std::string url)
Definition CalibTOFapi.h:62
static constexpr Double_t BC_TIME_INPS
Definition Geo.h:103
const CcdbObjectInfoVector & getLHCphaseInfoVector() const
CcdbObjectInfoVector & getLHCphaseInfoVector()
CalibTOFapi * getCalibTOFapi() const
bool hasEnoughData(const Slot &slot) const final
~LHCClockCalibrator() final=default
Slot & emplaceNewSlot(bool front, TFType tstart, TFType tend) final
void setCalibTOFapi(CalibTOFapi *api)
const LHCphaseVector & getLHCphaseVector() const
LHCClockCalibrator(int minEnt=500, int nb=10000, float r=244000, const std::string path=o2::base::NameConf::getCCDBServer())
void finalizeSlot(Slot &slot) final
GLenum GLint * range
Definition glcorearb.h:1899
GLboolean * data
Definition glcorearb.h:298
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLboolean r
Definition glcorearb.h:1233
uint32_t TFType
Definition TimeSlot.h:29
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
o2::tof::CalibTOFapi * calibApi
void fill(const gsl::span< const o2::dataformats::CalibInfoTOF > data)
LHCClockDataHisto(int nb, float r, o2::tof::CalibTOFapi *api)
void merge(const LHCClockDataHisto *prev)
ClassDefNV(LHCClockDataHisto, 1)