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
 
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<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

 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 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_2022v12_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 369 of file MultiChainEvent.cc.

References event1_.

369 { return event1_->atEnd(); }
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 98 of file MultiChainEvent.h.

References event1_.

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

◆ eventIndexSec()

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

Definition at line 99 of file MultiChainEvent.h.

References event2_.

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

◆ fileIndex()

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

Reimplemented from fwlite::EventBase.

Definition at line 105 of file MultiChainEvent.h.

References event1_.

Referenced by python.Events::fileIndicies().

105 { 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 318 of file MultiChainEvent.cc.

References event1_, and event2_.

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

318  {
319  // First try the first file
320  edm::WrapperBase const* edp = event1_->getByProductID(iID);
321  // Did not find the product, try secondary file
322  if (edp == nullptr) {
323  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
324  edp = event2_->getByProductID(iID);
325  }
326  return edp;
327  }
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ getLuminosityBlock()

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

Definition at line 101 of file MultiChainEvent.h.

References event1_.

101 { 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 103 of file MultiChainEvent.h.

References event1_.

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

◆ getTFile()

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

Definition at line 95 of file MultiChainEvent.h.

References event1_.

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

◆ getTFileSec()

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

Definition at line 96 of file MultiChainEvent.h.

References event2_.

96 { 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 353 of file MultiChainEvent.cc.

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

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

355  {
356  // First try the first file
357  auto edp = event1_->getThinnedKeyFrom(parent, key, thinned);
358  // Did not find the product, try secondary file
359  if (std::holds_alternative<std::monostate>(edp)) {
360  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
361  edp = event2_->getThinnedKeyFrom(parent, key, thinned);
362  }
363  return edp;
364  }
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 329 of file MultiChainEvent.cc.

References event1_, event2_, and crabWrapper::key.

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

330  {
331  // First try the first file
332  auto edp = event1_->getThinnedProduct(pid, key);
333  // Did not find the product, try secondary file
334  if (not edp.has_value()) {
335  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
336  edp = event2_->getThinnedProduct(pid, key);
337  }
338  return edp;
339  }
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 341 of file MultiChainEvent.cc.

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

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

343  {
344  // First try the first file
345  event1_->getThinnedProducts(pid, wrappers, keys);
346  // Did not find all the products, try secondary file
347  if (std::find(wrappers.begin(), wrappers.end(), nullptr) != wrappers.end()) {
348  (const_cast<MultiChainEvent*>(this))->toSec(event1_->id());
349  event2_->getThinnedProducts(pid, wrappers, keys);
350  }
351  }
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 366 of file MultiChainEvent.cc.

References event1_.

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

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

◆ operator bool()

MultiChainEvent::operator bool ( ) const

Definition at line 367 of file MultiChainEvent.cc.

367 { 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 412 of file MultiChainEvent.cc.

References event1_, event2_, and muonDTDigis_cfi::pset.

412  {
413  auto pset = event1_->parameterSet(psID);
414  if (nullptr == pset) {
415  pset = event2_->parameterSet(psID);
416  }
417  return pset;
418  }
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

◆ primary()

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

Definition at line 117 of file MultiChainEvent.h.

References event1_.

117 { 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 118 of file MultiChainEvent.h.

References event2_.

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

◆ secondaryFileIndex()

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

Reimplemented from fwlite::EventBase.

Definition at line 106 of file MultiChainEvent.h.

References event2_.

Referenced by python.Events::fileIndicies().

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

◆ size()

Long64_t MultiChainEvent::size ( void  ) const

Definition at line 371 of file MultiChainEvent.cc.

References event1_.

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

371 { 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 422 of file MultiChainEvent.cc.

References fwlite::ChainEvent::throwProductNotFoundException().

425  {
426  ChainEvent::throwProductNotFoundException(iType, iModule, iInstance, iProcess);
427  }
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
Definition: ChainEvent.cc:272

◆ 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:61
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, 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 373 of file MultiChainEvent.cc.

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

373  {
375  if (names != nullptr)
376  return *names;
377 
378  event1_->fillParameterSetRegistry();
380  if (names != nullptr)
381  return *names;
382 
383  // If we cannot find it in the primary file, this probably will
384  // not help but try anyway
385  event2_->to(event1_->id());
386  event2_->fillParameterSetRegistry();
388  if (names != nullptr)
389  return *names;
390 
391  throw cms::Exception("TriggerNamesNotFound") << "TriggerNames not found in ParameterSet registry";
392  return *names;
393  }
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:44
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 395 of file MultiChainEvent.cc.

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

395  {
397 
398  if (names == nullptr) {
399  event1_->fillParameterSetRegistry();
401  }
402 
403  if (names == nullptr) {
404  event2_->to(event1_->id());
405  event2_->fillParameterSetRegistry();
407  }
408 
410  }
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:44
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 152 of file MultiChainEvent.h.

Referenced by MultiChainEvent().

◆ secFileMapSorted_

sec_file_range_index_map fwlite::MultiChainEvent::secFileMapSorted_
private

Definition at line 159 of file MultiChainEvent.h.

Referenced by MultiChainEvent(), and toSec().

◆ useSecFileMapSorted_

bool fwlite::MultiChainEvent::useSecFileMapSorted_
private

Definition at line 158 of file MultiChainEvent.h.

Referenced by MultiChainEvent().