Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
DerivationFramework::TruthPVCollectionMaker Class Reference

#include <TruthPVCollectionMaker.h>

Inheritance diagram for DerivationFramework::TruthPVCollectionMaker:
Collaboration diagram for DerivationFramework::TruthPVCollectionMaker:

Public Member Functions

 TruthPVCollectionMaker (const std::string &t, const std::string &n, const IInterface *p)
 
 ~TruthPVCollectionMaker ()
 
StatusCode initialize ()
 
virtual StatusCode addBranches () const
 

Private Attributes

SG::ReadHandleKey< xAOD::TruthEventContainerm_eventsKey {this, "EventsKey", "TruthEvents"}
 Input event collection (navigates to the vertices) More...
 
SG::WriteHandleKey< xAOD::TruthVertexContainerm_outVtxKey {this, "NewCollectionName", ""}
 Output collection name. More...
 

Detailed Description

Definition at line 18 of file TruthPVCollectionMaker.h.

Constructor & Destructor Documentation

◆ TruthPVCollectionMaker()

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

Definition at line 19 of file TruthPVCollectionMaker.cxx.

22  : base_class(t,n,p)
23  {
24 }

◆ ~TruthPVCollectionMaker()

DerivationFramework::TruthPVCollectionMaker::~TruthPVCollectionMaker ( )
default

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::TruthPVCollectionMaker::addBranches ( ) const
virtual

Definition at line 44 of file TruthPVCollectionMaker.cxx.

45 {
46  const EventContext& ctx{Gaudi::Hive::currentContext()};
47  // Retrieve truth collections
49  if (!importedTruthEvents.isValid()) {
50  ATH_MSG_ERROR("No TruthEvent collection with name " << m_eventsKey.fullKey() << " found in StoreGate!");
51  return StatusCode::FAILURE;
52  }
53 
54  // Create the new vertex containers
56  ATH_CHECK(writeHandleVtx.record(std::make_unique<xAOD::TruthVertexContainer>(),
57  std::make_unique<xAOD::TruthVertexAuxContainer>()));
58  xAOD::TruthVertexContainer* newVertexCollection = writeHandleVtx.ptr();
59  ATH_MSG_DEBUG( "Recorded new TruthVertexContainer with key: " << m_outVtxKey.fullKey());
60 
61  // Go through the events, add one vertex for each event
62  for (const auto * event : *importedTruthEvents){
63  // Just in case there is a place-holder
64  if (!event) continue;
65  // Try with the signal process vertex
66  const xAOD::TruthVertex* old_vert(event->signalProcessVertex());
67  // If that's not there, grab the first vertex
68  if (!old_vert && event->nTruthVertices()>0){
69  old_vert = event->truthVertex(0);
70  }
71  if (old_vert){
72  // Hit -- copy it!
73  // Make a new vertex and add it to the container
74  xAOD::TruthVertex* xTruthVertex = new xAOD::TruthVertex();
75  newVertexCollection->push_back( xTruthVertex );
76  // Set properties
77  xTruthVertex->setId(HepMC::status(old_vert));
78  xTruthVertex->setBarcode(HepMC::barcode(old_vert)); // FIXME barcode-based
79  xTruthVertex->setX(old_vert->x());
80  xTruthVertex->setY(old_vert->y());
81  xTruthVertex->setZ(old_vert->z());
82  xTruthVertex->setT(old_vert->t());
83  } else {
84  ATH_MSG_WARNING("No signal vertex or vertices associated to an input event!");
85  }
86  }
87  return StatusCode::SUCCESS;
88 }

◆ initialize()

StatusCode DerivationFramework::TruthPVCollectionMaker::initialize ( )

Definition at line 29 of file TruthPVCollectionMaker.cxx.

30 {
31  ATH_MSG_VERBOSE("initialize() ...");
32 
33  // Check configuration, print errors, warning, and information for the user
34  ATH_CHECK(m_eventsKey.initialize());
35  ATH_MSG_INFO("Using " << m_eventsKey.fullKey() << " as the source collections for new truth collections");
36  ATH_CHECK(m_outVtxKey.initialize());
37  ATH_MSG_INFO("New truth vertex collection key: " << m_outVtxKey.fullKey() );
38 
39  return StatusCode::SUCCESS;
40 }

Member Data Documentation

◆ m_eventsKey

SG::ReadHandleKey<xAOD::TruthEventContainer> DerivationFramework::TruthPVCollectionMaker::m_eventsKey {this, "EventsKey", "TruthEvents"}
private

Input event collection (navigates to the vertices)

Definition at line 26 of file TruthPVCollectionMaker.h.

◆ m_outVtxKey

SG::WriteHandleKey<xAOD::TruthVertexContainer> DerivationFramework::TruthPVCollectionMaker::m_outVtxKey {this, "NewCollectionName", ""}
private

Output collection name.

Definition at line 27 of file TruthPVCollectionMaker.h.


The documentation for this class was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::TruthVertex_v1::setT
void setT(float value)
Set the vertex time.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::TruthVertex_v1::setY
void setY(float value)
Set the y displacement of the vertex.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TruthVertex
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition: TruthVertex.h:15
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::TruthVertex_v1::setId
void setId(int value)
Obsolete function Set vertex ID code HepMC2 id == HepMC3 status, i.e.
xAOD::TruthVertex_v1::setZ
void setZ(float value)
Set the vertex's longitudinal distance from the origin.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
xAOD::TruthVertex_v1::setBarcode
void setBarcode(int value)
Set barcode.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::TruthPVCollectionMaker::m_outVtxKey
SG::WriteHandleKey< xAOD::TruthVertexContainer > m_outVtxKey
Output collection name.
Definition: TruthPVCollectionMaker.h:27
HepMC::status
int status(const T &p)
Definition: MagicNumbers.h:138
xAOD::TruthVertex_v1::setX
void setX(float value)
Set the x displacement of the vertex.
DerivationFramework::TruthPVCollectionMaker::m_eventsKey
SG::ReadHandleKey< xAOD::TruthEventContainer > m_eventsKey
Input event collection (navigates to the vertices)
Definition: TruthPVCollectionMaker.h:26