ATLAS Offline Software
Functions
python.GenerateDVIterators Namespace Reference

Functions

def DataVectorIterator (self)
 Generic iterator that can be used with any DataVector type. More...
 
def generateDVIterators ()
 Function installing proper iterators for all the known DataVector types. More...
 

Function Documentation

◆ DataVectorIterator()

def python.GenerateDVIterators.DataVectorIterator (   self)

Generic iterator that can be used with any DataVector type.

Taken from Noel Dawe, from: https://its.cern.ch/jira/browse/ATLASG-31

Definition at line 19 of file GenerateDVIterators.py.

19 def DataVectorIterator( self ):
20  for i in range( self.size() ):
21  yield self.at( i )
22 

◆ generateDVIterators()

def python.GenerateDVIterators.generateDVIterators ( )

Function installing proper iterators for all the known DataVector types.

This function needs to be called once all the dictionaries for our types got loaded. It fixes up the DataVector types (in ROOT 6) to behave as proper Python lists.

Definition at line 29 of file GenerateDVIterators.py.

30 
31  # Let the user know what's happening:
32  print( "generateDVIterators INFO Attaching iterators to all known DV "
33  "types" )
34  print( "generateDVIterators INFO This may take a moment..." )
35 
36  # Load/access the dictionaries of all of the same types that xAOD::Init()
37  # accesses as well. Since apparently "the C++ side" and "the Python side"
38  # need to do this separately... :-/
39  for name in [ 'TruthParticleContainer',
40  'MuonRoIContainer',
41  'CaloClusterContainer',
42  'TrackParticleContainer',
43  'ElectronContainer',
44  'MuonContainer',
45  'JetContainer',
46  'TauJetContainer',
47  'PFOContainer',
48  'TrigElectronContainer',
49  'L2CombinedMuonContainer',
50  'ParticleContainer' ]:
51  getattr( ROOT.xAOD, name, None )
52  pass
53 
54  # Iterate over all classes known to ROOT:
55  for typ in ROOT.gROOT.GetListOfClasses():
56  # Skip emulated classes:
57  if not typ.IsLoaded():
58  continue
59  # We're only interested in DataVector types:
60  if typ.GetName().find( "DataVector<" ) != 0:
61  continue
62  # Access the python type associated with this type:
63  ptyp = getattr( ROOT, typ.GetName(), None )
64  if not ptyp:
65  print( "generateDVIterators ERROR Couldn't get python type for " \
66  "\"%s\"" % typ.GetName() )
67  continue
68  # Massage the iterator of this type:
69  ptyp.__iter__ = DataVectorIterator
70  pass
71 
72  # Return gracefully:
73  return
74 
75 # Call the function:
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.GenerateDVIterators.generateDVIterators
def generateDVIterators()
Function installing proper iterators for all the known DataVector types.
Definition: GenerateDVIterators.py:29
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.GenerateDVIterators.DataVectorIterator
def DataVectorIterator(self)
Generic iterator that can be used with any DataVector type.
Definition: GenerateDVIterators.py:19