ATLAS Offline Software
Generators
GeneratorFilters
src
xAODParentTwoChildrenFilter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
GeneratorFilters/xAODParentTwoChildrenFilter.h
"
6
#include "
TruthUtils/HepMCHelpers.h
"
7
#include "
CxxUtils/BasicTypes.h
"
8
#include "
xAODTruth/TruthVertexContainer.h
"
9
10
xAODParentTwoChildrenFilter::xAODParentTwoChildrenFilter
(
const
std::string&
name
, ISvcLocator* pSvcLocator)
11
:
GenFilter
(
name
,pSvcLocator)
12
{
13
14
}
15
16
17
StatusCode
xAODParentTwoChildrenFilter::filterInitialize
() {
18
if
(
m_PDGParent
.size() == 0)
ATH_MSG_ERROR
(
"PDGParent[] not set "
);
19
if
(
m_PDGChild
.size() == 0)
ATH_MSG_ERROR
(
"PDGChild[] not set "
);
20
for
(
int
i
=0;
i
<
int
(
m_PDGParent
.size());
i
++)
ATH_MSG_DEBUG
(
"PDGParent["
<<
i
<<
"] = "
<<
m_PDGParent
[
i
]);
21
ATH_MSG_DEBUG
(
"PtMinParent = "
<<
m_PtMinParent
);
22
ATH_MSG_DEBUG
(
"EtaRangeParent = "
<<
m_EtaRangeParent
);
23
for
(
int
i
=0;
i
<
int
(
m_PDGChild
.size());
i
++)
ATH_MSG_DEBUG
(
"PDGChild["
<<
i
<<
"] = "
<<
m_PDGChild
[
i
]);
24
ATH_MSG_DEBUG
(
"PtMinChild = "
<<
m_PtMinChild
);
25
ATH_MSG_DEBUG
(
"EtaRangeChild = "
<<
m_EtaRangeChild
);
26
return
StatusCode::SUCCESS;
27
}
28
29
30
StatusCode
xAODParentTwoChildrenFilter::filterEvent
() {
31
ATH_MSG_DEBUG
(
" ParentTwoChildrenFilter filtering for: "
32
<<
"Parent ("
<<
m_PDGParent
[0] <<
") --> Child ("
<<
m_PDGChild
[0] <<
") + antiparticle and "
33
<<
"Parent ("
<<
m_PDGParent
[0] <<
") --> Child ("
<<
m_PDGChild
[1] <<
") + antiparticle."
);
34
int
N_Child[2][2];
35
for
(
int
i
= 0;
i
< 2;
i
++) {
36
N_Child[
i
][0] = 0;
37
N_Child[
i
][1] = 0;
38
}
39
40
// Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and
41
// duplicated barcode ones
42
const
xAOD::TruthParticleContainer
* xTruthParticleContainer;
43
if
(
evtStore
()->
retrieve
(xTruthParticleContainer,
"TruthGen"
).isFailure()) {
44
ATH_MSG_ERROR
(
"No TruthParticle collection with name "
<<
"TruthGen"
<<
" found in StoreGate!"
);
45
return
StatusCode::FAILURE;
46
}
47
48
// Loop over all particles in the event and build up the grid
49
unsigned
int
nPart = xTruthParticleContainer->
size
();
50
for
(
unsigned
int
iPart = 0; iPart < nPart; ++iPart) {
51
const
xAOD::TruthParticle
* pitr = (*xTruthParticleContainer)[iPart];
52
53
int
id
= pitr->
pdgId
();
54
if
(std::abs(
id
) !=
m_PDGParent
[0])
continue
;
55
if
(pitr->
pt
() <
m_PtMinParent
)
continue
;
56
57
58
// Verify if we got a valid pointer and retrieve the number of daughters
59
const
xAOD::TruthVertex
* decayVtx = pitr->
decayVtx
();
60
if
(!decayVtx)
continue
;
61
int
n_daughters = decayVtx->
nOutgoingParticles
();
62
if
(n_daughters < 2)
continue
;
63
64
65
int
neutralPar = 0;
66
int
num_outgoing_particles = decayVtx->
nOutgoingParticles
();
67
for
(
int
j = 0; j< num_outgoing_particles; j++) {
68
const
xAOD::TruthParticle
* thisChild = decayVtx->
outgoingParticle
(j);
69
70
ATH_MSG_DEBUG
(
" ParentTwoChildrenFilter: parent ==> "
<<pitr->
pdgId
() <<
" child ===> "
<<thisChild->
pdgId
());
71
for
(
int
i
= 0;
i
< 2;
i
++) {
72
if
( std::abs(thisChild->
pdgId
()) ==
m_PDGChild
[
i
]) {
73
int
antiparticle = (
MC::charge
(
m_PDGChild
[
i
]) == 0 ? 1 : -1 );
// assume that zero charge particles are their own anti-particle
74
if
( thisChild->
pdgId
() ==
m_PDGChild
[
i
] ) {
75
if
( (thisChild->
pt
() >=
m_PtMinChild
) ) {
76
if
(antiparticle == 1) {
77
neutralPar++;
78
if
(neutralPar == 1) N_Child[
i
][0]++;
79
}
80
else
N_Child[
i
][0]++;
81
}
82
}
83
if
( thisChild->
pdgId
() == antiparticle *
m_PDGChild
[
i
] ) {
84
if
( (thisChild->
pt
() >=
m_PtMinChild
) ) {
85
if
(antiparticle == 1){
86
if
(neutralPar == 2) N_Child[
i
][1]++;
87
}
88
else
N_Child[
i
][1]++;
89
}
90
}
91
}
92
}
93
}
94
}
//lopp over TruthParticles
95
96
setFilterPassed(N_Child[0][0] >= 1 && N_Child[0][1] >= 1 && N_Child[1][0] >= 1 && N_Child[1][1] >= 1);
97
return
StatusCode::SUCCESS;
98
}
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition:
PyKernel.py:110
xAOD::TruthVertex_v1::nOutgoingParticles
size_t nOutgoingParticles() const
Get the number of outgoing particles.
CaloCellPos2Ntuple.int
int
Definition:
CaloCellPos2Ntuple.py:24
xAODParentTwoChildrenFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition:
xAODParentTwoChildrenFilter.cxx:17
TruthVertexContainer.h
xAODParentTwoChildrenFilter::m_PtMinChild
Gaudi::Property< double > m_PtMinChild
Definition:
xAODParentTwoChildrenFilter.h:31
xAODParentTwoChildrenFilter.h
xAODParentTwoChildrenFilter::m_PtMinParent
Gaudi::Property< double > m_PtMinParent
Definition:
xAODParentTwoChildrenFilter.h:27
xAODParentTwoChildrenFilter::filterEvent
virtual StatusCode filterEvent()
Definition:
xAODParentTwoChildrenFilter.cxx:30
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:85
GenFilter
Base class for event generator filtering modules.
Definition:
GenFilter.h:30
xAODParentTwoChildrenFilter::m_PDGParent
Gaudi::Property< std::vector< int > > m_PDGParent
Definition:
xAODParentTwoChildrenFilter.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition:
AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition:
lumiFormat.py:92
xAODParentTwoChildrenFilter::xAODParentTwoChildrenFilter
xAODParentTwoChildrenFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
xAODParentTwoChildrenFilter.cxx:10
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
BasicTypes.h
Provide simplified clock_gettime() function for MacOSX.
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition:
TruthParticle_v1.h:41
xAODParentTwoChildrenFilter::m_EtaRangeParent
Gaudi::Property< double > m_EtaRangeParent
Definition:
xAODParentTwoChildrenFilter.h:29
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:581
xAOD::TruthParticle_v1::decayVtx
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition:
TruthVertex_v1.h:41
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:195
charge
double charge(const T &p)
Definition:
AtlasPID.h:494
xAODParentTwoChildrenFilter::m_PDGChild
Gaudi::Property< std::vector< int > > m_PDGChild
Definition:
xAODParentTwoChildrenFilter.h:30
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition:
TruthParticle_v1.cxx:166
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::TruthVertex_v1::outgoingParticle
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
Definition:
TruthVertex_v1.cxx:121
xAODParentTwoChildrenFilter::m_EtaRangeChild
Gaudi::Property< double > m_EtaRangeChild
Definition:
xAODParentTwoChildrenFilter.h:32
HepMCHelpers.h
Generated on Fri Jul 5 2024 21:33:06 for ATLAS Offline Software by
1.8.18