41 std::vector<edm::WrapperBase const*>& foundContainers,
42 std::vector<unsigned int>&
keys)
const override {
65 std::vector<std::string>
const& iFileNames2,
66 bool useSecFileMapSorted) {
67 event1_ = std::make_shared<ChainEvent>(iFileNames1);
68 event2_ = std::make_shared<ChainEvent>(iFileNames2);
70 getter_ = std::make_shared<internal::MultiProductGetter>(
this);
72 if (event1_->size() == 0) {
73 std::cout <<
"------------------------------------------------------------------------" << std::endl;
74 std::cout <<
"WARNING! MultiChainEvent: all primary files have zero events." << std::endl;
75 std::cout <<
"Trying to access the events may lead to a crash. " << std::endl;
76 std::cout <<
"------------------------------------------------------------------------" << std::endl;
78 event1_->setGetter(getter_);
79 event2_->setGetter(getter_);
82 useSecFileMapSorted_ = useSecFileMapSorted;
84 if (!useSecFileMapSorted_) {
85 std::cout <<
"------------------------------------------------------------------------" << std::endl;
86 std::cout <<
"WARNING! What you are about to do may be very slow." << std::endl;
87 std::cout <<
"The 2-file solution in FWLite works with very simple assumptions." << std::endl;
88 std::cout <<
"It will linearly search through the files in the secondary file list for Products." << std::endl;
89 std::cout <<
"There are speed improvements available to make this run faster." << std::endl;
90 std::cout <<
"***If your secondary files are sorted with a run-range within a file, (almost always the case) " 92 std::cout <<
"***please use the option useSecFileMapSorted=true in this constructor. " << std::endl;
93 std::cout <<
" > usage: MultiChainEvent(primaryFiles, secondaryFiles, true);" << std::endl;
94 std::cout <<
"------------------------------------------------------------------------" << std::endl;
97 if (useSecFileMapSorted_) {
98 std::cout <<
"------------------------------------------------------------------------" << std::endl;
99 std::cout <<
"This MultiChainEvent is now creating a (run_range)_2 ---> file_index_2 map" << std::endl;
100 std::cout <<
"for the 2-file solution. " << std::endl;
102 <<
"This is assuming the files you are giving me are sorted by run,event pairs within each secondary file." 104 std::cout <<
"If this is not true (rarely the case), set this option to false." << std::endl;
105 std::cout <<
" > usage: MultiChainEvent(primaryFiles, secondaryFiles, false);" << std::endl;
106 std::cout <<
"------------------------------------------------------------------------" << std::endl;
111 TFile* lastFile =
nullptr;
112 std::pair<event_id_range, Long64_t> eventRange;
113 bool firstFile =
true;
115 bool foundAny =
false;
117 for (event2_->toBegin(); !event2_->atEnd(); ++(*event2_)) {
119 if (lastFile != event2_->getTFile()) {
125 secFileMapSorted_[
toAdd] = eventRange.second;
128 eventRange.first.first = event2_->event()->id();
129 lastFile = event2_->getTFile();
135 eventRange.first.second = event2_->event()->id();
136 eventRange.second = event2_->eventIndex();
144 secFileMapSorted_[
toAdd] = eventRange.second;
188 event1_->operator++();
200 return event1_->to(run, lumi, event);
212 if (event2_->event_->to(
id)) {
219 for (sec_file_range_index_map::const_iterator mBegin = secFileMapSorted_.begin(),
220 mEnd = secFileMapSorted_.end(),
224 if (id < mit->
first.first ||
id > mit->first.second) {
234 event2_->switchToFile(mit->second);
236 if (event2_->to(
id)) {
248 if (event2_->to(
id)) {
254 <<
"Cannot find id " <<
id.run() <<
", " <<
id.event() <<
" in secondary list. Exiting." << std::endl;
281 char const* iInstance,
282 char const* iProcess)
const {
283 return event1_->getBranchNameFor(iType, iModule, iInstance, iProcess);
287 return event1_->getBranchDescriptions();
298 char const* iInstance,
299 char const* iProcess,
300 void* iValue)
const {
301 bool ret1 = event1_->getByLabel(iType, iModule, iInstance, iProcess, iValue);
304 bool ret2 = event2_->getByLabel(iType, iModule, iInstance, iProcess, iValue);
315 if (edp ==
nullptr) {
317 edp = event2_->getByProductID(iID);
326 if (edp ==
nullptr) {
328 edp = event2_->getThinnedProduct(pid, key);
334 std::vector<edm::WrapperBase const*>& wrappers,
335 std::vector<unsigned int>&
keys)
const {
337 event1_->getThinnedProducts(pid, wrappers, keys);
339 if (
std::find(wrappers.begin(), wrappers.end(),
nullptr) != wrappers.end()) {
341 event2_->getThinnedProducts(pid, wrappers, keys);
354 if (names !=
nullptr)
357 event1_->fillParameterSetRegistry();
358 names = triggerNames_(triggerResults);
359 if (names !=
nullptr)
364 event2_->to(event1_->id());
365 event2_->fillParameterSetRegistry();
366 names = triggerNames_(triggerResults);
367 if (names !=
nullptr)
370 throw cms::Exception(
"TriggerNamesNotFound") <<
"TriggerNames not found in ParameterSet registry";
377 if (names ==
nullptr) {
378 event1_->fillParameterSetRegistry();
379 names = triggerNames_(triggerResults);
382 if (names ==
nullptr) {
383 event2_->to(event1_->id());
384 event2_->fillParameterSetRegistry();
385 names = triggerNames_(triggerResults);
392 auto pset = event1_->parameterSet(psID);
393 if (
nullptr ==
pset) {
394 pset = event2_->parameterSet(psID);
403 char const* iInstance,
404 char const* iProcess) {
const MultiChainEvent & toBegin() override
edm::EventAuxiliary const & eventAuxiliary() const override
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
MultiProductGetter(MultiChainEvent const *iEvent)
MultiChainEvent const * event_
unsigned long long EventNumber_t
~MultiChainEvent() override
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned int LuminosityBlockNumber_t
const std::string names[nVars_]
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
bool to(Long64_t iIndex)
Go to the event at index iIndex.
bool toSec(Long64_t iIndex)
Go to the event from secondary files at index iIndex.
edm::WrapperBase const * getByProductID(edm::ProductID const &) const override
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &pid, unsigned int &key) const
std::vector< std::string > const & getProcessHistory() const
std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const override
static void throwProductNotFoundException(std::type_info const &, char const *, char const *, char const *)
static std::string const triggerResults
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const override
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
void getThinnedProducts(edm::ProductID const &pid, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const
bool atEnd() const override
bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *) const override
MultiChainEvent(std::vector< std::string > const &iFileNames1, std::vector< std::string > const &iFileNames2, bool useSecFileMapSorted=false)
std::pair< edm::EventID, edm::EventID > event_id_range
const MultiChainEvent & operator++() override
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
edm::WrapperBase const * getIt(edm::ProductID const &iID) const override
edm::ParameterSet const * parameterSet(edm::ParameterSetID const &psID) const override
unsigned int transitionIndex_() const override
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &pid, unsigned int &key) const override
edm::ProcessHistory const & processHistory() const override