Falaise  4.0.1
SuperNEMO Software Toolkit
metadata_utils.h
Go to the documentation of this file.
1 //! \file falaise/app/metadata_utils.h
2 //! \brief Utilities for accessing metadata
3 //
4 // Copyright (c) 2017 by François Mauger <mauger@lpccaen.in2p3.fr>
5 // Copyright (c) 2017 by The Université de Caen Normandie
6 //
7 // This file is part of falaise.
8 //
9 // falaise is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // falaise is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with falaise. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef FALAISE_APP_METADATA_UTILS_H
23 #define FALAISE_APP_METADATA_UTILS_H
24 
25 // Standard library:
26 #include <iostream>
27 #include <string>
28 
29 // Third party:
30 // - Boost:
31 #include <boost/variant.hpp>
32 // - Bayeux:
34 
35 namespace falaise {
36 
37 namespace app {
38 
39 //! \brief Metadata collector
41  public:
42  //! Constructor
43  metadata_collector(const uint32_t flags_ = 0);
44 
45  //! Set the input data file from which we extract metadata
46  void set_input_data_file(const std::string &);
47 
48  //! Set the input plain metadata file
49  void set_input_metadata_file(const std::string &);
50 
51  //! Extract metadata from input data file (embedded metadata)
53 
54  //! Extract metadata from input metadata file
56 
57  //! Extract metadata from input metadata file
59 
60  private:
61  std::string _input_data_file_; //!< Input data file from which extraction of metadata is done
62  std::string _input_metadata_file_; //!< Input metadata plain file
63 };
64 
65 //! \brief Commonly used parameters extracted from input metadata
67  std::string userProfile = ""; //!< the user profile used to produce input data
68  std::string experimentalSetupUrn = ""; //!< the experimental setup tag used to produce input data
69  std::string variantConfigUrn = ""; //!< the variant service tag used to produce input data
70  std::string variantConfigPath =
71  ""; //!< the variant service configuration file path used to produce input data
72  std::string variantProfileUrn = ""; //!< the variant profile tag used to produce input data
73  std::string variantProfilePath = ""; //!< the variant profile file used to produce input data
74  std::string servicesConfigUrn =
75  ""; //!< the services configuration tag used to produce input data
76  std::string servicesConfigPath =
77  ""; //!< the services configuration file path used to produce input data
78  std::size_t numberOfEvents = 0; //!< the number of event after input data
79  bool doSimulation = false; //!< the flag for simulation input
80  std::string simuSetupUrn = ""; //!< the simulation setup tag used to produce input data
81  bool doDigitization = false; //!< the flag for digitization input
82  std::string digiSetupUrn = ""; //!< the digitization setup tag used to produce input data
83  bool doReconstruction = false; //!< the flag for reconstruction input
84  std::string recSetupUrn = ""; //!< the reconstruction setup tag used to produce input data
85 
86  // Reset parameters to default values
87  void reset();
88 
89  // Scan the source metadata container and extract parameters' values
90  void scan(const datatools::multi_properties &);
91 
92  // Raw print
93  void print(std::ostream &out_) const;
94 };
95 
96 //! \brief Metadata scanner
98  public:
99  typedef boost::variant<bool, int, double, std::string> prop_value_type;
100 
101  //! Constructor
103 
104  bool check_section(const std::string &section_name_, const std::string &section_type_) const;
105 
106  const datatools::properties &get_section(const std::string &section_name_,
107  const std::string &section_type_) const;
108 
109  bool find_boolean(const std::string &section_name_, const std::string &section_type_,
110  const std::string &propKey_, bool &propValue_) const;
111 
112  bool find_integer(const std::string &section_name_, const std::string &section_type_,
113  const std::string &propKey_, int &propValue_) const;
114 
115  bool find_size(const std::string &section_name_, const std::string &section_type_,
116  const std::string &propKey_, std::size_t &propValue_) const;
117 
118  bool find_real(const std::string &section_name_, const std::string &section_type_,
119  const std::string &propKey_, double &propValue_) const;
120 
121  bool find_string(const std::string &section_name_, const std::string &section_type_,
122  const std::string &propKey_, std::string &propValue_) const;
123 
124  bool find_path(const std::string &section_name_, const std::string &section_type_,
125  const std::string &propKey_, std::string &propValue_) const;
126 
127  private:
128  bool _find_data_in_section_(const std::string &section_name_, const std::string &section_type_,
129  const std::string &propKey_,
130  datatools::properties::data &data_) const;
131 
132  private:
133  const datatools::multi_properties &_mp_; //!< The source input metadata
134 };
135 
136 } // namespace app
137 
138 } // namespace falaise
139 
140 #endif // FALAISE_APP_METADATA_UTILS_H
const datatools::properties & get_section(const std::string &section_name_, const std::string &section_type_) const
std::string simuSetupUrn
the simulation setup tag used to produce input data
Definition: metadata_utils.h:80
Metadata collector.
Definition: metadata_utils.h:40
std::string variantConfigPath
the variant service configuration file path used to produce input data
Definition: metadata_utils.h:70
bool find_path(const std::string &section_name_, const std::string &section_type_, const std::string &propKey_, std::string &propValue_) const
metadata_scanner(const datatools::multi_properties &)
Constructor.
datatools::multi_properties get_metadata_from_data_file() const
Extract metadata from input data file (embedded metadata)
bool doSimulation
the flag for simulation input
Definition: metadata_utils.h:79
metadata_collector(const uint32_t flags_=0)
Constructor.
bool find_boolean(const std::string &section_name_, const std::string &section_type_, const std::string &propKey_, bool &propValue_) const
std::size_t numberOfEvents
the number of event after input data
Definition: metadata_utils.h:78
bool find_integer(const std::string &section_name_, const std::string &section_type_, const std::string &propKey_, int &propValue_) const
std::string variantProfilePath
the variant profile file used to produce input data
Definition: metadata_utils.h:73
Commonly used parameters extracted from input metadata.
Definition: metadata_utils.h:66
std::string variantConfigUrn
the variant service tag used to produce input data
Definition: metadata_utils.h:69
bool check_section(const std::string &section_name_, const std::string &section_type_) const
std::string servicesConfigPath
the services configuration file path used to produce input data
Definition: metadata_utils.h:76
std::string recSetupUrn
the reconstruction setup tag used to produce input data
Definition: metadata_utils.h:84
Definition: metadata_utils.h:35
void scan(const datatools::multi_properties &)
std::string digiSetupUrn
the digitization setup tag used to produce input data
Definition: metadata_utils.h:82
datatools::multi_properties get_metadata() const
Extract metadata from input metadata file.
bool find_string(const std::string &section_name_, const std::string &section_type_, const std::string &propKey_, std::string &propValue_) const
bool find_size(const std::string &section_name_, const std::string &section_type_, const std::string &propKey_, std::size_t &propValue_) const
std::string variantProfileUrn
the variant profile tag used to produce input data
Definition: metadata_utils.h:72
datatools::multi_properties get_metadata_from_metadata_file() const
Extract metadata from input metadata file.
void set_input_data_file(const std::string &)
Set the input data file from which we extract metadata.
void set_input_metadata_file(const std::string &)
Set the input plain metadata file.
bool doDigitization
the flag for digitization input
Definition: metadata_utils.h:81
bool doReconstruction
the flag for reconstruction input
Definition: metadata_utils.h:83
std::string userProfile
the user profile used to produce input data
Definition: metadata_utils.h:67
boost::variant< bool, int, double, std::string > prop_value_type
Definition: metadata_utils.h:99
std::string servicesConfigUrn
the services configuration tag used to produce input data
Definition: metadata_utils.h:74
Metadata scanner.
Definition: metadata_utils.h:97
bool find_real(const std::string &section_name_, const std::string &section_type_, const std::string &propKey_, double &propValue_) const
std::string experimentalSetupUrn
the experimental setup tag used to produce input data
Definition: metadata_utils.h:68
void print(std::ostream &out_) const