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)),
44 treeCacheSize_(pset.getUntrackedParameter<unsigned
int>(
"cacheSize", roottree::
defaultCacheSize)),
45 enablePrefetching_(
false) {
48 <<
"RootEmbeddedFileSequence no input files specified for secondary input source.\n";
90 std::ifstream
f(
"/dev/urandom");
92 f.read(reinterpret_cast<char*>(&seed),
sizeof(seed));
93 std::default_random_engine dre(seed);
95 std::uniform_int_distribution<int>
distribution(0, count - 1);
124 std::shared_ptr<InputFile> filePtr) {
126 return std::make_shared<RootFile>(
fileName(),
138 currentIndexIntoFile,
146 bool completed =
rootFile()->skipEntries(offset);
155 completed =
rootFile()->skipEntries(offset);
200 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
207 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
209 found =
rootFile()->readCurrentEvent(cache);
223 size_t& fileNameHash,
229 <<
" do not contain specified event:\n" 233 found =
rootFile()->readCurrentEvent(cache);
236 if (fileNameHash == 0
U) {
249 if (newSeqNumber != currentSeqNumber) {
251 currentSeqNumber = newSeqNumber;
256 <<
fileName() <<
" contains no events.\n";
265 bool found =
rootFile()->readCurrentEvent(cache);
274 size_t& fileNameHash,
275 CLHEP::HepRandomEngine* engine,
282 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
287 int eventsInLumi = 0;
289 while (
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock()))
293 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
294 for (
int i = 0;
i < eventInLumi; ++
i) {
295 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
300 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
302 found =
rootFile()->readCurrentEvent(cache);
305 bool found =
rootFile()->setEntryAtItem(
id.
run(),
id.luminosityBlock(), 0);
316 size_t& fileNameHash,
317 CLHEP::HepRandomEngine* engine,
322 return (this->*
fptr_)(
cache, fileNameHash, engine,
id, recycleFiles);
328 "True: loopEvents() reads events sequentially from beginning of first file.\n" 329 "False: loopEvents() first reads events beginning at random event. New files also chosen randomly");
332 "True: loopEvents() reads events only in same lumi as the specified event.\n" 333 "False: loopEvents() reads events regardless of lumi.");
336 "Skip the first 'skipEvents' events. Used only if 'sequential' is True and 'sameLumiBlock' is False");
338 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr) override
bool readOneRandomWithID(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool)
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
unsigned int nStreams() const
bool readOneSequentialWithID(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool)
void initFile_(bool skipBadFiles) override
unsigned int const defaultCacheSize
~RootEmbeddedFileSequence() override
bool readOneRandom(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *, bool)
bool bypassVersionCheck() const
EmbeddedRootSource & input_
static std::string const input
void closeFile_() override
bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id, bool recycleFiles)
bool readOneSequential(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *, bool recycleFiles)
RunHelperBase * runHelper()
EventID const & eventID() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int treeMaxVirtualSize() const
bool skipBadFiles() const
int initialNumberOfEventsToSkip_
static void fillDescription(ParameterSetDescription &desc)
static constexpr EntryNumber_t invalidEntry
size_t fileNameHash() const
ProductSelectorRules const & productSelectorRules() const
void updateFromInput(ProductList const &other)
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
void skipEntries(unsigned int offset)
int eventsRemainingInFile_
unsigned int treeCacheSize_
RootEmbeddedFileSequence(ParameterSet const &pset, EmbeddedRootSource &input, InputFileCatalog const &catalog)
bool(RootEmbeddedFileSequence::* fptr_)(EventPrincipal &, size_t &, CLHEP::HepRandomEngine *, EventID const *, bool)