CMS 3D CMS Logo

TestLimitedOutput.cc
Go to the documentation of this file.
1 
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 namespace edm {
16 
17  class TestLimitedOutput : public limited::OutputModule<WatchInputFiles, RunCache<int>, LuminosityBlockCache<int>> {
18  public:
19  explicit TestLimitedOutput(ParameterSet const& pset);
20  ~TestLimitedOutput() override;
21  static void fillDescriptions(ConfigurationDescriptions& descriptions);
22 
23  private:
24  void write(EventForOutput const& e) override;
25  void writeLuminosityBlock(LuminosityBlockForOutput const&) override;
26  void writeRun(RunForOutput const&) override;
27  void writeProcessBlock(ProcessBlockForOutput const&) override;
28 
29  void respondToOpenInputFile(FileBlock const&) override;
30  void respondToCloseInputFile(FileBlock const&) override;
31 
32  std::shared_ptr<int> globalBeginRun(RunForOutput const&) const override;
33  void globalEndRun(RunForOutput const&) const override;
34 
35  std::shared_ptr<int> globalBeginLuminosityBlock(LuminosityBlockForOutput const&) const override;
36  void globalEndLuminosityBlock(LuminosityBlockForOutput const&) const override;
37 
38  void endJob() override;
39 
40  bool verbose_;
44  };
45 
49  verbose_(pset.getUntrackedParameter<bool>("verbose")),
50  expectedProcessesWithProcessBlockProducts_(
51  pset.getUntrackedParameter<std::vector<std::string>>("expectedProcessesWithProcessBlockProducts")),
52  expectedWriteProcessBlockTransitions_(pset.getUntrackedParameter<int>("expectedWriteProcessBlockTransitions")) {
53  }
54 
56 
58  if (verbose_) {
59  LogAbsolute("TestLimitedOutput") << "limited write event";
60  }
61  }
62 
64  if (verbose_) {
65  LogAbsolute("TestLimitedOutput") << "limited writeLuminosityBlock";
66  }
67  }
68 
69  void TestLimitedOutput::writeRun(RunForOutput const&) { LogAbsolute("TestLimitedOutput") << "limited writeRun"; }
70 
72  LogAbsolute("TestLimitedOutput") << "limited writeProcessBlock";
76  LogAbsolute("TestLimitedOutput") << " " << process;
77  }
79  outputProcessBlockHelper().processesWithProcessBlockProducts()) {
80  throw cms::Exception("TestFailure") << "TestLimitedOutput::writeProcessBlock unexpected process name list";
81  }
82  }
83  }
84 
86  if (verbose_) {
87  LogAbsolute("TestLimitedOutput") << "limited respondToOpenInputFile";
88  }
89  }
90 
92  if (verbose_) {
93  LogAbsolute("TestLimitedOutput") << "limited respondToCloseInputFile";
94  }
95  }
96 
97  std::shared_ptr<int> TestLimitedOutput::globalBeginRun(RunForOutput const&) const {
98  LogAbsolute("TestLimitedOutput") << "limited globalBeginRun";
99  if (verbose_) {
100  BranchIDLists const* theBranchIDLists = branchIDLists();
101  for (auto const& branchIDList : *theBranchIDLists) {
102  LogAbsolute("TestLimitedOutput") << "A branchID list";
103  for (auto const& branchID : branchIDList) {
104  LogAbsolute("TestLimitedOutput") << " limited branchID " << branchID;
105  }
106  }
108  for (auto const& it : reg->productList()) {
109  LogAbsolute("TestLimitedOutput") << it.second;
110  }
111  }
112  return std::make_shared<int>(0);
113  }
114 
116  LogAbsolute("TestLimitedOutput") << "limited globalEndRun";
117  }
118 
120  if (verbose_) {
121  LogAbsolute("TestLimitedOutput") << "limited globalBeginLuminosityBlock";
122  }
123  return std::make_shared<int>(0);
124  }
125 
127  if (verbose_) {
128  LogAbsolute("TestLimitedOutput") << "limited globalEndLuminosityBlock";
129  }
130  }
131 
135  throw cms::Exception("TestFailure")
136  << "TestLimitedOutput::writeProcessBlock unexpected number of writeProcessBlock transitions";
137  }
138  }
139  }
140 
143  OutputModule::fillDescription(desc);
144  desc.addUntracked<bool>("verbose", true);
145  desc.addUntracked<std::vector<std::string>>("expectedProcessesWithProcessBlockProducts",
146  std::vector<std::string>());
147  desc.addUntracked<int>("expectedWriteProcessBlockTransitions", -1);
148  descriptions.addDefault(desc);
149  }
150 } // namespace edm
151 
void write(EventForOutput const &e) override
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
OutputProcessBlockHelper const & outputProcessBlockHelper() const
std::vector< std::string > const & processesWithProcessBlockProducts() const
std::shared_ptr< int > globalBeginRun(RunForOutput const &) const override
ProductList const & productList() const
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< std::string > expectedProcessesWithProcessBlockProducts_
BranchIDLists const * branchIDLists() const
TestLimitedOutput(ParameterSet const &pset)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void writeRun(RunForOutput const &) override
void writeLuminosityBlock(LuminosityBlockForOutput const &) override
void writeProcessBlock(ProcessBlockForOutput const &) override
void globalEndRun(RunForOutput const &) const override
void globalEndLuminosityBlock(LuminosityBlockForOutput const &) const override
void respondToCloseInputFile(FileBlock const &) override
std::shared_ptr< int > globalBeginLuminosityBlock(LuminosityBlockForOutput const &) const override
HLT enums.
Log< level::System, true > LogAbsolute
void respondToOpenInputFile(FileBlock const &) override
static void fillDescriptions(ConfigurationDescriptions &descriptions)