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
FWLiteESRecordWriterAnalyzer Class Reference

#include <PhysicsTools/FWLiteESRecordWriterAnalyzer/src/FWLiteESRecordWriterAnalyzer.cc>

Inheritance diagram for FWLiteESRecordWriterAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 FWLiteESRecordWriterAnalyzer (const edm::ParameterSet &)
 
 ~FWLiteESRecordWriterAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void endJob () override
 
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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 147 of file FWLiteESRecordWriterAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 180 of file FWLiteESRecordWriterAnalyzer.cc.

References edm::errors::Configuration, data, edm::hlt::Exception, edm::ParameterSet::getParameterNamesForType(), edm::ParameterSet::getUntrackedParameter(), diffTwoXMLs::label, m_file, m_recordToDataNames, cscdqm::h::names, and AlCaHLTBitMon_QueryRunRegistry::string.

181 {
182  std::vector<std::string> names = iConfig.getParameterNamesForType<std::vector<edm::ParameterSet> >(false);
183  if (0 == names.size()) {
184  throw edm::Exception(edm::errors::Configuration)<<"No VPSets were given in configuration";
185  }
186  for (std::vector<std::string>::const_iterator it = names.begin(), itEnd=names.end(); it != itEnd; ++it) {
187  const std::vector<edm::ParameterSet>& ps = iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(*it);
188  std::vector<std::pair<std::string,std::string> >& data = m_recordToDataNames[*it];
189  for(std::vector<edm::ParameterSet>::const_iterator itPS = ps.begin(),itPSEnd = ps.end();
190  itPS != itPSEnd;
191  ++itPS){
192  std::string type = itPS->getUntrackedParameter<std::string>("type");
193  std::string label = itPS->getUntrackedParameter<std::string>("label",std::string());
194  data.push_back(std::make_pair(type,label) );
195  }
196  }
197 
198  m_file = TFile::Open(iConfig.getUntrackedParameter<std::string>("fileName").c_str(),"NEW");
199 }
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
static const HistoName names[]
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:192
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer ( )

Definition at line 202 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

203 {
204 
205  // do anything here that needs to be done at desctruction time
206  // (e.g. close files, deallocate resources etc.)
207  m_file->Close();
208  delete m_file;
209 }

Member Function Documentation

void FWLiteESRecordWriterAnalyzer::analyze ( const edm::Event ,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 281 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

282 {
283  update(iSetup);
284 }
void update(const edm::EventSetup &)
void FWLiteESRecordWriterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 289 of file FWLiteESRecordWriterAnalyzer.cc.

290 {
291 }
void FWLiteESRecordWriterAnalyzer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 304 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

304  {
305  update(iSetup);
306 }
void update(const edm::EventSetup &)
void FWLiteESRecordWriterAnalyzer::beginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 300 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

300  {
301  update(iSetup);
302 }
void update(const edm::EventSetup &)
void FWLiteESRecordWriterAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 295 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

295  {
296  m_file->Write();
297 }
void FWLiteESRecordWriterAnalyzer::update ( const edm::EventSetup iSetup)
private

Definition at line 216 of file FWLiteESRecordWriterAnalyzer.cc.

References data, edm::hlt::Exception, edm::eventsetup::EventSetupRecord::fillRegisteredDataKeys(), edm::EventSetup::find(), edm::typelookup::findType(), relativeConstraints::keys, m_file, m_handlers, m_recordToDataNames, python.multivaluedict::map(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::tt.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), analyze(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), beginLuminosityBlock(), beginRun(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

217 {
219  if(m_handlers.empty()) {
220  //now we have access to the EventSetup so we can setup our data structure
221  for(std::map<std::string, std::vector<std::pair<std::string,std::string> > >::iterator it=m_recordToDataNames.begin(),
222  itEnd = m_recordToDataNames.end();
223  it != itEnd;
224  ++it) {
225  HCTypeTag tt = HCTypeTag::findType(it->first);
226  if(tt == HCTypeTag()) {
227  throw cms::Exception("UnknownESRecordType")<<"The name '"<<it->first<<"' is not associated with a known EventSetupRecord.\n"
228  "Please check spelling or load a module known to link with the package which declares that Record.";
229  }
231 
232  const edm::eventsetup::EventSetupRecord* rec = iSetup.find(tt);
233  if(0==rec) {
234  throw cms::Exception("UnknownESRecordType")<<"The name '"<<it->first<<"' is not associated with a type which is not an EventSetupRecord.\n"
235  "Please check your spelling.";
236  }
237 
238  //now figure out what data
239  std::vector<std::pair<std::string,std::string> >& data = it->second;
240  if(data.empty()) {
241  //get everything from the record
242  std::vector<edm::eventsetup::DataKey> keys;
243  rec->fillRegisteredDataKeys(keys);
244  for(std::vector<edm::eventsetup::DataKey>::iterator itKey = keys.begin(), itKeyEnd = keys.end();
245  itKey != itKeyEnd;
246  ++itKey) {
247  data.push_back(std::make_pair(std::string(itKey->type().name()),
248  std::string(itKey->name().value())));
249  }
250  }
251 
252  std::vector<DataInfo> dataInfos;
253  for (std::vector<std::pair<std::string,std::string> >::iterator itData = data.begin(), itDataEnd = data.end();
254  itData != itDataEnd;
255  ++itData) {
256  HCTypeTag tt = HCTypeTag::findType(itData->first);
257  if(tt == HCTypeTag()) {
258  throw cms::Exception("UnknownESDataType")<<"The name '"<<itData->first<<"' is not associated with a known type held in the "<<it->first<<" Record.\n"
259  "Please check spelling or load a module known to link with the package which declares that type.";
260  }
261  if(!bool(edm::TypeWithDict( tt.value() ))) {
262  throw cms::Exception("NoDictionary")<<"The type '"<<itData->first<<"' can not be retrieved from the Record "<<it->first<<" and stored \n"
263  "because no dictionary exists for the type.";
264  }
265  dataInfos.push_back(DataInfo(tt,itData->second));
266  }
267  m_handlers.push_back( boost::shared_ptr<RecordHandler>( new RecordHandler(rKey,m_file,dataInfos) ) );
268  }
269  }
270 
271  for(std::vector<boost::shared_ptr<RecordHandler> >::iterator it = m_handlers.begin(),itEnd = m_handlers.end();
272  it != itEnd;
273  ++it) {
274  (*it)->update(iSetup);
275  }
276 }
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:51
void fillRegisteredDataKeys(std::vector< DataKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all registered data keys ...
std::vector< boost::shared_ptr< RecordHandler > > m_handlers
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

TFile* FWLiteESRecordWriterAnalyzer::m_file
private
std::vector<boost::shared_ptr<RecordHandler> > FWLiteESRecordWriterAnalyzer::m_handlers
private

Definition at line 163 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 165 of file FWLiteESRecordWriterAnalyzer.cc.

Referenced by FWLiteESRecordWriterAnalyzer(), and update().