CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::InputFileCatalog Class Reference

#include <InputFileCatalog.h>

Public Member Functions

bool empty () const
 
std::vector< FileCatalogItem > const & fileCatalogItems () const
 
std::vector< std::string > fileNames (unsigned iCatalog) const
 
 InputFileCatalog (std::vector< std::string > const &fileNames, std::string const &override, bool useLFNasPFNifLFNnotFound=false)
 
std::vector< std::string > const & logicalFileNames () const
 
 ~InputFileCatalog ()
 

Static Public Member Functions

static bool isPhysical (std::string const &name)
 

Private Member Functions

void findFile (std::string const &lfn, std::vector< std::string > &pfns, bool useLFNasPFNifLFNnotFound)
 
void init (std::string const &override, bool useLFNasPFNifLFNnotFound)
 

Private Attributes

std::vector< FileCatalogItemfileCatalogItems_
 
std::vector< edm::propagate_const< std::unique_ptr< FileLocator > > > fileLocators_
 
std::vector< std::string > fileNames_
 
std::vector< std::string > logicalFileNames_
 
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
 

Detailed Description

Definition at line 32 of file InputFileCatalog.h.

Constructor & Destructor Documentation

◆ InputFileCatalog()

edm::InputFileCatalog::InputFileCatalog ( std::vector< std::string > const &  fileNames,
std::string const &  override,
bool  useLFNasPFNifLFNnotFound = false 
)

Definition at line 17 of file InputFileCatalog.cc.

21  init(override, useLFNasPFNifLFNnotFound);
22  }

References init().

◆ ~InputFileCatalog()

edm::InputFileCatalog::~InputFileCatalog ( )

Definition at line 24 of file InputFileCatalog.cc.

24 {}

Member Function Documentation

◆ empty()

bool edm::InputFileCatalog::empty ( void  ) const
inline

Definition at line 42 of file InputFileCatalog.h.

42 { return fileCatalogItems_.empty(); }

References fileCatalogItems_.

Referenced by edm::PoolSource::PoolSource().

◆ fileCatalogItems()

std::vector<FileCatalogItem> const& edm::InputFileCatalog::fileCatalogItems ( ) const
inline

◆ fileNames()

std::vector< std::string > edm::InputFileCatalog::fileNames ( unsigned  iCatalog) const

Definition at line 26 of file InputFileCatalog.cc.

26  {
27  std::vector<std::string> tmp;
28  tmp.reserve(fileCatalogItems_.size());
29  for (auto const& item : fileCatalogItems_) {
30  tmp.push_back(item.fileName(iCatalog));
31  }
32  return tmp;
33  }

References fileCatalogItems_, B2GTnPMonitor_cfi::item, and createJobs::tmp.

Referenced by edm::FromFiles::fileNames(), and DQMRootSource::readFile_().

◆ findFile()

void edm::InputFileCatalog::findFile ( std::string const &  lfn,
std::vector< std::string > &  pfns,
bool  useLFNasPFNifLFNnotFound 
)
private

Definition at line 86 of file InputFileCatalog.cc.

88  {
90  pfns.push_back(overrideFileLocator_->pfn(lfn));
91  } else {
92  for (auto const& locator : fileLocators_) {
93  std::string pfn = locator->pfn(lfn);
94  if (pfn.empty() && useLFNasPFNifLFNnotFound)
95  pfns.push_back(lfn);
96  else
97  pfns.push_back(pfn);
98  }
99  }
100 
101  // Empty PFN will be found by caller.
102  }

References fileLocators_, overrideFileLocator_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by init().

◆ init()

void edm::InputFileCatalog::init ( std::string const &  override,
bool  useLFNasPFNifLFNnotFound 
)
private

Definition at line 35 of file InputFileCatalog.cc.

35  {
36  typedef std::vector<std::string>::iterator iter;
37 
38  if (!overrideFileLocator_ && !inputOverride.empty()) {
40  std::make_unique<FileLocator>(inputOverride); // propagate_const<T> has no reset() function
41  }
42 
43  Service<SiteLocalConfig> localconfservice;
44  if (!localconfservice.isAvailable())
45  throw cms::Exception("TrivialFileCatalog", "edm::SiteLocalConfigService is not available");
46 
47  std::vector<std::string> const& tmp_dataCatalogs = localconfservice->dataCatalogs();
48  if (!fileLocators_.empty())
49  fileLocators_.clear();
50 
51  //require the first file locator to success so obvious mistakes in data catalogs, typos for example, can be catched early. Note that tmp_dataCatalogs is not empty at this point. The protection is done inside the dataCatalogs() above
52  fileLocators_.push_back(std::make_unique<FileLocator>(tmp_dataCatalogs.front()));
53 
54  for (auto it = tmp_dataCatalogs.begin() + 1; it != tmp_dataCatalogs.end(); ++it) {
55  try {
56  fileLocators_.push_back(std::make_unique<FileLocator>(*it));
57  } catch (cms::Exception const& e) {
58  continue;
59  }
60  }
61 
62  for (iter it = fileNames_.begin(), lt = logicalFileNames_.begin(), itEnd = fileNames_.end(); it != itEnd;
63  ++it, ++lt) {
64  boost::trim(*it);
65  std::vector<std::string> pfns;
66  if (it->empty()) {
67  throw Exception(errors::Configuration, "InputFileCatalog::InputFileCatalog()\n")
68  << "An empty string specified in the fileNames parameter for input source.\n";
69  }
70  if (isPhysical(*it)) {
71  if (it->back() == ':') {
72  throw Exception(errors::Configuration, "InputFileCatalog::InputFileCatalog()\n")
73  << "An empty physical file name specified in the fileNames parameter for input source.\n";
74  }
75  pfns.push_back(*it);
76  // Clear the LFN.
77  lt->clear();
78  } else {
79  boost::trim(*lt);
80  findFile(*lt, pfns, useLFNasPFNifLFNnotFound);
81  }
82  fileCatalogItems_.push_back(FileCatalogItem(pfns, *lt));
83  }
84  }

References edm::errors::Configuration, MillePedeFileConverter_cfg::e, Exception, fileCatalogItems_, fileLocators_, fileNames_, findFile(), edm::Service< T >::isAvailable(), isPhysical(), logicalFileNames_, overrideFileLocator_, and trim().

Referenced by InputFileCatalog().

◆ isPhysical()

static bool edm::InputFileCatalog::isPhysical ( std::string const &  name)
inlinestatic

Definition at line 43 of file InputFileCatalog.h.

43 { return (name.empty() || name.find(':') != std::string::npos); }

References Skims_PA_cff::name.

Referenced by init().

◆ logicalFileNames()

std::vector<std::string> const& edm::InputFileCatalog::logicalFileNames ( ) const
inline

Definition at line 40 of file InputFileCatalog.h.

40 { return logicalFileNames_; }

References logicalFileNames_.

Referenced by edm::FromFiles::logicalFileNames().

Member Data Documentation

◆ fileCatalogItems_

std::vector<FileCatalogItem> edm::InputFileCatalog::fileCatalogItems_
private

Definition at line 50 of file InputFileCatalog.h.

Referenced by empty(), fileCatalogItems(), fileNames(), and init().

◆ fileLocators_

std::vector<edm::propagate_const<std::unique_ptr<FileLocator> > > edm::InputFileCatalog::fileLocators_
private

Definition at line 53 of file InputFileCatalog.h.

Referenced by findFile(), and init().

◆ fileNames_

std::vector<std::string> edm::InputFileCatalog::fileNames_
private

Definition at line 49 of file InputFileCatalog.h.

Referenced by init().

◆ logicalFileNames_

std::vector<std::string> edm::InputFileCatalog::logicalFileNames_
private

Definition at line 48 of file InputFileCatalog.h.

Referenced by init(), and logicalFileNames().

◆ overrideFileLocator_

edm::propagate_const<std::unique_ptr<FileLocator> > edm::InputFileCatalog::overrideFileLocator_
private

Definition at line 51 of file InputFileCatalog.h.

Referenced by findFile(), and init().

edm::InputFileCatalog::isPhysical
static bool isPhysical(std::string const &name)
Definition: InputFileCatalog.h:43
edm::InputFileCatalog::findFile
void findFile(std::string const &lfn, std::vector< std::string > &pfns, bool useLFNasPFNifLFNnotFound)
Definition: InputFileCatalog.cc:86
edm::InputFileCatalog::fileCatalogItems_
std::vector< FileCatalogItem > fileCatalogItems_
Definition: InputFileCatalog.h:50
edm::InputFileCatalog::fileNames
std::vector< std::string > fileNames(unsigned iCatalog) const
Definition: InputFileCatalog.cc:26
edm::InputFileCatalog::fileLocators_
std::vector< edm::propagate_const< std::unique_ptr< FileLocator > > > fileLocators_
Definition: InputFileCatalog.h:53
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
edm::InputFileCatalog::fileNames_
std::vector< std::string > fileNames_
Definition: InputFileCatalog.h:49
Service
edm::InputFileCatalog::init
void init(std::string const &override, bool useLFNasPFNifLFNnotFound)
Definition: InputFileCatalog.cc:35
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::InputFileCatalog::overrideFileLocator_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
Definition: InputFileCatalog.h:51
edm::InputFileCatalog::logicalFileNames_
std::vector< std::string > logicalFileNames_
Definition: InputFileCatalog.h:48
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
cms::Exception
Definition: Exception.h:70
trim
static void trim(std::string &s)
Definition: DTCCablingMapProducer.cc:67
edm::errors::Configuration
Definition: EDMException.h:36
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37