14 association_(association),
21 std::vector<ThinnedAssociationBranches>::const_iterator
26 std::vector<ThinnedAssociationBranches>::const_iterator
31 std::vector<ThinnedAssociationBranches>::const_iterator
37 {
return x.parent() < y.parent(); });
40 std::vector<ThinnedAssociationBranches>::const_iterator
46 {
return x.parent() < y.parent(); });
53 {
return x.
parent() < y.parent() ?
true : y.parent() < x.
parent() ?
false : x.
association() < y.association(); });
66 std::vector<std::pair<BranchID, ThinnedAssociationBranches const*> >
68 std::vector<std::pair<BranchID, ThinnedAssociationBranches const*> >
temp;
70 temp.push_back(std::make_pair(item.association(), &item));
72 std::sort(temp.begin(), temp.end(), [](std::pair<BranchID, ThinnedAssociationBranches const*>
const&
x,
73 std::pair<BranchID, ThinnedAssociationBranches const*>
const& y)
74 {
return x.first < y.first; });
81 std::set<BranchID>
const& keptProductsInEvent,
82 std::map<BranchID, bool>& keepAssociation)
const {
84 keepAssociation.clear();
87 std::vector<std::pair<BranchID, ThinnedAssociationBranches const*> > assocToBranches =
90 for(
auto association : associationDescriptions) {
91 if(association->isAlias()) {
92 keepAssociation.insert(std::make_pair(association->branchID(),
false));
94 std::set<BranchID> branchesInRecursion;
106 std::vector<std::pair<BranchID, ThinnedAssociationBranches const*> >
const& associationToBranches,
107 std::set<BranchID>& branchesInRecursion,
108 std::set<BranchID>
const& keptProductsInEvent,
109 std::map<BranchID, bool>& keepAssociation)
const {
113 auto decision = keepAssociation.find(association);
114 if(decision != keepAssociation.end()) {
115 return decision->second;
120 if(!branchesInRecursion.insert(association).second) {
126 std::make_pair(association, static_cast<ThinnedAssociationBranches const*>(
nullptr)),
127 [](std::pair<BranchID, ThinnedAssociationBranches const*>
const&
x,
128 std::pair<BranchID, ThinnedAssociationBranches const*>
const& y)
129 {
return x.first < y.first; });
132 throw edm::Exception(
errors::LogicError,
"ThinnedAssociationHelper::shouldKeepAssociation could not find branches information, contact Framework developers");
134 BranchID const& thinnedCollection = branches->second->thinned();
135 if(keptProductsInEvent.find(thinnedCollection) != keptProductsInEvent.end()) {
136 keepAssociation.insert(std::make_pair(association ,
true));
142 auto iterEnd =
parentEnd(thinnedCollection);
149 keepAssociation.insert(std::make_pair(association ,
true));
154 keepAssociation.insert(std::make_pair(association ,
false));
159 bool foundMatch =
false;
178 std::vector<ThinnedAssociationBranches>
const&
inputData = helper.
data();
179 for (
auto const& inputEntry : inputData) {
185 std::vector<BranchID>
const& associationsFromSecondary) {
186 if(associationsFromSecondary.empty())
return;
188 std::vector<std::pair<BranchID, ThinnedAssociationBranches const*> > assocToBranches = helper.
associationToBranches();
190 for(
BranchID const& association : associationsFromSecondary) {
192 auto branches = std::lower_bound(assocToBranches.begin(), assocToBranches.end(),
193 std::make_pair(association, static_cast<ThinnedAssociationBranches const*>(
nullptr)),
194 [](std::pair<BranchID, ThinnedAssociationBranches const*>
const&
x,
195 std::pair<BranchID, ThinnedAssociationBranches const*>
const& y)
196 {
return x.first < y.first; });
198 if(branches == assocToBranches.end() || branches->first != association) {
200 "ThinnedAssociationHelper::initAssociationsFromSecondary could not find branches information, contact Framework developers");
208 std::map<BranchID, bool>
const& keepAssociation,
209 std::map<BranchID::value_type, BranchID::value_type>
const& droppedBranchIDToKeptBranchID) {
211 for(
auto const& associationBranches : parentThinnedAssociationsHelper.
data()) {
212 auto keep = keepAssociation.find(associationBranches.association());
213 if(
keep != keepAssociation.end() &&
keep->second) {
215 auto iter = droppedBranchIDToKeptBranchID.find(parent.
id());
216 if(iter != droppedBranchIDToKeptBranchID.end()) {
219 BranchID thinned = associationBranches.thinned();
220 iter = droppedBranchIDToKeptBranchID.find(thinned.
id());
221 if(iter != droppedBranchIDToKeptBranchID.end()) {
224 addAssociation(parent, associationBranches.association(), thinned);
233 if(associationsFromSecondary.empty())
return;
235 std::vector<std::pair<BranchID, ThinnedAssociationBranches const*> > assocToBranches =
238 for(
BranchID const& association : associationsFromSecondary) {
240 auto branches = std::lower_bound(assocToBranches.begin(), assocToBranches.end(),
241 std::make_pair(association, static_cast<ThinnedAssociationBranches const*>(
nullptr)),
242 [](std::pair<BranchID, ThinnedAssociationBranches const*>
const&
x,
243 std::pair<BranchID, ThinnedAssociationBranches const*>
const& y)
244 {
return x.first < y.first; });
246 if(branches == assocToBranches.end() || branches->first != association) {
248 "ThinnedAssociationHelper::initAssociationsFromSecondary could not find branches information, contact Framework developers");
void initAssociationsFromSecondary(std::vector< BranchID > const &, ThinnedAssociationsHelper const &)
std::vector< ThinnedAssociationBranches > const & data() const
void addAssociation(BranchID const &, BranchID const &, BranchID const &)
void requireMatch(ThinnedAssociationBranches const &input) const
BranchID const & parent() const
ThinnedAssociationBranches()
std::vector< std::pair< BranchID, ThinnedAssociationBranches const * > > associationToBranches() const
void updateFromPrimaryInput(ThinnedAssociationsHelper const &)
std::vector< ThinnedAssociationBranches >::const_iterator end() const
static std::string const input
std::vector< ThinnedAssociationBranches >::const_iterator parentEnd(BranchID const &) const
void selectAssociationProducts(std::vector< BranchDescription const * > const &associationDescriptions, std::set< BranchID > const &keptProductsInEvent, std::map< BranchID, bool > &keepAssociation) const
T x() const
Cartesian x coordinate.
BranchID const & association() const
void updateFromSecondaryInput(ThinnedAssociationsHelper const &, std::vector< BranchID > const &associationsFromSecondary)
std::vector< ThinnedAssociationBranches > vThinnedAssociationBranches_
std::vector< ThinnedAssociationBranches >::const_iterator begin() const
std::vector< ThinnedAssociationBranches >::const_iterator parentBegin(BranchID const &) const
void updateFromParentProcess(ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > const &keepAssociation, std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
ThinnedAssociationsHelper()
bool shouldKeepAssociation(BranchID const &association, std::vector< std::pair< BranchID, ThinnedAssociationBranches const * > > const &associationToBranches, std::set< BranchID > &branchesInRecursion, std::set< BranchID > const &keptProductsInEvent, std::map< BranchID, bool > &keepAssociation) const
BranchID const & thinned() const
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)