17 bool operator () (
const std::size_t& lhs,
const std::size_t rhs){
27 const std::vector<std::size_t>& rhs){
28 if(lhs.size() < rhs.size()){
return true;}
29 if(rhs.size() < rhs.size()){
return false;}
31 for(std::size_t i = 0; i < lhs.size(); ++i){
32 if(lhs[i] > rhs[i]){
return false;}
53 for(std::size_t i = 0; i <
m_tree.size(); ++i){
55 m_testedBy.emplace(i, std::set<std::size_t>{});
65 collector->
collect(
"FastReducer early return",
66 "from findInitialJetGroups");
76 collector->
collect(
"FastReducer early return",
77 "from propagateJetGroups");
85 collector->
collect(
"FastReducer returning",
86 "from propagateJetGroups");
104 std::set<std::size_t> rootSatJetGroupInds(
m_satisfiedBy.at(0).begin(),
109 std::set<std::size_t> rootElSatJetGroupInds;
110 for (
const auto& ji : rootSatJetGroupInds) {
111 rootElSatJetGroupInds.insert(
m_jg2elemjgs.at(ji).begin(),
120 auto leaves =
m_tree.leaves();
122 for (
const auto& ci : leaves) {
123 std::set<std::size_t> satJetGroupInds;
130 std::set<std::size_t> elSatJetGroupInds;
131 for (
const auto& ji : satJetGroupInds) {
140 std::stringstream
ss;
141 ss <<
"elSatJettGroupInds.size() "
144 << elSatJetGroupInds.size();
145 collector->
collect(
"FastReducer",
ss.str());
154 auto end = rootElSatJetGroupInds.end();
155 for(
const auto& ji : elSatJetGroupInds) {
157 if (rootElSatJetGroupInds.find(ji) != end){
165 collector->
collect(
"FastReducer",
166 "collected " + std::to_string(jetCollector.
size()));
179 auto leaves =
m_tree.leaves();
184 for(
const auto& leaf: leaves){
186 auto filtered_jets = jv;
188 if (filter_ind != -1) {
190 filtered_jets = filter->filter(filtered_jets, collector);
193 auto iters = std::make_pair(filtered_jets.begin(),
194 filtered_jets.end());
203 auto jg = grouper->next();
204 if (jg.empty()) {
break;}
227 std::vector<std::size_t>& elem_indices =
m_jg2elemjgs[jg_ind];
228 if (elem_indices.empty()) {
230 elem_indices.reserve(jg.size());
231 for (
const auto& hj : jg){
234 auto single_jet_group = std::vector{hj};
235 auto single_jet_index =
m_jgRegister.record(single_jet_group);
236 auto& single_jet_elems =
m_jg2elemjgs[single_jet_index];
237 if (single_jet_elems.empty()) {
238 single_jet_elems.push_back(single_jet_index);
243 elem_indices.push_back(single_jet_index);
248 elem_indices.push_back(jg_ind);
265 for (
const auto& i : leaves) {
288 typedef std::priority_queue<std::size_t,
289 std::vector<std::size_t>,
293 DepthQueue to_process(comparator);
300 if(!(item.second.empty())){
301 to_process.push(item.first);
305 while(!to_process.empty()){
307 auto k = to_process.top();
318 collector->
collect(
"FastReducer",
319 "Condition node 0 fails");
327 auto siblings =
m_tree.siblings(k);
328 for(
const auto& s : siblings){
339 std::size_t par =
m_tree.parent(k);
340 to_process.push(par);
347 const std::vector<std::size_t>& siblings,
359 std::size_t par =
m_tree.parent(child);
362 if(child == 0){
return true;}
381 auto jg_indices = jg_product->next(collector);
387 while (!jg_indices.empty()){
388 if (!std::is_sorted(jg_indices.begin(), jg_indices.end())) {
389 throw std::runtime_error(
"Jet hypo unsorted jet group");
392 for (
const auto& ind : jg_indices) {
394 throw std::runtime_error(
"Jet hypo jet group with non-elementary index");
401 for(
const auto& i : jg_indices){
403 jg.insert(jg.end(), jetGroup.begin(), jetGroup.end());
411 jg_indices = jg_product->next(collector);
427 jg_indices = jg_product->next(collector);
434 if(collector and !par_satisfied){
435 collector->
collect(
"FastReducer",
436 "Condition node " + std::to_string(par) +
440 return par_satisfied;
446 std::stringstream
ss;
447 ss <<
"FastReducer:\n";
448 ss <<
" treeVector: " <<
m_tree <<
'\n';;
449 ss <<
"FastReducer Conditions ["
452 std::size_t
count{0u};
454 auto sc = std::to_string(
count++);
455 sc.insert(
sc.begin(), 3-
sc.length(),
' ');
456 ss <<
sc <<
": "<< c->toString() +
'\n';
465 std::stringstream
ss;
466 ss <<
"FastReducer data structure dumps\nindToJetGroup:\n";
469 for(
const auto& j :
pair.second){
475 ss <<
"satisfiedBy: \n";
478 for(
const auto& i :
pair.second){
485 ss <<
"testedBy: \n";
488 for(
const auto& i :
pair.second){
494 ss <<
"jg to elemental jgs: \n";
498 for(
const auto& i :
pair.second){
510 if(!collector){
return;}
512 collector->
collect(
"FastReducer",
521 std::stringstream ss0;
522 ss0 <<
"FastReducer jet group "
523 << ind <<
" [" << jg.size() <<
"]:";
525 std::stringstream ss1;
527 const void* address =
static_cast<const void*
>(ip.get());
528 ss1 <<
"\n " << address <<
" eta " << ip->eta()
530 <<
" et " << ip->et();
533 collector->
collect(ss0.str(), ss1.str());
537 std::size_t n_injets,
541 if(!collector) {
return;}
543 std::stringstream ss0;
544 ss0 <<
"FastReducer filtering Condition index: " << leaf_ind;
546 std::stringstream ss1;
547 ss1 <<
"n jets. in: " << n_injets <<
" filtered: " << n_filteredjets <<
'\n';
549 collector->
collect(ss0.str(), ss1.str());
562 auto capSat =
m_conditions.at(ind)->multiplicitySatisfied(jgMult, collector);
563 if (!capSat and collector) {
564 collector->
collect(
"FastReduce",
"Condition " + std::to_string(ind)
565 +
" unsatisfied multiplicity, aborting");
std::vector< int > ConditionFilterInds
std::vector< std::unique_ptr< IHypoJetVectorFilter > > ConditionFilters
std::unique_ptr< ITrigJetHypoInfoCollector > Collector
std::unique_ptr< IJetGrouper > grouperByCapacityFactory(unsigned int cap, const HypoJetCIter &b, const HypoJetCIter &e)
std::vector< pHypoJet > HypoJetVector
std::unique_ptr< IJetGroupProduct > makeJetGroupProduct(const std::vector< std::size_t > &siblings, const CondInd2JetGroupsInds &satisfiedBy, const std::vector< std::size_t > &condMult, const std::vector< unsigned int > &condCap, const std::vector< int > &condClique, const JetGroupInd2ElemInds &jg2elemjgs, std::size_t parentCap, bool simpleTree, const Collector &)
std::vector< ConditionPtr > ConditionPtrs
bool operator()(const std::size_t &lhs, const std::size_t rhs)
DepthComparison(const Tree &t)
JetGroupInd2ElemInds m_jg2elemjgs
map jet group indices to indices of incoming jet groups
std::vector< int > m_conditionClique
std::vector< unsigned int > m_conditionCap
Tree m_tree
tree structure for Conditions objects.
bool pass() const
determine whether a set of jets satisfies all hypo conditions.
CondInd2JetGroupsInds m_satisfiedBy
bool m_pass
event pass flag
void collectLeafJets(xAODJetCollector &jetCollector, const Collector &collector) const
const ConditionPtrs & m_conditions
ConditionFilterInds m_conditionFilterInds
bool propagate_(std::size_t child, const std::vector< std::size_t > &siblings, const Collector &)
std::vector< std::size_t > m_conditionMult
void dumpDataStructures(const Collector &) const
std::string toString() const
std::map< std::size_t, std::set< std::size_t > > m_testedBy
map Condition index onto a set of indices the condition has been tested with - used to prevent retest...
void recordJetGroup(std::size_t ind, const HypoJetVector &jg, const Collector &collector) const
FastReducer(const HypoJetVector &jv, const ConditionPtrs &conditionObjects, const ConditionFilters &conditionFilters, const ConditionFilterInds &conditionFilterInds, const Tree &conditionsTree, xAODJetCollector &jetCollector, const Collector &collector)
JetGroupRegister m_jgRegister
bool capacitySatisfied(std::size_t ind, const Collector &collector) const
const ConditionFilters & m_conditionFilters
void recordFiltering(std::size_t leaf_ind, std::size_t n_inputjets, int n_filteredjets, const Collector &collector) const
std::string dataStructuresToStr() const
std::map< std::size_t, HypoJetVector > m_indJetGroup
map jet group indices to jet groups
bool propagateJetGroups(const Collector &collector)
bool findInitialJetGroups(const HypoJetVector &jv, const Collector &collector)
set up the data structures for propagation.
virtual void collect(const std::string &, const std::string &)=0
void addJets(const HypoJetCIter &begin, const HypoJetCIter &end, int chainPartInd=-1)
std::string find(const std::string &s)
return a remapped string
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
bool operator()(const std::vector< std::size_t > &lhs, const std::vector< std::size_t > &rhs)