Skip to content

Commit 44a9ccf

Browse files
mgheatachiarazampolli
authored andcommitted
Scripts to compute size and compression for a list of AO2D.root trees.
1 parent 9b8d5f4 commit 44a9ccf

File tree

3 files changed

+201
-0
lines changed

3 files changed

+201
-0
lines changed

UTILS/aod-size/counttracks.C

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
void countperfile(const char *filename, size_t &ntracks, size_t &nevents, size_t &nbc) {
2+
TFile *file = TFile::Open(filename);
3+
if (!file) {
4+
printf("counttracks could not open file %s\n", filename);
5+
}
6+
ntracks = 0;
7+
nevents = 0;
8+
nbc = 0;
9+
TIter next(file->GetListOfKeys());
10+
TKey *key;
11+
while ((key = (TKey*)next())) {
12+
TString tname = TString::Format("%s/O2track", key->GetName());
13+
TString ename = TString::Format("%s/O2collision", key->GetName());
14+
TString bcname = TString::Format("%s/O2bc", key->GetName());
15+
16+
TTree *tree_tracks = (TTree*) file->Get(tname);
17+
TTree *tree_events = (TTree*) file->Get(ename);
18+
TTree *tree_bc = (TTree*) file->Get(bcname);
19+
if (tree_events) {
20+
ntracks += tree_tracks->GetEntries();
21+
nevents += tree_events->GetEntries();
22+
if (tree_bc) nbc += tree_bc->GetEntries();
23+
}
24+
}
25+
printf("events: %zu bc: %zu tracks: %zu\n", nevents, nbc, ntracks);
26+
}
27+
28+
void counttracks(const char *filenames)
29+
{
30+
TString sfname(filenames);
31+
if (sfname.BeginsWith("alien"))
32+
TGrid::Connect("alien:");
33+
TObjArray *list = sfname.Tokenize(" ");
34+
size_t ntracks, nevents, nbc;
35+
size_t ntrackstot=0, neventstot=0, nbctot=0;
36+
for (int i = 0; i < list->GetEntriesFast(); i++) {
37+
TString filename = list->At(i)->GetName();
38+
if (filename.Length() < 2) continue;
39+
//printf("%s\n", filename.Data());
40+
countperfile(filename.Data(), ntracks, nevents, nbc);
41+
ntrackstot += ntracks;
42+
neventstot += nevents;
43+
nbctot += nbc;
44+
}
45+
printf("eventstot: %zu bctot: %zu trackstot: %zu\n", neventstot, nbctot, ntrackstot);
46+
}

UTILS/aod-size/counttracks.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# This script counts the number of events, bc's and tracks in a list of AO2D.root files.
4+
# run as: counttracks.sh [file1] [file2] ...
5+
# Remote file locations should be specified as: alien:///alice/.../AO2D.root
6+
7+
LIST=""
8+
for var in "$@"
9+
do
10+
LIST+="$var "
11+
done
12+
13+
LIST=\"$LIST\"
14+
15+
root.exe -b -q -l counttracks.C\("$LIST"\)

UTILS/aod-size/size_ao2d.pl

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/perl
2+
3+
# Run as: perl size_ao2d.pl [file1] [file2] ...
4+
# file1, file2, ... have to be local or remote AO2D.root files
5+
# Remote file locations should be specified as: alien:///alice/.../AO2D.root
6+
7+
use warnings;
8+
use strict;
9+
10+
my @tableNames = ("O2bc",
11+
"O2fdd",
12+
"O2collision",
13+
"O2track.par",
14+
"O2track.parcov",
15+
"O2track.extra",
16+
"O2zdc",
17+
"O2v0",
18+
"O2fv0a",
19+
"O2fv0c",
20+
"O2ft0",
21+
"O2cascade",
22+
"O2calo",
23+
"O2calotrigger",
24+
"O2muon",
25+
"O2muoncluster",
26+
"O2mcparticle",
27+
"O2mccollision",
28+
"O2mccalolabel",
29+
"O2mctracklabel",
30+
"O2mccollisionlabel"
31+
#"O2tof"
32+
#"O2mcparticle", "O2mccollision", "O2mccalolabel", "O2mctracklabel", "O2mccollisionlabel"
33+
#"DbgEventExtra"
34+
);
35+
36+
# my %totalSize = map { $_ => 0 } @tableNames;
37+
# my %comprSize = map { $_ => 0 } @tableNames;
38+
39+
my %fields = (
40+
"par" => ["CollisionsID", "TrackType",
41+
"X", "Alpha",
42+
"Y", "Z", "Snp", "Tgl",
43+
"Signed1Pt",
44+
],
45+
"parcov" => [ "SigmaY", "SigmaZ", "SigmaSnp", "SigmaTgl", "Sigma1Pt", "RhoZY", "RhoSnpY",
46+
"RhoSnpZ", "RhoTglY", "RhoTglZ", "RhoTglSnp", "Rho1PtY", "Rho1PtZ",
47+
"Rho1PtSnp", "Rho1PtTgl",
48+
],
49+
"extra" => [ "TPCInnerParam", "Flags", "ITSClusterMap",
50+
"TPCNClsFindable", "TPCNClsFindableMinusFound", "TPCNClsFindableMinusCrossedRows",
51+
"TPCNClsShared", "TRDPattern", "ITSChi2NCl",
52+
"TPCChi2NCl", "TRDChi2", "TOFChi2",
53+
"TPCSignal", "TRDSignal", "TOFSignal", "Length", "TOFExpMom", "TrackEtaEMCAL", "TrackPhiEMCAL"
54+
]
55+
);
56+
57+
my $totalU = 0;
58+
my $totalC = 0;
59+
60+
for (@tableNames) {
61+
my $table = $_;
62+
my $O2table = undef;
63+
if (/(.*)\.(.*)/) {
64+
#tree name (O2bc, ...)
65+
$table = $1;
66+
# fields name (par, parcov or extra)
67+
$O2table = $2;
68+
#print "### 1 = $table 2 = $O2table ### \n";
69+
}
70+
71+
my $uncompressed = 0;
72+
my $compressed = 0;
73+
74+
my @branch_names;
75+
my @uncompressed_br = (0) x 200;
76+
my @compressed_br = (0) x 200;
77+
my $arr_ind = 0;
78+
my $nbranches = 0;
79+
my $pass = 0;
80+
81+
for (@ARGV) {
82+
83+
my @treeInfo = `root -b -q treeinfo.C'("$_", "$table")'`;
84+
85+
$arr_ind = -1;
86+
# print %size;
87+
88+
my $adding = 0;
89+
for (@treeInfo)
90+
{
91+
if (/\*Br/) {
92+
$arr_ind += 1;
93+
$adding = 0;
94+
my @elem = split ":";
95+
# branch name
96+
$elem[1] =~ s/\s//g;
97+
$branch_names[$arr_ind] = "${table}.$elem[1]" if ($pass == 0);
98+
99+
if (defined $O2table) {
100+
for (@{$fields{$O2table}}) {
101+
$adding = 1 if ("f$_" eq $elem[1]);
102+
}
103+
#print $O2table, " branch=", $elem[1], " adding=",$adding,"\n";
104+
} else {
105+
$adding = 1;
106+
}
107+
}
108+
109+
$uncompressed += $1 if ($adding && /Total Size=\s+(\d+) bytes/);
110+
$compressed += $1 if ($adding && /File Size =\s+(\d+)/);
111+
112+
$uncompressed_br[$arr_ind] += $1 if (/Total Size=\s+(\d+) bytes/);
113+
$compressed_br[$arr_ind] += $1 if (/File Size =\s+(\d+)/);
114+
}
115+
$pass += 1;
116+
}
117+
118+
print "$_ \t $uncompressed \t $compressed \t";
119+
print ($uncompressed / $compressed) if ($compressed > 0);
120+
print "\n";
121+
122+
# print branch Compression
123+
for my $i (0 .. $arr_ind)
124+
{
125+
#print "$branch_names[$i] \t $uncompressed_br[$i] \t $compressed_br[$i] \t";
126+
#print ($uncompressed_br[$i] / $compressed_br[$i]) if ($compressed_br[$i] > 0);
127+
#print "\n";
128+
}
129+
130+
131+
$totalU += $uncompressed;
132+
$totalC += $compressed;
133+
# last;
134+
}
135+
136+
print "Total \t $totalU \t $totalC \t " . ($totalU / $totalC) . "\n";
137+
138+
# *Br 0 :fCollisionsID : fCollisionsID/I *
139+
# *Entries : 992709 : Total Size= 4077499 bytes File Size = 139185 *
140+
# *Baskets : 992 : Basket Size= 4096 bytes Compression= 29.10 *

0 commit comments

Comments
 (0)