dictwrite.py 6.41 KB
Newer Older
1
2
3
#!/usr/bin/env pyroot.py 

# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4
5
6
7
8
9
10
11
12
13

#----------------------------------------------
#
# PLEASE DO NOT UPDATE bs-streamerinfos.root YOURSELF!!!!
# Contact the person mentioned on: 
#    https://twiki.cern.ch/twiki/bin/view/Atlas/TrigSerializeResult
# and/or the Trigger EDM Coordinator 
#
#----------------------------------------------

14
import sys
15
16
17

doEDM=False
#doEDM=True
18
doxAODonly=False
19
bs_filename = 'bs-streamerinfos.root'
20
21

import ROOT
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from ROOT import TFile

import StreamerInfoGenerator
SIG = StreamerInfoGenerator.StreamerInfoGenerator()

"""
MN: NOTE about xAOD containers in ROOT5 
For an xAOD container like xAOD::HIEventShapeContainer_v1
you need to either:
a) use the real class name:  DataVector<xAOD::HIEventShape_v2>
b) have a real class in the 'objects' list BEFORE the typedef
   (so the dict library gets loaded and the typedefs resolved)
"""

36

37
objects = [
38
39
40
41
42
43
44
45
46
'xAOD::TrigEMCluster_v1',
'xAOD::TrigEMClusterContainer_v1',
'xAOD::TrigEMClusterAuxContainer_v1',
'xAOD::TrigRingerRings_v1',
'xAOD::TrigRingerRingsContainer_v1',
'xAOD::TrigRingerRingsAuxContainer_v1',
'xAOD::TrigRNNOutput_v1',
'xAOD::TrigRNNOutputContainer_v1',
'xAOD::TrigRNNOutputAuxContainer_v1',
47
48
'xAOD::TrigRNNOutputContainer_v2',
'xAOD::TrigRNNOutputAuxContainer_v2',
49
50
51
52
'xAOD::CaloClusterContainer_v1',
'xAOD::CaloClusterAuxContainer_v2',
'xAOD::L2StandAloneMuonContainer_v1',
'xAOD::L2StandAloneMuonAuxContainer_v1',
53
'xAOD::L2StandAloneMuonAuxContainer_v2',
54
55
56
57
58
'xAOD::L2CombinedMuonContainer_v1',
'xAOD::L2CombinedMuonAuxContainer_v1',
'xAOD::L2IsoMuonContainer_v1',
'xAOD::L2IsoMuonAuxContainer_v1',
'xAOD::MuonContainer_v1',
59
'xAOD::MuonAuxContainer_v1',
60
'xAOD::MuonAuxContainer_v2',
61
'xAOD::MuonAuxContainer_v3',
62
'xAOD::MuonAuxContainer_v4',
63
'xAOD::TrackParticleContainer_v1',
64
'xAOD::TrackParticleAuxContainer_v1',
65
'xAOD::TrackParticleAuxContainer_v2',
66
'xAOD::TrackParticleAuxContainer_v3',
67
68
'xAOD::TauJetContainer_v2',
'xAOD::TauJetAuxContainer_v2',
69
'xAOD::TauJetAuxContainer_v3',
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'xAOD::VertexContainer_v1',
'xAOD::VertexAuxContainer_v1',
'xAOD::TrigCompositeContainer_v1',
'xAOD::TrigCompositeAuxContainer_v1',
'xAOD::MuonRoIContainer_v1',
'xAOD::MuonRoIAuxContainer_v1',
'xAOD::EmTauRoIContainer_v2',
'xAOD::EmTauRoIAuxContainer_v2',
'xAOD::JetRoIContainer_v2',
'xAOD::JetRoIAuxContainer_v2',
'xAOD::JetEtRoI_v1',
'xAOD::JetEtRoIAuxInfo_v1',
'xAOD::EnergySumRoI_v1',
'xAOD::EnergySumRoIAuxInfo_v1',
'xAOD::TriggerTowerContainer_v2',
'xAOD::TriggerTowerAuxContainer_v2',
'xAOD::ElectronContainer_v1',
'xAOD::ElectronAuxContainer_v1',
'xAOD::PhotonContainer_v1',
'xAOD::PhotonAuxContainer_v1',
'xAOD::TrigBphysContainer_v1',
'xAOD::TrigBphysAuxContainer_v1',
'xAOD::TrigT2MbtsBitsAuxContainer_v1',
93
'xAOD::TrigT2MbtsBitsContainer_v1',
94
95
96
97
98
99
100
101
102
103
104
105
106
107
'xAOD::TrigSpacePointCountsContainer_v1',
'xAOD::TrigSpacePointCountsAuxContainer_v1',
'xAOD::TrigVertexCountsContainer_v1',
'xAOD::TrigVertexCountsAuxContainer_v1',
'xAOD::TrigTrackCounts_v1',
'xAOD::TrigTrackCountsAuxContainer_v1',
'xAOD::TrigMissingETContainer_v1',
'xAOD::TrigMissingETAuxContainer_v1',
'xAOD::TrigPhotonContainer_v1',
'xAOD::TrigPhotonAuxContainer_v1',
'xAOD::TrigElectronContainer_v1',
'xAOD::TrigElectronAuxContainer_v1',
'xAOD::JetContainer_v1',
'xAOD::JetTrigAuxContainer_v1',
108
'xAOD::JetTrigAuxContainer_v2',
109
110
111
112
113
114
115
'xAOD::TrigDecision_v1',
'xAOD::TrigDecisionAuxInfo_v1',
'xAOD::TrigConfKeys_v1',
'xAOD::TrigNavigation_v1',
'xAOD::TrigNavigationAuxInfo_v1',
'xAOD::BTaggingContainer_v1',
'xAOD::BTaggingAuxContainer_v1',
116
'xAOD::BTaggingTrigAuxContainer_v1',
117
'xAOD::BTagVertexContainer_v1',
118
119
120
121
'xAOD::BTagVertexAuxContainer_v1',
'xAOD::HIEventShapeAuxContainer_v2',
'xAOD::HIEventShapeContainer_v2',
'xAOD::TrigT2ZdcSignalsAuxContainer_v1',
122
123
124
125
126
127
128
129
130
'xAOD::TrigT2ZdcSignalsContainer_v1',
'xAOD::TrigPassBitsContainer_v1',
'xAOD::TrigPassBitsAuxContainer_v1',
'xAOD::CaloClusterTrigAuxContainer_v1',
'xAOD::ElectronTrigAuxContainer_v1',
'xAOD::PhotonTrigAuxContainer_v1',
'xAOD::TrigEMClusterAuxContainer_v2',
'xAOD::TrigRingerRingsAuxContainer_v2',
'xAOD::TrigRNNOutputAuxContainer_v2',
131
#'TrigMuonEFIsolation_p2',
132
]
133

134
135
136
137
138
from collections import defaultdict
streamerChecksums = defaultdict(set)
print "Reading streamerinfos from", bs_filename
file = TFile(bs_filename, 'UPDATE')
streamer_n = 0
139
140
141
if  file.GetStreamerInfoList():
  for i in file.GetStreamerInfoList():
     if i.GetName() != 'listOfRules':
142
143
144
145
146
147
        # print i.GetName(), "%x" % i.GetCheckSum()
        streamerChecksums[i.GetName()].add( i.GetCheckSum() )
        streamer_n += 1
print "Read", streamer_n, 'streamers for', len(streamerChecksums), 'types'
print

148
if doEDM:
149
  from TriggerJobOpts.TriggerEDM import EDMDetails
150
151
152
153
  for item in EDMDetails.keys():
    pers = EDMDetails[item]['persistent']
    objects.append(pers)

154
for pers in objects:
155
    SIG.inspect(pers)
156
    print
157
fulllist = SIG.classlist 
158
print fulllist
159
print '*******************************'
160
161
162
163
164


from CLIDComps.clidGenerator import clidGenerator
cgen = clidGenerator("")

165
166
167
types_new = 0
types_exist = 0
types_bad = 0
168
fulllist = list(set(fulllist))
169
for item in fulllist:    
170
  if doxAODonly and not 'xAOD' in item: continue # current issues seen because of missing xAOD libs not being loaded
171
172
173
  print "Trying to fill item", item, "to root file"
  c_clid = cgen.genClidFromName(item)
  c_typeinfo = cgen.getTidFromClid(c_clid)
174
  print "CLID", c_clid
175
  print "TypeInfo", c_typeinfo
176
177
178
  try:
   cls = ROOT.gROOT.GetClass(item)
  except:
179
   cls = ROOT.gROOT.GetClass(c_typeinfo)      
180
181
  print cls

182
183
  if cls!=None:
    streamerinfo = cls.GetStreamerInfo()
184
185
186
    if streamerinfo.GetCheckSum() == 0:
      # try to patch missing checksum in DataVectors
      print 'Warning: no checksum in streamerinfo for type: ', cls.GetName()
187
      print 'Attempting to fix with 0x%x' %  cls.GetCheckSum()
188
      streamerinfo.SetCheckSum( cls.GetCheckSum() )
189
190
191
192
193
194
195
196
197
198

    chksum = streamerinfo.GetCheckSum()
    if chksum not in streamerChecksums[cls.GetName()]:
      print 'Writing: %s  streamer size=%d, checksum=0x%x' %(cls.GetName(), streamerinfo.Sizeof(), chksum)
      obj = cls.New()
      file.WriteObjectAny(obj, cls, cls.GetName())
      types_new += 1
    else:
      print 'Skipping', cls.GetName(), 'streamer checksum', chksum, ' - already in the file'
      types_exist += 1
199
200
201
      
  else:
    print 'skipping ', item
202
    types_bad += 1
203
    #sys.exit()
204
  print '----'  
205

206
207
print 'Wrote', types_new, 'types'
print 'Skipped', types_exist, ' existing types'
208
209
210
211
212
213
print 'Problems with', types_bad + len(SIG.problemclasses), ' types'
for t in SIG.problemclasses:
  print '    ', t