ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::PFlowAugmentationTool Class Reference

#include <PFlowAugmentationTool.h>

Inheritance diagram for DerivationFramework::PFlowAugmentationTool:
Collaboration diagram for DerivationFramework::PFlowAugmentationTool:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

PublicToolHandle< CP::IWeightPFOToolm_weightPFOTool {this, "WeightPFOTool", "CP::WeightPFOTool/WeightPFOTool"}
SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainer_key {this, "VertexContainer", "PrimaryVertices", "Input vertex container"}
SG::ReadHandleKey< xAOD::FlowElementContainerm_pfoContainer_key {this, "GlobalChargedParticleFlowObjects", "GlobalChargedParticleFlowObjects", "Input charged PFO"}
SG::WriteDecorHandleKey< xAOD::FlowElementContainerm_corrP4_ptKey {this, "m_corrP4_ptKey", m_pfoContainer_key, "DFCommonPFlow_CaloCorrectedPt", "Decoration for weighted charged PFO pt"}
SG::WriteDecorHandleKey< xAOD::FlowElementContainerm_z0Key {this, "m_z0Key", m_pfoContainer_key, "DFCommonPFlow_z0", "Decoration for track z0"}
SG::WriteDecorHandleKey< xAOD::FlowElementContainerm_vzKey {this, "m_vzKey", m_pfoContainer_key, "DFCommonPFlow_vz", "Decoration for track vz"}
SG::WriteDecorHandleKey< xAOD::FlowElementContainerm_d0Key {this, "m_d0Key", m_pfoContainer_key, "DFCommonPFlow_d0", "Decoration for track d0"}
SG::WriteDecorHandleKey< xAOD::FlowElementContainerm_thetaKey {this, "m_thetaKey", m_pfoContainer_key, "DFCommonPFlow_theta", "Decoration for track theta"}
SG::WriteDecorHandleKey< xAOD::FlowElementContainerm_envWeightKey {this, "m_envWeightKey", m_pfoContainer_key, "DFCommonPFlow_envWeight", "Decoration for weight for dense environments"}

Detailed Description

Definition at line 29 of file PFlowAugmentationTool.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::PFlowAugmentationTool::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 32 of file PFlowAugmentationTool.cxx.

33 {
34 // Get the vertex.
35 const xAOD::Vertex* pv{};
36
37 auto vertexContainer = SG::makeHandle (m_vertexContainer_key, ctx);
38 if (!vertexContainer.isValid()){
39 ATH_MSG_WARNING("Invalid xAOD::VertexContainer datahandle"
40 << m_vertexContainer_key.key());
41 return StatusCode::FAILURE;
42 }
43 auto pvcont = vertexContainer.cptr();
44 if ( pvcont == 0 || pvcont->size()==0 ) {
45 ATH_MSG_WARNING(" Failed to retrieve PrimaryVertices collection" );
46 return StatusCode::FAILURE;
47 }
48 for (const auto vx : *pvcont) {
49 if (vx->vertexType() == xAOD::VxType::PriVtx) {
50 pv = vx;
51 break;
52 }//If we have a vertex of type primary vertex
53 }//iterate over the vertices and check their type
54
55 // Use NoVtx as fall-back in case no PV is found, but the events should be rejected by the user
56 // If there is no such then mark all CPFOs as unmatched
57 if (pv == nullptr) {
58 ATH_MSG_DEBUG("Could not find a primary vertex in this event" );
59 for (auto theVertex : *pvcont) {
60 if (xAOD::VxType::NoVtx == theVertex->vertexType() ) {
61 pv = theVertex;
62 break;
63 }
64 }
65 if (nullptr == pv) {
66 ATH_MSG_WARNING("Found neither PriVtx nor NoVtx in this event" );
67 }
68 }
69
70 SG::WriteDecorHandle<xAOD::FlowElementContainer,float> dec_corrP4_pt(m_corrP4_ptKey, ctx);
71 SG::WriteDecorHandle<xAOD::FlowElementContainer,float> dec_z0(m_z0Key, ctx);
72 SG::WriteDecorHandle<xAOD::FlowElementContainer,float> dec_vz(m_vzKey, ctx);
73 SG::WriteDecorHandle<xAOD::FlowElementContainer,float> dec_d0(m_d0Key, ctx);
74 SG::WriteDecorHandle<xAOD::FlowElementContainer,float> dec_theta(m_thetaKey, ctx);
75 SG::WriteDecorHandle<xAOD::FlowElementContainer,float> dec_envWeight(m_envWeightKey, ctx);
76
77 auto pfoContainer = SG::makeHandle (m_pfoContainer_key, ctx);
78 if (!pfoContainer.isValid()){
79 ATH_MSG_WARNING("Invalid xAOD::PFOContainer datahandle"
80 << m_pfoContainer_key.key());
81 return StatusCode::FAILURE;
82 }
83 auto cpfos = pfoContainer.cptr();
84
85 for ( const xAOD::FlowElement* cpfo : *cpfos ) {
86 if ( cpfo == 0 ) {
87 ATH_MSG_WARNING("Have NULL pointer to charged PFO");
88 continue;
89 }
90 const xAOD::TrackParticle* ptrk = dynamic_cast<const xAOD::TrackParticle*>(cpfo->chargedObject(0));
91 if ( ptrk == 0 ) {
92 ATH_MSG_WARNING("Skipping charged PFO with null track pointer.");
93 continue;
94 }
95
96 // decorate the track properties
97 dec_z0(*cpfo) = ptrk->z0();
98 dec_vz(*cpfo) = ptrk->vz();
99 dec_d0(*cpfo) = ptrk->d0();
100 dec_theta(*cpfo) = ptrk->theta();
101
102 //find the weights from the tool
103 float weight = 1.0;
104 const static SG::AuxElement::ConstAccessor<int> accIsInDE("IsInDenseEnvironment");
105 if(accIsInDE.isAvailable(*cpfo)){
106 ATH_CHECK( m_weightPFOTool->fillWeight( *cpfo, weight ) );
107 }
108
109 // decorate the computed variables
110 dec_corrP4_pt(*cpfo) = weight*cpfo->pt();
111 dec_envWeight(*cpfo) = weight;
112 }
113
114 return StatusCode::SUCCESS;
115 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_d0Key
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_corrP4_ptKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_envWeightKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_z0Key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
SG::ReadHandleKey< xAOD::FlowElementContainer > m_pfoContainer_key
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_vzKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_thetaKey
PublicToolHandle< CP::IWeightPFOTool > m_weightPFOTool
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
float d0() const
Returns the parameter.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ PriVtx
Primary vertex.
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ initialize()

StatusCode DerivationFramework::PFlowAugmentationTool::initialize ( )
finaloverridevirtual

Definition at line 17 of file PFlowAugmentationTool.cxx.

18 {
19
20 ATH_CHECK(m_vertexContainer_key.initialize());
21 ATH_CHECK(m_pfoContainer_key.initialize());
22 ATH_CHECK(m_corrP4_ptKey.initialize());
23 ATH_CHECK(m_z0Key.initialize());
24 ATH_CHECK(m_vzKey.initialize());
25 ATH_CHECK(m_d0Key.initialize());
26 ATH_CHECK(m_thetaKey.initialize());
27 ATH_CHECK(m_envWeightKey.initialize());
28
29 return StatusCode::SUCCESS;
30 }

Member Data Documentation

◆ m_corrP4_ptKey

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_corrP4_ptKey {this, "m_corrP4_ptKey", m_pfoContainer_key, "DFCommonPFlow_CaloCorrectedPt", "Decoration for weighted charged PFO pt"}
private

Definition at line 44 of file PFlowAugmentationTool.h.

44{this, "m_corrP4_ptKey", m_pfoContainer_key, "DFCommonPFlow_CaloCorrectedPt", "Decoration for weighted charged PFO pt"};

◆ m_d0Key

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_d0Key {this, "m_d0Key", m_pfoContainer_key, "DFCommonPFlow_d0", "Decoration for track d0"}
private

Definition at line 47 of file PFlowAugmentationTool.h.

47{this, "m_d0Key", m_pfoContainer_key, "DFCommonPFlow_d0", "Decoration for track d0"};

◆ m_envWeightKey

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_envWeightKey {this, "m_envWeightKey", m_pfoContainer_key, "DFCommonPFlow_envWeight", "Decoration for weight for dense environments"}
private

Definition at line 49 of file PFlowAugmentationTool.h.

49{this, "m_envWeightKey", m_pfoContainer_key, "DFCommonPFlow_envWeight", "Decoration for weight for dense environments"};

◆ m_pfoContainer_key

SG::ReadHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_pfoContainer_key {this, "GlobalChargedParticleFlowObjects", "GlobalChargedParticleFlowObjects", "Input charged PFO"}
private

Definition at line 42 of file PFlowAugmentationTool.h.

42{this, "GlobalChargedParticleFlowObjects", "GlobalChargedParticleFlowObjects", "Input charged PFO"};

◆ m_thetaKey

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_thetaKey {this, "m_thetaKey", m_pfoContainer_key, "DFCommonPFlow_theta", "Decoration for track theta"}
private

Definition at line 48 of file PFlowAugmentationTool.h.

48{this, "m_thetaKey", m_pfoContainer_key, "DFCommonPFlow_theta", "Decoration for track theta"};

◆ m_vertexContainer_key

SG::ReadHandleKey<xAOD::VertexContainer> DerivationFramework::PFlowAugmentationTool::m_vertexContainer_key {this, "VertexContainer", "PrimaryVertices", "Input vertex container"}
private

Definition at line 41 of file PFlowAugmentationTool.h.

41{this, "VertexContainer", "PrimaryVertices", "Input vertex container"};

◆ m_vzKey

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_vzKey {this, "m_vzKey", m_pfoContainer_key, "DFCommonPFlow_vz", "Decoration for track vz"}
private

Definition at line 46 of file PFlowAugmentationTool.h.

46{this, "m_vzKey", m_pfoContainer_key, "DFCommonPFlow_vz", "Decoration for track vz"};

◆ m_weightPFOTool

PublicToolHandle<CP::IWeightPFOTool> DerivationFramework::PFlowAugmentationTool::m_weightPFOTool {this, "WeightPFOTool", "CP::WeightPFOTool/WeightPFOTool"}
private

Definition at line 39 of file PFlowAugmentationTool.h.

39{this, "WeightPFOTool", "CP::WeightPFOTool/WeightPFOTool"};

◆ m_z0Key

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_z0Key {this, "m_z0Key", m_pfoContainer_key, "DFCommonPFlow_z0", "Decoration for track z0"}
private

Definition at line 45 of file PFlowAugmentationTool.h.

45{this, "m_z0Key", m_pfoContainer_key, "DFCommonPFlow_z0", "Decoration for track z0"};

The documentation for this class was generated from the following files: