In [1]:
import uproot
import numpy as np
In [2]:
fileToLoad = r"/eos/project/i/insulab-como/testBeam/TB_2023_10_T9_OREO/dataForDaino/run720127.root"
Ispeziono cosa c'è dentro il file¶
In [3]:
with uproot.open(fileToLoad) as f:
for k in f:
print(k)
try:
f[k].show()
# for kk in f[k]:
# print(kk)
except:
pass
h1;1 name | typename | interpretation ---------------------+--------------------------+------------------------------- Ievent | int32_t | AsDtype('>i4') Itime | int32_t | AsDtype('>i4') Iatime | int32_t | AsDtype('>i4') N1 | int32_t | AsDtype('>i4') N2 | int32_t | AsDtype('>i4') N3 | int32_t | AsDtype('>i4') N4 | int32_t | AsDtype('>i4') N5 | int32_t | AsDtype('>i4') N6 | int32_t | AsDtype('>i4') N7 | int32_t | AsDtype('>i4') N8 | int32_t | AsDtype('>i4') N9 | int32_t | AsDtype('>i4') N10 | int32_t | AsDtype('>i4') N11 | int32_t | AsDtype('>i4') Ivfas_strip1 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip2 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip3 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip4 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip5 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip6 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip7 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip8 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip9 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_strip10 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data1 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data2 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data3 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data4 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data5 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data6 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data7 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data8 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data9 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data10 | uint16_t[] | AsJagged(AsDtype('>u2')) Ivfas_data11 | uint16_t[] | AsJagged(AsDtype('>u2')) Xinfo | float[10] | AsDtype("('>f4', (10,))") Info_plus | int32_t[10] | AsDtype("('>i4', (10,))") Info_digi | uint16_t[3][32] | AsDtype("('>u2', (3, 32))") Icrys | int32_t[8][264] | AsDtype("('>i4', (8, 264))") h2;1 name | typename | interpretation ---------------------+--------------------------+------------------------------- Idigi2 | int32_t | AsDtype('>i4') Idtime2 | int32_t | AsDtype('>i4') Idatime2 | int32_t | AsDtype('>i4') Nwdigi_730 | uint16_t[1] | AsDtype("('>u2', (1,))") Idigi_730 | uint16_t[1][4152] | AsDtype("('>u2', (1, 4152))") h100;1 h200;1 h101;1 h201;1 h102;1 h202;1 h103;1 h203;1 h104;1 h204;1 h105;1 h205;1 h106;1 h206;1 h107;1 h207;1 h108;1 h208;1 h109;1 h209;1 h110;1 h210;1 h111;1 h211;1 h112;1 h212;1 h113;1 h213;1 h114;1 h214;1 h115;1 h215;1 h116;1 h216;1 h117;1 h217;1 h1000;1 h1001;1 h1002;1 h1003;1 h1004;1 h1005;1 h1006;1 h1007;1 h1008;1 h1009;1
Il file risulta essere molto pesante: carichiamo ad esempio solo le righe tra la n. 100 e la n. 400¶
In [4]:
%%time
with uproot.open(fileToLoad) as f:
for k in f["h2"]:
# print(k)
comando = f"{k.name} = f['h2'].arrays(library = 'np', entry_start = 100, entry_stop = 400){[k.name]}"
print(comando)
exec(comando)
Idigi2 = f['h2'].arrays(library = 'np', entry_start = 100, entry_stop = 400)['Idigi2'] Idtime2 = f['h2'].arrays(library = 'np', entry_start = 100, entry_stop = 400)['Idtime2'] Idatime2 = f['h2'].arrays(library = 'np', entry_start = 100, entry_stop = 400)['Idatime2'] Nwdigi_730 = f['h2'].arrays(library = 'np', entry_start = 100, entry_stop = 400)['Nwdigi_730'] Idigi_730 = f['h2'].arrays(library = 'np', entry_start = 100, entry_stop = 400)['Idigi_730'] CPU times: user 234 ms, sys: 15.1 ms, total: 249 ms Wall time: 249 ms
In [ ]:
Verifichiamo che le dimensioni siano quelle attese
In [6]:
print(Idigi2.shape, Nwdigi_730.shape)
(300,) (300, 1)