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 19 of file InputFileCatalog.cc.

References init().

24  init(override, useLFNasPFNifLFNnotFound, catType);
25  }
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 27 of file InputFileCatalog.cc.

27 {}

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 29 of file InputFileCatalog.cc.

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

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

29  {
30  std::vector<std::string> tmp;
31  tmp.reserve(fileCatalogItems_.size());
32  for (auto const& item : fileCatalogItems_) {
33  tmp.push_back(item.fileName(iCatalog));
34  }
35  return tmp;
36  }
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 139 of file InputFileCatalog.cc.

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

Referenced by init().

142  {
143  if (overrideFileLocator_) {
144  pfns.push_back(overrideFileLocator_->pfn(lfn, catType));
145  } else {
146  if (catType == edm::CatalogType::TrivialCatalog) {
147  for (auto const& locator : fileLocators_trivalCatalog_) {
148  std::string pfn = locator->pfn(lfn, edm::CatalogType::TrivialCatalog);
149  if (pfn.empty() && useLFNasPFNifLFNnotFound)
150  pfns.push_back(lfn);
151  else
152  pfns.push_back(pfn);
153  }
154  } else if (catType == edm::CatalogType::RucioCatalog) {
155  for (auto const& locator : fileLocators_) {
156  std::string pfn = locator->pfn(lfn, edm::CatalogType::RucioCatalog);
157  if (pfn.empty() && useLFNasPFNifLFNnotFound)
158  pfns.push_back(lfn);
159  else
160  pfns.push_back(pfn);
161  }
162  } else {
163  cms::Exception ex("FileCatalog");
164  ex << "Undefined catalog type";
165  ex.addContext("Calling edm::InputFileCatalog::findFile()");
166  throw ex;
167  }
168  }
169 
170  // Empty PFN will be found by caller.
171  }
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 38 of file InputFileCatalog.cc.

References cms::Exception::addContext(), 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().

40  {
41  typedef std::vector<std::string>::iterator iter;
42 
43  if (!overrideFileLocator_ && !inputOverride.empty()) {
44  if (catType == edm::CatalogType::TrivialCatalog) {
46  std::make_unique<FileLocator>(inputOverride); // propagate_const<T> has no reset() function
47  } else if (catType == edm::CatalogType::RucioCatalog) {
48  //now make a struct from input string
49  std::vector<std::string> tmps;
50  boost::algorithm::split(tmps, inputOverride, boost::is_any_of(std::string(",")));
51  if (tmps.size() != 5) {
52  cms::Exception ex("FileCatalog");
53  ex << "Trying to override input file catalog but invalid input override string " << inputOverride
54  << " (Should be site,subSite,storageSite,volume,protocol)";
55  ex.addContext("Calling edm::InputFileCatalog::init()");
56  throw ex;
57  }
58 
59  edm::CatalogAttributes inputOverride_struct(
60  tmps[0], tmps[1], tmps[2], tmps[3], tmps[4]); //site, subSite,storageSite,volume,protocol
61 
63  std::make_unique<FileLocator>(inputOverride_struct); // propagate_const<T> has no reset() function
64  }
65  }
66 
67  Service<SiteLocalConfig> localconfservice;
68  if (!localconfservice.isAvailable()) {
69  cms::Exception ex("FileCatalog");
70  ex << "edm::SiteLocalConfigService is not available";
71  ex.addContext("Calling edm::InputFileCatalog::init()");
72  throw ex;
73  }
74 
75  if (catType == edm::CatalogType::TrivialCatalog) {
76  std::vector<std::string> const& tmp_dataCatalogs = localconfservice->trivialDataCatalogs();
77  if (!fileLocators_trivalCatalog_.empty())
79 
80  //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 trivialDataCatalogs() of SiteLocalConfigService
81  fileLocators_trivalCatalog_.push_back(std::make_unique<FileLocator>(tmp_dataCatalogs.front()));
82 
83  for (auto it = tmp_dataCatalogs.begin() + 1; it != tmp_dataCatalogs.end(); ++it) {
84  try {
85  fileLocators_trivalCatalog_.push_back(std::make_unique<FileLocator>(*it));
86  } catch (cms::Exception const& e) {
87  continue;
88  }
89  }
90  } else if (catType == edm::CatalogType::RucioCatalog) {
91  std::vector<edm::CatalogAttributes> const& tmp_dataCatalogs = localconfservice->dataCatalogs();
92  if (!fileLocators_.empty())
93  fileLocators_.clear();
94  //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() of SiteLocalConfigService
95  fileLocators_.push_back(std::make_unique<FileLocator>(tmp_dataCatalogs.front()));
96  for (auto it = tmp_dataCatalogs.begin() + 1; it != tmp_dataCatalogs.end(); ++it) {
97  try {
98  fileLocators_.push_back(std::make_unique<FileLocator>(*it));
99  } catch (cms::Exception const& e) {
100  continue;
101  }
102  }
103  } else {
104  cms::Exception ex("FileCatalog");
105  ex << "Undefined catalog type";
106  ex.addContext("Calling edm::InputFileCatalog::init()");
107  throw ex;
108  }
109 
110  for (iter it = fileNames_.begin(), lt = logicalFileNames_.begin(), itEnd = fileNames_.end(); it != itEnd;
111  ++it, ++lt) {
112  boost::trim(*it);
113  std::vector<std::string> pfns;
114  if (it->empty()) {
115  cms::Exception ex("FileCatalog");
116  ex << "An empty string specified in the fileNames parameter for input source";
117  ex.addContext("Calling edm::InputFileCatalog::init()");
118  throw ex;
119  }
120  if (isPhysical(*it)) {
121  if (it->back() == ':') {
122  cms::Exception ex("FileCatalog");
123  ex << "An empty physical file name specified in the fileNames parameter for input source";
124  ex.addContext("Calling edm::InputFileCatalog::init()");
125  throw ex;
126  }
127  pfns.push_back(*it);
128  // Clear the LFN.
129  lt->clear();
130  } else {
131  boost::trim(*lt);
132  findFile(*lt, pfns, useLFNasPFNifLFNnotFound, catType);
133  }
134 
135  fileCatalogItems_.push_back(FileCatalogItem(pfns, *lt));
136  }
137  }
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_
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().