CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
fwlite::MultiChainEvent Class Reference

#include <MultiChainEvent.h>

Inheritance diagram for fwlite::MultiChainEvent:
fwlite::EventBase edm::EventBase

Public Types

typedef std::pair< edm::EventID, edm::EventIDevent_id_range
 
typedef std::map< edm::EventID, Long64_t > sec_file_index_map
 
typedef std::map< event_id_range, Long64_t > sec_file_range_index_map
 

Public Member Functions

bool atEnd () const override
 
template<typename T >
edm::EDGetTokenT< Tconsumes (edm::InputTag const &iTag) const
 
edm::EventAuxiliary const & eventAuxiliary () const override
 
Long64_t eventIndex () const
 
Long64_t eventIndexSec () const
 
Long64_t fileIndex () const override
 
std::vector< edm::BranchDescription > const & getBranchDescriptions () const
 
std::string const getBranchNameFor (std::type_info const &, char const *, char const *, char const *) const override
 
bool getByLabel (std::type_info const &, char const *, char const *, char const *, void *) const override
 
edm::WrapperBase const * getByProductID (edm::ProductID const &) const override
 
fwlite::LuminosityBlock const & getLuminosityBlock ()
 
std::vector< std::string > const & getProcessHistory () const
 
fwlite::Run const & getRun ()
 
TFile * getTFile () const
 
TFile * getTFileSec () 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
 
bool isValid () const
 
 MultiChainEvent (std::vector< std::string > const &iFileNames1, std::vector< std::string > const &iFileNames2, bool useSecFileMapSorted=false)
 
 operator bool () const
 
const MultiChainEventoperator++ () override
 
edm::ParameterSet const * parameterSet (edm::ParameterSetID const &psID) const override
 
ChainEvent const * primary () const
 
edm::ProcessHistory const & processHistory () const override
 
ChainEvent const * secondary () const
 
Long64_t secondaryFileIndex () const override
 
Long64_t size () const
 
bool to (Long64_t iIndex)
 Go to the event at index iIndex. More...
 
bool to (edm::EventID id)
 Go to event with event id "id". More...
 
bool to (edm::RunNumber_t run, edm::EventNumber_t event)
 Go to event with given run and event number. More...
 
bool to (edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event)
 Go to event with given run , lumi (if non-zero), and event number. More...
 
const MultiChainEventtoBegin () override
 
edm::TriggerNames const & triggerNames (edm::TriggerResults const &triggerResults) const override
 
edm::TriggerResultsByName triggerResultsByName (edm::TriggerResults const &triggerResults) const override
 
 ~MultiChainEvent () override
 
- Public Member Functions inherited from fwlite::EventBase
 EventBase ()
 
 ~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<>
bool getByLabel (edm::InputTag const &tag, Handle< FWGenericObject > &result) const
 Specialize the getByLabel method to work with a Handle<FWGenericObject> More...
 
template<typename T >
bool getByLabel (InputTag const &, Handle< T > &) const
 
template<typename T >
bool getByToken (edm::EDGetTokenT< T > const &token, edm::Handle< T > &result) const
 
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

bool getByTokenImp (edm::EDGetToken, edm::WrapperBase const *&) const override
 
 MultiChainEvent (Event const &)
 
const MultiChainEventoperator= (Event const &)
 
bool toSec (Long64_t iIndex)
 Go to the event from secondary files at index iIndex. More...
 
bool toSec (const edm::EventID &id)
 
bool toSec (edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event)
 Go to event with given run, lumi, and event number. More...
 
bool toSec (edm::RunNumber_t run, edm::EventNumber_t event)
 Go to event with given run and event number. More...
 

Private Attributes

std::shared_ptr< ChainEventevent1_
 
std::shared_ptr< ChainEventevent2_
 
std::shared_ptr< internal::MultiProductGetter const > getter_
 
sec_file_range_index_map secFileMapSorted_
 
bool useSecFileMapSorted_
 

Additional Inherited Members

- Static Protected Member Functions inherited from fwlite::EventBase
template<typename T >
static edm::EDGetTokenT< TmakeTokenUsing (unsigned int iIndex)
 
- 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 50 of file MultiChainEvent.h.

Member Typedef Documentation

◆ event_id_range

Definition at line 53 of file MultiChainEvent.h.

◆ sec_file_index_map

Definition at line 52 of file MultiChainEvent.h.

◆ sec_file_range_index_map

Definition at line 54 of file MultiChainEvent.h.

Constructor & Destructor Documentation

◆ MultiChainEvent() [1/2]

MultiChainEvent::MultiChainEvent ( std::vector< std::string > const &  iFileNames1,
std::vector< std::string > const &  iFileNames2,
bool  useSecFileMapSorted = false 
)

Definition at line 71 of file MultiChainEvent.cc.

References gather_cfg::cout, event1_, event2_, unittestinputsource_cfi::eventRange, getter_, secFileMapSorted_, HLT_2024v12_cff::toAdd, and useSecFileMapSorted_.

73  {
74  event1_ = std::make_shared<ChainEvent>(iFileNames1);
75  event2_ = std::make_shared<ChainEvent>(iFileNames2);
76 
77  getter_ = std::make_shared<internal::MultiProductGetter>(this);
78 
79  if (event1_->size() == 0) {
80  std::cout << "------------------------------------------------------------------------" << std::endl;
81  std::cout << "WARNING! MultiChainEvent: all primary files have zero events." << std::endl;
82  std::cout << "Trying to access the events may lead to a crash. " << std::endl;
83  std::cout << "------------------------------------------------------------------------" << std::endl;
84  } else {
85  event1_->setGetter(getter_);
86  event2_->setGetter(getter_);
87  }
88 
89  useSecFileMapSorted_ = useSecFileMapSorted;
90 
91  if (!useSecFileMapSorted_) {
92  std::cout << "------------------------------------------------------------------------" << std::endl;
93  std::cout << "WARNING! What you are about to do may be very slow." << std::endl;
94  std::cout << "The 2-file solution in FWLite works with very simple assumptions." << std::endl;
95  std::cout << "It will linearly search through the files in the secondary file list for Products." << std::endl;
96  std::cout << "There are speed improvements available to make this run faster." << std::endl;
97  std::cout << "***If your secondary files are sorted with a run-range within a file, (almost always the case) "
98  << std::endl;
99  std::cout << "***please use the option useSecFileMapSorted=true in this constructor. " << std::endl;
100  std::cout << " > usage: MultiChainEvent(primaryFiles, secondaryFiles, true);" << std::endl;
101  std::cout << "------------------------------------------------------------------------" << std::endl;
102  }
103 
104  if (useSecFileMapSorted_) {
105  std::cout << "------------------------------------------------------------------------" << std::endl;
106  std::cout << "This MultiChainEvent is now creating a (run_range)_2 ---> file_index_2 map" << std::endl;
107  std::cout << "for the 2-file solution. " << std::endl;
108  std::cout
109  << "This is assuming the files you are giving me are sorted by run,event pairs within each secondary file."
110  << std::endl;
111  std::cout << "If this is not true (rarely the case), set this option to false." << std::endl;
112  std::cout << " > usage: MultiChainEvent(primaryFiles, secondaryFiles, false);" << std::endl;
113  std::cout << "------------------------------------------------------------------------" << std::endl;
114  // speed up secondary file access with a (run,event)_1 ---> index_2 map
115 
116  // Loop over events, when a new file is encountered, store the first run number from this file,
117  // and the last run number from the last file.
118  TFile* lastFile = nullptr;
119  std::pair<event_id_range, Long64_t> eventRange;
120  bool firstFile = true;
121 
122  bool foundAny = false;
123 
124  for (event2_->toBegin(); !event2_->atEnd(); ++(*event2_)) {
125  // if we have a new file, cache the "first"
126  if (lastFile != event2_->getTFile()) {
127  // if this is not the first file, we have an entry.
128  // Add it to the list.
129  if (!firstFile) {
130  foundAny = true;
133  }
134  // always add the "first" event id to the cached event range
135  eventRange.first.first = event2_->event()->id();
136  lastFile = event2_->getTFile();
137  }
138  // otherwise, cache the "second" event id in the cached event range.
139  // Upon the discovery of a new file, this will be used as the
140  // "last" event id in the cached event range.
141  else {
142  eventRange.first.second = event2_->event()->id();
143  eventRange.second = event2_->eventIndex();
144  }
145  firstFile = false;
146  }
147  // due to the invailability of a "look ahead" operation, we have one additional "put" to make
148  // after the loop (which puts the "last" event, not "this" event.
149  if (foundAny) {
152  }
153  // std::cout << "Dumping run range to event id list:" << std::endl;
154  // for (sec_file_range_index_map::const_iterator mBegin = secFileMapSorted_.begin(),
155  // mEnd = secFileMapSorted_.end(),
156  // mit = mBegin;
157  // mit != mEnd; ++mit) {
158  // char buff[1000];
159  // event2_->to(mit->second);
160  // sprintf(buff, "[%10d,%10d - %10d,%10d] ---> %10d",
161  // mit->first.first.run(),
162  // mit->first.first.event(),
163  // mit->first.second.run(),
164  // mit->first.second.event(),
165  // mit->second);
166  // std::cout << buff << std::endl;
167  // }
168  }
169  }
sec_file_range_index_map secFileMapSorted_
std::shared_ptr< internal::MultiProductGetter const > getter_
std::pair< edm::EventID, edm::EventID > event_id_range
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ ~MultiChainEvent()

MultiChainEvent::~MultiChainEvent ( )
override

Definition at line 176 of file MultiChainEvent.cc.

176 {}

◆ MultiChainEvent() [2/2]

fwlite::MultiChainEvent::MultiChainEvent ( Event const &  )
private

Member Function Documentation

◆ atEnd()

bool MultiChainEvent::atEnd ( ) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 380 of file MultiChainEvent.cc.

References event1_.

380 { return event1_->atEnd(); }
std::shared_ptr< ChainEvent > event1_

◆ consumes()

template<typename T >
edm::EDGetTokenT<T> fwlite::MultiChainEvent::consumes ( edm::InputTag const &  iTag) const
inline

Definition at line 78 of file MultiChainEvent.h.

References event1_, event2_, and submitPVValidationJobs::t.

78  {
79  auto t = event1_->consumes<T>(iTag);
80  if (t) {
81  return t;
82  }
83  return event2_->consumes<T>(iTag);
84  }
std::shared_ptr< ChainEvent > event2_
long double T
std::shared_ptr< ChainEvent > event1_

◆ eventAuxiliary()

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

Implements edm::EventBase.

Definition at line 301 of file MultiChainEvent.cc.

References event1_.

301 { return event1_->eventAuxiliary(); }
std::shared_ptr< ChainEvent > event1_

◆ eventIndex()

Long64_t fwlite::MultiChainEvent::eventIndex ( ) const
inline

Definition at line 106 of file MultiChainEvent.h.

References event1_.

106 { return event1_->eventIndex(); }
std::shared_ptr< ChainEvent > event1_

◆ eventIndexSec()

Long64_t fwlite::MultiChainEvent::eventIndexSec ( ) const
inline

Definition at line 107 of file MultiChainEvent.h.

References event2_.

107 { return event2_->eventIndex(); }
std::shared_ptr< ChainEvent > event2_

◆ fileIndex()

Long64_t fwlite::MultiChainEvent::fileIndex ( ) const
inlineoverridevirtual

Reimplemented from fwlite::EventBase.

Definition at line 113 of file MultiChainEvent.h.

References event1_.

Referenced by python.Events::fileIndicies().

113 { return event1_->eventIndex(); }
std::shared_ptr< ChainEvent > event1_

◆ getBranchDescriptions()

std::vector< edm::BranchDescription > const & MultiChainEvent::getBranchDescriptions ( ) const

Definition at line 293 of file MultiChainEvent.cc.

References event1_.

293  {
294  return event1_->getBranchDescriptions();
295  }
std::shared_ptr< ChainEvent > event1_

◆ getBranchNameFor()

std::string const MultiChainEvent::getBranchNameFor ( std::type_info const &  iType,
char const *  iModule,
char const *  iInstance,
char const *  iProcess 
) const
overridevirtual

Implements fwlite::EventBase.

Definition at line 286 of file MultiChainEvent.cc.

References event1_.

289  {
290  return event1_->getBranchNameFor(iType, iModule, iInstance, iProcess);
291  }
std::shared_ptr< ChainEvent > event1_

◆ getByLabel()

bool MultiChainEvent::getByLabel ( std::type_info const &  iType,
char const *  iModule,
char const *  iInstance,
char const *  iProcess,
void *  iValue 
) const
overridevirtual

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

Implements fwlite::EventBase.

Definition at line 303 of file MultiChainEvent.cc.

References event1_, and event2_.

307  {
308  bool ret1 = event1_->getByLabel(iType, iModule, iInstance, iProcess, iValue);
309  if (!ret1) {
310  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
311  bool ret2 = event2_->getByLabel(iType, iModule, iInstance, iProcess, iValue);
312  if (!ret2)
313  return false;
314  }
315  return true;
316  }
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ getByProductID()

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

Implements fwlite::EventBase.

Definition at line 329 of file MultiChainEvent.cc.

References event1_, and event2_.

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

329  {
330  // First try the first file
331  edm::WrapperBase const* edp = event1_->getByProductID(iID);
332  // Did not find the product, try secondary file
333  if (edp == nullptr) {
334  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
335  edp = event2_->getByProductID(iID);
336  }
337  return edp;
338  }
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ getByTokenImp()

bool MultiChainEvent::getByTokenImp ( edm::EDGetToken  iToken,
edm::WrapperBase const *&  iValue 
) const
overrideprivatevirtual

Implements fwlite::EventBase.

Definition at line 318 of file MultiChainEvent.cc.

References event1_, and event2_.

318  {
319  bool ret1 = event1_->getByTokenImp(iToken, iValue);
320  if (!ret1) {
321  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
322  bool ret2 = event2_->getByTokenImp(iToken, iValue);
323  if (!ret2)
324  return false;
325  }
326  return true;
327  }
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ getLuminosityBlock()

fwlite::LuminosityBlock const& fwlite::MultiChainEvent::getLuminosityBlock ( )
inline

Definition at line 109 of file MultiChainEvent.h.

References event1_.

109 { return event1_->getLuminosityBlock(); }
std::shared_ptr< ChainEvent > event1_

◆ getProcessHistory()

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

Definition at line 297 of file MultiChainEvent.cc.

References event1_.

297 { return event1_->getProcessHistory(); }
std::shared_ptr< ChainEvent > event1_

◆ getRun()

fwlite::Run const& fwlite::MultiChainEvent::getRun ( )
inline

Definition at line 111 of file MultiChainEvent.h.

References event1_.

111 { return event1_->getRun(); }
std::shared_ptr< ChainEvent > event1_

◆ getTFile()

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

Definition at line 103 of file MultiChainEvent.h.

References event1_.

103 { return event1_->getTFile(); }
std::shared_ptr< ChainEvent > event1_

◆ getTFileSec()

TFile* fwlite::MultiChainEvent::getTFileSec ( ) const
inline

Definition at line 104 of file MultiChainEvent.h.

References event2_.

104 { return event2_->getTFile(); }
std::shared_ptr< ChainEvent > event2_

◆ getThinnedKeyFrom()

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

Definition at line 364 of file MultiChainEvent.cc.

References event1_, event2_, submitPVResolutionJobs::key, and class-composition::parent.

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

366  {
367  // First try the first file
368  auto edp = event1_->getThinnedKeyFrom(parent, key, thinned);
369  // Did not find the product, try secondary file
370  if (std::holds_alternative<std::monostate>(edp)) {
371  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
372  edp = event2_->getThinnedKeyFrom(parent, key, thinned);
373  }
374  return edp;
375  }
key
prepare the HTCondor submission files and eventually submit them
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ getThinnedProduct()

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

Definition at line 340 of file MultiChainEvent.cc.

References event1_, event2_, and submitPVResolutionJobs::key.

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

341  {
342  // First try the first file
343  auto edp = event1_->getThinnedProduct(pid, key);
344  // Did not find the product, try secondary file
345  if (not edp.has_value()) {
346  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
347  edp = event2_->getThinnedProduct(pid, key);
348  }
349  return edp;
350  }
key
prepare the HTCondor submission files and eventually submit them
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ getThinnedProducts()

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

Definition at line 352 of file MultiChainEvent.cc.

References event1_, event2_, spr::find(), and relativeConstraints::keys.

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

354  {
355  // First try the first file
356  event1_->getThinnedProducts(pid, wrappers, keys);
357  // Did not find all the products, try secondary file
358  if (std::find(wrappers.begin(), wrappers.end(), nullptr) != wrappers.end()) {
359  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
360  event2_->getThinnedProducts(pid, wrappers, keys);
361  }
362  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ isValid()

bool MultiChainEvent::isValid ( void  ) const

Definition at line 377 of file MultiChainEvent.cc.

References event1_.

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

377 { return event1_->isValid(); }
std::shared_ptr< ChainEvent > event1_

◆ operator bool()

MultiChainEvent::operator bool ( ) const

Definition at line 378 of file MultiChainEvent.cc.

378 { return *event1_; }
std::shared_ptr< ChainEvent > event1_

◆ operator++()

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

Implements fwlite::EventBase.

Definition at line 194 of file MultiChainEvent.cc.

References event1_.

194  {
195  event1_->operator++();
196  return *this;
197  }
std::shared_ptr< ChainEvent > event1_

◆ operator=()

const MultiChainEvent& fwlite::MultiChainEvent::operator= ( Event const &  )
private

◆ parameterSet()

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

Implements edm::EventBase.

Definition at line 423 of file MultiChainEvent.cc.

References event1_, event2_, and muonDTDigis_cfi::pset.

423  {
424  auto pset = event1_->parameterSet(psID);
425  if (nullptr == pset) {
426  pset = event2_->parameterSet(psID);
427  }
428  return pset;
429  }
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ primary()

ChainEvent const* fwlite::MultiChainEvent::primary ( ) const
inline

Definition at line 125 of file MultiChainEvent.h.

References event1_.

125 { return &*event1_; }
std::shared_ptr< ChainEvent > event1_

◆ processHistory()

edm::ProcessHistory const & MultiChainEvent::processHistory ( ) const
overridevirtual

Implements edm::EventBase.

Definition at line 299 of file MultiChainEvent.cc.

References event1_.

299 { return event1_->processHistory(); }
std::shared_ptr< ChainEvent > event1_

◆ secondary()

ChainEvent const* fwlite::MultiChainEvent::secondary ( ) const
inline

Definition at line 126 of file MultiChainEvent.h.

References event2_.

126 { return &*event2_; }
std::shared_ptr< ChainEvent > event2_

◆ secondaryFileIndex()

Long64_t fwlite::MultiChainEvent::secondaryFileIndex ( ) const
inlineoverridevirtual

Reimplemented from fwlite::EventBase.

Definition at line 114 of file MultiChainEvent.h.

References event2_.

Referenced by python.Events::fileIndicies().

114 { return event2_->eventIndex(); }
std::shared_ptr< ChainEvent > event2_

◆ size()

Long64_t MultiChainEvent::size ( void  ) const

Definition at line 382 of file MultiChainEvent.cc.

References event1_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

382 { return event1_->size(); }
std::shared_ptr< ChainEvent > event1_

◆ throwProductNotFoundException()

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

Definition at line 433 of file MultiChainEvent.cc.

References fwlite::ChainEvent::throwProductNotFoundException().

436  {
437  ChainEvent::throwProductNotFoundException(iType, iModule, iInstance, iProcess);
438  }
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:276

◆ to() [1/4]

bool MultiChainEvent::to ( Long64_t  iIndex)

Go to the event at index iIndex.

Definition at line 200 of file MultiChainEvent.cc.

References event1_.

Referenced by to().

200 { return event1_->to(iIndex); }
std::shared_ptr< ChainEvent > event1_

◆ to() [2/4]

bool MultiChainEvent::to ( edm::EventID  id)

Go to event with event id "id".

Definition at line 203 of file MultiChainEvent.cc.

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

203 { return to(id.run(), id.luminosityBlock(), id.event()); }
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:65
bool to(Long64_t iIndex)
Go to the event at index iIndex.

◆ to() [3/4]

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

Go to event with given run and event number.

Definition at line 211 of file MultiChainEvent.cc.

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

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

◆ to() [4/4]

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

Go to event with given run , lumi (if non-zero), and event number.

Definition at line 206 of file MultiChainEvent.cc.

References event1_, and writedatasetfile::run.

206  {
207  return event1_->to(run, lumi, event);
208  }
Definition: event.py:1
std::shared_ptr< ChainEvent > event1_

◆ toBegin()

const MultiChainEvent & MultiChainEvent::toBegin ( )
overridevirtual

Implements fwlite::EventBase.

Definition at line 278 of file MultiChainEvent.cc.

References event1_.

278  {
279  event1_->toBegin();
280  return *this;
281  }
std::shared_ptr< ChainEvent > event1_

◆ toSec() [1/4]

bool MultiChainEvent::toSec ( Long64_t  iIndex)
private

Go to the event from secondary files at index iIndex.

Go to the event at index iIndex.

Definition at line 214 of file MultiChainEvent.cc.

References event2_.

Referenced by toSec().

214 { return event2_->to(iIndex); }
std::shared_ptr< ChainEvent > event2_

◆ toSec() [2/4]

bool MultiChainEvent::toSec ( const edm::EventID id)
private

Definition at line 217 of file MultiChainEvent.cc.

References event2_, Exception, dqmdumpme::first, and secFileMapSorted_.

217  {
218  // First try this file.
219  if (event2_->event_->to(id)) {
220  // Found it, return.
221  return true;
222  }
223  // Second, assume that the secondary files are each in run/event
224  // order. So, let's loop over all files and see if we can figure
225  // out where the event ought to be.
226  for (sec_file_range_index_map::const_iterator mBegin = secFileMapSorted_.begin(),
227  mEnd = secFileMapSorted_.end(),
228  mit = mBegin;
229  mit != mEnd;
230  ++mit) {
231  if (id < mit->first.first || id > mit->first.second) {
232  // We don't expect this event to be in this file, so don't
233  // bother checking it right now.
234  continue;
235  }
236  // If we're here, then we have a reasonable belief that this
237  // event is in this secondary file. This part is
238  // expensive. switchToFile does memory allocations and opens the
239  // files which becomes very time consuming. This should be done
240  // as infrequently as possible.
241  event2_->switchToFile(mit->second);
242  // Is it here?
243  if (event2_->to(id)) {
244  // Yes!
245  return true;
246  }
247  // if we assumed that the secondary files were not each in
248  // order, but were non-overlapping, we could break here. But at
249  // this point, we might as well keep going.
250  } // for loop over files
251 
252  // if we are still here, then we did not find the id in question,
253  // do it the old fashioned way. This will open up each secondary
254  // file and explicitly check to see if the event is there.
255  if (event2_->to(id)) {
256  return true;
257  }
258  // if we're still here, then there really is no matching event in
259  // the secondary files. Throw.
260  throw cms::Exception("ProductNotFound")
261  << "Cannot find id " << id.run() << ", " << id.event() << " in secondary list. Exiting." << std::endl;
262  // to make the compiler happy
263  return false;
264  }
sec_file_range_index_map secFileMapSorted_
std::shared_ptr< ChainEvent > event2_

◆ toSec() [3/4]

bool MultiChainEvent::toSec ( edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi,
edm::EventNumber_t  event 
)
private

Go to event with given run, lumi, and event number.

Definition at line 267 of file MultiChainEvent.cc.

References writedatasetfile::run, and toSec().

267  {
268  return toSec(edm::EventID(run, lumi, event));
269  }
bool toSec(Long64_t iIndex)
Go to the event from secondary files at index iIndex.
Definition: event.py:1

◆ toSec() [4/4]

bool MultiChainEvent::toSec ( edm::RunNumber_t  run,
edm::EventNumber_t  event 
)
private

Go to event with given run and event number.

Definition at line 273 of file MultiChainEvent.cc.

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

273  {
274  return toSec(edm::EventID(run, 0U, event));
275  }
bool toSec(Long64_t iIndex)
Go to the event from secondary files at index iIndex.
Definition: event.py:1

◆ triggerNames()

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

Implements edm::EventBase.

Definition at line 384 of file MultiChainEvent.cc.

References event1_, event2_, Exception, names, edm::EventBase::triggerNames_(), and triggerResults.

384  {
386  if (names != nullptr)
387  return *names;
388 
389  event1_->fillParameterSetRegistry();
391  if (names != nullptr)
392  return *names;
393 
394  // If we cannot find it in the primary file, this probably will
395  // not help but try anyway
396  event2_->to(event1_->id());
397  event2_->fillParameterSetRegistry();
399  if (names != nullptr)
400  return *names;
401 
402  throw cms::Exception("TriggerNamesNotFound") << "TriggerNames not found in ParameterSet registry";
403  return *names;
404  }
static TriggerNames const * triggerNames_(edm::TriggerResults const &triggerResults)
Definition: EventBase.cc:45
const std::string names[nVars_]
static std::string const triggerResults
Definition: EdmProvDump.cc:47
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ triggerResultsByName()

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

Implements edm::EventBase.

Definition at line 406 of file MultiChainEvent.cc.

References event1_, event2_, names, edm::EventBase::triggerNames_(), and triggerResults.

406  {
408 
409  if (names == nullptr) {
410  event1_->fillParameterSetRegistry();
412  }
413 
414  if (names == nullptr) {
415  event2_->to(event1_->id());
416  event2_->fillParameterSetRegistry();
418  }
419 
421  }
static TriggerNames const * triggerNames_(edm::TriggerResults const &triggerResults)
Definition: EventBase.cc:45
const std::string names[nVars_]
static std::string const triggerResults
Definition: EdmProvDump.cc:47
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

Member Data Documentation

◆ event1_

std::shared_ptr<ChainEvent> fwlite::MultiChainEvent::event1_
private

◆ event2_

std::shared_ptr<ChainEvent> fwlite::MultiChainEvent::event2_
private

◆ getter_

std::shared_ptr<internal::MultiProductGetter const> fwlite::MultiChainEvent::getter_
private

Definition at line 162 of file MultiChainEvent.h.

Referenced by MultiChainEvent().

◆ secFileMapSorted_

sec_file_range_index_map fwlite::MultiChainEvent::secFileMapSorted_
private

Definition at line 169 of file MultiChainEvent.h.

Referenced by MultiChainEvent(), and toSec().

◆ useSecFileMapSorted_

bool fwlite::MultiChainEvent::useSecFileMapSorted_
private

Definition at line 168 of file MultiChainEvent.h.

Referenced by MultiChainEvent().