Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
Davide Di Croce
athena
Commits
70077646
Commit
70077646
authored
2 years ago
by
John Derek Chapman
Committed by
Tadej Novak
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Optimization of GenEventBarcodes property filling
Optimization of GenEventBarcodes property filling
parent
3f2e624c
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Generators/AtlasHepMC/AtlasHepMC/GenEvent.h
+89
-28
89 additions, 28 deletions
Generators/AtlasHepMC/AtlasHepMC/GenEvent.h
with
89 additions
and
28 deletions
Generators/AtlasHepMC/AtlasHepMC/GenEvent.h
+
89
−
28
View file @
70077646
...
@@ -96,6 +96,40 @@ public:
...
@@ -96,6 +96,40 @@ public:
}
}
std
::
unordered_map
<
int
,
GenVertexPtr
>
barcode_to_vertex_map
()
const
{
return
m_vertexBC
;
}
std
::
unordered_map
<
int
,
GenVertexPtr
>
barcode_to_vertex_map
()
const
{
return
m_vertexBC
;
}
std
::
unordered_map
<
int
,
GenParticlePtr
>
barcode_to_particle_map
()
const
{
return
m_particleBC
;
}
std
::
unordered_map
<
int
,
GenParticlePtr
>
barcode_to_particle_map
()
const
{
return
m_particleBC
;
}
void
fillAttribute
(
GenEvent
*
e
)
{
auto
barcodeAttributes
=
e
->
attributes
()[
"barcode"
];
auto
particles
=
e
->
particles
();
for
(
size_t
i
=
1
;
i
<=
particles
.
size
();
i
++
)
{
if
(
barcodeAttributes
.
count
(
i
))
{
auto
ptr
=
barcodeAttributes
.
at
(
i
);
if
(
ptr
->
is_parsed
())
{
m_particleBC
[
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
ptr
)
->
value
()]
=
ptr
->
particle
();
}
else
{
m_particleBC
[
std
::
atoi
(
ptr
->
unparsed_string
().
c_str
())]
=
ptr
->
particle
();
}
}
else
{
m_particleBC
[
i
]
=
particles
[
i
-
1
];
}
}
auto
vertices
=
e
->
vertices
();
for
(
size_t
i
=
1
;
i
<=
vertices
.
size
();
i
++
)
{
if
(
barcodeAttributes
.
count
(
-
i
))
{
auto
ptr
=
barcodeAttributes
.
at
(
-
i
);
if
(
ptr
->
is_parsed
())
{
m_vertexBC
[
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
ptr
)
->
value
()]
=
ptr
->
vertex
();
}
else
{
m_vertexBC
[
std
::
atoi
(
ptr
->
unparsed_string
().
c_str
())]
=
ptr
->
vertex
();
}
}
else
{
m_vertexBC
[
-
i
]
=
vertices
[
i
-
1
];
}
}
set_is_parsed
(
true
);
}
private
:
private
:
std
::
unordered_map
<
int
,
GenVertexPtr
>
m_vertexBC
;
std
::
unordered_map
<
int
,
GenVertexPtr
>
m_vertexBC
;
std
::
unordered_map
<
int
,
GenParticlePtr
>
m_particleBC
;
std
::
unordered_map
<
int
,
GenParticlePtr
>
m_particleBC
;
...
@@ -124,7 +158,7 @@ inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent
...
@@ -124,7 +158,7 @@ inline std::vector<HepMC3::GenParticlePtr>::const_iterator end(HepMC3::GenEvent
inline
std
::
vector
<
HepMC3
::
ConstGenParticlePtr
>::
const_iterator
begin
(
const
HepMC3
::
GenEvent
&
e
)
{
return
e
.
particles
().
begin
();
}
inline
std
::
vector
<
HepMC3
::
ConstGenParticlePtr
>::
const_iterator
begin
(
const
HepMC3
::
GenEvent
&
e
)
{
return
e
.
particles
().
begin
();
}
inline
std
::
vector
<
HepMC3
::
ConstGenParticlePtr
>::
const_iterator
end
(
const
HepMC3
::
GenEvent
&
e
)
{
return
e
.
particles
().
end
();
}
inline
std
::
vector
<
HepMC3
::
ConstGenParticlePtr
>::
const_iterator
end
(
const
HepMC3
::
GenEvent
&
e
)
{
return
e
.
particles
().
end
();
}
inline
GenEvent
*
newGenEvent
(
const
int
signal_process_id
,
const
int
event_number
)
{
inline
GenEvent
*
newGenEvent
(
const
int
signal_process_id
,
const
int
event_number
)
{
// TODO Update event_number to long long int?
GenEvent
*
e
=
new
GenEvent
();
GenEvent
*
e
=
new
GenEvent
();
std
::
shared_ptr
<
HepMC3
::
IntAttribute
>
signal_process_id_A
=
std
::
make_shared
<
HepMC3
::
IntAttribute
>
(
signal_process_id
);
std
::
shared_ptr
<
HepMC3
::
IntAttribute
>
signal_process_id_A
=
std
::
make_shared
<
HepMC3
::
IntAttribute
>
(
signal_process_id
);
e
->
add_attribute
(
"signal_process_id"
,
signal_process_id_A
);
e
->
add_attribute
(
"signal_process_id"
,
signal_process_id_A
);
...
@@ -158,18 +192,13 @@ inline GenEvent* copyemptyGenEvent(const GenEvent* inEvt) {
...
@@ -158,18 +192,13 @@ inline GenEvent* copyemptyGenEvent(const GenEvent* inEvt) {
}
}
inline
void
fillBarcodesAttribute
(
GenEvent
*
e
)
{
inline
void
fillBarcodesAttribute
(
GenEvent
*
e
)
{
// TODO improve this implementation in a follow-up MR
auto
barcodes
=
e
->
attribute
<
GenEventBarcodes
>
(
"barcodes"
);
auto
barcodes
=
e
->
attribute
<
GenEventBarcodes
>
(
"barcodes"
);
if
(
!
barcodes
)
{
if
(
!
barcodes
)
{
barcodes
=
std
::
make_shared
<
GenEventBarcodes
>
();
barcodes
=
std
::
make_shared
<
GenEventBarcodes
>
();
e
->
add_attribute
(
"barcodes"
,
barcodes
);
e
->
add_attribute
(
"barcodes"
,
barcodes
);
}
}
for
(
GenParticlePtr
p
:
e
->
particles
())
{
// force re-parsing as calling barcodes->is_parsed() returns true here
barcodes
->
add
(
p
);
barcodes
->
fillAttribute
(
e
);
}
for
(
GenVertexPtr
v
:
e
->
vertices
())
{
barcodes
->
add
(
v
);
}
}
}
inline
ConstGenVertexPtr
barcode_to_vertex
(
const
GenEvent
*
e
,
int
id
)
{
inline
ConstGenVertexPtr
barcode_to_vertex
(
const
GenEvent
*
e
,
int
id
)
{
...
@@ -180,12 +209,20 @@ inline ConstGenVertexPtr barcode_to_vertex(const GenEvent* e, int id ) {
...
@@ -180,12 +209,20 @@ inline ConstGenVertexPtr barcode_to_vertex(const GenEvent* e, int id ) {
if
(
ptr
)
return
ptr
;
if
(
ptr
)
return
ptr
;
}
}
// Fallback to unoptimized GenVertex barcode attribute
// Fallback to unoptimized GenVertex barcode attribute
// TODO improve this implementation in a follow-up MR
auto
vertices
=
e
->
vertices
();
auto
vertices
=
e
->
vertices
();
if
(
!
vertices
.
empty
()
and
vertices
[
0
]
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
))
{
auto
barcodeAttributes
=
e
->
attributes
()[
"barcode"
];
// If there are no "barcode" Attributes, then an empty map would be generated.
for
(
auto
vertex
:
vertices
)
{
for
(
size_t
i
=
1
;
i
<=
vertices
.
size
();
i
++
)
{
if
(
id
==
vertex
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
)
->
value
())
{
if
(
barcodeAttributes
.
count
(
-
i
))
{
return
vertex
;
auto
ptr
=
barcodeAttributes
.
at
(
-
i
);
if
(
ptr
->
is_parsed
())
{
if
(
id
==
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
ptr
)
->
value
())
{
return
ptr
->
vertex
();
}
}
else
{
if
(
id
==
std
::
atoi
(
ptr
->
unparsed_string
().
c_str
()))
{
return
ptr
->
vertex
();
}
}
}
}
}
}
}
...
@@ -206,12 +243,20 @@ inline ConstGenParticlePtr barcode_to_particle(const GenEvent* e, int id ) {
...
@@ -206,12 +243,20 @@ inline ConstGenParticlePtr barcode_to_particle(const GenEvent* e, int id ) {
if
(
ptr
)
return
ptr
;
if
(
ptr
)
return
ptr
;
}
}
// Fallback to unoptimized GenParticle barcode attribute
// Fallback to unoptimized GenParticle barcode attribute
// TODO improve this implementation in a follow-up MR
auto
particles
=
e
->
particles
();
auto
particles
=
e
->
particles
();
if
(
!
particles
.
empty
()
and
particles
[
0
]
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
))
{
auto
barcodeAttributes
=
e
->
attributes
()[
"barcode"
];
// If there are no "barcode" Attributes, then an empty map would be generated.
for
(
auto
particle
:
particles
)
{
for
(
size_t
i
=
1
;
i
<=
particles
.
size
();
i
++
)
{
if
(
id
==
particle
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
)
->
value
())
{
if
(
barcodeAttributes
.
count
(
i
))
{
return
particle
;
auto
ptr
=
barcodeAttributes
.
at
(
i
);
if
(
ptr
->
is_parsed
())
{
if
(
id
==
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
ptr
)
->
value
())
{
return
ptr
->
particle
();
}
}
else
{
if
(
id
==
std
::
atoi
(
ptr
->
unparsed_string
().
c_str
()))
{
return
ptr
->
particle
();
}
}
}
}
}
}
}
...
@@ -232,12 +277,20 @@ inline GenVertexPtr barcode_to_vertex(GenEvent* e, int id ) {
...
@@ -232,12 +277,20 @@ inline GenVertexPtr barcode_to_vertex(GenEvent* e, int id ) {
if
(
ptr
)
return
ptr
;
if
(
ptr
)
return
ptr
;
}
}
// Fallback to unoptimized GenVertex barcode attribute
// Fallback to unoptimized GenVertex barcode attribute
// TODO improve this implementation in a follow-up MR
auto
vertices
=
e
->
vertices
();
auto
vertices
=
e
->
vertices
();
if
(
!
vertices
.
empty
()
and
vertices
[
0
]
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
))
{
auto
barcodeAttributes
=
e
->
attributes
()[
"barcode"
];
// If there are no "barcode" Attributes, then an empty map would be generated.
for
(
auto
vertex
:
vertices
)
{
for
(
size_t
i
=
1
;
i
<=
vertices
.
size
();
i
++
)
{
if
(
id
==
vertex
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
)
->
value
())
{
if
(
barcodeAttributes
.
count
(
-
i
))
{
return
vertex
;
auto
ptr
=
barcodeAttributes
.
at
(
-
i
);
if
(
ptr
->
is_parsed
())
{
if
(
id
==
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
ptr
)
->
value
())
{
return
ptr
->
vertex
();
}
}
else
{
if
(
id
==
std
::
atoi
(
ptr
->
unparsed_string
().
c_str
()))
{
return
ptr
->
vertex
();
}
}
}
}
}
}
}
...
@@ -258,12 +311,20 @@ inline GenParticlePtr barcode_to_particle(GenEvent* e, int id ) {
...
@@ -258,12 +311,20 @@ inline GenParticlePtr barcode_to_particle(GenEvent* e, int id ) {
if
(
ptr
)
return
ptr
;
if
(
ptr
)
return
ptr
;
}
}
// Fallback to unoptimized GenParticle barcode attribute
// Fallback to unoptimized GenParticle barcode attribute
// TODO improve this implementation in a follow-up MR
auto
particles
=
e
->
particles
();
auto
particles
=
e
->
particles
();
if
(
!
particles
.
empty
()
and
particles
[
0
]
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
))
{
auto
barcodeAttributes
=
e
->
attributes
()[
"barcode"
];
// If there are no "barcode" Attributes, then an empty map would be generated.
for
(
auto
particle
:
particles
)
{
for
(
size_t
i
=
1
;
i
<=
particles
.
size
();
i
++
)
{
if
(
id
==
particle
->
attribute
<
HepMC3
::
IntAttribute
>
(
"barcode"
)
->
value
())
{
if
(
barcodeAttributes
.
count
(
i
))
{
return
particle
;
auto
ptr
=
barcodeAttributes
.
at
(
i
);
if
(
ptr
->
is_parsed
())
{
if
(
id
==
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
ptr
)
->
value
())
{
return
ptr
->
particle
();
}
}
else
{
if
(
id
==
std
::
atoi
(
ptr
->
unparsed_string
().
c_str
()))
{
return
ptr
->
particle
();
}
}
}
}
}
}
}
...
...
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