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 
20 #include "IOVTestInfo.h"
26 
28 
29 namespace edmtest {
30 
32  public:
34 
35  void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
36 
38 
39  private:
43  };
44 
46  : checkExpectedValues_{pset.getUntrackedParameter<bool>("checkExpectedValues")},
47  esTokenFromESSource_{esConsumes(pset.getUntrackedParameter<edm::ESInputTag>("fromSource"))},
48  esTokenFromESProducer_{esConsumes(edm::ESInputTag("", "fromESProducer"))} {}
49 
51  auto lumiNumber = event.eventAuxiliary().luminosityBlock();
52 
53  edm::ESHandle<IOVTestInfo> iovTestInfoFromESSource = eventSetup.getHandle(esTokenFromESSource_);
54  edm::ESHandle<IOVTestInfo> iovTestInfoFromESProducer = eventSetup.getHandle(esTokenFromESProducer_);
55 
56  ESTestRecordI esTestRecordI = eventSetup.get<ESTestRecordI>();
57  edm::ValidityInterval iov = esTestRecordI.validityInterval();
58 
59  if (iovTestInfoFromESSource->iovStartLumi_ != iov.first().luminosityBlockNumber() ||
60  iovTestInfoFromESSource->iovEndLumi_ != iov.last().luminosityBlockNumber() ||
61  iovTestInfoFromESSource->iovIndex_ != esTestRecordI.iovIndex() ||
62  iovTestInfoFromESSource->cacheIdentifier_ != esTestRecordI.cacheIdentifier()) {
63  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
64  << " values read from ESSource do not agree with record";
65  }
66 
67  if (iovTestInfoFromESProducer->iovStartLumi_ != iov.first().luminosityBlockNumber() ||
68  iovTestInfoFromESProducer->iovEndLumi_ != iov.last().luminosityBlockNumber() ||
69  iovTestInfoFromESProducer->iovIndex_ != esTestRecordI.iovIndex() ||
70  iovTestInfoFromESProducer->cacheIdentifier_ != esTestRecordI.cacheIdentifier()) {
71  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
72  << " values read from ESProducer do not agree with record";
73  }
74 
75  if (!checkExpectedValues_) {
76  return;
77  }
78 
79  // cacheIdentifier starts at 2 for beginRun and 3 is next here for the first lumi
80  if (lumiNumber == 1) {
81  if (iovTestInfoFromESProducer->iovStartLumi_ != 1 || iovTestInfoFromESProducer->iovEndLumi_ != 3 ||
82  iovTestInfoFromESProducer->cacheIdentifier_ != 3) {
83  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
84  << " values read from ESProducer do not agree with expected values";
85  }
86  }
87  if (lumiNumber == 2) {
88  if (iovTestInfoFromESProducer->iovStartLumi_ != 1 || iovTestInfoFromESProducer->iovEndLumi_ != 3 ||
89  iovTestInfoFromESProducer->cacheIdentifier_ != 3) {
90  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
91  << " values read from ESProducer do not agree with expected values";
92  }
93  }
94  if (lumiNumber == 3) {
95  if (iovTestInfoFromESProducer->iovStartLumi_ != 1 || iovTestInfoFromESProducer->iovEndLumi_ != 3 ||
96  iovTestInfoFromESProducer->cacheIdentifier_ != 3) {
97  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
98  << " values read from ESProducer do not agree with expected values";
99  }
100  }
101  if (lumiNumber == 4) {
102  if (iovTestInfoFromESProducer->iovStartLumi_ != 4 || iovTestInfoFromESProducer->iovEndLumi_ != 5 ||
103  iovTestInfoFromESProducer->cacheIdentifier_ != 4) {
104  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
105  << " values read from ESProducer do not agree with expected values";
106  }
107  }
108  if (lumiNumber == 5) {
109  if (iovTestInfoFromESProducer->iovStartLumi_ != 4 || iovTestInfoFromESProducer->iovEndLumi_ != 5 ||
110  iovTestInfoFromESProducer->cacheIdentifier_ != 4) {
111  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
112  << " values read from ESProducer do not agree with expected values";
113  }
114  }
115  if (lumiNumber == 6) {
116  if (iovTestInfoFromESProducer->iovStartLumi_ != 6 || iovTestInfoFromESProducer->iovEndLumi_ != 6 ||
117  iovTestInfoFromESProducer->cacheIdentifier_ != 5) {
118  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
119  << " values read from ESProducer do not agree with expected values";
120  }
121  }
122  if (lumiNumber == 7) {
123  if (iovTestInfoFromESProducer->iovStartLumi_ != 7 || iovTestInfoFromESProducer->iovEndLumi_ != 7 ||
124  iovTestInfoFromESProducer->cacheIdentifier_ != 6) {
125  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
126  << " values read from ESProducer do not agree with expected values";
127  }
128  }
129  if (lumiNumber == 8) {
130  if (iovTestInfoFromESProducer->iovStartLumi_ != 8 || iovTestInfoFromESProducer->iovEndLumi_ != 8 ||
131  iovTestInfoFromESProducer->cacheIdentifier_ != 7) {
132  throw cms::Exception("TestFailure") << "ConcurrentIOVAnalyzer::analyze,"
133  << " values read from ESProducer do not agree with expected values";
134  }
135  }
136  }
137 
140  desc.addUntracked<bool>("checkExpectedValues", true);
141  desc.addUntracked<edm::ESInputTag>("fromSource", edm::ESInputTag("", ""));
142  descriptions.addDefault(desc);
143  }
144 } // namespace edmtest
145 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
#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