ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 
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  }

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ m_weightPFOTool

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

Definition at line 39 of file PFlowAugmentationTool.h.

◆ 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.


The documentation for this class was generated from the following files:
DerivationFramework::PFlowAugmentationTool::m_z0Key
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_z0Key
Definition: PFlowAugmentationTool.h:45
DerivationFramework::PFlowAugmentationTool::m_pfoContainer_key
SG::ReadHandleKey< xAOD::FlowElementContainer > m_pfoContainer_key
Definition: PFlowAugmentationTool.h:42
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
DerivationFramework::PFlowAugmentationTool::m_thetaKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_thetaKey
Definition: PFlowAugmentationTool.h:48
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
DerivationFramework::PFlowAugmentationTool::m_corrP4_ptKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_corrP4_ptKey
Definition: PFlowAugmentationTool.h:44
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition: TrackingPrimitives.h:571
xAOD::TrackParticle_v1::d0
float d0() const
Returns the parameter.
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
DerivationFramework::PFlowAugmentationTool::m_weightPFOTool
PublicToolHandle< CP::IWeightPFOTool > m_weightPFOTool
Definition: PFlowAugmentationTool.h:39
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::PFlowAugmentationTool::m_d0Key
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_d0Key
Definition: PFlowAugmentationTool.h:47
DerivationFramework::PFlowAugmentationTool::m_vertexContainer_key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Definition: PFlowAugmentationTool.h:41
DerivationFramework::PFlowAugmentationTool::m_envWeightKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_envWeightKey
Definition: PFlowAugmentationTool.h:49
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.changerun.pv
pv
Definition: changerun.py:79
DerivationFramework::PFlowAugmentationTool::m_vzKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_vzKey
Definition: PFlowAugmentationTool.h:46
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:44
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition: FlowElement_v1.h:25