Hello,
I have recently started to use ROOT to develop my application, so I apologize if my problem has got an obvious answer for you.
While running a little test program defining a TTree in a function and calling a Scan on it from outside I get CINT to crash.
In the loop I create the TTree from a file and I scan it successfully within the function (just for testing). Once back to the main function I want to make use of this TTree and call the same scan() on it. But this second scan sends CINT crashing.
It is unclear to me whether this is a problem with my code, or my use of CINT.
Below is my code:
#include "TTree.h"
void test(){
TTree *mytree;
mytree=ReadAbe(2);
mytree->Print();
mytree->Show(8);
mytree->Scan("Chrom");
}
TTree *ReadAbe(int v) {
struct Abe_t {
Int_t Chrom;
Int_t Start_bp;
Int_t End_bp;
Float_t Len_Mb;
Char_t Start_rs[16];
Char_t End_rs[16];
Int_t N_rs;
Int_t CN;
Int_t LOH;
Float_t Max_BF;
};
Abe_t abe;
//The input file as output from my runof OncoSNP on Enric's dataset
FILE *fp = fopen("test.dat","r");
char line[500];
TFile *f = new TFile("Abe.root","RECREATE");
TTree *tree = new TTree("T","Aberrations from ascii file");
tree->Branch("Values",&abe.Chrom,"Chrom/I:Start_bp/I:End_bp/I:Len_Mb/F");
tree->Branch("Start",abe.Start_rs,"Startrs/C");
tree->Branch("End",abe.End_rs,"Endrs/C");
tree->Branch("Score",&abe.N_rs,"N_rs/I:CN/I:LOH/I:MaxBF/F");
fgets(&line,500,fp);
while (fgets(&line,500,fp)) {
sscanf(&line[0],"%d %d %d %f %s %s %d %d %d %f",&abe.Chrom,&abe.Start_bp,&abe.End_bp,&abe.Len_Mb,abe.Start_rs,abe.End_rs,&abe.N_rs,&abe.CN,&abe.LOH,&abe.Max_BF);
tree->Fill();
}
cout << "abe.LOH is "<< abe.LOH <<endl;
tree->Print();
tree->Write();
tree->Scan("Chrom:Len_Mb");
fclose(fp);
delete f;
return tree ;
}
And here is the way I call it from CINT, with the error message I get:
[code]root [2] .x test.C
abe.LOH is 1
*Tree :T : Aberrations from ascii file *
*Entries : 9 : Total = 3818 bytes File Size = 0 *
-
: : Tree compression factor = 1.00 *
*Br 0 :Values : Chrom/I:Start_bp/I:End_bp/I:Len_Mb/F *
*Entries : 9 : Total Size= 1035 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
…
*Br 1 :Start : Startrs/C *
*Entries : 9 : Total Size= 753 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
…
*Br 2 :End : Endrs/C *
*Entries : 9 : Total Size= 738 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
…
*Br 3 :Score : N_rs/I:CN/I:LOH/I:MaxBF/F *
*Entries : 9 : Total Size= 999 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
…
- Row * Chrom * Len_Mb *
-
0 * 1 * 241.80000 *
-
1 * 2 * 242.5 *
-
2 * 3 * 21.5 *
-
3 * 3 * 42.599998 *
-
4 * 3 * 132.89999 *
-
5 * 4 * 56.599998 *
-
6 * 4 * 131.80000 *
-
7 * 5 * 7 *
-
8 * 5 * 99.900001 *
*** Break *** segmentation violation
(no debugging symbols found)
Attaching to program: /proc/8521/exe, process 8521
(no debugging symbols found)…done.
[Thread debugging using libthread_db enabled]
[New Thread 0x7f6e43e556f0 (LWP 8521)]
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)…done.
(no debugging symbols found)
0x00007f6e4188c965 in waitpid () from /lib/libc.so.6
#1 0x00007f6e4182ce11 in ?? () from /lib/libc.so.6
#2 0x00007f6e434f5b90 in TUnixSystem::StackTrace () from /usr/lib/root/libCore.so.5.18
#3 0x00007f6e434f6b05 in TUnixSystem::DispatchSignals () from /usr/lib/root/libCore.so.5.18
#4
#5 0x00007f6e41b3dd70 in ?? () from /lib/libc.so.6
#6 0x00007f6e43661dd3 in ?? () from /usr/lib/root/libCore.so.5.18
#7 0x00007f6e42a5b65a in G__call_cppfunc () from /usr/lib/root/libCint.so.5.18
#8 0x00007f6e42a3bb2e in G__interpret_func () from /usr/lib/root/libCint.so.5.18
#9 0x00007f6e42a2b540 in G__getfunction () from /usr/lib/root/libCint.so.5.18
#10 0x00007f6e42ae7cc2 in G__getstructmem () from /usr/lib/root/libCint.so.5.18
#11 0x00007f6e42ae1748 in G__getvariable () from /usr/lib/root/libCint.so.5.18
#12 0x00007f6e42a012cf in G__getitem () from /usr/lib/root/libCint.so.5.18
#13 0x00007f6e42a06a29 in G__getexpr () from /usr/lib/root/libCint.so.5.18
#14 0x00007f6e42a84837 in G__exec_statement () from /usr/lib/root/libCint.so.5.18
#15 0x00007f6e42a3ca98 in G__interpret_func () from /usr/lib/root/libCint.so.5.18
#16 0x00007f6e42a2b2a6 in G__getfunction () from /usr/lib/root/libCint.so.5.18
#17 0x00007f6e42a013f2 in G__getitem () from /usr/lib/root/libCint.so.5.18
#18 0x00007f6e42a06a29 in G__getexpr () from /usr/lib/root/libCint.so.5.18
#19 0x00007f6e42a120e4 in G__calc_internal () from /usr/lib/root/libCint.so.5.18
#20 0x00007f6e42a8d779 in G__process_cmd () from /usr/lib/root/libCint.so.5.18
#21 0x00007f6e434caba5 in TCint::ProcessLine () from /usr/lib/root/libCore.so.5.18
#22 0x00007f6e43434e6a in TApplication::ExecuteFile () from /usr/lib/root/libCore.so.5.18
#23 0x00007f6e43433a87 in TApplication::ProcessLine () from /usr/lib/root/libCore.so.5.18
#24 0x00007f6e42719add in TRint::HandleTermInput () from /usr/lib/root/libRint.so.5.18
#25 0x00007f6e434f4b24 in TUnixSystem::CheckDescriptors () from /usr/lib/root/libCore.so.5.18
#26 0x00007f6e434f5141 in TUnixSystem::DispatchOneEvent () from /usr/lib/root/libCore.so.5.18
#27 0x00007f6e4348aad6 in TSystem::InnerLoop () from /usr/lib/root/libCore.so.5.18
#28 0x00007f6e4348cba4 in TSystem::Run () from /usr/lib/root/libCore.so.5.18
#29 0x00007f6e43431b9f in TApplication::Run () from /usr/lib/root/libCore.so.5.18
#30 0x00007f6e4271b09e in TRint::Run () from /usr/lib/root/libRint.so.5.18
#31 0x000000000040115d in main ()
The program is running. Quit anyway (and detach it)? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/8521/exe, process 8521
Root > Function test() busy flag cleared
[/code]
After this it hangs and I need to kill ROOT from another terminal.
Any help with the use of CINT and/or the programming will be appreciated.
Thanks
Jean-Baptiste