|
|
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,
218 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
225 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
242 size_t& fileNameHash,
248 <<
" do not contain specified event:\n"
249 <<
id <<
" in file id " <<
idx.fileNameHash() <<
"\n";
255 fileNameHash =
idx.fileNameHash();
256 if (fileNameHash == 0
U) {
271 if (newSeqNumber != currentSeqNumber) {
273 currentSeqNumber = newSeqNumber;
280 <<
fileNames()[0] <<
" contains no events.\n";
282 LogWarning(
"RootEmbeddedFileSequence") <<
"RootEmbeddedFileSequence::readOneRandom(): Secondary Input file "
283 <<
fileNames()[0] <<
" contains no events and will be skipped.\n";
289 if (newSeqNumber != currentSeqNumber) {
296 <<
" input file retries exhausted.\n";
314 size_t& fileNameHash,
315 CLHEP::HepRandomEngine* engine,
322 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
327 int eventsInLumi = 0;
329 while (
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock()))
333 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
334 for (
int i = 0;
i < eventInLumi; ++
i) {
335 bool foundEventInLumi =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
340 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
357 size_t& fileNameHash,
358 CLHEP::HepRandomEngine* engine,
363 return (this->*
fptr_)(
cache, fileNameHash, engine,
id, recycleFiles);
367 desc.addUntracked<
bool>(
"sequential",
false)
369 "True: loopEvents() reads events sequentially from beginning of first file.\n"
370 "False: loopEvents() first reads events beginning at random event. New files also chosen randomly");
371 desc.addUntracked<
bool>(
"sameLumiBlock",
false)
373 "True: loopEvents() reads events only in same lumi as the specified event.\n"
374 "False: loopEvents() reads events regardless of lumi.");
375 desc.addUntracked<
unsigned int>(
"skipEvents", 0
U)
377 "Skip the first 'skipEvents' events. Used only if 'sequential' is True and 'sameLumiBlock' is False");
378 desc.addUntracked<
unsigned int>(
"maxFileSkips")
380 "How many files to try if 'sequential' is False and 'skipBadFiles' is True.\n"
381 "Defaults to 3 (or # of files if smaller).");
383 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
384 desc.addUntracked<
bool>(
"enforceGUIDInFileName",
false)
386 "True: file name part is required to be equal to the GUID of the file\n"
387 "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_