Dear ROOT experts,
I would like to do a simple “homework” which opens several root files, takes a histo and calculates the integral in a certain range. Below is the code.
const int N = 50;
int count = 0;
int i1 = 1;
double temp1, temp2, temp3;
double arr1[N];
double arr2[N];
double arr3[N];
char filename1[350], filename2[350], filename3[350];
// open the files
while (i1<50) {
temp1 = 0.; temp2 = 0.; temp3 = 0.;
sprintf(filename1,"../rootFiles_%d/test1.root",i1);
f1 = new TFile(filename1,"READONLY");
f1->cd("folder1");
TH1D* hAlphaT1 = (TH1D*)gDirectory->Get("histo");
h1->GetXaxis()->SetRangeUser(0.45,2);
temp1 = h1->Integral();
h1->Delete();
sprintf(filename2,"../rootFiles_%d/test2.root",i1);
f2 = new TFile(filename2,"READONLY");
f2->cd("folder1");
TH1D* h2 = (TH1D*)gDirectory->Get("histo");
h2->GetXaxis()->SetRangeUser(0.45,2);
temp2 = h2->Integral();
h2->Delete();
arr1[count] = temp1;
arr2[count] = temp2;
arr3[count] = temp3;
i1 += 5;
count += 1;
}
f1->Delete();
f2->Delete();
the execution stops because I get a segmentation violation error. It loops 7 times and then displays the following error…
*** Break *** segmentation violation
(no debugging symbols found)
Using host libthread_db library "/lib64/tls/libthread_db.so.1".
Attaching to program: /proc/4657/exe, process 4657
(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New Thread 4149835456 (LWP 4657)]
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
(no debugging symbols found)...done.
0xffffe410 in __kernel_vsyscall
()
#1 0x007074b3 in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x006b0779 in do_system () from /lib/tls/libc.so.6
#3 0x007e398d in system () from /lib/tls/libpthread.so.0
...
...
...
Could you please help me on this ?
thanks in advance,
loukas