CMS 3D CMS Logo

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

Public Member Functions

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

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Attributes

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

Detailed Description

Definition at line 29 of file ThinningThingProducer.cc.

Constructor & Destructor Documentation

◆ ThinningThingSelector()

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

Definition at line 52 of file ThinningThingProducer.cc.

References gpuPixelDoublets::cc, expectedCollectionSize_, offsetToThinnedKey_, offsetToValue_, muonDTDigis_cfi::pset, slimmedValueFactor_, trackToken_, and whatsItToken_.

52  {
53  trackToken_ = cc.consumes<TrackOfThingsCollection>(pset.getParameter<edm::InputTag>("trackTag"));
54  whatsItToken_ = cc.esConsumes();
55  offsetToThinnedKey_ = pset.getParameter<unsigned int>("offsetToThinnedKey");
56  offsetToValue_ = pset.getParameter<unsigned int>("offsetToValue");
57  expectedCollectionSize_ = pset.getParameter<unsigned int>("expectedCollectionSize");
58  slimmedValueFactor_ = pset.getParameter<int>("slimmedValueFactor");
59  }
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< TrackOfThingsCollection > trackToken_
edm::ESGetToken< edmtest::WhatsIt, GadgetRcd > whatsItToken_

Member Function Documentation

◆ choose()

bool edmtest::ThinningThingSelector::choose ( unsigned int  iIndex,
edmtest::Thing const &  iItem 
)

Definition at line 90 of file ThinningThingProducer.cc.

References Exception, keysToSave_, offsetToValue_, and slimmedValueFactor_.

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

◆ fillPSetDescription()

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

Definition at line 61 of file ThinningThingProducer.cc.

References submitPVResolutionJobs::desc.

61  {
62  desc.add<edm::InputTag>("trackTag");
63  desc.add<unsigned int>("offsetToThinnedKey");
64  desc.add<unsigned int>("offsetToValue", 0);
65  desc.add<unsigned int>("expectedCollectionSize");
66  desc.add<int>("slimmedValueFactor", 1);
67  }

◆ preChoose()

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

Definition at line 69 of file ThinningThingProducer.cc.

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

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

◆ reset()

void edmtest::ThinningThingSelector::reset ( void  )
inline

Definition at line 39 of file ThinningThingProducer.cc.

References keysToSave_.

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

Member Data Documentation

◆ expectedCollectionSize_

unsigned int edmtest::ThinningThingSelector::expectedCollectionSize_
private

Definition at line 48 of file ThinningThingProducer.cc.

Referenced by preChoose(), and ThinningThingSelector().

◆ keysToSave_

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

Definition at line 45 of file ThinningThingProducer.cc.

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

◆ offsetToThinnedKey_

unsigned int edmtest::ThinningThingSelector::offsetToThinnedKey_
private

Definition at line 46 of file ThinningThingProducer.cc.

Referenced by preChoose(), and ThinningThingSelector().

◆ offsetToValue_

unsigned int edmtest::ThinningThingSelector::offsetToValue_
private

Definition at line 47 of file ThinningThingProducer.cc.

Referenced by choose(), and ThinningThingSelector().

◆ slimmedValueFactor_

int edmtest::ThinningThingSelector::slimmedValueFactor_
private

Definition at line 49 of file ThinningThingProducer.cc.

Referenced by choose(), and ThinningThingSelector().

◆ trackToken_

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

Definition at line 42 of file ThinningThingProducer.cc.

Referenced by preChoose(), and ThinningThingSelector().

◆ whatsItToken_

edm::ESGetToken<edmtest::WhatsIt, GadgetRcd> edmtest::ThinningThingSelector::whatsItToken_
private

Definition at line 43 of file ThinningThingProducer.cc.

Referenced by preChoose(), and ThinningThingSelector().