CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
loadFFTJetInterpolationTable.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 
4 #include "Alignment/Geners/interface/Reference.hh"
5 
9 
10 
11 static void dumpArchiveMetadata(gs::StringArchive& ar, std::ostream& os)
12 {
13  const unsigned long long idSmall = ar.smallestId();
14  if (!idSmall)
15  os << "!!! No records in the archive !!!" << std::endl;
16  else
17  {
18  const unsigned long long idLarge = ar.largestId();
19  unsigned long long count = 0;
20  for (unsigned long long id = idSmall; id <= idLarge; ++id)
21  if (ar.itemExists(id))
22  {
23  CPP11_shared_ptr<const gs::CatalogEntry> e =
24  ar.catalogEntry(id);
25  os << '\n';
26  e->humanReadable(os);
27  ++count;
28  }
29  os << '\n' << count << " records in the archive" << std::endl;
30  }
31 }
32 
33 
34 CPP11_auto_ptr<npstat::StorableMultivariateFunctor>
36  gs::StringArchive& ar, const bool verbose)
37 {
38  gs::SearchSpecifier nameSearch(ps.getParameter<std::string>("name"),
39  ps.getParameter<bool>("nameIsRegex"));
40  gs::SearchSpecifier categorySearch(ps.getParameter<std::string>("category"),
41  ps.getParameter<bool>("categoryIsRegex"));
42  gs::Reference<npstat::StorableMultivariateFunctor> ref(
43  ar, nameSearch, categorySearch);
44 
45  // Require that we get a unique item for this search
46  if (!ref.unique())
47  {
48  std::ostringstream os;
49  os << "Error in loadFFTJetInterpolationTable: table with name \""
50  << nameSearch.pattern() << "\" ";
51  if (nameSearch.useRegex())
52  os << "(regex) ";
53  os << "and category \""
54  << categorySearch.pattern() << "\" ";
55  if (categorySearch.useRegex())
56  os << "(regex) ";
57  os << "is not ";
58  if (ref.empty())
59  os << "found";
60  else
61  os << "unique";
62  os << " in the archive. Archive contents are:\n";
63  dumpArchiveMetadata(ar, os);
64  throw cms::Exception("FFTJetBadConfig", os.str());
65  }
66 
67  CPP11_auto_ptr<npstat::StorableMultivariateFunctor> p = ref.get(0);
68  if (verbose)
69  {
70  std::cout << "In loadFFTJetInterpolationTable: loaded table with metadata"
71  << std::endl;
72  CPP11_shared_ptr<const gs::CatalogEntry> e = ref.indexedCatalogEntry(0);
73  e->humanReadable(std::cout);
74  std::cout << std::endl;
75  std::cout << "Actual table class name is \""
76  << p->classId().name() << '"' << std::endl;
77  }
78  return p;
79 }
T getParameter(std::string const &) const
CPP11_auto_ptr< npstat::StorableMultivariateFunctor > loadFFTJetInterpolationTable(const edm::ParameterSet &ps, gs::StringArchive &ar, bool verbose)
tuple cout
Definition: gather_cfg.py:121
static void dumpArchiveMetadata(gs::StringArchive &ar, std::ostream &os)