CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ConfigurableAPVCyclePhaseProducer Class Reference

#include <DPGAnalysis/SiStripTools/plugins/ConfigurableAPVCyclePhaseProducer.cc>

Inheritance diagram for ConfigurableAPVCyclePhaseProducer:
edm::global::EDProducer< edm::RunCache< APVCyclePhaseCollection > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ConfigurableAPVCyclePhaseProducer (const edm::ParameterSet &)
 
 ~ConfigurableAPVCyclePhaseProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer< edm::RunCache< APVCyclePhaseCollection > >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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)
 

Private Member Functions

std::shared_ptr< APVCyclePhaseCollectionglobalBeginRun (const edm::Run &, const edm::EventSetup &) const override
 
void globalEndRun (edm::Run const &, edm::EventSetup const &) const override
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const std::vector< std::string > _defpartnames
 
const std::vector< int > _defphases
 
std::map< int, std::vector< std::string > > _runpartnames
 
std::map< int, std::vector< int > > _runphases
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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

Description: EDproducer for APVCyclePhaseCollection which uses the configuration file to assign a phase to the run

Implementation: <Notes on="" implementation>="">

Definition at line 44 of file ConfigurableAPVCyclePhaseProducer.cc.

Constructor & Destructor Documentation

◆ ConfigurableAPVCyclePhaseProducer()

ConfigurableAPVCyclePhaseProducer::ConfigurableAPVCyclePhaseProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file ConfigurableAPVCyclePhaseProducer.cc.

References _defpartnames, _defphases, _runpartnames, _runphases, Exception, edm::ParameterSet::getParameter(), and findQualityFiles::size.

75  : _defpartnames(iConfig.getParameter<std::vector<std::string>>("defaultPartitionNames")),
76  _defphases(iConfig.getParameter<std::vector<int>>("defaultPhases")) {
77  produces<APVCyclePhaseCollection, edm::InEvent>();
78 
79  //now do what ever other initialization is needed
80 
81  if (_defphases.size() < _defpartnames.size()) {
82  // throw exception
83  throw cms::Exception("InvalidAPVCyclePhases")
84  << " Inconsistent default phases/partitions vector sizes: " << _defphases.size() << " " << _defpartnames.size();
85  }
86 
87  std::vector<edm::ParameterSet> vps(iConfig.getParameter<std::vector<edm::ParameterSet>>("runPhases"));
88 
89  for (std::vector<edm::ParameterSet>::const_iterator ps = vps.begin(); ps != vps.end(); ps++) {
90  _runphases[ps->getParameter<int>("runNumber")] = ps->getUntrackedParameter<std::vector<int>>("phases", _defphases);
91  _runpartnames[ps->getParameter<int>("runNumber")] =
92  ps->getUntrackedParameter<std::vector<std::string>>("partitions", _defpartnames);
93 
94  if (_runphases[ps->getParameter<int>("runNumber")].size() <
95  _runpartnames[ps->getParameter<int>("runNumber")].size()) {
96  // throw exception
97  throw cms::Exception("InvalidAPVCyclePhases")
98  << " Inconsistent run " << ps->getParameter<int>("runNumber")
99  << " phases/partitions vector sizes: " << _runphases[ps->getParameter<int>("runNumber")].size() << " "
100  << _runpartnames[ps->getParameter<int>("runNumber")].size();
101  }
102  }
103 }
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< int, std::vector< int > > _runphases
std::map< int, std::vector< std::string > > _runpartnames
const std::vector< std::string > _defpartnames

◆ ~ConfigurableAPVCyclePhaseProducer()

ConfigurableAPVCyclePhaseProducer::~ConfigurableAPVCyclePhaseProducer ( )
override

Definition at line 105 of file ConfigurableAPVCyclePhaseProducer.cc.

105  {
106  // do anything here that needs to be done at desctruction time
107  // (e.g. close files, deallocate resources etc.)
108 }

Member Function Documentation

◆ globalBeginRun()

std::shared_ptr< APVCyclePhaseCollection > ConfigurableAPVCyclePhaseProducer::globalBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
) const
overrideprivate

Definition at line 115 of file ConfigurableAPVCyclePhaseProducer.cc.

References _defpartnames, _defphases, _runpartnames, _runphases, Exception, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, configurableapvcyclephaseproducer_CRAFT08_cfi::phases, and edm::RunBase::run().

116  {
117  using namespace edm;
118 
119  auto currapvphases = std::make_shared<APVCyclePhaseCollection>();
120 
121  // fill phase map
122 
123  const std::map<int, std::vector<std::string>>& _crunpartnames = _runpartnames;
124  const std::map<int, std::vector<int>>& _crunphases = _runphases;
125 
126  std::map<int, std::vector<int>>::const_iterator trphases = _crunphases.find(iRun.run());
127  std::map<int, std::vector<std::string>>::const_iterator trpartnames = _crunpartnames.find(iRun.run());
128 
129  std::vector<int> phases = _defphases;
130  std::vector<std::string> partnames = _defpartnames;
131 
132  if (trphases != _crunphases.end()) {
133  phases = trphases->second;
134  }
135  if (trpartnames != _crunpartnames.end()) {
136  partnames = trpartnames->second;
137  }
138 
139  if (phases.size() < partnames.size()) {
140  // throw exception
141  throw cms::Exception("InvalidAPVCyclePhases")
142  << " Inconsistent phases/partitions vector sizes: " << phases.size() << " " << partnames.size();
143  }
144 
145  for (unsigned int ipart = 0; ipart < partnames.size(); ++ipart) {
146  if (phases[ipart] >= 0) {
147  currapvphases->get()[partnames[ipart]] = phases[ipart];
148  }
149  }
150 
151  for (std::map<std::string, int>::const_iterator it = currapvphases->get().begin(); it != currapvphases->get().end();
152  it++) {
153  edm::LogInfo("APVCyclePhaseProducerDebug") << "partition " << it->first << " phase " << it->second;
154  }
155  return currapvphases;
156 }
std::map< int, std::vector< int > > _runphases
std::map< int, std::vector< std::string > > _runpartnames
RunNumber_t run() const
Definition: RunBase.h:40
const std::vector< std::string > _defpartnames
Log< level::Info, false > LogInfo
HLT enums.

◆ globalEndRun()

void ConfigurableAPVCyclePhaseProducer::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverrideprivate

Definition at line 52 of file ConfigurableAPVCyclePhaseProducer.cc.

52 {}

◆ produce()

void ConfigurableAPVCyclePhaseProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 158 of file ConfigurableAPVCyclePhaseProducer.cc.

References iEvent, and eostools::move().

160  {
161  using namespace edm;
162 
163  std::unique_ptr<APVCyclePhaseCollection> apvphases =
164  std::make_unique<APVCyclePhaseCollection>(*runCache(iEvent.getRun().index()));
165 
166  iEvent.put(std::move(apvphases));
167 }
int iEvent
Definition: GenABIO.cc:224
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ _defpartnames

const std::vector<std::string> ConfigurableAPVCyclePhaseProducer::_defpartnames
private

◆ _defphases

const std::vector<int> ConfigurableAPVCyclePhaseProducer::_defphases
private

◆ _runpartnames

std::map<int, std::vector<std::string> > ConfigurableAPVCyclePhaseProducer::_runpartnames
private

◆ _runphases

std::map<int, std::vector<int> > ConfigurableAPVCyclePhaseProducer::_runphases
private