Project
Loading...
Searching...
No Matches
TPCVDriftTglCalibration.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
15
16#ifndef TPC_VDrifITSTPCCalibration_H_
17#define TPC_VDrifITSTPCCalibration_H_
18
24#include "CCDB/CcdbObjectInfo.h"
25
26namespace o2::tpc
27{
29 std::unique_ptr<o2::dataformats::FlatHisto2D_f> histo;
30 size_t entries = 0;
31 size_t nTFProc = 0;
32 double driftVFullMean = 0.;
33 static float tOffsetRef;
34 static float driftVRef;
35 float tp = 0;
36
37 TPCVDTglContainer(int ntgl, float tglMax, int ndtgl, float dtglMax)
38 {
39 histo = std::make_unique<o2::dataformats::FlatHisto2D_f>(ntgl, -tglMax, tglMax, ndtgl, -dtglMax, dtglMax);
40 }
41
43 {
44 histo = std::make_unique<o2::dataformats::FlatHisto2D_f>(*(src.histo.get()));
45 entries = src.entries;
46 tp = src.tp;
47 driftVFullMean = src.driftVFullMean;
48 }
49
51 void fill(const gsl::span<const o2::dataformats::Triplet<float, float, float>> data, float currentTemperaturePressure = 0)
52 {
53 if (data.size() < 3) { // first 2 entres always contains the {full and reference VDrift} and {full and reference DriftTimeOffset} used for the TF
54 return;
55 }
56 for (size_t i = 2; i < data.size(); i++) {
57 auto& p = data[i];
58 auto bin = histo->fill(p.first, p.first - p.second);
59 LOGP(debug, "fill #{} : {} for {} {}", i - 1, bin, p.first, p.first - p.second);
60 if (bin > -1) {
61 entries++;
62 }
63 }
64 //
65 float vfull = data[0].first, vref = data[0].second;
66 const float temperaturePressure = (data[0].third == 0) ? currentTemperaturePressure : data[0].third;
67 if (driftVRef == 0.f) {
68 driftVRef = vref;
69 } else if (driftVRef != vref) {
70 LOGP(warn, "data with VDriftRef={} were received while initially was set to {}, keep old one", vref, driftVRef);
71 }
72 driftVFullMean = (driftVFullMean * nTFProc + vfull) / (nTFProc + 1);
73 tp = (tp * nTFProc + temperaturePressure) / (nTFProc + 1);
74 if (tOffsetRef == 0.f) {
75 tOffsetRef = data[1].first; // assign 1st full toffset as a reference
76 }
77 nTFProc++;
78 }
79
81 {
82 const int norm = nTFProc + other->nTFProc;
83 if (norm > 0) {
84 tp = (tp * nTFProc + other->tp * other->nTFProc) / norm;
85 driftVFullMean = (driftVFullMean * nTFProc + other->driftVFullMean * other->nTFProc) / norm;
86 }
87 entries += other->entries;
88 histo->add(*(other->histo));
89 LOGP(debug, "Old entries:{} New entries:{} oldSum: {} newSum: {}", other->entries, entries, other->histo->getSum(), histo->getSum());
90 }
91
92 void print() const
93 {
94 LOG(info) << "Nentries = " << entries;
95 }
97};
98
100{
102
103 public:
105 TPCVDriftTglCalibration(int ntgl, float tglMax, int ndtgl, float dtglMax, uint32_t slotL, float offsetFrac, float maxDelay, size_t minEnt, float offset = 0.f)
106 : mNBinsTgl(ntgl), mMaxTgl(tglMax), mNBinsDTgl(ndtgl), mMaxDTgl(dtglMax), mMineEntriesPerSlot(minEnt)
107 {
109 setMaxSlotsDelay(maxDelay);
110 setStartOffsetFrac(offsetFrac);
111 }
112
113 ~TPCVDriftTglCalibration() final = default;
114
115 bool hasEnoughData(const Slot& slot) const final { return slot.getContainer()->entries >= mMineEntriesPerSlot; }
116 void initOutput() final;
117 void finalizeSlot(Slot& slot) final;
118 Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
119
120 const std::vector<o2::tpc::VDriftCorrFact>& getVDPerSlot() const { return mVDPerSlot; }
121 const std::vector<o2::ccdb::CcdbObjectInfo>& getCCDBInfoPerSlot() const { return mCCDBInfoPerSlot; }
122 std::vector<o2::tpc::VDriftCorrFact>& getVDPerSlot() { return mVDPerSlot; }
123 std::vector<o2::ccdb::CcdbObjectInfo>& getCCDBInfoPerSlot() { return mCCDBInfoPerSlot; }
124
125 void setSaveHistosFile(const std::string& f) { mSaveHistosFile = f; }
126
127 private:
128 size_t mMineEntriesPerSlot = 10000;
129 int mNBinsTgl = 10;
130 int mNBinsDTgl = 100;
131 float mMaxTgl = 1.;
132 float mMaxDTgl = 0.2;
133 std::string mSaveHistosFile{};
134 std::vector<o2::tpc::VDriftCorrFact> mVDPerSlot;
135 std::vector<o2::ccdb::CcdbObjectInfo> mCCDBInfoPerSlot;
136
137 ClassDefNV(TPCVDriftTglCalibration, 1);
138};
139
140} // namespace o2::tpc
141#endif
2D messeageable histo class
int32_t i
uint64_t TFType
calibration data from laser track calibration
std::ostringstream debug
bool hasEnoughData(const Slot &slot) const final
TPCVDriftTglCalibration(int ntgl, float tglMax, int ndtgl, float dtglMax, uint32_t slotL, float offsetFrac, float maxDelay, size_t minEnt, float offset=0.f)
Slot & emplaceNewSlot(bool front, TFType tstart, TFType tend) final
void setSaveHistosFile(const std::string &f)
~TPCVDriftTglCalibration() final=default
const std::vector< o2::tpc::VDriftCorrFact > & getVDPerSlot() const
std::vector< o2::ccdb::CcdbObjectInfo > & getCCDBInfoPerSlot()
std::vector< o2::tpc::VDriftCorrFact > & getVDPerSlot()
const std::vector< o2::ccdb::CcdbObjectInfo > & getCCDBInfoPerSlot() const
GLenum src
Definition glcorearb.h:1767
GLdouble f
Definition glcorearb.h:310
GLboolean * data
Definition glcorearb.h:298
GLintptr offset
Definition glcorearb.h:660
Global TPC definitions and constants.
Definition SimTraits.h:167
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
ClassDefNV(TPCVDTglContainer, 2)
TPCVDTglContainer(const TPCVDTglContainer &src)
void fill(const gsl::span< const o2::dataformats::Triplet< float, float, float > > data, float currentTemperaturePressure=0)
std::unique_ptr< o2::dataformats::FlatHisto2D_f > histo
TPCVDTglContainer(int ntgl, float tglMax, int ndtgl, float dtglMax)
void merge(const TPCVDTglContainer *other)
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"