CMS 3D CMS Logo

TestGlobalOutput.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 TestGlobalOutput : public global::OutputModule<WatchInputFiles, RunCache<int>, LuminosityBlockCache<int>> {
18  public:
19  explicit TestGlobalOutput(ParameterSet const& pset);
20  ~TestGlobalOutput() 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  void endJob() override;
38 
39  bool verbose_;
43  };
44 
46  : global::OutputModuleBase(pset),
47  global::OutputModule<WatchInputFiles, RunCache<int>, LuminosityBlockCache<int>>(pset),
48  verbose_(pset.getUntrackedParameter<bool>("verbose")),
49  expectedProcessesWithProcessBlockProducts_(
50  pset.getUntrackedParameter<std::vector<std::string>>("expectedProcessesWithProcessBlockProducts")),
51  expectedWriteProcessBlockTransitions_(pset.getUntrackedParameter<int>("expectedWriteProcessBlockTransitions")) {
52  }
53 
55 
57  if (verbose_) {
58  LogAbsolute("TestGlobalOutput") << "global write event";
59  }
60  }
61 
63  if (verbose_) {
64  LogAbsolute("TestGlobalOutput") << "global writeLuminosityBlock";
65  }
66  }
67 
68  void TestGlobalOutput::writeRun(RunForOutput const&) { LogAbsolute("TestGlobalOutput") << "global writeRun"; }
69 
71  LogAbsolute("TestGlobalOutput") << "global writeProcessBlock";
75  LogAbsolute("TestGlobalOutput") << " " << process;
76  }
78  outputProcessBlockHelper().processesWithProcessBlockProducts()) {
79  throw cms::Exception("TestFailure") << "TestGlobalOutput::writeProcessBlock unexpected process name list";
80  }
81  }
82  }
83 
85  if (verbose_) {
86  LogAbsolute("TestGlobalOutput") << "global respondToOpenInputFile";
87  }
88  }
89 
91  if (verbose_) {
92  LogAbsolute("TestGlobalOutput") << "global respondToCloseInputFile";
93  }
94  }
95 
96  std::shared_ptr<int> TestGlobalOutput::globalBeginRun(RunForOutput const&) const {
97  LogAbsolute("TestGlobalOutput") << "global globalBeginRun";
98  if (verbose_) {
99  BranchIDLists const* theBranchIDLists = branchIDLists();
100  for (auto const& branchIDList : *theBranchIDLists) {
101  LogAbsolute("TestGlobalOutput") << "A branchID list";
102  for (auto const& branchID : branchIDList) {
103  LogAbsolute("TestGlobalOutput") << " global branchID " << branchID;
104  }
105  }
107  for (auto const& it : reg->productList()) {
108  LogAbsolute("TestGlobalOutput") << it.second;
109  }
110  }
111  return std::make_shared<int>(0);
112  }
113 
115  LogAbsolute("TestGlobalOutput") << "global globalEndRun";
116  }
117 
119  if (verbose_) {
120  LogAbsolute("TestGlobalOutput") << "global globalBeginLuminosityBlock";
121  }
122  return std::make_shared<int>(0);
123  }
124 
126  if (verbose_) {
127  LogAbsolute("TestGlobalOutput") << "global globalEndLuminosityBlock";
128  }
129  }
130 
134  throw cms::Exception("TestFailure")
135  << "TestGlobalOutput::writeProcessBlock unexpected number of writeProcessBlock transitions";
136  }
137  }
138  }
139 
142  OutputModule::fillDescription(desc);
143  desc.addUntracked<bool>("verbose", true);
144  desc.addUntracked<std::vector<std::string>>("expectedProcessesWithProcessBlockProducts",
145  std::vector<std::string>());
146  desc.addUntracked<int>("expectedWriteProcessBlockTransitions", -1);
147  descriptions.addDefault(desc);
148  }
149 } // namespace edm
150 
void globalEndLuminosityBlock(LuminosityBlockForOutput const &) const override
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
void writeProcessBlock(ProcessBlockForOutput const &) override
OutputProcessBlockHelper const & outputProcessBlockHelper() const
void writeRun(RunForOutput const &) override
std::vector< std::string > const & processesWithProcessBlockProducts() const
ProductList const & productList() const
std::vector< std::string > expectedProcessesWithProcessBlockProducts_
std::shared_ptr< int > globalBeginLuminosityBlock(LuminosityBlockForOutput const &) const override
TestGlobalOutput(ParameterSet const &pset)
void addDefault(ParameterSetDescription const &psetDescription)
BranchIDLists const * branchIDLists() const
void globalEndRun(RunForOutput const &) const override
void write(EventForOutput const &e) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void respondToCloseInputFile(FileBlock const &) override
void writeLuminosityBlock(LuminosityBlockForOutput const &) override
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void respondToOpenInputFile(FileBlock const &) override
HLT enums.
Log< level::System, true > LogAbsolute
std::shared_ptr< int > globalBeginRun(RunForOutput const &) const override