forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalVdriftExB.h
More file actions
130 lines (113 loc) · 3.78 KB
/
CalVdriftExB.h
File metadata and controls
130 lines (113 loc) · 3.78 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
// 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 CalVdriftExB.h
/// \brief Object with vDrift and ExB values per chamber to be written into the CCDB
#ifndef ALICEO2_CALVDRIFTEXB_H
#define ALICEO2_CALVDRIFTEXB_H
#include "DataFormatsTRD/Constants.h"
#include "Rtypes.h"
#include <array>
namespace o2
{
namespace trd
{
class CalVdriftExB
{
public:
CalVdriftExB() = default;
CalVdriftExB(const CalVdriftExB&) = default;
~CalVdriftExB() = default;
void setVdrift(int iDet, float vd) { mVdrift[iDet] = vd; }
void setExB(int iDet, float exb) { mExB[iDet] = exb; }
float getVdrift(int iDet, bool defaultAvg = false) const
{
// if defaultAvg = false, we take the value stored whatever it is
// if defaultAvg = true and we have default value or bad value stored, we take the average on all chambers instead
if (!defaultAvg || (isGoodExB(iDet) && isGoodVdrift(iDet)))
return mVdrift[iDet];
else
return getAverageVdrift();
}
float getExB(int iDet, bool defaultAvg = false) const
{
if (!defaultAvg || (isGoodExB(iDet) && isGoodVdrift(iDet)))
return mExB[iDet];
else
return getAverageExB();
}
float getAverageVdrift() const
{
float averageVdrift = 0.;
int ngood = 0;
for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) {
if (isGoodExB(iDet) && isGoodVdrift(iDet)) {
// Both values need to be correct to declare a chamber as well calibrated
ngood++;
averageVdrift += mVdrift[iDet];
}
}
if (ngood == 0) {
// we should make sure it never happens
return constants::VDRIFTDEFAULT;
}
averageVdrift /= ngood;
return averageVdrift;
}
float getAverageExB() const
{
float averageExB = 0.;
int ngood = 0;
for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) {
if (isGoodExB(iDet) && isGoodVdrift(iDet)) {
// Both values need to be correct to declare a chamber as well calibrated
ngood++;
averageExB += mExB[iDet];
}
}
if (ngood == 0) {
// we should make sure it never happens
return constants::EXBDEFAULT;
}
averageExB /= ngood;
return averageExB;
}
bool isGoodExB(int iDet) const
{
// check if value is well calibrated or not
// default calibration if not enough entries
// close to boundaries indicate a failed fit
if (TMath::Abs(mExB[iDet] - constants::EXBDEFAULT) > 1e-6 &&
TMath::Abs(mExB[iDet] - constants::EXBMIN) > 0.01 &&
TMath::Abs(mExB[iDet] - constants::EXBMAX) > 0.01)
return true;
else
return false;
}
bool isGoodVdrift(int iDet) const
{
// check if value is well calibrated or not
// default calibration if not enough entries
// close to boundaries indicate a failed fit
if (TMath::Abs(mVdrift[iDet] - constants::VDRIFTDEFAULT) > 1e-6 &&
TMath::Abs(mVdrift[iDet] - constants::VDRIFTMIN) > 0.1 &&
TMath::Abs(mVdrift[iDet] - constants::VDRIFTMAX) > 0.1)
return true;
else
return false;
}
private:
std::array<float, constants::MAXCHAMBER> mVdrift{}; ///< calibrated drift velocity per TRD chamber
std::array<float, constants::MAXCHAMBER> mExB{}; ///< calibrated Lorentz angle per TRD chamber
ClassDefNV(CalVdriftExB, 2);
};
} // namespace trd
} // namespace o2
#endif // ALICEO2_CALVDRIFTEXB_H