ATLAS Offline Software
Loading...
Searching...
No Matches
checkxAOD Namespace Reference

Classes

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

Functions

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

Variables

str __author__
 parser = OptionParser( usage = "usage: %prog [OPTION]... my.xAOD.file.pool.root" )
 p = parser.add_option
 action
 dest
 help
 options
 args = {'newline' : ''}
dict categoryStrings
list fileNames = []
 fileName = os.path.expandvars( os.path.expanduser( options.fileName ) )
 kb
str sizeUnits = "kB"
 auxvarptn = re.compile( r"Aux(?:Dyn)?(?:\.|:)" )
 poolFile = PF.PoolFile( fileName )
dict summedData = {}
dict categData = {}
 brName = d.name
 m = auxvarptn.search( d.name )
 file
 typeName
list orderedData = [rec for rec in summedData.values()]
 sorter = PF.PoolRecord.Sorter.DiskSize
 key
float memSize = 0.0
float diskSize = 0.0
str mtlp = re.search( "_tlp.$", d.name ) or "DataHeader" in d.name
 colTypeName = d.typeName
 d_name = m.group(1)
str nameType = "%s (%s)" % (d_name, colTypeName)
 catName = categ
 categorizedData = list(categData.values())
float totDiskSize = 0.0
float frac = 0.0
list ds = []
list dsFrac = []
list dsName = []
float dsPerEvt = d.diskSize / max(poolFile.dataHeader.nEntries,1)
float dsPerCatFrac = d.diskSize / diskSize
list b = ['{:.3f}'.format(i) for i in reversed(ds)]
 writer = csv.writer( f )

Function Documentation

◆ main()

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.

21def 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
STL class.
int main()
Definition hello.cxx:18

◆ printFileInfo()

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.

113def 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( r"(.*)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( r"(.*)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":
void print(char *figname, TCanvas *c1)

Variable Documentation

◆ __author__

str checkxAOD.__author__
private
Initial value:
1= "Sebastien Binet <binet@cern.ch>, " \
2 "Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>, " \
3 "RD Schaffer R.D.Schaffer@cern.ch"

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

dict checkxAOD.args = {'newline' : ''}

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

◆ auxvarptn

checkxAOD.auxvarptn = re.compile( r"Aux(?:Dyn)?(?:\.|:)" )

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

◆ b

list checkxAOD.b = ['{:.3f}'.format(i) for i in reversed(ds)]

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

◆ brName

checkxAOD.brName = d.name

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

◆ categData

dict checkxAOD.categData = {}

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

◆ categorizedData

checkxAOD.categorizedData = list(categData.values())

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

◆ categoryStrings

dict checkxAOD.categoryStrings

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

◆ catName

str checkxAOD.catName = categ

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

◆ colTypeName

checkxAOD.colTypeName = d.typeName

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

◆ d_name

checkxAOD.d_name = m.group(1)

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

float checkxAOD.diskSize = 0.0

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

◆ ds

list checkxAOD.ds = []

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

◆ dsFrac

list checkxAOD.dsFrac = []

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

◆ dsName

list checkxAOD.dsName = []

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

◆ dsPerCatFrac

float checkxAOD.dsPerCatFrac = d.diskSize / diskSize

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

◆ dsPerEvt

float checkxAOD.dsPerEvt = d.diskSize / max(poolFile.dataHeader.nEntries,1)

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 = os.path.expandvars( os.path.expanduser( options.fileName ) )

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

◆ fileNames

list checkxAOD.fileNames = []

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

◆ frac

float checkxAOD.frac = 0.0

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 = auxvarptn.search( d.name )

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

◆ memSize

float checkxAOD.memSize = 0.0

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

◆ mtlp

str checkxAOD.mtlp = re.search( "_tlp.$", d.name ) or "DataHeader" in d.name

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

◆ nameType

str checkxAOD.nameType = "%s (%s)" % (d_name, colTypeName)

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

list checkxAOD.orderedData = [rec for rec in summedData.values()]

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

◆ p

checkxAOD.p = parser.add_option

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

◆ parser

checkxAOD.parser = OptionParser( usage = "usage: %prog [OPTION]... my.xAOD.file.pool.root" )

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

◆ poolFile

checkxAOD.poolFile = PF.PoolFile( fileName )

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

◆ sizeUnits

str checkxAOD.sizeUnits = "kB"

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

◆ sorter

checkxAOD.sorter = PF.PoolRecord.Sorter.DiskSize

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

◆ summedData

dict checkxAOD.summedData = {}

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

◆ totDiskSize

float checkxAOD.totDiskSize = 0.0

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.

◆ writer

checkxAOD.writer = csv.writer( f )

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