Project
Loading...
Searching...
No Matches
CalGain.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
14
15#ifndef ALICEO2_CALGAIN_H
16#define ALICEO2_CALGAIN_H
17
19#include "Rtypes.h"
20#include <array>
21
22namespace o2
23{
24namespace trd
25{
26
28{
29 public:
30 CalGain() = default;
31 CalGain(const CalGain&) = default;
32 ~CalGain() = default;
33
34 void setMPVdEdx(int iDet, float mpv) { mMPVdEdx[iDet] = mpv; }
35
36 float getMPVdEdx(int iDet, bool defaultAvg = true) const
37 {
38 // if defaultAvg = false, we take the value stored whatever it is
39 // if defaultAvg = true and we have default value or bad value stored, we take the average on all chambers instead
40 if (!defaultAvg || isGoodGain(iDet))
41 return mMPVdEdx[iDet];
42 else {
43 if (TMath::Abs(mMeanGain + 999.) < 1e-6)
44 mMeanGain = getAverageGain();
45 return mMeanGain;
46 }
47 }
48
49 float getAverageGain() const
50 {
51 float averageGain = 0.;
52 int ngood = 0;
53
54 for (int iDet = 0; iDet < constants::MAXCHAMBER; iDet++) {
55 if (isGoodGain(iDet)) {
56 // The chamber has correct calibration
57 ngood++;
58 averageGain += mMPVdEdx[iDet];
59 }
60 }
61 if (ngood == 0) {
62 // we should make sure it never happens
64 }
65 averageGain /= ngood;
66 return averageGain;
67 }
68
69 bool isGoodGain(int iDet) const
70 {
71 if (TMath::Abs(mMPVdEdx[iDet] - constants::MPVDEDXDEFAULT) > 1e-6)
72 return true;
73 else
74 return false;
75 }
76
77 private:
78 std::array<float, constants::MAXCHAMBER> mMPVdEdx{};
79 mutable float mMeanGain{-999.};
80
81 ClassDefNV(CalGain, 2);
82};
83
84} // namespace trd
85} // namespace o2
86
87#endif // ALICEO2_CALGAIN_H
Global TRD definitions and constants.
void setMPVdEdx(int iDet, float mpv)
Definition CalGain.h:34
CalGain(const CalGain &)=default
~CalGain()=default
CalGain()=default
float getAverageGain() const
Definition CalGain.h:49
bool isGoodGain(int iDet) const
Definition CalGain.h:69
float getMPVdEdx(int iDet, bool defaultAvg=true) const
Definition CalGain.h:36
constexpr float MPVDEDXDEFAULT
default Most Probable Value of TRD dEdx
Definition Constants.h:84
constexpr int MAXCHAMBER
the maximum number of installed chambers
Definition Constants.h:30
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...