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  auto history = processHistoryRegistry().getMapped(aux.processHistoryID());
89 
90  eventPrincipal.fillEventPrincipal(aux, history);
91  }
92 
95  desc.setComment("Generates the specified sequence of transitions.");
97 
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;
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:93
TestSource(ParameterSet const &, InputSourceDescription const &)
Definition: TestSource.cc:29
#define DEFINE_FWK_INPUT_SOURCE(type)
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:197
void readEvent_(EventPrincipal &eventPrincipal) final
Definition: TestSource.cc:84
std::vector< std::pair< ItemType, EventID > >::const_iterator m_nextTransition
Definition: TestSource.cc:24
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:139
static void fillDescription(ParameterSetDescription &desc)
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() final
Definition: TestSource.cc:77
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
HLT enums.
std::shared_ptr< RunAuxiliary > readRunAuxiliary_() final
Definition: TestSource.cc:71
ItemType getNextItemType() final
Definition: TestSource.cc:62