CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17  : VectorInputSource(pset, desc),
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 
50  bool
51  EmbeddedRootSource::readOneEvent(EventPrincipal& cache, size_t& fileNameHash, CLHEP::HepRandomEngine* engine, EventID const* id) {
52  return fileSequence_->readOneEvent(cache, fileNameHash, engine, id);
53  }
54 
56  size_t& fileNameHash,
57  SecondaryEventIDAndFileInfo const& id) {
58  fileSequence_->readOneSpecified(cache, fileNameHash, id);
59  }
60 
61  void EmbeddedRootSource::dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) {
62  std::vector<std::string> rules;
63  rules.reserve(wantedBranches.size() + 1);
64  rules.emplace_back("drop *");
65  for (std::string const& branch : wantedBranches) {
66  rules.push_back("keep " + branch + "_*");
67  }
69  pset.addUntrackedParameter("inputCommands", rules);
70  productSelectorRules_ = ProductSelectorRules(pset, "inputCommands", "InputSource");
71  }
72 
75 
76  std::vector<std::string> defaultStrings;
77  desc.setComment("Reads EDM/Root files for mixing.");
78  desc.addUntracked<std::vector<std::string> >("fileNames")->setComment("Names of files to be processed.");
79  desc.addUntracked<std::string>("overrideCatalog", std::string());
80  desc.addUntracked<bool>("skipBadFiles", false)
81  ->setComment(
82  "True: Ignore any missing or unopenable input file.\n"
83  "False: Throw exception if missing or unopenable input file.");
84  desc.addUntracked<bool>("bypassVersionCheck", false)
85  ->setComment(
86  "True: Bypass release version check.\n"
87  "False: Throw exception if reading file in a release prior to the release in which the file was written.");
88  desc.addUntracked<int>("treeMaxVirtualSize", -1)
89  ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
90 
91  ProductSelectorRules::fillDescription(desc, "inputCommands");
93 
94  descriptions.add("source", desc);
95  }
96 } // namespace edm
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
virtual void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setComment(std::string const &value)
virtual void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id)
static void reportReadBranches()
Definition: InputFile.cc:113
virtual void beginJob() override
EmbeddedRootSource(ParameterSet const &pset, VectorInputSourceDescription const &desc)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
virtual bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id) override
static void fillDescription(ParameterSetDescription &desc)
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:208
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ProductSelectorRules productSelectorRules_
volatile std::atomic< bool > shutdown_flag false
virtual void endJob() override
edm::propagate_const< std::unique_ptr< RootEmbeddedFileSequence > > fileSequence_