23 #include "CLHEP/Random/RandFlat.h"
32 unsigned int nStreams,
35 inputType_(inputType),
40 findFileForSpecifiedID_(
nullptr),
41 fileIterBegin_(fileCatalogItems().
begin()),
42 fileIterEnd_(fileCatalogItems().
end()),
43 fileIter_(fileIterEnd_),
44 fileIterLastOpened_(fileIterEnd_),
47 indexesIntoFiles_(fileCatalogItems().
size()),
48 orderedProcessHistoryIDs_(),
51 eventsRemainingInFile_(0),
59 initialNumberOfEventsToSkip_(inputType ==
InputType::
Primary ? pset.getUntrackedParameter<unsigned int>(
"skipEvents", 0U) : 0U),
61 skipBadFiles_(pset.getUntrackedParameter<bool>(
"skipBadFiles",
false)),
62 bypassVersionCheck_(pset.getUntrackedParameter<bool>(
"bypassVersionCheck",
false)),
63 treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>(
"cacheSize", roottree::
defaultCacheSize) : 0U),
64 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize", -1)),
65 setRun_(pset.getUntrackedParameter<unsigned int>(
"setRunNumber", 0U)),
66 productSelectorRules_(pset,
"inputCommands",
"InputSource"),
68 dropDescendants_(pset.getUntrackedParameter<bool>(
"dropDescendantsOfDroppedBranches", inputType !=
InputType::
SecondarySource)),
69 labelRawDataLikeMC_(pset.getUntrackedParameter<bool>(
"labelRawDataLikeMC",
true)),
70 usingGoToEvent_(
false),
71 enablePrefetching_(
false),
72 usedFallback_(
false) {
110 std::vector<FileCatalogItem>
const&
120 std::unique_ptr<FileBlock>
134 return std::unique_ptr<FileBlock>(
new FileBlock);
143 std::unique_ptr<InputSource::FileCloseSentry>
163 !needIndexesForDuplicateChecker &&
165 if(deleteIndexIntoFile) {
184 throw cms::Exception(
"LogicalFileNameNotFound",
"RootInputFileSequence::initFile()\n")
185 <<
"Logical file name '" <<
fileIter_->logicalFileName() <<
"' was not found in the file catalog.\n"
186 <<
"If you wanted a local file, you forgot the 'file:' prefix\n"
187 <<
"before the file name in your configuration file.\n";
189 LogWarning(
"") <<
"Input logical file: " <<
fileIter_->logicalFileName() <<
" was not found in the catalog, and will be skipped.\n";
200 bool hasFallbackUrl = !fallbackName.empty() && fallbackName !=
fileIter_->fileName();
202 std::shared_ptr<InputFile> filePtr;
203 std::list<std::string> originalInfo;
205 std::unique_ptr<InputSource::FileOpenSentry>
212 std::ostringstream
out;
220 ex.addContext(
"Calling RootInputFileSequence::initFile()");
221 std::ostringstream
out;
222 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.";
223 ex.addAdditionalInfo(out.str());
228 if(!filePtr && (hasFallbackUrl)) {
231 std::unique_ptr<InputSource::FileOpenSentry>
233 std::string fallbackFullName = gSystem->ExpandPathName(fallbackName.c_str());
236 filePtr.reset(
new InputFile(fallbackFullName.c_str(),
" Fallback request to file ",
inputType_));
242 ex.addContext(
"Calling RootInputFileSequence::initFile()");
243 std::ostringstream
out;
244 out <<
"Input file " <<
fileIter_->fileName() <<
" could not be opened.\n";
245 out <<
"Fallback Input file " << fallbackName <<
" also could not be opened.";
246 if (originalInfo.size()) {
247 out << std::endl <<
"Original exception info is above; fallback exception info is below.";
248 ex.addAdditionalInfo(out.str());
249 for (
auto const &
s : originalInfo) {
250 ex.addAdditionalInfo(
s);
253 ex.addAdditionalInfo(out.str());
285 currentIndexIntoFile,
294 indexesIntoFiles_[currentIndexIntoFile] =
rootFile_->indexIntoFileSharedPtr();
295 char const* inputType = 0;
306 "RootInputFileSequence::initFile(): Input file " <<
fileIter_->fileName() <<
" was not found or could not be opened.\n";
308 LogWarning(
"") <<
"Input file: " <<
fileIter_->fileName() <<
" was not found or could not be opened, and will be skipped.\n";
312 std::shared_ptr<ProductRegistry const>
318 std::shared_ptr<BranchIDListHelper const>
341 if(!mergeInfo.empty()) {
365 if(!mergeInfo.empty()) {
376 std::shared_ptr<RunAuxiliary>
382 std::shared_ptr<LuminosityBlockAuxiliary>
385 return rootFile_->readLuminosityBlockAuxiliary_();
397 rootFile_->readLuminosityBlock_(lumiPrincipal);
447 return rootFile_->containsItem(run, lumi, event);
484 bool atEnd =
rootFile_->skipEvents(offset);
485 if((offset > 0 || atEnd) && !
nextFile()) {
509 bool closedOriginalFile =
false;
510 std::vector<FileCatalogItem>::const_iterator originalFile =
fileIter_;
514 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
532 closedOriginalFile =
true;
541 if(closedOriginalFile) {
545 rootFile_->setPosition(originalPosition);
554 assert(fileNameHash != 0U);
560 auto hasher = std::hash<std::string>();
567 for(
auto iter = range.first;
iter != range.second; ++
iter) {
586 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
613 typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
615 if(*it && (*it)->containsItem(run, lumi, event)) {
617 std::vector<FileCatalogItem>::const_iterator currentIter =
fileIter_;
624 found =
rootFile_->setEntryAtItem(run, lumi, event);
664 std::shared_ptr<ProductRegistry const>
671 std::vector<std::string>
rules;
672 rules.reserve(wantedBranches.size() + 1);
673 rules.emplace_back(
"drop *");
675 rules.push_back(
"keep " + branch +
"_*");
714 throw Exception(
errors::Configuration) <<
"RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
718 rootFile_->indexIntoFileIter().run() !=
id.run() ||
719 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
726 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
728 found =
rootFile_->readCurrentEvent(cache);
751 "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
752 " do not contain specified event:\n" <<
id <<
"\n";
755 found =
rootFile_->readCurrentEvent(cache);
758 if(fileNameHash == 0U) {
775 if(newSeqNumber != currentSeqNumber) {
777 currentSeqNumber = newSeqNumber;
782 "RootInputFileSequence::readOneRandom(): Secondary Input file " <<
fileIter_->fileName() <<
" contains no events.\n";
791 bool found =
rootFile_->readCurrentEvent(cache);
807 rootFile_->indexIntoFileIter().run() !=
id.run() ||
808 rootFile_->indexIntoFileIter().lumi() !=
id.luminosityBlock()) {
813 int eventsInLumi = 0;
815 while(
rootFile_->setEntryAtNextEventInLumi(
id.run(),
id.luminosityBlock())) ++eventsInLumi;
818 int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
819 for(
int i = 0;
i < eventInLumi; ++
i) {
820 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
825 bool found =
rootFile_->setEntryAtNextEventInLumi(
id.
run(),
id.luminosityBlock());
827 found =
rootFile_->readCurrentEvent(cache);
830 bool found =
rootFile_->setEntryAtItem(
id.
run(),
id.luminosityBlock(), 0);
843 ->setComment(
"Skip the first 'skipEvents' events that otherwise would have been processed.");
845 ->setComment(
"True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
846 "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
847 "Note 1: Events within the same lumi will always be processed contiguously.\n"
848 "Note 2: Lumis within the same run will always be processed contiguously.\n"
849 "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
851 ->setComment(
"True: Ignore any missing or unopenable input file.\n"
852 "False: Throw exception if missing or unopenable input file.");
854 ->setComment(
"True: Bypass release version check.\n"
855 "False: Throw exception if reading file in a release prior to the release in which the file was written.");
857 ->setComment(
"Size of ROOT TTree prefetch cache. Affects performance.");
859 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
861 ->setComment(
"If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
862 desc.
addUntracked<
bool>(
"dropDescendantsOfDroppedBranches",
true)
863 ->setComment(
"If True, also drop on input any descendent of any branch dropped on input.");
866 ->setComment(
"'strict': Branches in each input file must match those in the first file.\n"
867 "'permissive': Branches in each input file may be any subset of those in the first file.");
869 ->setComment(
"If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
882 std::vector<FileCatalogItem>::const_iterator itr(
fileIter_);
895 if(!
rootFile_->wasFirstEventJustRead()) {
907 for(
auto const& branchID : associationsFromSecondary) {
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)
virtual std::string explainSelf() const
unsigned long long EventNumber_t
static void fillDescription(ParameterSetDescription &desc)
LuminosityBlockNumber_t luminosityBlock() const
unsigned int const defaultCacheSize
unsigned int LuminosityBlockNumber_t
std::list< std::string > const & additionalInfo() const
static std::string const input
static StorageFactory * get(void)
tuple InputFile
Open Root file and provide MEs ############.
EventID const & eventID() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
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)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
static void fillDescription(ParameterSetDescription &desc)
size_t fileNameHash() const
void updateFromInput(ProductList const &other)
void activateTimeout(const std::string &url)
volatile std::atomic< bool > shutdown_flag false
tuple size
Write out results.