CMS 3D CMS Logo

TestSource.cc
Go to the documentation of this file.
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 
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  }
35  }
36 
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 
63  if (m_nextTransition == m_transitions.end()) {
64  return IsStop;
65  }
66  auto trans = m_nextTransition->first;
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  eventPrincipal.fillEventPrincipal(aux, processHistoryRegistry());
89  }
90 
93  desc.setComment("Generates the specified sequence of transitions.");
95 
97  trans.addUntracked<std::string>("type");
98  trans.addUntracked<edm::EventID>("id");
99  desc.addVPSetUntracked("transitions", trans, {{}});
100  descriptions.add("source", desc);
101  }
102 } // namespace edm
103 
104 using edm::TestSource;
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:155
T getUntrackedParameter(std::string const &, T const &) const
static ItemType stringToType(const std::string &)
Definition: TestSource.cc:37
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< std::pair< ItemType, EventID > > m_transitions
Definition: TestSource.cc:23
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: TestSource.cc:91
TestSource(ParameterSet const &, InputSourceDescription const &)
Definition: TestSource.cc:29
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:204
#define DEFINE_FWK_INPUT_SOURCE(type)
void setComment(std::string const &value)
void readEvent_(EventPrincipal &eventPrincipal) final
Definition: TestSource.cc:84
std::vector< std::pair< ItemType, EventID > >::const_iterator m_nextTransition
Definition: TestSource.cc:24
static void fillDescription(ParameterSetDescription &desc)
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() final
Definition: TestSource.cc:77
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
HLT enums.
ParameterDescriptionBase * addVPSetUntracked(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::shared_ptr< RunAuxiliary > readRunAuxiliary_() final
Definition: TestSource.cc:71
ItemType getNextItemType() final
Definition: TestSource.cc:62