#include <PhysicsTools/FWLiteESRecordWriterAnalyzer/src/FWLiteESRecordWriterAnalyzer.cc>
Public Member Functions | |
FWLiteESRecordWriterAnalyzer (const edm::ParameterSet &) | |
~FWLiteESRecordWriterAnalyzer () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) |
virtual void | beginRun (edm::Run const &, edm::EventSetup const &) |
virtual void | endJob () |
void | update (const edm::EventSetup &) |
Private Attributes | |
TFile * | m_file |
std::vector< boost::shared_ptr < RecordHandler > > | m_handlers |
std::map< std::string, std::vector< std::pair < std::string, std::string > > > | m_recordToDataNames |
Description: [one line class summary]
Implementation: [Notes on implementation]
Definition at line 148 of file FWLiteESRecordWriterAnalyzer.cc.
FWLiteESRecordWriterAnalyzer::FWLiteESRecordWriterAnalyzer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 181 of file FWLiteESRecordWriterAnalyzer.cc.
References edm::errors::Configuration, runTheMatrix::data, Exception, edm::ParameterSet::getParameterNamesForType(), edm::ParameterSet::getUntrackedParameter(), label, m_file, m_recordToDataNames, and h::names.
{ std::vector<std::string> names = iConfig.getParameterNamesForType<std::vector<edm::ParameterSet> >(false); if (0 == names.size()) { throw edm::Exception(edm::errors::Configuration)<<"No VPSets were given in configuration"; } for (std::vector<std::string>::const_iterator it = names.begin(), itEnd=names.end(); it != itEnd; ++it) { const std::vector<edm::ParameterSet>& ps = iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(*it); std::vector<std::pair<std::string,std::string> >& data = m_recordToDataNames[*it]; for(std::vector<edm::ParameterSet>::const_iterator itPS = ps.begin(),itPSEnd = ps.end(); itPS != itPSEnd; ++itPS){ std::string type = itPS->getUntrackedParameter<std::string>("type"); std::string label = itPS->getUntrackedParameter<std::string>("label",std::string()); data.push_back(std::make_pair(type,label) ); } } m_file = TFile::Open(iConfig.getUntrackedParameter<std::string>("fileName").c_str(),"NEW"); }
FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer | ( | ) |
Definition at line 203 of file FWLiteESRecordWriterAnalyzer.cc.
References m_file.
void FWLiteESRecordWriterAnalyzer::analyze | ( | const edm::Event & | , |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 282 of file FWLiteESRecordWriterAnalyzer.cc.
References update().
{ update(iSetup); }
void FWLiteESRecordWriterAnalyzer::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 290 of file FWLiteESRecordWriterAnalyzer.cc.
{ }
void FWLiteESRecordWriterAnalyzer::beginLuminosityBlock | ( | edm::LuminosityBlock const & | , |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 305 of file FWLiteESRecordWriterAnalyzer.cc.
References update().
{ update(iSetup); }
void FWLiteESRecordWriterAnalyzer::beginRun | ( | edm::Run const & | , |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 301 of file FWLiteESRecordWriterAnalyzer.cc.
References update().
{ update(iSetup); }
void FWLiteESRecordWriterAnalyzer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 296 of file FWLiteESRecordWriterAnalyzer.cc.
References m_file.
{ m_file->Write(); }
void FWLiteESRecordWriterAnalyzer::update | ( | const edm::EventSetup & | iSetup | ) | [private] |
Definition at line 217 of file FWLiteESRecordWriterAnalyzer.cc.
References runTheMatrix::data, Exception, edm::eventsetup::EventSetupRecord::fillRegisteredDataKeys(), edm::EventSetup::find(), edm::typelookup::findType(), relativeConstraints::keys, m_file, m_handlers, m_recordToDataNames, and python::multivaluedict::map().
Referenced by analyze(), beginLuminosityBlock(), and beginRun().
{ using edm::eventsetup::heterocontainer::HCTypeTag; if(m_handlers.empty()) { //now we have access to the EventSetup so we can setup our data structure for(std::map<std::string, std::vector<std::pair<std::string,std::string> > >::iterator it=m_recordToDataNames.begin(), itEnd = m_recordToDataNames.end(); it != itEnd; ++it) { HCTypeTag tt = HCTypeTag::findType(it->first); if(tt == HCTypeTag()) { throw cms::Exception("UnknownESRecordType")<<"The name '"<<it->first<<"' is not associated with a known EventSetupRecord.\n" "Please check spelling or load a module known to link with the package which declares that Record."; } edm::eventsetup::EventSetupRecordKey rKey(tt); const edm::eventsetup::EventSetupRecord* rec = iSetup.find(tt); if(0==rec) { throw cms::Exception("UnknownESRecordType")<<"The name '"<<it->first<<"' is not associated with a type which is not an EventSetupRecord.\n" "Please check your spelling."; } //now figure out what data std::vector<std::pair<std::string,std::string> >& data = it->second; if(data.empty()) { //get everything from the record std::vector<edm::eventsetup::DataKey> keys; rec->fillRegisteredDataKeys(keys); for(std::vector<edm::eventsetup::DataKey>::iterator itKey = keys.begin(), itKeyEnd = keys.end(); itKey != itKeyEnd; ++itKey) { data.push_back(std::make_pair(std::string(itKey->type().name()), std::string(itKey->name().value()))); } } std::vector<DataInfo> dataInfos; for (std::vector<std::pair<std::string,std::string> >::iterator itData = data.begin(), itDataEnd = data.end(); itData != itDataEnd; ++itData) { HCTypeTag tt = HCTypeTag::findType(itData->first); if(tt == HCTypeTag()) { throw cms::Exception("UnknownESDataType")<<"The name '"<<itData->first<<"' is not associated with a known type held in the "<<it->first<<" Record.\n" "Please check spelling or load a module known to link with the package which declares that type."; } if(ROOT::Reflex::Type::ByTypeInfo( tt.value() ) == ROOT::Reflex::Type()) { throw cms::Exception("NoDictionary")<<"The type '"<<itData->first<<"' can not be retrieved from the Record "<<it->first<<" and stored \n" "because no Reflex dictionary exists for the type."; } dataInfos.push_back(DataInfo(tt,itData->second)); } m_handlers.push_back( boost::shared_ptr<RecordHandler>( new RecordHandler(rKey,m_file,dataInfos) ) ); } } for(std::vector<boost::shared_ptr<RecordHandler> >::iterator it = m_handlers.begin(),itEnd = m_handlers.end(); it != itEnd; ++it) { (*it)->update(iSetup); } }
TFile* FWLiteESRecordWriterAnalyzer::m_file [private] |
Definition at line 167 of file FWLiteESRecordWriterAnalyzer.cc.
Referenced by endJob(), FWLiteESRecordWriterAnalyzer(), update(), and ~FWLiteESRecordWriterAnalyzer().
std::vector<boost::shared_ptr<RecordHandler> > FWLiteESRecordWriterAnalyzer::m_handlers [private] |
Definition at line 164 of file FWLiteESRecordWriterAnalyzer.cc.
Referenced by update().
std::map<std::string, std::vector<std::pair<std::string,std::string> > > FWLiteESRecordWriterAnalyzer::m_recordToDataNames [private] |
Definition at line 166 of file FWLiteESRecordWriterAnalyzer.cc.
Referenced by FWLiteESRecordWriterAnalyzer(), and update().