CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::ProductRegistryHelper

Public Member Functions

 ConfigurableAPVCyclePhaseProducer (const edm::ParameterSet &)
 
 ~ConfigurableAPVCyclePhaseProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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

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
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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, edm::hlt::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 }
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
tuple size
Write out results.
ConfigurableAPVCyclePhaseProducer::~ConfigurableAPVCyclePhaseProducer ( )

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  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 191 of file ConfigurableAPVCyclePhaseProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 130 of file ConfigurableAPVCyclePhaseProducer.cc.

References _currapvphases, _defpartnames, _defphases, _runpartnames, _runphases, edm::hlt::Exception, APVCyclePhaseCollection::get(), 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:44
std::map< int, std::vector< std::string > > _runpartnames
const std::map< std::string, int > & get() const
const std::vector< std::string > _defpartnames
std::map< int, std::vector< int > > _runphases
void ConfigurableAPVCyclePhaseProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 197 of file ConfigurableAPVCyclePhaseProducer.cc.

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

Implements edm::EDProducer.

Definition at line 178 of file ConfigurableAPVCyclePhaseProducer.cc.

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

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

179 {
180 
181  using namespace edm;
182 
183  std::auto_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection(_currapvphases) );
184 
185  iEvent.put(apvphases);
186 
187 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84

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