#include <DPGAnalysis/SiStripTools/plugins/ConfigurableAPVCyclePhaseProducer.cc>
Public Member Functions | |
ConfigurableAPVCyclePhaseProducer (const edm::ParameterSet &) | |
~ConfigurableAPVCyclePhaseProducer () | |
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 |
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.
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.
: _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")), _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")), _currapvphases() { produces<APVCyclePhaseCollection,edm::InEvent>(); //now do what ever other initialization is needed if(_defphases.size() < _defpartnames.size() ) { // throw exception throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent default phases/partitions vector sizes: " << _defphases.size() << " " << _defpartnames.size(); } std::vector<edm::ParameterSet> vps(iConfig.getParameter<std::vector<edm::ParameterSet> >("runPhases")); for(std::vector<edm::ParameterSet>::const_iterator ps = vps.begin();ps!=vps.end();ps++) { _runphases[ps->getParameter<int>("runNumber")] = ps->getUntrackedParameter<std::vector<int> >("phases",_defphases); _runpartnames[ps->getParameter<int>("runNumber")] = ps->getUntrackedParameter<std::vector<std::string> >("partitions",_defpartnames); if(_runphases[ps->getParameter<int>("runNumber")].size() < _runpartnames[ps->getParameter<int>("runNumber")].size() ) { // throw exception throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent run " << ps->getParameter<int>("runNumber") << " phases/partitions vector sizes: " << _runphases[ps->getParameter<int>("runNumber")].size() << " " << _runpartnames[ps->getParameter<int>("runNumber")].size(); } } }
ConfigurableAPVCyclePhaseProducer::~ConfigurableAPVCyclePhaseProducer | ( | ) |
Definition at line 115 of file ConfigurableAPVCyclePhaseProducer.cc.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
void ConfigurableAPVCyclePhaseProducer::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 191 of file ConfigurableAPVCyclePhaseProducer.cc.
{ }
void ConfigurableAPVCyclePhaseProducer::beginRun | ( | edm::Run & | iRun, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 130 of file ConfigurableAPVCyclePhaseProducer.cc.
References _currapvphases, _defpartnames, _defphases, _runpartnames, _runphases, Exception, APVCyclePhaseCollection::get(), and edm::RunBase::run().
{ using namespace edm; _currapvphases.get().clear(); // fill phase map const std::map<int,std::vector<std::string> >& _crunpartnames = _runpartnames; const std::map<int,std::vector<int> >& _crunphases = _runphases; std::map<int,std::vector<int> >::const_iterator trphases = _crunphases.find(iRun.run()); std::map<int,std::vector<std::string> >::const_iterator trpartnames = _crunpartnames.find(iRun.run()); std::vector<int> phases = _defphases; std::vector<std::string> partnames = _defpartnames; if(trphases != _crunphases.end()) { phases = trphases->second; } if(trpartnames != _crunpartnames.end()) { partnames = trpartnames->second; } if(phases.size() < partnames.size() ) { // throw exception throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: " << phases.size() << " " << partnames.size(); } for(unsigned int ipart=0;ipart<partnames.size();++ipart) { if(phases[ipart]>=0) { _currapvphases.get()[partnames[ipart]] = phases[ipart]; } } for(std::map<std::string,int>::const_iterator it=_currapvphases.get().begin(); it!=_currapvphases.get().end();it++) { edm::LogInfo("APVCyclePhaseProducerDebug") << "partition " << it->first << " phase " << it->second; } }
void ConfigurableAPVCyclePhaseProducer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 197 of file ConfigurableAPVCyclePhaseProducer.cc.
{ }
void ConfigurableAPVCyclePhaseProducer::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 178 of file ConfigurableAPVCyclePhaseProducer.cc.
References _currapvphases, and edm::Event::put().
{ using namespace edm; std::auto_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection(_currapvphases) ); iEvent.put(apvphases); }
Definition at line 64 of file ConfigurableAPVCyclePhaseProducer.cc.
Referenced by beginRun(), and produce().
const std::vector<std::string> ConfigurableAPVCyclePhaseProducer::_defpartnames [private] |
Definition at line 58 of file ConfigurableAPVCyclePhaseProducer.cc.
Referenced by beginRun(), and ConfigurableAPVCyclePhaseProducer().
const std::vector<int> ConfigurableAPVCyclePhaseProducer::_defphases [private] |
Definition at line 59 of file ConfigurableAPVCyclePhaseProducer.cc.
Referenced by beginRun(), and ConfigurableAPVCyclePhaseProducer().
std::map<int,std::vector<std::string> > ConfigurableAPVCyclePhaseProducer::_runpartnames [private] |
Definition at line 61 of file ConfigurableAPVCyclePhaseProducer.cc.
Referenced by beginRun(), and ConfigurableAPVCyclePhaseProducer().
std::map<int,std::vector<int> > ConfigurableAPVCyclePhaseProducer::_runphases [private] |
Definition at line 62 of file ConfigurableAPVCyclePhaseProducer.cc.
Referenced by beginRun(), and ConfigurableAPVCyclePhaseProducer().