|
|
Go to the documentation of this file.
19 #include "CLHEP/Random/RandFlat.h"
31 orderedProcessHistoryIDs_(),
32 sequential_(
pset.getUntrackedParameter<
bool>(
"sequential",
false)),
33 sameLumiBlock_(
pset.getUntrackedParameter<
bool>(
"sameLumiBlock",
false)),
35 eventsRemainingInFile_(0),
43 initialNumberOfEventsToSkip_(
pset.getUntrackedParameter<unsigned
int>(
"skipEvents", 0
U)),
45 enablePrefetching_(
false),
46 enforceGUIDInFileName_(
pset.getUntrackedParameter<
bool>(
"enforceGUIDInFileName",
false)) {
49 <<
"RootEmbeddedFileSequence no input files specified for secondary input source.\n";
91 std::ifstream
f(
"/dev/urandom");
93 f.read(reinterpret_cast<char*>(&
seed),
sizeof(
seed));
94 std::default_random_engine dre(
seed);
96 std::uniform_int_distribution<int> distribution(0,
count - 1);
99 int offset = distribution(dre);
125 std::shared_ptr<InputFile> filePtr) {
127 return std::make_shared<RootFile>(
fileNames()[0],
139 currentIndexIntoFile,
202 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
209 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
225 size_t& fileNameHash,
231 <<
" do not contain specified event:\n"
237 fileNameHash =
idx.fileNameHash();
238 if (fileNameHash == 0
U) {
251 if (newSeqNumber != currentSeqNumber) {
253 currentSeqNumber = newSeqNumber;
258 <<
fileNames()[0] <<
" contains no events.\n";
276 size_t& fileNameHash,
277 CLHEP::HepRandomEngine* engine,
284 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
289 int eventsInLumi = 0;
291 while (
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock()))
295 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
296 for (
int i = 0;
i < eventInLumi; ++
i) {
297 bool foundEventInLumi =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
302 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
318 size_t& fileNameHash,
319 CLHEP::HepRandomEngine* engine,
324 return (this->*
fptr_)(
cache, fileNameHash, engine,
id, recycleFiles);
328 desc.addUntracked<
bool>(
"sequential",
false)
330 "True: loopEvents() reads events sequentially from beginning of first file.\n"
331 "False: loopEvents() first reads events beginning at random event. New files also chosen randomly");
332 desc.addUntracked<
bool>(
"sameLumiBlock",
false)
334 "True: loopEvents() reads events only in same lumi as the specified event.\n"
335 "False: loopEvents() reads events regardless of lumi.");
336 desc.addUntracked<
unsigned int>(
"skipEvents", 0
U)
338 "Skip the first 'skipEvents' events. Used only if 'sequential' is True and 'sameLumiBlock' is False");
340 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
341 desc.addUntracked<
bool>(
"enforceGUIDInFileName",
false)
343 "True: file name part is required to be equal to the GUID of the file\n"
344 "False: file name can be anything");
void initFile_(bool skipBadFiles) override
static const std::string input
ProductSelectorRules const & productSelectorRules() const
void skipEntries(unsigned int offset)
int eventsRemainingInFile_
~RootEmbeddedFileSequence() override
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
static constexpr EntryNumber_t invalidEntry
bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool recycleFiles)
void updateFromInput(ProductList const &other)
bool skipBadFiles() const
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id)
int initialNumberOfEventsToSkip_
RunHelperBase * runHelper()
bool readOneSequentialWithID(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool)
void closeFile_() override
unsigned const int defaultCacheSize
bool bypassVersionCheck() const
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
int treeMaxVirtualSize() const
bool readOneRandom(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *, bool)
RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr) override
bool readOneSequential(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *, bool recycleFiles)
EmbeddedRootSource & input_
bool(RootEmbeddedFileSequence::* fptr_)(EventPrincipal &, size_t &, CLHEP::HepRandomEngine *, EventID const *, bool)
unsigned int treeCacheSize_
bool readOneRandomWithID(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool)
RootEmbeddedFileSequence(ParameterSet const &pset, EmbeddedRootSource &input, InputFileCatalog const &catalog)
ProductRegistry & productRegistryUpdate()
unsigned int nStreams() const
static void fillDescription(ParameterSetDescription &desc)
bool enforceGUIDInFileName_