Project
Loading...
Searching...
No Matches
GainCalibrator.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 CPV_GAIN_CALIBRATOR_H_
13#define CPV_GAIN_CALIBRATOR_H_
14
19#include "CCDB/CcdbObjectInfo.h"
20#include "CPVBase/Geometry.h"
21#include <TH1F.h>
22
23namespace o2
24{
25namespace cpv
26{
27//=============================================================================
29{
30 public:
31 static constexpr uint16_t nBins = 1000; // N bins of amplitude histo
32 static constexpr float lRange = 0.; // Range (left) of amplitude histo
33 static constexpr float rRange = 1000.; // Range (right) of amplitude histo
34
36 ~AmplitudeSpectrum() = default;
38 void reset();
40 void fill(float amplitude);
41 double getMean() const { return mSumA / mNEntries; } // return mean of distribution
42 double getRMS() const { return (mSumA2 / mNEntries) - ((mSumA * mSumA) / (mNEntries * mNEntries)); }; // return RMS of distribution
43 uint32_t getNEntries() const { return mNEntries; }
44 const uint32_t* getBinContent() { return mBinContent.data(); } // since C++17 std::array::data is constexpr
45 void dumpToHisto(TH1F* h);
46 int nEventsInRange(float lR, float rR);
47
48 private:
49 uint32_t mNEntries;
50 double mSumA;
51 double mSumA2;
52 std::array<uint32_t, nBins> mBinContent; // we are going use ROOT::Fit which works with doubles
53
54 ClassDef(AmplitudeSpectrum, 1);
55}; // end AmplitudeSpectrum
56//=============================================================================
58{
59 public:
60 GainCalibData() = default;
61 ~GainCalibData() = default;
62
63 void fill(const gsl::span<const Digit> data);
64 void merge(const GainCalibData* prev);
65 void print() const;
66
67 std::array<AmplitudeSpectrum, Geometry::kNCHANNELS> mAmplitudeSpectra;
68
70}; // end GainCalibData
71//=============================================================================
73class GainCalibrator final : public o2::calibration::TimeSlotCalibration<GainCalibData>
74{
75 public:
77 ~GainCalibrator() final = default;
78 std::vector<o2::ccdb::CcdbObjectInfo>& getCcdbInfoGainsVector() { return mCcdbInfoGainsVec; }
79 const std::vector<CalibParams>& getGainsVector() const { return mGainsVec; }
80 std::vector<o2::ccdb::CcdbObjectInfo>& getCcdbInfoGainCalibDataVector() { return mCcdbInfoGainCalibDataVec; }
81 const std::vector<GainCalibData>& getGainCalibDataVector() const { return mGainCalibDataVec; }
82
83 void setPreviousGains(CalibParams* previousGains) { mPreviousGains.reset(previousGains); }
84 bool isSettedPreviousGains() { return mPreviousGains.get() == nullptr ? false : true; }
85 void setPreviousGainCalibData(GainCalibData* previousGainCalibData) { mPreviousGainCalibData.reset(previousGainCalibData); }
86 bool isSettedPreviousGainCalibData() { return mPreviousGainCalibData.get() == nullptr ? false : true; }
87
88 bool hasEnoughData(const GainTimeSlot& slot) const final;
89 void initOutput() final;
90 void finalizeSlot(GainTimeSlot& slot) final;
91 GainTimeSlot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
92 void prepareForEnding();
93 void setUpdateTFInterval(uint32_t interval) { mUpdateTFInterval = interval; }
94 // read configurable parameters from CPVCalibParams
95 void configParameters();
96
97 private:
98 uint32_t mMinEvents = 1000;
99 uint32_t mMinNChannelsToCalibrate = 10000;
100 float mDesiredLandauMPV = 200.;
101 float mToleratedChi2PerNDF = 100.;
102 float mMinAllowedCoeff = 0.1;
103 float mMaxAllowedCoeff = 10.;
104 float mFitRangeL = 10.;
105 float mFitRangeR = 1000.;
106 uint32_t mUpdateTFInterval = 100;
107
108 std::unique_ptr<CalibParams> mPreviousGains = nullptr;
109 std::unique_ptr<GainCalibData> mPreviousGainCalibData;
110 std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoGainsVec;
111 std::vector<o2::ccdb::CcdbObjectInfo> mCcdbInfoGainCalibDataVec;
112 std::vector<CalibParams> mGainsVec;
113 std::vector<GainCalibData> mGainCalibDataVec;
114
115 ClassDef(GainCalibrator, 1);
116}; // end GainCalibrator
117
118} // namespace cpv
119} // namespace o2
120
121#endif /* CPV_GAIN_CALIBRATOR_H_ */
uint64_t TFType
Class for time synchronization of RawReader instances.
static constexpr float lRange
const uint32_t * getBinContent()
uint32_t getNEntries() const
static constexpr float rRange
int nEventsInRange(float lR, float rR)
void fill(float amplitude)
AmplitudeSpectrum & operator+=(const AmplitudeSpectrum &rhs)
static constexpr uint16_t nBins
AmplitudeSpectrum(const AmplitudeSpectrum &)=default
ClassDef(GainCalibData, 1)
std::array< AmplitudeSpectrum, Geometry::kNCHANNELS > mAmplitudeSpectra
void fill(const gsl::span< const Digit > data)
void merge(const GainCalibData *prev)
std::vector< o2::ccdb::CcdbObjectInfo > & getCcdbInfoGainsVector()
void setPreviousGainCalibData(GainCalibData *previousGainCalibData)
~GainCalibrator() final=default
void finalizeSlot(GainTimeSlot &slot) final
const std::vector< GainCalibData > & getGainCalibDataVector() const
bool hasEnoughData(const GainTimeSlot &slot) const final
GainTimeSlot & emplaceNewSlot(bool front, TFType tstart, TFType tend) final
void setUpdateTFInterval(uint32_t interval)
void setPreviousGains(CalibParams *previousGains)
std::vector< o2::ccdb::CcdbObjectInfo > & getCcdbInfoGainCalibDataVector()
const std::vector< CalibParams > & getGainsVector() const
GLboolean * data
Definition glcorearb.h:298
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.