PhysicsTools
UtilAlgos
src
VariableHelper.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/Event.h
"
2
#include "
FWCore/Framework/interface/EventSetup.h
"
3
4
#include "
PhysicsTools/UtilAlgos/interface/VariableHelper.h
"
5
#include "
PhysicsTools/UtilAlgos/interface/CachingVariable.h
"
6
7
#include <iomanip>
8
9
VariableHelper::VariableHelper
(
const
edm::ParameterSet
& iConfig,
edm::ConsumesCollector
& iC) {
10
std::vector<std::string> psetNames;
11
iConfig.
getParameterSetNames
(psetNames);
12
for
(
unsigned
int
i
= 0;
i
!= psetNames.size(); ++
i
) {
13
std::string
& vname = psetNames[
i
];
14
edm::ParameterSet
vPset = iConfig.
getParameter
<
edm::ParameterSet
>(psetNames[
i
]);
15
std::string
method
= vPset.
getParameter
<
std::string
>(
"method"
);
16
17
CachingVariableFactory::get
()->create(
18
method
,
CachingVariable::CachingVariableFactoryArg
(vname,
variables_
, vPset), iC);
19
}
20
}
21
22
void
VariableHelper::setHolder
(
std::string
hn) {
23
iterator
it =
variables_
.begin();
24
iterator
it_end =
variables_
.end();
25
for
(; it != it_end; ++it)
26
it->second->setHolder(hn);
27
}
28
29
void
VariableHelper::print
()
const
{
30
iterator
it =
variables_
.begin();
31
iterator
it_end =
variables_
.end();
32
for
(; it != it_end; ++it)
33
it->second->print();
34
}
35
36
std::string
VariableHelper::printValues
(
const
edm::Event
&
event
)
const
{
37
std::stringstream
ss
;
38
iterator
it =
variables_
.begin();
39
iterator
it_end =
variables_
.end();
40
ss
<< std::setw(10) <<
event
.id().run() <<
" : "
<< std::setw(10) <<
event
.id().event();
41
for
(; it != it_end; ++it) {
42
if
(it->second->compute(
event
))
43
ss
<<
" : "
<< it->first <<
"="
<< (*it->second)(
event
);
44
else
45
ss
<<
" : "
<< it->first <<
" N/A"
;
46
}
47
return
ss
.str();
48
}
49
const
CachingVariable
*
VariableHelper::variable
(
std::string
name
)
const
{
50
iterator
v
=
variables_
.find(
name
);
51
if
(
v
!=
variables_
.end())
52
return
v
->second;
53
else
{
54
edm::LogError
(
"VariableHelper"
) <<
"I don't know anything named: "
<<
name
55
<<
" list of available variables follows."
;
56
print
();
57
return
nullptr
;
58
}
59
}
mps_fire.i
i
Definition:
mps_fire.py:428
VariableHelper::print
void print() const
Definition:
VariableHelper.cc:29
CachingVariable.h
VariableHelper::VariableHelper
VariableHelper(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
Definition:
VariableHelper.cc:9
AlcaSiPixelAliHarvester0T_cff.method
method
Definition:
AlcaSiPixelAliHarvester0T_cff.py:41
VariableHelper::printValues
std::string printValues(const edm::Event &event) const
Definition:
VariableHelper.cc:36
CachingVariable
Definition:
CachingVariable.h:40
findQualityFiles.v
v
Definition:
findQualityFiles.py:179
contentValuesCheck.ss
ss
Definition:
contentValuesCheck.py:33
VariableHelper::iterator
std::map< std::string, const CachingVariable * >::const_iterator iterator
Definition:
VariableHelper.h:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
VariableHelper::variable
const CachingVariable * variable(std::string name) const
Definition:
VariableHelper.cc:49
VariableHelper::setHolder
void setHolder(std::string hn)
Definition:
VariableHelper.cc:22
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
edmPickEvents.event
event
Definition:
edmPickEvents.py:273
VariableHelper::variables_
std::map< std::string, const CachingVariable * > variables_
Definition:
VariableHelper.h:31
get
#define get
Skims_PA_cff.name
name
Definition:
Skims_PA_cff.py:17
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
VariableHelper.h
CachingVariable::CachingVariableFactoryArg
Definition:
CachingVariable.h:46
event
Definition:
event.py:1
edm::Event
Definition:
Event.h:73
edm::Log
Definition:
MessageLogger.h:70
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
edm::ParameterSet::getParameterSetNames
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
Definition:
ParameterSet.cc:724
Generated for CMSSW Reference Manual by
1.8.16