106{
108 const unsigned nc = (1 << nparticles);
110 strSelection.erase(
std::remove_if(strSelection.begin(), strSelection.end(),
111 [](char c){ return std::isspace(c); }), strSelection.end());
112 std::stringstream
ss(strSelection);
113
114 std::string word = "(?:!?T){" + std::to_string(nparticles) + "}(\\+(?:!?T){" + std::to_string(nparticles) + "})*";
115
116 if(std::regex_match(strSelection, std::regex(word)))
117 {
118 while(std::getline(
ss, word,
'+'))
119 {
120 if(!word.length()) continue;
122 while((pos=word.find("!T")) != std::string::npos) word.replace(pos, 2, 1, 'A');
126 }
127 return true;
128 }
129
130 std::regex rx0("([<>]=?)([0-9])(!?T)");
131 std::regex
rx1(
"=?([0-9])(-[0-9])?(!?T)");
132 std::regex rx2("(OS|SS)");
133 std::smatch sm;
136 uint8_t maxT=15, maxL=15, minT=0, minL=0;
137 while(std::getline(
ss, word,
','))
138 {
140 if(std::regex_match(word, sm, rx0))
141 {
142 uint8_t o = (sm[1].length()<=1)? 1 : 0;
143 if(sm[1].
str()[0]==
'>') nmin = sm[2].str()[0] -
'0' + o;
144 else
145 {
146 nmax = sm[2].str()[0] -
'0';
148 {
149 error =
"number of leptons constrained to be negative in the 'selection' argument: \"" + strSelection +
"\"";
151 return false;
152 }
154 }
155 }
156 else if(std::regex_match(word, sm, rx1))
157 {
158 nmin = sm[1].str()[0] - '0';
159 if(sm[2].
length())
nmax = sm[2].str()[1] -
'0';
161 }
162 else if(std::regex_match(word, sm, rx2))
163 {
165 {
166 error =
"both OS and SS requirements were specifed in the 'selection' argument: \"" + strSelection +
"\"; this is not allowed";
168 return false;
169 }
172 continue;
173 }
174 else
175 {
176 error =
"unable to understand the specified 'selection' argument: \"" + strSelection +
"\"";
178 return false;
179 }
181 {
182 error =
"unexpected error (nmin>nmax) while parsing the specified 'selection' argument: \"" + strSelection +
"\"";
184 return false;
185 }
186 bool count_loose = sm[sm.size()-1] == "!T";
187 if(count_loose)
188 {
189 minL = std::max(minL, nmin);
190 maxL = std::min(maxL,
nmax);
191 }
192 else
193 {
194 minT = std::max(minT, nmin);
195 maxT = std::min(maxT,
nmax);
196 }
197 for(
unsigned i=0;
i<
nc;++
i)
198 {
200 if(count_loose)
n = nparticles -
n;
202 }
204 }
206 {
207 error =
"the 'selection' argument is empty";
209 return false;
210 }
211
219 {
220 error =
"the specified 'selection' and 'process' arguments are not consistent";
222 return false;
223 }
224
225 return true;
226}
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.