CMS 3D CMS Logo

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::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 FWLiteESRecordWriterAnalyzer (const edm::ParameterSet &)
 
 ~FWLiteESRecordWriterAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void registerLateConsumes (edm::eventsetup::ESRecordsToProxyIndices const &) final
 
void update (const edm::EventSetup &, bool isRun)
 

Private Attributes

TFile * m_file
 
std::vector< std::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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 234 of file FWLiteESRecordWriterAnalyzer.cc.

Constructor & Destructor Documentation

◆ FWLiteESRecordWriterAnalyzer()

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

Definition at line 270 of file FWLiteESRecordWriterAnalyzer.cc.

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

270  {
271  std::vector<std::string> names = iConfig.getParameterNamesForType<std::vector<edm::ParameterSet> >(false);
272  if (names.empty()) {
273  throw edm::Exception(edm::errors::Configuration) << "No VPSets were given in configuration";
274  }
275  for (std::vector<std::string>::const_iterator it = names.begin(), itEnd = names.end(); it != itEnd; ++it) {
276  const std::vector<edm::ParameterSet>& ps = iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(*it);
277  std::vector<std::pair<std::string, std::string> >& data = m_recordToDataNames[*it];
278  for (std::vector<edm::ParameterSet>::const_iterator itPS = ps.begin(), itPSEnd = ps.end(); itPS != itPSEnd;
279  ++itPS) {
280  std::string type = itPS->getUntrackedParameter<std::string>("type");
281  std::string label = itPS->getUntrackedParameter<std::string>("label", std::string());
282  data.push_back(std::make_pair(type, label));
283  }
284  }
285 
286  m_file = TFile::Open(iConfig.getUntrackedParameter<std::string>("fileName").c_str(), "NEW");
287 }
const std::string names[nVars_]
T getUntrackedParameter(std::string const &, T const &) const
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
char const * label
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ ~FWLiteESRecordWriterAnalyzer()

FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer ( )
override

Definition at line 347 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

347  {
348  // do anything here that needs to be done at desctruction time
349  // (e.g. close files, deallocate resources etc.)
350  m_file->Close();
351  delete m_file;
352 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 366 of file FWLiteESRecordWriterAnalyzer.cc.

366 {}

◆ beginJob()

void FWLiteESRecordWriterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 369 of file FWLiteESRecordWriterAnalyzer.cc.

369 {}

◆ beginLuminosityBlock()

void FWLiteESRecordWriterAnalyzer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 375 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

375  {
376  update(iSetup, false);
377 }
void update(const edm::EventSetup &, bool isRun)

◆ beginRun()

void FWLiteESRecordWriterAnalyzer::beginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 374 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

374 { update(iSetup, true); }
void update(const edm::EventSetup &, bool isRun)

◆ endJob()

void FWLiteESRecordWriterAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 372 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

◆ endLuminosityBlock()

void FWLiteESRecordWriterAnalyzer::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 245 of file FWLiteESRecordWriterAnalyzer.cc.

245 {}

◆ endRun()

void FWLiteESRecordWriterAnalyzer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 246 of file FWLiteESRecordWriterAnalyzer.cc.

246 {}

◆ registerLateConsumes()

void FWLiteESRecordWriterAnalyzer::registerLateConsumes ( edm::eventsetup::ESRecordsToProxyIndices const &  iInfo)
finalprivatevirtual

Reimplemented from edm::EDConsumerBase.

Definition at line 289 of file FWLiteESRecordWriterAnalyzer.cc.

References data, Exception, edm::typelookup::findType(), relativeConstraints::keys, edm::eventsetup::ESRecordsToProxyIndices::keysForRecord(), m_file, m_handlers, m_recordToDataNames, edm::eventsetup::ESRecordsToProxyIndices::missingRecordIndex(), edm::eventsetup::ESRecordsToProxyIndices::recordIndexFor(), AlCaHLTBitMon_QueryRunRegistry::string, and trackerHitRTTI::vector.

289  {
291 
292  for (auto it = m_recordToDataNames.begin(), itEnd = m_recordToDataNames.end(); it != itEnd; ++it) {
293  HCTypeTag tt = HCTypeTag::findType(it->first);
294  if (tt == HCTypeTag()) {
295  throw cms::Exception("UnknownESRecordType")
296  << "The name '" << it->first
297  << "' is not associated with a known EventSetupRecord.\n"
298  "Please check spelling or load a module known to link with the package which declares that Record.";
299  }
301 
302  auto recIndex = iInfo.recordIndexFor(rKey);
303  if (recIndex == iInfo.missingRecordIndex()) {
304  throw cms::Exception("UnknownESRecordType")
305  << "The name '" << it->first
306  << "' is not associated with a type which is not an EventSetupRecord.\n"
307  "Please check your spelling.";
308  }
309 
310  //now figure out what data
311  std::vector<std::pair<std::string, std::string> >& data = it->second;
312  if (data.empty()) {
313  //get everything from the record
314  auto keys = iInfo.keysForRecord(rKey);
315  for (auto itKey = keys.first, itKeyEnd = keys.second; itKey != itKeyEnd; ++itKey) {
316  data.push_back(std::make_pair(std::string(itKey->type().name()), std::string(itKey->name().value())));
317  }
318  }
319 
320  std::vector<DataInfo> dataInfos;
321  for (std::vector<std::pair<std::string, std::string> >::iterator itData = data.begin(), itDataEnd = data.end();
322  itData != itDataEnd;
323  ++itData) {
324  HCTypeTag tt = HCTypeTag::findType(itData->first);
325  if (tt == HCTypeTag()) {
326  throw cms::Exception("UnknownESDataType")
327  << "The name '" << itData->first << "' is not associated with a known type held in the " << it->first
328  << " Record.\n"
329  "Please check spelling or load a module known to link with the package which declares that type.";
330  }
331  if (!bool(edm::TypeWithDict(tt.value()))) {
332  throw cms::Exception("NoDictionary")
333  << "The type '" << itData->first << "' can not be retrieved from the Record " << it->first
334  << " and stored \n"
335  "because no dictionary exists for the type.";
336  }
337  dataInfos.push_back(DataInfo(tt, itData->second));
338  dataInfos.back().m_runToken =
339  esConsumes<edm::Transition::BeginRun>(rKey, edm::eventsetup::DataKey(tt, itData->second.c_str()));
340  dataInfos.back().m_lumiToken =
341  esConsumes<edm::Transition::BeginLuminosityBlock>(rKey, edm::eventsetup::DataKey(tt, itData->second.c_str()));
342  }
343  m_handlers.push_back(std::make_shared<RecordHandler>(rKey, m_file, dataInfos));
344  }
345 }
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:70
std::vector< std::shared_ptr< RecordHandler > > m_handlers
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
Definition: TTTypes.h:54
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ update()

void FWLiteESRecordWriterAnalyzer::update ( const edm::EventSetup iSetup,
bool  isRun 
)
private

Definition at line 357 of file FWLiteESRecordWriterAnalyzer.cc.

References m_handlers, and trackerHitRTTI::vector.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), beginLuminosityBlock(), beginRun(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

357  {
358  for (std::vector<std::shared_ptr<RecordHandler> >::iterator it = m_handlers.begin(), itEnd = m_handlers.end();
359  it != itEnd;
360  ++it) {
361  (*it)->update(iSetup, isRun);
362  }
363 }
std::vector< std::shared_ptr< RecordHandler > > m_handlers

Member Data Documentation

◆ m_file

TFile* FWLiteESRecordWriterAnalyzer::m_file
private

◆ m_handlers

std::vector<std::shared_ptr<RecordHandler> > FWLiteESRecordWriterAnalyzer::m_handlers
private

Definition at line 253 of file FWLiteESRecordWriterAnalyzer.cc.

Referenced by registerLateConsumes(), and update().

◆ m_recordToDataNames

std::map<std::string, std::vector<std::pair<std::string, std::string> > > FWLiteESRecordWriterAnalyzer::m_recordToDataNames
private