16 #include "DataFormats/TestObjects/interface/ToyProducts.h" 43 edm::one::WatchLuminosityBlocks,
44 edm::WatchProcessBlock,
45 edm::InputProcessBlockCache<int, long long int>> {
81 std::vector<edm::EDGetTokenT<IntProduct>>
tokens_;
104 expectedSum_(
pset.getUntrackedParameter<
int>(
"expectedSum", 0)),
105 expectedCache_(
pset.getUntrackedParameter<
int>(
"expectedCache", 0)),
107 inputTagsNotFound_(),
108 getByTokenFirst_(
pset.getUntrackedParameter<
bool>(
"getByTokenFirst",
false)),
110 runProducerParameterCheck_(
pset.getUntrackedParameter<
bool>(
"runProducerParameterCheck",
false)),
111 testGetterOfProducts_(
pset.getUntrackedParameter<
bool>(
"testGetterOfProducts",
false)),
116 std::vector<edm::InputTag> emptyTagVector;
117 inputTagsNotFound_ =
pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsNotFound", emptyTagVector);
118 inputTagsView_ =
pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsView", emptyTagVector);
119 inputTagsUInt64_ =
pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsUInt64", emptyTagVector);
120 inputTagsEndLumi_ =
pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsEndLumi", emptyTagVector);
121 inputTagsEndRun_ =
pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsEndRun", emptyTagVector);
123 pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsBeginProcessBlock", emptyTagVector);
125 pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsInputProcessBlock", emptyTagVector);
127 pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsEndProcessBlock", emptyTagVector);
129 pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsEndProcessBlock2", emptyTagVector);
131 pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsEndProcessBlock3", emptyTagVector);
133 pset.getUntrackedParameter<std::vector<edm::InputTag>>(
"inputTagsEndProcessBlock4", emptyTagVector);
173 registerProcessBlockCacheFiller<int>(
175 [
this](
edm::ProcessBlock const& processBlock, std::shared_ptr<int>
const& previousCache) {
176 auto returnValue = std::make_shared<int>(0);
178 *returnValue += processBlock.get(
token).value;
182 registerProcessBlockCacheFiller<1>(
184 [
this](
edm::ProcessBlock const& processBlock, std::shared_ptr<long long int>
const& previousCache) {
185 auto returnValue = std::make_shared<long long int>(0);
187 *returnValue += processBlock.get(
token).value;
202 std::vector<edm::EDGetTokenT<IntProduct>>::const_iterator iToken =
tokens_.begin();
203 for (std::vector<edm::InputTag>::const_iterator iter =
inputTags_.begin(), iEnd =
inputTags_.end(); iter != iEnd;
206 event.getByToken(*iToken, hToken);
210 event.getByLabel(*iter,
h);
213 event.getByToken(*iToken, hToken);
214 if (
h->value != hToken->value) {
216 <<
"TestFindProduct::analyze getByLabel and getByToken return inconsistent results";
225 int expectedParameterValue = 3;
226 if (!iter->process().empty()) {
227 if (
event.run() == 1) {
228 expectedParameterValue = 1;
230 expectedParameterValue = 2;
233 if (par != expectedParameterValue) {
234 throw cms::Exception(
"TestFail") <<
"TestFindProduct::analyze unexpected value from producer parameter set";
242 event.getByLabel(*iter,
h);
245 <<
"TestFindProduct::analyze: getByLabel found a product that should not be found " 246 <<
h.provenance()->moduleLabel();
249 event.getByToken(*iToken, hToken);
252 <<
"TestFindProduct::analyze: getByToken found a product that should not be found " 256 std::vector<edm::EDGetTokenT<edm::View<int>>>::const_iterator iTokenView =
tokensView_.begin();
259 ++iter, ++iTokenView) {
261 event.getByToken(*iTokenView, hViewToken);
265 event.getByLabel(*iter, hView);
266 sum_ += hView->at(0);
268 event.getByToken(*iTokenView, hViewToken);
269 if (hView->at(0) != hViewToken->at(0)) {
271 <<
"TestFindProduct::analyze getByLabel and getByToken return inconsistent results";
278 event.getByToken(
token, h64);
287 throw cms::Exception(
"TestFail") <<
"TestFindProduct::analyze 0 ProcessBlock cache has unexpected value " 294 throw cms::Exception(
"TestFail") <<
"TestFindProduct::analyze 1 ProcessBlock cache has unexpected value " 328 std::vector<edm::Handle<IntProduct>>
handles;
330 for (
auto const& intHandle :
handles) {
331 sum_ += intHandle->value;
355 if (
h->value !=
val + 2) {
356 throw cms::Exception(
"TestFail") <<
"TestFindProduct::endProcessBlock 2, received unexpected value";
361 if (
h->value !=
val + 3) {
362 throw cms::Exception(
"TestFail") <<
"TestFindProduct::endProcessBlock 3, received unexpected value";
367 if (
h->value !=
val + 4) {
368 throw cms::Exception(
"TestFail") <<
"TestFindProduct::endProcessBlock 4, received unexpected value";
374 std::vector<edm::Handle<IntProduct>>
handles;
376 for (
auto const& intHandle :
handles) {
377 sum_ += intHandle->value;
386 <<
"TestFindProduct::endJob - Sum of test object values does not equal expected value";
std::vector< edm::InputTag > inputTagsUInt64_
std::vector< edm::InputTag > inputTagsEndProcessBlock2_
T getParameter(std::string const &) const
std::vector< edm::EDGetToken > tokensEndProcessBlock2_
std::vector< edm::InputTag > inputTagsEndProcessBlock_
std::vector< edm::EDGetTokenT< UInt64Product > > tokensUInt64_
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
std::vector< edm::EDGetTokenT< IntProduct > > tokensBeginProcessBlock_
PROD const & get(EDGetTokenT< PROD > token) const noexcept(false)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
void beginRun(edm::Run const &, edm::EventSetup const &) override
Provenance const * provenance() const
std::vector< edm::EDGetTokenT< IntProduct > > tokensNotFound_
std::vector< edm::InputTag > inputTagsView_
std::vector< edm::EDGetTokenT< IntProduct > > tokens_
void beginProcessBlock(edm::ProcessBlock const &) override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool runProducerParameterCheck_
std::vector< edm::InputTag > inputTagsEndLumi_
TestFindProduct(edm::ParameterSet const &pset)
edm::GetterOfProducts< IntProduct > getterOfProducts_
std::vector< BaseVolumeHandle * > handles
std::vector< edm::EDGetTokenT< IntProduct > > tokensEndRun_
std::vector< edm::EDGetTokenT< IntProduct > > tokensInputProcessBlock_
std::vector< edm::EDGetTokenT< IntProduct > > tokensEndProcessBlock4_
void endRun(edm::Run const &, edm::EventSetup const &) override
std::vector< edm::InputTag > inputTagsInputProcessBlock_
bool testGetterOfProducts_
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
#define DEFINE_FWK_MODULE(type)
ParameterSet const * getProducerParameterSet(Provenance const &provenance, ProcessHistory const &)
std::vector< edm::InputTag > inputTags_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< edm::EDGetTokenT< edm::View< int > > > tokensView_
void fillHandles(edm::Event const &event, std::vector< edm::Handle< T >> &handles) const
std::vector< edm::EDGetTokenT< IntProduct > > tokensEndProcessBlock_
std::vector< edm::InputTag > inputTagsEndProcessBlock4_
~TestFindProduct() override
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void analyze(edm::Event const &e, edm::EventSetup const &es) override
void accessInputProcessBlock(edm::ProcessBlock const &) override
std::vector< edm::InputTag > inputTagsEndProcessBlock3_
std::vector< edm::InputTag > inputTagsNotFound_
void endProcessBlock(edm::ProcessBlock const &) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::vector< edm::EDGetTokenT< IntProduct > > tokensEndProcessBlock3_
std::vector< edm::EDGetTokenT< IntProduct > > tokensEndLumi_
std::vector< edm::InputTag > inputTagsEndRun_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< edm::InputTag > inputTagsBeginProcessBlock_