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  private:
17  ItemType getNextItemType() final;
18  std::shared_ptr<RunAuxiliary> readRunAuxiliary_() final;
19  std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() final;
20  void readEvent_(EventPrincipal& eventPrincipal) final;
21 
22  std::vector<std::pair<ItemType,EventID>> m_transitions;
23  std::vector<std::pair<ItemType,EventID>>::const_iterator m_nextTransition;
24 
25  static ItemType stringToType( const std::string& ) ;
26  };
27 
29  InputSourceDescription const& desc) :
30  InputSource(pset, desc)
31  {
32  for( auto const& p: pset.getUntrackedParameter<std::vector<edm::ParameterSet>>("transitions")) {
33  m_transitions.emplace_back( stringToType(p.getUntrackedParameter<std::string>("type")),
34  p.getUntrackedParameter<EventID>("id"));
35  }
37  }
38 
40  if (iTrans == "IsStop") { return IsStop;}
41  if (iTrans == "IsFile") { return IsFile;}
42  if (iTrans == "IsRun") { return IsRun;}
43  if (iTrans == "IsLumi") {return IsLumi;}
44  if (iTrans == "IsEvent") {return IsEvent;}
45  if (iTrans == "IsSynchronize") {return IsSynchronize;}
46 
47  throw edm::Exception(errors::Configuration)<<"Unknown transition type \'"<<iTrans<<"\'";
48 
49  return IsInvalid;
50  }
51 
53  if(m_nextTransition == m_transitions.end()) {
54  return IsStop;
55  }
56  auto trans = m_nextTransition->first;
58  return trans;
59  }
60 
61  std::shared_ptr<RunAuxiliary> TestSource::readRunAuxiliary_() {
62  auto it =m_nextTransition;
63  --it;
64  return std::make_shared<RunAuxiliary>(it->second.run(),Timestamp(0),Timestamp(10));
65  }
66 
67  std::shared_ptr<LuminosityBlockAuxiliary> TestSource::readLuminosityBlockAuxiliary_() {
68  auto it =m_nextTransition;
69  --it;
70  return std::make_shared<LuminosityBlockAuxiliary>(it->second.run(),it->second.luminosityBlock(), Timestamp(0),Timestamp(10));
71  }
72 
73  void TestSource::readEvent_(EventPrincipal& eventPrincipal) {
74  auto it =m_nextTransition;
75  --it;
76  EventAuxiliary aux(it->second, processGUID(), Timestamp(0), false);
77  eventPrincipal.fillEventPrincipal(aux, processHistoryRegistry());
78  }
79 
80  void
83  desc.setComment("Generates the specified sequence of transitions.");
85 
87  trans.addUntracked<std::string>("type");
88  trans.addUntracked<edm::EventID>("id");
89  desc.addVPSetUntracked("transitions",trans, {{}});
90  descriptions.add("source", desc);
91  }
92 }
93 
94 using edm::TestSource;
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:168
T getUntrackedParameter(std::string const &, T const &) const
static ItemType stringToType(const std::string &)
Definition: TestSource.cc:39
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: TestSource.cc:81
TestSource(ParameterSet const &, InputSourceDescription const &)
Definition: TestSource.cc:28
std::vector< std::pair< ItemType, EventID > > m_transitions
Definition: TestSource.cc:22
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:211
void setComment(std::string const &value)
#define DEFINE_FWK_INPUT_SOURCE(type)
void readEvent_(EventPrincipal &eventPrincipal) final
Definition: TestSource.cc:73
static void fillDescription(ParameterSetDescription &desc)
std::vector< std::pair< ItemType, EventID > >::const_iterator m_nextTransition
Definition: TestSource.cc:23
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() final
Definition: TestSource.cc:67
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:61
ItemType getNextItemType() final
Definition: TestSource.cc:52