CMS 3D CMS Logo

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

Public Member Functions

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

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Attributes

unsigned int const expectedDetSets_
 
unsigned int const expectedDetSetSize_
 
std::set< unsigned int > keysToSave_
 
unsigned int const offsetToThinnedKey_
 
unsigned int const offsetToValue_
 
int const slimmedValueFactor_
 
edm::EDGetTokenT< TrackOfDSVThingsCollection > const trackToken_
 

Detailed Description

Definition at line 21 of file SlimmingDSVThingProducer.cc.

Constructor & Destructor Documentation

◆ SlimmingDSVThingSelector()

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

Definition at line 43 of file SlimmingDSVThingProducer.cc.

44  : trackToken_(cc.consumes<TrackOfDSVThingsCollection>(pset.getParameter<edm::InputTag>("trackTag"))),
45  offsetToThinnedKey_(pset.getParameter<unsigned int>("offsetToThinnedKey")),
46  offsetToValue_(pset.getParameter<unsigned int>("offsetToValue")),
47  expectedDetSets_(pset.getParameter<unsigned int>("expectedDetSets")),
48  expectedDetSetSize_(pset.getParameter<unsigned int>("expectedDetSetSize")),
49  slimmedValueFactor_(pset.getParameter<int>("slimmedValueFactor")) {}
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< TrackOfDSVThingsCollection > const trackToken_

Member Function Documentation

◆ choose()

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

Definition at line 82 of file SlimmingDSVThingProducer.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") << "SlimmingDSVThingSelector::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 std::nullopt;
95  auto copy = iItem;
96  copy.a *= 10;
97  return copy;
98  }

◆ fillPSetDescription()

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

Definition at line 51 of file SlimmingDSVThingProducer.cc.

References submitPVResolutionJobs::desc.

51  {
52  desc.add<edm::InputTag>("trackTag");
53  desc.add<unsigned int>("offsetToThinnedKey");
54  desc.add<unsigned int>("offsetToValue", 0);
55  desc.add<unsigned int>("expectedDetSets");
56  desc.add<unsigned int>("expectedDetSetSize");
57  desc.add<int>("slimmedValueFactor", 1);
58  }

◆ preChoose()

void edmtest::SlimmingDSVThingSelector::preChoose ( edm::Handle< edmNew::DetSetVector< Thing >>  tc,
edm::Event const &  event,
edm::EventSetup const &  es 
)

Definition at line 60 of file SlimmingDSVThingProducer.cc.

References Exception, expectedDetSets_, expectedDetSetSize_, keysToSave_, offsetToThinnedKey_, HLT_2024v10_cff::track, and trackToken_.

62  {
63  for (auto const& track : event.get(trackToken_)) {
64  keysToSave_.insert(track.ref1.key() - offsetToThinnedKey_);
65  keysToSave_.insert(track.ref2.key() - offsetToThinnedKey_);
66  }
67 
68  // Just checking to see if the collection got passed in. Not really using it for anything.
69  if (tc->size() != expectedDetSets_) {
70  throw cms::Exception("TestFailure") << "SlimmingDSVThingSelector::preChoose, number of DetSets = " << tc->size()
71  << " expected = " << expectedDetSets_;
72  }
73  for (auto const& ds : *tc) {
74  if (ds.size() != expectedDetSetSize_) {
75  throw cms::Exception("TestFailure")
76  << "SlimmingDSVThingSelector::preChoose, number of elements in DetSet with id " << ds.id() << " = "
77  << ds.size() << " expected = " << expectedDetSetSize_;
78  }
79  }
80  }
edm::EDGetTokenT< TrackOfDSVThingsCollection > const trackToken_
Definition: event.py:1

◆ reset()

void edmtest::SlimmingDSVThingSelector::reset ( void  )
inline

Definition at line 31 of file SlimmingDSVThingProducer.cc.

References keysToSave_.

31 { keysToSave_.clear(); }

Member Data Documentation

◆ expectedDetSets_

unsigned int const edmtest::SlimmingDSVThingSelector::expectedDetSets_
private

Definition at line 38 of file SlimmingDSVThingProducer.cc.

Referenced by preChoose().

◆ expectedDetSetSize_

unsigned int const edmtest::SlimmingDSVThingSelector::expectedDetSetSize_
private

Definition at line 39 of file SlimmingDSVThingProducer.cc.

Referenced by preChoose().

◆ keysToSave_

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

Definition at line 35 of file SlimmingDSVThingProducer.cc.

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

◆ offsetToThinnedKey_

unsigned int const edmtest::SlimmingDSVThingSelector::offsetToThinnedKey_
private

Definition at line 36 of file SlimmingDSVThingProducer.cc.

Referenced by preChoose().

◆ offsetToValue_

unsigned int const edmtest::SlimmingDSVThingSelector::offsetToValue_
private

Definition at line 37 of file SlimmingDSVThingProducer.cc.

Referenced by choose().

◆ slimmedValueFactor_

int const edmtest::SlimmingDSVThingSelector::slimmedValueFactor_
private

Definition at line 40 of file SlimmingDSVThingProducer.cc.

Referenced by choose().

◆ trackToken_

edm::EDGetTokenT<TrackOfDSVThingsCollection> const edmtest::SlimmingDSVThingSelector::trackToken_
private

Definition at line 34 of file SlimmingDSVThingProducer.cc.

Referenced by preChoose().