Public Member Functions | List of all members
meta::MetadataParse Class Reference

Public Member Functions

 MetadataParse (std::string infile)
 
void PrintMetadata ()
 

Detailed Description

Definition at line 25 of file parseFCLMetadata.cxx.

Constructor & Destructor Documentation

meta::MetadataParse::MetadataParse ( std::string  infile)
explicit

Definition at line 38 of file parseFCLMetadata.cxx.

References om::cerr, meta::MetadataManager::DoParsing(), fhicl::ParameterSet::get_if_present(), cet::getenv(), meta::MetadataManager::getInstance(), fhicl::make_ParameterSet(), and fhicl::parse_document().

39  {
40  MetadataManager& fManager = MetadataManager::getInstance();
41 
42  char const* fhiclEnv = getenv("FHICL_FILE_PATH");
43  std::string searchPath;
44  if(*fhiclEnv == '\0'){
45  std::cerr << "FHICL_FILE_PATH is empty\n";
46  abort();
47  }
48  else searchPath = std::string(fhiclEnv) + ":";
49 
51  // parse a configuration file; obtain intermediate form
53  fhicl::parse_document(infile, policy, tbl);
54 
55  // convert to ParameterSet
57  fhicl::make_ParameterSet(tbl, pset);
58 
59  //fetch the appropriate sub-pset and pass to the manager
60  fhicl::ParameterSet metaPSet;
61  bool foundPSet = pset.get_if_present<fhicl::ParameterSet>("physics.analyzers.metadata.params", metaPSet);
62  if(foundPSet) fManager.DoParsing(metaPSet);
63  }
static MetadataManager & getInstance()
OStream cerr
Definition: OStream.cxx:7
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
string infile
std::string getenv(std::string const &name)
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)

Member Function Documentation

void meta::MetadataParse::PrintMetadata ( )

Definition at line 66 of file parseFCLMetadata.cxx.

References om::cout, allTimeWatchdog::endl, modifyFHiCL::found, meta::MetadataManager::getInstance(), meta::MetadataManager::GetMetadata(), it, and findDuplicateFiles::key.

Referenced by main().

67  {
68  MetadataManager& fManager = MetadataManager::getInstance();
69 
70  std::map<std::string, std::string> metamap = fManager.GetMetadata();
71 
72  std::cout << "{" << std::endl;
73  std::cout << " \"file_type\": \"mc_config\" " << std::endl;
74  std::cout << ",\"file_format\": \"fcl\" " << std::endl;
75 
76  for(auto& it: metamap){
77  std::string key = it.first;
78  std::string value = it.second;
79 
80  // Exclude base_release type entries from fcl metadata
81  size_t found = key.find("base_release");
82  if(found != std::string::npos) continue;
83 
84  std::cout << ",\"" << key
85  << "\":" << " "
86  << "\"" << value
87  << "\"" << std::endl;
88  }
89  std::cout << "}" << std::endl;
90  }
static MetadataManager & getInstance()
set< int >::iterator it
const XML_Char int const XML_Char * value
Definition: expat.h:331
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154

The documentation for this class was generated from the following file: