CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edmtest::ThinningTestAnalyzer Class Reference
Inheritance diagram for edmtest::ThinningTestAnalyzer:
edm::global::EDAnalyzer<> edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::StreamID, edm::Event const &e, edm::EventSetup const &c) const override
 
 ThinningTestAnalyzer (edm::ParameterSet const &pset)
 
- Public Member Functions inherited from edm::global::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

edm::Handle< edm::ThinnedAssociationgetAssociation (edm::Event const &event) const
 
edm::Handle< ThingCollection > getParent (edm::Event const &event) const
 
std::tuple< edm::Handle< ThingCollection >, edm::RefProd< ThingCollection > > getThinned (edm::Event const &event) const
 
edm::Handle< TrackOfThingsCollection > getTrackCollection (edm::Event const &event) const
 
void incrementExpectedValue (std::vector< int >::const_iterator &iter) const
 
template<typename RefT >
void testRefToParent (RefT const &ref, std::string_view refName, int const expectedValue, int const eventOffset) const
 
template<typename RefT >
void testRefToThinned (RefT const &ref, std::string_view refName, int const expectedValue, int const eventOffset, edm::ProductID const thinnedCollectionID) const
 
void testVectors (TrackOfThings const &track, edm::RefProd< ThingCollection > const &thinnedRefProd, edm::EDProductGetter const &productGetter, int const eventOffset) const
 

Private Attributes

bool associationShouldBeDropped_
 
edm::EDGetTokenT< edm::ThinnedAssociationassociationToken_
 
std::vector< unsigned int > expectedIndexesIntoParent_
 
std::vector< int > expectedParentContent_
 
std::vector< int > expectedThinnedContent_
 
std::vector< int > expectedValues_
 
int parentSlimmedValueFactor_
 
edm::EDGetTokenT< ThingCollection > parentToken_
 
bool parentWasDropped_
 
int refSlimmedValueFactor_
 
bool refToParentIsAvailable_
 
bool thinnedIsAlias_
 
int thinnedSlimmedValueFactor_
 
edm::EDGetTokenT< ThingCollection > thinnedToken_
 
bool thinnedWasDropped_
 
edm::EDGetTokenT< TrackOfThingsCollection > trackToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 21 of file ThinningTestAnalyzer.cc.

Constructor & Destructor Documentation

◆ ThinningTestAnalyzer()

edmtest::ThinningTestAnalyzer::ThinningTestAnalyzer ( edm::ParameterSet const &  pset)
explicit

Definition at line 74 of file ThinningTestAnalyzer.cc.

References associationShouldBeDropped_, associationToken_, submitPVResolutionJobs::count, expectedIndexesIntoParent_, expectedParentContent_, expectedThinnedContent_, expectedValues_, mps_fire::i, parentSlimmedValueFactor_, parentToken_, parentWasDropped_, muonDTDigis_cfi::pset, refSlimmedValueFactor_, refToParentIsAvailable_, runTheMatrix::ret, thinnedIsAlias_, thinnedSlimmedValueFactor_, thinnedToken_, thinnedWasDropped_, and trackToken_.

74  {
75  parentToken_ = consumes<ThingCollection>(pset.getParameter<edm::InputTag>("parentTag"));
76  thinnedToken_ = mayConsume<ThingCollection>(pset.getParameter<edm::InputTag>("thinnedTag"));
77  associationToken_ = mayConsume<edm::ThinnedAssociation>(pset.getParameter<edm::InputTag>("associationTag"));
78  trackToken_ = consumes<TrackOfThingsCollection>(pset.getParameter<edm::InputTag>("trackTag"));
79  parentWasDropped_ = pset.getParameter<bool>("parentWasDropped");
80  if (!parentWasDropped_) {
81  expectedParentContent_ = pset.getParameter<std::vector<int>>("expectedParentContent");
82  }
83  thinnedWasDropped_ = pset.getParameter<bool>("thinnedWasDropped");
84  thinnedIsAlias_ = pset.getParameter<bool>("thinnedIsAlias");
85  if (!thinnedWasDropped_) {
86  expectedThinnedContent_ = pset.getParameter<std::vector<int>>("expectedThinnedContent");
87  }
88  refToParentIsAvailable_ = pset.getParameter<bool>("refToParentIsAvailable");
89  associationShouldBeDropped_ = pset.getParameter<bool>("associationShouldBeDropped");
91  expectedIndexesIntoParent_ = pset.getParameter<std::vector<unsigned int>>("expectedIndexesIntoParent");
92  }
93  expectedValues_ = pset.getParameter<std::vector<int>>("expectedValues");
94 
95  auto slimmedFactor = [](int count, int factor) {
96  int ret = 1;
97  for (int i = 0; i < count; ++i) {
98  ret *= factor;
99  }
100  return ret;
101  };
102  int const slimmedValueFactor = pset.getParameter<int>("slimmedValueFactor");
103  parentSlimmedValueFactor_ = slimmedFactor(pset.getParameter<int>("parentSlimmedCount"), slimmedValueFactor);
104  thinnedSlimmedValueFactor_ = slimmedFactor(pset.getParameter<int>("thinnedSlimmedCount"), slimmedValueFactor);
105  refSlimmedValueFactor_ = slimmedFactor(pset.getParameter<int>("refSlimmedCount"), slimmedValueFactor);
106  }
ret
prodAgent to be discontinued
edm::EDGetTokenT< ThingCollection > thinnedToken_
std::vector< int > expectedThinnedContent_
edm::EDGetTokenT< TrackOfThingsCollection > trackToken_
std::vector< int > expectedParentContent_
edm::EDGetTokenT< ThingCollection > parentToken_
std::vector< unsigned int > expectedIndexesIntoParent_
edm::EDGetTokenT< edm::ThinnedAssociation > associationToken_

Member Function Documentation

◆ analyze()

void edmtest::ThinningTestAnalyzer::analyze ( edm::StreamID  ,
edm::Event const &  e,
edm::EventSetup const &  c 
) const
overridevirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 136 of file ThinningTestAnalyzer.cc.

References associationShouldBeDropped_, Exception, expectedValues_, getAssociation(), getParent(), getThinned(), getTrackCollection(), incrementExpectedValue(), parentWasDropped_, testRefToParent(), testRefToThinned(), testVectors(), edm::thinnedRefFrom(), thinnedWasDropped_, HLT_2023v12_cff::track, and JetHT_cfg::trackCollection.

136  {
137  auto parentCollection = getParent(event);
138  auto [thinnedCollection, thinnedRefProd] = getThinned(event);
139  auto associationCollection = getAssociation(event);
141 
143  if (associationCollection->parentCollectionID() != parentCollection.id()) {
144  throw cms::Exception("TestFailure") << "analyze parent ProductID is not correct";
145  }
146  }
147 
149  if (associationCollection->thinnedCollectionID() != thinnedCollection.id()) {
150  throw cms::Exception("TestFailure") << "analyze thinned ProductID is not correct";
151  }
152  }
153 
154  int const eventOffset = static_cast<int>(event.eventAuxiliary().event() * 100 + 100);
155 
156  std::vector<int>::const_iterator expectedValue = expectedValues_.begin();
157  for (auto const& track : *trackCollection) {
158  testRefToParent(track.ref1, "ref1", *expectedValue, eventOffset);
159  if (not thinnedWasDropped_) {
160  testRefToThinned(edm::thinnedRefFrom(track.ref1, thinnedRefProd, event.productGetter()),
161  "ref1",
162  *expectedValue,
163  eventOffset,
164  thinnedCollection.id());
165  }
166  testRefToParent(track.refToBase1, "refToBase1", *expectedValue, eventOffset);
167  incrementExpectedValue(expectedValue);
168 
169  testRefToParent(track.ref2, "ref2", *expectedValue, eventOffset);
170  if (not thinnedWasDropped_) {
171  testRefToThinned(edm::thinnedRefFrom(track.ref2, thinnedRefProd, event.productGetter()),
172  "ref2",
173  *expectedValue,
174  eventOffset,
175  thinnedCollection.id());
176  }
177  incrementExpectedValue(expectedValue);
178 
179  testRefToParent(track.ptr1, "ptr1", *expectedValue, eventOffset);
180  incrementExpectedValue(expectedValue);
181 
182  testRefToParent(track.ptr2, "ptr2", *expectedValue, eventOffset);
183  incrementExpectedValue(expectedValue);
184 
185  testVectors(track, thinnedRefProd, event.productGetter(), eventOffset);
186  }
187  }
edm::Handle< TrackOfThingsCollection > getTrackCollection(edm::Event const &event) const
void incrementExpectedValue(std::vector< int >::const_iterator &iter) const
void testVectors(TrackOfThings const &track, edm::RefProd< ThingCollection > const &thinnedRefProd, edm::EDProductGetter const &productGetter, int const eventOffset) const
edm::Handle< ThingCollection > getParent(edm::Event const &event) const
edm::Handle< edm::ThinnedAssociation > getAssociation(edm::Event const &event) const
trackCollection
Definition: JetHT_cfg.py:51
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...
Definition: RefItemGet.h:129
void testRefToThinned(RefT const &ref, std::string_view refName, int const expectedValue, int const eventOffset, edm::ProductID const thinnedCollectionID) const
void testRefToParent(RefT const &ref, std::string_view refName, int const expectedValue, int const eventOffset) const
std::tuple< edm::Handle< ThingCollection >, edm::RefProd< ThingCollection > > getThinned(edm::Event const &event) const
Definition: event.py:1

◆ fillDescriptions()

void edmtest::ThinningTestAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 108 of file ThinningTestAnalyzer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

108  {
110  desc.add<edm::InputTag>("parentTag");
111  desc.add<edm::InputTag>("thinnedTag");
112  desc.add<edm::InputTag>("associationTag");
113  desc.add<edm::InputTag>("trackTag");
114  desc.add<bool>("parentWasDropped", false);
115  desc.add<bool>("thinnedWasDropped", false);
116  desc.add<bool>("thinnedIsAlias", false);
117  desc.add<bool>("refToParentIsAvailable", true)
118  ->setComment(
119  "If Ref-to-parent is generally available. With thinnedRefFrom it may happen that the Ref-to-parent is not "
120  "available, but the Ref-to-thinned is. In such case this parameter should be set to 'False', and the "
121  "'expectedValues' should be set to correspond the values via Ref-to-thinned.");
122  std::vector<int> defaultV;
123  std::vector<unsigned int> defaultVU;
124  desc.add<std::vector<int>>("expectedParentContent", defaultV);
125  desc.add<std::vector<int>>("expectedThinnedContent", defaultV);
126  desc.add<std::vector<unsigned int>>("expectedIndexesIntoParent", defaultVU);
127  desc.add<bool>("associationShouldBeDropped", false);
128  desc.add<std::vector<int>>("expectedValues");
129  desc.add<int>("parentSlimmedCount", 0);
130  desc.add<int>("thinnedSlimmedCount", 0);
131  desc.add<int>("refSlimmedCount", 0);
132  desc.add<int>("slimmedValueFactor", 10);
133  descriptions.addDefault(desc);
134  }
void addDefault(ParameterSetDescription const &psetDescription)

◆ getAssociation()

edm::Handle< edm::ThinnedAssociation > edmtest::ThinningTestAnalyzer::getAssociation ( edm::Event const &  event) const
private

Definition at line 251 of file ThinningTestAnalyzer.cc.

References associationShouldBeDropped_, associationToken_, Exception, and expectedIndexesIntoParent_.

Referenced by analyze().

251  {
252  auto associationCollection = event.getHandle(associationToken_);
253  if (associationShouldBeDropped_ && associationCollection.isValid()) {
254  throw cms::Exception("TestFailure") << "association collection should have been dropped but was not";
255  }
257  unsigned int expectedIndex = 0;
258  if (associationCollection->indexesIntoParent().size() != expectedIndexesIntoParent_.size()) {
259  throw cms::Exception("TestFailure") << "association collection has unexpected size";
260  }
261  for (auto const& association : associationCollection->indexesIntoParent()) {
262  if (association != expectedIndexesIntoParent_.at(expectedIndex)) {
263  throw cms::Exception("TestFailure")
264  << "association collection has unexpected content, for index " << expectedIndex << " got " << association
265  << " expected " << expectedIndexesIntoParent_.at(expectedIndex);
266  }
267  ++expectedIndex;
268  }
269  }
270  return associationCollection;
271  }
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
std::vector< unsigned int > expectedIndexesIntoParent_
edm::EDGetTokenT< edm::ThinnedAssociation > associationToken_

◆ getParent()

edm::Handle< ThingCollection > edmtest::ThinningTestAnalyzer::getParent ( edm::Event const &  event) const
private

Definition at line 189 of file ThinningTestAnalyzer.cc.

References Exception, expectedParentContent_, mps_fire::i, parentSlimmedValueFactor_, parentToken_, and parentWasDropped_.

Referenced by analyze().

189  {
190  auto parentCollection = event.getHandle(parentToken_);
191 
192  unsigned int i = 0;
193  if (parentWasDropped_) {
194  if (parentCollection.isValid()) {
195  throw cms::Exception("TestFailure") << "parent collection present, should have been dropped";
196  }
197  } else if (!expectedParentContent_.empty()) {
198  if (parentCollection->size() != expectedParentContent_.size()) {
199  throw cms::Exception("TestFailure") << "parent collection has unexpected size, got " << parentCollection->size()
200  << " expected " << expectedParentContent_.size();
201  }
202  for (auto const& thing : *parentCollection) {
203  // Just some numbers that match the somewhat arbitrary values put in
204  // by the ThingProducer.
205  int expected = static_cast<int>(expectedParentContent_.at(i) + event.eventAuxiliary().event() * 100 + 100) *
207  if (thing.a != expected) {
208  throw cms::Exception("TestFailure")
209  << "parent collection has unexpected content, got " << thing.a << " expected " << expected;
210  }
211  ++i;
212  }
213  }
214 
215  return parentCollection;
216  }
std::vector< int > expectedParentContent_
edm::EDGetTokenT< ThingCollection > parentToken_

◆ getThinned()

std::tuple< edm::Handle< ThingCollection >, edm::RefProd< ThingCollection > > edmtest::ThinningTestAnalyzer::getThinned ( edm::Event const &  event) const
private

Definition at line 218 of file ThinningTestAnalyzer.cc.

References Exception, expectedThinnedContent_, thinnedSlimmedValueFactor_, thinnedToken_, thinnedWasDropped_, and mkLumiAveragedPlots::tuple.

Referenced by analyze().

219  {
220  auto thinnedCollection = event.getHandle(thinnedToken_);
221 
222  // Check to see the content is what we expect based on what was written
223  // by ThingProducer and TrackOfThingsProducer. The values are somewhat
224  // arbitrary and meaningless.
225  edm::RefProd<ThingCollection> thinnedRefProd;
226  if (thinnedWasDropped_) {
227  if (thinnedCollection.isValid()) {
228  throw cms::Exception("TestFailure") << "thinned collection present, should have been dropped";
229  }
230  } else {
231  thinnedRefProd = edm::RefProd<ThingCollection>{thinnedCollection};
232  unsigned expectedIndex = 0;
233  if (thinnedCollection->size() != expectedThinnedContent_.size()) {
234  throw cms::Exception("TestFailure")
235  << "thinned collection has unexpected size, got " << thinnedCollection->size() << " expected "
236  << expectedThinnedContent_.size();
237  }
238  for (auto const& thing : *thinnedCollection) {
239  const int expected = (expectedThinnedContent_.at(expectedIndex) + event.eventAuxiliary().event() * 100 + 100) *
241  if (thing.a != expected) {
242  throw cms::Exception("TestFailure")
243  << "thinned collection has unexpected content, got " << thing.a << " expected " << expected;
244  }
245  ++expectedIndex;
246  }
247  }
248  return std::tuple(thinnedCollection, thinnedRefProd);
249  }
edm::EDGetTokenT< ThingCollection > thinnedToken_
std::vector< int > expectedThinnedContent_

◆ getTrackCollection()

edm::Handle< TrackOfThingsCollection > edmtest::ThinningTestAnalyzer::getTrackCollection ( edm::Event const &  event) const
private

Definition at line 273 of file ThinningTestAnalyzer.cc.

References Exception, JetHT_cfg::trackCollection, and trackToken_.

Referenced by analyze().

273  {
274  auto trackCollection = event.getHandle(trackToken_);
275  if (trackCollection->size() != 5u) {
276  throw cms::Exception("TestFailure") << "unexpected Track size";
277  }
278  return trackCollection;
279  }
edm::EDGetTokenT< TrackOfThingsCollection > trackToken_
trackCollection
Definition: JetHT_cfg.py:51

◆ incrementExpectedValue()

void edmtest::ThinningTestAnalyzer::incrementExpectedValue ( std::vector< int >::const_iterator &  iter) const
private

Definition at line 425 of file ThinningTestAnalyzer.cc.

References expectedValues_.

Referenced by analyze().

425  {
426  ++iter;
427  if (iter == expectedValues_.end())
428  iter = expectedValues_.begin();
429  }

◆ testRefToParent()

template<typename RefT >
void edmtest::ThinningTestAnalyzer::testRefToParent ( RefT const &  ref,
std::string_view  refName,
int const  expectedValue,
int const  eventOffset 
) const
private

Definition at line 282 of file ThinningTestAnalyzer.cc.

References Exception, or, refSlimmedValueFactor_, and refToParentIsAvailable_.

Referenced by analyze().

285  {
286  if (not refToParentIsAvailable_ or expectedValue == -1) {
287  if (ref.isAvailable()) {
288  throw cms::Exception("TestFailure")
289  << refName << " is available when it should not be, refers to " << ref.id() << " key " << ref.key();
290  }
291  } else {
292  if (!ref.isAvailable()) {
293  throw cms::Exception("TestFailure") << refName << " is not available when it should be";
294  }
295  // Check twice to test some possible caching problems.
296  const int expected = (expectedValue + eventOffset) * refSlimmedValueFactor_;
297  if (ref->a != expected) {
298  throw cms::Exception("TestFailure")
299  << "Unexpected values from " << refName << ", got " << ref->a << " expected " << expected;
300  }
301  if (ref->a != expected) {
302  throw cms::Exception("TestFailure")
303  << "Unexpected values from " << refName << " (2nd try), got " << ref->a << " expected " << expected;
304  }
305  }
306  }
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
Definition: Activities.doc:12

◆ testRefToThinned()

template<typename RefT >
void edmtest::ThinningTestAnalyzer::testRefToThinned ( RefT const &  ref,
std::string_view  refName,
int const  expectedValue,
int const  eventOffset,
edm::ProductID const  thinnedCollectionID 
) const
private

Definition at line 309 of file ThinningTestAnalyzer.cc.

References Exception, and thinnedSlimmedValueFactor_.

Referenced by analyze().

313  {
314  if (expectedValue == -1) {
315  if (refToThinned.isNonnull()) {
316  throw cms::Exception("TestFailure") << "thinnedRefFrom(" << refName << ") is non-null when it should be null";
317  }
318  if (refToThinned.isAvailable()) {
319  throw cms::Exception("TestFailure") << "thinnedRefFrom(" << refName << ") is available when it should not be";
320  }
321  } else {
322  if (refToThinned.isNull()) {
323  throw cms::Exception("TestFailure") << "thinnedRefFrom(" << refName << ") is null when it should not be";
324  }
325  if (refToThinned.id() != thinnedCollectionID) {
326  throw cms::Exception("TestFailure") << "thinnedRefFrom(" << refName << ").id() " << refToThinned.id()
327  << " differs from expectation " << thinnedCollectionID;
328  }
329  if (not refToThinned.isAvailable()) {
330  throw cms::Exception("TestFailure") << "thinnedRefFrom(" << refName << ") is not available when it should be";
331  }
332  // Check twice to test some possible caching problems.
333  // need to account for slimming because going through an explicit ref-to-slimmed
334  const int expected = (expectedValue + eventOffset) * thinnedSlimmedValueFactor_;
335  if (refToThinned->a != expected) {
336  throw cms::Exception("TestFailure") << "Unexpected values from thinnedRefFrom(" << refName << "), got "
337  << refToThinned->a << " expected " << expected;
338  }
339  if (refToThinned->a != expected) {
340  throw cms::Exception("TestFailure") << "Unexpected values from thinnedRefFrom(" << refName << ") (2nd try) "
341  << refToThinned->a << " expected " << expected;
342  }
343  }
344  }

◆ testVectors()

void edmtest::ThinningTestAnalyzer::testVectors ( TrackOfThings const &  track,
edm::RefProd< ThingCollection > const &  thinnedRefProd,
edm::EDProductGetter const &  productGetter,
int const  eventOffset 
) const
private

Definition at line 346 of file ThinningTestAnalyzer.cc.

References Exception, expectedValues_, dqmdumpme::k, edm::refcoreimpl::productGetter(), refSlimmedValueFactor_, refToParentIsAvailable_, edm::thinnedRefFrom(), thinnedSlimmedValueFactor_, thinnedWasDropped_, and HLT_2023v12_cff::track.

Referenced by analyze().

349  {
350  // Test RefVector, PtrVector, and RefToBaseVector
351  unsigned int k = 0;
352  bool allPresent = true;
353  for (auto iExpectedValue : expectedValues_) {
354  if (iExpectedValue != -1) {
355  if (not thinnedWasDropped_) {
356  auto refToThinned = edm::thinnedRefFrom(track.refVector1[k], thinnedRefProd, productGetter);
357  // need to account for slimming because going through an explicit ref-to-slimmed
358  const int expected = (iExpectedValue + eventOffset) * thinnedSlimmedValueFactor_;
359  if (refToThinned->a != expected) {
360  throw cms::Exception("TestFailure") << "unexpected values from thinnedRefFrom(refVector1), got "
361  << refToThinned->a << " expected " << expected;
362  }
363  }
365  const int expected = (iExpectedValue + eventOffset) * refSlimmedValueFactor_;
366  if (track.refVector1[k]->a != expected) {
367  throw cms::Exception("TestFailure")
368  << "unexpected values from refVector1, got " << track.refVector1[k]->a << " expected " << expected;
369  }
370  if (track.ptrVector1[k]->a != expected) {
371  throw cms::Exception("TestFailure") << "unexpected values from ptrVector1";
372  }
373  if (track.refToBaseVector1[k]->a != expected) {
374  throw cms::Exception("TestFailure") << "unexpected values from refToBaseVector1";
375  }
376  }
377  } else {
378  allPresent = false;
379  }
380  ++k;
381  }
382 
383  if (refToParentIsAvailable_ and allPresent) {
384  if (!track.refVector1.isAvailable()) {
385  throw cms::Exception("TestFailure") << "unexpected value (false) from refVector::isAvailable";
386  }
387  if (!track.ptrVector1.isAvailable()) {
388  throw cms::Exception("TestFailure") << "unexpected value (false) from ptrVector::isAvailable";
389  }
390  if (!track.refToBaseVector1.isAvailable()) {
391  throw cms::Exception("TestFailure") << "unexpected value (false) from refToBaseVector::isAvailable";
392  }
393  } else {
394  if (track.refVector1.isAvailable()) {
395  throw cms::Exception("TestFailure") << "unexpected value (true) from refVector::isAvailable";
396  }
397  if (track.ptrVector1.isAvailable()) {
398  throw cms::Exception("TestFailure") << "unexpected value (true) from ptrVector::isAvailable";
399  }
400  if (track.refToBaseVector1.isAvailable()) {
401  throw cms::Exception("TestFailure") << "unexpected value (true) from refToBaseVector::isAvailable";
402  }
403  }
404  k = 0;
405  for (auto iExpectedValue : expectedValues_) {
406  if (refToParentIsAvailable_ and iExpectedValue != -1) {
407  const int expected = (iExpectedValue + eventOffset) * refSlimmedValueFactor_;
408  if (track.refVector1[k]->a != expected) {
409  throw cms::Exception("TestFailure")
410  << "unexpected values from refVector1, got " << track.refVector1[k]->a << " expected " << expected;
411  }
412  if (track.ptrVector1[k]->a != expected) {
413  throw cms::Exception("TestFailure") << "unexpected values from ptrVector1";
414  }
415  if (track.refToBaseVector1[k]->a != expected) {
416  throw cms::Exception("TestFailure") << "unexpected values from refToBaseVector1";
417  }
418  } else {
419  allPresent = false;
420  }
421  ++k;
422  }
423  }
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...
Definition: RefItemGet.h:129
EDProductGetter const * productGetter(std::atomic< void const *> const &iCache)

Member Data Documentation

◆ associationShouldBeDropped_

bool edmtest::ThinningTestAnalyzer::associationShouldBeDropped_
private

Definition at line 67 of file ThinningTestAnalyzer.cc.

Referenced by analyze(), getAssociation(), and ThinningTestAnalyzer().

◆ associationToken_

edm::EDGetTokenT<edm::ThinnedAssociation> edmtest::ThinningTestAnalyzer::associationToken_
private

Definition at line 57 of file ThinningTestAnalyzer.cc.

Referenced by getAssociation(), and ThinningTestAnalyzer().

◆ expectedIndexesIntoParent_

std::vector<unsigned int> edmtest::ThinningTestAnalyzer::expectedIndexesIntoParent_
private

Definition at line 66 of file ThinningTestAnalyzer.cc.

Referenced by getAssociation(), and ThinningTestAnalyzer().

◆ expectedParentContent_

std::vector<int> edmtest::ThinningTestAnalyzer::expectedParentContent_
private

Definition at line 61 of file ThinningTestAnalyzer.cc.

Referenced by getParent(), and ThinningTestAnalyzer().

◆ expectedThinnedContent_

std::vector<int> edmtest::ThinningTestAnalyzer::expectedThinnedContent_
private

Definition at line 65 of file ThinningTestAnalyzer.cc.

Referenced by getThinned(), and ThinningTestAnalyzer().

◆ expectedValues_

std::vector<int> edmtest::ThinningTestAnalyzer::expectedValues_
private

◆ parentSlimmedValueFactor_

int edmtest::ThinningTestAnalyzer::parentSlimmedValueFactor_
private

Definition at line 69 of file ThinningTestAnalyzer.cc.

Referenced by getParent(), and ThinningTestAnalyzer().

◆ parentToken_

edm::EDGetTokenT<ThingCollection> edmtest::ThinningTestAnalyzer::parentToken_
private

Definition at line 55 of file ThinningTestAnalyzer.cc.

Referenced by getParent(), and ThinningTestAnalyzer().

◆ parentWasDropped_

bool edmtest::ThinningTestAnalyzer::parentWasDropped_
private

Definition at line 60 of file ThinningTestAnalyzer.cc.

Referenced by analyze(), getParent(), and ThinningTestAnalyzer().

◆ refSlimmedValueFactor_

int edmtest::ThinningTestAnalyzer::refSlimmedValueFactor_
private

Definition at line 71 of file ThinningTestAnalyzer.cc.

Referenced by testRefToParent(), testVectors(), and ThinningTestAnalyzer().

◆ refToParentIsAvailable_

bool edmtest::ThinningTestAnalyzer::refToParentIsAvailable_
private

Definition at line 64 of file ThinningTestAnalyzer.cc.

Referenced by testRefToParent(), testVectors(), and ThinningTestAnalyzer().

◆ thinnedIsAlias_

bool edmtest::ThinningTestAnalyzer::thinnedIsAlias_
private

Definition at line 63 of file ThinningTestAnalyzer.cc.

Referenced by ThinningTestAnalyzer().

◆ thinnedSlimmedValueFactor_

int edmtest::ThinningTestAnalyzer::thinnedSlimmedValueFactor_
private

◆ thinnedToken_

edm::EDGetTokenT<ThingCollection> edmtest::ThinningTestAnalyzer::thinnedToken_
private

Definition at line 56 of file ThinningTestAnalyzer.cc.

Referenced by getThinned(), and ThinningTestAnalyzer().

◆ thinnedWasDropped_

bool edmtest::ThinningTestAnalyzer::thinnedWasDropped_
private

Definition at line 62 of file ThinningTestAnalyzer.cc.

Referenced by analyze(), getThinned(), testVectors(), and ThinningTestAnalyzer().

◆ trackToken_

edm::EDGetTokenT<TrackOfThingsCollection> edmtest::ThinningTestAnalyzer::trackToken_
private

Definition at line 58 of file ThinningTestAnalyzer.cc.

Referenced by getTrackCollection(), and ThinningTestAnalyzer().