CMS 3D CMS Logo

EmbeddedRootSource.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 #include "EmbeddedRootSource.h"
4 #include "InputFile.h"
5 #include "RunHelper.h"
10 
11 namespace edm {
12 
13  class EventID;
14  class EventPrincipal;
15 
18  rootServiceChecker_(),
19  nStreams_(desc.allocations_->numberOfStreams()),
20  // The default value provided as the second argument to the getUntrackedParameter function call
21  // is not used when the ParameterSet has been validated and the parameters are not optional
22  // in the description. This is currently true when PoolSource is the primary input source.
23  // The modules that use PoolSource as a SecSource have not defined their fillDescriptions function
24  // yet, so the ParameterSet does not get validated yet. As soon as all the modules with a SecSource
25  // have defined descriptions, the defaults in the getUntrackedParameterSet function calls can
26  // and should be deleted from the code.
27  //
28  skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
29  bypassVersionCheck_(pset.getUntrackedParameter<bool>("bypassVersionCheck", false)),
30  treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
31  productSelectorRules_(pset, "inputCommands", "InputSource"),
32  runHelper_(new DefaultRunHelper()),
33  catalog_(pset.getUntrackedParameter<std::vector<std::string> >("fileNames"),
34  pset.getUntrackedParameter<std::string>("overrideCatalog", std::string())),
35  // Note: fileSequence_ needs to be initialized last, because it uses data members
36  // initialized previously in its own initialization.
37  fileSequence_(new RootEmbeddedFileSequence(pset, *this, catalog_)) {}
38 
40 
42 
44  fileSequence_->endJob();
46  }
47 
49 
51  size_t& fileNameHash,
52  CLHEP::HepRandomEngine* engine,
53  EventID const* id,
54  bool recycleFiles) {
55  return fileSequence_->readOneEvent(cache, fileNameHash, engine, id, recycleFiles);
56  }
57 
59  size_t& fileNameHash,
60  SecondaryEventIDAndFileInfo const& id) {
61  fileSequence_->readOneSpecified(cache, fileNameHash, id);
62  }
63 
64  void EmbeddedRootSource::dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) {
65  std::vector<std::string> rules;
66  rules.reserve(wantedBranches.size() + 1);
67  rules.emplace_back("drop *");
68  for (std::string const& branch : wantedBranches) {
69  rules.push_back("keep " + branch + "_*");
70  }
72  pset.addUntrackedParameter("inputCommands", rules);
73  productSelectorRules_ = ProductSelectorRules(pset, "inputCommands", "InputSource");
74  }
75 
78 
79  std::vector<std::string> defaultStrings;
80  desc.setComment("Reads EDM/Root files for mixing.");
81  desc.addUntracked<std::vector<std::string> >("fileNames")->setComment("Names of files to be processed.");
82  desc.addUntracked<std::string>("overrideCatalog", std::string());
83  desc.addUntracked<bool>("skipBadFiles", false)
84  ->setComment(
85  "True: Ignore any missing or unopenable input file.\n"
86  "False: Throw exception if missing or unopenable input file.");
87  desc.addUntracked<bool>("bypassVersionCheck", false)
88  ->setComment(
89  "True: Bypass release version check.\n"
90  "False: Throw exception if reading file in a release prior to the release in which the file was written.");
91  desc.addUntracked<int>("treeMaxVirtualSize", -1)
92  ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
93 
96 
97  descriptions.add("source", desc);
98  }
99 } // namespace edm
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id) override
static void fillDescription(ParameterSetDescription &desc, char const *parameterName, std::vector< std::string > const &defaultStrings=defaultSelectionStrings())
bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool recycleFiles) override
static void reportReadBranches()
Definition: InputFile.cc:105
EmbeddedRootSource(ParameterSet const &pset, VectorInputSourceDescription const &desc)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches) override
static void fillDescription(ParameterSetDescription &desc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ProductSelectorRules productSelectorRules_
HLT enums.
def cache(function)
Definition: utilities.py:3
edm::propagate_const< std::unique_ptr< RootEmbeddedFileSequence > > fileSequence_