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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ConfigurableAPVCyclePhaseProducer (const edm::ParameterSet &)
 
 ~ConfigurableAPVCyclePhaseProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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 updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

APVCyclePhaseCollection _currapvphases
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDProducer
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)
 
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 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)
 

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 45 of file ConfigurableAPVCyclePhaseProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 79 of file ConfigurableAPVCyclePhaseProducer.cc.

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

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

Definition at line 115 of file ConfigurableAPVCyclePhaseProducer.cc.

116 {
117 
118  // do anything here that needs to be done at desctruction time
119  // (e.g. close files, deallocate resources etc.)
120 
121 }

Member Function Documentation

void ConfigurableAPVCyclePhaseProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 191 of file ConfigurableAPVCyclePhaseProducer.cc.

192 {
193 }
void ConfigurableAPVCyclePhaseProducer::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 130 of file ConfigurableAPVCyclePhaseProducer.cc.

References _currapvphases, _defpartnames, _defphases, _runpartnames, _runphases, Exception, APVCyclePhaseCollection::get(), phases, and edm::RunBase::run().

131 {
132 
133  using namespace edm;
134 
135  _currapvphases.get().clear();
136 
137  // fill phase map
138 
139  const std::map<int,std::vector<std::string> >& _crunpartnames = _runpartnames;
140  const std::map<int,std::vector<int> >& _crunphases = _runphases;
141 
142  std::map<int,std::vector<int> >::const_iterator trphases = _crunphases.find(iRun.run());
143  std::map<int,std::vector<std::string> >::const_iterator trpartnames = _crunpartnames.find(iRun.run());
144 
145  std::vector<int> phases = _defphases;
146  std::vector<std::string> partnames = _defpartnames;
147 
148  if(trphases != _crunphases.end()) {
149  phases = trphases->second;
150  }
151  if(trpartnames != _crunpartnames.end()) {
152  partnames = trpartnames->second;
153  }
154 
155  if(phases.size() < partnames.size() ) {
156  // throw exception
157  throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: "
158  << phases.size() << " "
159  << partnames.size();
160  }
161 
162  for(unsigned int ipart=0;ipart<partnames.size();++ipart) {
163  if(phases[ipart]>=0) {
164  _currapvphases.get()[partnames[ipart]] = phases[ipart];
165  }
166  }
167 
168 
169  for(std::map<std::string,int>::const_iterator it=_currapvphases.get().begin(); it!=_currapvphases.get().end();it++) {
170 
171  edm::LogInfo("APVCyclePhaseProducerDebug") << "partition " << it->first << " phase " << it->second;
172 
173  }
174 
175 }
RunNumber_t run() const
Definition: RunBase.h:40
std::map< int, std::vector< std::string > > _runpartnames
const std::map< std::string, int > & get() const
const std::vector< std::string > _defpartnames
std::vector< int > phases
HLT enums.
std::map< int, std::vector< int > > _runphases
void ConfigurableAPVCyclePhaseProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 197 of file ConfigurableAPVCyclePhaseProducer.cc.

References DEFINE_FWK_MODULE.

197  {
198 }
void ConfigurableAPVCyclePhaseProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 178 of file ConfigurableAPVCyclePhaseProducer.cc.

References _currapvphases, eostools::move(), and edm::Event::put().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

179 {
180 
181  using namespace edm;
182 
183  std::unique_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection(_currapvphases) );
184 
185  iEvent.put(std::move(apvphases));
186 
187 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

APVCyclePhaseCollection ConfigurableAPVCyclePhaseProducer::_currapvphases
private

Definition at line 64 of file ConfigurableAPVCyclePhaseProducer.cc.

Referenced by beginRun(), and produce().

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