2 #include "DataFormats/TestObjects/interface/OtherThing.h" 3 #include "DataFormats/TestObjects/interface/OtherThingCollection.h" 31 : thingWasDropped_(
pset.getUntrackedParameter<
bool>(
"thingWasDropped")),
33 consumes<OtherThingCollection>(
otherTag_);
41 edm::LogInfo(
"OtherThingAnalyzer") <<
" --------------- next event ------------ \n";
43 for (OtherThingCollection::const_iterator
it = otherThings->begin(), itEnd = otherThings->end();
it != itEnd;
45 OtherThing
const& otherThing = *
it;
47 if (otherThing.oneNullOneNot.size() != 2) {
48 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
49 <<
" oneNullOneNot has wrong length: " << otherThing.oneNullOneNot.size() <<
" should be 2\n";
51 if (otherThing.oneNullOneNot[0].isNonnull()) {
52 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
" expected null Ref is not null\n";
54 if (otherThing.oneNullOneNot[1].isNull()) {
55 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
" expected non-null Ref is null\n";
58 bool shouldBeTrue = otherThing.refVec[0] != otherThing.refVec[1];
60 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"Inequality has incorrect value\n";
62 shouldBeTrue = otherThing.refVec[0] == otherThing.refVec[0];
64 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"Equality has incorrect value\n";
66 shouldBeTrue = otherThing.refProd == otherThing.refProd;
68 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
69 <<
"RefProd Equality has incorrect value\n";
71 shouldBeTrue = otherThing.refVec[0].isNonnull();
73 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
74 <<
"Non-null check has incorrect value\n";
76 shouldBeTrue = otherThing.refProd.isNonnull();
78 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
79 <<
"RefProd non-null check has incorrect value\n";
81 shouldBeTrue = !(!otherThing.refVec[0]);
83 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"'!' has incorrect value\n";
85 shouldBeTrue = !(!otherThing.refProd);
87 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"RefProd '!' has incorrect value\n";
89 shouldBeTrue = !otherThing.refVec.empty();
91 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"empty() has incorrect value\n";
93 shouldBeTrue = (otherThing.refVec == otherThing.refVec);
95 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
96 <<
"RefVector equality has incorrect value\n";
98 shouldBeTrue = !(otherThing.refVec != otherThing.refVec);
100 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
101 <<
"RefVector inequality has incorrect value\n";
107 if (otherThing.ptrOneNullOneNot.size() != 2) {
108 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
109 <<
" ptrOneNullOneNot has wrong length: " << otherThing.ptrOneNullOneNot.size() <<
" should be 2\n";
111 if (otherThing.ptrOneNullOneNot[0].isNonnull()) {
112 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
" expected null Ptr is not null\n";
114 if (otherThing.ptrOneNullOneNot[1].isNull()) {
115 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
" expected non-null Ptr is null\n";
118 shouldBeTrue = otherThing.ptrVec[0] != otherThing.ptrVec[1];
120 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"Inequality has incorrect value\n";
122 shouldBeTrue = otherThing.ptrVec[0] == otherThing.ptrVec[0];
124 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"Equality has incorrect value\n";
126 shouldBeTrue = otherThing.ptrVec[0].isNonnull();
128 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
129 <<
"Non-null check has incorrect value\n";
131 shouldBeTrue = !(!otherThing.ptrVec[0]);
133 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"'!' has incorrect value\n";
135 shouldBeTrue = !otherThing.ptrVec.empty();
137 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"empty() has incorrect value\n";
139 shouldBeTrue = (otherThing.ptrVec == otherThing.ptrVec);
141 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
142 <<
"PtrVector equality has incorrect value\n";
150 ThingCollection
const& tcoll = *otherThing.refProd;
153 if (size1 == 0 || size1 != size2) {
154 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
155 <<
" RefProd size mismatch " << std::endl;
158 Thing
const& tc = *otherThing.ref;
159 int const&
x = otherThing.ref->a;
160 if (tc.a ==
i &&
x ==
i) {
162 <<
" ITEM " <<
i <<
" LABEL " <<
label <<
" dereferenced from edm::Ref successfully.\n";
164 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
165 <<
"ITEM " <<
i <<
" has incorrect edm::Ref value " << tc.a <<
'\n';
171 if (viewSize1 == 0 || viewSize2 != viewSize1) {
172 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
173 <<
" RefToBaseProd size mismatch " << std::endl;
175 if (viewSize1 != size1) {
176 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
177 <<
" RefToBaseProd size mismatch to RefProd size" << std::endl;
181 Thing
const& tcBase = *otherThing.refToBase;
182 if (tcBase.a != refFromCast->a) {
183 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
184 <<
" Ref from RefToBase::castTo has incorrect value " <<
'\n';
186 if (tcBase.a != ptrFromCast->a) {
187 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
188 <<
" Ptr from RefToBase::castTo has incorrect value " <<
'\n';
190 int const& xBase = otherThing.refToBase->a;
191 if (tcBase.a ==
i && xBase ==
i) {
193 <<
" ITEM " <<
i <<
" LABEL " <<
label <<
" RefToBase dereferenced successfully.\n";
195 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
196 <<
"ITEM " <<
i <<
" RefToBase has incorrect value " << tc.a <<
'\n';
199 Thing
const& tcv = *otherThing.refVec[0];
200 int const& xv = otherThing.refVec[0]->a;
201 if (xv != tcv.a || xv !=
i) {
202 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
203 <<
"VECTOR ITEM 0 " <<
i <<
" has incorrect value " << tcv.a <<
'\n';
205 Thing
const& tcv1 = *otherThing.refVec[1];
206 int const& xv1 = otherThing.refVec[1]->a;
207 if (xv1 != tcv1.a || xv1 != 19 -
i) {
208 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
209 <<
"VECTOR ITEM 1 " <<
i <<
" has incorrect value " << tcv1.a <<
'\n';
212 iterRefVectorEnd = otherThing.refVec.end();
213 iterRefVector != iterRefVectorEnd;
216 Thing
const& ti = **iterRefVector;
217 int const&
xi = (*iterRefVector)->a;
219 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
220 <<
"iterator item " << ti.a <<
" " <<
xi <<
'\n';
221 }
else if (iterRefVector == otherThing.refVec.begin() &&
xi !=
i) {
222 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"iterator item 0" <<
xi <<
'\n';
223 }
else if (iterRefVector != otherThing.refVec.begin() &&
xi != 19 -
i) {
224 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"iterator item 1" <<
xi <<
'\n';
228 int zero = (*it0)->a;
234 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
235 <<
"operator+ iterator error: " << x1 <<
" " <<
one <<
'\n';
239 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
240 <<
"operator- iterator error: " << x0 <<
" " <<
zero <<
'\n';
243 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
244 <<
"operator++ iterator error: " << x0 <<
" " <<
zero <<
'\n';
247 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
248 <<
"operator++ iterator error 2: " << x1 <<
" " <<
one <<
'\n';
251 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
252 <<
"operator-- iterator error: " << x1 <<
" " <<
one <<
'\n';
255 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
256 <<
"operator-- iterator error 2: " << x0 <<
" " <<
zero <<
'\n';
259 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
260 <<
"operator[] iterator error: " << x1 <<
" " <<
one <<
'\n';
263 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
264 <<
"operator[] iterator error 2: " << x1 <<
" " <<
one <<
'\n';
267 Thing
const& tc = *otherThing.ptr;
268 int const&
x = otherThing.ptr->a;
269 if (tc.a ==
i &&
x ==
i) {
271 <<
" ITEM " <<
i <<
" LABEL " <<
label <<
" dereferenced from edm::Ptr successfully.\n";
273 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
274 <<
"ITEM " <<
i <<
" has incorrect edm::Ptr value " << tc.a <<
'\n';
277 Thing
const& tcv = *otherThing.ptrVec[0];
278 int const& xv = otherThing.ptrVec[0]->a;
279 if (xv != tcv.a || xv !=
i) {
280 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
281 <<
"VECTOR ITEM 0 " <<
i <<
" has incorrect value " << tcv.a <<
'\n';
283 Thing
const& tcv1 = *otherThing.ptrVec[1];
284 int const& xv1 = otherThing.ptrVec[1]->a;
285 if (xv1 != tcv1.a || xv1 != 19 -
i) {
286 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
287 <<
"VECTOR ITEM 1 " <<
i <<
" has incorrect value " << tcv1.a <<
'\n';
290 iterPtrVecEnd = otherThing.ptrVec.end();
291 iterPtrVec != iterPtrVecEnd;
294 Thing
const& ti = **iterPtrVec;
295 int const&
xi = (*iterPtrVec)->a;
297 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
298 <<
"iterator item " << ti.a <<
" " <<
xi <<
'\n';
299 }
else if (iterPtrVec == otherThing.ptrVec.begin() &&
xi !=
i) {
300 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"iterator item 0" <<
xi <<
'\n';
301 }
else if (iterPtrVec != otherThing.ptrVec.begin() &&
xi != 19 -
i) {
302 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze") <<
"iterator item 1" <<
xi <<
'\n';
306 int zero = (*it0)->a;
312 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
313 <<
"operator+ iterator error: " << x1 <<
" " <<
one <<
'\n';
317 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
318 <<
"operator- iterator error: " << x0 <<
" " <<
zero <<
'\n';
321 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
322 <<
"operator++ iterator error: " << x0 <<
" " <<
zero <<
'\n';
325 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
326 <<
"operator++ iterator error 2: " << x1 <<
" " <<
one <<
'\n';
329 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
330 <<
"operator-- iterator error: " << x1 <<
" " <<
one <<
'\n';
333 throw cms::Exception(
"Inconsistent Data",
"OtherThingAnalyzer::analyze")
334 <<
"operator-- iterator error 2: " << x0 <<
" " <<
zero <<
'\n';
341 desc.addUntracked<
bool>(
"thingWasDropped",
false)
343 "true if the ref to the ThingCollection in the OtherThingCollection can not be resolved since the " 344 "ThingCollection was not stored.");
346 ->setComment(
"Where to get the OtherThingCollection");
347 descriptions.
add(
"otherThingAnalyzer",
desc);
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
OtherThingAnalyzer(edm::ParameterSet const &pset)
Log< level::Info, false > LogInfo
void analyze(edm::Event const &e, edm::EventSetup const &c) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void doit(edm::Event const &event, std::string const &label)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const