forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBadChannelsMap.cxx
More file actions
99 lines (87 loc) · 2.69 KB
/
BadChannelsMap.cxx
File metadata and controls
99 lines (87 loc) · 2.69 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
// 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.
#include "PHOSBase/Geometry.h"
#include "DataFormatsPHOS/BadChannelsMap.h"
#include <fairlogger/Logger.h>
#include <TH2.h>
#include <iostream>
using namespace o2::phos;
BadChannelsMap::BadChannelsMap(int /*dummy*/)
{
// Mark few channels as bad for test peurposes
for (short i = 0; i < 56; i++) {
// module 2
short channelID = 3584 + i * 57;
mBadCells.set(channelID - OFFSET);
channelID = 3640 + i * 55;
mBadCells.set(channelID - OFFSET);
}
for (short i = 0; i < 16; i++) {
// module 3
int channelID = 8972 + i * 57;
mBadCells.set(channelID - OFFSET);
channelID = 8092 + i * 57;
mBadCells.set(channelID - OFFSET);
channelID = 8147 + i * 55;
mBadCells.set(channelID - OFFSET);
channelID = 9059 + i * 55;
mBadCells.set(channelID - OFFSET);
}
}
void BadChannelsMap::getHistogramRepresentation(char module, TH2* h) const
{
const char MAXX = 64,
MAXZ = 56;
if (module < 1 || module > 4) {
LOG(error) << "module " << module << "does not exist";
return;
}
if (!h) {
LOG(error) << "provide histogram to be filled";
}
if (h->GetNbinsX() != MAXX || h->GetNbinsY() != MAXZ) {
LOG(error) << "Wrong dimentions of input histogram:" << h->GetNbinsX() << "," << h->GetNbinsY() << " instead of " << MAXX << "," << MAXZ;
return;
}
h->Reset();
int8_t relid[3] = {module, 1, 1};
short absId;
int8_t xmin = 1;
if (module == 1) {
xmin = 33;
}
for (int8_t ix = xmin; ix <= MAXX; ix++) {
relid[1] = ix;
for (int8_t iz = 1; iz <= MAXZ; iz++) {
relid[2] = iz;
if (o2::phos::Geometry::relToAbsNumbering(relid, absId)) {
if (!isChannelGood(absId)) {
h->SetBinContent(ix, iz, 1);
}
}
}
}
}
void BadChannelsMap::PrintStream(std::ostream& stream) const
{
// first sort bad channel IDs
stream << "Number of bad cells: " << mBadCells.count() << "\n";
for (std::size_t cellID = 0; cellID < mBadCells.size(); cellID++) {
if (mBadCells.test(cellID)) {
stream << cellID + OFFSET << "\n";
}
}
}
std::ostream& o2::phos::operator<<(std::ostream& stream, const BadChannelsMap& bcm)
{
bcm.PrintStream(stream);
return stream;
}