23 #include "CLHEP/Random/RandFlat.h"
32 unsigned int nStreams,
35 inputType_(inputType),
39 fileIterBegin_(fileCatalogItems().
begin()),
40 fileIterEnd_(fileCatalogItems().
end()),
41 fileIter_(fileIterEnd_),
42 fileIterLastOpened_(fileIterEnd_),
46 indexesIntoFiles_(fileCatalogItems().
size()),
47 orderedProcessHistoryIDs_(),
50 eventsRemainingInFile_(0),
58 initialNumberOfEventsToSkip_(inputType ==
InputType::
Primary ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
60 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
61 treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>(
"cacheSize", roottree::
defaultCacheSize) : 0U),
62 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
63 setRun_(pset.getUntrackedParameter<unsigned int>(
"setRunNumber", 0U)),
64 productSelectorRules_(pset,
"inputCommands",
"InputSource"),
66 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", inputType !=
InputType::
SecondarySource)),
67 labelRawDataLikeMC_(pset.getUntrackedParameter<bool>(
"labelRawDataLikeMC",
true)),
68 usingGoToEvent_(
false),
69 enablePrefetching_(
false),
70 usedFallback_(
false) {
108 std::vector<FileCatalogItem>
const&
118 std::unique_ptr<FileBlock>
132 return std::unique_ptr<FileBlock>(
new FileBlock);
141 std::unique_ptr<InputSource::FileCloseSentry>
161 !needIndexesForDuplicateChecker &&
163 if(deleteIndexIntoFile) {
182 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
183 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
184 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
185 <<
"before the file name in your configuration file.\n";
187 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
197 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
199 boost::shared_ptr<InputFile> filePtr;
201 std::unique_ptr<InputSource::FileOpenSentry>
208 std::ostringstream
out;
215 ex.addContext(
"Calling RootInputFileSequence::initFile()");
216 std::ostringstream
out;
217 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.";
218 ex.addAdditionalInfo(out.str());
223 if(!filePtr && (hasFallbackUrl)) {
226 std::unique_ptr<InputSource::FileOpenSentry>
228 filePtr.reset(
new InputFile(gSystem->ExpandPathName(fallbackName.c_str()),
" Fallback request to file ",
inputType_));
234 ex.addContext(
"Calling RootInputFileSequence::initFile()");
235 std::ostringstream
out;
236 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.\n";
237 out <<
"Fallback Input file " << fallbackName <<
" also could not be opened.";
238 ex.addAdditionalInfo(out.str());
267 currentIndexIntoFile,
274 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
275 char const* inputType = 0;
286 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
288 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
292 boost::shared_ptr<ProductRegistry const>
298 boost::shared_ptr<BranchIDListHelper const>
321 if(!mergeInfo.empty()) {
345 if(!mergeInfo.empty()) {
356 boost::shared_ptr<RunAuxiliary>
361 boost::shared_ptr<LuminosityBlockAuxiliary>
363 return rootFile_->readLuminosityBlockAuxiliary_();
373 rootFile_->readLuminosityBlock_(lumiPrincipal);
422 return rootFile_->containsItem(run, lumi, event);
458 bool atEnd =
rootFile_->skipEvents(offset);
459 if((offset > 0 || atEnd) && !
nextFile()) {
483 bool closedOriginalFile =
false;
484 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
488 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
505 closedOriginalFile =
true;
513 if(closedOriginalFile) {
516 rootFile_->setPosition(originalPosition);
525 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
550 typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
552 if(*it && (*it)->containsItem(run, lumi, event)) {
554 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
560 found =
rootFile_->setEntryAtItem(run, lumi, event);
601 boost::shared_ptr<ProductRegistry const>
608 std::vector<std::string>
rules;
609 rules.reserve(wantedBranches.size() + 1);
610 rules.emplace_back(
"drop *");
611 for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
613 rules.push_back(
"keep " + *it +
"_*");
648 throw Exception(
errors::Configuration) <<
"RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
652 rootFile_->indexIntoFileIter().run() !=
id.run() ||
653 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
659 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
661 found =
rootFile_->readCurrentEvent(cache);
682 "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
683 " do not contain specified event:\n" <<
id <<
"\n";
685 found =
rootFile_->readCurrentEvent(cache);
696 CLHEP::HepRandomEngine& engine = rng->getEngine();
704 if(newSeqNumber != currentSeqNumber) {
706 currentSeqNumber = newSeqNumber;
711 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
720 bool found =
rootFile_->readCurrentEvent(cache);
735 CLHEP::HepRandomEngine& engine = rng->getEngine();
740 rootFile_->indexIntoFileIter().run() !=
id.run() ||
741 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
746 int eventsInLumi = 0;
747 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
751 for(
int i = 0;
i < eventInLumi; ++
i) {
752 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
756 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
758 found =
rootFile_->readCurrentEvent(cache);
761 bool found =
rootFile_->setEntryAtItem(
id.
run(),
id.luminosityBlock(), 0);
773 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
775 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
776 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
777 "Note 1: Events within the same lumi will always be processed contiguously.\n"
778 "Note 2: Lumis within the same run will always be processed contiguously.\n"
779 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
781 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
782 "False: Throw exception if missing or unopenable input file.");
784 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
786 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
788 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
789 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
790 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
793 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
794 "'permissive': Branches in each input file may be any subset of those in the first file.");
796 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
809 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
822 if(!
rootFile_->wasFirstEventJustRead()) {
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void stagein(const std::string &url)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
unsigned int EventNumber_t
virtual std::string explainSelf() const
static void fillDescription(ParameterSetDescription &desc)
LuminosityBlockNumber_t luminosityBlock() const
unsigned int const defaultCacheSize
unsigned int LuminosityBlockNumber_t
static std::string const input
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
unsigned int offset(bool)
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
static EntryNumber_t const invalidEntry
void addUntrackedParameter(std::string const &name, T const &value)
static void fillDescription(ParameterSetDescription &desc)
void updateFromInput(ProductList const &other)
void activateTimeout(const std::string &url)
volatile std::atomic< bool > shutdown_flag false
tuple size
Write out results.