ATLAS Offline Software
Loading...
Searching...
No Matches
xAODAuxStoreHelper.py
Go to the documentation of this file.
1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3
4import ROOT
5
6cast_offset_str="""
7#include "TBranchElement.h"
8 #include "TObjArray.h"
9 #include "TStreamerElement.h"
10 #include "TStreamerInfo.h"
11
12 Long_t cast_with_offset( TBranchElement* be ) {
13 Long_t offset = ((TStreamerElement*)be->GetInfo()->GetElements()->At(be->GetID()))->GetOffset();
14 return (Long_t)(be->GetObject() + offset);
15 }
16"""
17open("cast_with_offset.C","w").write(cast_offset_str)
18ROOT.gROOT.LoadMacro("cast_with_offset.C+")
19
20
21def initBranch( tree, name ):
22
23 tree.SetBranchStatus( name, ROOT.kTRUE )
24 be = tree.GetBranch( name )
25 be.GetEntry(0) # tickle object creation
26 values = ROOT.BindObject( ROOT.cast_with_offset( be ), be.GetTypeName() )
27 setattr( tree, name, values )
28 return values
29
31 be.GetEntry(0) # tickle object creation
32 values = ROOT.BindObject( ROOT.cast_with_offset( be ), be.GetTypeName() )
33 setattr( tree, be.GetName(), values )
34 return values
35