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 float tp{0.f};
46
47 bool isValid() const
48 {
49 return (std::abs(dvCorrectionA - 1.f) < 0.2) || (std::abs(dvCorrectionC - 1.f) < 0.2);
50 }
51
52 float getDriftVCorrection() const
53 {
54 float correction = 0;
55 int nCorr = 0;
56 // only allow +- 20% around reference correction
57 if (std::abs(dvCorrectionA - 1.f) < 0.2) {
58 correction += dvCorrectionA;
59 ++nCorr;
60 } else {
61 LOGP(warning, "abs(dvCorrectionA ({}) - 1) >= 0.2, not using for combined estimate", dvCorrectionA);
62 }
63
64 if (std::abs(dvCorrectionC - 1.f) < 0.2) {
65 correction += dvCorrectionC;
66 ++nCorr;
67 } else {
68 LOGP(warning, "abs(dvCorrectionC ({}) - 1) >= 0.2, not using for combined estimate", dvCorrectionC);
69 }
70
71 if (nCorr == 0) {
72 LOGP(error, "no valid drift velocity correction");
73 return 1.f;
74 }
75
76 return correction / nCorr;
77 }
78
79 float getVDrift() const { return refVDrift / getDriftVCorrection(); }
80
81 float getTimeOffset() const { return refTimeOffset + timeOffsetCorr; }
82
83 // renormalize reference and correction either to provided new reference (if >0) or to correction 1 wrt current reference
84 void normalize(float newVRef = 0.f)
85 {
86 if (refVDrift == 0.) {
87 LOG(error) << "LtrCalibData data has no reference";
88 return;
89 }
90 if (getDriftVCorrection() == 0) {
91 LOGP(error, "Drift correction is 0: dvCorrectionA={}, dvCorrectionC={}, nTracksA={}, nTracksC={}", dvCorrectionA, dvCorrectionC, nTracksA, nTracksC);
92 return;
93 }
94 if (newVRef == 0.) {
95 newVRef = refVDrift / getDriftVCorrection();
96 }
97 float fact = newVRef / refVDrift;
98 refVDrift = newVRef;
99 dvCorrectionA *= fact;
100 dvCorrectionC *= fact;
101 }
102
103 // similarly, the time offset reference is set to provided newRefTimeOffset (if > -998) or modified to have timeOffsetCorr to
104 // be 0 otherwise
105
106 void normalizeOffset(float newRefTimeOffset = -999.)
107 {
108 if (newRefTimeOffset > -999.) {
109 timeOffsetCorr = getTimeOffset() - newRefTimeOffset;
110 refTimeOffset = newRefTimeOffset;
111 } else {
113 timeOffsetCorr = 0.;
114 }
115 }
116
117 float getT0A() const { return (250.f * (1.f - dvCorrectionA) - dvOffsetA) / refVDrift; }
118 float getT0C() const { return (250.f * (1.f - dvCorrectionC) + dvOffsetC) / refVDrift; }
119 float getZOffsetA() const { return (250.f * (1.f - dvCorrectionA) - dvOffsetA) / dvCorrectionA; }
120 float getZOffsetC() const { return (250.f * (1.f - dvCorrectionC) + dvOffsetC) / dvCorrectionC; }
121
122 void reset()
123 {
124 processedTFs = 0;
125 firstTime = 0;
126 lastTime = 0;
127 creationTime = 0;
128 dvCorrectionA = 0;
129 dvCorrectionC = 0;
130 dvOffsetA = 0;
131 dvOffsetC = 0;
132 nTracksA = 0;
133 nTracksC = 0;
134 refVDrift = 0;
135 refTimeOffset = 0;
136 timeOffsetCorr = 0;
137 matchedLtrIDs.clear();
138 nTrackTF.clear();
139 dEdx.clear();
140 }
141
143};
144
145} // namespace o2::tpc
146#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 tp
temperature over pressure ratio
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
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
ClassDefNV(LtrCalibData, 5)
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"