Project
Loading...
Searching...
No Matches
DigitFilter.cxx
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
13
15#include "Framework/Logger.h"
17#include "MCHStatus/StatusMap.h"
18#include <functional>
19#include <gsl/span>
20#include <vector>
21
22namespace
23{
28double signalCut(double* x, const double* p)
29{
30 double x0 = pow(p[0] / p[2], 1. / p[3]) + p[1];
31 if (x[0] < x0) {
32 return p[0];
33 } else {
34 return p[2] * pow(x[0] - p[1], p[3]);
35 }
36}
37
42double backgroundCut(double* x, const double* p)
43{
44
45 double x0 = (p[3] * p[2] - p[1] * p[0]) / (p[3] - p[1]);
46 if (x[0] < x0) {
47 return p[1] * (x[0] - p[0]);
48 } else {
49 return p[3] * (x[0] - p[2]);
50 }
51}
52
53o2::mch::DigitFilter createMinAdcCut(uint32_t minADC)
54{
55 return [minADC](const o2::mch::Digit& digit) -> bool {
56 if (digit.getADC() < minADC) {
57 return false;
58 }
59 return true;
60 };
61}
62
63o2::mch::DigitFilter createRejectBackground()
64{
65 uint16_t minNSamplesBackground = 14;
66 double backgroundParam[4] = {18., 24., -20., 7.0};
67
68 auto backgroundCut = [backgroundParam](double* x) {
69 return ::backgroundCut(x, backgroundParam);
70 };
71
72 return [backgroundCut, minNSamplesBackground](const o2::mch::Digit& digit) -> bool {
73 double nSample = digit.getNofSamples();
74 if (digit.getNofSamples() < minNSamplesBackground || digit.getADC() < backgroundCut(&nSample)) {
75 return false;
76 }
77 return true;
78 };
79}
80
81o2::mch::DigitFilter createSelectSignal()
82{
83 uint16_t minNSamplesSignal = 17;
84 double signalParam[4] = {80., 16., 12., 1.2};
85
86 auto signalCut = [signalParam](double* x) {
87 return ::signalCut(x, signalParam);
88 };
89 return [signalCut, minNSamplesSignal](const o2::mch::Digit& digit) -> bool {
90 double nSample = digit.getNofSamples();
91 if (digit.getNofSamples() < minNSamplesSignal || digit.getADC() < signalCut(&nSample)) {
92 return false;
93 }
94 return true;
95 };
96}
97} // namespace
98
99namespace o2::mch
100{
101void report(const std::map<int, std::vector<int>>& rejectList, uint32_t statusMask)
102{
103 int nbad{0};
104 for (const auto it : rejectList) {
105 nbad += it.second.size();
106 }
107 LOGP(info, "Got {} bad channels in {} detection element{} (using statusMask=0x{:x})", nbad,
108 rejectList.size(), rejectList.size() > 1 ? "s" : "", statusMask);
109}
110
112 uint32_t statusMask)
113{
114 auto rejectList = applyMask(statusMap, statusMask);
115 report(rejectList, statusMask);
116
117 return [rejectList](const o2::mch::Digit& digit) -> bool {
118 bool goodChannel{true};
119 auto deID = digit.getDetID();
120 auto it = rejectList.find(digit.getDetID());
121 if (it != rejectList.end()) {
122 // channel is good if it's not found in the rejectlist
123 goodChannel = std::find(it->second.begin(), it->second.end(), digit.getPadID()) == it->second.end();
124 }
125 return goodChannel;
126 };
127}
128
130 bool rejectBackground,
131 bool selectSignal,
132 const StatusMap& statusMap,
133 uint32_t statusMask)
134{
135 std::vector<DigitFilter> parts;
136
137 if (minADC > 0) {
138 parts.emplace_back(createMinAdcCut(minADC));
139 }
140 if (rejectBackground) {
141 parts.emplace_back(createRejectBackground());
142 }
143 if (selectSignal) {
144 parts.emplace_back(createSelectSignal());
145 }
146 if (!statusMap.empty() && statusMask) {
147 parts.emplace_back(createBadChannelFilter(statusMap, statusMask));
148 }
149 return [parts](const Digit& digit) {
150 for (const auto& p : parts) {
151 if (!p(digit)) {
152 return false;
153 }
154 }
155 return true;
156 };
157}
158
159} // namespace o2::mch
MCH digit implementation.
Definition Digit.h:31
bool empty() const
Definition StatusMap.h:93
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLfloat x0
Definition glcorearb.h:5034
std::map< int, std::vector< int > > applyMask(const o2::mch::StatusMap &statusMap, uint32_t mask)
std::function< bool(const Digit &)> DigitFilter
Definition DigitFilter.h:21
DigitFilter createDigitFilter(uint32_t minADC, bool rejectBackground, bool selectSignal, const StatusMap &statusMap={}, uint32_t statusMask=0)
DigitFilter createBadChannelFilter(const StatusMap &statusMap, uint32_t statusMask)
void report(const std::map< int, std::vector< int > > &rejectList, uint32_t statusMask)