Hello all,
I am trying to loop through a folder containing about 150 ntuple root files with a TTree histogram called EdepNTuple;1 stored in each of them. My goal is to plot the histogram with log(y) axis, save the canvas of each plot and perform some analysis detailed in my code below. The output csv files should contain values of x, y, z for each of those files.
I’ve spent quite some time on my own trying to solve this issue and will really appreciate some help. The files are too many to perform this manually
void efficiencyandplots(const char *dirname="$HOME/B1-b/", const char *ext=".root"){
char* dir = gSystem->ExpandPathName(dirname);
void* dirp = gSystem->OpenDirectory(dir);
const char* entry;
Int_t n = 0;
TString str;
while((entry = (char*)gSystem->GetDirEntry(dirp))) {
str = entry;
if(str.EndsWith(ext))
TFile *f = new TFile(str,"READ");
TTree *E = (TTree*)f->Get("EdepNtuple;1");
E->Draw("Edep>>hist");
double a = hist->Integral(1,1)/hist->Integral()
double b = hist->Integral(1,20)/hist->Integral()
double c = hist->Integral(1,30)/hist->Integral()
double x = 1 - a
double y = 1 - b
double z = 1 - c
}
}