Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
FclRunDataTool_tool.cc
Go to the documentation of this file.
1
// FclRunDataTool_tool.cc
2
3
#include "
FclRunDataTool.h
"
4
#include "
dunecore/DuneCommon/Utility/StringManipulator.h
"
5
#include "
fhiclcpp/intermediate_table.h
"
6
#include "
fhiclcpp/make_ParameterSet.h
"
7
#include "TString.h"
8
#include "TSystem.h"
9
#include <iostream>
10
11
using
std::cout;
12
using
std::endl
;
13
using
std::string
;
14
15
//**********************************************************************
16
17
namespace
{
18
19
using
Name
=
FclRunDataTool::Name
;
20
using
Index
=
RunData::Index
;
21
using
IndexVector
=
RunData::IndexVector
;
22
23
int
parseFcl(
string
path,
string
fclname,
RunData
& rdat) {
24
TString ts(fclname.c_str());
25
gSystem->FindFile(path.c_str(), ts);
26
string
pfname = ts.Data();
27
if
( pfname.size() == 0 )
return
1;
28
cet::filepath_maker
policy;
29
auto
ps
=
fhicl::ParameterSet::make
(
fhicl::parse_document
(pfname, policy));
30
ps
.get_if_present<
Index
>(
"run"
, rdat.
accessRun
());
31
ps
.get_if_present<
string
>(
"cryostat"
, rdat.
accessCryostat
());
32
ps
.get_if_present<
IndexVector
>(
"apas"
, rdat.
accessApas
());
33
ps
.get_if_present<
float
>(
"gain"
, rdat.
accessGain
());
34
ps
.get_if_present<
float
>(
"shaping"
, rdat.
accessShaping
());
35
ps
.get_if_present<
float
>(
"baseline"
, rdat.
accessBaseline
());
36
ps
.get_if_present<
float
>(
"leakage"
, rdat.
accessLeakage
());
37
ps
.get_if_present<
float
>(
"hvfrac"
, rdat.
accessHvfrac
());
38
ps
.get_if_present<
Index
>(
"pulserAmplitude"
, rdat.
accessPulserAmplitude
());
39
ps
.get_if_present<
Index
>(
"pulserSource"
, rdat.
accessPulserSource
());
40
ps
.get_if_present<
Index
>(
"pulserPeriod"
, rdat.
accessPulserPeriod
());
41
ps
.get_if_present<
Name
>(
"phaseGroup"
, rdat.
accessPhaseGroup
());
42
ps
.get_if_present<
IndexVector
>(
"phases"
, rdat.
accessPhases
());
43
return
0;
44
}
45
46
}
// end unnamed namespace
47
48
//**********************************************************************
49
50
FclRunDataTool::FclRunDataTool
(
fhicl::ParameterSet
const
&
ps
)
51
: m_LogLevel(ps.
get
<
Index
>(
"LogLevel"
)),
52
m_FileNames(ps.
get
<
NameVector
>(
"FileNames"
)) {
53
const
Name
myname =
"FclRunDataTool::ctor: "
;
54
m_fclPath
= gSystem->Getenv(
"FHICL_FILE_PATH"
);
55
if
(
m_LogLevel
) {
56
cout << myname <<
"Configuration:"
<<
endl
;
57
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
58
cout << myname <<
" FileNames: "
;
59
if
(
m_FileNames
.size() == 0 ) {
60
cout <<
"<empty>"
;
61
}
62
for
(
Name
fname
:
m_FileNames
) {
63
cout <<
"\n"
<< myname <<
" "
<<
fname
;
64
}
65
cout <<
endl
;
66
}
67
}
68
69
//**********************************************************************
70
71
RunData
FclRunDataTool::runData
(
Index
run
,
Index
subRun)
const
{
72
const
Name
myname =
"FclRunDataTool::runData: "
;
73
RunData
rdat;
74
bool
useSubRun = subRun;
75
if
(
m_LogLevel
>= 2 ) {
76
cout << myname <<
"Fetching tool for run "
<<
run
;
77
if
( useSubRun ) cout <<
", subrun "
<< subRun;
78
cout <<
endl
;
79
}
80
for
(
Name
fname
:
m_FileNames
) {
81
StringManipulator
sman(
fname
,
false
);
82
sman.
replaceFixedWidth
(
"%RUN%"
, run, 6);
83
sman.
replaceFixedWidth
(
"%SUBRUN%"
, subRun, 6);
84
if
( parseFcl(
m_fclPath
,
fname
, rdat) ) {
85
if
(
m_LogLevel
>= 3 ) cout << myname <<
"Unable to find/read "
<<
fname
<<
endl
;
86
}
else
{
87
if
(
m_LogLevel
>= 3 ) cout << myname <<
" Read "
<<
fname
<<
endl
;
88
}
89
}
90
return
rdat;
91
}
92
93
//**********************************************************************
94
95
DEFINE_ART_CLASS_TOOL
(
FclRunDataTool
)
IndexVector
std::vector< Index > IndexVector
Definition:
test_FclIndexVectorMapTool.cxx:26
FclRunDataTool::runData
RunData runData(Index run, Index subRun) const override
Definition:
FclRunDataTool_tool.cc:71
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
intermediate_table.h
string
std::string string
Definition:
nybbler.cc:12
fhicl::ParameterSet::make
static ParameterSet make(intermediate_table const &tbl)
Definition:
ParameterSet.cc:68
FclRunDataTool::m_fclPath
Name m_fclPath
Definition:
FclRunDataTool.h:49
RunData
Definition:
RunData.h:21
RunData::accessGain
float & accessGain()
Definition:
RunData.h:158
make_ParameterSet.h
Name
ChannelGroupService::Name Name
Definition:
FixedChannelGroupService_service.cc:19
RunData::accessBaseline
float & accessBaseline()
Definition:
RunData.h:160
FclRunDataTool
Definition:
FclRunDataTool.h:27
RunData::accessLeakage
float & accessLeakage()
Definition:
RunData.h:161
FclRunDataTool::m_FileNames
NameVector m_FileNames
Definition:
FclRunDataTool.h:47
wirecell.sigproc.paper.noise.fname
fname
Definition:
noise.py:68
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
FclRunDataTool::m_LogLevel
Index m_LogLevel
Definition:
FclRunDataTool.h:46
FclRunDataTool::FclRunDataTool
FclRunDataTool(fhicl::ParameterSet const &ps)
Definition:
FclRunDataTool_tool.cc:50
RunData::accessPhases
IndexVector & accessPhases()
Definition:
RunData.h:167
filelisting.run
int run
Definition:
filelisting.py:13
RunData::accessApas
IndexVector & accessApas()
Definition:
RunData.h:157
StringManipulator
Definition:
StringManipulator.h:15
cet::filepath_maker
Definition:
filepath_maker.h:42
RunData::accessPhaseGroup
Name & accessPhaseGroup()
Definition:
RunData.h:166
RunData::accessCryostat
Name & accessCryostat()
Definition:
RunData.h:156
FclRunDataTool::NameVector
std::vector< Name > NameVector
Definition:
FclRunDataTool.h:32
RunData::IndexVector
std::vector< Index > IndexVector
Definition:
RunData.h:27
RunDataTool::Index
unsigned int Index
Definition:
RunDataTool.h:14
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
FclRunDataTool.h
RunData::accessPulserAmplitude
Index & accessPulserAmplitude()
Definition:
RunData.h:163
RunData::accessPulserSource
Index & accessPulserSource()
Definition:
RunData.h:164
RunData::accessHvfrac
float & accessHvfrac()
Definition:
RunData.h:162
fhicl::parse_document
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
Definition:
parse.cc:720
StringManipulator::replaceFixedWidth
int replaceFixedWidth(std::string substr, const T &xsub, Index width)
Definition:
StringManipulator.h:159
RunData::accessShaping
float & accessShaping()
Definition:
RunData.h:159
RunData::accessPulserPeriod
Index & accessPulserPeriod()
Definition:
RunData.h:165
FclRunDataTool::Name
std::string Name
Definition:
FclRunDataTool.h:31
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
StringManipulator.h
RunData::Index
unsigned int Index
Definition:
RunData.h:26
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
RunData::accessRun
Index & accessRun()
Definition:
RunData.h:155
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11