Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
BlockIndexMapTool_tool.cc
Go to the documentation of this file.
1
// BlockIndexMapTool_tool.cc
2
3
#include "
BlockIndexMapTool.h
"
4
#include "
fhiclcpp/make_ParameterSet.h
"
5
6
#include <iostream>
7
#include <iomanip>
8
9
using
std::cout;
10
using
std::endl
;
11
using
std::setw
;
12
using
Name
=
std::string
;
13
using
Index
=
BlockIndexMapTool::Index
;
14
15
//**********************************************************************
16
17
BlockIndexMapTool::BlockIndexMapTool
(
fhicl::ParameterSet
const
&
ps
)
18
: m_LogLevel(ps.
get
<
Index
>(
"LogLevel"
)),
19
m_Starts(ps.
get
<
IndexVector
>(
"Starts"
)),
20
m_Values(ps.
get
<
IndexVector
>(
"Values"
)),
21
m_Period(ps.
get
<
Index
>(
"Period"
)) {
22
const
Name
myname =
"BlockIndexMapTool::ctor: "
;
23
// Build teh map.
24
m_map
[0] = 0;
25
for
(
Index
ival=0; ival<
m_Starts
.size(); ++ival ) {
26
Index
idx =
m_Starts
[ival];
27
Index
val
= ival <
m_Values
.size() ?
m_Values
[ival] : 0;
28
m_map
[idx] =
val
;
29
}
30
// Display the parameters.
31
if
(
m_LogLevel
>= 1 ) {
32
// Use largest value to set the display width for indices and values.
33
Index
imax
= 0;
34
for
(
Index
val
:
m_Starts
)
if
(
val
> imax ) imax =
val
;
35
for
(
Index
val
:
m_Values
)
if
(
val
> imax ) imax =
val
;
36
Index
wid = 1;
37
Index
chk = 1;
38
while
( chk < imax ) {
39
chk *=10;
40
++wid;
41
}
42
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
43
cout << myname <<
" Starts: ["
;
44
bool
first =
true
;
45
for
(
Index
val
: m_Starts ) {
46
if
( first ) first =
false
;
47
else
cout <<
", "
;
48
cout <<
setw
(wid) <<
val
;
49
}
50
cout <<
"]"
<<
endl
;
51
cout << myname <<
" Values: ["
;
52
first =
true
;
53
for
(
Index
val
: m_Values ) {
54
if
( first ) first =
false
;
55
else
cout <<
", "
;
56
cout <<
setw
(wid) <<
val
;
57
}
58
cout <<
"]"
<<
endl
;
59
cout << myname <<
" Period: "
<<
m_Period
<<
endl
;
60
}
61
}
62
63
//**********************************************************************
64
65
Index
BlockIndexMapTool::get
(
Index
icha)
const
{
66
const
Name
myname =
"BlockIndexMapTool::get: "
;
67
Index
kcha =
m_Period
? icha%
m_Period
: icha;
68
return
(--
m_map
.upper_bound(kcha))->
second
;
69
}
70
71
//**********************************************************************
72
73
DEFINE_ART_CLASS_TOOL
(
BlockIndexMapTool
)
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
val
Definition:
registry_via_id_test_2.cc:15
string
std::string string
Definition:
nybbler.cc:12
BlockIndexMapTool.h
make_ParameterSet.h
Name
ChannelGroupService::Name Name
Definition:
FixedChannelGroupService_service.cc:19
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
BlockIndexMapTool::m_Starts
IndexVector m_Starts
Definition:
BlockIndexMapTool.h:53
BlockIndexMapTool::m_LogLevel
Index m_LogLevel
Definition:
BlockIndexMapTool.h:52
BlockIndexMapTool
Definition:
BlockIndexMapTool.h:31
BlockIndexMapTool::m_Period
Index m_Period
Definition:
BlockIndexMapTool.h:55
testsqlite3.val
list val
Definition:
testsqlite3.py:13
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
BlockIndexMapTool::Index
IndexMapTool::Index Index
Definition:
BlockIndexMapTool.h:35
BlockIndexMapTool::m_map
IndexMap m_map
Definition:
BlockIndexMapTool.h:58
tracks.imax
int imax
Definition:
tracks.py:195
BlockIndexMapTool::IndexVector
std::vector< Index > IndexVector
Definition:
BlockIndexMapTool.h:48
BlockIndexMapTool::BlockIndexMapTool
BlockIndexMapTool(fhicl::ParameterSet const &ps)
Definition:
BlockIndexMapTool_tool.cc:17
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
util::quantities::second
second_as<> second
Type of time stored in seconds, in double precision.
Definition:
spacetime.h:85
BlockIndexMapTool::get
Index get(Index icha) const override
Definition:
BlockIndexMapTool_tool.cc:65
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
BlockIndexMapTool::m_Values
IndexVector m_Values
Definition:
BlockIndexMapTool.h:54
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11