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
ConfigurationDescriptions.h
edm::EmbeddedRootSource::EmbeddedRootSource
EmbeddedRootSource(ParameterSet const &pset, VectorInputSourceDescription const &desc)
Definition: EmbeddedRootSource.cc:16
RunHelper.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
funct::false
false
Definition: Factorize.h:29
edm::DefaultRunHelper
Definition: RunHelper.h:41
EmbeddedRootSource.h
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:169
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::VectorInputSourceDescription
Definition: VectorInputSourceDescription.h:18
edm::VectorInputSource
Definition: VectorInputSource.h:27
edm::EmbeddedRootSource::readOneEvent
bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool recycleFiles) override
Definition: EmbeddedRootSource.cc:50
edm::EmbeddedRootSource::~EmbeddedRootSource
~EmbeddedRootSource() override
Definition: EmbeddedRootSource.cc:39
edm::SecondaryEventIDAndFileInfo
Definition: SecondaryEventIDAndFileInfo.h:8
edm::InputFile::reportReadBranches
static void reportReadBranches()
Definition: InputFile.cc:106
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
ParameterSetDescription.h
utilities.cache
def cache(function)
Definition: utilities.py:3
edm::EmbeddedRootSource::productSelectorRules_
ProductSelectorRules productSelectorRules_
Definition: EmbeddedRootSource.h:69
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ProductSelectorRules
Definition: ProductSelectorRules.h:24
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
edm::ProductSelectorRules::fillDescription
static void fillDescription(ParameterSetDescription &desc, char const *parameterName, std::vector< std::string > const &defaultStrings=defaultSelectionStrings())
Definition: ProductSelectorRules.cc:202
edm::EmbeddedRootSource::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: EmbeddedRootSource.cc:76
createfilelist.int
int
Definition: createfilelist.py:10
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
InputFile.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
edm::EmbeddedRootSource::beginJob
void beginJob() override
Definition: EmbeddedRootSource.cc:41
edm::EmbeddedRootSource::closeFile_
virtual void closeFile_()
Definition: EmbeddedRootSource.cc:48
VectorInputSourceDescription.h
edm::RootEmbeddedFileSequence
Definition: RootEmbeddedFileSequence.h:32
edm::EmbeddedRootSource::endJob
void endJob() override
Definition: EmbeddedRootSource.cc:43
visualization-live-secondInstance_cfg.numberOfStreams
numberOfStreams
Definition: visualization-live-secondInstance_cfg.py:89
edm::RootEmbeddedFileSequence::fillDescription
static void fillDescription(ParameterSetDescription &desc)
Definition: RootEmbeddedFileSequence.cc:362
edm::EmbeddedRootSource::fileSequence_
edm::propagate_const< std::unique_ptr< RootEmbeddedFileSequence > > fileSequence_
Definition: EmbeddedRootSource.h:73
cmsCodeRulesChecker.rules
rules
Definition: cmsCodeRulesChecker.py:152
edm::EmbeddedRootSource::readOneSpecified
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id) override
Definition: EmbeddedRootSource.cc:58
edm::EmbeddedRootSource::dropUnwantedBranches_
void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches) override
Definition: EmbeddedRootSource.cc:64
edm::EventID
Definition: EventID.h:31
RootEmbeddedFileSequence.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27