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

 PFlowAugmentationTool (const std::string &t, const std::string &n, const IInterface *p)
 
StatusCode initialize ()
 
StatusCode finalize ()
 
virtual StatusCode addBranches (const EventContext &ctx) const
 

Private Attributes

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

Detailed Description

Definition at line 29 of file PFlowAugmentationTool.h.

Constructor & Destructor Documentation

◆ PFlowAugmentationTool()

DerivationFramework::PFlowAugmentationTool::PFlowAugmentationTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 17 of file PFlowAugmentationTool.cxx.

19  :
20  base_class(t,n,p),
21  m_weightPFOTool("CP::WeightPFOTool/WeightPFOTool")
22  {
23  declareProperty("WeightPFOTool", m_weightPFOTool );
24  }

Member Function Documentation

◆ addBranches()

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

Definition at line 46 of file PFlowAugmentationTool.cxx.

47  {
48  // Get the vertex.
49  const xAOD::Vertex* pv{};
50 
51  auto vertexContainer = SG::makeHandle (m_vertexContainer_key, ctx);
52  if (!vertexContainer.isValid()){
53  ATH_MSG_WARNING("Invalid xAOD::VertexContainer datahandle"
54  << m_vertexContainer_key.key());
55  return StatusCode::FAILURE;
56  }
57  auto pvcont = vertexContainer.cptr();
58  if ( pvcont == 0 || pvcont->size()==0 ) {
59  ATH_MSG_WARNING(" Failed to retrieve PrimaryVertices collection" );
60  return StatusCode::FAILURE;
61  }
62  for (const auto vx : *pvcont) {
63  if (vx->vertexType() == xAOD::VxType::PriVtx) {
64  pv = vx;
65  break;
66  }//If we have a vertex of type primary vertex
67  }//iterate over the vertices and check their type
68 
69  // Use NoVtx as fall-back in case no PV is found, but the events should be rejected by the user
70  // If there is no such then mark all CPFOs as unmatched
71  if (pv == nullptr) {
72  ATH_MSG_DEBUG("Could not find a primary vertex in this event" );
73  for (auto theVertex : *pvcont) {
74  if (xAOD::VxType::NoVtx == theVertex->vertexType() ) {
75  pv = theVertex;
76  break;
77  }
78  }
79  if (nullptr == pv) {
80  ATH_MSG_WARNING("Found neither PriVtx nor NoVtx in this event" );
81  }
82  }
83 
90 
91  auto pfoContainer = SG::makeHandle (m_pfoContainer_key, ctx);
92  if (!pfoContainer.isValid()){
93  ATH_MSG_WARNING("Invalid xAOD::PFOContainer datahandle"
94  << m_pfoContainer_key.key());
95  return StatusCode::FAILURE;
96  }
97  auto cpfos = pfoContainer.cptr();
98 
99  for ( const xAOD::FlowElement* cpfo : *cpfos ) {
100  if ( cpfo == 0 ) {
101  ATH_MSG_WARNING("Have NULL pointer to charged PFO");
102  continue;
103  }
104  const xAOD::TrackParticle* ptrk = dynamic_cast<const xAOD::TrackParticle*>(cpfo->chargedObject(0));
105  if ( ptrk == 0 ) {
106  ATH_MSG_WARNING("Skipping charged PFO with null track pointer.");
107  continue;
108  }
109 
110  // decorate the track properties
111  dec_z0(*cpfo) = ptrk->z0();
112  dec_vz(*cpfo) = ptrk->vz();
113  dec_d0(*cpfo) = ptrk->d0();
114  dec_theta(*cpfo) = ptrk->theta();
115 
116  //find the weights from the tool
117  float weight = 1.0;
118  const static SG::AuxElement::ConstAccessor<int> accIsInDE("IsInDenseEnvironment");
119  if(accIsInDE.isAvailable(*cpfo)){
120  ATH_CHECK( m_weightPFOTool->fillWeight( *cpfo, weight ) );
121  }
122 
123  // decorate the computed variables
124  dec_corrP4_pt(*cpfo) = weight*cpfo->pt();
125  dec_envWeight(*cpfo) = weight;
126  }
127 
128  return StatusCode::SUCCESS;
129  }

◆ finalize()

StatusCode DerivationFramework::PFlowAugmentationTool::finalize ( )

Definition at line 41 of file PFlowAugmentationTool.cxx.

42  {
43  return StatusCode::SUCCESS;
44  }

◆ initialize()

StatusCode DerivationFramework::PFlowAugmentationTool::initialize ( )

Definition at line 26 of file PFlowAugmentationTool.cxx.

27  {
28 
29  ATH_CHECK(m_vertexContainer_key.initialize());
30  ATH_CHECK(m_pfoContainer_key.initialize());
31  ATH_CHECK(m_corrP4_ptKey.initialize());
32  ATH_CHECK(m_z0Key.initialize());
33  ATH_CHECK(m_vzKey.initialize());
34  ATH_CHECK(m_d0Key.initialize());
35  ATH_CHECK(m_thetaKey.initialize());
36  ATH_CHECK(m_envWeightKey.initialize());
37 
38  return StatusCode::SUCCESS;
39  }

Member Data Documentation

◆ m_corrP4_ptKey

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_corrP4_ptKey {this, "m_corrP4_ptKey", "GlobalChargedParticleFlowObjects.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","GlobalChargedParticleFlowObjects.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","GlobalChargedParticleFlowObjects.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","GlobalChargedParticleFlowObjects.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

Retrieval tool.

Definition at line 41 of file PFlowAugmentationTool.h.

◆ m_vzKey

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

Definition at line 46 of file PFlowAugmentationTool.h.

◆ m_weightPFOTool

ToolHandle<CP::IWeightPFOTool> DerivationFramework::PFlowAugmentationTool::m_weightPFOTool
private

Definition at line 39 of file PFlowAugmentationTool.h.

◆ m_z0Key

SG::WriteDecorHandleKey<xAOD::FlowElementContainer> DerivationFramework::PFlowAugmentationTool::m_z0Key {this, "m_z0Key", "GlobalChargedParticleFlowObjects.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
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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:274
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
beamspotman.n
n
Definition: beamspotman.py:727
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_weightPFOTool
ToolHandle< CP::IWeightPFOTool > m_weightPFOTool
Definition: PFlowAugmentationTool.h:39
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
Retrieval tool.
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:43
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