ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
AtlasHepMC
AtlasHepMC
Barcode.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
/* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
5
6
#ifndef ATLASHEPMC_BARCODE_H
7
#define ATLASHEPMC_BARCODE_H
8
#include <type_traits>
9
#include "HepMC3/GenParticle.h"
10
#include "HepMC3/GenVertex.h"
11
#include "HepMC3/GenEvent.h"
12
#include "
AtlasHepMC/AttributeNames.h
"
13
namespace
HepMC
{
14
template
<
class
T>
15
inline
int
barcode
(
const
T* p){
return
p->barcode(); }
16
inline
int
barcode
(
int
p){
return
p; }
17
template <class T, std::enable_if_t< !std::is_pointer<T>::value &&
18
!std::is_same<T, HepMC3::GenParticlePtr>::value &&
19
!std::is_same<T, HepMC3::ConstGenParticlePtr>::value &&
20
!std::is_same<T, HepMC3::GenVertexPtr>::value &&
21
!std::is_same<T, HepMC3::ConstGenVertexPtr>::value &&
22
!std::is_same<T, HepMC3::GenVertex>::value &&
23
!std::is_same<T, HepMC3::GenParticle>::value &&
24
!std::is_same<T, int>::value
25
,
bool
> =
true
>
26
inline
int
barcode
(
const
T& p){
return
p.barcode();}
27
28
template
<
class
T, std::enable_if_t<
29
std::is_same<T, HepMC3::GenParticlePtr>::value ||
30
std::is_same<T, HepMC3::ConstGenParticlePtr>::value ||
31
std::is_same<T, HepMC3::GenVertexPtr>::value ||
32
std::is_same<T, HepMC3::ConstGenVertexPtr>::value
33
,
bool
> =
true
>
34
inline
int
barcode
(
const
T& p) {
35
if
(!p)
return
0;
36
const
HepMC3::GenEvent* e = p->parent_event();
37
if
(!e)
return
0;
38
std::shared_ptr<HepMC3::IntAttribute>
barcode
= e->attribute<HepMC3::IntAttribute>(HepMCStr::barcode, p->id());
39
return
barcode
? (
barcode
->value()) : p->id();
40
}
41
42
template
<
class
T, std::enable_if_t<
43
std::is_same<T, HepMC3::GenParticle>::value ||
44
std::is_same<T, HepMC3::GenVertex>::value
45
,
bool
> =
true
>
46
inline
int
barcode
(
const
T& p) {
47
const
HepMC3::GenEvent* e = p.parent_event();
48
if
(!e)
return
0;
49
std::shared_ptr<HepMC3::IntAttribute>
barcode
= e->attribute<HepMC3::IntAttribute>(HepMCStr::barcode, p.id());
50
return
barcode
? (
barcode
->value()) : p.id();
51
}
52
53
}
54
#endif
AttributeNames.h
HepMC
Definition
Barcode.h:13
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
Generated on
for ATLAS Offline Software by
1.17.0