Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Project Juggler
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
21
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
EIC
Project Juggler
Merge requests
!543
fix: "Immutable objects can only be added to subset collections" exception
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
fix: "Immutable objects can only be added to subset collections" exception
fix-immutable-objects-exception
into
main
Overview
0
Commits
4
Pipelines
4
Changes
1
Merged
Wouter Deconinck
requested to merge
fix-immutable-objects-exception
into
main
9 months ago
Overview
0
Commits
4
Pipelines
4
Changes
1
Expand
👍
0
👎
0
Merge request reports
Viewing commit
c5ff42fa
Prev
Next
Show latest version
1 file
+
16
−
16
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
c5ff42fa
fix: use indices instead of vector of objects
· c5ff42fa
Wouter Deconinck
authored
9 months ago
JugReco/src/components/CalorimeterHitsMerger.cpp
+
16
−
16
Options
@@ -114,31 +114,30 @@ public:
auto
&
outputs
=
*
m_outputHitCollection
.
createAndPut
();
// find the hits that belong to the same group (for merging)
std
::
unordered_map
<
long
long
,
std
::
vector
<
edm4eic
::
MutableCalorimeterHit
>>
merge_map
;
std
::
unordered_map
<
long
long
,
std
::
vector
<
size_t
>>
merge_map
;
std
::
size_t
ix
=
0
;
for
(
const
auto
&
h
:
inputs
)
{
int64_t
id
=
h
.
getCellID
()
&
id_mask
;
// use the reference field position
auto
it
=
merge_map
.
find
(
id
);
if
(
it
==
merge_map
.
end
())
{
merge_map
[
id
]
=
{
h
};
}
else
{
it
->
second
.
push_back
(
h
);
}
merge_map
[
id
].
push_back
(
ix
);
ix
++
;
}
// sort hits by energy from large to small
std
::
for_each
(
merge_map
.
begin
(),
merge_map
.
end
(),
[](
auto
&
it
)
{
std
::
sort
(
it
.
second
.
begin
(),
it
.
second
.
end
(),
[](
const
auto
&
h1
,
const
auto
&
h
2
)
{
return
h1
.
getEnergy
()
>
h2
.
getEnergy
();
});
}
);
for
(
auto
&
it
:
merge_map
)
{
std
::
sort
(
it
.
second
.
begin
(),
it
.
second
.
end
(),
[
&
](
std
::
size_t
ix1
,
std
::
size_t
ix
2
)
{
return
(
*
in_hits
)[
ix1
].
getEnergy
()
>
(
*
in_hits
)[
ix2
]
.
getEnergy
();
});
}
// reconstruct info for merged hits
// dd4hep decoders
auto
poscon
=
m_converter
;
auto
volman
=
m_geoSvc
->
getDetector
()
->
volumeManager
();
for
(
auto
&
[
id
,
hit
s
]
:
merge_map
)
{
for
(
auto
&
[
id
,
ix
s
]
:
merge_map
)
{
// reference fields id
const
uint64_t
ref_id
=
id
|
ref_mask
;
// global positions
@@ -152,17 +151,18 @@ public:
float
energyError
=
0.
;
float
time
=
0
;
float
timeError
=
0
;
for
(
auto
&
hit
:
hits
)
{
for
(
auto
ix
:
ixs
)
{
auto
hit
=
(
*
in_hits
)[
ix
];
energy
+=
hit
.
getEnergy
();
energyError
+=
hit
.
getEnergyError
()
*
hit
.
getEnergyError
();
time
+=
hit
.
getTime
();
timeError
+=
hit
.
getTimeError
()
*
hit
.
getTimeError
();
}
energyError
=
sqrt
(
energyError
);
time
/=
hit
s
.
size
();
timeError
=
sqrt
(
timeError
)
/
hit
s
.
size
();
time
/=
ix
s
.
size
();
timeError
=
sqrt
(
timeError
)
/
ix
s
.
size
();
const
auto
&
href
=
hit
s
.
front
();
const
auto
&
href
=
(
*
in_hits
)[
ix
s
.
front
()
]
;
// create const vectors for passing to hit initializer list
const
decltype
(
edm4eic
::
CalorimeterHitData
::
position
)
position
(
Loading