Project
Loading...
Searching...
No Matches
BadChannelMap.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
12#include "EMCALBase/Geometry.h"
15
16#include <fairlogger/Logger.h>
17
18#include <TH2.h>
19
20#include <iostream>
21
22using namespace o2::emcal;
23
25{
26 if (channelID >= 17664) {
28 }
29 switch (mask) {
31 mBadCells.reset(channelID);
32 mWarmCells.reset(channelID);
33 mDeadCells.reset(channelID);
34 break;
36 mBadCells.reset(channelID);
37 mWarmCells.set(channelID);
38 mDeadCells.reset(channelID);
39 break;
41 mBadCells.set(channelID);
42 mWarmCells.reset(channelID);
43 mDeadCells.reset(channelID);
44 break;
46 mDeadCells.set(channelID);
47 mBadCells.reset(channelID);
48 mWarmCells.reset(channelID);
49 break;
50 };
51}
52
54{
55 if (channelID >= 17664) {
57 }
58 auto status = MaskType_t::GOOD_CELL;
59 if (mDeadCells.test(channelID)) {
60 status = MaskType_t::DEAD_CELL;
61 } else if (mBadCells.test(channelID)) {
62 status = MaskType_t::BAD_CELL;
63 } else if (mWarmCells.test(channelID)) {
64 status = MaskType_t::WARM_CELL;
65 }
66 return status;
67}
68
70{
71 const int MAXROWS = 208,
72 MAXCOLS = 96;
73 auto hist = new TH2S("badchannelmap", "Bad Channel Map", MAXCOLS, -0.5, double(MAXCOLS) - 0.5, MAXROWS, -0.5, double(MAXROWS) - 0.5);
74 hist->SetDirectory(nullptr);
75 try {
76 auto geo = Geometry::GetInstance();
77 for (size_t cellID = 0; cellID < mBadCells.size(); cellID++) {
78 int value(0);
79 if (mBadCells.test(cellID)) {
80 value = 1;
81 } else if (mDeadCells.test(cellID)) {
82 value = 2;
83 } else if (mWarmCells.test(cellID)) {
84 value = 3;
85 }
86 if (value) {
87 auto position = geo->GlobalRowColFromIndex(cellID);
88 hist->Fill(std::get<1>(position), std::get<0>(position), value);
89 }
90 }
92 LOG(error) << "Geometry needs to be initialized";
93 }
94 return hist;
95}
96
98{
99 for (size_t cellID = 0; cellID < mDeadCells.size(); cellID++) {
100 if (rhs.mDeadCells.test(cellID)) {
101 mDeadCells.set(cellID);
102 if (mBadCells.test(cellID)) {
103 mBadCells.reset(cellID);
104 }
105 if (mWarmCells.test(cellID)) {
106 mWarmCells.reset(cellID);
107 }
108 }
109 if (rhs.mBadCells.test(cellID) && !mDeadCells.test(cellID)) {
110 mBadCells.set(cellID);
111 if (mWarmCells.test(cellID)) {
112 mWarmCells.reset(cellID);
113 }
114 }
115 if (rhs.mWarmCells.test(cellID) && !(mBadCells.test(cellID) || mDeadCells.test(cellID))) {
116 mWarmCells.set(cellID);
117 }
118 }
119 return *this;
120}
121
123{
124 return mBadCells == other.mBadCells && mWarmCells == other.mWarmCells && mDeadCells == other.mDeadCells;
125}
126
127void BadChannelMap::PrintStream(std::ostream& stream) const
128{
129 // first sort bad channel IDs
130 stream << "Number of bad cells: " << mBadCells.count() << "\n";
131 stream << "Number of dead cells: " << mDeadCells.count() << "\n";
132 stream << "Number of warm cells: " << mWarmCells.count() << "\n";
133 for (size_t cellID = 0; cellID < mBadCells.size(); cellID++) {
134 if (mBadCells.test(cellID)) {
135 stream << "Channel " << cellID << ": Bad cell\n";
136 }
137 if (mDeadCells.test(cellID)) {
138 stream << "Channel " << cellID << ": Dead cell\n";
139 }
140 if (mWarmCells.test(cellID)) {
141 stream << "Channel " << cellID << ": Warm cell\n";
142 }
143 }
144}
145
146std::ostream& o2::emcal::operator<<(std::ostream& stream, const BadChannelMap& bcm)
147{
148 bcm.PrintStream(stream);
149 return stream;
150}
151
152std::ostream& o2::emcal::operator<<(std::ostream& stream, const BadChannelMap::MaskType_t& masktype)
153{
154 switch (masktype) {
156 stream << "Good cell";
157 break;
159 stream << "Warm cell";
160 break;
162 stream << "Bad cell";
163 break;
165 stream << "Dead cell";
166 break;
167 };
168 return stream;
169}
uint8_t channelID
Definition RawEventData.h:8
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
char error[CURL_ERROR_SIZE]
Acts::Vector3 position
CCDB container for masked cells in EMCAL.
void PrintStream(std::ostream &stream) const
Print bad channels on a given stream.
MaskType_t getChannelStatus(unsigned short channelID) const
Get the status of a certain cell.
bool operator==(const BadChannelMap &other) const
Comparison of two bad channel maps.
MaskType_t
Definition of mask types in the bad channel map.
@ DEAD_CELL
Dead cell, no data obtained.
@ BAD_CELL
Bad cell, must be excluded.
@ GOOD_CELL
GOOD cell, can be used without problems.
@ WARM_CELL
Warm cell, to be used with care.
void addBadChannel(unsigned short channelID, MaskType_t mask)
Add bad cell to the container.
BadChannelMap & operator+=(const BadChannelMap &rhs)
Add bad channel map to this bad channel map.
TH2 * getHistogramRepresentation() const
Convert map into 2D histogram representation.
Error handling for invalid index in calibration request.
Error handling access to non-initialized geometry.
static Geometry * GetInstance()
Get geometry instance. It should have been set before.
Definition Geometry.cxx:154
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLuint stream
Definition glcorearb.h:1806
GLint GLuint mask
Definition glcorearb.h:291
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:366
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"