List determinated KEY (Histogram) inside a root file

I have a file.root with a lot histograms inside and i want to list only the TH2F histograms from a remote host on console.

I tried with:

TFile f(file.root)
.L Macro.C

there is no subdirectories in the root file, i wonder if there is some other feature of ls command like f->ls("TH2F")


$f ? what does that mean ?

I ran:

void buscaHIST (TDirectory *dir) {

TIter nextkey (dir->GetListOfKeys());

TKey *key;

while ((key = (TKey*)nextkey())) { 
if (strstr(key->GetClassName(),"TH2F")) {
printf (" %s :: %s :: %s\n",key->GetName(),key->GetClassName(),dir->GetPath());

if (!strcmp(key->GetClassName(),"TDirectoryFile")) {
TDirectory *subdir = gDirectory;

This is the error:

root [0] TFile *f = TFile::Open("input.root")
(TFile *) 0x26e6960
root [1] .L buscaHIST.C
root [2] buscaHIST(&f)
ROOT_prompt_2:1:1: error: no matching function for call to 'buscaHIST'
directoriemine/run/buscaHIST.C:1:6: note: candidate function not viable: no known conversion from 'TFile **' to 'TDirectory *' for 1st argument; remove &
void buscaHIST (TDirectory *dir) {

(there is not subdirectories on the root file)

As f is already a point and your function takes a pointer as input,
can you try:

root [2] buscaHIST(f)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.