|
|
Go to the documentation of this file.
20 #include "CLHEP/Random/RandFlat.h"
27 std::atomic<unsigned int> badFilesSkipped_{0};
28 auto operator"" _uz(
unsigned long long i) -> std::size_t {
return std::size_t{
i}; }
39 orderedProcessHistoryIDs_(),
40 sequential_(
pset.getUntrackedParameter<
bool>(
"sequential",
false)),
41 sameLumiBlock_(
pset.getUntrackedParameter<
bool>(
"sameLumiBlock",
false)),
43 eventsRemainingInFile_(0),
51 initialNumberOfEventsToSkip_(
pset.getUntrackedParameter<unsigned
int>(
"skipEvents", 0
U)),
53 enablePrefetching_(
false),
54 enforceGUIDInFileName_(
pset.getUntrackedParameter<
bool>(
"enforceGUIDInFileName",
false)),
58 <<
"RootEmbeddedFileSequence no input files specified for secondary input source.\n";
100 std::ifstream
f(
"/dev/urandom");
102 f.read(reinterpret_cast<char*>(&
seed),
sizeof(
seed));
103 std::default_random_engine dre(
seed);
104 std::uniform_int_distribution<int> distribution(0,
numberOfFiles() - 1);
106 int offset = distribution(dre);
118 <<
" input file retries exhausted.\n";
138 std::shared_ptr<InputFile> filePtr) {
140 return std::make_shared<RootFile>(
fileNames()[0],
152 currentIndexIntoFile,
217 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
224 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
240 size_t& fileNameHash,
246 <<
" do not contain specified event:\n"
247 <<
id <<
" in file id " <<
idx.fileNameHash() <<
"\n";
252 fileNameHash =
idx.fileNameHash();
253 if (fileNameHash == 0
U) {
268 if (newSeqNumber != currentSeqNumber) {
270 currentSeqNumber = newSeqNumber;
277 <<
fileNames()[0] <<
" contains no events.\n";
279 LogWarning(
"RootEmbeddedFileSequence") <<
"RootEmbeddedFileSequence::readOneRandom(): Secondary Input file "
280 <<
fileNames()[0] <<
" contains no events and will be skipped.\n";
286 if (newSeqNumber != currentSeqNumber) {
293 <<
" input file retries exhausted.\n";
311 size_t& fileNameHash,
312 CLHEP::HepRandomEngine* engine,
319 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
324 int eventsInLumi = 0;
326 while (
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock()))
330 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
331 for (
int i = 0;
i < eventInLumi; ++
i) {
332 bool foundEventInLumi =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
337 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
353 size_t& fileNameHash,
354 CLHEP::HepRandomEngine* engine,
359 return (this->*
fptr_)(
cache, fileNameHash, engine,
id, recycleFiles);
363 desc.addUntracked<
bool>(
"sequential",
false)
365 "True: loopEvents() reads events sequentially from beginning of first file.\n"
366 "False: loopEvents() first reads events beginning at random event. New files also chosen randomly");
367 desc.addUntracked<
bool>(
"sameLumiBlock",
false)
369 "True: loopEvents() reads events only in same lumi as the specified event.\n"
370 "False: loopEvents() reads events regardless of lumi.");
371 desc.addUntracked<
unsigned int>(
"skipEvents", 0
U)
373 "Skip the first 'skipEvents' events. Used only if 'sequential' is True and 'sameLumiBlock' is False");
374 desc.addUntracked<
unsigned int>(
"maxFileSkips")
376 "How many files to try if 'sequential' is False and 'skipBadFiles' is True.\n"
377 "Defaults to 3 (or # of files if smaller).");
379 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
380 desc.addUntracked<
bool>(
"enforceGUIDInFileName",
false)
382 "True: file name part is required to be equal to the GUID of the file\n"
383 "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_
EventID const & min(EventID const &lh, EventID const &rh)
~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)
Log< level::Warning, false > LogWarning
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_
unsigned int maxFileSkips_
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_