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 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(), 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:179
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ ~FWLiteESRecordWriterAnalyzer()

FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer ( )
override

Definition at line 348 of file FWLiteESRecordWriterAnalyzer.cc.

References m_file.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 367 of file FWLiteESRecordWriterAnalyzer.cc.

367 {}

◆ beginJob()

void FWLiteESRecordWriterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 370 of file FWLiteESRecordWriterAnalyzer.cc.

370 {}

◆ beginLuminosityBlock()

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

Definition at line 376 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

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

◆ beginRun()

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

Definition at line 375 of file FWLiteESRecordWriterAnalyzer.cc.

References update().

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

◆ endJob()

void FWLiteESRecordWriterAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 373 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::ESRecordsToProxyIndices const &  iInfo)
finalprivatevirtual

Reimplemented from edm::EDConsumerBase.

Definition at line 290 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.

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

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