symstu
September 30, 2014, 6:53pm
1
void copytree(){
gROOT->Reset();
TChain * chains=new TChain("orange");
chains->Add("/home/maks/HERA2/Mini_HERA2_V08b_04.root");
Float_t Z_Eventnr;
chains->SetBranchAddress("Eventnr", &Z_Eventnr);
Float_t Z_Runnr;
chains->SetBranchAddress("Runnr", &Z_Runnr);
Float_t Z_Sincand;
chains->SetBranchAddress("Sincand", &Z_Sincand);
Float_t Z_Siprob;
chains->SetBranchAddress("Siprob", &Z_Siprob);
Float_t Z_Siyel;
chains->SetBranchAddress("Siyel", &Z_Siyel);
Float_t Z_Tltw;
chains->SetBranchAddress("Tltw", &Z_Tltw);
Float_t Z_Zvtx;
chains->SetBranchAddress("Zvtx", &Z_Zvtx);
Float_t Z_Cal_tb ;
chains->SetBranchAddress("Cal_tb", &Z_Cal_tb);
Float_t Z_Cal_pt;
chains->SetBranchAddress("Cal_pt", &Z_Cal_pt);
Float_t Z_Cc_yjb;
chains->SetBranchAddress("Cc_yjb", &Z_Cc_yjb);
Float_t Z_Etamax_zu4;
chains->SetBranchAddress("Etamax_zu4", &Z_Etamax_zu4);
Float_t Z_Trk_px;
chains->SetBranchAddress("Trk_px", &Z_Trk_px);
Float_t Z_Trk_py;
chains->SetBranchAddress("Trk_py", &Z_Trk_py);
Float_t Z_Trk_pz;
chains->SetBranchAddress("Trk_pz", &Z_Trk_pz);
Float_t Z_Nzufos;
chains->SetBranchAddress("Nzufos", &Z_Nzufos);
Float_t Z_Tufo;
chains->SetBranchAddress("Tufo", &Z_Tufo);
Float_t Z_Zufo;
chains->SetBranchAddress("Zufo", &Z_Zufo);
Float_t Z_Zufo_deltaz;
chains->SetBranchAddress("Zufo_deltaz", &Z_Zufo_deltaz);
Float_t Z_Zufoeemc;
chains->SetBranchAddress("Zufoeemc", &Z_Zufoeemc);
Float_t Z_Zufoecal;
chains->SetBranchAddress("Zufoecal", &Z_Zufoecal);
Float_t Z_Zufo_fmax_bemc;
chains->SetBranchAddress("Zufo_fmax_bemc", &Z_Zufo_fmax_bemc);
Float_t Z_Trk_ntracks;
chains->SetBranchAddress("Trk_ntracks", &Z_Trk_ntracks);
chains->SetBranchStatus("*",0);
chains->SetBranchStatus("Runnr",1);
chains->SetBranchStatus("Eventnr",1);
chains->SetBranchStatus("Nzufos",1);
chains->SetBranchStatus("Zufo",1);
chains->SetBranchStatus("Zufo_deltaz",1);
chains->SetBranchStatus("Etamax_zu4",1);
TFile *newfile = new TFile("tree.root","recreate");
TTree *newtree = chains->CloneTree();
newtree->Print();
newfile->Write();
delete oldfile;
delete newfile;
delete chains;
//return 0;
}
After compiling i have this errors:
Warning in : /usr/share/root/macros is not writable!
Warning in : Output will be written to /tmp/maks
Info in TUnixSystem::ACLiC : creating shared library /tmp/maks//usr/share/root/macros/copytree_c.so
In file included from /tmp/maks//usr/share/root/macros/copytree_c_ACLiC_dict.h:34:0,
from /tmp/maks//usr/share/root/macros/copytree_c_ACLiC_dict.cxx:17:
/usr/share/root/macros/copytree.c: In function ‘void copytree()’:
/usr/share/root/macros/copytree.c:7:2: error: ‘gROOT’ was not declared in this scope
gROOT->Reset();
^
/usr/share/root/macros/copytree.c:9:2: error: ‘TChain’ was not declared in this scope
TChain * chains=new TChain(“orange”);
^
/usr/share/root/macros/copytree.c:9:11: error: ‘chains’ was not declared in this scope
TChain * chains=new TChain(“orange”);
^
/usr/share/root/macros/copytree.c:9:22: error: expected type-specifier before ‘TChain’
TChain * chains=new TChain(“orange”);
^
/usr/share/root/macros/copytree.c:9:22: error: expected ‘;’ before ‘TChain’
/usr/share/root/macros/copytree.c:65:2: error: ‘TFile’ was not declared in this scope
TFile *newfile = new TFile(“tree.root”,“recreate”);
^
/usr/share/root/macros/copytree.c:65:9: error: ‘newfile’ was not declared in this scope
TFile *newfile = new TFile(“tree.root”,“recreate”);
^
/usr/share/root/macros/copytree.c:65:23: error: expected type-specifier before ‘TFile’
TFile *newfile = new TFile(“tree.root”,“recreate”);
^
/usr/share/root/macros/copytree.c:65:23: error: expected ‘;’ before ‘TFile’
/usr/share/root/macros/copytree.c:66:2: error: ‘TTree’ was not declared in this scope
TTree *newtree = chains->CloneTree();
^
/usr/share/root/macros/copytree.c:66:9: error: ‘newtree’ was not declared in this scope
TTree *newtree = chains->CloneTree();
^
/usr/share/root/macros/copytree.c:71:12: error: ‘oldfile’ was not declared in this scope
delete oldfile;
^
/usr/share/root/macros/copytree.c:72:12: error: type ‘’ argument given to ‘delete’, expected pointer
delete newfile;
^
/usr/share/root/macros/copytree.c:73:9: error: type ‘’ argument given to ‘delete’, expected pointer
delete chains;
^
g++: error: /tmp/maks//usr/share/root/macros/copytree_c_ACLiC_dict.o: Нет такого файла или каталога
Error in : Compilation failed!
When i build it:
Processing /home/maks/HERA2/copytree.c…
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
#0 0x00007ffdb74f15cc in __libc_waitpid (pid=2907, stat_loc=stat_loc
entry=0x7fffdd408d00, options=options
entry=0) at …/sysdeps/unix/sysv/linux/waitpid.c:31
#1 0x00007ffdb74761d2 in do_system (line=) at …/sysdeps/posix/system.c:148
#2 0x00007ffdb83743a3 in TUnixSystem::StackTrace() () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#3 0x00007ffdb837607c in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#4
#5 0x00007ffdb65c20f8 in G__searchvariable () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#6 0x00007ffdb65d1f49 in G__letvariable(G__FastAllocString&, G__value, G__var_array*, G__var_array*, Cint::G__DataMemberHandle&) () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#7 0x00007ffdb64b819a in G__define_var () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#8 0x00007ffdb654b073 in G__exec_statement () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#9 0x00007ffdb6500d91 in G__interpret_func () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#10 0x00007ffdb64ed711 in G__getfunction () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#11 0x00007ffdb64c8262 in G__getitem () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#12 0x00007ffdb64cd715 in G__getexpr () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#13 0x00007ffdb64d901b in G__calc_internal () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#14 0x00007ffdb655cba7 in G__process_cmd () from /usr/lib/x86_64-linux-gnu/libCint.so.5.34
#15 0x00007ffdb833d830 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#16 0x00007ffdb833684b in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#17 0x00007ffdb82a6b34 in TApplication::ExecuteFile(char const*, int*, bool) () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#18 0x00007ffdb82a6012 in TApplication::ProcessLine(char const*, bool, int*) () from /usr/lib/x86_64-linux-gnu/libCore.so.5.34
#19 0x00007ffdb7f4836d in TRint::Run(bool) () from /usr/lib/x86_64-linux-gnu/libRint.so.5.34
#20 0x0000000000400fec in main ()
The crash is most likely caused by a problem in your script.
Try to compile it (.L myscript.C+g) and fix any errors.
If that does not help then please submit a bug report at
root.cern.ch/bugs . Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
Root > Function copytree() busy flag cleared
Interesting that first time it has copied branches correctly, but only one time. After it i build it and new tree creates unclosed (how i’ve understood) - in TBrowser i can’t open it. What i’m doing wrong?
P.S. Sry for my bad english.
P.P.S. OS: Ubuntu 14.04, ROOT: 5.34/14
ganis
October 12, 2014, 3:38pm
2
Hi,
Sorry for the late reply.
Not sure this post has anything to do with PROOF.
Not sure to understand your problem.
First, your script misses several includes (at least TROOT.h, TChain.h, TFile.h) and has some undefined variable (oldfile). Once you fix these you should be able to compile it.
It is not clear, then, what you would like to do in your script.
Is this to extract a Tree from a file and save it into another? Why do you think you need a TChain ?
G. Ganis