|
1 | | - |
2 | | -#include "FWCore/Framework/test/stubs/RunLumiEventAnalyzer.h" |
3 | | - |
4 | 1 | #include "DataFormats/Common/interface/Handle.h" |
5 | 2 | #include "DataFormats/Common/interface/TriggerResults.h" |
6 | 3 | #include "FWCore/Framework/interface/Event.h" |
7 | 4 | #include "FWCore/Framework/interface/LuminosityBlock.h" |
8 | 5 | #include "FWCore/Framework/interface/MakerMacros.h" |
9 | 6 | #include "FWCore/Framework/interface/Run.h" |
| 7 | +#include "FWCore/Framework/interface/one/EDAnalyzer.h" |
10 | 8 | #include "FWCore/MessageLogger/interface/MessageLogger.h" |
11 | 9 | #include "FWCore/ParameterSet/interface/ParameterSet.h" |
| 10 | +#include "FWCore/Utilities/interface/EDGetToken.h" |
12 | 11 | #include "FWCore/Utilities/interface/Exception.h" |
| 12 | +#include "FWCore/Utilities/interface/propagate_const.h" |
13 | 13 |
|
14 | 14 | #include <cassert> |
15 | | -#include <iostream> |
| 15 | +#include <vector> |
16 | 16 |
|
17 | 17 | namespace edmtest { |
| 18 | + class RunLumiEventAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> { |
| 19 | + public: |
| 20 | + explicit RunLumiEventAnalyzer(edm::ParameterSet const& pset); |
| 21 | + |
| 22 | + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); |
| 23 | + |
| 24 | + void analyze(edm::Event const& event, edm::EventSetup const& es) final; |
| 25 | + void beginRun(edm::Run const& run, edm::EventSetup const& es) final; |
| 26 | + void endRun(edm::Run const& run, edm::EventSetup const& es) final; |
| 27 | + void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) final; |
| 28 | + void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) final; |
| 29 | + void endJob(); |
| 30 | + |
| 31 | + private: |
| 32 | + std::vector<unsigned long long> expectedRunLumisEvents0_; |
| 33 | + std::vector<unsigned long long> expectedRunLumisEvents1_; |
| 34 | + edm::propagate_const<std::vector<unsigned long long>*> const expectedRunLumisEvents_; |
| 35 | + bool const verbose_; |
| 36 | + bool const dumpTriggerResults_; |
| 37 | + int const expectedEndingIndex0_; |
| 38 | + int const expectedEndingIndex1_; |
| 39 | + int const expectedEndingIndex_; |
| 40 | + edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_; |
| 41 | + int index_ = 0; |
| 42 | + }; |
18 | 43 |
|
19 | 44 | RunLumiEventAnalyzer::RunLumiEventAnalyzer(edm::ParameterSet const& pset) |
20 | 45 | : expectedRunLumisEvents0_(), |
21 | 46 | expectedRunLumisEvents1_(), |
22 | 47 | expectedRunLumisEvents_(&expectedRunLumisEvents0_), |
23 | | - index_(0), |
24 | | - verbose_(pset.getUntrackedParameter<bool>("verbose", false)), |
25 | | - dumpTriggerResults_(pset.getUntrackedParameter<bool>("dumpTriggerResults", false)), |
26 | | - expectedEndingIndex0_(pset.getUntrackedParameter<int>("expectedEndingIndex", -1)), |
27 | | - expectedEndingIndex1_(pset.getUntrackedParameter<int>("expectedEndingIndex1", -1)), |
| 48 | + verbose_(pset.getUntrackedParameter<bool>("verbose")), |
| 49 | + dumpTriggerResults_(pset.getUntrackedParameter<bool>("dumpTriggerResults")), |
| 50 | + expectedEndingIndex0_(pset.getUntrackedParameter<int>("expectedEndingIndex")), |
| 51 | + expectedEndingIndex1_(pset.getUntrackedParameter<int>("expectedEndingIndex1")), |
28 | 52 | expectedEndingIndex_(expectedEndingIndex0_) { |
29 | | - if (pset.existsAs<std::vector<unsigned int> >("expectedRunLumiEvents", false)) { |
30 | | - std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int> >("expectedRunLumiEvents"); |
| 53 | + if (pset.existsAs<std::vector<unsigned int>>("expectedRunLumiEvents", false)) { |
| 54 | + std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int>>("expectedRunLumiEvents"); |
31 | 55 | expectedRunLumisEvents0_.assign(temp.begin(), temp.end()); |
32 | 56 | } else { |
33 | | - expectedRunLumisEvents0_ = pset.getUntrackedParameter<std::vector<unsigned long long> >( |
34 | | - "expectedRunLumiEvents", std::vector<unsigned long long>()); |
| 57 | + expectedRunLumisEvents0_ = pset.getUntrackedParameter<std::vector<unsigned long long>>("expectedRunLumiEvents"); |
35 | 58 | } |
36 | 59 |
|
37 | | - if (pset.existsAs<std::vector<unsigned int> >("expectedRunLumiEvents1", false)) { |
38 | | - std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int> >("expectedRunLumiEvents1"); |
| 60 | + if (pset.existsAs<std::vector<unsigned int>>("expectedRunLumiEvents1", false)) { |
| 61 | + std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int>>("expectedRunLumiEvents1"); |
39 | 62 | expectedRunLumisEvents1_.assign(temp.begin(), temp.end()); |
40 | 63 | } else { |
41 | | - expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long> >( |
42 | | - "expectedRunLumiEvents1", std::vector<unsigned long long>()); |
| 64 | + expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long>>("expectedRunLumiEvents1"); |
43 | 65 | } |
44 | 66 | if (dumpTriggerResults_) { |
45 | 67 | triggerResultsToken_ = consumes(edm::InputTag("TriggerResults")); |
46 | 68 | } |
47 | 69 | } |
48 | 70 |
|
| 71 | + void RunLumiEventAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 72 | + edm::ParameterSetDescription desc; |
| 73 | + desc.addUntracked<bool>("verbose", false); |
| 74 | + desc.addUntracked<bool>("dumpTriggerResults", false); |
| 75 | + desc.addUntracked<int>("expectedEndingIndex", -1); |
| 76 | + desc.addUntracked<int>("expectedEndingIndex1", -1); |
| 77 | + desc.addNode(edm::ParameterDescription<std::vector<unsigned long long>>("expectedRunLumiEvents", {}, false) xor |
| 78 | + edm::ParameterDescription<std::vector<unsigned int>>("expectedRunLumiEvents", {}, false)); |
| 79 | + desc.addNode(edm::ParameterDescription<std::vector<unsigned long long>>("expectedRunLumiEvents1", {}, false) xor |
| 80 | + edm::ParameterDescription<std::vector<unsigned int>>("expectedRunLumiEvents1", {}, false)); |
| 81 | + |
| 82 | + descriptions.addDefault(desc); |
| 83 | + } |
| 84 | + |
49 | 85 | void RunLumiEventAnalyzer::analyze(edm::Event const& event, edm::EventSetup const&) { |
50 | 86 | if (verbose_) { |
51 | 87 | edm::LogAbsolute("RunLumiEvent") << "RUN_LUMI_EVENT " << event.run() << ", " << event.luminosityBlock() << ", " |
|
0 commit comments