CMS 3D CMS Logo

ConcurrentIOVAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Integration
4 // Class: ConcurrentIOVAnalyzer
5 //
11 // Original Author: Chris Jones
12 // Created: Fri Jun 24 19:13:25 EDT 2005
13 
27 
29 
30 #include <vector>
31 
32 namespace edmtest {
33 
35  public:
37 
38  void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
39 
41 
42  private:
48  };
49 
51  : checkExpectedValues_{pset.getUntrackedParameter<bool>("checkExpectedValues")},
52  esTokenFromESSource_{esConsumes(pset.getUntrackedParameter<edm::ESInputTag>("fromSource"))},
53  esTokenFromESProducer_{esConsumes(edm::ESInputTag("", "fromESProducer"))},
54  expectedESAcquireTestResults_{pset.getUntrackedParameter<std::vector<int>>("expectedESAcquireTestResults")} {
55  if (!expectedESAcquireTestResults_.empty()) {
56  esTokenFromAcquireIntESProducer_ = esConsumes(edm::ESInputTag("", "fromAcquireIntESProducer"));
57  }
58  }
59 
61  auto lumiNumber = event.eventAuxiliary().luminosityBlock();
62 
63  edm::ESHandle<IOVTestInfo> iovTestInfoFromESSource = eventSetup.getHandle(esTokenFromESSource_);
64  edm::ESHandle<IOVTestInfo> iovTestInfoFromESProducer = eventSetup.getHandle(esTokenFromESProducer_);
65 
66  ESTestRecordI esTestRecordI = eventSetup.get<ESTestRecordI>();
67  edm::ValidityInterval iov = esTestRecordI.validityInterval();
68 
69  if (iovTestInfoFromESSource->iovStartLumi_ != iov.first().luminosityBlockNumber() ||
70  iovTestInfoFromESSource->iovEndLumi_ != iov.last().luminosityBlockNumber() ||
71  iovTestInfoFromESSource->iovIndex_ != esTestRecordI.iovIndex() ||
72  iovTestInfoFromESSource->cacheIdentifier_ != esTestRecordI.cacheIdentifier()) {
73  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
74  << " values read from ESSource do not agree with record";
75  }
76 
77  if (iovTestInfoFromESProducer->iovStartLumi_ != iov.first().luminosityBlockNumber() ||
78  iovTestInfoFromESProducer->iovEndLumi_ != iov.last().luminosityBlockNumber() ||
79  iovTestInfoFromESProducer->iovIndex_ != esTestRecordI.iovIndex() ||
80  iovTestInfoFromESProducer->cacheIdentifier_ != esTestRecordI.cacheIdentifier()) {
81  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
82  << " values read from ESProducer do not agree with record";
83  }
84 
85  // First cacheIdentifier in the test is actually 3 (0, 1, and 2 just are ignored)
86  unsigned int cacheIdentifier = esTestRecordI.cacheIdentifier();
87  if (cacheIdentifier < expectedESAcquireTestResults_.size()) {
88  int testResult = eventSetup.getData(esTokenFromAcquireIntESProducer_).value();
89  if (testResult != expectedESAcquireTestResults_[cacheIdentifier]) {
90  throw cms::Exception("TestFailure")
91  << "ConcurrentIOVAnalyzer::analyze,"
92  << " unexpected value for EventSetup acquire test.\n"
93  << "Expected = " << expectedESAcquireTestResults_[cacheIdentifier] << " result = " << testResult
94  << " cacheIdentifier = " << cacheIdentifier << "\n";
95  }
96  }
97 
98  if (!checkExpectedValues_) {
99  return;
100  }
101 
102  // cacheIdentifier starts at 2 for beginRun and 3 is next here for the first lumi
103  if (lumiNumber == 1) {
104  if (iovTestInfoFromESProducer->iovStartLumi_ != 1 || iovTestInfoFromESProducer->iovEndLumi_ != 3 ||
105  iovTestInfoFromESProducer->cacheIdentifier_ != 3) {
106  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
107  << " values read from ESProducer do not agree with expected values";
108  }
109  }
110  if (lumiNumber == 2) {
111  if (iovTestInfoFromESProducer->iovStartLumi_ != 1 || iovTestInfoFromESProducer->iovEndLumi_ != 3 ||
112  iovTestInfoFromESProducer->cacheIdentifier_ != 3) {
113  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
114  << " values read from ESProducer do not agree with expected values";
115  }
116  }
117  if (lumiNumber == 3) {
118  if (iovTestInfoFromESProducer->iovStartLumi_ != 1 || iovTestInfoFromESProducer->iovEndLumi_ != 3 ||
119  iovTestInfoFromESProducer->cacheIdentifier_ != 3) {
120  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
121  << " values read from ESProducer do not agree with expected values";
122  }
123  }
124  if (lumiNumber == 4) {
125  if (iovTestInfoFromESProducer->iovStartLumi_ != 4 || iovTestInfoFromESProducer->iovEndLumi_ != 5 ||
126  iovTestInfoFromESProducer->cacheIdentifier_ != 4) {
127  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
128  << " values read from ESProducer do not agree with expected values";
129  }
130  }
131  if (lumiNumber == 5) {
132  if (iovTestInfoFromESProducer->iovStartLumi_ != 4 || iovTestInfoFromESProducer->iovEndLumi_ != 5 ||
133  iovTestInfoFromESProducer->cacheIdentifier_ != 4) {
134  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
135  << " values read from ESProducer do not agree with expected values";
136  }
137  }
138  if (lumiNumber == 6) {
139  if (iovTestInfoFromESProducer->iovStartLumi_ != 6 || iovTestInfoFromESProducer->iovEndLumi_ != 6 ||
140  iovTestInfoFromESProducer->cacheIdentifier_ != 5) {
141  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
142  << " values read from ESProducer do not agree with expected values";
143  }
144  }
145  if (lumiNumber == 7) {
146  if (iovTestInfoFromESProducer->iovStartLumi_ != 7 || iovTestInfoFromESProducer->iovEndLumi_ != 7 ||
147  iovTestInfoFromESProducer->cacheIdentifier_ != 6) {
148  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
149  << " values read from ESProducer do not agree with expected values";
150  }
151  }
152  if (lumiNumber == 8) {
153  if (iovTestInfoFromESProducer->iovStartLumi_ != 8 || iovTestInfoFromESProducer->iovEndLumi_ != 8 ||
154  iovTestInfoFromESProducer->cacheIdentifier_ != 7) {
155  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
156  << " values read from ESProducer do not agree with expected values";
157  }
158  }
159  }
160 
163  desc.addUntracked<bool>("checkExpectedValues", true);
164  desc.addUntracked<edm::ESInputTag>("fromSource", edm::ESInputTag("", ""));
165  desc.addUntracked<std::vector<int>>("expectedESAcquireTestResults", std::vector<int>());
166  descriptions.addDefault(desc);
167  }
168 } // namespace edmtest
169 using namespace edmtest;
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned int iovEndLumi_
Definition: IOVTestInfo.h:24
ConcurrentIOVAnalyzer(edm::ParameterSet const &)
unsigned int iovIndex_
Definition: IOVTestInfo.h:25
static void fillDescriptions(edm::ConfigurationDescriptions &)
edm::ESGetToken< IOVTestInfo, ESTestRecordI > const esTokenFromESProducer_
unsigned long long cacheIdentifier() const
void addDefault(ParameterSetDescription const &psetDescription)
edm::ESGetToken< IOVTestInfo, ESTestRecordI > const esTokenFromESSource_
unsigned int iovStartLumi_
Definition: IOVTestInfo.h:22
std::vector< int > expectedESAcquireTestResults_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
unsigned long long cacheIdentifier_
Definition: IOVTestInfo.h:26
ValidityInterval validityInterval() const
Definition: event.py:1
edm::ESGetToken< ESTestDataI, ESTestRecordI > esTokenFromAcquireIntESProducer_