CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::EventID
event_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

Definition at line 53 of file MultiChainEvent.h.

Definition at line 52 of file MultiChainEvent.h.

Definition at line 54 of file MultiChainEvent.h.

Constructor & Destructor Documentation

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_FULL_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;
131  event_id_range toAdd = eventRange.first;
132  secFileMapSorted_[toAdd] = eventRange.second;
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) {
150  event_id_range toAdd = eventRange.first;
151  secFileMapSorted_[toAdd] = eventRange.second;
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_
tuple cout
Definition: gather_cfg.py:144
std::shared_ptr< ChainEvent > event1_
MultiChainEvent::~MultiChainEvent ( )
override

Definition at line 176 of file MultiChainEvent.cc.

176 {}
fwlite::MultiChainEvent::MultiChainEvent ( Event const &  )
private

Member Function Documentation

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_
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_
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_
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_
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_
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_
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_
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_
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_
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_
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_
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_
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_
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_
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_, and event2_.

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  }
tuple key
prepare the HTCondor submission files and eventually submit them
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_
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_, and event2_.

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  }
tuple key
prepare the HTCondor submission files and eventually submit them
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_
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_, and spr::find().

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_
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_
MultiChainEvent::operator bool ( ) const

Definition at line 367 of file MultiChainEvent.cc.

367 { return *event1_; }
std::shared_ptr< ChainEvent > event1_
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_
const MultiChainEvent& fwlite::MultiChainEvent::operator= ( Event const &  )
private
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 TrackValidation_cff::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_
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_
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_
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_
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_
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_
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
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_
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(), submitPVValidationJobs::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.
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 to().

211 { return to(run, 0U, event); }
bool to(Long64_t iIndex)
Go to the event at index iIndex.
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_.

206  {
207  return event1_->to(run, lumi, event);
208  }
list lumi
Definition: dqmdumpme.py:53
std::shared_ptr< ChainEvent > event1_
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_
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_
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_
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 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.
list lumi
Definition: dqmdumpme.py:53
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 toSec().

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.
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, and edm::EventBase::triggerNames_().

373  {
375  if (names != nullptr)
376  return *names;
377 
378  event1_->fillParameterSetRegistry();
379  names = triggerNames_(triggerResults);
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();
387  names = triggerNames_(triggerResults);
388  if (names != nullptr)
389  return *names;
390 
391  throw cms::Exception("TriggerNamesNotFound") << "TriggerNames not found in ParameterSet registry";
392  return *names;
393  }
const std::string names[nVars_]
static std::string const triggerResults
Definition: EdmProvDump.cc:44
static TriggerNames const * triggerNames_(edm::TriggerResults const &triggerResults)
Definition: EventBase.cc:45
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_
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, and edm::EventBase::triggerNames_().

395  {
397 
398  if (names == nullptr) {
399  event1_->fillParameterSetRegistry();
400  names = triggerNames_(triggerResults);
401  }
402 
403  if (names == nullptr) {
404  event2_->to(event1_->id());
405  event2_->fillParameterSetRegistry();
406  names = triggerNames_(triggerResults);
407  }
408 
410  }
const std::string names[nVars_]
static std::string const triggerResults
Definition: EdmProvDump.cc:44
static TriggerNames const * triggerNames_(edm::TriggerResults const &triggerResults)
Definition: EventBase.cc:45
std::shared_ptr< ChainEvent > event2_
std::shared_ptr< ChainEvent > event1_

Member Data Documentation

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

Definition at line 152 of file MultiChainEvent.h.

Referenced by MultiChainEvent().

sec_file_range_index_map fwlite::MultiChainEvent::secFileMapSorted_
private

Definition at line 159 of file MultiChainEvent.h.

Referenced by MultiChainEvent(), and toSec().

bool fwlite::MultiChainEvent::useSecFileMapSorted_
private

Definition at line 158 of file MultiChainEvent.h.

Referenced by MultiChainEvent().