Project
Loading...
Searching...
No Matches
ChamberEfficiency.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
16
18
19#include <iostream>
21#include "MIDBase/Mapping.h"
22
23namespace o2
24{
25namespace mid
26{
27
28void ChamberEfficiency::setFromCounters(const std::vector<ChEffCounter>& counters)
29{
30 mCounters.clear();
31 for (auto& count : counters) {
32 mCounters[detparams::makeUniqueFEEId(count.deId, count.columnId, count.lineId)] = count;
33 }
34}
35
36std::vector<ChEffCounter> ChamberEfficiency::getCountersAsVector() const
37{
38 std::vector<ChEffCounter> counters;
39 for (auto& count : mCounters) {
40 counters.emplace_back(count.second);
41 }
42 return counters;
43}
44
45EffCountType ChamberEfficiency::convert(EffType type) const
46{
47 switch (type) {
54 }
55 return EffCountType::BothPlanes; // Never used
56}
57
58double ChamberEfficiency::getEfficiency(int deId, int columnId, int lineId, EffType type) const
59{
60 auto idx = detparams::makeUniqueFEEId(deId, columnId, lineId);
61 auto entryTot = mCounters.find(idx);
62 if (entryTot == mCounters.end()) {
63 std::cerr << "Warning: no efficiency found for deId: " << deId << " column: " << columnId << " line: " << lineId << " type: " << static_cast<int>(type) << "\n";
64 return -1.;
65 }
66 return static_cast<double>(entryTot->second.getCounts(convert(type))) / static_cast<double>(entryTot->second.getCounts(EffCountType::AllTracks));
67}
68
69//______________________________________________________________________________
70void ChamberEfficiency::addEntry(bool isEfficientBP, bool isEfficientNBP, int deId, int columnId, int lineId)
71{
72 auto& entry = mCounters[detparams::makeUniqueFEEId(deId, columnId, lineId)];
73 entry.deId = deId;
74 entry.columnId = columnId;
75 entry.lineId = lineId;
76 ++entry.counts[3];
77 if (isEfficientBP) {
78 ++entry.counts[0];
79 }
80 if (isEfficientNBP) {
81 ++entry.counts[1];
82 }
83 if (isEfficientBP && isEfficientNBP) {
84 ++entry.counts[2];
85 }
86}
87
89{
91 ChamberEfficiency effMap;
92 Mapping mapping;
93 uint32_t nevents = 10000;
94 for (int ide = 0; ide < detparams::NDetectionElements; ++ide) {
95 for (int icol = mapping.getFirstColumn(ide); icol < 7; ++icol) {
96 for (int iline = mapping.getFirstBoardBP(icol, ide); iline <= mapping.getLastBoardBP(icol, ide); ++iline) {
97 for (uint32_t ievent = 0; ievent < nevents; ++ievent) {
98 effMap.addEntry(true, true, ide, icol, iline);
99 }
100 }
101 }
102 }
103
104 return effMap;
105}
106
107} // namespace mid
108} // namespace o2
Measured values of the RPC efficiency.
Useful detector parameters for MID.
Mapping for MID.
@ BendPlane
Bending plane efficiency.
@ BothPlanes
Both plane efficiency.
@ NonBendPlane
Non-bending plane efficiency.
double getEfficiency(int deId, int columnId, int lineId, EffType type) const
std::vector< ChEffCounter > getCountersAsVector() const
void addEntry(bool isEfficientBP, bool isEfficientNBP, int deId, int columnId, int lineId)
void setFromCounters(const std::vector< ChEffCounter > &counters)
int getFirstColumn(int deId) const
Definition Mapping.cxx:169
int getLastBoardBP(int column, int deId) const
Definition Mapping.cxx:188
int getFirstBoardBP(int column, int deId) const
Definition Mapping.cxx:178
GLint GLsizei count
Definition glcorearb.h:399
GLuint entry
Definition glcorearb.h:5735
GLint GLint GLsizei GLuint * counters
Definition glcorearb.h:3985
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
constexpr int NDetectionElements
Number of RPCs.
uint16_t makeUniqueFEEId(int deId, int columnId, int lineId)
@ BendPlane
Bending plane counters.
@ BothPlanes
Both plane counters.
@ AllTracks
All tracks counters.
ChamberEfficiency createDefaultChamberEfficiency()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...