CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edmtest::SlimmingThingSelector Class Reference

Public Member Functions

std::optional< edmtest::Thing > choose (unsigned int iIndex, edmtest::Thing const &iItem) const
 
void preChoose (edm::Handle< edmtest::ThingCollection > tc, edm::Event const &event, edm::EventSetup const &es)
 
void reset ()
 
 SlimmingThingSelector (edm::ParameterSet const &pset, edm::ConsumesCollector &&cc)
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Attributes

unsigned int const expectedCollectionSize_
 
std::set< unsigned int > keysToSave_
 
unsigned int const offsetToThinnedKey_
 
unsigned int const offsetToValue_
 
edm::ESGetToken< edmtest::WhatsIt, GadgetRcd > const setupToken_
 
int const slimmedValueFactor_
 
edm::EDGetTokenT< TrackOfThingsCollection > const trackToken_
 

Detailed Description

Definition at line 24 of file SlimmingThingProducer.cc.

Constructor & Destructor Documentation

◆ SlimmingThingSelector()

edmtest::SlimmingThingSelector::SlimmingThingSelector ( edm::ParameterSet const &  pset,
edm::ConsumesCollector &&  cc 
)

Definition at line 46 of file SlimmingThingProducer.cc.

47  : trackToken_(cc.consumes<TrackOfThingsCollection>(pset.getParameter<edm::InputTag>("trackTag"))),
48  setupToken_(cc.esConsumes<edmtest::WhatsIt, GadgetRcd>()),
49  offsetToThinnedKey_(pset.getParameter<unsigned int>("offsetToThinnedKey")),
50  offsetToValue_(pset.getParameter<unsigned int>("offsetToValue")),
51  expectedCollectionSize_(pset.getParameter<unsigned int>("expectedCollectionSize")),
52  slimmedValueFactor_(pset.getParameter<int>("slimmedValueFactor")) {}
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< TrackOfThingsCollection > const trackToken_
edm::ESGetToken< edmtest::WhatsIt, GadgetRcd > const setupToken_

Member Function Documentation

◆ choose()

std::optional< edmtest::Thing > edmtest::SlimmingThingSelector::choose ( unsigned int  iIndex,
edmtest::Thing const &  iItem 
) const

Definition at line 83 of file SlimmingThingProducer.cc.

References filterCSVwithJSON::copy, Exception, keysToSave_, offsetToValue_, and slimmedValueFactor_.

83  {
84  // Just checking to see the element in the container got passed in OK. Not really using it.
85  // Just using %10 because it coincidentally works with the arbitrary numbers I picked, no meaning really.
86  auto const expected = slimmedValueFactor_ * (iIndex + offsetToValue_);
87  if (static_cast<unsigned>(iItem.a % 10) != static_cast<unsigned>(expected % 10)) {
88  throw cms::Exception("TestFailure") << "SlimmingThingSelector::choose, item content = " << iItem.a
89  << " index = " << iIndex << " expected " << expected;
90  }
91 
92  // Save the Things referenced by the Tracks
93  if (keysToSave_.find(iIndex) == keysToSave_.end())
94  return {};
95  auto copy = iItem;
96  copy.a *= 10;
97  return copy;
98  }
std::set< unsigned int > keysToSave_

◆ fillPSetDescription()

void edmtest::SlimmingThingSelector::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 54 of file SlimmingThingProducer.cc.

References submitPVResolutionJobs::desc.

54  {
55  desc.add<edm::InputTag>("trackTag");
56  desc.add<unsigned int>("offsetToThinnedKey");
57  desc.add<unsigned int>("offsetToValue", 0);
58  desc.add<unsigned int>("expectedCollectionSize");
59  desc.add<int>("slimmedValueFactor", 1);
60  }

◆ preChoose()

void edmtest::SlimmingThingSelector::preChoose ( edm::Handle< edmtest::ThingCollection >  tc,
edm::Event const &  event,
edm::EventSetup const &  es 
)

Definition at line 62 of file SlimmingThingProducer.cc.

References Exception, expectedCollectionSize_, edm::EventSetup::getHandle(), edm::ESHandleBase::isValid(), keysToSave_, offsetToThinnedKey_, setupToken_, HLT_2023v12_cff::track, and trackToken_.

64  {
65  for (auto const& track : event.get(trackToken_)) {
66  keysToSave_.insert(track.ref1.key() - offsetToThinnedKey_);
67  keysToSave_.insert(track.ref2.key() - offsetToThinnedKey_);
68  keysToSave_.insert(track.ptr1.key() - offsetToThinnedKey_);
69  keysToSave_.insert(track.ptr2.key() - offsetToThinnedKey_);
70  }
71 
72  // Just checking to see if the collection got passed in. Not really using it for anything.
73  if (tc->size() != expectedCollectionSize_) {
74  throw cms::Exception("TestFailure") << "SlimmingThingSelector::preChoose, collection size = " << tc->size()
75  << " expected size = " << expectedCollectionSize_;
76  }
77 
78  // Just checking to see the EventSetup works from here. Not really using it for anything.
79  edm::ESHandle<edmtest::WhatsIt> pSetup = es.getHandle(setupToken_);
80  pSetup.isValid();
81  }
std::set< unsigned int > keysToSave_
edm::EDGetTokenT< TrackOfThingsCollection > const trackToken_
edm::ESGetToken< edmtest::WhatsIt, GadgetRcd > const setupToken_
bool isValid() const
Definition: ESHandle.h:44
Definition: event.py:1

◆ reset()

void edmtest::SlimmingThingSelector::reset ( void  )
inline

Definition at line 34 of file SlimmingThingProducer.cc.

References keysToSave_.

34 { keysToSave_.clear(); }
std::set< unsigned int > keysToSave_

Member Data Documentation

◆ expectedCollectionSize_

unsigned int const edmtest::SlimmingThingSelector::expectedCollectionSize_
private

Definition at line 42 of file SlimmingThingProducer.cc.

Referenced by preChoose().

◆ keysToSave_

std::set<unsigned int> edmtest::SlimmingThingSelector::keysToSave_
private

Definition at line 39 of file SlimmingThingProducer.cc.

Referenced by choose(), preChoose(), and reset().

◆ offsetToThinnedKey_

unsigned int const edmtest::SlimmingThingSelector::offsetToThinnedKey_
private

Definition at line 40 of file SlimmingThingProducer.cc.

Referenced by preChoose().

◆ offsetToValue_

unsigned int const edmtest::SlimmingThingSelector::offsetToValue_
private

Definition at line 41 of file SlimmingThingProducer.cc.

Referenced by choose().

◆ setupToken_

edm::ESGetToken<edmtest::WhatsIt, GadgetRcd> const edmtest::SlimmingThingSelector::setupToken_
private

Definition at line 38 of file SlimmingThingProducer.cc.

Referenced by preChoose().

◆ slimmedValueFactor_

int const edmtest::SlimmingThingSelector::slimmedValueFactor_
private

Definition at line 43 of file SlimmingThingProducer.cc.

Referenced by choose().

◆ trackToken_

edm::EDGetTokenT<TrackOfThingsCollection> const edmtest::SlimmingThingSelector::trackToken_
private

Definition at line 37 of file SlimmingThingProducer.cc.

Referenced by preChoose().