Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:54

0001 #ifndef FWCore_Catalog_InputFileCatalog_h
0002 #define FWCore_Catalog_InputFileCatalog_h
0003 //////////////////////////////////////////////////////////////////////
0004 //
0005 // Class InputFileCatalog. Services to manage InputFile catalog.
0006 // Physical file names, pfns_ of FileCatalogItem, are constructed from multiple data catalogs in site-local-config.xml. Each member of pfns_ corresponds to a data catalog.
0007 // Note that fileNames(unsigned iCatalog) of InputFileCatalog return physical file names of all input files corresponding to a data catalog (for example, a job has 10 input files provided as a PoolSource, the fileNames(unsigned iCatalog) will return PFNs of these 10 files constructed from a data catalog)
0008 // Set catType=TrivialCatalog: use trivial data catalogs from <event-data>
0009 // Set catType=RucioCatalog: use data catalogs from <data-access> and storage.json
0010 //
0011 //////////////////////////////////////////////////////////////////////
0012 
0013 #include <memory>
0014 #include <string>
0015 #include <vector>
0016 #include "FWCore/Catalog/interface/FileLocator.h"
0017 #include "FWCore/Utilities/interface/propagate_const.h"
0018 
0019 namespace edm {
0020   class FileCatalogItem {
0021   public:
0022     FileCatalogItem(std::vector<std::string> const& pfns, std::string const& lfn) : pfns_(pfns), lfn_(lfn) {}
0023 
0024     std::string const& fileName(unsigned iCatalog) const { return pfns_[iCatalog]; }
0025     std::string const& logicalFileName() const { return lfn_; }
0026 
0027     std::vector<std::string> const& fileNames() const { return pfns_; }
0028 
0029   private:
0030     std::vector<std::string> pfns_;
0031     std::string lfn_;
0032   };
0033 
0034   class InputFileCatalog {
0035   public:
0036     InputFileCatalog(std::vector<std::string> const& fileNames,
0037                      std::string const& override,
0038                      bool useLFNasPFNifLFNnotFound = false,
0039                      //switching between two catalog types
0040                      //edm::CatalogType catType = edm::CatalogType::TrivialCatalog);
0041                      edm::CatalogType catType = edm::CatalogType::RucioCatalog);
0042 
0043     ~InputFileCatalog();
0044     std::vector<FileCatalogItem> const& fileCatalogItems() const { return fileCatalogItems_; }
0045     std::vector<std::string> const& logicalFileNames() const { return logicalFileNames_; }
0046     std::vector<std::string> fileNames(unsigned iCatalog) const;
0047     bool empty() const { return fileCatalogItems_.empty(); }
0048     static bool isPhysical(std::string const& name) { return (name.empty() || name.find(':') != std::string::npos); }
0049 
0050   private:
0051     void init(std::string const& override, bool useLFNasPFNifLFNnotFound, edm::CatalogType catType);
0052     void findFile(std::string const& lfn,
0053                   std::vector<std::string>& pfns,
0054                   bool useLFNasPFNifLFNnotFound,
0055                   edm::CatalogType catType);
0056     std::vector<std::string> logicalFileNames_;
0057     std::vector<std::string> fileNames_;
0058     std::vector<FileCatalogItem> fileCatalogItems_;
0059     edm::propagate_const<std::unique_ptr<FileLocator>> overrideFileLocator_;
0060 
0061     std::vector<edm::propagate_const<std::unique_ptr<FileLocator>>> fileLocators_trivalCatalog_;
0062     std::vector<edm::propagate_const<std::unique_ptr<FileLocator>>> fileLocators_;
0063   };
0064 }  // namespace edm
0065 
0066 #endif