19 #include "CLHEP/Random/RandFlat.h"
30 unsigned int nStreams) :
33 orderedProcessHistoryIDs_(),
35 sequential_(pset.getUntrackedParameter<bool>(
"sequential",
false)),
36 sameLumiBlock_(pset.getUntrackedParameter<bool>(
"sameLumiBlock",
false)),
38 eventsRemainingInFile_(0),
46 initialNumberOfEventsToSkip_(pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U)),
47 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
48 bypassVersionCheck_(pset.getUntrackedParameter<bool>(
"bypassVersionCheck",
false)),
49 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
50 productSelectorRules_(pset,
"inputCommands",
"InputSource"),
51 enablePrefetching_(
false) {
93 std::ifstream
f(
"/dev/urandom");
95 f.read(reinterpret_cast<char*>(&seed),
sizeof(seed));
96 std::default_random_engine dre(seed);
98 std::uniform_int_distribution<int> distribution(0, count - 1);
101 int offset = distribution(dre);
133 return std::make_shared<RootFile>(
150 std::make_shared<BranchIDListHelper>(),
151 std::make_shared<ThinnedAssociationsHelper>(),
152 std::vector<BranchID>(),
157 currentIndexIntoFile,
167 std::vector<std::string>
rules;
168 rules.reserve(wantedBranches.size() + 1);
169 rules.emplace_back(
"drop *");
171 rules.push_back(
"keep " + branch +
"_*");
181 bool completed =
rootFile()->skipEntries(offset);
190 completed =
rootFile()->skipEntries(offset);
234 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
241 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
243 found =
rootFile()->readCurrentEvent(cache);
263 "RootEmbeddedFileSequence::readOneSpecified(): Secondary Input files" <<
264 " do not contain specified event:\n" <<
id <<
"\n";
267 found =
rootFile()->readCurrentEvent(cache);
270 if(fileNameHash == 0U) {
285 if(newSeqNumber != currentSeqNumber) {
287 currentSeqNumber = newSeqNumber;
292 "RootEmbeddedFileSequence::readOneRandom(): Secondary Input file " <<
fileName() <<
" contains no events.\n";
301 bool found =
rootFile()->readCurrentEvent(cache);
317 rootFile()->indexIntoFileIter().
lumi() !=
id.luminosityBlock()) {
322 int eventsInLumi = 0;
324 while(
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock())) ++eventsInLumi;
327 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
328 for(
int i = 0;
i < eventInLumi; ++
i) {
329 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
334 bool found =
rootFile()->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
336 found =
rootFile()->readCurrentEvent(cache);
339 bool found =
rootFile()->setEntryAtItem(
id.
run(),
id.luminosityBlock(), 0);
353 return (this->*
fptr_)(cache, fileNameHash, engine, id);
359 ->setComment(
"True: loopEvents() reads events sequentially from beginning of first file.\n"
360 "False: loopEvents() first reads events beginning at random event. New files also chosen randomly");
362 ->setComment(
"True: loopEvents() reads events only in same lumi as the specified event.\n"
363 "False: loopEvents() reads events regardless of lumi.");
365 ->setComment(
"Skip the first 'skipEvents' events. Used only if 'sequential' is True and 'sameLumiBlock' is False");
367 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
368 "False: Throw exception if missing or unopenable input file.");
370 ->setComment(
"True: Bypass release version check.\n"
371 "False: Throw exception if reading file in a release prior to the release in which the file was written.");
373 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
bool(RootEmbeddedFileSequence::* fptr_)(EventPrincipal &, size_t &, CLHEP::HepRandomEngine *, EventID const *)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
virtual RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr) override
int const treeMaxVirtualSize_
void readOneSpecified(EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void initFile_(bool skipBadFiles) override
EmbeddedRootSource & input_
static std::string const input
bool readOneRandomWithID(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id)
virtual void closeFile_() override
bool readOneSequential(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *)
virtual ~RootEmbeddedFileSequence()
bool readOneRandom(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *)
RootEmbeddedFileSequence(ParameterSet const &pset, EmbeddedRootSource &input, InputFileCatalog const &catalog, unsigned int nStreams)
EventID const & eventID() const
bool readOneEvent(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id)
ProductSelectorRules productSelectorRules_
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
bool readOneSequentialWithID(EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *, EventID const *id)
int initialNumberOfEventsToSkip_
static void fillDescription(ParameterSetDescription &desc)
static EntryNumber_t const invalidEntry
void addUntrackedParameter(std::string const &name, T const &value)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
size_t fileNameHash() const
void dropUnwantedBranches_(std::vector< std::string > const &wantedBranches)
void updateFromInput(ProductList const &other)
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
void skipEntries(unsigned int offset)
volatile std::atomic< bool > shutdown_flag false
std::shared_ptr< RootFile > RootFileSharedPtr
int eventsRemainingInFile_
tuple size
Write out results.