34 std::vector<std::string>
35 splitString (
const std::string& input,
const std::string& separator)
37 std::vector<std::string>
result;
39 while ((
split =
input.find (separator, start)) != std::string::npos)
54 std::unique_ptr<ISelectionReadAccessor>& accessor,
57 using namespace msgSelectionHelpers;
61 accessor = std::make_unique<SelectionReadAccessorNull> (
true);
62 return StatusCode::SUCCESS;
68 }
catch (
const std::exception&
e) {
69 ANA_MSG_FATAL(
"Failure to parse expression: '" << expr <<
"': " <<
e.what());
70 return StatusCode::FAILURE;
73 return StatusCode::SUCCESS;
79 struct SplitData final
86 StatusCode
fill (
const std::string&
name,
bool defaultToChar)
88 using namespace msgSelectionHelpers;
97 }
else if (option ==
"as_char")
105 }
else if (option ==
"as_bits")
108 }
else if (option ==
"invert")
113 ANA_MSG_ERROR (
"invalid option " << option <<
"for selection decoration");
114 return StatusCode::FAILURE;
118 if (asChar && asBits)
120 ANA_MSG_ERROR (
"can't specify both 'as_bits' and 'as_char' for the same selection decoration, pick one!!!");
121 return StatusCode::FAILURE;
124 if (!asChar && !asBits)
131 return StatusCode::SUCCESS;
139 std::unique_ptr<ISelectionReadAccessor>& accessor,
142 using namespace msgSelectionHelpers;
144 if (
name.find (
"%SYS%") != std::string::npos)
146 accessor = std::make_unique<SelectionAccessorReadSys>(
name);
147 return StatusCode::SUCCESS;
153 if (splitData.asChar)
154 accessor = std::make_unique<SelectionReadAccessorChar> (splitData.var);
156 accessor = std::make_unique<SelectionReadAccessorBits> (splitData.var);
158 if (splitData.invert)
160 accessor = std::make_unique<SelectionReadAccessorInvert>
161 (std::move (accessor));
164 return StatusCode::SUCCESS;
170 std::unique_ptr<ISelectionWriteAccessor>& accessor,
173 using namespace msgSelectionHelpers;
175 if (
name.find (
"%SYS%") != std::string::npos)
177 accessor = std::make_unique<SelectionWriteAccessorSys>(
name);
178 return StatusCode::SUCCESS;
184 if (splitData.asChar)
185 accessor = std::make_unique<SelectionWriteAccessorChar> (splitData.var);
187 accessor = std::make_unique<SelectionWriteAccessorBits> (splitData.var);
189 if (splitData.invert)
191 accessor = std::make_unique<SelectionWriteAccessorInvert>
192 (std::move (accessor));
195 return StatusCode::SUCCESS;
std::vector< std::string > splitString(const std::string &in, std::string_view delim)
Public interface for the expression parsing facility.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Select isolated Photons, Electrons and Muons.
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
StatusCode makeSelectionReadAccessorVar(const std::string &name, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionReadAccessor accessing the given decoration.
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
::StatusCode StatusCode
StatusCode definition for legacy code.
void fill(H5::Group &out_file, size_t iterations)