forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLtrCalibData.h
More file actions
146 lines (127 loc) · 5.13 KB
/
LtrCalibData.h
File metadata and controls
146 lines (127 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file LtrCalibData.h
/// \brief calibration data from laser track calibration
///
/// This class holds the calibration output data of CalibLaserTracks
///
/// \author Jens Wiechula, Jens.Wiechula@ikf.uni-frankfurt.de
#ifndef AliceO2_TPC_LtrCalibData_H_
#define AliceO2_TPC_LtrCalibData_H_
#include <fairlogger/Logger.h>
#include <Rtypes.h>
namespace o2::tpc
{
struct LtrCalibData {
size_t processedTFs{}; ///< number of processed TFs with laser track candidates
uint64_t firstTime{}; ///< first time stamp of processed TFs
uint64_t lastTime{}; ///< last time stamp of processed TFs
long creationTime{}; ///< time of creation
float dvCorrectionA{1.f}; ///< drift velocity correction factor A-Side (inverse multiplicative)
float dvCorrectionC{1.f}; ///< drift velocity correction factor C-Side (inverse multiplicative)
float dvOffsetA{}; ///< drift velocity trigger offset A-Side
float dvOffsetC{}; ///< drift velocity trigger offset C-Side
float refVDrift{}; ///< reference vdrift for which factor was extracted
float refTimeOffset{0.}; ///< additive time offset reference (\mus)
float timeOffsetCorr{0.}; ///< additive time offset correction (\mus)
uint16_t nTracksA{}; ///< number of tracks used for A-Side fit
uint16_t nTracksC{}; ///< number of tracks used for C-Side fit
std::vector<uint16_t> matchedLtrIDs; ///< matched laser track IDs
std::vector<uint16_t> nTrackTF; ///< number of laser tracks per TF
std::vector<float> dEdx; ///< dE/dx of each track
float tp{0.f}; ///< temperature over pressure ratio
bool isValid() const
{
return (std::abs(dvCorrectionA - 1.f) < 0.2) || (std::abs(dvCorrectionC - 1.f) < 0.2);
}
float getDriftVCorrection() const
{
float correction = 0;
int nCorr = 0;
// only allow +- 20% around reference correction
if (std::abs(dvCorrectionA - 1.f) < 0.2) {
correction += dvCorrectionA;
++nCorr;
} else {
LOGP(warning, "abs(dvCorrectionA ({}) - 1) >= 0.2, not using for combined estimate", dvCorrectionA);
}
if (std::abs(dvCorrectionC - 1.f) < 0.2) {
correction += dvCorrectionC;
++nCorr;
} else {
LOGP(warning, "abs(dvCorrectionC ({}) - 1) >= 0.2, not using for combined estimate", dvCorrectionC);
}
if (nCorr == 0) {
LOGP(error, "no valid drift velocity correction");
return 1.f;
}
return correction / nCorr;
}
float getVDrift() const { return refVDrift / getDriftVCorrection(); }
float getTimeOffset() const { return refTimeOffset + timeOffsetCorr; }
// renormalize reference and correction either to provided new reference (if >0) or to correction 1 wrt current reference
void normalize(float newVRef = 0.f)
{
if (refVDrift == 0.) {
LOG(error) << "LtrCalibData data has no reference";
return;
}
if (getDriftVCorrection() == 0) {
LOGP(error, "Drift correction is 0: dvCorrectionA={}, dvCorrectionC={}, nTracksA={}, nTracksC={}", dvCorrectionA, dvCorrectionC, nTracksA, nTracksC);
return;
}
if (newVRef == 0.) {
newVRef = refVDrift / getDriftVCorrection();
}
float fact = newVRef / refVDrift;
refVDrift = newVRef;
dvCorrectionA *= fact;
dvCorrectionC *= fact;
}
// similarly, the time offset reference is set to provided newRefTimeOffset (if > -998) or modified to have timeOffsetCorr to
// be 0 otherwise
void normalizeOffset(float newRefTimeOffset = -999.)
{
if (newRefTimeOffset > -999.) {
timeOffsetCorr = getTimeOffset() - newRefTimeOffset;
refTimeOffset = newRefTimeOffset;
} else {
refTimeOffset = getTimeOffset();
timeOffsetCorr = 0.;
}
}
float getT0A() const { return (250.f * (1.f - dvCorrectionA) - dvOffsetA) / refVDrift; }
float getT0C() const { return (250.f * (1.f - dvCorrectionC) + dvOffsetC) / refVDrift; }
float getZOffsetA() const { return (250.f * (1.f - dvCorrectionA) - dvOffsetA) / dvCorrectionA; }
float getZOffsetC() const { return (250.f * (1.f - dvCorrectionC) + dvOffsetC) / dvCorrectionC; }
void reset()
{
processedTFs = 0;
firstTime = 0;
lastTime = 0;
creationTime = 0;
dvCorrectionA = 0;
dvCorrectionC = 0;
dvOffsetA = 0;
dvOffsetC = 0;
nTracksA = 0;
nTracksC = 0;
refVDrift = 0;
refTimeOffset = 0;
timeOffsetCorr = 0;
matchedLtrIDs.clear();
nTrackTF.clear();
dEdx.clear();
}
ClassDefNV(LtrCalibData, 5);
};
} // namespace o2::tpc
#endif