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, edm::CatalogType catType=edm::CatalogType::RucioCatalog)
 
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, edm::CatalogType catType)
 
void init (std::string const &override, bool useLFNasPFNifLFNnotFound, edm::CatalogType catType)
 

Private Attributes

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

Detailed Description

Definition at line 34 of file InputFileCatalog.h.

Constructor & Destructor Documentation

◆ InputFileCatalog()

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

Definition at line 20 of file InputFileCatalog.cc.

References init().

25  init(override, useLFNasPFNifLFNnotFound, catType);
26  }
std::vector< std::string > fileNames(unsigned iCatalog) const
std::vector< FileCatalogItem > fileCatalogItems_
std::vector< std::string > fileNames_
void init(std::string const &override, bool useLFNasPFNifLFNnotFound, edm::CatalogType catType)
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
std::vector< std::string > logicalFileNames_

◆ ~InputFileCatalog()

edm::InputFileCatalog::~InputFileCatalog ( )

Definition at line 28 of file InputFileCatalog.cc.

28 {}

Member Function Documentation

◆ empty()

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

Definition at line 47 of file InputFileCatalog.h.

References fileCatalogItems_.

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

47 { return fileCatalogItems_.empty(); }
std::vector< FileCatalogItem > fileCatalogItems_

◆ fileCatalogItems()

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

Definition at line 44 of file InputFileCatalog.h.

References fileCatalogItems_.

Referenced by edm::RootInputFileSequence::fileCatalogItems(), and DQMRootSource::readFile_().

44 { return fileCatalogItems_; }
std::vector< FileCatalogItem > fileCatalogItems_

◆ fileNames()

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

Definition at line 30 of file InputFileCatalog.cc.

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

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

30  {
31  std::vector<std::string> tmp;
32  tmp.reserve(fileCatalogItems_.size());
33  for (auto const& item : fileCatalogItems_) {
34  tmp.push_back(item.fileName(iCatalog));
35  }
36  return tmp;
37  }
std::vector< FileCatalogItem > fileCatalogItems_
tmp
align.sh
Definition: createJobs.py:716

◆ findFile()

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

Definition at line 155 of file InputFileCatalog.cc.

References cms::Exception::addContext(), fileLocators_, fileLocators_trivalCatalog_, overrideFileLocator_, edm::RucioCatalog, AlCaHLTBitMon_QueryRunRegistry::string, and edm::TrivialCatalog.

Referenced by init().

158  {
159  if (overrideFileLocator_) {
160  pfns.push_back(overrideFileLocator_->pfn(lfn, catType));
161  } else {
162  if (catType == edm::CatalogType::TrivialCatalog) {
163  for (auto const& locator : fileLocators_trivalCatalog_) {
164  std::string pfn = locator->pfn(lfn, edm::CatalogType::TrivialCatalog);
165  if (pfn.empty() && useLFNasPFNifLFNnotFound)
166  pfns.push_back(lfn);
167  else
168  pfns.push_back(pfn);
169  }
170  } else if (catType == edm::CatalogType::RucioCatalog) {
171  for (auto const& locator : fileLocators_) {
172  std::string pfn = locator->pfn(lfn, edm::CatalogType::RucioCatalog);
173  if (pfn.empty() && useLFNasPFNifLFNnotFound)
174  pfns.push_back(lfn);
175  else
176  pfns.push_back(pfn);
177  }
178  } else {
179  cms::Exception ex("FileCatalog");
180  ex << "Undefined catalog type";
181  ex.addContext("Calling edm::InputFileCatalog::findFile()");
182  throw ex;
183  }
184  }
185 
186  // Empty PFN will be found by caller.
187  }
std::vector< edm::propagate_const< std::unique_ptr< FileLocator > > > fileLocators_
std::vector< edm::propagate_const< std::unique_ptr< FileLocator > > > fileLocators_trivalCatalog_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_

◆ init()

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

Definition at line 39 of file InputFileCatalog.cc.

References cms::Exception::addContext(), getEcalConditions_orcoffint2r_cff::catalog, MillePedeFileConverter_cfg::e, fileCatalogItems_, fileLocators_, fileLocators_trivalCatalog_, fileNames_, findFile(), edm::Service< T >::isAvailable(), isPhysical(), logicalFileNames_, overrideFileLocator_, edm::RucioCatalog, submitPVValidationJobs::split(), AlCaHLTBitMon_QueryRunRegistry::string, trim(), and edm::TrivialCatalog.

Referenced by InputFileCatalog().

41  {
42  typedef std::vector<std::string>::iterator iter;
43 
44  if (!overrideFileLocator_ && !inputOverride.empty()) {
45  if (catType == edm::CatalogType::TrivialCatalog) {
47  std::make_unique<FileLocator>(inputOverride); // propagate_const<T> has no reset() function
48  } else if (catType == edm::CatalogType::RucioCatalog) {
49  //now make a struct from input string
50  std::vector<std::string> tmps;
51  boost::algorithm::split(tmps, inputOverride, boost::is_any_of(std::string(",")));
52  if (tmps.size() != 5) {
53  cms::Exception ex("FileCatalog");
54  ex << "Trying to override input file catalog but invalid input override string " << inputOverride
55  << " (Should be site,subSite,storageSite,volume,protocol)";
56  ex.addContext("Calling edm::InputFileCatalog::init()");
57  throw ex;
58  }
59 
60  edm::CatalogAttributes inputOverride_struct(tmps[0], //current-site
61  tmps[1], //current-subSite
62  tmps[2], //desired-data-access-site
63  tmps[3], //desired-data-access-volume
64  tmps[4]); //desired-data-access-protocol
65 
67  std::make_unique<FileLocator>(inputOverride_struct); // propagate_const<T> has no reset() function
68  }
69  }
70 
71  Service<SiteLocalConfig> localconfservice;
72  if (!localconfservice.isAvailable()) {
73  cms::Exception ex("FileCatalog");
74  ex << "edm::SiteLocalConfigService is not available";
75  ex.addContext("Calling edm::InputFileCatalog::init()");
76  throw ex;
77  }
78 
79  if (catType == edm::CatalogType::TrivialCatalog) {
80  std::vector<std::string> const& tmp_dataCatalogs = localconfservice->trivialDataCatalogs();
81  if (!fileLocators_trivalCatalog_.empty())
83  //Construct all file locators from data catalogs. If a data catalog is invalid (wrong protocol for example), it is skipped and no file locator is constructed (an exception is thrown out from FileLocator::init).
84  for (const auto& catalog : tmp_dataCatalogs) {
85  try {
86  fileLocators_trivalCatalog_.push_back(std::make_unique<FileLocator>(catalog));
87  } catch (cms::Exception const& e) {
88  edm::LogWarning("InputFileCatalog")
89  << "Caught an exception while constructing a file locator in InputFileCatalog::init: " << e.what()
90  << "Skip this catalog";
91  }
92  }
93  if (fileLocators_trivalCatalog_.empty()) {
94  cms::Exception ex("FileCatalog");
95  ex << "Unable to construct any file locator in InputFileCatalog::init";
96  ex.addContext("Calling edm::InputFileCatalog::init()");
97  throw ex;
98  }
99  } else if (catType == edm::CatalogType::RucioCatalog) {
100  std::vector<edm::CatalogAttributes> const& tmp_dataCatalogs = localconfservice->dataCatalogs();
101  if (!fileLocators_.empty())
102  fileLocators_.clear();
103  //Construct all file locators from data catalogs. If a data catalog is invalid (wrong protocol for example), it is skipped and no file locator is constructed (an exception is thrown out from FileLocator::init).
104  for (const auto& catalog : tmp_dataCatalogs) {
105  try {
106  fileLocators_.push_back(std::make_unique<FileLocator>(catalog));
107  } catch (cms::Exception const& e) {
108  edm::LogWarning("InputFileCatalog")
109  << "Caught an exception while constructing a file locator in InputFileCatalog::init: " << e.what()
110  << "Skip this catalog";
111  }
112  }
113  if (fileLocators_.empty()) {
114  cms::Exception ex("FileCatalog");
115  ex << "Unable to construct any file locator in InputFileCatalog::init";
116  ex.addContext("Calling edm::InputFileCatalog::init()");
117  throw ex;
118  }
119  } else {
120  cms::Exception ex("FileCatalog");
121  ex << "Undefined catalog type";
122  ex.addContext("Calling edm::InputFileCatalog::init()");
123  throw ex;
124  }
125 
126  for (iter it = fileNames_.begin(), lt = logicalFileNames_.begin(), itEnd = fileNames_.end(); it != itEnd;
127  ++it, ++lt) {
128  boost::trim(*it);
129  std::vector<std::string> pfns;
130  if (it->empty()) {
131  cms::Exception ex("FileCatalog");
132  ex << "An empty string specified in the fileNames parameter for input source";
133  ex.addContext("Calling edm::InputFileCatalog::init()");
134  throw ex;
135  }
136  if (isPhysical(*it)) {
137  if (it->back() == ':') {
138  cms::Exception ex("FileCatalog");
139  ex << "An empty physical file name specified in the fileNames parameter for input source";
140  ex.addContext("Calling edm::InputFileCatalog::init()");
141  throw ex;
142  }
143  pfns.push_back(*it);
144  // Clear the LFN.
145  lt->clear();
146  } else {
147  boost::trim(*lt);
148  findFile(*lt, pfns, useLFNasPFNifLFNnotFound, catType);
149  }
150 
151  fileCatalogItems_.push_back(FileCatalogItem(pfns, *lt));
152  }
153  }
void findFile(std::string const &lfn, std::vector< std::string > &pfns, bool useLFNasPFNifLFNnotFound, edm::CatalogType catType)
std::vector< FileCatalogItem > fileCatalogItems_
static void trim(std::string &s)
std::vector< std::string > fileNames_
std::vector< edm::propagate_const< std::unique_ptr< FileLocator > > > fileLocators_
static bool isPhysical(std::string const &name)
std::vector< edm::propagate_const< std::unique_ptr< FileLocator > > > fileLocators_trivalCatalog_
edm::propagate_const< std::unique_ptr< FileLocator > > overrideFileLocator_
Log< level::Warning, false > LogWarning
std::vector< std::string > logicalFileNames_

◆ isPhysical()

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

Definition at line 48 of file InputFileCatalog.h.

References Skims_PA_cff::name.

Referenced by init().

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

◆ logicalFileNames()

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

Definition at line 45 of file InputFileCatalog.h.

References logicalFileNames_.

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

45 { return logicalFileNames_; }
std::vector< std::string > logicalFileNames_

Member Data Documentation

◆ fileCatalogItems_

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

Definition at line 58 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 62 of file InputFileCatalog.h.

Referenced by findFile(), and init().

◆ fileLocators_trivalCatalog_

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

Definition at line 61 of file InputFileCatalog.h.

Referenced by findFile(), and init().

◆ fileNames_

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

Definition at line 57 of file InputFileCatalog.h.

Referenced by init().

◆ logicalFileNames_

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

Definition at line 56 of file InputFileCatalog.h.

Referenced by init(), and logicalFileNames().

◆ overrideFileLocator_

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

Definition at line 59 of file InputFileCatalog.h.

Referenced by findFile(), and init().