FWCore
Modules
src
TestSource.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
2
#include "
FWCore/Framework/interface/InputSourceMacros.h
"
3
#include "
FWCore/Framework/interface/EventPrincipal.h
"
4
#include "
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
"
5
#include "
FWCore/ParameterSet/interface/ParameterSetDescription.h
"
6
#include "
FWCore/Sources/interface/ProducerSourceBase.h
"
7
8
#include <vector>
9
#include <utility>
10
11
namespace
edm
{
12
class
TestSource
:
public
InputSource
{
13
public
:
14
explicit
TestSource
(
ParameterSet
const
&,
InputSourceDescription
const
&);
15
static
void
fillDescriptions
(
ConfigurationDescriptions
& descriptions);
16
17
private
:
18
ItemType
getNextItemType
()
final
;
19
std::shared_ptr<RunAuxiliary>
readRunAuxiliary_
()
final
;
20
std::shared_ptr<LuminosityBlockAuxiliary>
readLuminosityBlockAuxiliary_
()
final
;
21
void
readEvent_
(
EventPrincipal
& eventPrincipal)
final
;
22
23
std::vector<std::pair<ItemType, EventID>>
m_transitions
;
24
std::vector<std::pair<ItemType, EventID>>::const_iterator
m_nextTransition
;
25
26
static
ItemType
stringToType
(
const
std::string
&);
27
};
28
29
TestSource::TestSource
(
ParameterSet
const
&
pset
,
InputSourceDescription
const
&
desc
) :
InputSource
(
pset
,
desc
) {
30
for
(
auto
const
&
p
:
pset
.getUntrackedParameter<std::vector<edm::ParameterSet>>(
"transitions"
)) {
31
m_transitions
.emplace_back(
stringToType
(
p
.getUntrackedParameter<
std::string
>(
"type"
)),
32
p
.getUntrackedParameter<
EventID
>(
"id"
));
33
}
34
m_nextTransition
=
m_transitions
.begin();
35
}
36
37
TestSource::ItemType
TestSource::stringToType
(
const
std::string
& iTrans) {
38
if
(iTrans ==
"IsStop"
) {
39
return
IsStop
;
40
}
41
if
(iTrans ==
"IsFile"
) {
42
return
IsFile
;
43
}
44
if
(iTrans ==
"IsRun"
) {
45
return
IsRun
;
46
}
47
if
(iTrans ==
"IsLumi"
) {
48
return
IsLumi
;
49
}
50
if
(iTrans ==
"IsEvent"
) {
51
return
IsEvent
;
52
}
53
if
(iTrans ==
"IsSynchronize"
) {
54
return
IsSynchronize
;
55
}
56
57
throw
edm::Exception
(
errors::Configuration
) <<
"Unknown transition type \'"
<< iTrans <<
"\'"
;
58
59
return
IsInvalid
;
60
}
61
62
TestSource::ItemType
TestSource::getNextItemType
() {
63
if
(
m_nextTransition
==
m_transitions
.end()) {
64
return
IsStop
;
65
}
66
auto
trans =
m_nextTransition
->first;
67
++
m_nextTransition
;
68
return
trans;
69
}
70
71
std::shared_ptr<RunAuxiliary>
TestSource::readRunAuxiliary_
() {
72
auto
it =
m_nextTransition
;
73
--it;
74
return
std::make_shared<RunAuxiliary>(it->second.run(),
Timestamp
(0),
Timestamp
(10));
75
}
76
77
std::shared_ptr<LuminosityBlockAuxiliary>
TestSource::readLuminosityBlockAuxiliary_
() {
78
auto
it =
m_nextTransition
;
79
--it;
80
return
std::make_shared<LuminosityBlockAuxiliary>(
81
it->second.run(), it->second.luminosityBlock(),
Timestamp
(0),
Timestamp
(10));
82
}
83
84
void
TestSource::readEvent_
(
EventPrincipal
& eventPrincipal) {
85
auto
it =
m_nextTransition
;
86
--it;
87
EventAuxiliary
aux
(it->second,
processGUID
(),
Timestamp
(0),
false
);
88
auto
history =
processHistoryRegistry
().
getMapped
(
aux
.processHistoryID());
89
90
eventPrincipal.
fillEventPrincipal
(
aux
, history);
91
}
92
93
void
TestSource::fillDescriptions
(
ConfigurationDescriptions
& descriptions) {
94
ParameterSetDescription
desc
;
95
desc
.setComment(
"Generates the specified sequence of transitions."
);
96
ProducerSourceBase::fillDescription
(
desc
);
97
98
ParameterSetDescription
trans;
99
trans.
addUntracked
<
std::string
>(
"type"
);
100
trans.
addUntracked
<
edm::EventID
>(
"id"
);
101
desc
.addVPSetUntracked(
"transitions"
, trans, {{}});
102
descriptions.
add
(
"source"
,
desc
);
103
}
104
}
// namespace edm
105
106
using
edm::TestSource
;
107
DEFINE_FWK_INPUT_SOURCE
(
TestSource
);
edm::TestSource::readRunAuxiliary_
std::shared_ptr< RunAuxiliary > readRunAuxiliary_() final
Definition:
TestSource.cc:71
ConfigurationDescriptions.h
edm
HLT enums.
Definition:
AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
edm::TestSource::TestSource
TestSource(ParameterSet const &, InputSourceDescription const &)
Definition:
TestSource.cc:29
edm::TestSource::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition:
TestSource.cc:93
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
edm::InputSourceDescription
Definition:
InputSourceDescription.h:20
edm::TestSource::stringToType
static ItemType stringToType(const std::string &)
Definition:
TestSource.cc:37
edm::TestSource::m_transitions
std::vector< std::pair< ItemType, EventID > > m_transitions
Definition:
TestSource.cc:23
edm::TestSource
Definition:
TestSource.cc:12
edm::InputSource::IsRun
Definition:
InputSource.h:78
edm::EventPrincipal
Definition:
EventPrincipal.h:46
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:57
EventPrincipal.h
DEFINE_FWK_INPUT_SOURCE
#define DEFINE_FWK_INPUT_SOURCE(type)
Definition:
InputSourceMacros.h:8
edm::InputSource::IsSynchronize
Definition:
InputSource.h:78
ParameterSetDescription.h
edm::EventAuxiliary
Definition:
EventAuxiliary.h:14
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
edm::InputSource::IsFile
Definition:
InputSource.h:78
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition:
ParameterSetDescription.h:100
edm::InputSource::processHistoryRegistry
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition:
InputSource.h:158
edm::ParameterSet
Definition:
ParameterSet.h:47
edm::InputSource::IsLumi
Definition:
InputSource.h:78
printConversionInfo.aux
aux
Definition:
printConversionInfo.py:19
edm::TestSource::readEvent_
void readEvent_(EventPrincipal &eventPrincipal) final
Definition:
TestSource.cc:84
edm::InputSource::IsStop
Definition:
InputSource.h:78
edm::TestSource::m_nextTransition
std::vector< std::pair< ItemType, EventID > >::const_iterator m_nextTransition
Definition:
TestSource.cc:24
InputSourceMacros.h
edm::EventPrincipal::fillEventPrincipal
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
Definition:
EventPrincipal.cc:105
edm::InputSource::ItemType
ItemType
Definition:
InputSource.h:78
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
edm::TestSource::readLuminosityBlockAuxiliary_
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() final
Definition:
TestSource.cc:77
Frameworkfwd.h
Exception
Definition:
hltDiff.cc:245
edm::ProcessHistoryRegistry::getMapped
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
Definition:
ProcessHistoryRegistry.cc:29
edm::InputSource::IsEvent
Definition:
InputSource.h:78
edm::InputSource
Definition:
InputSource.h:76
edm::InputSource::processGUID
std::string const & processGUID() const
Accessor for global process identifier.
Definition:
InputSource.h:207
edm::TestSource::getNextItemType
ItemType getNextItemType() final
Definition:
TestSource.cc:62
edm::EventID
Definition:
EventID.h:31
edm::InputSource::IsInvalid
Definition:
InputSource.h:78
edm::errors::Configuration
Definition:
EDMException.h:36
edm::IDGeneratorSourceBase< PuttableSourceBase >::fillDescription
static void fillDescription(ParameterSetDescription &desc)
Definition:
IDGeneratorSourceBase.cc:263
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
ProducerSourceBase.h
edm::Timestamp
Definition:
Timestamp.h:30
Generated for CMSSW Reference Manual by
1.8.16