14 s.erase(
std::remove(s.begin(), s.end(),
' '), s.end());
15 s.erase(
std::remove(s.begin(), s.end(),
'\t'), s.end());
18 void test_remove_whitespace() {
30 typedef std::pair<std::string, std::string> parsed_path_spec_t;
32 parsed_path_spec_t&
output) {
34 remove_whitespace(trimmed_path_spec);
37 if(colon == std::string::npos) {
38 output.first = trimmed_path_spec;
40 output.first = trimmed_path_spec.substr(0, colon);
41 output.second = trimmed_path_spec.substr(colon + 1,
42 trimmed_path_spec.size());
46 void test_parse_path_spec() {
47 std::vector<std::string> paths;
48 paths.push_back(
"a:p1");
49 paths.push_back(
"b:p2");
50 paths.push_back(
" c");
51 paths.push_back(
"ddd\t:p3");
52 paths.push_back(
"eee: p4 ");
54 std::vector<parsed_path_spec_t> parsed(paths.size());
55 for(
size_t i = 0;
i < paths.size(); ++
i) {
56 parse_path_spec(paths[
i], parsed[i]);
59 assert(parsed[0].
first ==
"a");
60 assert(parsed[0].
second ==
"p1");
61 assert(parsed[1].
first ==
"b");
62 assert(parsed[1].
second ==
"p2");
63 assert(parsed[2].
first ==
"c");
64 assert(parsed[2].
second ==
"");
65 assert(parsed[3].
first ==
"ddd");
66 assert(parsed[3].
second ==
"p3");
67 assert(parsed[4].
first ==
"eee");
68 assert(parsed[4].
second ==
"p4");
76 test_remove_whitespace();
77 test_parse_path_spec();
86 std::vector<std::string>
const& iAllTriggerNames,
98 std::vector<std::string> path_specs =
99 iPSet.
getParameter<std::vector<std::string> >(
"SelectEvents");
101 if(path_specs.empty()) {
108 std::vector<parsed_path_spec_t> parsed_paths(path_specs.size());
109 for(
size_t i = 0;
i < path_specs.size(); ++
i) {
110 parse_path_spec(path_specs[
i], parsed_paths[i]);
112 oSelector.
setup(parsed_paths, iAllTriggerNames, iProcessName,
std::move(iC));
119 TriggerResultsBasedEventSelector::TriggerResultsBasedEventSelector() :
121 wantAllEvents_(
false)
131 std::vector<std::string>
const& triggernames,
136 std::map<std::string, std::vector<std::string> > paths_for_process;
137 for (
auto const& path_spec : path_specs) {
139 if (path_spec.second ==
"") {
140 paths_for_process[process_name].push_back(path_spec.first);
143 paths_for_process[path_spec.second].push_back(path_spec.first);
148 for (
auto const&
path : paths_for_process) {
151 if (
path.first == process_name) {
169 bool match = selector.match(*handle);
180 std::map<
std::string, std::vector<std::pair<std::string, int> > >
const& outputModulePathPositions,
181 bool anyProductProduced) {
184 selectEventsInfo.
addParameter<
bool>(
"InProcessHistory", anyProductProduced);
185 std::vector<std::string> endPaths;
186 std::vector<int> endPathPositions;
190 if (!iLabel.empty()) {
191 std::map<std::string, std::vector<std::pair<std::string, int> > >::const_iterator iter = outputModulePathPositions.find(iLabel);
192 assert(iter != outputModulePathPositions.end());
193 for(
auto const& item : iter->second) {
194 endPaths.push_back(item.first);
195 endPathPositions.push_back(item.second);
198 selectEventsInfo.
addParameter<std::vector<std::string> >(
"EndPaths", endPaths);
199 selectEventsInfo.
addParameter<std::vector<int> >(
"EndPathPositions", endPathPositions);
200 if (!selectEventsInfo.
exists(
"SelectEvents")) {
201 selectEventsInfo.
addParameter<std::vector<std::string> >(
"SelectEvents", std::vector<std::string>());
205 return selectEventsInfo.
id();
T getParameter(std::string const &) const
bool wantEvent(EventForOutput const &e)
ParameterSetID id() const
static const edm::TypeID s_TrigResultsType(typeid(edm::TriggerResults))
bool exists(std::string const ¶meterName) const
checks if a parameter exists
U second(std::pair< T, U > const &p)
void run_all_output_module_tests()
bool getByToken(EDGetToken token, TypeID const &typeID, BasicHandle &result) const
void addParameter(std::string const &name, T const &value)
bool configureEventSelector(edm::ParameterSet const &iPSet, std::string const &iProcessName, std::vector< std::string > const &iAllTriggerNames, edm::detail::TriggerResultsBasedEventSelector &oSelector, ConsumesCollector &&iC)
void copyForModify(ParameterSet const &other)
def remove(d, key, TELL=False)
void setup(std::vector< parsed_path_spec_t > const &path_specs, std::vector< std::string > const &triggernames, std::string const &process_name, ConsumesCollector &&iC)
ParameterSetID registerProperSelectionInfo(edm::ParameterSet const &iInitial, std::string const &iLabel, std::map< std::string, std::vector< std::pair< std::string, int > > > const &outputModulePathPositions, bool anyProductProduced)
ParameterSet const & registerIt()
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)