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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::ESRecordsToProductResolverIndices 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 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 235 of file FWLiteESRecordWriterAnalyzer.cc.

Constructor & Destructor Documentation

◆ FWLiteESRecordWriterAnalyzer()

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

Definition at line 271 of file FWLiteESRecordWriterAnalyzer.cc.

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

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

◆ ~FWLiteESRecordWriterAnalyzer()

FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer ( )
override

Definition at line 349 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 368 of file FWLiteESRecordWriterAnalyzer.cc.

368 {}

◆ beginJob()

void FWLiteESRecordWriterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 371 of file FWLiteESRecordWriterAnalyzer.cc.

371 {}

◆ beginLuminosityBlock()

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

Definition at line 377 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

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

◆ beginRun()

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

Definition at line 376 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

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

◆ endJob()

void FWLiteESRecordWriterAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 374 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

◆ endLuminosityBlock()

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

Definition at line 246 of file FWLiteESRecordWriterAnalyzer.cc.

246 {}

◆ endRun()

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

Definition at line 247 of file FWLiteESRecordWriterAnalyzer.cc.

247 {}

◆ registerLateConsumes()

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

Reimplemented from edm::EDConsumerBase.

Definition at line 290 of file FWLiteESRecordWriterAnalyzer.cc.

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

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

◆ update()

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

Definition at line 359 of file FWLiteESRecordWriterAnalyzer.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, 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().

359  {
360  for (std::vector<std::shared_ptr<RecordHandler> >::iterator it = m_handlers.begin(), itEnd = m_handlers.end();
361  it != itEnd;
362  ++it) {
363  (*it)->update(iSetup, isRun);
364  }
365 }
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 254 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