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  }
39 
41 
42  void
44  }
45 
46  void
48  fileSequence_->endJob();
50  }
51 
53  fileSequence_->closeFile_();
54  }
55 
56  bool
57  EmbeddedRootSource::readOneEvent(EventPrincipal& cache, size_t& fileNameHash, CLHEP::HepRandomEngine* engine, EventID const* id) {
58  return fileSequence_->readOneEvent(cache, fileNameHash, engine, id);
59  }
60 
61  void
63  fileSequence_->readOneSpecified(cache, fileNameHash, id);
64  }
65 
66  void
67  EmbeddedRootSource::dropUnwantedBranches_(std::vector<std::string> const& wantedBranches) {
68  std::vector<std::string> rules;
69  rules.reserve(wantedBranches.size() + 1);
70  rules.emplace_back("drop *");
71  for(std::string const& branch : wantedBranches) {
72  rules.push_back("keep " + branch + "_*");
73  }
75  pset.addUntrackedParameter("inputCommands", rules);
76  productSelectorRules_ = ProductSelectorRules(pset, "inputCommands", "InputSource");
77  }
78 
79  void
81 
83 
84  std::vector<std::string> defaultStrings;
85  desc.setComment("Reads EDM/Root files for mixing.");
86  desc.addUntracked<std::vector<std::string> >("fileNames")
87  ->setComment("Names of files to be processed.");
88  desc.addUntracked<std::string>("overrideCatalog", std::string());
89  desc.addUntracked<bool>("skipBadFiles", false)
90  ->setComment("True: Ignore any missing or unopenable input file.\n"
91  "False: Throw exception if missing or unopenable input file.");
92  desc.addUntracked<bool>("bypassVersionCheck", false)
93  ->setComment("True: Bypass release version check.\n"
94  "False: Throw exception if reading file in a release prior to the release in which the file was written.");
95  desc.addUntracked<int>("treeMaxVirtualSize", -1)
96  ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
97 
98  ProductSelectorRules::fillDescription(desc, "inputCommands");
100 
101  descriptions.add("source", desc);
102  }
103 }
virtual void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id) override
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName, std::vector< std::string > const &defaultStrings=defaultSelectionStrings())
void setComment(std::string const &value)
static void reportReadBranches()
Definition: InputFile.cc:120
virtual void beginJob() override
EmbeddedRootSource(ParameterSet const &pset, VectorInputSourceDescription const &desc)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
virtual void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches) override
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_