Index: interface/InputFileCatalog.h =================================================================== RCS file: /cvs_server/repositories/CMSSW/CMSSW/FWCore/Catalog/interface/InputFileCatalog.h,v retrieving revision 1.13 diff -u -r1.13 InputFileCatalog.h --- interface/InputFileCatalog.h 18 Jun 2010 15:50:37 -0000 1.13 +++ interface/InputFileCatalog.h 13 Jul 2010 02:51:19 -0000 @@ -14,33 +14,40 @@ namespace edm { class FileCatalogItem { public: - FileCatalogItem() : pfn_(), lfn_() {} - FileCatalogItem(std::string const& pfn, std::string const& lfn) : pfn_(pfn), lfn_(lfn) {} + FileCatalogItem() : pfn_(), lfn_(), fallbackPfn_() {} + FileCatalogItem(std::string const& pfn, std::string const& lfn, std::string const& fallbackPfn) : pfn_(pfn), lfn_(lfn), fallbackPfn_(fallbackPfn) {} std::string const& fileName() const {return pfn_;} std::string const& logicalFileName() const {return lfn_;} + std::string const& fallbackFileName() const {return fallbackPfn_;} private: std::string pfn_; std::string lfn_; + std::string fallbackPfn_; }; class InputFileCatalog { public: InputFileCatalog(std::vector const& fileNames, std::string const& override, bool noThrow = false); + InputFileCatalog(std::vector const& fileNames, std::string const& override, std::string const& overrideFallback, bool noThrow = false); ~InputFileCatalog(); std::vector const& fileCatalogItems() const {return fileCatalogItems_;} std::vector const& logicalFileNames() const {return logicalFileNames_;} std::vector const& fileNames() const {return fileNames_;} + std::vector const& fallbackFileNames() const {return fallbackFileNames_;} bool empty() const {return fileCatalogItems_.empty();} static bool isPhysical(std::string const& name) { return (name.empty() || name.find(':') != std::string::npos); } private: - void findFile(std::string & pfn, std::string const& lfn, bool noThrow); + void init(std::vector const& fileNames, std::string const& override, std::string const& overrideFallback, bool noThrow); + void findFile(std::string & pfn, std::string & fallbackPfn, std::string const& lfn, bool noThrow); std::vector logicalFileNames_; std::vector fileNames_; + std::vector fallbackFileNames_; std::vector fileCatalogItems_; - boost::scoped_ptr fl_; + boost::scoped_ptr fileLocator_; + boost::scoped_ptr fallbackFileLocator_; }; } Index: interface/SiteLocalConfig.h =================================================================== RCS file: /cvs_server/repositories/CMSSW/CMSSW/FWCore/Catalog/interface/SiteLocalConfig.h,v retrieving revision 1.9 diff -u -r1.9 SiteLocalConfig.h --- interface/SiteLocalConfig.h 3 May 2010 17:59:36 -0000 1.9 +++ interface/SiteLocalConfig.h 13 Jul 2010 02:51:19 -0000 @@ -26,6 +26,7 @@ virtual ~SiteLocalConfig() {} virtual const std::string dataCatalog (void) const = 0; + virtual const std::string fallbackDataCatalog (void) const = 0; virtual const std::string lookupCalibConnect (const std::string& input) const = 0; virtual const std::string rfioType (void) const = 0; Index: src/InputFileCatalog.cc =================================================================== RCS file: /cvs_server/repositories/CMSSW/CMSSW/FWCore/Catalog/src/InputFileCatalog.cc,v retrieving revision 1.18 diff -u -r1.18 InputFileCatalog.cc --- src/InputFileCatalog.cc 18 Jun 2010 15:50:37 -0000 1.18 +++ src/InputFileCatalog.cc 13 Jul 2010 02:51:19 -0000 @@ -4,50 +4,96 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Utilities/interface/EDMException.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Catalog/interface/SiteLocalConfig.h" #include "FWCore/Catalog/interface/InputFileCatalog.h" #include namespace edm { + InputFileCatalog::InputFileCatalog(std::vector const& fileNames, std::string const& override, bool noThrow) : logicalFileNames_(fileNames), fileNames_(logicalFileNames_), + fallbackFileNames_(fallbackFileNames_), + fileCatalogItems_(), + fileLocator_(), + fallbackFileLocator_(){ + + init(fileNames, override, "", noThrow); + } + + InputFileCatalog::InputFileCatalog(std::vector const& fileNames, std::string const& override, std::string const& overrideFallback, bool noThrow) : + logicalFileNames_(fileNames), + fileNames_(logicalFileNames_), + fallbackFileNames_(fallbackFileNames_), fileCatalogItems_(), - fl_(){ + fileLocator_(), + fallbackFileLocator_(){ + + init(fileNames, override, overrideFallback, noThrow); + } + + InputFileCatalog::~InputFileCatalog() {} + + void InputFileCatalog::init(std::vector const& fileNames, std::string const& inputOverride, std::string const& inputOverrideFallback, bool noThrow) { + std::string override = inputOverride; + if (inputOverride.empty()) { + edm::Service localconfservice; + if( !localconfservice.isAvailable() ){ + throw cms::Exception("edm::SiteLocalConfigService is not available"); + } + override=localconfservice->dataCatalog(); + } + std::string overrideFallback = inputOverrideFallback; + if (overrideFallback.empty()) { + edm::Service localconfservice; + if( !localconfservice.isAvailable() ){ + throw cms::Exception("edm::SiteLocalConfigService is not available"); + } + overrideFallback=localconfservice->fallbackDataCatalog(); + } + // Note that overrideFallback might still be empty if none is specified in the site-local-config. fileCatalogItems_.reserve(fileNames_.size()); typedef std::vector::iterator iter; - for(iter it = fileNames_.begin(), lt = logicalFileNames_.begin(), itEnd = fileNames_.end(); - it != itEnd; ++it, ++lt) { + for(iter it = fileNames_.begin(), lt = logicalFileNames_.begin(), itEnd = fileNames_.end(), ft = fallbackFileNames_.begin(); + it != itEnd; ++it, ++lt, ++ft) { boost::trim(*it); if (it->empty()) { throw edm::Exception(edm::errors::Configuration, "InputFileCatalog::InputFileCatalog()\n") - << "An empty string specified in the fileNames parameter for input source.\n"; + << "An empty string specified in the fileNames parameter for input source.\n"; } if (isPhysical(*it)) { + // Clear the LFN, but default the fallback filename to the same as the PFN. lt->clear(); } else { - if (!fl_) { - fl_.reset(new FileLocator(override)); + if (!fileLocator_) { + fileLocator_.reset(new FileLocator(override)); + } + if (!fallbackFileLocator_ && (!overrideFallback.empty())) { + fallbackFileLocator_.reset(new FileLocator(overrideFallback)); } boost::trim(*lt); - findFile(*it, *lt, noThrow); + findFile(*it, *ft, *lt, noThrow); } - fileCatalogItems_.push_back(FileCatalogItem(*it, *lt)); + fileCatalogItems_.push_back(FileCatalogItem(*it, *lt, *ft)); } } - InputFileCatalog::~InputFileCatalog() {} - - void InputFileCatalog::findFile(std::string & pfn, std::string const& lfn, bool noThrow) { - pfn = fl_->pfn(lfn); + void InputFileCatalog::findFile(std::string & pfn, std::string & fallbackPfn, std::string const& lfn, bool noThrow) { + pfn = fileLocator_->pfn(lfn); if (pfn.empty() && !noThrow) { throw cms::Exception("LogicalFileNameNotFound", "FileCatalog::findFile()\n") << "Logical file name '" << lfn << "' was not found in the file catalog.\n" << "If you wanted a local file, you forgot the 'file:' prefix\n" << "before the file name in your configuration file.\n"; } + if (fallbackFileLocator_) { + fallbackPfn = fallbackFileLocator_->pfn(lfn); + // Empty fallback PFN is OK. + } } }