Project
Loading...
Searching...
No Matches
LtrCalibData.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
18
19#ifndef AliceO2_TPC_LtrCalibData_H_
20#define AliceO2_TPC_LtrCalibData_H_
21
22#include <fairlogger/Logger.h>
23#include <Rtypes.h>
24
25namespace o2::tpc
26{
27
29 size_t processedTFs{};
30 uint64_t firstTime{};
31 uint64_t lastTime{};
32 long creationTime{};
33 float dvCorrectionA{1.f};
34 float dvCorrectionC{1.f};
35 float dvOffsetA{};
36 float dvOffsetC{};
37 float refVDrift{};
38 float refTimeOffset{0.};
39 float timeOffsetCorr{0.};
40 uint16_t nTracksA{};
41 uint16_t nTracksC{};
42 std::vector<uint16_t> matchedLtrIDs;
43 std::vector<uint16_t> nTrackTF;
44 std::vector<float> dEdx;
45
46 bool isValid() const
47 {
48 return (std::abs(dvCorrectionA - 1.f) < 0.2) || (std::abs(dvCorrectionC - 1.f) < 0.2);
49 }
50
51 float getDriftVCorrection() const
52 {
53 float correction = 0;
54 int nCorr = 0;
55 // only allow +- 20% around reference correction
56 if (std::abs(dvCorrectionA - 1.f) < 0.2) {
57 correction += dvCorrectionA;
58 ++nCorr;
59 } else {
60 LOGP(warning, "abs(dvCorrectionA ({}) - 1) >= 0.2, not using for combined estimate", dvCorrectionA);
61 }
62
63 if (std::abs(dvCorrectionC - 1.f) < 0.2) {
64 correction += dvCorrectionC;
65 ++nCorr;
66 } else {
67 LOGP(warning, "abs(dvCorrectionC ({}) - 1) >= 0.2, not using for combined estimate", dvCorrectionC);
68 }
69
70 if (nCorr == 0) {
71 LOGP(error, "no valid drift velocity correction");
72 return 1.f;
73 }
74
75 return correction / nCorr;
76 }
77
78 float getVDrift() const { return refVDrift / getDriftVCorrection(); }
79
80 float getTimeOffset() const { return refTimeOffset + timeOffsetCorr; }
81
82 // renormalize reference and correction either to provided new reference (if >0) or to correction 1 wrt current reference
83 void normalize(float newVRef = 0.f)
84 {
85 if (refVDrift == 0.) {
86 LOG(error) << "LtrCalibData data has no reference";
87 return;
88 }
89 if (getDriftVCorrection() == 0) {
90 LOGP(error, "Drift correction is 0: dvCorrectionA={}, dvCorrectionC={}, nTracksA={}, nTracksC={}", dvCorrectionA, dvCorrectionC, nTracksA, nTracksC);
91 return;
92 }
93 if (newVRef == 0.) {
94 newVRef = refVDrift / getDriftVCorrection();
95 }
96 float fact = newVRef / refVDrift;
97 refVDrift = newVRef;
98 dvCorrectionA *= fact;
99 dvCorrectionC *= fact;
100 }
101
102 // similarly, the time offset reference is set to provided newRefTimeOffset (if > -998) or modified to have timeOffsetCorr to
103 // be 0 otherwise
104
105 void normalizeOffset(float newRefTimeOffset = -999.)
106 {
107 if (newRefTimeOffset > -999.) {
108 timeOffsetCorr = getTimeOffset() - newRefTimeOffset;
109 refTimeOffset = newRefTimeOffset;
110 } else {
112 timeOffsetCorr = 0.;
113 }
114 }
115
116 float getT0A() const { return (250.f * (1.f - dvCorrectionA) - dvOffsetA) / refVDrift; }
117 float getT0C() const { return (250.f * (1.f - dvCorrectionC) + dvOffsetC) / refVDrift; }
118 float getZOffsetA() const { return (250.f * (1.f - dvCorrectionA) - dvOffsetA) / dvCorrectionA; }
119 float getZOffsetC() const { return (250.f * (1.f - dvCorrectionC) + dvOffsetC) / dvCorrectionC; }
120
121 void reset()
122 {
123 processedTFs = 0;
124 firstTime = 0;
125 lastTime = 0;
126 creationTime = 0;
127 dvCorrectionA = 0;
128 dvCorrectionC = 0;
129 dvOffsetA = 0;
130 dvOffsetC = 0;
131 nTracksA = 0;
132 nTracksC = 0;
133 refVDrift = 0;
134 refTimeOffset = 0;
135 timeOffsetCorr = 0;
136 matchedLtrIDs.clear();
137 nTrackTF.clear();
138 dEdx.clear();
139 }
140
142};
143
144} // namespace o2::tpc
145#endif
Global TPC definitions and constants.
Definition SimTraits.h:167
std::vector< uint16_t > nTrackTF
number of laser tracks per TF
float timeOffsetCorr
additive time offset correction (\mus)
float getDriftVCorrection() const
float getVDrift() const
void normalize(float newVRef=0.f)
float dvCorrectionA
drift velocity correction factor A-Side (inverse multiplicative)
float dvOffsetC
drift velocity trigger offset C-Side
float dvOffsetA
drift velocity trigger offset A-Side
float dvCorrectionC
drift velocity correction factor C-Side (inverse multiplicative)
std::vector< uint16_t > matchedLtrIDs
matched laser track IDs
std::vector< float > dEdx
dE/dx of each track
size_t processedTFs
number of processed TFs with laser track candidates
uint64_t lastTime
last time stamp of processed TFs
ClassDefNV(LtrCalibData, 4)
void normalizeOffset(float newRefTimeOffset=-999.)
float getZOffsetA() const
uint16_t nTracksC
number of tracks used for C-Side fit
float getTimeOffset() const
long creationTime
time of creation
uint16_t nTracksA
number of tracks used for A-Side fit
float getZOffsetC() const
float refTimeOffset
additive time offset reference (\mus)
float refVDrift
reference vdrift for which factor was extracted
uint64_t firstTime
first time stamp of processed TFs
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"