CMS 3D CMS Logo

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

Public Member Functions

void analyze (edm::StreamID, edm::Event const &iEvent, edm::EventSetup const &iSetup) const override
 
 SwitchProducerProvenanceAnalyzer (edm::ParameterSet const &iConfig)
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void testProduct (edm::Handle< IntProduct > const &prod, int mode, edm::Event const &iEvent) const
 

Private Attributes

bool const aliasMode_
 
edm::EDGetTokenT< IntProduct > inputToken1_
 
edm::EDGetTokenT< IntProduct > inputToken2_
 
std::string producerPrefix_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 18 of file SwitchProducerProvenanceAnalyzer.cc.

Constructor & Destructor Documentation

◆ SwitchProducerProvenanceAnalyzer()

edmtest::SwitchProducerProvenanceAnalyzer::SwitchProducerProvenanceAnalyzer ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 32 of file SwitchProducerProvenanceAnalyzer.cc.

33  : inputToken1_(consumes(iConfig.getParameter<edm::InputTag>("src1"))),
34  inputToken2_(consumes(iConfig.getParameter<edm::InputTag>("src2"))),
35  producerPrefix_(iConfig.getParameter<std::string>("producerPrefix")),
36  aliasMode_(iConfig.getParameter<bool>("aliasMode")) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)

Member Function Documentation

◆ analyze()

void edmtest::SwitchProducerProvenanceAnalyzer::analyze ( edm::StreamID  ,
edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
) const
overridevirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 38 of file SwitchProducerProvenanceAnalyzer.cc.

References h, iEvent, inputToken1_, inputToken2_, and testProduct().

40  {
42  iEvent.getByToken(inputToken1_, h);
43  testProduct(h, iEvent.id().luminosityBlock(), iEvent);
44 
45  iEvent.getByToken(inputToken2_, h);
46  testProduct(h, iEvent.id().luminosityBlock(), iEvent);
47  }
int iEvent
Definition: GenABIO.cc:224
void testProduct(edm::Handle< IntProduct > const &prod, int mode, edm::Event const &iEvent) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ testProduct()

void edmtest::SwitchProducerProvenanceAnalyzer::testProduct ( edm::Handle< IntProduct > const &  prod,
int  mode,
edm::Event const &  iEvent 
) const
private

Definition at line 49 of file SwitchProducerProvenanceAnalyzer.cc.

References aliasMode_, cms::cuda::assert(), edm::Provenance::branchID(), edm::pset::Registry::getMapped(), edm::ParameterSet::getParameterSet(), iEvent, edm::pset::Registry::instance(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, HerwigMaxPtPartonFilter_cfi::moduleLabel, edm::Provenance::moduleLabel(), class-composition::parent, edm::ProductProvenance::parentage(), edm::Provenance::processName(), dumpMFGeometry_cfg::prod, producerPrefix_, edm::Provenance::productProvenance(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::impl::to_string().

Referenced by analyze().

51  {
52  assert(prod->value == mode);
53 
54  edm::Provenance const* provenance = prod.provenance();
55  assert(provenance != nullptr);
56  auto const* productProvenance = provenance->productProvenance();
57  assert(productProvenance != nullptr);
58  auto const& processHistory = iEvent.processHistory();
59 
60  edm::pset::Registry const* psetRegistry = edm::pset::Registry::instance();
61  assert(psetRegistry != nullptr);
62 
63  auto const& moduleLabel = provenance->moduleLabel();
64 
65  // Switch output should not look like an alias
66  assert(productProvenance->branchID() == provenance->branchID());
67 
68  // Check that the provenance of the Switch itself is recorded correctly
69  for (edm::ProcessConfiguration const& pc : processHistory) {
70  if (pc.processName() == provenance->processName()) {
71  edm::ParameterSetID const& psetID = pc.parameterSetID();
72  edm::ParameterSet const* processPSet = psetRegistry->getMapped(psetID);
73  assert(processPSet);
74  auto const& modPSet = processPSet->getParameterSet(moduleLabel);
75  assert(modPSet.getParameter<std::string>("@module_edm_type") == "EDProducer");
76  assert(modPSet.getParameter<std::string>("@module_type") == "SwitchProducer");
77  assert(modPSet.getParameter<std::string>("@module_label") == moduleLabel);
78  auto const& allCases = modPSet.getParameter<std::vector<std::string>>("@all_cases");
79  assert(allCases.size() == 2);
80  assert(allCases[0] == moduleLabel + "@test1");
81  assert(allCases[1] == moduleLabel + "@test2");
82  assert(modPSet.exists("@chosen_case") == false);
83  }
84  }
85 
86  // Check the parentage (foo -> foo@case -> possible input)
87  auto const& parent = productProvenance->parentage();
88  // Here is where Switch differs from a normal EDProducer: each Switch output branch has exactly one parent
89  assert(parent.parents().size() == 1);
90  auto const& parentProvenance = iEvent.getProvenance(parent.parents()[0]);
91  edm::ProductProvenance const* parentProductProvenance = nullptr;
92  if (not(aliasMode_ and mode == 2)) {
93  // If parent is EDAlias, it is skipped in the provenance, so in
94  // that case the normal grandparent can be found on the place of
95  // the parent.
96 
97  assert(parentProvenance.branchDescription().moduleLabel() == moduleLabel + "@test" + std::to_string(mode));
98 
99  // Check grandparent as well
100  parentProductProvenance = parentProvenance.productProvenance();
101  assert(parentProductProvenance != nullptr);
102  }
103  auto const& grandParent = parentProductProvenance ? parentProductProvenance->parentage() : parent;
104  //auto const& grandParent = parentProductProvenance->parentage();
105  assert(grandParent.parents().size() == 1); // behaviour of the AddIntsProducer
106  auto const& grandParentProvenance = iEvent.getProvenance(grandParent.parents()[0]);
107  int postfix = mode;
108  if (aliasMode_ and mode == 2) {
109  postfix = 3;
110  }
111  assert(grandParentProvenance.branchDescription().moduleLabel() == producerPrefix_ + std::to_string(postfix));
112  }
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
ProductProvenance const * productProvenance() const
Definition: Provenance.cc:24
ParameterSet const & getParameterSet(std::string const &) const
std::string to_string(const V &value)
Definition: OMSAccess.h:71
std::string const & processName() const
Definition: Provenance.h:57
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
BranchID const & branchID() const
Definition: Provenance.h:52
std::string const & moduleLabel() const
Definition: Provenance.h:55
static Registry * instance()
Definition: Registry.cc:12

Member Data Documentation

◆ aliasMode_

bool const edmtest::SwitchProducerProvenanceAnalyzer::aliasMode_
private

Definition at line 29 of file SwitchProducerProvenanceAnalyzer.cc.

Referenced by testProduct().

◆ inputToken1_

edm::EDGetTokenT<IntProduct> edmtest::SwitchProducerProvenanceAnalyzer::inputToken1_
private

Definition at line 26 of file SwitchProducerProvenanceAnalyzer.cc.

Referenced by analyze().

◆ inputToken2_

edm::EDGetTokenT<IntProduct> edmtest::SwitchProducerProvenanceAnalyzer::inputToken2_
private

Definition at line 27 of file SwitchProducerProvenanceAnalyzer.cc.

Referenced by analyze().

◆ producerPrefix_

std::string edmtest::SwitchProducerProvenanceAnalyzer::producerPrefix_
private

Definition at line 28 of file SwitchProducerProvenanceAnalyzer.cc.

Referenced by testProduct().