Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LHCb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LHCb
LHCb
Commits
5ffbee85
Commit
5ffbee85
authored
2 years ago
by
Michel De Cian
Committed by
Rosen Matev
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add templated mergers
parent
cec9b7ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3665
Add templated mergers
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Event/EventBase/include/Event/SOACollectionMerger.h
+56
-0
56 additions, 0 deletions
Event/EventBase/include/Event/SOACollectionMerger.h
Event/EventBase/include/Event/VectorOfObjectsMerger.h
+52
-0
52 additions, 0 deletions
Event/EventBase/include/Event/VectorOfObjectsMerger.h
with
108 additions
and
0 deletions
Event/EventBase/include/Event/SOACollectionMerger.h
0 → 100644
+
56
−
0
View file @
5ffbee85
/*****************************************************************************\
* (c) Copyright 2000-2022 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
/** @class SOACollectionMerger.h SOACollectionMerger
*
* Merge SOACollections into one. Template to work with all containers based on SOACollection.
*
* @author Michel De Cian
* @date 05/07/2022
*/
#include
"Event/SOACollection.h"
#include
"LHCbAlgs/MergingTransformer.h"
#include
<string>
namespace
LHCb
{
template
<
typename
Type
>
struct
SOACollectionMerger
final
:
Algorithm
::
MergingTransformer
<
Type
(
const
Gaudi
::
Functional
::
vector_of_const_
<
Type
>&
)
>
{
SOACollectionMerger
(
const
std
::
string
&
name
,
ISvcLocator
*
pSvcLocator
)
:
Algorithm
::
MergingTransformer
<
Type
(
const
Gaudi
::
Functional
::
vector_of_const_
<
Type
>&
)
>
{
name
,
pSvcLocator
,
{
"InputLocations"
,
{}},
{
"OutputLocation"
,
{}}}
{}
Type
operator
()(
const
Gaudi
::
Functional
::
vector_of_const_
<
Type
>&
lists
)
const
override
{
if
(
lists
.
size
()
==
0
)
return
{};
Type
out
(
lists
[
0
].
zipIdentifier
(),
lists
[
0
].
get_allocator
()
);
std
::
size_t
overallSize
=
0
;
for
(
const
auto
&
list
:
lists
)
overallSize
+=
list
.
size
();
out
.
reserve
(
overallSize
);
m_nbObjectsCounter
+=
overallSize
;
for
(
const
auto
&
list
:
lists
)
{
if
(
list
.
empty
()
)
continue
;
for
(
const
auto
&
obj
:
list
.
simd
()
)
{
out
.
template
copy_back
<
SIMDWrapper
::
best
::
types
>(
list
,
obj
.
offset
(),
obj
.
loop_mask
()
);
}
}
return
out
;
}
private
:
mutable
Gaudi
::
Accumulators
::
SummingCounter
<>
m_nbObjectsCounter
{
this
,
"Nb of Merged Objects"
};
};
}
// namespace LHCb
This diff is collapsed.
Click to expand it.
Event/EventBase/include/Event/VectorOfObjectsMerger.h
0 → 100644
+
52
−
0
View file @
5ffbee85
/*****************************************************************************\
* (c) Copyright 2000-2022 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
/** @class SOACollectionMerger.h SOACollectionMerger
*
* Merge several std::vector<Type> into one. Template to work with all std::vector<Type>
*
* @author Michel De Cian
* @date 24/08/2022
*/
#include
"LHCbAlgs/MergingTransformer.h"
#include
<string>
namespace
LHCb
{
template
<
typename
Type
,
typename
Container
=
std
::
vector
<
Type
>
>
struct
VectorOfObjectsMerger
final
:
Algorithm
::
MergingTransformer
<
Container
(
const
Gaudi
::
Functional
::
vector_of_const_
<
Container
>&
)
>
{
VectorOfObjectsMerger
(
const
std
::
string
&
name
,
ISvcLocator
*
pSvcLocator
)
:
Algorithm
::
MergingTransformer
<
Container
(
const
Gaudi
::
Functional
::
vector_of_const_
<
Container
>&
)
>
{
name
,
pSvcLocator
,
{
"InputLocations"
,
{}},
{
"OutputLocation"
,
{}}}
{}
Container
operator
()(
const
Gaudi
::
Functional
::
vector_of_const_
<
Container
>&
lists
)
const
override
{
if
(
lists
.
size
()
==
0
)
return
{};
Container
out
;
std
::
size_t
overallSize
=
0
;
for
(
const
auto
&
list
:
lists
)
overallSize
+=
list
.
size
();
out
.
reserve
(
overallSize
);
m_nbObjectsCounter
+=
overallSize
;
for
(
const
auto
&
list
:
lists
)
{
if
(
list
.
empty
()
)
continue
;
out
.
insert
(
out
.
end
(),
list
.
begin
(),
list
.
end
()
);
}
return
out
;
}
private
:
mutable
Gaudi
::
Accumulators
::
SummingCounter
<>
m_nbObjectsCounter
{
this
,
"Nb of Merged Objects"
};
};
}
// namespace LHCb
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment