15 #include "DataFormats/TestObjects/interface/Thing.h" 16 #include "DataFormats/TestObjects/interface/TrackOfDSVThings.h" 62 associationToken_(consumes<
edm::ThinnedAssociation>(
pset.getParameter<
edm::
InputTag>(
"associationTag"))),
63 trackToken_(consumes<TrackOfDSVThingsCollection>(
pset.getParameter<
edm::
InputTag>(
"trackTag"))),
64 parentWasDropped_(
pset.getParameter<
bool>(
"parentWasDropped")),
65 thinnedWasDropped_(
pset.getParameter<
bool>(
"thinnedWasDropped")),
66 thinnedIsAlias_(
pset.getParameter<
bool>(
"thinnedIsAlias")),
67 refToParentIsAvailable_(
pset.getParameter<
bool>(
"refToParentIsAvailable")),
68 associationShouldBeDropped_(
pset.getParameter<
bool>(
"associationShouldBeDropped")),
69 expectedNumberOfTracks_(
pset.getParameter<unsigned
int>(
"expectedNumberOfTracks")),
72 return DSContent{
p.getParameter<
unsigned int>(
"id"),
p.getParameter<std::vector<int>>(
"values")};
76 pset.getParameter<std::vector<edm::ParameterSet>>(
"expectedParentContent"), makeDSContent);
80 pset.getParameter<std::vector<edm::ParameterSet>>(
"expectedThinnedContent"), makeDSContent);
93 int const slimmedValueFactor =
pset.getParameter<
int>(
"slimmedValueFactor");
105 desc.add<
bool>(
"parentWasDropped",
false);
106 desc.add<
bool>(
"thinnedWasDropped",
false);
107 desc.add<
bool>(
"thinnedIsAlias",
false);
108 desc.add<
bool>(
"refToParentIsAvailable",
true)
110 "If Ref-to-parent is generally available. With thinnedRefFrom it may happen that the Ref-to-parent is not " 111 "available, but the Ref-to-thinned is. In such case this parameter should be set to 'False', and the " 112 "'expectedValues' should be set to correspond the values via Ref-to-thinned.");
113 std::vector<int> defaultV;
114 std::vector<unsigned int> defaultVU;
115 std::vector<edm::ParameterSet> defaultVPSet;
117 dsValidator.
add<
unsigned int>(
"id");
118 dsValidator.
add<std::vector<int>>(
"values", defaultV);
119 desc.addVPSet(
"expectedParentContent", dsValidator, defaultVPSet);
120 desc.addVPSet(
"expectedThinnedContent", dsValidator, defaultVPSet);
121 desc.add<std::vector<unsigned int>>(
"expectedIndexesIntoParent", defaultVU);
122 desc.add<
bool>(
"associationShouldBeDropped",
false);
123 desc.add<
unsigned int>(
"expectedNumberOfTracks", 5);
124 desc.add<std::vector<int>>(
"expectedValues");
125 desc.add<
int>(
"parentSlimmedCount", 0);
126 desc.add<
int>(
"thinnedSlimmedCount", 0);
127 desc.add<
int>(
"refSlimmedCount", 0);
128 desc.add<
int>(
"slimmedValueFactor", 10);
139 if (parentCollection.isValid()) {
140 throw cms::Exception(
"TestFailure") <<
"parent collection present, should have been dropped";
144 throw cms::Exception(
"TestFailure") <<
"parent collection has unexpected size, got " << parentCollection->size()
149 for (
auto const& detset : *parentCollection) {
150 auto const& expectedContent = *iExpected;
153 if (detset.id() != expectedContent.id) {
155 <<
"parent collection detset has unexpected id " << detset.id() <<
" expected " << expectedContent.id;
157 if (detset.size() != expectedContent.values.size()) {
159 <<
"parent collection detset with id " << detset.id() <<
" has unexpected size, got " << detset.size()
160 <<
" expected " << expectedContent.values.size();
162 auto iValue = expectedContent.values.begin();
163 for (
auto const& thing : detset) {
168 if (thing.a != expected) {
170 <<
"parent collection has unexpected content for detset with id " << detset.id() <<
", got " << thing.a
171 <<
" expected " << expected <<
" (element " <<
std::distance(expectedContent.values.begin(), iValue)
184 if (thinnedCollection.isValid()) {
185 throw cms::Exception(
"TestFailure") <<
"thinned collection present, should have been dropped";
191 <<
"thinned collection has unexpected size, got " << thinnedCollection->size() <<
" expected " 196 for (
auto const& detset : *thinnedCollection) {
197 auto const& expectedContent = *iExpected;
200 if (detset.id() != expectedContent.id) {
202 <<
"thinned collection detset has unexpected id " << detset.id() <<
" expected " << expectedContent.id;
204 if (detset.size() != expectedContent.values.size()) {
206 <<
"thinned collection detset with id " << detset.id() <<
" has unexpected size, got " << detset.size()
207 <<
" expected " << expectedContent.values.size();
209 auto iValue = expectedContent.values.begin();
210 for (
auto const& thing : detset) {
213 if (thing.a != expected) {
215 <<
"thinned collection has unexpected content for detset with id " << detset.id() <<
", got " << thing.a
216 <<
" expected " << expected <<
" (element " <<
std::distance(expectedContent.values.begin(), iValue)
225 throw cms::Exception(
"TestFailure") <<
"association collection should have been dropped but was not";
228 unsigned int expectedIndex = 0;
231 <<
"association collection has unexpected size " << associationCollection->indexesIntoParent().size()
234 for (
auto const&
association : associationCollection->indexesIntoParent()) {
237 <<
"association collection has unexpected content, for index " << expectedIndex <<
" got " <<
association 245 if (associationCollection->parentCollectionID() != parentCollection.id()) {
246 throw cms::Exception(
"TestFailure") <<
"analyze parent ProductID is not correct";
251 if (associationCollection->thinnedCollectionID() != thinnedCollection.id()) {
252 throw cms::Exception(
"TestFailure") <<
"analyze thinned ProductID is not correct";
265 int eventOffset = (
static_cast<int>(
event.eventAuxiliary().event()) - 1) * 100;
267 std::vector<int>::const_iterator expectedValue =
expectedValues_.begin();
270 if (
track.ref1.isAvailable()) {
271 throw cms::Exception(
"TestFailure") <<
"ref1 is available when it should not be, refers to " 272 <<
track.ref1.id() <<
" key " <<
track.ref1.key();
275 if (!
track.ref1.isAvailable()) {
276 throw cms::Exception(
"TestFailure") <<
"ref1 is not available when it should be";
280 if (
track.ref1->a != expected) {
282 <<
"Unexpected values from ref1, got " <<
track.ref1->a <<
" expected " << expected;
284 if (
track.ref1->a != expected) {
286 <<
"Unexpected values from ref1 (2nd try), got " <<
track.ref1->a <<
" expected " << expected;
293 if (*expectedValue == -1) {
294 if (refToThinned.isNonnull()) {
295 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref1) is non-null when it should be null";
297 if (refToThinned.isAvailable()) {
298 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref1) is available when it should not be";
301 if (refToThinned.isNull()) {
302 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref1) is null when it should not be";
304 if (refToThinned.id() != thinnedCollection.id()) {
305 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref).id() " << refToThinned.id()
306 <<
" differs from expectation " << thinnedCollection.id();
308 if (not refToThinned.isAvailable()) {
309 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref1) is not available when it should be";
314 if (refToThinned->a != expected) {
316 <<
"Unexpected values from thinnedRefFrom(ref1), got " << refToThinned->a <<
" expected " << expected;
318 if (refToThinned->a != expected) {
319 throw cms::Exception(
"TestFailure") <<
"Unexpected values from thinnedRefFrom(ref1) (2nd try) " 320 << refToThinned->a <<
" expected " << expected;
327 if (
track.ref2.isAvailable()) {
328 throw cms::Exception(
"TestFailure") <<
"ref2 is available when it should not be";
331 if (!
track.ref2.isAvailable()) {
332 throw cms::Exception(
"TestFailure") <<
"ref2 is not available when it should be";
336 if (
track.ref2->a != expected) {
338 <<
"unexpected values from ref2, got " <<
track.ref2->a <<
" expected " << expected;
340 if (
track.ref2->a != expected) {
342 <<
"unexpected values from ref2 (2nd try), got " <<
track.ref2->a <<
" expected " << expected;
348 if (*expectedValue == -1) {
349 if (refToThinned.isNonnull()) {
350 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref2) is non-null when it should be null";
352 if (refToThinned.isAvailable()) {
353 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref2) is available when it should not be";
356 if (refToThinned.isNull()) {
357 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref2) is null when it should not be";
359 if (refToThinned.id() != thinnedCollection.id()) {
360 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref2).id() " << refToThinned.id()
361 <<
" differs from expectation " << thinnedCollection.id();
363 if (not refToThinned.isAvailable()) {
364 throw cms::Exception(
"TestFailure") <<
"thinnedRefFrom(ref2) is not available when it should be";
369 if (refToThinned->a != expected) {
371 <<
"Unexpected values from thinnedRefFrom(ref2), got " << refToThinned->a <<
" expected " << expected;
373 if (refToThinned->a != expected) {
374 throw cms::Exception(
"TestFailure") <<
"Unexpected values from thinnedRefFrom(ref2) (2nd try), got " 375 << refToThinned->a <<
" expected " << expected;
384 bool allPresent =
true;
386 if (iExpectedValue != -1) {
391 if (refToThinned->a != expected) {
392 throw cms::Exception(
"TestFailure") <<
"unexpected values from thinnedRefFrom(refVector1), got " 393 << refToThinned->a <<
" expected " << expected;
398 if (
track.refVector1[
k]->a != expected) {
400 <<
"unexpected values from refVector1, got " <<
track.refVector1[
k]->a <<
" expected " << expected;
410 if (!
track.refVector1.isAvailable()) {
411 throw cms::Exception(
"TestFailure") <<
"unexpected value (false) from refVector::isAvailable";
414 if (
track.refVector1.isAvailable()) {
415 throw cms::Exception(
"TestFailure") <<
"unexpected value (true) from refVector::isAvailable";
422 if (
track.refVector1[
k]->a != expected) {
424 <<
"unexpected values from refVector1, got " <<
track.refVector1[
k]->a <<
" expected " << expected;
int refSlimmedValueFactor_
ThinningDSVTestAnalyzer(edm::ParameterSet const &pset)
void incrementExpectedValue(std::vector< int >::const_iterator &iter) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ret
prodAgent to be discontinued
edm::EDGetTokenT< edmNew::DetSetVector< Thing > > parentToken_
int parentSlimmedValueFactor_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
bool refToParentIsAvailable_
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
std::vector< int > values
void analyze(edm::StreamID, edm::Event const &e, edm::EventSetup const &c) const override
void addDefault(ParameterSetDescription const &psetDescription)
unsigned int expectedNumberOfTracks_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::vector< DSContent > expectedThinnedContent_
edm::EDGetTokenT< edmNew::DetSetVector< Thing > > thinnedToken_
edm::EDGetTokenT< edm::ThinnedAssociation > associationToken_
#define DEFINE_FWK_MODULE(type)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Ref< C, T, F > thinnedRefFrom(Ref< C, T, F > const &parent, RefProd< C > const &thinned, edm::EDProductGetter const &prodGetter)
Return a Ref to thinned collection corresponding to an element of the Ref to parent collection...
std::vector< DSContent > expectedParentContent_
bool associationShouldBeDropped_
std::vector< int > expectedValues_
edm::EDGetTokenT< TrackOfDSVThingsCollection > trackToken_
std::vector< unsigned int > expectedIndexesIntoParent_
int thinnedSlimmedValueFactor_