ATLAS Offline Software
Loading...
Searching...
No Matches
xAODBranchAddress.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
7// xAODBranchAddress.cxx
8// Implementation file for class Athena::xAODBranchAddress
9// Author: Johannes ELmsheuser, Will Buttinger
11
12// AthenaRootComps includes
13#include "xAODBranchAddress.h"
14#include "xAODTEvent.h"
15
16// fwk includes
17#include "GaudiKernel/System.h"
20
21// ROOT includes
22#include "TBranch.h"
23#include "TTree.h"
24#include "TLeaf.h"
25
27#include "TClass.h"
28#include <typeinfo>
29
30
31namespace Athena {
32
34// Public methods:
36
37// Constructors
39
42 GenericAddress(),
43 m_ptr ()
44{}
45
48 GenericAddress(rhs),
49 m_ptr (rhs.m_ptr)
50{}
51
55{
56 if (this != &rhs) {
57 GenericAddress::operator=(rhs);
58 m_ptr = rhs.m_ptr;
59 }
60 return *this;
61}
62
65 const CLID& clid,
66 const std::string& p1,
67 const std::string& p2,
68 unsigned long ip1,
69 unsigned long ip2) :
70 GenericAddress(svc, clid, p1, p2, ip1, ip2),
71 m_ptr(0) //the actual data object that is retrieved
72{
73 // std::cerr << "::RBA::+RBA... (this=" << this << ") br=["
74 // << this->par()[1] << "]\n";
75}
76
79{
80 // std::cerr << "::RBA::~RBA... (this=" << this << ") br=["
81 // << this->par()[1] << "]\n";
82}
83
84
87{
88 //std::cout << "xAODBranchAddress::tevent ..." << std::endl;
89 return reinterpret_cast<xAOD::xAODTEvent*>(reinterpret_cast<unsigned long*>(this->ipar()[0]));
90}
91
92void
94{
95
96 //std::cout << "xAODBranchAddress::setTEvent ..." << std::endl;
97
98
99
100 const std::string& br_name = this->par()[1];
101 xAOD::xAODTEvent* tevent = this->tevent();
102 //xAOD::TEvent* tevent = this->tevent();
103 //std::cout << "xAODBranchAddress::setTEventAddress br_name=" << br_name << std::endl;
104 //std::cout << "xAODBranchAddress::setTEventAddress tevent=" << tevent << " entries = " << tevent->getEntries() << std::endl;
105 //std::cout << "xAODBranchAddress::setTEventAddress tlID()=" << this->clID() << std::endl;
106
107 const std::type_info* ti = CLIDRegistry::CLIDToTypeinfo(this->clID());
108 //std::cout << "xAODBranchAddress::setTEventAddress ti=" << ti << std::endl;
109
110 // void* addr = *(char**)&tevent;
111
112
113 //we use the ipar()[1] to flag if we retrieve main event info (0) or metadata (1) (see xAODEventSelector where it creates BranchAddress)
114 switch( (this->ipar()[1]) ) {
115 case 0:
116 {//reading event level info
117 tevent->setActive(); //ensure we are active tevent
118 static constexpr bool SILENT = false;
119 static constexpr bool METADATA = false;
120 void* addr ATLAS_THREAD_SAFE = const_cast<void*>(tevent->getInputObject(br_name, *ti, SILENT, METADATA));
121 m_ptr = addr;
122 }
123 break;
124 case 1:
125 {//reading metadata
126 //FIXME: NEEED TO ACCESS METADATA
127 //std::cout << "xAODBranchAddress::setTEventAddress metadata " << br_name << std::endl;
128 tevent->setActive(); //ensure we are active tevent
129 static constexpr bool SILENT = false;
130 static constexpr bool METADATA = true;
131 void* addr ATLAS_THREAD_SAFE = const_cast<void*>(tevent->getInputObject(br_name, *ti, SILENT, METADATA));
132 m_ptr = addr;
133 }
134 break;
135 }
136
137 //std::cout << "xAODBranchAddress::setTEventAddress m_ptr=" << m_ptr << std::endl;
138
139
140}
141
143// Protected methods:
145
146} //> end namespace Athena
a static registry of CLID->typeName entries.
uint32_t CLID
The Class ID type.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
A simple class to do the retrieve from TEvent.
xAODBranchAddress & operator=(const xAODBranchAddress &rhs)
Assignment operator:
virtual ~xAODBranchAddress()
Destructor:
xAOD::xAODTEvent * tevent()
xAODBranchAddress()
Default constructor:
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....