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::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 FWLiteESRecordWriterAnalyzer (const edm::ParameterSet &)
 
 ~FWLiteESRecordWriterAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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 update (const edm::EventSetup &)
 

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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 144 of file FWLiteESRecordWriterAnalyzer.cc.

Constructor & Destructor Documentation

◆ FWLiteESRecordWriterAnalyzer()

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

Definition at line 176 of file FWLiteESRecordWriterAnalyzer.cc.

176  {
177  std::vector<std::string> names = iConfig.getParameterNamesForType<std::vector<edm::ParameterSet> >(false);
178  if (names.empty()) {
179  throw edm::Exception(edm::errors::Configuration) << "No VPSets were given in configuration";
180  }
181  for (std::vector<std::string>::const_iterator it = names.begin(), itEnd = names.end(); it != itEnd; ++it) {
182  const std::vector<edm::ParameterSet>& ps = iConfig.getUntrackedParameter<std::vector<edm::ParameterSet> >(*it);
183  std::vector<std::pair<std::string, std::string> >& data = m_recordToDataNames[*it];
184  for (std::vector<edm::ParameterSet>::const_iterator itPS = ps.begin(), itPSEnd = ps.end(); itPS != itPSEnd;
185  ++itPS) {
186  std::string type = itPS->getUntrackedParameter<std::string>("type");
187  std::string label = itPS->getUntrackedParameter<std::string>("label", std::string());
188  data.push_back(std::make_pair(type, label));
189  }
190  }
191 
192  m_file = TFile::Open(iConfig.getUntrackedParameter<std::string>("fileName").c_str(), "NEW");
193 }

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

◆ ~FWLiteESRecordWriterAnalyzer()

FWLiteESRecordWriterAnalyzer::~FWLiteESRecordWriterAnalyzer ( )
override

Definition at line 195 of file FWLiteESRecordWriterAnalyzer.cc.

195  {
196  // do anything here that needs to be done at desctruction time
197  // (e.g. close files, deallocate resources etc.)
198  m_file->Close();
199  delete m_file;
200 }

References m_file.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 275 of file FWLiteESRecordWriterAnalyzer.cc.

275  {
276  update(iSetup);
277 }

References update().

◆ beginJob()

void FWLiteESRecordWriterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 280 of file FWLiteESRecordWriterAnalyzer.cc.

280 {}

◆ beginLuminosityBlock()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 286 of file FWLiteESRecordWriterAnalyzer.cc.

286  {
287  update(iSetup);
288 }

References update().

◆ beginRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 285 of file FWLiteESRecordWriterAnalyzer.cc.

285 { update(iSetup); }

References update().

◆ endJob()

void FWLiteESRecordWriterAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 283 of file FWLiteESRecordWriterAnalyzer.cc.

283 { m_file->Write(); }

References m_file.

◆ update()

void FWLiteESRecordWriterAnalyzer::update ( const edm::EventSetup iSetup)
private

Definition at line 205 of file FWLiteESRecordWriterAnalyzer.cc.

205  {
207  if (m_handlers.empty()) {
208  //now we have access to the EventSetup so we can setup our data structure
209  for (std::map<std::string, std::vector<std::pair<std::string, std::string> > >::iterator
210  it = m_recordToDataNames.begin(),
211  itEnd = m_recordToDataNames.end();
212  it != itEnd;
213  ++it) {
214  HCTypeTag tt = HCTypeTag::findType(it->first);
215  if (tt == HCTypeTag()) {
216  throw cms::Exception("UnknownESRecordType")
217  << "The name '" << it->first
218  << "' is not associated with a known EventSetupRecord.\n"
219  "Please check spelling or load a module known to link with the package which declares that Record.";
220  }
222 
223  auto rec = iSetup.find(tt);
224  if (not rec) {
225  throw cms::Exception("UnknownESRecordType")
226  << "The name '" << it->first
227  << "' is not associated with a type which is not an EventSetupRecord.\n"
228  "Please check your spelling.";
229  }
230 
231  //now figure out what data
232  std::vector<std::pair<std::string, std::string> >& data = it->second;
233  if (data.empty()) {
234  //get everything from the record
235  std::vector<edm::eventsetup::DataKey> keys;
236  rec->fillRegisteredDataKeys(keys);
237  for (std::vector<edm::eventsetup::DataKey>::iterator itKey = keys.begin(), itKeyEnd = keys.end();
238  itKey != itKeyEnd;
239  ++itKey) {
240  data.push_back(std::make_pair(std::string(itKey->type().name()), std::string(itKey->name().value())));
241  }
242  }
243 
244  std::vector<DataInfo> dataInfos;
245  for (std::vector<std::pair<std::string, std::string> >::iterator itData = data.begin(), itDataEnd = data.end();
246  itData != itDataEnd;
247  ++itData) {
248  HCTypeTag tt = HCTypeTag::findType(itData->first);
249  if (tt == HCTypeTag()) {
250  throw cms::Exception("UnknownESDataType")
251  << "The name '" << itData->first << "' is not associated with a known type held in the " << it->first
252  << " Record.\n"
253  "Please check spelling or load a module known to link with the package which declares that type.";
254  }
255  if (!bool(edm::TypeWithDict(tt.value()))) {
256  throw cms::Exception("NoDictionary")
257  << "The type '" << itData->first << "' can not be retrieved from the Record " << it->first
258  << " and stored \n"
259  "because no dictionary exists for the type.";
260  }
261  dataInfos.push_back(DataInfo(tt, itData->second));
262  }
263  m_handlers.push_back(std::make_shared<RecordHandler>(rKey, m_file, dataInfos));
264  }
265  }
266 
267  for (std::vector<std::shared_ptr<RecordHandler> >::iterator it = m_handlers.begin(), itEnd = m_handlers.end();
268  it != itEnd;
269  ++it) {
270  (*it)->update(iSetup);
271  }
272 }

References data, Exception, edm::EventSetup::find(), edm::typelookup::findType(), relativeConstraints::keys, m_file, m_handlers, m_recordToDataNames, genParticles_cff::map, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::tt, and trackerHitRTTI::vector.

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

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 159 of file FWLiteESRecordWriterAnalyzer.cc.

Referenced by update().

◆ m_recordToDataNames

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

Definition at line 161 of file FWLiteESRecordWriterAnalyzer.cc.

Referenced by FWLiteESRecordWriterAnalyzer(), and update().

edm::typelookup::findType
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:69
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
FWLiteESRecordWriterAnalyzer::m_file
TFile * m_file
Definition: FWLiteESRecordWriterAnalyzer.cc:162
FWLiteESRecordWriterAnalyzer::update
void update(const edm::EventSetup &)
Definition: FWLiteESRecordWriterAnalyzer.cc:205
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::TypeWithDict
Definition: TypeWithDict.h:38
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
edm::eventsetup::heterocontainer::HCTypeTag
Definition: HCTypeTag.h:38
FWLiteESRecordWriterAnalyzer::m_handlers
std::vector< std::shared_ptr< RecordHandler > > m_handlers
Definition: FWLiteESRecordWriterAnalyzer.cc:159
edm::ParameterSet::getParameterNamesForType
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
FWLiteESRecordWriterAnalyzer::m_recordToDataNames
std::map< std::string, std::vector< std::pair< std::string, std::string > > > m_recordToDataNames
Definition: FWLiteESRecordWriterAnalyzer.cc:161
edm::EventSetup::find
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &iKey) const
Definition: EventSetup.h:176
Exception
Definition: hltDiff.cc:245
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
genParticles_cff.map
map
Definition: genParticles_cff.py:11
edm::errors::Configuration
Definition: EDMException.h:36
label
const char * label
Definition: PFTauDecayModeTools.cc:11