File indexing completed on 2024-04-06 12:19:05
0001
0002
0003 #include "EmbeddedRootSource.h"
0004 #include "InputFile.h"
0005 #include "RunHelper.h"
0006 #include "RootEmbeddedFileSequence.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 #include "FWCore/Sources/interface/VectorInputSourceDescription.h"
0010
0011 namespace edm {
0012
0013 class EventID;
0014 class EventPrincipal;
0015
0016 EmbeddedRootSource::EmbeddedRootSource(ParameterSet const& pset, VectorInputSourceDescription const& desc)
0017 : VectorInputSource(pset, desc),
0018 rootServiceChecker_(),
0019 nStreams_(desc.allocations_->numberOfStreams()),
0020
0021
0022
0023
0024
0025
0026
0027
0028 skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
0029 bypassVersionCheck_(pset.getUntrackedParameter<bool>("bypassVersionCheck", false)),
0030 treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
0031 productSelectorRules_(pset, "inputCommands", "InputSource"),
0032 runHelper_(new DefaultRunHelper()),
0033 catalog_(pset.getUntrackedParameter<std::vector<std::string> >("fileNames"),
0034 pset.getUntrackedParameter<std::string>("overrideCatalog", std::string())),
0035
0036
0037 fileSequence_(new RootEmbeddedFileSequence(pset, *this, catalog_)) {}
0038
0039 EmbeddedRootSource::~EmbeddedRootSource() {}
0040
0041 void EmbeddedRootSource::beginJob() {}
0042
0043 void EmbeddedRootSource::endJob() {
0044 fileSequence_->endJob();
0045 InputFile::reportReadBranches();
0046 }
0047
0048 void EmbeddedRootSource::closeFile_() { fileSequence_->closeFile(); }
0049
0050 bool EmbeddedRootSource::readOneEvent(EventPrincipal& cache,
0051 size_t& fileNameHash,
0052 CLHEP::HepRandomEngine* engine,
0053 EventID const* id,
0054 bool recycleFiles) {
0055 return fileSequence_->readOneEvent(cache, fileNameHash, engine, id, recycleFiles);
0056 }
0057
0058 void EmbeddedRootSource::readOneSpecified(EventPrincipal& cache,
0059 size_t& fileNameHash,
0060 SecondaryEventIDAndFileInfo const& id) {
0061 fileSequence_->readOneSpecified(cache, fileNameHash, id);
0062 }
0063
0064 void EmbeddedRootSource::dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) {
0065 std::vector<std::string> rules;
0066 rules.reserve(wantedBranches.size() + 1);
0067 rules.emplace_back("drop *");
0068 for (std::string const& branch : wantedBranches) {
0069 rules.push_back("keep " + branch + "_*");
0070 }
0071 ParameterSet pset;
0072 pset.addUntrackedParameter("inputCommands", rules);
0073 productSelectorRules_ = ProductSelectorRules(pset, "inputCommands", "InputSource");
0074 }
0075
0076 void EmbeddedRootSource::fillDescriptions(ConfigurationDescriptions& descriptions) {
0077 ParameterSetDescription desc;
0078
0079 std::vector<std::string> defaultStrings;
0080 desc.setComment("Reads EDM/Root files for mixing.");
0081 desc.addUntracked<std::vector<std::string> >("fileNames")->setComment("Names of files to be processed.");
0082 desc.addUntracked<std::string>("overrideCatalog", std::string());
0083 desc.addUntracked<bool>("skipBadFiles", false)
0084 ->setComment(
0085 "True: Ignore any missing or unopenable input file.\n"
0086 "False: Throw exception if missing or unopenable input file.");
0087 desc.addUntracked<bool>("bypassVersionCheck", false)
0088 ->setComment(
0089 "True: Bypass release version check.\n"
0090 "False: Throw exception if reading file in a release prior to the release in which the file was written.");
0091 desc.addUntracked<int>("treeMaxVirtualSize", -1)
0092 ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
0093
0094 ProductSelectorRules::fillDescription(desc, "inputCommands");
0095 RootEmbeddedFileSequence::fillDescription(desc);
0096
0097 descriptions.add("source", desc);
0098 }
0099 }