Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
ChannelStatusConfigTool_tool.cc
Go to the documentation of this file.
1
// ChannelStatusConfigTool_tool.cc
2
3
#include "
ChannelStatusConfigTool.h
"
4
#include "
dunecore/DuneInterface/Data/AdcTypes.h
"
5
#include "
fhiclcpp/intermediate_table.h
"
6
#include "
fhiclcpp/make_ParameterSet.h
"
7
#include "
larevt/CalibrationDBI/Interface/ChannelStatusService.h
"
8
#include "
larevt/CalibrationDBI/Interface/ChannelStatusProvider.h
"
9
10
#include <iostream>
11
#include <iomanip>
12
13
using
std::cout;
14
using
std::endl
;
15
using
std::setw
;
16
using
Name
=
std::string
;
17
using
Index
=
ChannelStatusConfigTool::Index
;
18
19
//**********************************************************************
20
21
ChannelStatusConfigTool::ChannelStatusConfigTool
(
fhicl::ParameterSet
const
&
ps
)
22
: m_LogLevel(ps.
get
<
Index
>(
"LogLevel"
)),
23
m_DefaultIndex(ps.
get
<
Index
>(
"DefaultIndex"
)),
24
m_IndexVectors(ps.
get
<
IndexVectorVector
>(
"IndexVectors"
)) {
25
const
Name
myname =
"ChannelStatusConfigTool::ctor: "
;
26
if
(
m_LogLevel
>= 1 ) {
27
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
28
Index
nidx =
m_IndexVectors
.size();
29
Index
nsho = 0;
30
for
(
Index
iidx=0; iidx<nidx; ++iidx ) {
31
const
IndexVector
& vals =
m_IndexVectors
[iidx];
32
Index
nval = vals.size();
33
if
( nval == 0 )
continue
;
34
if
( nsho == 0 ) {
35
cout << myname <<
" Index Count"
<<
endl
;
36
}
37
++nsho;
38
cout << myname <<
setw
(7) << iidx <<
setw
(7) << nval <<
endl
;
39
}
40
}
41
// Build the map.
42
Index
idxSize = 0;
43
for
(
const
IndexVector
& vec :
m_IndexVectors
) {
44
for
(
Index
idx : vec ) {
45
if
( idx >= idxSize ) idxSize = idx + 1;
46
}
47
}
48
m_vals
.resize(idxSize,
m_DefaultIndex
);
49
Index
ivec = m_IndexVectors.size();
50
IndexVector
counts
(idxSize, 0);
51
while
( ivec ) {
52
const
IndexVector
& vec = m_IndexVectors[--ivec];
53
for
(
Index
idx : vec ) {
54
m_vals
[idx] = ivec;
55
++counts[idx];
56
}
57
}
58
if
(
m_LogLevel
== 2 ) {
59
Index
ndup = 0;
60
for
(
Index
idx=0; idx<idxSize; ++idx ) {
61
if
( counts[idx] > 1 ) {
62
if
( ndup >= 20 ) {
63
cout <<
", ..."
;
64
break
;
65
}
66
if
( ndup == 0 ) {
67
cout << myname <<
"Found indices with duplicate entries: "
;
68
}
else
{
69
cout <<
", "
;
70
}
71
cout << idx;
72
++ndup;
73
}
74
}
75
if
( ndup == 0 ) {
76
cout << myname <<
"No duplicate entries."
;
77
}
78
cout <<
endl
;
79
}
80
}
81
82
//**********************************************************************
83
84
Index
ChannelStatusConfigTool::get
(
Index
icha)
const
{
85
const
Name
myname =
"ChannelStatusConfigTool::get: "
;
86
if
( icha <
m_vals
.size() )
return
m_vals
[icha];
87
return
m_DefaultIndex
;
88
}
89
90
//**********************************************************************
91
92
DEFINE_ART_CLASS_TOOL
(
ChannelStatusConfigTool
)
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
intermediate_table.h
ChannelStatusConfigTool::m_LogLevel
Index m_LogLevel
Definition:
ChannelStatusConfigTool.h:57
string
std::string string
Definition:
nybbler.cc:12
ChannelStatusConfigTool::IndexVectorVector
std::vector< IndexVector > IndexVectorVector
Definition:
ChannelStatusConfigTool.h:43
ChannelStatusConfigTool::Index
IndexMapTool::Index Index
Definition:
ChannelStatusConfigTool.h:41
make_ParameterSet.h
Name
ChannelGroupService::Name Name
Definition:
FixedChannelGroupService_service.cc:19
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
ChannelStatusConfigTool
Definition:
ChannelStatusConfigTool.h:37
ChannelStatusConfigTool::m_vals
IndexVector m_vals
Definition:
ChannelStatusConfigTool.h:62
ChannelStatusConfigTool.h
ChannelStatusConfigTool::m_DefaultIndex
Index m_DefaultIndex
Definition:
ChannelStatusConfigTool.h:58
ChannelStatusConfigTool::m_IndexVectors
IndexVectorVector m_IndexVectors
Definition:
ChannelStatusConfigTool.h:59
ChannelStatusConfigTool::ChannelStatusConfigTool
ChannelStatusConfigTool(fhicl::ParameterSet const &ps)
Definition:
ChannelStatusConfigTool_tool.cc:21
util::quantities::counts
counts_as<> counts
Number of ADC counts, represented by signed short int.
Definition:
electronics.h:116
AdcTypes.h
ChannelStatusConfigTool::get
Index get(Index icha) const override
Definition:
ChannelStatusConfigTool_tool.cc:84
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
ChannelStatusProvider.h
Interface for experiment-specific channel quality info provider.
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
ChannelStatusService.h
Interface for experiment-specific service for channel quality info.
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
ChannelStatusConfigTool::IndexVector
std::vector< Index > IndexVector
Definition:
ChannelStatusConfigTool.h:42
Generated by
1.8.11