Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Peter Sherwood
athena
Commits
88026286
Commit
88026286
authored
4 years ago
by
Andrii Verbytskyi
Committed by
Edward Moyse
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Hepmc3 nightly fixes 04122020 part 7
parent
a60bdec3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Generators/AtlasHepMC/AtlasHepMC/GenParticle.h
+4
-2
4 additions, 2 deletions
Generators/AtlasHepMC/AtlasHepMC/GenParticle.h
Generators/TruthConverters/Root/xAODtoHepMCTool.cxx
+29
-17
29 additions, 17 deletions
Generators/TruthConverters/Root/xAODtoHepMCTool.cxx
with
33 additions
and
19 deletions
Generators/AtlasHepMC/AtlasHepMC/GenParticle.h
+
4
−
2
View file @
88026286
...
...
@@ -40,6 +40,7 @@ using HepMC3::GenParticle;
}
#else
#include
"HepMC/GenParticle.h"
#include
<memory>
namespace
HepMC
{
typedef
GenParticle
*
GenParticlePtr
;
typedef
const
GenParticle
*
ConstGenParticlePtr
;
...
...
@@ -48,8 +49,9 @@ inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::Fo
}
inline
int
barcode
(
GenParticle
p
)
{
return
p
.
barcode
();
}
template
<
class
T
>
inline
int
barcode
(
T
p
)
{
return
p
->
barcode
();
}
template
<
class
T
>
bool
suggest_barcode
(
T
p
,
int
i
)
{
return
p
->
suggest_barcode
(
i
);}
inline
bool
suggest_barcode
(
GenParticle
p
,
int
i
)
{
return
p
.
suggest_barcode
(
i
);}
template
<
class
T
>
bool
suggest_barcode
(
T
&
p
,
int
i
)
{
return
p
.
suggest_barcode
(
i
);}
//Smart pointers should not be used with HepMC2. But it happens.
template
<
>
inline
bool
suggest_barcode
<
std
::
unique_ptr
<
HepMC
::
GenParticle
>
>
(
std
::
unique_ptr
<
HepMC
::
GenParticle
>&
p
,
int
i
)
{
return
p
->
suggest_barcode
(
i
);}
template
<
class
T
>
bool
suggest_barcode
(
T
*
p
,
int
i
)
{
return
p
->
suggest_barcode
(
i
);}
namespace
Print
{
inline
void
line
(
std
::
ostream
&
os
,
const
GenParticle
&
p
)
{
p
.
print
(
os
);}
...
...
This diff is collapsed.
Click to expand it.
Generators/TruthConverters/Root/xAODtoHepMCTool.cxx
+
29
−
17
View file @
88026286
...
...
@@ -74,7 +74,7 @@ std::vector<HepMC::GenEvent> xAODtoHepMCTool :: getHepMCEvents(const xAOD::Truth
// Insert into McEventCollection
mcEventCollection
.
push_back
(
hepmcEvent
);
if
(
doPrint
)
ATH_MSG_DEBUG
(
"XXX Printing HepMC Event"
);
if
(
doPrint
)
hepmcEvent
.
print
(
);
if
(
doPrint
)
HepMC
::
Print
::
line
(
std
::
cout
,
hepmcEvent
);
// Quit if signal only
if
(
m_signalOnly
)
break
;
}
...
...
@@ -93,7 +93,7 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt,
// PARTICLES AND VERTICES
// Map of existing vertices - needed for the tree linking
std
::
map
<
const
xAOD
::
TruthVertex
*
,
HepMC
::
GenVertex
*
>
vertexMap
;
std
::
map
<
const
xAOD
::
TruthVertex
*
,
HepMC
::
GenVertex
Ptr
>
vertexMap
;
// Loop over all of the particles in the event, call particle builder
// Call suggest_barcode only after insertion!
...
...
@@ -117,7 +117,11 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt,
// Create GenParticle
//presumably the GenEvent takes ownership of this, but creating a unique_ptr here as that will only happen if there's an associated vertex
#ifdef HEPMC3
auto
hepmcParticle
=
createHepMCParticle
(
xPart
)
;
#else
std
::
unique_ptr
<
HepMC
::
GenParticle
>
hepmcParticle
(
createHepMCParticle
(
xPart
)
);
#endif
int
bcpart
=
xPart
->
barcode
();
// status 10902 should be treated just as status 2
...
...
@@ -129,18 +133,22 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt,
// skip production vertices with barcode > 200000 --> Geant4 secondaries
if
(
std
::
abs
(
xAODProdVtx
->
barcode
())
>
200000
)
continue
;
bool
prodVtxSeenBefore
(
false
);
// is this new?
HepMC
::
GenVertex
*
hepmcProdVtx
=
vertexHelper
(
xAODProdVtx
,
vertexMap
,
prodVtxSeenBefore
);
auto
hepmcProdVtx
=
vertexHelper
(
xAODProdVtx
,
vertexMap
,
prodVtxSeenBefore
);
// Set the decay/production links
#ifdef HEPMC3
hepmcProdVtx
->
add_particle_out
(
hepmcParticle
);
#else
hepmcProdVtx
->
add_particle_out
(
hepmcParticle
.
release
());
#endif
// Insert into Event
if
(
!
prodVtxSeenBefore
){
genEvt
.
add_vertex
(
hepmcProdVtx
);
if
(
!
h
ep
mcProdVtx
->
suggest_barcode
(
xAODProdVtx
->
barcode
())
){
if
(
!
H
ep
MC
::
suggest_barcode
(
hepmcProdVtx
,
xAODProdVtx
->
barcode
())
){
ATH_MSG_WARNING
(
"suggest_barcode failed for vertex "
<<
xAODProdVtx
->
barcode
());
++
m_badSuggest
;
}
}
if
(
!
h
ep
mcParticle
->
suggest_barcode
(
bcpart
)
){
if
(
!
H
ep
MC
::
suggest_barcode
(
hepmcParticle
,
bcpart
)
){
ATH_MSG_DEBUG
(
"suggest_barcode failed for particle "
<<
bcpart
);
++
m_badSuggest
;
}
...
...
@@ -152,22 +160,26 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt,
if
(
xPart
->
hasDecayVtx
()
){
const
xAOD
::
TruthVertex
*
xAODDecayVtx
=
xPart
->
decayVtx
();
// skip decay vertices with barcode > 200000 --> Geant4 secondaries
if
(
f
abs
(
xAODDecayVtx
->
barcode
())
>
200000
)
continue
;
if
(
std
::
abs
(
xAODDecayVtx
->
barcode
())
>
200000
)
continue
;
bool
decayVtxSeenBefore
(
false
);
// is this new?
HepMC
::
GenVertex
*
hepmcDecayVtx
=
vertexHelper
(
xAODDecayVtx
,
vertexMap
,
decayVtxSeenBefore
);
auto
hepmcDecayVtx
=
vertexHelper
(
xAODDecayVtx
,
vertexMap
,
decayVtxSeenBefore
);
// Set the decay/production links
#ifdef HEPMC3
hepmcDecayVtx
->
add_particle_in
(
hepmcParticle
);
#else
hepmcDecayVtx
->
add_particle_in
(
hepmcParticle
.
release
());
#endif
// Insert into Event
if
(
!
decayVtxSeenBefore
){
genEvt
.
add_vertex
(
hepmcDecayVtx
);
if
(
!
h
ep
mcDecayVtx
->
suggest_barcode
(
xAODDecayVtx
->
barcode
())
){
if
(
!
H
ep
MC
::
suggest_barcode
(
hepmcDecayVtx
,
xAODDecayVtx
->
barcode
())
){
ATH_MSG_WARNING
(
"suggest_barcode failed for vertex "
<<
xAODDecayVtx
->
barcode
());
++
m_badSuggest
;
}
}
if
(
bcpart
!=
0
){
if
(
!
h
ep
mcParticle
->
suggest_barcode
(
bcpart
)
){
if
(
!
H
ep
MC
::
suggest_barcode
(
hepmcParticle
,
bcpart
)
){
ATH_MSG_DEBUG
(
"suggest_barcode failed for particle "
<<
bcpart
);
++
m_badSuggest
;
}
...
...
@@ -185,12 +197,12 @@ HepMC::GenEvent xAODtoHepMCTool::createHepMCEvent(const xAOD::TruthEvent* xEvt,
// Helper to check whether a vertex exists or not using a map;
// calls createHepMCVertex if not
HepMC
::
GenVertex
*
xAODtoHepMCTool
::
vertexHelper
(
const
xAOD
::
TruthVertex
*
xaodVertex
,
std
::
map
<
const
xAOD
::
TruthVertex
*
,
HepMC
::
GenVertex
*
>
&
vertexMap
,
HepMC
::
GenVertex
Ptr
xAODtoHepMCTool
::
vertexHelper
(
const
xAOD
::
TruthVertex
*
xaodVertex
,
std
::
map
<
const
xAOD
::
TruthVertex
*
,
HepMC
::
GenVertex
Ptr
>
&
vertexMap
,
bool
&
seenBefore
)
const
{
HepMC
::
GenVertex
*
hepmcVertex
;
std
::
map
<
const
xAOD
::
TruthVertex
*
,
HepMC
::
GenVertex
*
>::
iterator
vMapItr
;
HepMC
::
GenVertex
Ptr
hepmcVertex
;
std
::
map
<
const
xAOD
::
TruthVertex
*
,
HepMC
::
GenVertex
Ptr
>::
iterator
vMapItr
;
vMapItr
=
vertexMap
.
find
(
xaodVertex
);
// Vertex seen before?
if
(
vMapItr
!=
vertexMap
.
end
())
{
...
...
@@ -209,20 +221,20 @@ HepMC::GenVertex* xAODtoHepMCTool::vertexHelper(const xAOD::TruthVertex* xaodVer
// Create the HepMC GenParticle
// Call suggest_barcode after insertion!
HepMC
::
GenParticle
*
xAODtoHepMCTool
::
createHepMCParticle
(
const
xAOD
::
TruthParticle
*
particle
)
const
{
HepMC
::
GenParticle
Ptr
xAODtoHepMCTool
::
createHepMCParticle
(
const
xAOD
::
TruthParticle
*
particle
)
const
{
ATH_MSG_VERBOSE
(
"Creating GenParticle for barcode "
<<
particle
->
barcode
());
const
HepMC
::
FourVector
fourVec
(
m_momFac
*
particle
->
px
(),
m_momFac
*
particle
->
py
(),
m_momFac
*
particle
->
pz
(),
m_momFac
*
particle
->
e
()
);
HepMC
::
GenParticle
*
hepmcParticle
=
new
HepMC
::
GenParticle
(
fourVec
,
particle
->
pdgId
(),
particle
->
status
());
auto
hepmcParticle
=
HepMC
::
new
GenParticle
Ptr
(
fourVec
,
particle
->
pdgId
(),
particle
->
status
());
hepmcParticle
->
set_generated_mass
(
m_momFac
*
particle
->
m
());
return
hepmcParticle
;
}
// Create the HepMC GenVertex
// Call suggest_barcode after insertion!
HepMC
::
GenVertex
*
xAODtoHepMCTool
::
createHepMCVertex
(
const
xAOD
::
TruthVertex
*
vertex
)
const
{
HepMC
::
GenVertex
Ptr
xAODtoHepMCTool
::
createHepMCVertex
(
const
xAOD
::
TruthVertex
*
vertex
)
const
{
ATH_MSG_VERBOSE
(
"Creating GenVertex for barcode "
<<
vertex
->
barcode
());
HepMC
::
FourVector
prod_pos
(
m_lenFac
*
vertex
->
x
(),
m_lenFac
*
vertex
->
y
(),
m_lenFac
*
vertex
->
z
(),
m_lenFac
*
vertex
->
t
()
);
HepMC
::
GenVertex
*
genVertex
=
new
HepMC
::
GenVertex
(
prod_pos
);
auto
genVertex
=
HepMC
::
new
GenVertex
Ptr
(
prod_pos
);
return
genVertex
;
}
...
...
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