CMS 3D CMS Logo

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

Public Member Functions

void analyze (edm::StreamID streamID, edm::Event const &e, edm::EventSetup const &c) const override
 
 ThinnedRefFromTestAnalyzer (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 Attributes

const edm::EDGetTokenT< ThingCollection > parentToken_
 
const edm::EDGetTokenT< ThingCollection > thinnedToken_
 
const edm::EDGetTokenT< TrackOfThingsCollection > trackToken_
 
const edm::EDGetTokenT< ThingCollection > unrelatedToken_
 

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 38 of file ThinnedRefFromTestAnalyzer.cc.

Constructor & Destructor Documentation

◆ ThinnedRefFromTestAnalyzer()

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

Definition at line 53 of file ThinnedRefFromTestAnalyzer.cc.

References muonDTDigis_cfi::pset.

54  : parentToken_{consumes<ThingCollection>(pset.getParameter<edm::InputTag>("parentTag"))},
55  thinnedToken_{consumes<ThingCollection>(pset.getParameter<edm::InputTag>("thinnedTag"))},
56  unrelatedToken_{consumes<ThingCollection>(pset.getParameter<edm::InputTag>("unrelatedTag"))},
57  trackToken_{consumes<TrackOfThingsCollection>(pset.getParameter<edm::InputTag>("trackTag"))} {}
const edm::EDGetTokenT< ThingCollection > thinnedToken_
const edm::EDGetTokenT< ThingCollection > unrelatedToken_
const edm::EDGetTokenT< ThingCollection > parentToken_
const edm::EDGetTokenT< TrackOfThingsCollection > trackToken_

Member Function Documentation

◆ analyze()

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

Implements edm::global::EDAnalyzerBase.

Definition at line 68 of file ThinnedRefFromTestAnalyzer.cc.

References Exception, edm::errors::InvalidReference, parentToken_, edm::Ref< C, T, F >::productGetter(), edm::thinnedRefFrom(), thinnedToken_, HLT_2024v13_cff::track, JetHT_cfg::trackCollection, trackToken_, edm::tryThinnedRefFrom(), and unrelatedToken_.

70  {
71  auto parentHandle = event.getHandle(parentToken_);
72  auto thinnedHandle = event.getHandle(thinnedToken_);
73  auto unrelatedHandle = event.getHandle(unrelatedToken_);
74  auto const& trackCollection = event.get(trackToken_);
75 
76  edm::RefProd parentRefProd{parentHandle};
77  edm::RefProd thinnedRefProd{thinnedHandle};
78  edm::RefProd unrelatedRefProd{unrelatedHandle};
79 
80  requireExceptionCategory(edm::errors::InvalidReference, [&]() {
81  auto invalidParentRef = edm::thinnedRefFrom(edm::Ref(unrelatedHandle, 0), thinnedRefProd, event.productGetter());
82  });
83  if (auto invalidParentRef =
84  edm::tryThinnedRefFrom(edm::Ref(unrelatedHandle, 0), thinnedRefProd, event.productGetter());
85  invalidParentRef.isNonnull()) {
86  throw cms::Exception("TestFailure") << "Expected to get Null Ref when passing in a Ref to unrelated parent "
87  "collection, got a non-null Ref instead";
88  }
89 
90  for (auto const& track : trackCollection) {
91  auto parentRef1 = edm::thinnedRefFrom(track.ref1, parentRefProd, event.productGetter());
92  if (parentRef1.id() != track.ref1.id()) {
93  throw cms::Exception("TestFailure")
94  << "Ref1-to-parent ProductID " << parentRef1.id() << " expected " << track.ref1.id();
95  }
96  if (parentRef1.key() != track.ref1.key()) {
97  throw cms::Exception("TestFailure")
98  << "Ref1-to-parent key " << parentRef1.key() << " expected " << track.ref1.key();
99  }
100 
101  auto thinnedRef1 = edm::thinnedRefFrom(track.ref1, thinnedRefProd, event.productGetter());
102  if (thinnedRef1.id() != thinnedRefProd.id()) {
103  throw cms::Exception("TestFailure")
104  << "Ref1-to-thinned ProductID " << thinnedRef1.id() << " expected " << thinnedRefProd.id();
105  }
106 
107  requireExceptionCategory(edm::errors::InvalidReference, [&]() {
108  auto invalidThinnedRef = edm::thinnedRefFrom(track.ref1, unrelatedRefProd, event.productGetter());
109  });
110  if (auto invalidThinnedRef = edm::tryThinnedRefFrom(track.ref1, unrelatedRefProd, event.productGetter());
111  invalidThinnedRef.isNonnull()) {
112  throw cms::Exception("TestFailure") << "Expected to get Null Ref when passing in a RefProd to unrelated "
113  "thinned collection, got a non-null Ref instead";
114  }
115  }
116  }
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: Ref.h:247
const edm::EDGetTokenT< ThingCollection > thinnedToken_
const edm::EDGetTokenT< ThingCollection > unrelatedToken_
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
Ref< C, T, F > tryThinnedRefFrom(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:157
const edm::EDGetTokenT< ThingCollection > parentToken_
const edm::EDGetTokenT< TrackOfThingsCollection > trackToken_
Definition: event.py:1

◆ fillDescriptions()

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

Definition at line 59 of file ThinnedRefFromTestAnalyzer.cc.

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

59  {
61  desc.add<edm::InputTag>("parentTag");
62  desc.add<edm::InputTag>("thinnedTag");
63  desc.add<edm::InputTag>("unrelatedTag");
64  desc.add<edm::InputTag>("trackTag");
65  descriptions.addDefault(desc);
66  }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ parentToken_

const edm::EDGetTokenT<ThingCollection> edmtest::ThinnedRefFromTestAnalyzer::parentToken_
private

Definition at line 47 of file ThinnedRefFromTestAnalyzer.cc.

Referenced by analyze().

◆ thinnedToken_

const edm::EDGetTokenT<ThingCollection> edmtest::ThinnedRefFromTestAnalyzer::thinnedToken_
private

Definition at line 48 of file ThinnedRefFromTestAnalyzer.cc.

Referenced by analyze().

◆ trackToken_

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

Definition at line 50 of file ThinnedRefFromTestAnalyzer.cc.

Referenced by analyze().

◆ unrelatedToken_

const edm::EDGetTokenT<ThingCollection> edmtest::ThinnedRefFromTestAnalyzer::unrelatedToken_
private

Definition at line 49 of file ThinnedRefFromTestAnalyzer.cc.

Referenced by analyze().