CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
fwlite::Event Class Reference

#include <Event.h>

Inheritance diagram for fwlite::Event:
fwlite::EventBase edm::EventBase

Public Member Functions

bool atEnd () const override
 
void draw (Option_t *opt)
 Properly setup for edm::Ref, etc and then call TTree method. More...
 
Long64_t draw (char const *varexp, const TCut &selection, Option_t *option="", Long64_t nentries=1000000000, Long64_t firstentry=0)
 
Long64_t draw (char const *varexp, char const *selection, Option_t *option="", Long64_t nentries=1000000000, Long64_t firstentry=0)
 
 Event (TFile *iFile, bool useCache=true, std::function< void(TBranch const &)> baFunc=[](TBranch const &) {})
 
 Event (Event const &)=delete
 
edm::EventAuxiliary const & eventAuxiliary () const override
 
std::vector< edm::BranchDescription > const & getBranchDescriptions () const
 
std::string const getBranchNameFor (std::type_info const &, char const *iModuleLabel, char const *iProductInstanceLabel, char const *iProcessName) const override
 Return the branch name in the TFile which contains the data. More...
 
bool getByLabel (std::type_info const &, char const *, char const *, char const *, void *) const override
 This function should only be called by fwlite::Handle<> More...
 
edm::WrapperBase const * getByProductID (edm::ProductID const &) const override
 
fwlite::LuminosityBlock const & getLuminosityBlock () const
 
std::vector< std::string > const & getProcessHistory () const
 
fwlite::Run const & getRun () const
 
TFile * getTFile () const
 
edm::OptionalThinnedKey getThinnedKeyFrom (edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const
 
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct (edm::ProductID const &pid, unsigned int key) const
 
void getThinnedProducts (edm::ProductID const &pid, std::vector< edm::WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys) const
 
Long64_t indexFromEventId (edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event)
 Find index of given event-id. More...
 
bool isValid () const
 
 operator bool () const
 
Event const & operator++ () override
 Advance to next event in the TFile. More...
 
Event const & operator= (Event const &)=delete
 
edm::ParameterSet const * parameterSet (edm::ParameterSetID const &psID) const override
 
edm::ProcessHistory const & processHistory () const override
 
Long64_t scan (char const *varexp="", char const *selection="", Option_t *option="", Long64_t nentries=1000000000, Long64_t firstentry=0)
 
Long64_t size () const
 Returns number of events in the file. More...
 
bool to (Long64_t iIndex)
 Go to the event at index iIndex. More...
 
bool to (const edm::EventID &id)
 Go to event by Run & Event number. More...
 
bool to (edm::RunNumber_t run, edm::EventNumber_t event)
 
bool to (edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event)
 
Event const & toBegin () override
 Go to the very first Event. More...
 
edm::TriggerNames const & triggerNames (edm::TriggerResults const &triggerResults) const override
 
edm::TriggerResultsByName triggerResultsByName (edm::TriggerResults const &triggerResults) const override
 
 ~Event () override
 
- Public Member Functions inherited from fwlite::EventBase
 EventBase ()
 
virtual Long64_t fileIndex () const
 
virtual Long64_t secondaryFileIndex () const
 
 ~EventBase () override
 
- Public Member Functions inherited from edm::EventBase
int bunchCrossing () const
 
 EventBase ()
 
edm::EventAuxiliary::ExperimentType experimentType () const
 
template<typename T >
bool get (ProductID const &, Handle< T > &) const
 
template<typename T >
bool getByLabel (InputTag const &, Handle< T > &) const
 
template<>
bool getByLabel (edm::InputTag const &tag, Handle< FWGenericObject > &result) const
 Specialize the getByLabel method to work with a Handle<FWGenericObject> More...
 
edm::EventID id () const
 
bool isRealData () const
 
edm::LuminosityBlockNumber_t luminosityBlock () const
 
int orbitNumber () const
 
edm::Timestamp time () const
 

Static Public Member Functions

static void throwProductNotFoundException (std::type_info const &, char const *, char const *, char const *)
 

Private Member Functions

void fillParameterSetRegistry () const
 
edm::ProcessHistory const & history () const
 
void setGetter (std::shared_ptr< edm::EDProductGetter const > getter)
 
void updateAux (Long_t eventIndex) const
 

Private Attributes

edm::EventAuxiliary aux_
 
TBranch * auxBranch_
 
fwlite::BranchMapReader branchMap_
 
fwlite::DataGetterHelper dataHelper_
 
EntryFinder entryFinder_
 
TTree * eventHistoryTree_
 
std::vector< edm::EventProcessHistoryIDeventProcessHistoryIDs_
 
TFile * file_
 
int fileVersion_
 
edm::ProcessHistoryMap historyMap_
 
std::vector< char const * > labels_
 
std::shared_ptr< fwlite::LuminosityBlocklumi_
 
bool parameterSetRegistryFilled_
 
edm::EventAuxiliary const * pAux_
 
edm::EventAux const * pOldAux_
 
std::vector< std::string > procHistoryNames_
 
std::shared_ptr< fwlite::Runrun_
 
std::shared_ptr< RunFactoryrunFactory_
 

Friends

class ChainEvent
 
class EventHistoryGetter
 
class internal::ProductGetter
 

Additional Inherited Members

- Static Protected Member Functions inherited from edm::EventBase
static edm::ParameterSet const * parameterSetForID_ (edm::ParameterSetID const &psID)
 
static TriggerNames const * triggerNames_ (edm::TriggerResults const &triggerResults)
 

Detailed Description

Definition at line 87 of file Event.h.

Constructor & Destructor Documentation

◆ Event() [1/2]

Event::Event ( TFile *  iFile,
bool  useCache = true,
std::function< void(TBranch const &)>  baFunc = [](TBranch const&) {} 
)

Definition at line 114 of file Event.cc.

References auxBranch_, branchMap_, edm::BranchTypeToAuxBranchName(), edm::BranchTypeToAuxiliaryBranchName(), eventHistoryTree_, edm::poolNames::eventHistoryTreeName(), edm::poolNames::eventTreeName(), Exception, fileVersion_, fwlite::BranchMapReader::getEventTree(), fwlite::BranchMapReader::getFileVersion(), edm::InEvent, pAux_, pOldAux_, runFactory_, and fwlite::BranchMapReader::updateEvent().

115  : file_(iFile),
116  // eventTree_(nullptr),
117  eventHistoryTree_(nullptr),
118  // eventIndex_(-1),
119  branchMap_(iFile),
120  pAux_(&aux_),
121  pOldAux_(nullptr),
122  fileVersion_(-1),
125  std::make_shared<EventHistoryGetter>(this),
126  std::shared_ptr<BranchMapReader>(&branchMap_, NoDelete()),
127  std::make_shared<internal::ProductGetter>(this),
128  useCache,
129  baFunc) {
130  if (nullptr == iFile) {
131  throw cms::Exception("NoFile") << "The TFile pointer passed to the constructor was null";
132  }
133 
134  if (nullptr == branchMap_.getEventTree()) {
135  throw cms::Exception("NoEventTree") << "The TFile contains no TTree named " << edm::poolNames::eventTreeName();
136  }
137  //need to know file version in order to determine how to read the basic event info
139 
140  //got this logic from IOPool/Input/src/RootFile.cc
141 
142  TTree* eventTree = branchMap_.getEventTree();
143  if (fileVersion_ >= 3) {
144  auxBranch_ = eventTree->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
145  if (nullptr == auxBranch_) {
146  throw cms::Exception("NoEventAuxilliary")
147  << "The TTree " << edm::poolNames::eventTreeName() << " does not contain a branch named 'EventAuxiliary'";
148  }
149  auxBranch_->SetAddress(&pAux_);
150  } else {
151  pOldAux_ = new edm::EventAux();
152  auxBranch_ = eventTree->GetBranch(edm::BranchTypeToAuxBranchName(edm::InEvent).c_str());
153  if (nullptr == auxBranch_) {
154  throw cms::Exception("NoEventAux")
155  << "The TTree " << edm::poolNames::eventTreeName() << " does not contain a branch named 'EventAux'";
156  }
157  auxBranch_->SetAddress(&pOldAux_);
158  }
160 
161  if (fileVersion_ >= 7 && fileVersion_ < 17) {
162  eventHistoryTree_ = dynamic_cast<TTree*>(iFile->Get(edm::poolNames::eventHistoryTreeName().c_str()));
163  }
164  runFactory_ = std::make_shared<RunFactory>();
165  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
bool updateEvent(Long_t eventEntry)
TTree const * getEventTree() const
std::string const & BranchTypeToAuxBranchName(BranchType const &branchType)
Definition: BranchType.cc:122
TTree * eventHistoryTree_
Definition: Event.h:206
int fileVersion_
Definition: Event.h:222
int getFileVersion(TFile *file)
bool parameterSetRegistryFilled_
Definition: Event.h:223
edm::EventAuxiliary const * pAux_
Definition: Event.h:219
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:224
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
TFile * file_
Definition: Event.h:204
edm::EventAuxiliary aux_
Definition: Event.h:217
std::string const & eventTreeName()
Definition: BranchType.cc:220
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
TBranch * auxBranch_
Definition: Event.h:221
edm::EventAux const * pOldAux_
Definition: Event.h:220
std::shared_ptr< RunFactory > runFactory_
Definition: Event.h:226

◆ Event() [2/2]

fwlite::Event::Event ( Event const &  )
delete

◆ ~Event()

Event::~Event ( )
override

Definition at line 172 of file Event.cc.

References label, labels_, and pOldAux_.

172  {
173  for (auto const& label : labels_) {
174  delete[] label;
175  }
176  delete pOldAux_;
177  }
char const * label
std::vector< char const * > labels_
Definition: Event.h:213
edm::EventAux const * pOldAux_
Definition: Event.h:220

Member Function Documentation

◆ atEnd()

bool Event::atEnd ( ) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 267 of file Event.cc.

References branchMap_, fwlite::BranchMapReader::getEventEntry(), or, and size().

Referenced by FWHLTTriggerTableView::fillAverageAcceptFractions(), FWFileEntry::filterEventsWithCustomParser(), and getByLabel().

267  {
268  Long_t eventIndex = branchMap_.getEventEntry();
269  return eventIndex == -1 or eventIndex == size();
270  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Long_t getEventEntry() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
Long64_t size() const
Returns number of events in the file.
Definition: Event.cc:258

◆ draw() [1/3]

void Event::draw ( Option_t *  opt)

Properly setup for edm::Ref, etc and then call TTree method.

Definition at line 238 of file Event.cc.

References branchMap_, dataHelper_, fwlite::BranchMapReader::getEventTree(), fwlite::DataGetterHelper::getter(), and runTheMatrix::opt.

238  {
239  GetterOperate op(dataHelper_.getter());
240  branchMap_.getEventTree()->Draw(opt);
241  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
TTree const * getEventTree() const
edm::EDProductGetter const * getter() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ draw() [2/3]

Long64_t Event::draw ( char const *  varexp,
const TCut &  selection,
Option_t *  option = "",
Long64_t  nentries = 1000000000,
Long64_t  firstentry = 0 
)

Definition at line 242 of file Event.cc.

References branchMap_, dataHelper_, mps_merge::firstentry, fwlite::BranchMapReader::getEventTree(), fwlite::DataGetterHelper::getter(), fileinputsource_cfi::option, and corrVsCorr::selection.

243  {
244  GetterOperate op(dataHelper_.getter());
245  return branchMap_.getEventTree()->Draw(varexp, selection, option, nentries, firstentry);
246  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
selection
main part
Definition: corrVsCorr.py:100
TTree const * getEventTree() const
bool firstentry
Definition: mps_merge.py:77
edm::EDProductGetter const * getter() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ draw() [3/3]

Long64_t Event::draw ( char const *  varexp,
char const *  selection,
Option_t *  option = "",
Long64_t  nentries = 1000000000,
Long64_t  firstentry = 0 
)

Definition at line 247 of file Event.cc.

References branchMap_, dataHelper_, mps_merge::firstentry, fwlite::BranchMapReader::getEventTree(), fwlite::DataGetterHelper::getter(), fileinputsource_cfi::option, and corrVsCorr::selection.

248  {
249  GetterOperate op(dataHelper_.getter());
250  return branchMap_.getEventTree()->Draw(varexp, selection, option, nentries, firstentry);
251  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
selection
main part
Definition: corrVsCorr.py:100
TTree const * getEventTree() const
bool firstentry
Definition: mps_merge.py:77
edm::EDProductGetter const * getter() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ eventAuxiliary()

edm::EventAuxiliary const & Event::eventAuxiliary ( ) const
overridevirtual

Implements edm::EventBase.

Definition at line 300 of file Event.cc.

References aux_, branchMap_, fwlite::BranchMapReader::getEventEntry(), and updateAux().

Referenced by getLuminosityBlock(), and getRun().

300  {
301  Long_t eventIndex = branchMap_.getEventEntry();
302  updateAux(eventIndex);
303  return aux_;
304  }
void updateAux(Long_t eventIndex) const
Definition: Event.cc:306
Long_t getEventEntry() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
edm::EventAuxiliary aux_
Definition: Event.h:217

◆ fillParameterSetRegistry()

void Event::fillParameterSetRegistry ( ) const
private

Definition at line 418 of file Event.cc.

References b, branchMap_, Exception, edm::poolNames::fileFormatVersionBranchName(), fwlite::BranchMapReader::getFile(), mps_fire::i, edm::poolNames::idToParameterSetBlobsBranchName(), edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), B2GTnPMonitor_cfi::item, edm::poolNames::metaDataTreeName(), edm::poolNames::parameterSetMapBranchName(), parameterSetRegistryFilled_, edm::FileFormatVersion::parameterSetsByReference(), edm::poolNames::parameterSetsTreeName(), muonDTDigis_cfi::pset, and edm::FileFormatVersion::triggerPathsTracked().

Referenced by parameterSet(), triggerNames(), and triggerResultsByName().

418  {
420  return;
422 
423  TTree* meta = dynamic_cast<TTree*>(branchMap_.getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
424  if (nullptr == meta) {
425  throw cms::Exception("NoMetaTree") << "The TFile does not contain a TTree named "
427  }
428 
429  edm::FileFormatVersion fileFormatVersion;
430  edm::FileFormatVersion* fftPtr = &fileFormatVersion;
431  if (meta->FindBranch(edm::poolNames::fileFormatVersionBranchName().c_str()) != nullptr) {
432  TBranch* fft = meta->GetBranch(edm::poolNames::fileFormatVersionBranchName().c_str());
433  fft->SetAddress(&fftPtr);
434  fft->GetEntry(0);
435  }
436 
437  typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob> PsetMap;
438  PsetMap psetMap;
439  TTree* psetTree(nullptr);
440  if (meta->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
441  PsetMap* psetMapPtr = &psetMap;
442  TBranch* b = meta->GetBranch(edm::poolNames::parameterSetMapBranchName().c_str());
443  b->SetAddress(&psetMapPtr);
444  b->GetEntry(0);
445  } else if (nullptr == (psetTree = dynamic_cast<TTree*>(
447  throw cms::Exception("NoParameterSetMapTree")
448  << "The TTree " << edm::poolNames::parameterSetsTreeName() << " could not be found in the file.";
449  } else {
450  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
451  IdToBlobs idToBlob;
452  IdToBlobs* pIdToBlob = &idToBlob;
453  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
454  for (long long i = 0; i != psetTree->GetEntries(); ++i) {
455  psetTree->GetEntry(i);
456  psetMap.insert(idToBlob);
457  }
458  }
460  if (!fileFormatVersion.triggerPathsTracked()) {
461  edm::ParameterSetConverter converter(psetMap, psetIdConverter, fileFormatVersion.parameterSetsByReference());
462  } else {
463  // Merge into the parameter set registry.
465  for (auto const& item : psetMap) {
466  edm::ParameterSet pset(item.second.pset());
467  pset.setID(item.first);
468  psetRegistry.insertMapped(pset);
469  }
470  }
471  }
std::string const & metaDataTreeName()
Definition: BranchType.cc:159
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:168
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:189
bool parameterSetRegistryFilled_
Definition: Event.h:223
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:216
bool triggerPathsTracked() const
std::map< ParameterSetID, ParameterSetID > ParameterSetIdConverter
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:218
TFile const * getFile() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
bool parameterSetsByReference() const
double b
Definition: hdecay.h:118
static Registry * instance()
Definition: Registry.cc:12

◆ getBranchDescriptions()

std::vector<edm::BranchDescription> const& fwlite::Event::getBranchDescriptions ( ) const
inline

Definition at line 162 of file Event.h.

References branchMap_, and fwlite::BranchMapReader::getBranchDescriptions().

Referenced by FWLiteJobMetadataManager::doUpdate(), and FWLiteJobMetadataManager::hasModuleLabel().

162  {
164  }
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
const std::vector< edm::BranchDescription > & getBranchDescriptions()

◆ getBranchNameFor()

std::string const Event::getBranchNameFor ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessName 
) const
overridevirtual

Return the branch name in the TFile which contains the data.

Implements fwlite::EventBase.

Definition at line 281 of file Event.cc.

References dataHelper_, and fwlite::DataGetterHelper::getBranchNameFor().

Referenced by FWFileEntry::getBranchName(), and FWFileEntry::runFilter().

284  {
285  return dataHelper_.getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
286  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const

◆ getByLabel()

bool Event::getByLabel ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessLabel,
void *  oData 
) const
overridevirtual

This function should only be called by fwlite::Handle<>

Implements fwlite::EventBase.

Definition at line 288 of file Event.cc.

References atEnd(), branchMap_, dataHelper_, Exception, fwlite::DataGetterHelper::getByLabel(), and fwlite::BranchMapReader::getEventEntry().

292  {
293  if (atEnd()) {
294  throw cms::Exception("OffEnd") << "You have requested data past the last event";
295  }
296  Long_t eventIndex = branchMap_.getEventEntry();
297  return dataHelper_.getByLabel(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel, oData, eventIndex);
298  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
Long_t getEventEntry() const
bool atEnd() const override
Definition: Event.cc:267
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *, Long_t) const

◆ getByProductID()

edm::WrapperBase const * Event::getByProductID ( edm::ProductID const &  iID) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 377 of file Event.cc.

References branchMap_, dataHelper_, fwlite::DataGetterHelper::getByProductID(), and fwlite::BranchMapReader::getEventEntry().

Referenced by fwlite::internal::ProductGetter::getIt().

377  {
378  Long_t eventEntry = branchMap_.getEventEntry();
379  return dataHelper_.getByProductID(iID, eventEntry);
380  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
Long_t getEventEntry() const
edm::WrapperBase const * getByProductID(edm::ProductID const &pid, Long_t eventEntry) const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ getLuminosityBlock()

fwlite::LuminosityBlock const & Event::getLuminosityBlock ( ) const

Definition at line 505 of file Event.cc.

References branchMap_, eventAuxiliary(), lumi_, edm::EventAuxiliary::luminosityBlock(), writedatasetfile::run, edm::EventAuxiliary::run(), and runFactory_.

505  {
506  if (not lumi_) {
507  // Branch map pointer not really being shared, owned by event, have to trick Lumi
508  lumi_ = std::make_shared<fwlite::LuminosityBlock>(std::shared_ptr<BranchMapReader>(&branchMap_, NoDelete()),
509  runFactory_);
510  }
513  lumi_->to(run, lumi);
514  return *lumi_;
515  }
LuminosityBlockNumber_t luminosityBlock() const
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: Event.cc:300
unsigned int LuminosityBlockNumber_t
std::shared_ptr< fwlite::LuminosityBlock > lumi_
Definition: Event.h:208
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
unsigned int RunNumber_t
std::shared_ptr< RunFactory > runFactory_
Definition: Event.h:226
RunNumber_t run() const

◆ getProcessHistory()

std::vector< std::string > const & Event::getProcessHistory ( ) const

Definition at line 272 of file Event.cc.

References history(), ValidateTausOnZEEFastSim_cff::proc, and procHistoryNames_.

Referenced by FWLiteJobMetadataManager::doUpdate().

272  {
273  if (procHistoryNames_.empty()) {
274  for (auto const& proc : history()) {
275  procHistoryNames_.push_back(proc.processName());
276  }
277  }
278  return procHistoryNames_;
279  }
edm::ProcessHistory const & history() const
Definition: Event.cc:316
std::vector< std::string > procHistoryNames_
Definition: Event.h:216

◆ getRun()

fwlite::Run const & Event::getRun ( ) const

Definition at line 517 of file Event.cc.

References branchMap_, eventAuxiliary(), writedatasetfile::run, edm::EventAuxiliary::run(), run_, and runFactory_.

Referenced by FWMagField::checkFieldInfo().

517  {
518  run_ = runFactory_->makeRun(std::shared_ptr<BranchMapReader>(&branchMap_, NoDelete()));
520  run_->to(run);
521  return *run_;
522  }
edm::EventAuxiliary const & eventAuxiliary() const override
Definition: Event.cc:300
std::shared_ptr< fwlite::Run > run_
Definition: Event.h:209
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
unsigned int RunNumber_t
std::shared_ptr< RunFactory > runFactory_
Definition: Event.h:226
RunNumber_t run() const

◆ getTFile()

TFile* fwlite::Event::getTFile ( ) const
inline

Definition at line 166 of file Event.h.

References branchMap_, and fwlite::BranchMapReader::getFile().

166 { return branchMap_.getFile(); }
TFile const * getFile() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ getThinnedKeyFrom()

edm::OptionalThinnedKey Event::getThinnedKeyFrom ( edm::ProductID const &  parent,
unsigned int  key,
edm::ProductID const &  thinned 
) const

Definition at line 395 of file Event.cc.

References branchMap_, dataHelper_, fwlite::BranchMapReader::getEventEntry(), fwlite::DataGetterHelper::getThinnedKeyFrom(), crabWrapper::key, and class-composition::parent.

Referenced by fwlite::internal::ProductGetter::getThinnedKeyFrom().

397  {
398  Long_t eventEntry = branchMap_.getEventEntry();
399  return dataHelper_.getThinnedKeyFrom(parent, key, thinned, eventEntry);
400  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
Long_t getEventEntry() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned, Long_t eventEntry) const

◆ getThinnedProduct()

std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > Event::getThinnedProduct ( edm::ProductID const &  pid,
unsigned int  key 
) const

Definition at line 382 of file Event.cc.

References branchMap_, dataHelper_, fwlite::BranchMapReader::getEventEntry(), fwlite::DataGetterHelper::getThinnedProduct(), and crabWrapper::key.

Referenced by fwlite::internal::ProductGetter::getThinnedProduct().

383  {
384  Long_t eventEntry = branchMap_.getEventEntry();
385  return dataHelper_.getThinnedProduct(pid, key, eventEntry);
386  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
Long_t getEventEntry() const
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &pid, unsigned int key, Long_t eventEntry) const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ getThinnedProducts()

void Event::getThinnedProducts ( edm::ProductID const &  pid,
std::vector< edm::WrapperBase const *> &  foundContainers,
std::vector< unsigned int > &  keys 
) const

Definition at line 388 of file Event.cc.

References branchMap_, dataHelper_, fwlite::BranchMapReader::getEventEntry(), fwlite::DataGetterHelper::getThinnedProducts(), and relativeConstraints::keys.

Referenced by fwlite::internal::ProductGetter::getThinnedProducts().

390  {
391  Long_t eventEntry = branchMap_.getEventEntry();
392  return dataHelper_.getThinnedProducts(pid, foundContainers, keys, eventEntry);
393  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys, Long_t eventEntry) const
Long_t getEventEntry() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ history()

const edm::ProcessHistory & Event::history ( ) const
private

Definition at line 316 of file Event.cc.

References aux_, b, branchMap_, edm::poolNames::eventHistoryBranchName(), eventHistoryTree_, eventProcessHistoryIDs_, Exception, edm::errors::FatalRootError, fileVersion_, fwlite::BranchMapReader::getEventEntry(), fwlite::BranchMapReader::getFile(), historyMap_, edm::EventAuxiliary::id(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, edm::poolNames::metaDataTreeName(), edm::poolNames::processHistoryBranchName(), edm::EventAuxiliary::processHistoryID(), edm::poolNames::processHistoryMapBranchName(), procHistoryNames_, edm::ProcessHistory::setProcessHistoryID(), filterCSVwithJSON::target, and updateAux().

Referenced by getProcessHistory(), fwlite::EventHistoryGetter::history(), and processHistory().

316  {
317  edm::ProcessHistoryID processHistoryID;
318 
319  bool newFormat = (fileVersion_ >= 5);
320 
321  Long_t eventIndex = branchMap_.getEventEntry();
322  updateAux(eventIndex);
323  if (!newFormat) {
324  processHistoryID = aux_.processHistoryID();
325  }
326  if (historyMap_.empty() || newFormat) {
327  procHistoryNames_.clear();
328  TTree* meta = dynamic_cast<TTree*>(branchMap_.getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
329  if (nullptr == meta) {
330  throw cms::Exception("NoMetaTree")
331  << "The TFile does not appear to contain a TTree named " << edm::poolNames::metaDataTreeName();
332  }
333  if (historyMap_.empty()) {
334  if (fileVersion_ < 11) {
336  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryMapBranchName().c_str());
337  b->SetAddress(&pPhm);
338  b->GetEntry(0);
339  } else {
340  edm::ProcessHistoryVector historyVector;
341  edm::ProcessHistoryVector* pPhv = &historyVector;
342  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryBranchName().c_str());
343  b->SetAddress(&pPhv);
344  b->GetEntry(0);
345  for (auto& history : historyVector) {
346  historyMap_.insert(std::make_pair(history.setProcessHistoryID(), history));
347  }
348  }
349  }
350  if (newFormat) {
351  if (fileVersion_ >= 17) {
352  processHistoryID = aux_.processHistoryID();
353  } else if (fileVersion_ >= 7) {
355  edm::History* pHistory = &history;
356  TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
357  if (!eventHistoryBranch)
358  throw edm::Exception(edm::errors::FatalRootError) << "Failed to find history branch in event history tree";
359  eventHistoryBranch->SetAddress(&pHistory);
360  eventHistoryTree_->GetEntry(eventIndex);
361  processHistoryID = history.processHistoryID();
362  } else {
363  std::vector<edm::EventProcessHistoryID>* pEventProcessHistoryIDs = &eventProcessHistoryIDs_;
364  TBranch* b = meta->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
365  b->SetAddress(&pEventProcessHistoryIDs);
366  b->GetEntry(0);
368  processHistoryID = std::lower_bound(eventProcessHistoryIDs_.begin(), eventProcessHistoryIDs_.end(), target)
369  ->processHistoryID();
370  }
371  }
372  }
373 
374  return historyMap_[processHistoryID];
375  }
std::vector< ProcessHistory > ProcessHistoryVector
edm::ProcessHistoryMap historyMap_
Definition: Event.h:214
std::string const & metaDataTreeName()
Definition: BranchType.cc:159
void updateAux(Long_t eventIndex) const
Definition: Event.cc:306
std::string const & processHistoryBranchName()
Definition: BranchType.cc:177
ProcessHistoryID setProcessHistoryID()
TTree * eventHistoryTree_
Definition: Event.h:206
int fileVersion_
Definition: Event.h:222
EventID const & id() const
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:174
edm::ProcessHistory const & history() const
Definition: Event.cc:316
std::vector< std::string > procHistoryNames_
Definition: Event.h:216
Long_t getEventEntry() const
Hash< ProcessHistoryType > ProcessHistoryID
TFile const * getFile() const
ProcessHistoryID const & processHistoryID() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
double b
Definition: hdecay.h:118
edm::EventAuxiliary aux_
Definition: Event.h:217
std::vector< edm::EventProcessHistoryID > eventProcessHistoryIDs_
Definition: Event.h:215
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:207
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap

◆ indexFromEventId()

Long64_t Event::indexFromEventId ( edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi,
edm::EventNumber_t  event 
)

Find index of given event-id.

Definition at line 202 of file Event.cc.

References branchMap_, mps_splice::entry, entryFinder_, fwlite::EntryFinder::fillIndex(), fwlite::EntryFinder::findEvent(), fwlite::EntryFinder::invalidEntry, and writedatasetfile::run.

202  {
205  return (entry == EntryFinder::invalidEntry) ? -1 : entry;
206  }
EntryNumber_t findEvent(edm::RunNumber_t const &run, edm::LuminosityBlockNumber_t const &lumi, edm::EventNumber_t const &event) const
Definition: EntryFinder.cc:56
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
void fillIndex(BranchMapReader &branchMap)
Definition: EntryFinder.cc:107
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:41
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
EntryFinder entryFinder_
Definition: Event.h:218
Definition: event.py:1

◆ isValid()

bool Event::isValid ( void  ) const

Definition at line 260 of file Event.cc.

References branchMap_, fwlite::BranchMapReader::getEventEntry(), and size().

Referenced by ntupleDataFormat._Object::_checkIsValid(), and core.AutoHandle.AutoHandle::ReallyLoad().

260  {
261  Long_t eventIndex = branchMap_.getEventEntry();
262  return eventIndex != -1 and eventIndex < size();
263  }
Long_t getEventEntry() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
Long64_t size() const
Returns number of events in the file.
Definition: Event.cc:258

◆ operator bool()

Event::operator bool ( ) const

Definition at line 265 of file Event.cc.

References sistrip::SpyUtilities::isValid().

265 { return isValid(); }
bool isValid() const
Definition: Event.cc:260

◆ operator++()

Event const & Event::operator++ ( )
overridevirtual

Advance to next event in the TFile.

Implements fwlite::EventBase.

Definition at line 194 of file Event.cc.

References branchMap_, fwlite::BranchMapReader::getEventEntry(), size(), and fwlite::BranchMapReader::updateEvent().

194  {
195  Long_t eventIndex = branchMap_.getEventEntry();
196  if (eventIndex < size()) {
197  branchMap_.updateEvent(++eventIndex);
198  }
199  return *this;
200  }
bool updateEvent(Long_t eventEntry)
Long_t getEventEntry() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
Long64_t size() const
Returns number of events in the file.
Definition: Event.cc:258

◆ operator=()

Event const& fwlite::Event::operator= ( Event const &  )
delete

◆ parameterSet()

edm::ParameterSet const * Event::parameterSet ( edm::ParameterSetID const &  psID) const
overridevirtual

Implements edm::EventBase.

Definition at line 473 of file Event.cc.

References fillParameterSetRegistry(), edm::EventBase::parameterSetForID_(), and parameterSetRegistryFilled_.

473  {
476  }
477  return parameterSetForID_(psID);
478  }
static edm::ParameterSet const * parameterSetForID_(edm::ParameterSetID const &psID)
Definition: EventBase.cc:41
bool parameterSetRegistryFilled_
Definition: Event.h:223
void fillParameterSetRegistry() const
Definition: Event.cc:418

◆ processHistory()

edm::ProcessHistory const& fwlite::Event::processHistory ( ) const
inlineoverridevirtual

Implements edm::EventBase.

Definition at line 184 of file Event.h.

References history().

184 { return history(); }
edm::ProcessHistory const & history() const
Definition: Event.cc:316

◆ scan()

Long64_t Event::scan ( char const *  varexp = "",
char const *  selection = "",
Option_t *  option = "",
Long64_t  nentries = 1000000000,
Long64_t  firstentry = 0 
)

Definition at line 252 of file Event.cc.

References branchMap_, dataHelper_, mps_merge::firstentry, fwlite::BranchMapReader::getEventTree(), fwlite::DataGetterHelper::getter(), fileinputsource_cfi::option, and corrVsCorr::selection.

253  {
254  GetterOperate op(dataHelper_.getter());
255  return branchMap_.getEventTree()->Scan(varexp, selection, option, nentries, firstentry);
256  }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
selection
main part
Definition: corrVsCorr.py:100
TTree const * getEventTree() const
bool firstentry
Definition: mps_merge.py:77
edm::EDProductGetter const * getter() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ setGetter()

void fwlite::Event::setGetter ( std::shared_ptr< edm::EDProductGetter const >  getter)
inlineprivate

Definition at line 200 of file Event.h.

References dataHelper_, and fwlite::DataGetterHelper::setGetter().

200 { return dataHelper_.setGetter(getter); }
fwlite::DataGetterHelper dataHelper_
Definition: Event.h:225
void setGetter(std::shared_ptr< edm::EDProductGetter const > getter)

◆ size()

Long64_t Event::size ( void  ) const

Returns number of events in the file.

Definition at line 258 of file Event.cc.

References branchMap_, and fwlite::BranchMapReader::getEventTree().

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), atEnd(), FWHLTTriggerTableView::fillAverageAcceptFractions(), isValid(), FWFileEntry::openFile(), operator++(), and to().

258 { return branchMap_.getEventTree()->GetEntries(); }
TTree const * getEventTree() const
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ throwProductNotFoundException()

void Event::throwProductNotFoundException ( std::type_info const &  iType,
char const *  iModule,
char const *  iProduct,
char const *  iProcess 
)
static

Definition at line 492 of file Event.cc.

References Exception, and edm::errors::ProductNotFound.

Referenced by fwlite::ChainEvent::throwProductNotFoundException().

495  {
496  edm::TypeID type(iType);
498  << "A branch was found for \n type ='" << type.className() << "'\n module='" << iModule
499  << "'\n productInstance='" << ((nullptr != iProduct) ? iProduct : "") << "'\n process='"
500  << ((nullptr != iProcess) ? iProcess : "")
501  << "'\n"
502  "but no data is available for this Event";
503  }

◆ to() [1/4]

bool Event::to ( Long64_t  iIndex)

Go to the event at index iIndex.

Definition at line 208 of file Event.cc.

References branchMap_, size(), and fwlite::BranchMapReader::updateEvent().

Referenced by FWHLTTriggerTableView::fillAverageAcceptFractions(), FWFileEntry::filterEventsWithCustomParser(), and to().

208  {
209  if (iEntry < size()) {
210  // this is a valid entry
211  return branchMap_.updateEvent(iEntry);
212  }
213  // if we're here, then iEntry was not valid
214  return false;
215  }
bool updateEvent(Long_t eventEntry)
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
Long64_t size() const
Returns number of events in the file.
Definition: Event.cc:258

◆ to() [2/4]

bool Event::to ( const edm::EventID id)

Go to event by Run & Event number.

Definition at line 228 of file Event.cc.

References edmPickEvents::event, edm::EventBase::luminosityBlock(), writedatasetfile::run, and to().

228 { return to(id.run(), id.luminosityBlock(), id.event()); }
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: Event.cc:208

◆ to() [3/4]

bool Event::to ( edm::RunNumber_t  run,
edm::EventNumber_t  event 
)

Definition at line 217 of file Event.cc.

References writedatasetfile::run, to(), and mitigatedMETSequence_cff::U.

217 { return to(run, 0U, event); }
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: Event.cc:208
Definition: event.py:1

◆ to() [4/4]

bool Event::to ( edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi,
edm::EventNumber_t  event 
)

Definition at line 219 of file Event.cc.

References branchMap_, mps_splice::entry, entryFinder_, fwlite::EntryFinder::fillIndex(), fwlite::EntryFinder::findEvent(), fwlite::EntryFinder::invalidEntry, writedatasetfile::run, and fwlite::BranchMapReader::updateEvent().

219  {
223  return false;
224  }
225  return branchMap_.updateEvent(entry);
226  }
EntryNumber_t findEvent(edm::RunNumber_t const &run, edm::LuminosityBlockNumber_t const &lumi, edm::EventNumber_t const &event) const
Definition: EntryFinder.cc:56
bool updateEvent(Long_t eventEntry)
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
void fillIndex(BranchMapReader &branchMap)
Definition: EntryFinder.cc:107
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:41
fwlite::BranchMapReader branchMap_
Definition: Event.h:210
EntryFinder entryFinder_
Definition: Event.h:218
Definition: event.py:1

◆ toBegin()

Event const & Event::toBegin ( )
overridevirtual

Go to the very first Event.

Implements fwlite::EventBase.

Definition at line 230 of file Event.cc.

References branchMap_, and fwlite::BranchMapReader::updateEvent().

Referenced by FWHLTTriggerTableView::fillAverageAcceptFractions(), and FWFileEntry::filterEventsWithCustomParser().

230  {
232  return *this;
233  }
bool updateEvent(Long_t eventEntry)
fwlite::BranchMapReader branchMap_
Definition: Event.h:210

◆ triggerNames()

edm::TriggerNames const & Event::triggerNames ( edm::TriggerResults const &  triggerResults) const
overridevirtual

Implements edm::EventBase.

Definition at line 402 of file Event.cc.

References Exception, fillParameterSetRegistry(), names, parameterSetRegistryFilled_, edm::EventBase::triggerNames_(), and triggerResults.

Referenced by FWHLTTriggerTableView::fillAverageAcceptFractions(), and FWFileEntry::filterEventsWithCustomParser().

402  {
404  if (names != nullptr)
405  return *names;
406 
410  }
411  if (names != nullptr)
412  return *names;
413 
414  throw cms::Exception("TriggerNamesNotFound") << "TriggerNames not found in ParameterSet registry";
415  return *names;
416  }
static TriggerNames const * triggerNames_(edm::TriggerResults const &triggerResults)
Definition: EventBase.cc:45
const std::string names[nVars_]
bool parameterSetRegistryFilled_
Definition: Event.h:223
static std::string const triggerResults
Definition: EdmProvDump.cc:47
void fillParameterSetRegistry() const
Definition: Event.cc:418

◆ triggerResultsByName()

edm::TriggerResultsByName Event::triggerResultsByName ( edm::TriggerResults const &  triggerResults) const
overridevirtual

Implements edm::EventBase.

Definition at line 480 of file Event.cc.

References fillParameterSetRegistry(), names, parameterSetRegistryFilled_, edm::EventBase::triggerNames_(), and triggerResults.

480  {
482  if (names == nullptr && !parameterSetRegistryFilled_) {
485  }
487  }
static TriggerNames const * triggerNames_(edm::TriggerResults const &triggerResults)
Definition: EventBase.cc:45
const std::string names[nVars_]
bool parameterSetRegistryFilled_
Definition: Event.h:223
static std::string const triggerResults
Definition: EdmProvDump.cc:47
void fillParameterSetRegistry() const
Definition: Event.cc:418

◆ updateAux()

void Event::updateAux ( Long_t  eventIndex) const
private

Definition at line 306 of file Event.cc.

References aux_, auxBranch_, edm::conversion(), and pOldAux_.

Referenced by eventAuxiliary(), and history().

306  {
307  if (auxBranch_->GetEntryNumber() != eventIndex) {
308  auxBranch_->GetEntry(eventIndex);
309  //handling dealing with old version
310  if (nullptr != pOldAux_) {
312  }
313  }
314  }
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
edm::EventAuxiliary aux_
Definition: Event.h:217
TBranch * auxBranch_
Definition: Event.h:221
edm::EventAux const * pOldAux_
Definition: Event.h:220

Friends And Related Function Documentation

◆ ChainEvent

friend class ChainEvent
friend

Definition at line 194 of file Event.h.

◆ EventHistoryGetter

friend class EventHistoryGetter
friend

Definition at line 195 of file Event.h.

◆ internal::ProductGetter

friend class internal::ProductGetter
friend

Definition at line 193 of file Event.h.

Member Data Documentation

◆ aux_

edm::EventAuxiliary fwlite::Event::aux_
mutableprivate

Definition at line 217 of file Event.h.

Referenced by eventAuxiliary(), history(), and updateAux().

◆ auxBranch_

TBranch* fwlite::Event::auxBranch_
private

Definition at line 221 of file Event.h.

Referenced by Event(), and updateAux().

◆ branchMap_

fwlite::BranchMapReader fwlite::Event::branchMap_
mutableprivate

◆ dataHelper_

fwlite::DataGetterHelper fwlite::Event::dataHelper_
private

◆ entryFinder_

EntryFinder fwlite::Event::entryFinder_
mutableprivate

Definition at line 218 of file Event.h.

Referenced by indexFromEventId(), and to().

◆ eventHistoryTree_

TTree* fwlite::Event::eventHistoryTree_
private

Definition at line 206 of file Event.h.

Referenced by Event(), and history().

◆ eventProcessHistoryIDs_

std::vector<edm::EventProcessHistoryID> fwlite::Event::eventProcessHistoryIDs_
mutableprivate

Definition at line 215 of file Event.h.

Referenced by history().

◆ file_

TFile* fwlite::Event::file_
mutableprivate

Definition at line 204 of file Event.h.

◆ fileVersion_

int fwlite::Event::fileVersion_
private

Definition at line 222 of file Event.h.

Referenced by Event(), and history().

◆ historyMap_

edm::ProcessHistoryMap fwlite::Event::historyMap_
mutableprivate

Definition at line 214 of file Event.h.

Referenced by history().

◆ labels_

std::vector<char const*> fwlite::Event::labels_
mutableprivate

Definition at line 213 of file Event.h.

Referenced by ~Event().

◆ lumi_

std::shared_ptr<fwlite::LuminosityBlock> fwlite::Event::lumi_
mutableprivate

Definition at line 208 of file Event.h.

Referenced by getLuminosityBlock().

◆ parameterSetRegistryFilled_

bool fwlite::Event::parameterSetRegistryFilled_
mutableprivate

◆ pAux_

edm::EventAuxiliary const* fwlite::Event::pAux_
private

Definition at line 219 of file Event.h.

Referenced by Event().

◆ pOldAux_

edm::EventAux const* fwlite::Event::pOldAux_
private

Definition at line 220 of file Event.h.

Referenced by Event(), updateAux(), and ~Event().

◆ procHistoryNames_

std::vector<std::string> fwlite::Event::procHistoryNames_
mutableprivate

Definition at line 216 of file Event.h.

Referenced by getProcessHistory(), and history().

◆ run_

std::shared_ptr<fwlite::Run> fwlite::Event::run_
mutableprivate

Definition at line 209 of file Event.h.

Referenced by getRun().

◆ runFactory_

std::shared_ptr<RunFactory> fwlite::Event::runFactory_
mutableprivate

Definition at line 226 of file Event.h.

Referenced by Event(), getLuminosityBlock(), and getRun().