ATLAS Offline Software
Classes | Functions | Variables
checkxAOD Namespace Reference

Classes

class  ContainerInfo
 Class for holding information about a single container. More...
 

Functions

def main ()
 C(++) style main function. More...
 
def printFileInfo (fileName, categoryStrings)
 Function printing information about a single xAOD file. More...
 

Variables

 __author__
 
 parser
 
 usage
 
 p
 
 action
 
 dest
 
 help
 
 options
 
 args
 
 categoryStrings
 
 fileNames
 
 fileName
 
 kb
 
 sizeUnits
 
 auxvarptn
 
 poolFile
 
 summedData
 
 categData
 
 brName
 
 m
 
 file
 
 typeName
 
 orderedData
 
 sorter
 
 key
 
 memSize
 
 diskSize
 
 mtlp
 
 colTypeName
 
 d_name
 
 nameType
 
 catName
 
 categorizedData
 
 totDiskSize
 
 frac
 
 ds
 
 dsFrac
 
 dsName
 
 dsPerEvt
 
 dsPerCatFrac
 
 b
 
 writer
 

Function Documentation

◆ main()

def checkxAOD.main ( )

C(++) style main function.

I just prefer writing executable Python code like this...

Returns
0 on success, something else on failure

Definition at line 21 of file Control/xAODRootAccess/scripts/checkxAOD.py.

21 def main():
22 
23  # Set up the command line option parser:
24  parser = OptionParser( usage = "usage: %prog [-f] xAOD.pool.root" )
25  parser.add_option( "-f", "--file",
26  dest = "fileName",
27  help = "The path to the xAOD file to analyse" )
28  ( options, args ) = parser.parse_args()
29 
30  # Set up categorization matching strings:
31  categoryStrings = {
32  "MetaData" : ["^DataHeader", "(.*)_mems$", "(.*)_timings$", "^Token$", "^RawInfoSummaryForTag$"],
33  "Trig" : ["^HLT", "^LVL1", "^xTrig", "^Trig", "^CTP_Decision", "^TrigInDetTrackTruthMap", "^TrigNavigation", ".*TriggerTowers", "TileTTL1MBTS", "^TileL2Cnt", "RoIBResult"],
34  "MET" : ["^MET", "^METMAP", "JEMEtSums"],
35  "EvtId" : ["^ByteStreamEventInfo", "^EventInfo", "^McEventInfo", "^LumiBlockN", "^EventWeight", "^RunNumber", "^ConditionsRun", "^EventTime", "^BunchId", "^EventNumber"],
36  "tau" : ["^Tau", "^DiTauJets"],
37  "PFO" : ["(.*)EventShape$", "^AntiKt4EMPFlowJets", "^JetETMissChargedParticleFlowObjects", "^JetETMissNeutralParticleFlowObjects", "^JetETMissLCNeutralParticleFlowObjects"],
38  "egamma" : ["^GSF", "^ForwardElectron", "^egamma", "^Electron", "^Photon"],
39  "Muon" : ["^Muon", "^TileMuObj", "^MS", "^SlowMuons", ".*Stau", "(.*)MuonTrackParticles$", "MUCTPI_RDO", "^RPC", "^TGC", "^MDT", "^CSC", "^sTGC", "^MM", ".*MuonMeasurements$", "^ExtrapolatedMuonTracks", "^CombinedMuonTracks"],
40  "BTag" : ["^BTag"],
41  "InDet" : ["^InDet", "^PrimaryVertices", "^ComTime_TRT", "^Pixel", "^TRT", "^SCT", "^BCM", "^CTP", "^Tracks", "^ResolvedForwardTracks", "^SplitClusterAmbiguityMap"],
42  "Jet" : ["^CamKt", "^AntiKt", "^Jet"],
43  "CaloTopo" : ["CaloCalTopoCluster"],
44  "Calo" : ["^LAr", "^AODCellContainer", "^MBTSContainer", "^CaloCompactCellContainer", "^E4prContainer", "^TileCellVec", "^TileDigits"],
45  "Truth" : ["^Truth", "Truth$", "TruthMap$", "TruthCollection$", "^PRD_MultiTruth", "TracksTruth$", ".*TrackTruth$", "TrackTruthCollection"]
46  }
47  # Get the file name(s), taking all options into account:
48  fileNames = []
49  if len( args ) > 0:
50  fileNames = [ arg for arg in args if arg[ 0 ] != "-" ]
51  pass
52  if ( options.fileName == None ) and ( len( fileNames ) == 0 ):
53  parser.print_help()
54  return 1
55  if options.fileName != None:
56  fileNames.append(
57  os.path.expandvars( os.path.expanduser( options.fileName ) ) )
58  pass
59  fileNames = set( fileNames )
60 
61  # Set up ROOT:
62  ROOT.gErrorIgnoreLevel = ROOT.kError
63 
64  # Loop over the files:
65  for fileName in fileNames:
66  # Print their contents using the helper function:
67  printFileInfo( fileName, categoryStrings )
68  pass
69 
70  # Return gracefully:
71  return 0
72 

◆ printFileInfo()

def checkxAOD.printFileInfo (   fileName,
  categoryStrings 
)

Function printing information about a single xAOD file.

This function is used to print the contents of a given xAOD file.

Parameters
fileNameThe name of the file to print information about

Definition at line 113 of file Control/xAODRootAccess/scripts/checkxAOD.py.

113 def printFileInfo( fileName, categoryStrings ):
114 
115  # Open the file:
116  f = ROOT.TFile.Open( fileName, "READ" )
117  if not f or f.IsZombie():
118  raise "Couldn't open file %s" % fileName
119 
120  # Get the main event tree from the file:
121  t = f.Get( "CollectionTree" )
122  if not t:
123  raise "Couldn't find 'CollectionTree; in file %s" % fileName
124 
125  # The collected data:
126  infoForCont = {}
127  categData = {}
128 
129  # The entries in the TTree, for cross-checking:
130  entries = t.GetEntries()
131 
132  # Get all the branches of the file:
133  branches = t.GetListOfBranches()
134  for i in range( branches.GetEntries() ):
135  # Get the branch:
136  branch = branches.At( i )
137  # A little security check:
138  if branch.GetEntries() != entries:
139  raise "Found %i entries in branch %s instead of %i" % \
140  ( branch.GetEntries(), branch.GetName(), entries )
141  # "Decode" the name of the branch:
142  brName = branch.GetName()
143  # Check if this is a static auxiliary branch:
144  m = re.match( "(.*)Aux\..*", branch.GetName() )
145  if m:
146  brName = m.group( 1 )
147  pass
148  # Check if this is a dynamic auxiliary branch:
149  m = re.match( "(.*)AuxDyn\..*", branch.GetName() )
150  if m:
151  brName = m.group( 1 )
152  pass
153  # Get the information that we need:
154  if brName in infoForCont.keys():
155  infoForCont[ brName ]._memSize += branch.GetTotBytes( "*" )
156  infoForCont[ brName ]._diskSize += branch.GetZipBytes( "*" )
157  else:
158  infoForCont[ brName ] = ContainerInfo( brName,
159  branch.GetTotBytes( "*" ),
160  branch.GetZipBytes( "*" ),
161  entries )
162  pass
163  pass
164 
165  # Sort the collected info based on the on-disk size of the containers:
166  orderedData = []
167  for cName in infoForCont.keys():
168  orderedData += [ infoForCont[ cName ] ]
169  pass
170  orderedData.sort( key = operator.attrgetter( "_diskSize" ) )
171 
172  # Finally, print the collected information:
173  memSize = 0.0
174  diskSize = 0.0
175  print( "=" * 120 )
176  print( " File: %s" % fileName )
177  print( "-" * 120 )
178  print( " Memory size Disk Size Size/Event Compression "
179  "Entries Name (Type)" )
180  print( "-" * 120 )
181  for d in orderedData:
182  # Try to get the type of the object/container:
183  intBr = t.GetBranch( d.name() )
184  className = "<!!!Interface missing!!!>"
185  if intBr:
186  className = intBr.GetClassName()
187  pass
188  # The name and type of the branch in question:
189  nameType = "%s (%s)" % ( d.name(), className )
190 
191 
192  # Find category:
193  found = False
194  catName = '*Unknown*'
195  # for pair in categoryStrings:
196  for categ in categoryStrings:
197  for pattern in categoryStrings[ categ ]:
198  # print d.name, d_name, pair, type(d.name), type(d_name), type(pair[0])
199  m = None
200  try:
201  m = re.match(pattern, d.name())
202  except TypeError:
203  pass
204  if m:
205  found = True
206  catName = categ
207  break
208  # print d.name, pair[1]
209  pass
210  if not found:
211  # print "Did not find category for:", d.name, d_name, br
212  pass
213  pass
214  # Add on category to name/type
215  nameType += ' [' + catName + ']'
216 
217  # Now sum up the sizes according to the category
218  # Check if we already know this category:
219  if catName in categData.keys():
220  categData[ catName ]._memSize += d._memSize
221  categData[ catName ]._diskSize += d._diskSize
222  else:
223  categData[ catName ] = \
224  ContainerInfo( catName,
225  d._memSize,
226  d._diskSize,
227  d._nEntries )
228  pass
229  pass
230  memSize = memSize + d.memSize()
231  diskSize = diskSize + d.diskSize()
232 
233  print( " %12.2f kB %12.2f kB %7.2f kB/event %5.2f %8i %s" % \
234  ( d.memSize(), d.diskSize(),
235  d.diskSizePerEntry(),
236  d.compression(),
237  d.nEntries(), nameType ) )
238  pass
239  print( "-" * 120 )
240  print( " %12.2f kB %12.2f kB %7.2f kB/event Total" % \
241  ( memSize, diskSize, diskSize/entries ) )
242  print( "=" * 120 )
243  print( "" )
244 
245  # Now print out the categorized information
246  # Order the records by size:
247  categorizedData = []
248  for br in categData.keys():
249  categorizedData += [ categData[ br ] ]
250  pass
251  categorizedData.sort( key = operator.attrgetter( "_diskSize" ) )
252 
253  print( "=" * 80 )
254  print( " Categorized data" )
255  print( "=" * 80 )
256  print( " Disk Size Fraction Category Name" )
257  print( "-" * 80 )
258  totDiskSize = 0.0
259  frac = 0.0
260  ds = []
261  dsFrac = []
262  dsName = []
263  for d in categorizedData:
264  #print d.name(), d.diskSize(), d.nEntries()
265  dsPerEvt = d.diskSize() / d.nEntries()
266  dsPerEvtFrac = d.diskSize() / diskSize
267  totDiskSize += dsPerEvt
268  frac += dsPerEvtFrac
269  ds += [dsPerEvt]
270  dsFrac += [dsPerEvtFrac]
271  dsName += [d.name()]
272  print( "%12.3f kb %12.3f %s" % ( dsPerEvt, dsPerEvtFrac, d.name() ) )
273  pass
274  print( "%12.3f kb %12.3f %s" % ( totDiskSize , frac, "Total" ) )
275  ds += [totDiskSize]
276  dsFrac += [frac]
277  dsName += ["Total"]
278 
279  print( "" )
280  print( "=" * 80 )
281  print( "CSV for categories disk size/evt and fraction:" )
282  # print out comment separated list in descending order
283  print( ",".join(dsName[::-1]))
284  b = ['{:<0.3f}'.format(i) for i in ds[::-1]]
285  print( ",".join(b))
286  b = ['{:<0.3f}'.format(i) for i in dsFrac[::-1]]
287  print( ",".join(b))
288  print( "=" * 80 )
289  print( "" )
290 
291  return
292 
293 # Run the main function in "normal mode":

Variable Documentation

◆ __author__

checkxAOD.__author__
private

Definition at line 11 of file Tools/PyUtils/bin/checkxAOD.py.

◆ action

checkxAOD.action

Definition at line 27 of file Tools/PyUtils/bin/checkxAOD.py.

◆ args

checkxAOD.args

Definition at line 38 of file Tools/PyUtils/bin/checkxAOD.py.

◆ auxvarptn

checkxAOD.auxvarptn

Definition at line 110 of file Tools/PyUtils/bin/checkxAOD.py.

◆ b

checkxAOD.b

Definition at line 283 of file Tools/PyUtils/bin/checkxAOD.py.

◆ brName

checkxAOD.brName

Definition at line 125 of file Tools/PyUtils/bin/checkxAOD.py.

◆ categData

checkxAOD.categData

Definition at line 120 of file Tools/PyUtils/bin/checkxAOD.py.

◆ categorizedData

checkxAOD.categorizedData

Definition at line 249 of file Tools/PyUtils/bin/checkxAOD.py.

◆ categoryStrings

checkxAOD.categoryStrings

Definition at line 47 of file Tools/PyUtils/bin/checkxAOD.py.

◆ catName

checkxAOD.catName

Definition at line 207 of file Tools/PyUtils/bin/checkxAOD.py.

◆ colTypeName

checkxAOD.colTypeName

Definition at line 175 of file Tools/PyUtils/bin/checkxAOD.py.

◆ d_name

checkxAOD.d_name

Definition at line 180 of file Tools/PyUtils/bin/checkxAOD.py.

◆ dest

checkxAOD.dest

Definition at line 27 of file Tools/PyUtils/bin/checkxAOD.py.

◆ diskSize

checkxAOD.diskSize

Definition at line 168 of file Tools/PyUtils/bin/checkxAOD.py.

◆ ds

checkxAOD.ds

Definition at line 260 of file Tools/PyUtils/bin/checkxAOD.py.

◆ dsFrac

checkxAOD.dsFrac

Definition at line 261 of file Tools/PyUtils/bin/checkxAOD.py.

◆ dsName

checkxAOD.dsName

Definition at line 262 of file Tools/PyUtils/bin/checkxAOD.py.

◆ dsPerCatFrac

checkxAOD.dsPerCatFrac

Definition at line 265 of file Tools/PyUtils/bin/checkxAOD.py.

◆ dsPerEvt

checkxAOD.dsPerEvt

Definition at line 264 of file Tools/PyUtils/bin/checkxAOD.py.

◆ file

checkxAOD.file

Definition at line 148 of file Tools/PyUtils/bin/checkxAOD.py.

◆ fileName

checkxAOD.fileName

Definition at line 90 of file Tools/PyUtils/bin/checkxAOD.py.

◆ fileNames

checkxAOD.fileNames

Definition at line 79 of file Tools/PyUtils/bin/checkxAOD.py.

◆ frac

checkxAOD.frac

Definition at line 259 of file Tools/PyUtils/bin/checkxAOD.py.

◆ help

checkxAOD.help

Definition at line 28 of file Tools/PyUtils/bin/checkxAOD.py.

◆ kb

checkxAOD.kb

Definition at line 104 of file Tools/PyUtils/bin/checkxAOD.py.

◆ key

checkxAOD.key

Definition at line 155 of file Tools/PyUtils/bin/checkxAOD.py.

◆ m

checkxAOD.m

Definition at line 127 of file Tools/PyUtils/bin/checkxAOD.py.

◆ memSize

checkxAOD.memSize

Definition at line 167 of file Tools/PyUtils/bin/checkxAOD.py.

◆ mtlp

checkxAOD.mtlp

Definition at line 172 of file Tools/PyUtils/bin/checkxAOD.py.

◆ nameType

checkxAOD.nameType

Definition at line 188 of file Tools/PyUtils/bin/checkxAOD.py.

◆ options

checkxAOD.options

Definition at line 38 of file Tools/PyUtils/bin/checkxAOD.py.

◆ orderedData

checkxAOD.orderedData

Definition at line 153 of file Tools/PyUtils/bin/checkxAOD.py.

◆ p

checkxAOD.p

Definition at line 25 of file Tools/PyUtils/bin/checkxAOD.py.

◆ parser

checkxAOD.parser

Definition at line 24 of file Tools/PyUtils/bin/checkxAOD.py.

◆ poolFile

checkxAOD.poolFile

Definition at line 115 of file Tools/PyUtils/bin/checkxAOD.py.

◆ sizeUnits

checkxAOD.sizeUnits

Definition at line 105 of file Tools/PyUtils/bin/checkxAOD.py.

◆ sorter

checkxAOD.sorter

Definition at line 154 of file Tools/PyUtils/bin/checkxAOD.py.

◆ summedData

checkxAOD.summedData

Definition at line 119 of file Tools/PyUtils/bin/checkxAOD.py.

◆ totDiskSize

checkxAOD.totDiskSize

Definition at line 258 of file Tools/PyUtils/bin/checkxAOD.py.

◆ typeName

checkxAOD.typeName

Definition at line 149 of file Tools/PyUtils/bin/checkxAOD.py.

◆ usage

checkxAOD.usage

Definition at line 24 of file Tools/PyUtils/bin/checkxAOD.py.

◆ writer

checkxAOD.writer

Definition at line 317 of file Tools/PyUtils/bin/checkxAOD.py.

vtune_athena.format
format
Definition: vtune_athena.py:14
checkxAOD.main
def main()
C(++) style main function.
Definition: Control/xAODRootAccess/scripts/checkxAOD.py:21
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
checkxAOD.printFileInfo
def printFileInfo(fileName, categoryStrings)
Function printing information about a single xAOD file.
Definition: Control/xAODRootAccess/scripts/checkxAOD.py:113
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10