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
36 TPCVDTglContainer(int ntgl, float tglMax, int ndtgl, float dtglMax)
37 {
38 histo = std::make_unique<o2::dataformats::FlatHisto2D_f>(ntgl, -tglMax, tglMax, ndtgl, -dtglMax, dtglMax);
39 }
40
42 {
43 histo = std::make_unique<o2::dataformats::FlatHisto2D_f>(*(src.histo.get()));
44 entries = src.entries;
45 }
46
48 {
49 if (data.size() < 3) { // first 2 entres always contains the {full and reference VDrift} and {full and reference DriftTimeOffset} used for the TF
50 return;
51 }
52 for (size_t i = 2; i < data.size(); i++) {
53 auto& p = data[i];
54 auto bin = histo->fill(p.first, p.first - p.second);
55 LOGP(debug, "fill #{} : {} for {} {}", i - 1, bin, p.first, p.first - p.second);
56 if (bin > -1) {
57 entries++;
58 }
59 }
60 //
61 float vfull = data[0].first, vref = data[0].second;
62 if (driftVRef == 0.f) {
63 driftVRef = vref;
64 } else if (driftVRef != vref) {
65 LOGP(warn, "data with VDriftRef={} were received while initially was set to {}, keep old one", vref, driftVRef);
66 }
67 driftVFullMean = (driftVFullMean * nTFProc + vfull) / (nTFProc + 1);
68 if (tOffsetRef == 0.f) {
69 tOffsetRef = data[1].first; // assign 1st full toffset as a reference
70 }
71 nTFProc++;
72 }
73
75 {
76 entries += other->entries;
77 histo->add(*(other->histo));
78 LOGP(debug, "Old entries:{} New entries:{} oldSum: {} newSum: {}", other->entries, entries, other->histo->getSum(), histo->getSum());
79 }
80
81 void print() const
82 {
83 LOG(info) << "Nentries = " << entries;
84 }
86};
87
89{
91
92 public:
94 TPCVDriftTglCalibration(int ntgl, float tglMax, int ndtgl, float dtglMax, uint32_t slotL, float offsetFrac, float maxDelay, size_t minEnt, float offset = 0.f)
95 : mNBinsTgl(ntgl), mMaxTgl(tglMax), mNBinsDTgl(ndtgl), mMaxDTgl(dtglMax), mMineEntriesPerSlot(minEnt)
96 {
98 setMaxSlotsDelay(maxDelay);
99 setStartOffsetFrac(offsetFrac);
100 }
101
102 ~TPCVDriftTglCalibration() final = default;
103
104 bool hasEnoughData(const Slot& slot) const final { return slot.getContainer()->entries >= mMineEntriesPerSlot; }
105 void initOutput() final;
106 void finalizeSlot(Slot& slot) final;
107 Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
108
109 const std::vector<o2::tpc::VDriftCorrFact>& getVDPerSlot() const { return mVDPerSlot; }
110 const std::vector<o2::ccdb::CcdbObjectInfo>& getCCDBInfoPerSlot() const { return mCCDBInfoPerSlot; }
111 std::vector<o2::tpc::VDriftCorrFact>& getVDPerSlot() { return mVDPerSlot; }
112 std::vector<o2::ccdb::CcdbObjectInfo>& getCCDBInfoPerSlot() { return mCCDBInfoPerSlot; }
113
114 void setSaveHistosFile(const std::string& f) { mSaveHistosFile = f; }
115
116 private:
117 size_t mMineEntriesPerSlot = 10000;
118 int mNBinsTgl = 10;
119 int mNBinsDTgl = 100;
120 float mMaxTgl = 1.;
121 float mMaxDTgl = 0.2;
122 std::string mSaveHistosFile{};
123 std::vector<o2::tpc::VDriftCorrFact> mVDPerSlot;
124 std::vector<o2::ccdb::CcdbObjectInfo> mCCDBInfoPerSlot;
125
126 ClassDefNV(TPCVDriftTglCalibration, 1);
127};
128
129} // namespace o2::tpc
130#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.
void fill(const gsl::span< const o2::dataformats::Triplet< float, float, float > > data)
TPCVDTglContainer(const TPCVDTglContainer &src)
std::unique_ptr< o2::dataformats::FlatHisto2D_f > histo
TPCVDTglContainer(int ntgl, float tglMax, int ndtgl, float dtglMax)
void merge(const TPCVDTglContainer *other)
ClassDefNV(TPCVDTglContainer, 1)
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"